//
// ------------------------------------------------------------------------- //
// Original Author: The Xoops Project
// Author Website : http://www.xoops.org
// License Type : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
$xoopsOption['pagetype'] = "search";
include_once("mainfile.php");
include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
$action = isset($_POST['action']) ? trim($_POST['action']) : "search";
$query = isset($_POST['query']) ? trim($_POST['query']) : "";
$andor = isset($_POST['andor']) ? trim($_POST['andor']) : "AND";
$start = isset($_POST['start']) ? intval($_POST['start']) : 0;
$mids = isset($_POST['mids']) ? $_POST['mids'] : array();
$mid = isset($_POST['mid']) ? intval($_POST['mid']) : 0;
$uid = isset($_POST['uid']) ? intval($_POST['uid']) : 0;
if (empty($uid)) {
if ( $action == "results" && $query == "" ) {
redirect_header("search.php", 1, _SR_PLZENTER);
exit();
}
if ( $action == "showall" && ($query == "" || empty($mid)) ) {
redirect_header("search.php", 1, _SR_PLZENTER);
exit();
}
}
if ( $andor != "OR" && $andor != "exact" && $andor != "AND" ) {
$andor = "AND";
}
if ($action == "results") {
if ( !is_array($mids) || count($mids) == 0 ) {
$mids = array();
$mids =& XoopsModule::getHasSearchModulesList(false);
}
if ( $andor != "exact" ) {
$queries = split(" ", $myts->oopsAddSlashesGPC($query));
} else {
$queries = array($myts->oopsAddSlashesGPC($query));
}
include_once(XOOPS_ROOT_PATH."/header.php");
OpenTable();
echo "
"._SR_SEARCHRESULTS."
";
foreach ( $mids as $mid ) {
$mid = intval($mid);
$module = new XoopsModule($mid);
$results = array();
$results = $module->search($queries, $andor, 5, 0, $uid);
echo "".$module->name()."
";
$count = count($results);
if ( !is_array($results) || ($count == 0) ) {
echo _SR_NOMATCH."";
} else {
for ($i=0; $i<$count; $i++) {
if ( isset($results[$i]['image']) || $results[$i]['image'] != "" ) {
echo "
";
} else {
echo "
";
}
echo "".$myts->makeTboxData4Show($results[$i]['title'])."
\n";
if ($results[$i]['content']) {
echo ' '.strip_tags($myts->makeTareaData4Show(strip_tags($results[$i]['content']),2,1,1)).'
';
}
echo " ";
$results[$i]['uid'] = intval($results[$i]['uid']);
if ( !empty($results[$i]['uid']) ) {
$uname = XoopsUser::getUnameFromId($results[$i]['uid']);
echo "".$uname."\n";
}
echo $results[$i]['time'] ? " (". formatTimestamp(intval($results[$i]['time'])).")" : "";
echo "
";
}
if ($count == 5) {
echo "
";
}
}
}
CloseTable();
}
if ( ($action == "search") || ($action == "results") ) {
if ( $action == "search" ) {
include_once(XOOPS_ROOT_PATH."/header.php");
}
OpenTable();
include_once("include/searchform.php");
$search_form->display();
CloseTable();
}
if ( $action == "showall" ) {
if ( $andor != "exact" ) {
$queries = split(" ", $myts->oopsAddSlashesGPC($query));
} else {
$queries = array($myts->oopsAddSlashesGPC($query));
}
include_once(XOOPS_ROOT_PATH."/header.php");
$module = new XoopsModule($mid);
$results = array();
$results = $module->search($queries, $andor, 0, 0, $uid);
$count = count($results);
if ( ($count-$start) > 20 ) {
$limit = ($start + 20);
} else {
$limit = $count;
}
OpenTable();
echo ""._SR_SEARCHRESULTS."
";
printf(_SR_FOUND, $count);
echo "
";
printf(_SR_SHOWING, ($start+1), $limit);
echo "".$module->name()."
";
for ($i=$start; $i<$limit; $i++) {
if ( isset($results[$i]['image']) && $results[$i]['image'] != "" ) {
echo "
";
} else {
echo "
";
}
echo "".$myts->makeTboxData4Show($results[$i]['title'])."
\n";
if ($results[$i]['content']) {
echo ' '.strip_tags($myts->makeTareaData4Show(strip_tags($results[$i]['content']),2,1,1)).'
';
}
echo " ";
$results[$i]['uid'] = intval($results[$i]['uid']);
if ( !empty($results[$i]['uid']) ) {
$uname = XoopsUser::getUnameFromId($results[$i]['uid']);
echo "".$uname."\n";
}
echo $results[$i]['time'] ? " (". formatTimestamp(intval($results[$i]['time'])).")" : "";
echo "
";
}
echo "";
if ($start > 0) {
$prev = ($start - 20);
echo "
|
| \n";
}
echo " | ";
if ( ($count-$start) > 20 ) {
$next = ($start + 20);
echo "
| \n";
}
echo "
";
include_once("include/searchform.php");
$search_form->display();
echo "
";
CloseTable();
}
include_once(XOOPS_ROOT_PATH."/footer.php");
?>