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

📄 class.tx_indexedsearch_modfunc1.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 3 页
字号:
		$content = $content.$this->linkList();		return $content;	}	/**	 * Show details for metaphone value	 *	 * @param	integer		Metaphone integer hash	 * @return	string		HTML content	 */	function showDetailsForMetaphone($metaphone)	{			// Finding top-20 on frequency for this phash:		$ftrows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(					'index_words.*',					'index_words',					'index_words.metaphone = '.intval($metaphone),					'',					'index_words.baseword',					''				);		if (count($ftrows))	{			$content.='<h4>Metaphone: '.$this->indexerObj->metaphone($ftrows[0]['baseword'],1).'</h4>';			$content.='				<tr class="tableheader bgColor5">					<td>Word</td>					<td>Is stopword?</td>				</tr>';			if (is_array($ftrows))	{				foreach($ftrows as $wDat)	{					$content.='						<tr class="bgColor4">							<td>'.$this->linkWordDetails(htmlspecialchars($wDat['baseword']),$wDat['wid']).'</td>							<td>'.htmlspecialchars($wDat['is_stopword'] ? 'YES' : 'No').'</td>						</tr>';				}			}			$content = '				<table border="0" cellspacing="1" cellpadding="2" class="c-list">'.					$content.'				</table>';			if ($this->indexerObj->metaphone($ftrows[0]['baseword'])!=$metaphone)	{				$content.='ERROR: Metaphone string and hash did not match for some reason!?';			}				// Add go-back link:			$content = $content.$this->linkList();		}		return $content;	}	/*******************************	 *	 * Helper functions	 *	 *******************************/	/**	 * Creates icon which clears indexes for a certain list of phash values.	 *	 * @param	string		List of phash integers	 * @param	string		Alt-text for the garbage bin icon.	 * @return	string		HTML img-tag with link around.	 */	function printRemoveIndexed($phash,$alt)	{		return '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('deletePhash'=>$phash))).'">'.				'<img src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" width="11" hspace="1" vspace="2" height="12" border="0" title="'.htmlspecialchars($alt).'" alt="" />'.				'</a>';	}	/**	 * Button for re-indexing of documents	 *	 * @param	array		phash table result row.	 * @param	string		Title attribute text for icon	 * @return	string		HTML content; Icon wrapped in link.	 */	function printReindex($resultRow,$alt)	{		if ($resultRow['item_type'] && $resultRow['item_type']!=='0')	{			return '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('reindex'=>$resultRow['phash'],'reindex_id'=>$resultRow['page_id']))).'">'.					'<img src="'.$GLOBALS['BACK_PATH'].'gfx/refresh_n.gif" width="14" hspace="1" vspace="2" height="14" border="0" title="'.htmlspecialchars($alt).'" alt="" />'.					'</a>';		}	}	/**	 * Wraps input string in a link that will display details for the phash value set.	 *	 * @param	string		String to wrap, possibly a title or so.	 * @param	integer		phash value to show details for	 * @return	string		Wrapped string	 */	function linkDetails($string,$phash)	{		return '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('phash'=>$phash))).'">'.$string.'</a>';	}	/**	 * Creates link back to listing	 *	 * @return	string		Link back to list	 */	function linkList()	{		return '<br/><a href="index.php?id='.$this->pObj->id.'">Back to list.</a><br/>';	}	/**	 * Wraps input string in a link that will display details for the phash value set.	 *	 * @param	string		String to wrap, possibly a title or so.	 * @param	integer		phash value to show details for	 * @return	string		Wrapped string	 */	function showPageDetails($string,$id)	{		return '<a href="'.htmlspecialchars('index.php?id='.$id.'&SET[depth]=0&SET[type]=1').'">'.$string.'</a>';	}	/**	 * Prints the gr_lists attached to a indexed entry.	 *	 * @param	array		Array of index_grlist records	 * @return	string		HTML code.	 */	function printExtraGrListRows($extraGrListRows)	{		if (count($extraGrListRows))	{			reset($extraGrListRows);			$lines=array();			while(list(,$r)=each($extraGrListRows))	{				$lines[] = $r['gr_list'];			}			return "<br/>".$GLOBALS['TBE_TEMPLATE']->dfw(implode('<br/>',$lines));		}	}	/**	 * Print path for indexing	 *	 * @param	array		Result row with content from index_section	 * @return	string		Rootline information	 */	function printRootlineInfo($row)	{		$uidCollection = array();		if ($row['rl0'])	{			$uidCollection[0] = $row['rl0'];			if ($row['rl1'])	{				$uidCollection[1] = $row['rl1'];				if ($row['rl2'])	{					$uidCollection[2] = $row['rl2'];						// Additional levels:					if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['addRootLineFields']))	{						foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['addRootLineFields'] as $fieldName => $rootLineLevel)	{							if ($row[$fieldName])	{								$uidCollection[$rootLineLevel] = $row[$fieldName];							}						}					}				}			}		}			// Return root line.		ksort($uidCollection);		return implode('/',$uidCollection);	}	/**	 * Return icon for file extension	 *	 * @param	string		File extension / item type	 * @param	string		Title attribute value in icon.	 * @return	string		<img> tag for icon	 */	function makeItemTypeIcon($it,$alt='')	{		if (!isset($this->iconFileNameCache[$it]))	{			if ($it==='0')	{				$icon = 'EXT:indexed_search/pi/res/pages.gif';			} elseif ($this->external_parsers[$it]) {				$icon = $this->external_parsers[$it]->getIcon($it);			}			$fullPath = t3lib_div::getFileAbsFileName($icon);			if ($fullPath)	{				$info = @getimagesize($fullPath);				$iconPath = $GLOBALS['BACK_PATH'].'../'.substr($fullPath,strlen(PATH_site));				$this->iconFileNameCache[$it] = is_array($info) ? '<img src="'.$iconPath.'" '.$info[3].' title="###TITLE_ATTRIBUTE###" alt="" />' : '';			}		}		return str_replace('###TITLE_ATTRIBUTE###',htmlspecialchars($it.': '.$alt),$this->iconFileNameCache[$it]);	}	/**	 * Converts the input string from utf-8 to the backend charset.	 *	 * @param	string		String to convert (utf-8)	 * @return	string		Converted string (backend charset if different from utf-8)	 */	function utf8_to_currentCharset($string)	{		global $LANG;		if ($LANG->charSet != 'utf-8')	{			$string = $LANG->csConvObj->utf8_decode($string, $LANG->charSet, TRUE);		}		return $string;	}	/********************************	 *	 * Reindexing	 *	 *******************************/	/**	 * Re-indexing files/records attached to a page.	 *	 * @param	integer		Phash value	 * @param	integer		The page uid for the section record (file/url could appear more than one place you know...)	 * @return	string		HTML content	 */	function reindexPhash($phash, $pageId)	{			// Query:		list($resultRow) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(					'ISEC.*, IP.*',					'index_phash IP, index_section ISEC',					'IP.phash = ISEC.phash						AND IP.phash = '.intval($phash).'						AND ISEC.page_id = '.intval($pageId)				);		$content = '';		if (is_array($resultRow))	{			if ($resultRow['item_type'] && $resultRow['item_type']!=='0')	{					// (Re)-Indexing file on page.				$indexerObj = &t3lib_div::makeInstance('tx_indexedsearch_indexer');				$indexerObj->backend_initIndexer($pageId, 0, 0, '', $this->getUidRootLineForClosestTemplate($pageId));					// URL or local file:				if ($resultRow['externalUrl'])	{					$indexerObj->indexExternalUrl($resultRow['data_filename']);				} else {					$indexerObj->indexRegularDocument($resultRow['data_filename'], TRUE);				}				if ($indexerObj->file_phash_arr['phash'] != $resultRow['phash'])	{					$content.= 'ERROR: phash ('.$indexerObj->file_phash_arr['phash'].') did NOT match '.$resultRow['phash'].' for strange reasons!';				}				$content.='<h4>Log for re-indexing of "'.htmlspecialchars($resultRow['data_filename']).'":</h4>';				$content.=t3lib_div::view_array($indexerObj->internal_log);				$content.='<h4>Hash-array, page:</h4>';				$content.=t3lib_div::view_array($indexerObj->hash);				$content.='<h4>Hash-array, file:</h4>';				$content.=t3lib_div::view_array($indexerObj->file_phash_arr);			}		}			// Link back to list.		$content.= $this->linkList();		return $content;	}	/**	 * Get rootline for closest TypoScript template root.	 * Algorithm same as used in Web > Template, Object browser	 *	 * @param	integer		The page id to traverse rootline back from	 * @return	array		Array where the root lines uid values are found.	 */	function getUidRootLineForClosestTemplate($id)	{		$tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');	// Defined global here!		$tmpl->tt_track = 0;	// Do not log time-performance information		$tmpl->init();				// Gets the rootLine		$sys_page = t3lib_div::makeInstance('t3lib_pageSelect');		$rootLine = $sys_page->getRootLine($id);		$tmpl->runThroughTemplates($rootLine,0);	// This generates the constants/config + hierarchy info for the template.			// Root line uids		$rootline_uids = array();		foreach($tmpl->rootLine as $rlkey => $rldat)	{			$rootline_uids[$rlkey] = $rldat['uid'];		}		return $rootline_uids;	}	/********************************	 *	 * SQL functions	 *	 *******************************/	/**	 * Removes ALL data regarding a certain list of indexed phash-row	 *	 * @param	string		List of phash integers	 * @param	boolean		If set, page cache is cleared as well.	 * @return	void	 */	function removeIndexedPhashRow($phashList,$clearPageCache=1)	{			// FIXME: This is only a workaround		if ($phashList=='ALL')	{			$this->drawTableOfIndexedPages();			$phashRows = $this->allPhashListed;			$this->allPhashListed = array();	// Reset it because it will be filled again later...		} else {			$phashRows = t3lib_div::trimExplode(',',$phashList,1);		}		foreach($phashRows as $phash)	{			$phash = intval($phash);			if ($phash>0)	{				if ($clearPageCache)	{						// Clearing page cache:					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('page_id', 'index_section', 'phash='.intval($phash));					if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))	{						$idList = array();						while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{							$idList[] = $row['page_id'];						}						$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($idList)).')');					}				}					// Removing old registrations for all tables.				$tableArr = explode(',','index_phash,index_rel,index_section,index_grlist,index_fulltext,index_debug');				foreach($tableArr as $table)	{					$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));				}					// Did not remove any index_section records for external files where phash_t3 points to this hash!			}		}	}	/**	 * Returns an array with gr_list records for a phash	 *	 * @param	integer		phash integer to look up on	 * @param	string		gr_list string to filter OUT of the result (first occurence)	 * @return	array		Array of records from index_grlist table	 */	function getGrListEntriesForPhash($phash,$gr_list)	{		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_grlist', 'phash='.intval($phash));		$lines = array();		$isRemoved = 0;		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{			if (!$isRemoved && !strcmp($row['gr_list'],$gr_list))	{				$isRemoved = 1;			} else {				$lines[] = $row;			}		}		return $lines;	}	/**	 * Setting / Unsetting stopwords	 *	 * @param	array		Array of stop-words WIDs with 0/1 to set / unset	 * @return	void	 */	function processStopWords($stopWords)	{		if ($GLOBALS['BE_USER']->isAdmin())	{				// Traverse words			foreach($stopWords as $wid => $state)	{				$fieldArray = array(					'is_stopword' => $state				);				$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_words', 'wid='.$wid, $fieldArray);			}		}	}	/**	 * Setting / Unsetting keywords in page header	 *	 * @param	array		Page keywords as keys in array with value 0 or 1 for set or unset.	 * @param	integer		The page uid of the header where the keywords are to be set.	 * @return	void	 */	function processPageKeywords($pageKeywords, $pageUid)	{			// Get pages current keywords		$pageRec = t3lib_BEfunc::getRecord('pages', $pageUid);		$keywords = array_flip(t3lib_div::trimExplode(',', $pageRec['keywords'], 1));			// Merge keywords:		foreach($pageKeywords as $key => $v)	{			if ($v)	{				$keywords[$key]=1;			} else {				unset($keywords[$key]);			}		}			// Compile new list:		$data = array();		$data['pages'][$pageUid]['keywords'] = implode(', ',array_keys($keywords));		$tce = t3lib_div::makeInstance('t3lib_TCEmain');		$tce->stripslashes_values = 0;		$tce->start($data,array());		$tce->process_datamap();	}}if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php'])    {    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php']);}?>

⌨️ 快捷键说明

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