/**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // get search conditions
     $conditions = $this->getConditions();
     // check query and author
     if (empty($this->query) && empty($this->username) && !$this->userID) {
         throw new UserInputException('q');
     }
     // build search hash
     $this->searchHash = StringUtil::getHash(serialize(array($this->query, $this->types, !$this->subjectOnly, $conditions, $this->sortField . ' ' . $this->sortOrder, PACKAGE_ID)));
     // check search hash
     if (!empty($this->query)) {
         $sql = "SELECT\tsearchID\n\t\t\t\tFROM\twcf" . WCF_N . "_search\n\t\t\t\tWHERE\tsearchHash = '" . $this->searchHash . "'\n\t\t\t\t\tAND userID = " . WCF::getUser()->userID . "\n\t\t\t\t\tAND searchType = 'messages'\n\t\t\t\t\tAND searchDate > " . (TIME_NOW - 1800);
         $row = WCF::getDB()->getFirstRow($sql);
         if (isset($row['searchID'])) {
             HeaderUtil::redirect('index.php?form=Search&searchID=' . $row['searchID'] . '&highlight=' . urlencode($this->query) . SID_ARG_2ND_NOT_ENCODED);
             exit;
         }
     }
     // do search
     $this->result = $this->engine->search($this->query, $this->types, $conditions, $this->sortField . ' ' . $this->sortOrder);
     // result is empty
     if (count($this->result) == 0) {
         $this->throwNoMatchesException();
     }
 }
 function perform()
 {
     // get the search terms that have already been validated...
     $this->_searchTerms = $this->_request->getValue("searchTerms");
     // check if the search feature is disabled in this site...
     $config =& Config::getConfig();
     if (!$config->getValue("search_engine_enabled")) {
         $this->_view = new ErrorView($this->_blogInfo, "error_search_engine_disabled");
         $this->setCommonData();
         return false;
     }
     // create the view and make sure that it hasn't been cached
     $this->_view = new BlogTemplatedView($this->_blogInfo, VIEW_SEARCH_TEMPLATE, array("searchTerms" => $this->_searchTerms));
     if ($this->_view->isCached()) {
         return true;
     }
     $searchEngine = new SearchEngine();
     $searchResults = $searchEngine->search($this->_blogInfo->getId(), $this->_searchTerms);
     // MARKWU: I add the searchterms variable for smarty/plog template
     $searchTerms = $searchEngine->getAdaptSearchTerms($this->_searchTerms);
     // if no search results, return an error message
     if (count($searchResults) == 0) {
         $this->_view = new ErrorView($this->_blogInfo, "error_no_search_results");
         $this->setCommonData();
         return true;
     }
     // if only one search result, we can see it straight away
     if (count($searchResults) == 1) {
         // we have to refill the $_REQUEST array, since the next action
         // is going to need some of the parameters
         $request =& HttpVars::getRequest();
         $searchResult = array_pop($searchResults);
         $article = $searchResult->getArticle();
         $request["articleId"] = $article->getId();
         $request["blogId"] = $this->_blogInfo->getId();
         HttpVars::setRequest($request);
         // since there is only one article, we can use the ViewArticleAction action
         // to display that article, instead of copy-pasting the code and doing it here.
         // You just have to love MVC and OOP :)
         return Controller::setForwardAction("ViewArticle");
     }
     // or else, show a list with all the posts that match the requested
     // search terms
     $this->_view->setValue("searchresults", $searchResults);
     // MARKWU: Now, I can use the searchterms to get the keyword
     $this->_view->setValue("searchterms", $searchTerms);
     // MARKWU:
     $config =& Config::getConfig();
     $urlmode = $config->getValue("request_format_mode");
     $this->_view->setValue("urlmode", $urlmode);
     $this->setCommonData();
     return true;
 }
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once '../core/generics/State.php';
$toSearch = $_REQUEST['toSearch'];
require_once "../core/SearchEngine/SearchEngine.php";
$paramsSetted = $_GET['paramsSetted'];
$paramsValue = $_GET['paramsValues'];
$i = 0;
$arrayParams = new ArrayObject();
foreach ($paramsSetted as $param) {
    $arrayParams->offsetSet($param, $paramsValue[$i++]);
}
$search = new SearchEngine(Connection::connect());
$resultSearch = $search->search($toSearch, $arrayParams->getIterator());
if ($resultSearch->count()) {
    header('Content-type: application/json');
    $proccessSearch = null;
    if ($toSearch == "video") {
        requireVideo();
        $proccessSearch = new ProccessVideoSearch($resultSearch);
    } elseif ($toSearch == "paper") {
        requirePaper();
        $proccessSearch = new ProccessPublicationSearch($resultSearch);
    } elseif ($toSearch == 'analysis') {
        requireAnalysis();
        $proccessSearch = new ProccessAnalysisSearch($resultSearch);
    }
    $json = new JsonResponse();
    $json->response(true, $proccessSearch->getResultsFound(), TRUE);
Пример #4
0
    $smarty->assign('name', $usr['login']);
} else {
    $smarty->assign('name', "");
}
$perms;
//tableau qui stockera si l'utilisateur a certaines permissions
$perms[0] = $sys->permissions_test('admin.user.create');
$perms[1] = $sys->permissions_test('admin.user.read');
$perms[2] = $sys->permissions_test('admin.user.update');
$perms[3] = $sys->permissions_test('admin.user.delete');
$perms[4] = $sys->permissions_test('admin.picture.read');
$perms[5] = $sys->permissions_test('application.picture.upload');
$smarty->assign('perms', $perms);
if (!isset($_GET['do'])) {
    //affichage initial de toutes les photos accessibles
    $listPics = $search->search();
    $smarty->assign('tabPics', $listPics);
} else {
    $listParams = array();
    $req = array();
    $i = 0;
    if (isset($_POST['size']) && isset($_POST['paramSize']) && $_POST['size'] != "") {
        $listParams[$i] = array('size' => array($_POST['paramSize'], $_POST['size']));
        $req[$i] = $search->filter_size($_POST['paramSize'], $_POST['size']);
        echo 'requete = ' . $req[$i];
        $i++;
    }
    if (isset($_POST['listPersonnes']) && $_POST['listPersonnes'] != "") {
        $listPersonnes = explode(', ', $_POST['listPersonnes']);
        $listParams[$i] = array();
        foreach ($listPersonnes as $personne) {
Пример #5
0
<?php

require_once "include/skin.inc.php";
require_once 'include/skinlet.inc.php';
require_once "include/beContent.inc.php";
require_once "include/entities.inc.php";
require_once "include/content.inc.php";
require_once "include/control/search/searchEngine.php";
require_once realpath(dirname(__FILE__)) . '/include/view/template/InitGraphic.php';
$main = new Skin();
InitGraphic::getInstance()->createGraphic($main);
$homeTemplate = new Skinlet("search");
$engine = new SearchEngine();
if (isset($_POST["search"]) && $_POST["search"] != "") {
    $sintax = explode(":", $_POST["search"]);
    if (isset($sintax[1])) {
        $entityName = $sintax[0];
        $search = explode(" ", $sintax[1]);
    } else {
        $entityName = null;
        $search = explode(" ", $_POST["search"]);
    }
}
$homeTemplate->setContent("results", $engine->search($entityName, $search));
$homeTemplate->setContent("search_keywords", $_POST["search"]);
$homeTemplate->setContent("results_number", $engine->resultsNumber);
$main->setContent("body", $homeTemplate->get());
$main->close();