TYPO3 CMS  TYPO3_6-2
LiveSearchDataProvider.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $searchResults = array(
28  'pageJump' => '',
29  'searchItems' => array()
30  );
31 
35  protected $liveSearch = NULL;
36 
40  protected $queryParser = NULL;
41 
45  public function __construct() {
46  $this->liveSearch = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Search\\LiveSearch\\LiveSearch');
47  $this->queryParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Search\\LiveSearch\\QueryParser');
48  }
49 
54  public function find($command) {
55  $this->liveSearch->setStartCount($command->start);
56  $this->liveSearch->setLimitCount($command->limit);
57  $this->liveSearch->setQueryString($command->query);
58  // Jump & edit - find page and retrieve an edit link (this is only for pages
59  if ($this->queryParser->isValidPageJump($command->query)) {
60  $this->searchResults['pageJump'] = $this->liveSearch->findPage($command->query);
61  $commandQuery = $this->queryParser->getCommandForPageJump($command->query);
62  if ($commandQuery) {
63  $command->query = $commandQuery;
64  }
65  }
66  // Search through the database and find records who match to the given search string
67  $resultArray = $this->liveSearch->find($command->query);
68  foreach ($resultArray as $resultFromTable) {
69  foreach ($resultFromTable as $item) {
70  $this->searchResults['searchItems'][] = $item;
71  }
72  }
73  return $this->searchResults;
74  }
75 
76 }