|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Michael Klapper <michael.klapper@aoemedia.de> 00006 * (c) 2010-2011 Jeff Segars <jeff@webempoweredchurch.org> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * A copy is found in the textfile GPL.txt and important notices to the license 00018 * from the author is found in LICENSE.txt distributed with these scripts. 00019 * 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 00029 /** 00030 * ExtDirect Class for handling backend live search. 00031 * 00032 * @author Michael Klapper <michael.klapper@aoemedia.de> 00033 * @author Jeff Segars <jeff@webempoweredchurch.org> 00034 * @package TYPO3 00035 * @subpackage t3lib 00036 */ 00037 class extDirect_dataProvider_BackendLiveSearch { 00038 00039 /** 00040 * @var array 00041 */ 00042 protected $searchResults = array( 00043 'pageJump' => '', 00044 'searchItems' => array() 00045 ); 00046 00047 /** 00048 * @var t3lib_search_livesearch 00049 */ 00050 protected $liveSearch = null; 00051 00052 /** 00053 * @var t3lib_search_livesearch_queryParser 00054 */ 00055 protected $queryParser = null; 00056 00057 /** 00058 * Initialize the live search 00059 */ 00060 public function __construct() { 00061 // @todo Use the autoloader for this. Not sure why its not working. 00062 require_once(PATH_t3lib . 'search/class.t3lib_search_livesearch_queryParser.php'); 00063 00064 $this->liveSearch = t3lib_div::makeInstance('t3lib_search_livesearch'); 00065 $this->queryParser = t3lib_div::makeInstance('t3lib_search_livesearch_queryParser'); 00066 } 00067 00068 /** 00069 * 00070 * 00071 * @param stdClass $command 00072 * 00073 * @return array 00074 */ 00075 public function find($command) { 00076 $this->liveSearch->setStartCount($command->start); 00077 $this->liveSearch->setLimitCount($command->limit); 00078 $this->liveSearch->setQueryString($command->query); 00079 00080 // jump & edit - find page and retrieve an edit link (this is only for pages 00081 if ($this->queryParser->isValidPageJump($command->query)) { 00082 $this->searchResults['pageJump'] = $this->liveSearch->findPage($command->query); 00083 $commandQuery = $this->queryParser->getCommandForPageJump($command->query); 00084 if ($commandQuery) { 00085 $command->query = $commandQuery; 00086 } 00087 } 00088 00089 // search through the database and find records who match to the given search string 00090 $resultArray = $this->liveSearch->find($command->query); 00091 00092 foreach ($resultArray as $resultFromTable) { 00093 foreach ($resultFromTable as $item) { 00094 $this->searchResults['searchItems'][] = $item; 00095 } 00096 } 00097 00098 return $this->searchResults; 00099 } 00100 00101 } 00102 00103 ?>
1.8.0