#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':
|
||||
if (isset($_REQUEST['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);
|
||||
} else {
|
||||
$Smarty->assign('results',false);
|
||||
|
|
|
@ -94,22 +94,31 @@ class uiHubSearch extends uiSearch {
|
|||
} // fn searchDB
|
||||
|
||||
|
||||
function getSearchResults($trtokid)
|
||||
function getSearchResults($trtokid, $andClose=TRUE)
|
||||
{
|
||||
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
|
||||
$results = $this->Base->gb->getSearchResults($trtokid);
|
||||
//echo"<pre><b>RESULTS:</b><br>";print_r($results);echo "</pre>";
|
||||
#sleep(4);
|
||||
$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)) {
|
||||
return false;
|
||||
}
|
||||
$this->results['cnt'] = $results['cnt'];
|
||||
/*
|
||||
foreach ($results['results'] as $rec) {
|
||||
// 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);
|
||||
//echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
|
||||
//echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
|
||||
return is_array($results);
|
||||
} // fn getSearchResults
|
||||
|
||||
|
|
|
@ -1695,14 +1695,16 @@ class GreenBox extends BasicStor {
|
|||
*
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @param boolean $andClose
|
||||
* if TRUE, close transport token
|
||||
* @return array
|
||||
* search result format (see localSearch)
|
||||
*/
|
||||
public function getSearchResults($trtok)
|
||||
public function getSearchResults($trtok, $andClose=TRUE)
|
||||
{
|
||||
require_once("Transport.php");
|
||||
$tr = new Transport($this);
|
||||
return $tr->getSearchResults($trtok);
|
||||
return $tr->getSearchResults($trtok, $andClose);
|
||||
} // fn getSearchResults
|
||||
|
||||
|
||||
|
|
|
@ -462,10 +462,12 @@ class Transport
|
|||
*
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @param boolean $andClose
|
||||
* if TRUE, close transport token
|
||||
* @return array
|
||||
* LS search result format (see localSearch)
|
||||
*/
|
||||
function getSearchResults($trtok)
|
||||
function getSearchResults($trtok, $andClose=TRUE)
|
||||
{
|
||||
$trec = TransportRecord::recall($this, $trtok);
|
||||
if (PEAR::isError($trec)) {
|
||||
|
@ -481,30 +483,44 @@ class Transport
|
|||
" ({$trec->row['errmsg']})"
|
||||
);
|
||||
case "closed":
|
||||
/*
|
||||
$res = file_get_contents($row['localfile']);
|
||||
$results = unserialize($res);
|
||||
return $results;
|
||||
*/
|
||||
return PEAR::raiseError(
|
||||
"Transport::getSearchResults:".
|
||||
" closed transport token ($trtok)", TRERR_TOK
|
||||
);
|
||||
case "finished":
|
||||
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:
|
||||
return PEAR::raiseError(
|
||||
"Transport::getSearchResults: not finished ($st)",
|
||||
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;
|
||||
case "metadata":
|
||||
case "searchjob":
|
||||
return TRUE; // don't close
|
||||
return TRUE; // don't close - getSearchResults should close it
|
||||
break;
|
||||
}
|
||||
$ret = $this->xmlrpcCall('archive.downloadClose',
|
||||
|
|
Loading…
Reference in New Issue