/**
  * @param stdClass $command
  * @return array
  */
 public function find($command)
 {
     $this->liveSearch->setStartCount($command->start);
     $this->liveSearch->setLimitCount($command->limit);
     $this->liveSearch->setQueryString($command->query);
     // Jump & edit - find page and retrieve an edit link (this is only for pages
     if ($this->queryParser->isValidPageJump($command->query)) {
         $this->searchResults['pageJump'] = $this->liveSearch->findPage($command->query);
         $commandQuery = $this->queryParser->getCommandForPageJump($command->query);
         if ($commandQuery) {
             $command->query = $commandQuery;
         }
     }
     // Search through the database and find records who match to the given search string
     $resultArray = $this->liveSearch->find($command->query);
     foreach ($resultArray as $resultFromTable) {
         foreach ($resultFromTable as $item) {
             $this->searchResults['searchItems'][] = $item;
         }
     }
     return $this->searchResults;
 }
Beispiel #2
0
 /**
  * Find records from database based on the given $searchQuery.
  *
  * @param string $searchQuery
  * @return array Result list of database search.
  */
 public function find($searchQuery)
 {
     $recordArray = [];
     $pageList = [];
     $mounts = $GLOBALS['BE_USER']->returnWebmounts();
     foreach ($mounts as $pageId) {
         $pageList[] = $this->getAvailablePageIds($pageId, self::RECURSIVE_PAGE_LEVEL);
     }
     $pageIdList = array_unique(explode(',', implode(',', $pageList)));
     unset($pageList);
     if ($this->queryParser->isValidCommand($searchQuery)) {
         $this->setQueryString($this->queryParser->getSearchQueryValue($searchQuery));
         $tableName = $this->queryParser->getTableNameFromCommand($searchQuery);
         if ($tableName) {
             $recordArray[] = $this->findByTable($tableName, $pageIdList, $this->startCount, $this->limitCount);
         }
     } else {
         $this->setQueryString($searchQuery);
         $recordArray = $this->findByGlobalTableList($pageIdList);
     }
     return $recordArray;
 }