⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.tx_indexedsearch.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/****************************************************************  Copyright notice**  (c) 2001-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)*  All rights reserved**  This script is part of the TYPO3 project. The TYPO3 project is*  free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  The GNU General Public License can be found at*  http://www.gnu.org/copyleft/gpl.html.*  A copy is found in the textfile GPL.txt and important notices to the license*  from the author is found in LICENSE.txt distributed with these scripts.***  This script is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * Index search frontend * * $Id: class.tx_indexedsearch.php 2158 2007-02-27 13:49:53Z ohader $ * * Creates a searchform for indexed search. Indexing must be enabled * for this to make sense. * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> * @co-author	Christian Jul Jensen <christian@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * *  123: class tx_indexedsearch extends tslib_pibase *  168:     function main($content, $conf) *  200:     function initialize() *  413:     function getSearchWords($defOp) *  447:     function procSearchWordsByLexer($SWArr) * *              SECTION: Main functions *  491:     function doSearch($sWArr) *  549:     function getResultRows($sWArr,$freeIndexUid=-1) *  623:     function getResultRows_SQLpointer($sWArr,$freeIndexUid=-1) *  647:     function getDisplayResults($sWArr, $resData, $freeIndexUid=-1) *  699:     function compileResult($resultRows, $freeIndexUid=-1) * *              SECTION: Searching functions (SQL) *  800:     function getPhashList($sWArr) *  901:     function execPHashListQuery($wordSel,$plusQ='') *  921:     function sectionTableWhere() *  968:     function mediaTypeWhere() *  993:     function languageWhere() * 1005:     function freeIndexUidWhere($freeIndexUid) * 1046:     function execFinalQuery($list,$freeIndexUid=-1) * 1189:     function checkResume($row) * 1236:     function isDescending($inverse=FALSE) * 1250:     function writeSearchStat($sWArr,$count,$pt) * *              SECTION: HTML output functions * 1302:     function makeSearchForm($optValues) * 1436:     function renderSelectBoxValues($value,$optValues) * 1455:     function printRules() * 1474:     function printResultSectionLinks() * 1508:     function makeSectionHeader($id, $sectionTitleLinked, $countResultRows) * 1529:     function printResultRow($row, $headerOnly=0) * 1598:     function pi_list_browseresults($showResultCount=1,$addString='',$addPart='',$freeIndexUid=-1) * *              SECTION: Support functions for HTML output (with a minimum of fixed markup) * 1686:     function prepareResultRowTemplateData($row, $headerOnly) * 1740:     function tellUsWhatIsSeachedFor($sWArr) * 1774:     function wrapSW($str) * 1786:     function renderSelectBox($name,$value,$optValues) * 1810:     function makePointerSelector_link($str,$p,$freeIndexUid) * 1825:     function makeItemTypeIcon($it,$alt='',$specRowConf) * 1867:     function makeRating($row) * 1911:     function makeDescription($row,$noMarkup=0,$lgd=180) * 1942:     function markupSWpartsOfString($str) * 2022:     function makeTitle($row) * 2046:     function makeInfo($row,$tmplArray) * 2075:     function getSpecialConfigForRow($row) * 2099:     function makeLanguageIndication($row) * 2142:     function makeAccessIndication($id) * 2157:     function linkPage($id,$str,$row=array(),$markUpSwParams=array()) * 2201:     function getRootLine($id,$pathMP='') * 2216:     function getFirstSysDomainRecordForPage($id) * 2229:     function getPathFromPageId($id,$pathMP='') * 2281:     function getMenu($id) * 2300:     function multiplePagesType($item_type) * 2310:     function utf8_to_currentCharset($str) * 2320:     function &hookRequest($functionName) * * TOTAL FUNCTIONS: 48 * (This index is automatically created/updated by the extension "extdeveval") * */require_once(PATH_tslib.'class.tslib_pibase.php');require_once(PATH_tslib.'class.tslib_search.php');require_once(t3lib_extMgm::extPath('indexed_search').'class.indexer.php');/** * Index search frontend * * Creates a searchform for indexed search. Indexing must be enabled * for this to make sense. * * @package TYPO3 * @subpackage tx_indexedsearch * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> */class tx_indexedsearch extends tslib_pibase {	var $prefixId = 'tx_indexedsearch';        // Same as class name	var $scriptRelPath = 'pi/class.tx_indexedsearch.php';    // Path to this script relative to the extension dir.	var $extKey = 'indexed_search';    // The extension key.	var $join_pages = 0;	// See document for info about this flag...	var $defaultResultNumber = 10;	var $operator_translate_table = Array (		// case-sensitive. Defines the words, which will be operators between words		Array ('+' , 'AND'),		Array ('|' , 'OR'),		Array ('-' , 'AND NOT'),			// english#		Array ('AND' , 'AND'),#		Array ('OR' , 'OR'),#		Array ('NOT' , 'AND NOT'),	);		// Internal variable	var $wholeSiteIdList = 0;		// Root-page PIDs to search in (rl0 field where clause, see initialize() function)		// Internals:	var $sWArr = array();			// Search Words and operators	var $optValues = array();		// Selector box values for search configuration form	var $firstRow = Array();		// Will hold the first row in result - used to calculate relative hit-ratings.	var $cache_path = array();		// Caching of page path	var $cache_rl = array();		// Caching of root line data	var $fe_groups_required = array();	// Required fe_groups memberships for display of a result.	var $domain_records = array();		// Domain records (?)	var $wSelClauses = array();		// Select clauses for individual words	var $resultSections = array();		// Page tree sections for search result.	var $external_parsers = array();	// External parser objects	var $iconFileNameCache = array();	// Storage of icons....	var $lexerObj;				// Lexer object	var $templateCode;			// Will hold the content of $conf['templateFile']	var $hiddenFieldList = 'ext, type, defOp, media, order, group, lang, desc, results';	/**	 * Main function, called from TypoScript as a USER_INT object.	 *	 * @param	string		Content input, ignore (just put blank string)	 * @param	array		TypoScript configuration of the plugin!	 * @return	string		HTML code for the search form / result display.	 */	function main($content, $conf)    {			// Initialize:		$this->conf = $conf;		$this->pi_loadLL();		$this->pi_setPiVarDefaults();			// Initialize the indexer-class - just to use a few function (for making hashes)		$this->indexerObj = t3lib_div::makeInstance('tx_indexedsearch_indexer');			// Initialize:		$this->initialize();			// Do search:			// If there were any search words entered...		if (is_array($this->sWArr))	{			$content = $this->doSearch($this->sWArr);		}			// Finally compile all the content, form, messages and results:		$content = $this->makeSearchForm($this->optValues).			$this->printRules().			$content;        return $this->pi_wrapInBaseClass($content);    }	/**	 * Initialize internal variables, especially selector box values for the search form and search words	 *	 * @return	void	 */	function initialize()	{		global $TYPO3_CONF_VARS;			// Initialize external document parsers for icon display and other soft operations		if (is_array($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['external_parsers']))	{			foreach ($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['external_parsers'] as $extension => $_objRef)	{				$this->external_parsers[$extension] = &t3lib_div::getUserObj($_objRef);					// Init parser and if it returns false, unset its entry again:				if (!$this->external_parsers[$extension]->softInit($extension))	{					unset($this->external_parsers[$extension]);				}			}		}			// Init lexer (used to post-processing of search words)		$lexerObjRef = $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['lexer'] ?						$TYPO3_CONF_VARS['EXTCONF']['indexed_search']['lexer'] :						'EXT:indexed_search/class.lexer.php:&tx_indexedsearch_lexer';		$this->lexerObj = &t3lib_div::getUserObj($lexerObjRef);			// If "_sections" is set, this value overrides any existing value.		if ($this->piVars['_sections'])		$this->piVars['sections'] = $this->piVars['_sections'];			// If "_sections" is set, this value overrides any existing value.		if ($this->piVars['_freeIndexUid']!=='_')		$this->piVars['freeIndexUid'] = $this->piVars['_freeIndexUid'];			// Add previous search words to current		if ($this->piVars['sword_prev_include'] && $this->piVars['sword_prev'])	{			$this->piVars['sword'] = trim($this->piVars['sword_prev']).' '.$this->piVars['sword'];		}		$this->piVars['results'] = t3lib_div::intInRange($this->piVars['results'],1,100000,$this->defaultResultNumber);			// Selector-box values defined here:		$this->optValues = Array(			'type' => Array(				'0' => $this->pi_getLL('opt_type_0'),				'1' => $this->pi_getLL('opt_type_1'),				'2' => $this->pi_getLL('opt_type_2'),				'3' => $this->pi_getLL('opt_type_3'),				'10' => $this->pi_getLL('opt_type_10'),				'20' => $this->pi_getLL('opt_type_20'),			),			'defOp' => Array(				'0' => $this->pi_getLL('opt_defOp_0'),				'1' => $this->pi_getLL('opt_defOp_1'),			),			'sections' => Array(				'0' => $this->pi_getLL('opt_sections_0'),				'-1' => $this->pi_getLL('opt_sections_-1'),				'-2' => $this->pi_getLL('opt_sections_-2'),				'-3' => $this->pi_getLL('opt_sections_-3'),				// Here values like "rl1_" and "rl2_" + a rootlevel 1/2 id can be added to perform searches in rootlevel 1+2 specifically. The id-values can even be commaseparated. Eg. "rl1_1,2" would search for stuff inside pages on menu-level 1 which has the uid's 1 and 2.			),			'freeIndexUid' => Array(				'-1' => $this->pi_getLL('opt_freeIndexUid_-1'),				'-2' => $this->pi_getLL('opt_freeIndexUid_-2'),				'0' => $this->pi_getLL('opt_freeIndexUid_0'),			),			'media' => Array(				'-1' => $this->pi_getLL('opt_media_-1'),				'0' => $this->pi_getLL('opt_media_0'),				'-2' => $this->pi_getLL('opt_media_-2'),			),			'order' => Array(				'rank_flag' => $this->pi_getLL('opt_order_rank_flag'),				'rank_freq' => $this->pi_getLL('opt_order_rank_freq'),				'rank_first' => $this->pi_getLL('opt_order_rank_first'),				'rank_count' => $this->pi_getLL('opt_order_rank_count'),				'mtime' => $this->pi_getLL('opt_order_mtime'),				'title' => $this->pi_getLL('opt_order_title'),				'crdate' => $this->pi_getLL('opt_order_crdate'),			),			'group' => Array (				'sections' => $this->pi_getLL('opt_group_sections'),				'flat' => $this->pi_getLL('opt_group_flat'),			),			'lang' => Array (				-1 => $this->pi_getLL('opt_lang_-1'),				0 => $this->pi_getLL('opt_lang_0'),			),			'desc' => Array (				'0' => $this->pi_getLL('opt_desc_0'),				'1' => $this->pi_getLL('opt_desc_1'),			),			'results' => Array (				'10' => '10',				'20' => '20',				'50' => '50',				'100' => '100',			)		);			// Free Index Uid:		if ($this->conf['search.']['defaultFreeIndexUidList'])	{			$uidList = t3lib_div::intExplode(',', $this->conf['search.']['defaultFreeIndexUidList']);			$indexCfgRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title','index_config','uid IN ('.implode(',',$uidList).')'.$this->cObj->enableFields('index_config'),'','','','uid');			foreach ($uidList as $uidValue)	{				if (is_array($indexCfgRecords[$uidValue]))	{					$this->optValues['freeIndexUid'][$uidValue] = $indexCfgRecords[$uidValue]['title'];				}			}		}			// Add media to search in:		if (strlen(trim($this->conf['search.']['mediaList'])))	{			$mediaList = implode(',', t3lib_div::trimExplode(',', $this->conf['search.']['mediaList'], 1));		}		foreach ($this->external_parsers as $extension => $obj)	{				// Skip unwanted extensions			if ($mediaList && !t3lib_div::inList($mediaList, $extension))	{ continue; }			if ($name = $obj->searchTypeMediaTitle($extension))	{				$this->optValues['media'][$extension] = $this->pi_getLL('opt_sections_'.$extension,$name);			}		}			// Add operators for various languages			// Converts the operators to UTF-8 and lowercase		$this->operator_translate_table[] = Array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8',$GLOBALS['TSFE']->csConvObj->utf8_encode($this->pi_getLL('local_operator_AND'), $GLOBALS['TSFE']->renderCharset),'toLower') , 'AND');		$this->operator_translate_table[] = Array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8',$GLOBALS['TSFE']->csConvObj->utf8_encode($this->pi_getLL('local_operator_OR'), $GLOBALS['TSFE']->renderCharset),'toLower') , 'OR');		$this->operator_translate_table[] = Array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8',$GLOBALS['TSFE']->csConvObj->utf8_encode($this->pi_getLL('local_operator_NOT'), $GLOBALS['TSFE']->renderCharset),'toLower') , 'AND NOT');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -