#1869 fixed hub search in web UI
This commit is contained in:
parent
4259cf0c08
commit
e316b65ac8
|
@ -248,7 +248,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
|
||||||
case 'HUBSEARCH.getResults':
|
case 'HUBSEARCH.getResults':
|
||||||
if (isset($_REQUEST['trtokid']) && $_REQUEST['trtokid']) {
|
if (isset($_REQUEST['trtokid']) && $_REQUEST['trtokid']) {
|
||||||
$Smarty->assign('trtokid',$_REQUEST['trtokid']);
|
$Smarty->assign('trtokid',$_REQUEST['trtokid']);
|
||||||
if ($uiBrowser->HUBSEARCH->getSearchResults($_REQUEST['trtokid'])) {
|
if ($uiBrowser->HUBSEARCH->getSearchResults($_REQUEST['trtokid'], FALSE)) {
|
||||||
$Smarty->assign('results',true);
|
$Smarty->assign('results',true);
|
||||||
} else {
|
} else {
|
||||||
$Smarty->assign('results',false);
|
$Smarty->assign('results',false);
|
||||||
|
|
|
@ -94,22 +94,31 @@ class uiHubSearch extends uiSearch {
|
||||||
} // fn searchDB
|
} // fn searchDB
|
||||||
|
|
||||||
|
|
||||||
function getSearchResults($trtokid)
|
function getSearchResults($trtokid, $andClose=TRUE)
|
||||||
{
|
{
|
||||||
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
|
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
|
||||||
$results = $this->Base->gb->getSearchResults($trtokid);
|
#sleep(4);
|
||||||
//echo"<pre><b>RESULTS:</b><br>";print_r($results);echo "</pre>";
|
$results = $this->Base->gb->getSearchResults($trtokid, $andClose);
|
||||||
|
// echo"<pre><b>RESULTS:</b><br>";print_r($results);echo "</pre>";
|
||||||
|
/*
|
||||||
|
if (PEAR::isError($results)) {
|
||||||
|
echo "ERROR: {$results->getMessage()} {$results->getUserInfo()}\n";
|
||||||
|
}
|
||||||
|
*/
|
||||||
if (!is_array($results) || !count($results)) {
|
if (!is_array($results) || !count($results)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->results['cnt'] = $results['cnt'];
|
$this->results['cnt'] = $results['cnt'];
|
||||||
|
/*
|
||||||
foreach ($results['results'] as $rec) {
|
foreach ($results['results'] as $rec) {
|
||||||
// TODO: maybe this getMetaInfo is not correct for the remote results
|
// TODO: maybe this getMetaInfo is not correct for the remote results
|
||||||
$this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec));
|
// yes, right :)
|
||||||
|
// $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec));
|
||||||
|
$this->results['items'][] = $rec;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
$this->results['items'] = $results['results'];
|
||||||
$this->pagination($results);
|
$this->pagination($results);
|
||||||
//echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
|
|
||||||
//echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
|
|
||||||
return is_array($results);
|
return is_array($results);
|
||||||
} // fn getSearchResults
|
} // fn getSearchResults
|
||||||
|
|
||||||
|
|
|
@ -1695,14 +1695,16 @@ class GreenBox extends BasicStor {
|
||||||
*
|
*
|
||||||
* @param string $trtok
|
* @param string $trtok
|
||||||
* transport token
|
* transport token
|
||||||
|
* @param boolean $andClose
|
||||||
|
* if TRUE, close transport token
|
||||||
* @return array
|
* @return array
|
||||||
* search result format (see localSearch)
|
* search result format (see localSearch)
|
||||||
*/
|
*/
|
||||||
public function getSearchResults($trtok)
|
public function getSearchResults($trtok, $andClose=TRUE)
|
||||||
{
|
{
|
||||||
require_once("Transport.php");
|
require_once("Transport.php");
|
||||||
$tr = new Transport($this);
|
$tr = new Transport($this);
|
||||||
return $tr->getSearchResults($trtok);
|
return $tr->getSearchResults($trtok, $andClose);
|
||||||
} // fn getSearchResults
|
} // fn getSearchResults
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -462,10 +462,12 @@ class Transport
|
||||||
*
|
*
|
||||||
* @param string $trtok
|
* @param string $trtok
|
||||||
* transport token
|
* transport token
|
||||||
|
* @param boolean $andClose
|
||||||
|
* if TRUE, close transport token
|
||||||
* @return array
|
* @return array
|
||||||
* LS search result format (see localSearch)
|
* LS search result format (see localSearch)
|
||||||
*/
|
*/
|
||||||
function getSearchResults($trtok)
|
function getSearchResults($trtok, $andClose=TRUE)
|
||||||
{
|
{
|
||||||
$trec = TransportRecord::recall($this, $trtok);
|
$trec = TransportRecord::recall($this, $trtok);
|
||||||
if (PEAR::isError($trec)) {
|
if (PEAR::isError($trec)) {
|
||||||
|
@ -481,30 +483,44 @@ class Transport
|
||||||
" ({$trec->row['errmsg']})"
|
" ({$trec->row['errmsg']})"
|
||||||
);
|
);
|
||||||
case "closed":
|
case "closed":
|
||||||
|
/*
|
||||||
|
$res = file_get_contents($row['localfile']);
|
||||||
|
$results = unserialize($res);
|
||||||
|
return $results;
|
||||||
|
*/
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Transport::getSearchResults:".
|
"Transport::getSearchResults:".
|
||||||
" closed transport token ($trtok)", TRERR_TOK
|
" closed transport token ($trtok)", TRERR_TOK
|
||||||
);
|
);
|
||||||
case "finished":
|
case "finished":
|
||||||
if ($row['direction'] == 'down') {
|
if ($row['direction'] == 'down') {
|
||||||
break; // really finished
|
// really finished
|
||||||
|
$res = file_get_contents($row['localfile']);
|
||||||
|
$results = unserialize($res);
|
||||||
|
if ($andClose) {
|
||||||
|
$ret = $this->xmlrpcCall('archive.downloadClose',
|
||||||
|
array(
|
||||||
|
'token' => $row['pdtoken'] ,
|
||||||
|
'trtype' => $row['trtype'] ,
|
||||||
|
));
|
||||||
|
if (PEAR::isError($ret)) {
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
@unlink($row['localfile']);
|
||||||
|
$r = $trec->close();
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
// otherwise only request upload finished
|
// otherwise not really finished - only request upload finished
|
||||||
default:
|
default:
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Transport::getSearchResults: not finished ($st)",
|
"Transport::getSearchResults: not finished ($st)",
|
||||||
TRERR_NOTFIN
|
TRERR_NOTFIN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$res = file_get_contents($row['localfile']);
|
|
||||||
//print_r($res);
|
|
||||||
$results = unserialize($res);
|
|
||||||
@unlink($row['localfile']);
|
|
||||||
$r = $trec->close();
|
|
||||||
if (PEAR::isError($r)) {
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1377,7 +1393,7 @@ class Transport
|
||||||
break;
|
break;
|
||||||
case "metadata":
|
case "metadata":
|
||||||
case "searchjob":
|
case "searchjob":
|
||||||
return TRUE; // don't close
|
return TRUE; // don't close - getSearchResults should close it
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$ret = $this->xmlrpcCall('archive.downloadClose',
|
$ret = $this->xmlrpcCall('archive.downloadClose',
|
||||||
|
|
Loading…
Reference in New Issue