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

📄 class.tx_indexedsearch_modfunc1.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/****************************************************************  Copyright notice**  (c) 2001-2005 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.**  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!***************************************************************//** * Module extension (addition to function menu) 'Indexed search' for the 'indexed_search' extension. * * @author    Kasper Sk錼h鴍 <kasperYYYY@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * *  106: class tx_indexedsearch_modfunc1 extends t3lib_extobjbase *  120:     function modMenu() *  144:     function main() * *              SECTION: Drawing table of indexed pages *  248:     function drawTableOfIndexedPages() *  299:     function indexed_info($data, $firstColContent) *  386:     function printPhashRow($row,$grouping=0,$extraGrListRows) *  527:     function printPhashRowHeader() *  582:     function returnNumberOfColumns() * *              SECTION: Details display, phash row *  618:     function showDetailsForPhash($phash) *  737:     function listWords($ftrows,$header, $stopWordBoxes=FALSE, $page='') *  787:     function listMetaphoneStat($ftrows,$header) *  824:     function linkWordDetails($string,$wid) *  836:     function linkMetaPhoneDetails($string,$metaphone) *  846:     function flagsMsg($flags) * *              SECTION: Details display, words / metaphone *  877:     function showDetailsForWord($wid) *  936:     function showDetailsForMetaphone($metaphone) * *              SECTION: Helper functions * 1007:     function printRemoveIndexed($phash,$alt) * 1020:     function printReindex($resultRow,$alt) * 1035:     function linkDetails($string,$phash) * 1044:     function linkList() * 1055:     function showPageDetails($string,$id) * 1065:     function printExtraGrListRows($extraGrListRows) * 1082:     function printRootlineInfo($row) * 1116:     function makeItemTypeIcon($it,$alt='') * 1141:     function utf8_to_currentCharset($string) * *              SECTION: Reindexing * 1173:     function reindexPhash($phash, $pageId) * 1227:     function getUidRootLineForClosestTemplate($id) * *              SECTION: SQL functions * 1270:     function removeIndexedPhashRow($phashList,$clearPageCache=1) * 1314:     function getGrListEntriesForPhash($phash,$gr_list) * 1334:     function processStopWords($stopWords) * 1354:     function processPageKeywords($pageKeywords, $pageUid) * * TOTAL FUNCTIONS: 30 * (This index is automatically created/updated by the extension "extdeveval") * */require_once(PATH_t3lib.'class.t3lib_pagetree.php');require_once(PATH_t3lib.'class.t3lib_extobjbase.php');require_once(t3lib_extMgm::extPath('indexed_search').'class.indexer.php');	// ... all for the rootline!require_once (PATH_t3lib."class.t3lib_page.php");require_once (PATH_t3lib."class.t3lib_tstemplate.php");require_once (PATH_t3lib."class.t3lib_tsparser_ext.php");	// Keywords mgm:require_once (PATH_t3lib."class.t3lib_tcemain.php");/** * Indexing class for TYPO3 frontend * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage tx_indexedsearch */class tx_indexedsearch_modfunc1 extends t3lib_extobjbase {		// Internal, dynamic:	var $allPhashListed = array();		// phash values accumulations for link to clear all	var $external_parsers = array();	// External content parsers - objects set here with file extensions as keys.	var $iconFileNameCache = array();	// File extensions - icon map/cache.	var $indexerObj;					// Indexer object	/**	 * Initialize menu array internally	 *	 * @return	void	 */	function modMenu()	{		global $LANG;		return array (			'depth' => array(				0 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'),				1 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'),				2 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'),				3 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'),				999 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'),			),			'type' => array(				0 => 'Overview',				1 => 'Technical Details',				2 => 'Words and content',			)		);	}	/**	 * Produces main content of the module	 *	 * @return	string		HTML output	 */	function main()	{			// Initializes the module. Done in this function because we may need to re-initialize if data is submitted!		global $LANG,$TYPO3_CONF_VARS;			// Return if no page id:		if ($this->pObj->id<=0)		return;			// Initialize max-list items		$this->maxListPerPage = t3lib_div::_GP('listALL') ? 100000 : 100;			// Processing deletion of phash rows:		if (t3lib_div::_GP('deletePhash'))	{			$this->removeIndexedPhashRow(t3lib_div::_GP('deletePhash'));		}			// Processing stop-words:		if (t3lib_div::_POST('_stopwords'))	{			$this->processStopWords(t3lib_div::_POST('stopWord'));		}			// Processing stop-words:		if (t3lib_div::_POST('_pageKeywords'))	{			$this->processPageKeywords(t3lib_div::_POST('pageKeyword'), t3lib_div::_POST('pageKeyword_pageUid'));		}			// Initialize external document parsers:			// Example configuration, see ext_localconf.php of this file!		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]);				}			}		}			// Initialize indexer if we need it (metaphone display does...)		$this->indexerObj = &t3lib_div::makeInstance('tx_indexedsearch_indexer');			// Set CSS styles specific for this document:		$this->pObj->content = str_replace('/*###POSTCSSMARKER###*/','			TABLE.c-list TR TD { white-space: nowrap; vertical-align: top; }		',$this->pObj->content);			// Check if details for a phash record should be shown:		if (t3lib_div::_GET('phash'))	{				// Show title / function menu:			$theOutput.=$this->pObj->doc->spacer(5);			$theOutput.=$this->pObj->doc->section('Details for a single result row:',$this->showDetailsForPhash(t3lib_div::_GET('phash')),0,1);		} elseif (t3lib_div::_GET('wid'))	{				// Show title / function menu:			$theOutput.=$this->pObj->doc->spacer(5);			$theOutput.=$this->pObj->doc->section('Details for a word:',$this->showDetailsForWord(t3lib_div::_GET('wid')),0,1);		} elseif (t3lib_div::_GET('metaphone'))	{				// Show title / function menu:			$theOutput.=$this->pObj->doc->spacer(5);			$theOutput.=$this->pObj->doc->section('Details for metaphone value:',$this->showDetailsForMetaphone(t3lib_div::_GET('metaphone')),0,1);		} elseif (t3lib_div::_GET('reindex'))	{				// Show title / function menu:			$theOutput.=$this->pObj->doc->spacer(5);			$theOutput.=$this->pObj->doc->section('Reindexing...',$this->reindexPhash(t3lib_div::_GET('reindex'),t3lib_div::_GET('reindex_id')),0,1);		} else {	// Detail listings:				// Depth function menu:			$h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[type]',$this->pObj->MOD_SETTINGS['type'],$this->pObj->MOD_MENU['type'],'index.php');			$h_func.= t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[depth]',$this->pObj->MOD_SETTINGS['depth'],$this->pObj->MOD_MENU['depth'],'index.php');				// Show title / function menu:			$theOutput.=$this->pObj->doc->spacer(5);			$theOutput.=$this->pObj->doc->section($LANG->getLL('title'),$h_func,0,1);			$theOutput.=$this->drawTableOfIndexedPages();		}        return $theOutput;    }	/*******************************	 *	 * Drawing table of indexed pages	 *	 ******************************/	/**	 * Produces a table with indexing information for each page.	 *	 * @return	string		HTML output	 */	function drawTableOfIndexedPages()	{		global $BACK_PATH;			// Drawing tree:		$tree = t3lib_div::makeInstance('t3lib_pageTree');		$perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);		$tree->init('AND '.$perms_clause);		$HTML = '<img src="'.$BACK_PATH.t3lib_iconWorks::getIcon('pages',$this->pObj->pageinfo).'" width="18" height="16" align="top" alt="" />';		$tree->tree[] = Array(			'row' => $this->pObj->pageinfo,			'HTML' => $HTML		);		if ($this->pObj->MOD_SETTINGS['depth'])	{			$tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], '');		}			// Traverse page tree:		$code = '';		foreach($tree->tree as $data)	{			$code.= $this->indexed_info(						$data['row'],						$data['HTML'].							$this->showPageDetails(t3lib_div::fixed_lgd_cs($data['row']['title'], 20),$data['row']['uid'])					);		}		if ($code)	{			$code = '<br/><br/>					<table border="0" cellspacing="1" cellpadding="2" class="c-list">'.						$this->printPhashRowHeader().						$code.					'</table>';				// Create section to output:			$theOutput.=$this->pObj->doc->section('',$code,0,1);		} else {			$theOutput.=$this->pObj->doc->section('','<br/><br/>'.$this->pObj->doc->icons(1).'There were no indexed pages found in the tree.<br/><br/>',0,1);		}		return 	$theOutput;	}	/**	 * Create information table row for a page regarding indexing information.	 *	 * @param	array		Data array for this page	 * @param	string		HTML content for first column (page tree icon etc.)	 * @return	string		HTML code. (table row)	 */	function indexed_info($data, $firstColContent)	{			// Query:		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(					'ISEC.*, IP.*, count(*) AS count_val',					'index_phash IP, index_section ISEC',					'IP.phash = ISEC.phash AND ISEC.page_id = '.intval($data['uid']),					'IP.phash,IP.phash_grouping,IP.cHashParams,IP.data_filename,IP.data_page_id,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2,ISEC.page_id,ISEC.uniqid,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId',					'IP.item_type, IP.tstamp',					($this->maxListPerPage+1)				);			// Initialize variables:		$rowCount = 0;		$lines = array();		// Collecting HTML rows here.		$phashAcc = array();	// Collecting phash values (to remove local indexing for)		$phashAcc[] = 0;			// Traverse the result set of phash rows selected:		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{			if ($rowCount == $this->maxListPerPage)	{				$rowCount++;	// Increase to the extra warning row will appear as well.				break;			}				// Adds a display row:			$lines[$row['phash_grouping']][] = $this->printPhashRow(						$row,						isset($lines[$row['phash_grouping']]),						$this->getGrListEntriesForPhash($row['phash'], $row['gr_list'])					);			$rowCount++;			$phashAcc[] = $row['phash'];			$this->allPhashListed[] = $row['phash'];	// For removing all shown phash rows.		}			// Compile rows into the table:		$out = '';		$cellAttrib = ($data['_CSSCLASS'] ? ' class="'.$data['_CSSCLASS'].'"' : '');		if (count($lines))	{			$firstColContent = '<td rowspan="'.$rowCount.'"'.$cellAttrib.'>'.$firstColContent.'</td>';			foreach($lines as $rowSet)	{				foreach($rowSet as $rows)	{					$out.='						<tr class="bgColor-20">'.$firstColContent.implode('',$rows).'</tr>';					$firstColContent = '';				}			}			if ($rowCount > $this->maxListPerPage)	{	// Now checking greater than, because we increased $rowCount before...				$out.='				<tr class="bgColor-20">					<td>&nbsp;</td>					<td colspan="'.($this->returnNumberOfColumns()-1).'">'.$this->pObj->doc->icons(3).'<span class="">There were more than '.$this->maxListPerPage.' rows. <a href="'.htmlspecialchars('index.php?id='.$this->pObj->id.'&listALL=1').'">Click here to list them ALL!</a></span></td>				</tr>';			}		} else {			$out.='				<tr class="bgColor-20">					<td'.$cellAttrib.'>'.$firstColContent.'</td>					<td colspan="'.($this->returnNumberOfColumns()-1).'"><em>Not indexed</em></td>				</tr>';		}			// Checking for phash-rows which are NOT joined with the section table:		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('IP.*', 'index_phash IP', 'IP.data_page_id = '.intval($data['uid']).' AND IP.phash NOT IN ('.implode(',',$phashAcc).')');		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{			$out.='				<tr class="typo3-red">					<td colspan="'.$this->returnNumberOfColumns().'"><b>Warning:</b> phash-row "'.$row['phash'].'" didn\'t have a representation in the index_section table!</td>				</tr>';			$this->allPhashListed[] = $row['phash'];		}		return $out;	}	/**	 * Render a single row of information about a indexing entry.	 *	 * @param	array		Row from query (combined phash table with sections etc).	 * @param	boolean		Set if grouped to previous result; the icon of the element is not shown again.	 * @param	array		Array of index_grlist records.	 * @return	array		Array of table rows.	 * @see indexed_info()	 */	function printPhashRow($row,$grouping=0,$extraGrListRows)	{		$lines = array();			// Title cell attributes will highlight TYPO3 pages with a slightly darker color (bgColor4) than attached medias. Also IF there are more than one section record for a phash row it will be red as a warning that something is wrong!		$titleCellAttribs = $row['count_val']!=1?' bgcolor="red"':($row['item_type']==='0' ? ' class="bgColor4"' : '');		if ($row['item_type'])	{			$arr = unserialize($row['cHashParams']);			$page = $arr['key'] ? ' ['.$arr['key'].']' : '';		} else $page = '';		$elTitle = $this->linkDetails($row['item_title'] ? htmlspecialchars(t3lib_div::fixed_lgd_cs($this->utf8_to_currentCharset($row['item_title']), 20).$page) : '<em>[No Title]</em>',$row['phash']);		$cmdLinks = $this->printRemoveIndexed($row['phash'],'Clear phash-row').$this->printReindex($row,'Re-index element');		switch($this->pObj->MOD_SETTINGS['type'])	{			case 1:		// Technical details:					// Display icon:				if (!$grouping)	{					$lines[] = '<td>'.$this->makeItemTypeIcon($row['item_type'], $row['data_filename'] ? $row['data_filename'] : $row['item_title']).'</td>';				} else {					$lines[] = '<td>&nbsp;</td>';				}					// Title displayed:				$lines[] = '<td'.$titleCellAttribs.'>'.$elTitle.'</td>';					// Remove-indexing-link:				$lines[] = '<td>'.$cmdLinks.'</td>';					// Various data:				$lines[] = '<td>'.$row['phash'].'</td>';				$lines[] = '<td>'.$row['contentHash'].'</td>';				if ($row['item_type']==='0')	{					$lines[] = '<td>'.($row['data_page_id'] ? $row['data_page_id'] : '&nbsp;').'</td>';					$lines[] = '<td>'.($row['data_page_type'] ? $row['data_page_type'] : '&nbsp;').'</td>';					$lines[] = '<td>'.($row['sys_language_uid'] ? $row['sys_language_uid'] : '&nbsp;').'</td>';					$lines[] = '<td>'.($row['data_page_mp'] ? $row['data_page_mp'] : '&nbsp;').'</td>';				} else {					$lines[] = '<td colspan="4">'.htmlspecialchars($row['data_filename']).'</td>';				}				$lines[] = '<td>'.$row['gr_list'].$this->printExtraGrListRows($extraGrListRows).'</td>';				$lines[] = '<td>'.$this->printRootlineInfo($row).'</td>';				$lines[] = '<td>'.($row['page_id'] ? $row['page_id'] : '&nbsp;').'</td>';				$lines[] = '<td>'.($row['phash_t3']!=$row['phash'] ? $row['phash_t3'] : '&nbsp;').'</td>';				$lines[] = '<td>'.($row['freeIndexUid'] ? $row['freeIndexUid'].($row['freeIndexSetId']?'/'.$row['freeIndexSetId']:'') : '&nbsp;').'</td>';				$lines[] = '<td>'.($row['recordUid'] ? $row['recordUid'] : '&nbsp;').'</td>';					// cHash parameters:				$arr = unserialize($row['cHashParams']);				if (is_array($arr))		{					$theCHash = $arr['cHash'];					unset($arr['cHash']);				}				if ($row['item_type'])	{	// pdf...					$lines[] = '<td>'.($arr['key'] ? 'Page '.$arr['key'] : '').'&nbsp;</td>';				} elseif ($row['item_type']==0) {					$lines[] = '<td>'.htmlspecialchars(t3lib_div::implodeArrayForUrl('',$arr)).'&nbsp;</td>';				} else {					$lines[] = '<td class="bgColor">&nbsp;</td>';				}				$lines[] = '<td>'.$theCHash.'</td>';			break;			case 2:		// Words and content:					// Display icon:				if (!$grouping)	{					$lines[] = '<td>'.$this->makeItemTypeIcon($row['item_type'], $row['data_filename'] ? $row['data_filename'] : $row['item_title']).'</td>';				} else {					$lines[] = '<td>&nbsp;</td>';				}					// Title displayed:				$lines[] = '<td'.$titleCellAttribs.'>'.$elTitle.'</td>';

⌨️ 快捷键说明

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