Project

General

Profile

Bug #17054 » indexed_search_fulltext_4-2.diff

Administrator Admin, 2008-11-08 20:17

View differences:

typo3_src-4.2.2_mysql_fulltext_index/t3lib/class.t3lib_tcemain.php 2008-11-04 00:59:01.000000000 +0100
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
if (t3lib_extMgm::isLoaded('cms')) {
$this->internal_clearPageCache();
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection','');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', '');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
}
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash','');
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/ext_localconf.php 2008-11-04 00:59:01.000000000 +0100
);
// registering hooks for the treelist cache
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
?>
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/ext_tables.sql 2008-11-04 00:59:01.000000000 +0100
#
# Table structure for table 'cache_treelist'
#
CREATE TABLE cache_treelist (
md5hash varchar(32) DEFAULT '' NOT NULL,
pid int(11) DEFAULT '0' NOT NULL,
treelist text NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
expires int(11) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (md5hash)
) ENGINE=InnoDB;
#
# Table structure for table 'fe_groups'
#
CREATE TABLE fe_groups (
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/tslib/class.tslib_content.php 2008-11-04 00:59:01.000000000 +0100
}
/**
* Generates a list of Page-uid's from $id. List does not include $id itself (unless the id specified is negative in which case it does!)
* Generates a list of Page-uid's from $id. List does not include $id itself
* (unless the id specified is negative in which case it does!)
* The only pages WHICH PREVENTS DECENDING in a branch are
* - deleted pages,
* - pages in a recycler or of the Backend User Section type
* - pages that has the extendToSubpages set, WHERE start/endtime, hidden and fe_users would hide the records.
* Apart from that, pages with enable-fields excluding them, will also be removed. HOWEVER $dontCheckEnableFields set will allow enableFields-excluded pages to be included anyway - including extendToSubpages sections!
* Mount Pages are also descended but notice that these ID numbers are not useful for links unless the correct MPvar is set.
* - pages in a recycler (doktype = 255) or of the Backend User Section (doktpe = 6) type
* - pages that has the extendToSubpages set, WHERE start/endtime, hidden
* and fe_users would hide the records.
* Apart from that, pages with enable-fields excluding them, will also be
* removed. HOWEVER $dontCheckEnableFields set will allow
* enableFields-excluded pages to be included anyway - including
* extendToSubpages sections!
* Mount Pages are also descended but notice that these ID numbers are not
* useful for links unless the correct MPvar is set.
*
* @param integer The id of the start page from which point in the page tree to decend. IF NEGATIVE the id itself is included in the end of the list (only if $begin is 0) AND the output does NOT contain a last comma. Recommended since it will resolve the input ID for mount pages correctly and also check if the start ID actually exists!
* @param integer The number of levels to decend. If you want to decend infinitely, just set this to 100 or so. Should be at least "1" since zero will just make the function return (no decend...)
......
* @return string Returns the list with a comma in the end (if any pages selected and not if $id is negative and $id is added itself) - which means the input page id can comfortably be appended to the output string if you need it to.
* @see tslib_fe::checkEnableFields(), tslib_fe::checkPagerecordForIncludeSection()
*/
function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0) {
public function getTreeList($id, $depth, $begin = 0, $dontCheckEnableFields = false, $addSelectFields = '', $moreWhereClauses = '', array $prevId_array = array(), $recursionLevel = 0) {
// Init vars:
$allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
$depth = intval($depth);
$begin = intval($begin);
$id = intval($id);
$theList = '';
$addId = 0;
$allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
$depth = intval($depth);
$begin = intval($begin);
$id = intval($id);
$theList = '';
$addId = 0;
$requestHash = '';
if ($id) {
if ($id) {
// First level, check id (second level, this is done BEFORE the recursive call)
if (!$recursionLevel) {
if (!$recursionLevel) {
// check cache
// first, create the hash for this request - not sure yet whether we need all these parameters though
$parameters = array(
$id,
$depth,
$begin,
$dontCheckEnableFields,
$addSelectFields,
$moreWhereClauses,
$prevId_array
);
$requestHash = md5(serialize($parameters));
$cacheEntry = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'treelist',
'cache_treelist',
'md5hash = \'' . $requestHash . '\' AND ( expires > ' . time() . ' OR expires = 0 )'
);
if(!empty($cacheEntry[0]['treelist'])) {
// cache hit
t3lib_div::devLog('Cache Treelist: HIT', 'tslib_cObj');
return $cacheEntry[0]['treelist'];
} else {
// cache miss
t3lib_div::devLog('Cache Treelist: MISS', 'tslib_cObj');
}
// If Id less than zero it means we should add the real id to list:
if ($id < 0) {
if ($id < 0) {
$addId = $id = abs($id);
}
// Check start page:
if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id,'uid')) {
if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages', $id, 'uid')) {
// Find mount point if any:
$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id);
if (is_array($mount_info)) {
if (is_array($mount_info)) {
$id = $mount_info['mount_pid'];
// In Overlay mode, use the mounted page uid as added ID!:
if ($addId && $mount_info['overlay']) {
if ($addId && $mount_info['overlay']) {
$addId = $id;
}
}
} else return ''; // Return blank if the start page was NOT found at all!
} else {
return ''; // Return blank if the start page was NOT found at all!
}
}
// Add this ID to the array of IDs
if ($begin<=0) {
if ($begin <= 0) {
$prevId_array[] = $id;
}
// Select sublevel:
if ($depth>0) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']>0) { unset($row); } // Doing this after the overlay to make sure changes in the overlay are respected.
if (is_array($row)) {
// Find mount point if any:
$next_id = $row['uid'];
$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
// Overlay mode:
if (is_array($mount_info) && $mount_info['overlay']) {
$next_id = $mount_info['mount_pid'];
$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
$GLOBALS['TYPO3_DB']->sql_free_result($res2);
$GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
if ($depth > 0) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$allFields,
'pages',
'pid = '.intval($id).' AND deleted = 0 '.$moreWhereClauses,
'',
'sorting'
);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
if ($row['doktype'] == 255 || $row['doktype'] == 6 || $row['t3ver_state'] > 0) {
// Doing this after the overlay to make sure changes
// in the overlay are respected.
// However, we do not process pages below of and
// including of type recycler and BE user section
continue;
}
// Find mount point if any:
$next_id = $row['uid'];
$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']>0) { unset($row); } // Doing this after the overlay to make sure changes in the overlay are respected.
// Overlay mode:
if (is_array($mount_info) && $mount_info['overlay']) {
$next_id = $mount_info['mount_pid'];
$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$allFields,
'pages',
'uid = '.intval($next_id).' AND deleted = 0 '.$moreWhereClauses,
'' ,
'sorting'
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
$GLOBALS['TYPO3_DB']->sql_free_result($res2);
$GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
if ($row['doktype'] == 255 || $row['doktype'] == 6 || $row['t3ver_state'] > 0) {
// Doing this after the overlay to make sure
// changes in the overlay are respected.
// see above
continue;
}
// Add record:
if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row))) {
// Add ID to list:
if ($begin<=0) {
if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row)) {
$theList.= $next_id.',';
}
}
// Add record:
if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)) {
// Add ID to list:
if ($begin <= 0) {
if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row)) {
$theList.= $next_id.',';
}
// Next level:
if ($depth>1 && !$row['php_tree_stop']) {
// Normal mode:
if (is_array($mount_info) && !$mount_info['overlay']) {
$next_id = $mount_info['mount_pid'];
}
// Call recursively, if the id is not in prevID_array:
if (!in_array($next_id,$prevId_array)) {
$theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
}
}
// Next level:
if ($depth > 1 && !$row['php_tree_stop']) {
// Normal mode:
if (is_array($mount_info) && !$mount_info['overlay']) {
$next_id = $mount_info['mount_pid'];
}
// Call recursively, if the id is not in prevID_array:
if (!in_array($next_id, $prevId_array)) {
$theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
}
}
}
......
}
}
// If first run, check if the ID should be returned:
if (!$recursionLevel) {
if ($addId) {
if ($begin>0) {
if (!$recursionLevel) {
if ($addId) {
if ($begin > 0) {
$theList.= 0;
} else {
$theList.= $addId;
}
}
$GLOBALS['TYPO3_DB']->exec_INSERTquery(
'cache_treelist',
array(
'md5hash' => $requestHash,
'pid' => $id,
'treelist' => $theList,
'tstamp' => time()
)
);
}
// Return list:
return $theList;
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/tslib/class.tslib_fe.php 2008-11-04 00:59:01.000000000 +0100
* @see INTincScript()
*/
protected function INTincScript_includeLibs($INTiS_config) {
global $TYPO3_CONF_VARS;
global $TYPO3_CONF_VARS, $TCA;
$GLOBALS['TT']->push('Include libraries');
foreach($INTiS_config as $INTiS_cPart) {
......
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
}
?>
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php 2008-11-04 00:59:01.000000000 +0100
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Ingo Renner (ingo@typo3.org)
* 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!
***************************************************************/
/**
* Class that hooks into TCEmain and listens for updates to pages to update the
* treelist cache
*
* @author Ingo Renner <ingo@typo3.org>
* @package TYPO3
* @subpackage tslib
*/
class tx_cms_treelistCacheUpdate {
// should not be manipulated from others except through the
// configuration provided @see __construct()
private $updateRequiringFields = array(
'pid',
'php_tree_stop',
'extendToSubpages'
);
/**
* constructor, adds update requiring fields to the default ones
*
*/
public function __construct() {
// as enableFields can be set dynamically we add them here
$pagesEnableFields = $GLOBALS['TCA']['pages']['ctrl']['enablecolumns'];
foreach($pagesEnableFields as $pagesEnableField) {
$this->updateRequiringFields[] = $pagesEnableField;
}
$this->updateRequiringFields[] = $GLOBALS['TCA']['pages']['ctrl']['delete'];
// extension can add fields to the pages table that require an
// update of the treelist cache, too; so we also add those
// example: $TYPO3_CONF_VARS['BE']['additionalTreelistUpdateFields'] .= ',my_field';
if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['additionalTreelistUpdateFields'])) {
$additionalTreelistUpdateFields = t3lib_div::trimExplode(
',',
$GLOBALS['TYPO3_CONF_VARS']['BE']['additionalTreelistUpdateFields'],
TRUE
);
foreach($additionalTreelistUpdateFields as $additionalTreelistUpdateField) {
$this->updateRequiringFields[] = $additionalTreelistUpdateField;
}
}
}
/**
* waits for TCEmain commands and looks for changed pages, if found further
* changes take place to determine whether the cache needs to be updated
*
* @param string TCEmain operation status, either 'new' or 'update'
* @param string the DB table the operation was carried out on
* @param mixed the record's uid for update records, a string to look the record's uid up after it has been created
* @param array array of changed fiels and their new values
* @param t3lib_TCEmain TCEmain parent object
*/
public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, t3lib_TCEmain $tceMain) {
if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPagePid = 0;
$affectedPageUid = 0;
if ($status == 'new') {
// detect new pages
// resolve the uid
$affectedPageUid = $tceMain->substNEWwithIDs[$recordId];
$affectedPagePid = $updatedFields['pid'];
} elseif ($status == 'update') {
// detect updated pages
$affectedPageUid = $recordId;
/*
when updating a page the pid is not directly available so we
need to retrieve it ourselves.
*/
$fullPageRecord = t3lib_BEfunc::getRecord($table, $recordId);
$affectedPagePid = $fullPageRecord['pid'];
}
$clearCacheActions = $this->determineClearCacheActions(
$status,
$updatedFields
);
$this->processClearCacheActions(
$affectedPageUid,
$affectedPagePid,
$updatedFields,
$clearCacheActions
);
}
}
/**
* waits for TCEmain commands and looks for deleted pages, if found further
* changes take place to determine whether the cache needs to be updated
*
* @param string the TCE command
* @param string the record's table
* @param integer the record's uid
* @param array the commands value, typically an array with more detailed command information
* @param t3lib_TCEmain the TCEmain parent object
*/
public function processCmdmap_postProcess($command, $table, $recordId, $commandValue, t3lib_TCEmain $tceMain) {
if ($table == 'pages' && $command == 'delete') {
$deletedRecord = t3lib_BEfunc::getRecord(
$table,
$recordId,
'*',
'',
FALSE
);
$affectedPageUid = $deletedRecord['uid'];
$affectedPagePid = $deletedRecord['pid'];
// faking the updated fields
$updatedFields = array('deleted' => 1);
$clearCacheActions = $this->determineClearCacheActions(
'update',
$updatedFields
);
$this->processClearCacheActions(
$affectedPageUid,
$affectedPagePid,
$updatedFields,
$clearCacheActions
);
}
}
/**
* waits for TCEmain commands and looks for moved pages, if found further
* changes take place to determine whether the cache needs to be updated
*
* @param string table name of the moved record
* @param integer the record's uid
* @param integer the record's destination page id
* @param array the record that moved
* @param array array of changed fields
* @param t3lib_TCEmain TCEmain parent object
*/
public function moveRecord_firstElementPostProcess($table, $recordId, $destinationPid, array $movedRecord, array $updatedFields, t3lib_TCEmain $tceMain) {
if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPageUid = $recordId;
$affectedPageOldPid = $movedRecord['pid'];
$affectedPageNewPid = $updatedFields['pid'];
$clearCacheActions = $this->determineClearCacheActions(
'update',
$updatedFields
);
// clear treelist entries for old parent page
$this->processClearCacheActions(
$affectedPageUid,
$affectedPageOldPid,
$updatedFields,
$clearCacheActions
);
// clear treelist entries for new parent page
$this->processClearCacheActions(
$affectedPageUid,
$affectedPageNewPid,
$updatedFields,
$clearCacheActions
);
}
}
/**
* waits for TCEmain commands and looks for moved pages, if found further
* changes take place to determine whether the cache needs to be updated
*
* @param string table name of the moved record
* @param integer the record's uid
* @param integer the record's destination page id
* @param integer (negative) page id th page has been moved after
* @param array the record that moved
* @param array array of changed fields
* @param t3lib_TCEmain TCEmain parent object
*/
public function moveRecord_afterAnotherElementPostProcess($table, $recordId, $destinationPid, $originalDestinationPid, array $movedRecord, array $updatedFields, t3lib_TCEmain $tceMain) {
if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPageUid = $recordId;
$affectedPageOldPid = $movedRecord['pid'];
$affectedPageNewPid = $updatedFields['pid'];
$clearCacheActions = $this->determineClearCacheActions(
'update',
$updatedFields
);
// clear treelist entries for old parent page
$this->processClearCacheActions(
$affectedPageUid,
$affectedPageOldPid,
$updatedFields,
$clearCacheActions
);
// clear treelist entries for new parent page
$this->processClearCacheActions(
$affectedPageUid,
$affectedPageNewPid,
$updatedFields,
$clearCacheActions
);
}
}
/**
* checks whether the change requires an update of the treelist cache
*
* @param array array of changed fields
* @return boolean true if the treelist cache needs to be updated, false if no update to the cache is required
*/
protected function requiresUpdate(array $updatedFields) {
$requiresUpdate = FALSE;
$updatedFieldNames = array_keys($updatedFields);
foreach ($updatedFieldNames as $updatedFieldName) {
if(in_array($updatedFieldName, $this->updateRequiringFields)) {
$requiresUpdate = TRUE;
break;
}
}
return $requiresUpdate;
}
/**
* calls the cache maintainance functions according to the determined actions
*
* @param integer uid of the affected page
* @param integer parent uid of the affected page
* @param array array of updated fields and their new values
* @param array array of actions to carry out
*/
protected function processClearCacheActions($affectedPage, $affectedParentPage, $updatedFields, array $actions) {
$actionNames = array_keys($actions);
foreach ($actionNames as $actionName) {
switch ($actionName) {
case 'allParents':
$this->clearCacheForAllParents($affectedParentPage);
break;
case 'setExpiration':
// only used when setting an end time for a page
$expirationTime = $updatedFields['endtime'];
$this->setCacheExpiration($affectedPage, $expirationTime);
break;
case 'uidInTreelist':
$this->clearCacheWhereUidInTreelist($affectedPage);
break;
}
}
// from time to time clean the cache from expired entries
// (theoretically every 1000 calls)
$randomNumber = rand(1, 1000);
if($randomNumber == 500) {
$this->removeExpiredCacheEntries();
}
}
/**
* clears the treelist cache for all parents of a changed page.
* gets called after creating a new page and after moving a page
*
* @param integer parent page id of the changed page, the page to start clearing from
*/
protected function clearCacheForAllParents($affectedParentPage) {
$rootline = t3lib_BEfunc::BEgetRootLine($affectedParentPage);
$rootlineIds = array();
foreach($rootline as $page) {
if($page['uid'] != 0) {
$rootlineIds[] = $page['uid'];
}
}
foreach($rootlineIds as $rootlineId) {
// delete the rootline, must contain
$GLOBALS['TYPO3_DB']->exec_DELETEquery(
'cache_treelist',
'pid = ' . $rootlineId
);
}
}
/**
* clears the treelist cache for all pages where the affected page is found
* in the treelist
*
* @param integer Id of the changed page
*/
protected function clearCacheWhereUidInTreelist($affectedPage) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery(
'cache_treelist',
$GLOBALS['TYPO3_DB']->listQuery(
'treelist',
$affectedPage,
'cache_treelist'
)
);
}
/**
* sets an expiration time for all cache entries having the changed page in
* the treelist.
*
* @param integer uid of the changed page
*/
protected function setCacheExpiration($affectedPage, $expirationTime) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'cache_treelist',
$GLOBALS['TYPO3_DB']->listQuery(
'treelist',
$affectedPage,
'cache_treelist'
),
array(
'expires' => $expirationTime
)
);
}
/**
* removes all expired treelist cache entries
*
*/
protected function removeExpiredCacheEntries() {
$GLOBALS['TYPO3_DB']->exec_DELETEquery(
'cache_treelist',
'expires <= ' . time()
);
}
/**
* determines what happened to the page record, this is necessary to clear
* as less cache entries as needed later
*
* @param string TCEmain operation status, either 'new' or 'update'
* @param array array of updated fields
* @return string list of actions that happened to the page record
*/
protected function determineClearCacheActions($status, $updatedFields) {
$actions = array();
if ($status == 'new') {
// new page
$actions['allParents'] = TRUE;
} elseif ($status == 'update') {
$updatedFieldNames = array_keys($updatedFields);
foreach ($updatedFieldNames as $updatedFieldName) {
switch ($updatedFieldName) {
case 'pid':
// page moved
$actions['allParents'] = TRUE;
$actions['uidInTreelist'] = TRUE;
break;
case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['disabled']:
case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['fe_group']:
case $GLOBALS['TCA']['pages']['ctrl']['delete']:
case 'extendToSubpages':
case 'php_tree_stop':
// page hidden / unhidden / deleted / extendToSubpages set
// php_tree_stop and/or FE groups set
$actions['uidInTreelist'] = TRUE;
break;
case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['starttime']:
/*
start time set/unset
Doesn't matter whether it was set or unset, in both
cases the cache needs to be cleared. When setting a
start time the page must be removed from the
treelist. When unsetting the start time it must
become listed in the tree list again.
*/
$actions['uidInTreelist'] = TRUE;
break;
case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['endtime']:
/*
end time set/unset
When setting an end time the cache entry needs an
expiration time. When unsetting the end time the
page must become listed in the treelist again.
*/
if($updatedFields['endtime'] > 0) {
$actions['setExpiration'] = TRUE;
} else {
$actions['uidInTreelist'] = TRUE;
}
break;
default:
if (in_array($updatedFieldName, $this->updateRequiringFields)) {
$actions['uidInTreelist'] = TRUE;
}
}
}
}
return $actions;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/hooks/class.tx_cms_treelistcacheupdate.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/hooks/class.tx_cms_treelistcacheupdate.php']);
}
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ChangeLog 2008-11-04 00:59:01.000000000 +0100
2008-11-03 Michael Stucki <michael@typo3.org>
* Check if files in search matches are still existing before displaying them
2008-04-01 Michael Stucki <michael@typo3.org>
* Fixed bug #7980: Fix wrong TypoScript code in plugin template
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/class.doublemetaphone.php 2008-11-04 00:59:01.000000000 +0100
// TYPO3: Had to change name to "user_DoubleMetaPhone" from just "DoubleMetaPhone" because TYPO3 requires a user class to be prefixed so:
// TYPO3: If you want to use this metaphone method instead of the default in the class.indexer.php you simply configure TYPO3 so by setting the line below in your localconf.php file:
// TYPO3: $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
// TYPO3: Of course you can write your own metaphone hook methods by taking this class and configuration as example.
// TYPO3: If you want to use this metaphone method instead of the default in the class.indexer.php you can enable it in the extension configuration
// TYPO3: Of course you can write your own metaphone hook methods by taking this class and configuration as example (also see ext_localconf.php)
class user_DoubleMetaPhone
{
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/class.indexer.php 2008-11-04 00:59:01.000000000 +0100
var $freqRange = 32000;
var $freqMax = 0.1;
var $enableMetaphoneSearch = false;
var $storeMetaphoneInfoAsWords;
var $metaphoneContent = '';
// Objects:
/**
* Charset class object
......
$this->maxExternalFiles = t3lib_div::intInRange($this->indexerConfig['maxExternalFiles'],0,1000,5);
$this->flagBitMask = t3lib_div::intInRange($this->indexerConfig['flagBitMask'],0,255);
// Workaround: If the extension configuration was not updated yet, the value is not existing
$this->enableMetaphoneSearch = isset($this->indexerConfig['enableMetaphoneSearch']) ? ($this->indexerConfig['enableMetaphoneSearch'] ? 1 : 0) : 1;
$this->storeMetaphoneInfoAsWords = $this->isTableUsed('index_words') ? false : ($this->enableMetaphoneSearch ? true : false);
// Initialize external document parsers:
// Example configuration, see ext_localconf.php of this file!
if ($this->conf['index_externals']) {
......
// Initialize metaphone hook:
// Example configuration (localconf.php) for this hook: $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
if ($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone']) {
// Make sure that the hook is loaded _after_ indexed_search as this may overwrite the hook depending on the configuration.
if ($this->enableMetaphoneSearch && $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone']) {
$this->metaphoneObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone']);
$this->metaphoneObj->pObj = &$this;
}
......
$this->log_pull();
// Calculating a hash over what is to be the actual page content. Maybe this hash should not include title,description and keywords? The bodytext is the primary concern. (on the other hand a changed page-title would make no difference then, so dont!)
$this->content_md5h = $this->md5inthash(implode($this->contentParts,''));
$this->content_md5h = $this->md5inthash(implode('', $this->contentParts));
// This function checks if there is already a page (with gr_list = 0,-1) indexed and if that page has the very same contentHash.
// If the contentHash is the same, then we can rest assured that this page is already indexed and regardless of mtime and origContent we don't need to do anything more.
......
// Check words and submit to word list if not there
$this->log_push('Check word list and submit words','');
$this->checkWordList($indexArr);
$this->submitWords($indexArr,$this->hash['phash']);
if ($this->isTableUsed('index_words')) {
$this->checkWordList($indexArr);
$this->submitWords($indexArr,$this->hash['phash']);
}
$this->log_pull();
// Set parsetime
......
// Check words and submit to word list if not there
$this->log_push('Check word list and submit words','');
$this->checkWordList($indexArr);
$this->submitWords($indexArr,$phash_arr['phash']);
if ($this->isTableUsed('index_words')) {
$this->checkWordList($indexArr);
$this->submitWords($indexArr,$phash_arr['phash']);
}
$this->log_pull();
// Set parsetime
......
$this->analyzeHeaderinfo($indexArr,$content,'description',5);
$this->analyzeBody($indexArr,$content);
return ($indexArr);
return $indexArr;
}
/**
......
* @return void
*/
function analyzeHeaderinfo(&$retArr,$content,$key,$offset) {
reset($content[$key]);
while(list(,$val)=each($content[$key])) {
$val = substr($val,0,60); // Max 60 - because the baseword varchar IS 60. This MUST be the same.
foreach ($content[$key] as $val) {
$val = substr($val,0,60); // Cut after 60 chars because the index_words.baseword varchar field has this length. This MUST be the same.
if (!isset($retArr[$val])) {
// Word ID (wid)
$retArr[$val]['hash'] = $this->md5inthash($val);
// Metaphone value is also 60 only chars long
$metaphone = $this->enableMetaphoneSearch
? substr($this->metaphone($val,$this->storeMetaphoneInfoAsWords),0,60)
: '';
$retArr[$val]['metaphone'] = $metaphone;
}
// Build metaphone fulltext string (can be used for fulltext indexing)
if ($this->storeMetaphoneInfoAsWords) {
$this->metaphoneContent.= ' '.$retArr[$val]['metaphone'];
}
// Priority used for flagBitMask feature (see extension configuration)
$retArr[$val]['cmp'] = $retArr[$val]['cmp']|pow(2,$offset);
$retArr[$val]['count'] = $retArr[$val]['count']+1;
$retArr[$val]['hash'] = hexdec(substr(md5($val),0,7));
$retArr[$val]['metaphone'] = $this->metaphone($val);
$retArr[$val]['count']++; // Increase number of occurences
$this->wordcount++;
}
}
......
* @return void
*/
function analyzeBody(&$retArr,$content) {
foreach($content['body'] as $key => $val) {
$val = substr($val,0,60); // Max 60 - because the baseword varchar IS 60. This MUST be the same.
if(!isset($retArr[$val])) {
foreach ($content['body'] as $key => $val) {
$val = substr($val,0,60); // Cut after 60 chars because the index_words.baseword varchar field has this length. This MUST be the same.
if (!isset($retArr[$val])) {
// First occurence (used for ranking results)
$retArr[$val]['first'] = $key;
$retArr[$val]['hash'] = hexdec(substr(md5($val),0,7));
$retArr[$val]['metaphone'] = $this->metaphone($val);
// Word ID (wid)
$retArr[$val]['hash'] = $this->md5inthash($val);
// Metaphone value is also only 60 chars long
$metaphone = $this->enableMetaphoneSearch
? substr($this->metaphone($val,$this->storeMetaphoneInfoAsWords),0,60)
: '';
$retArr[$val]['metaphone'] = $metaphone;
}
// Build metaphone fulltext string (can be used for fulltext indexing)
if ($this->storeMetaphoneInfoAsWords) {
$this->metaphoneContent.= ' '.$retArr[$val]['metaphone'];
}
$retArr[$val]['count'] = $retArr[$val]['count']+1;
$retArr[$val]['count']++; // Increase number of occurences
$this->wordcount++;
}
}
......
if (is_object($this->metaphoneObj)) {
$tmp = $this->metaphoneObj->metaphone($word, $this->conf['sys_language_uid']);
} else {
// Use native PHP function instead of advanced doubleMetaphone class
$tmp = metaphone($word);
}
// Return raw value?
if ($retRaw) return $tmp;
if ($retRaw) { // Return raw value?
$ret = $tmp;
} elseif (strlen($tmp)) { // Otherwise create hash and return integer
$ret = $this->md5inthash($tmp);
} else {
$ret = 0;
}
// Otherwise create hash and return integer
if($tmp=='') $ret=0; else $ret=hexdec(substr(md5($tmp),0,7));
return $ret;
}
......
'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
if ($this->isTableUsed('index_phash')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
}
// PROCESSING index_section
$this->submit_section($this->hash['phash'],$this->hash['phash']);
......
// PROCESSING index_fulltext
$fields = array(
'phash' => $this->hash['phash'],
'fulltextdata' => implode(' ', $this->contentParts)
'fulltextdata' => implode(' ', $this->contentParts),
'metaphonedata' => $this->metaphoneContent
);
if ($this->indexerConfig['fullTextDataLength']>0) {
$fields['fulltextdata'] = substr($fields['fulltextdata'],0,$this->indexerConfig['fullTextDataLength']);
}
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
if ($this->isTableUsed('index_fulltext')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
}
// PROCESSING index_debug
if ($this->indexerConfig['debugMode']) {
......
'lexer' => $this->lexerObj->debugString,
))
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
if ($this->isTableUsed('index_debug')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
}
}
}
......
'hash_gr_list' => $this->md5inthash($this->conf['gr_list']),
'gr_list' => $this->conf['gr_list']
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_grlist', $fields);
if ($this->isTableUsed('index_grlist')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_grlist', $fields);
}
}
/**
......
$this->getRootLineFields($fields);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_section', $fields);
if ($this->isTableUsed('index_section')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_section', $fields);
}
}
/**
......
function removeOldIndexedPages($phash) {
// Removing old registrations for all tables. Because the pages are TYPO3 pages there can be nothing else than 1-1 relations here.
$tableArr = explode(',','index_phash,index_section,index_grlist,index_fulltext,index_debug');
foreach($tableArr as $table) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
foreach ($tableArr as $table) {
if ($this->isTableUsed($table)) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
}
}
// Removing all index_section records with hash_t3 set to this hash (this includes such records set for external media on the page as well!). The re-insert of these records are done in indexRegularDocument($file).
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3='.intval($phash));
if ($this->isTableUsed('index_section')) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3='.intval($phash));
}
}
......
'tstamp' => time(),
'crdate' => time(),
'gr_list' => $this->conf['gr_list'],
'externalUrl' => $fileParts['scheme'] ? 1 : 0,
'recordUid' => intval($this->conf['recordUid']),
'freeIndexUid' => intval($this->conf['freeIndexUid']),
'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
'externalUrl' => $fileParts['scheme'] ? 1 : 0,
'recordUid' => intval($this->conf['recordUid']),
'freeIndexUid' => intval($this->conf['freeIndexUid']),
'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
if ($this->isTableUsed('index_phash')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
}
// PROCESSING index_fulltext
$fields = array(
'phash' => $hash['phash'],
'fulltextdata' => implode(' ', $contentParts)
'fulltextdata' => implode(' ', $contentParts),
'metaphonedata' => $this->metaphoneContent
);
if ($this->indexerConfig['fullTextDataLength']>0) {
$fields['fulltextdata'] = substr($fields['fulltextdata'],0,$this->indexerConfig['fullTextDataLength']);
}
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
if ($this->isTableUsed('index_fulltext')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
}
// PROCESSING index_debug
if ($this->indexerConfig['debugMode']) {
......
'lexer' => $this->lexerObj->debugString,
))
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
if ($this->isTableUsed('index_debug')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
}
}
}
......
*/
function submitFile_grlist($hash) {
// Testing if there is a gr_list record for a non-logged in user and if so, there is no need to place another one.
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($hash).' AND (hash_gr_list='.$this->md5inthash($this->defaultGrList).' OR hash_gr_list='.$this->md5inthash($this->conf['gr_list']).')');
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
if ($this->isTableUsed('index_grlist')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($hash).' AND (hash_gr_list='.$this->md5inthash($this->defaultGrList).' OR hash_gr_list='.$this->md5inthash($this->conf['gr_list']).')');
} else {
$res = false;
}
if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$this->submit_grlist($hash,$hash);
}
}
......
* @return void
*/
function submitFile_section($hash) {
// Testing if there is a section
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_section', 'phash='.intval($hash).' AND page_id='.intval($this->conf['id']));
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
// Testing if there is already a section
if ($this->isTableUsed('index_section')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_section', 'phash='.intval($hash).' AND page_id='.intval($this->conf['id']));
} else {
$res = false;
}
if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$this->submit_section($hash,$this->hash['phash']);
}
}
......
* @return void
*/
function removeOldIndexedFiles($phash) {
// Removing old registrations for tables.
$tableArr = explode(',','index_phash,index_grlist,index_fulltext,index_debug');
foreach($tableArr as $table) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
foreach ($tableArr as $table) {
if ($this->isTableUsed($table)) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
}
}
}
......
* @return integer Result integer: Generally: <0 = No indexing, >0 = Do indexing (see $this->reasons): -2) Min age was NOT exceeded and so indexing cannot occur. -1) mtime matched so no need to reindex page. 0) N/A 1) Max age exceeded, page must be indexed again. 2) mtime of indexed page doesn't match mtime given for current content and we must index page. 3) No mtime was set, so we will index... 4) No indexed page found, so of course we will index.
*/
function checkMtimeTstamp($mtime,$phash) {
$out = 0;
// Select indexed page:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('item_mtime,tstamp', 'index_phash', 'phash='.intval($phash));
$out = 0;
if ($this->isTableUsed('index_phash')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('item_mtime,tstamp', 'index_phash', 'phash='.intval($phash));
} else {
$res = false;
}
// If there was an indexing of the page...:
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($this->tstamp_maxAge && ($row['tstamp']+$this->tstamp_maxAge) < time()) { // If max age is exceeded, index the page
$out = 1; // The configured max-age was exceeded for the document and thus it's indexed.
} else {
......
*/
function checkContentHash() {
// With this query the page will only be indexed if it's content is different from the same "phash_grouping" -page.
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_phash A', 'A.phash_grouping='.intval($this->hash['phash_grouping']).' AND A.contentHash='.intval($this->content_md5h));
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($this->isTableUsed('index_phash')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_phash', 'phash_grouping='.intval($this->hash['phash_grouping']).' AND contentHash='.intval($this->content_md5h));
} else {
$res = false;
}
if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
return $row;
}
return 1;
......
* @return boolean Returns true if the document needs to be indexed (that is, there was no result)
*/
function checkExternalDocContentHash($hashGr,$content_md5h) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A', 'A.phash_grouping='.intval($hashGr).' AND A.contentHash='.intval($content_md5h));
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($this->isTableUsed('index_phash')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash', 'phash_grouping='.intval($hashGr).' AND contentHash='.intval($content_md5h));
} else {
$res = false;
}
if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
return 0;
}
return 1;
......
* @return void
*/
function is_grlist_set($phash_x) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash_x', 'index_grlist', 'phash_x='.intval($phash_x));
return $GLOBALS['TYPO3_DB']->sql_num_rows($res);
if ($this->isTableUsed('index_grlist')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash_x', 'index_grlist', 'phash_x='.intval($phash_x));
} else {
$res = false;
}
return $res ? $GLOBALS['TYPO3_DB']->sql_num_rows($res) : false;
}
/**
......
* @see submit_grlist()
*/
function update_grlist($phash,$phash_x) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($phash).' AND hash_gr_list='.$this->md5inthash($this->conf['gr_list']));
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
if ($this->isTableUsed('index_grlist')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($phash).' AND hash_gr_list='.$this->md5inthash($this->conf['gr_list']));
} else {
$res = false;
}
if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$this->submit_grlist($phash,$phash_x);
$this->log_setTSlogMessage("Inserted gr_list '".$this->conf['gr_list']."' for phash '".$phash."'",1);
}
......
);
if ($mtime) { $updateFields['item_mtime'] = intval($mtime); }
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
if ($this->isTableUsed('index_phash')) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
}
}
/**
......
'freeIndexSetId' => intval($this->conf['freeIndexSetId'])
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
if ($this->isTableUsed('index_phash')) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
}
}
/**
......
'parsetime' => intval($parsetime)
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
if ($this->isTableUsed('index_phash')) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
}
}
/**
......
$updateFields = array();
$this->getRootLineFields($updateFields);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id='.intval($this->conf['id']), $updateFields);
if ($this->isTableUsed('index_section')) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id='.intval($this->conf['id']), $updateFields);
}
}
/**
......
* @return void
*/
function removeLoginpagesWithContentHash() {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A,index_grlist B', '
if ($this->isTableUsed('index_phash,index_grlist')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A,index_grlist B', '
A.phash=B.phash
AND A.phash_grouping='.intval($this->hash['phash_grouping']).'
AND B.hash_gr_list!='.$this->md5inthash($this->defaultGrList).'
AND A.contentHash='.intval($this->content_md5h));
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->log_setTSlogMessage("The currently indexed page was indexed under no user-login and apparently this page has been indexed under login conditions earlier, but with the SAME content. Therefore the old similar page with phash='".$row['phash']."' are now removed.",1);
$this->removeOldIndexedPages($row['phash']);
} else {
$res = false;
}
if ($res) {
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->log_setTSlogMessage("The currently indexed page was indexed under no user-login and apparently this page has been indexed under login conditions earlier, but with the SAME content. Therefore the old similar page with phash='".$row['phash']."' are now removed.",1);
$this->removeOldIndexedPages($row['phash']);
}
}
}
......
require_once(t3lib_extMgm::extPath('crawler').'class.tx_crawler_lib.php');
}
/**
* Check if the tables provided are configured for usage.
* This becomes neccessary for extensions that provide additional database functionality like indexed_search_mysql.
*
* @param string Comma-separated list of tables
* @return boolean True if given tables are enabled
*/
function isTableUsed($table_list) {
$OK = true;
$tableArr = t3lib_div::trimExplode(',', $table_list);
$enabledTableList = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['use_tables'];
foreach ($tableArr as $table) {
if (!t3lib_div::inList($enabledTableList, $table)) {
$OK = false;
}
}
return $OK;
}
......
}
if (count($phashArr)) {
$cwl = implode(',',$phashArr);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'index_words', 'wid IN ('.$cwl.')');
if ($this->isTableUsed('index_words')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'index_words', 'wid IN ('.$cwl.')');
} else {
$res = false;
}
if($GLOBALS['TYPO3_DB']->sql_num_rows($res)!=count($wl)) {
if ($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res)!=count($wl)) {
$this->log_setTSlogMessage('Inserting words: '.(count($wl)-$GLOBALS['TYPO3_DB']->sql_num_rows($res)),1);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
unset($wl[$row['baseword']]);
}
reset($wl);
while(list($key,$val)=each($wl)) {
while (list($key,$val)=each($wl)) {
$insertFields = array(
'wid' => $val['hash'],
'baseword' => $key,
'metaphone' => $val['metaphone']
);
// A duplicate-key error will occur here if a word is NOT unset in the unset() line. However as long as the words in $wl are NOT longer as 60 chars (the baseword varchar is 60 characters...) this is not a problem.
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_words', $insertFields);
if ($this->isTableUsed('index_words')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_words', $insertFields);
}
}
}
}
......
* @return void
*/
function submitWords($wl,$phash) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash='.intval($phash));
if ($this->isTableUsed('index_rel')) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash='.intval($phash));
}
foreach($wl as $val) {
foreach ($wl as $val) {
$insertFields = array(
'phash' => $phash,
'wid' => $val['hash'],
......
'flags' => ($val['cmp'] & $this->flagBitMask)
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields);
if ($this->isTableUsed('index_rel')) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields);
}
}
}
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/doc/README.txt 2008-11-04 00:59:01.000000000 +0100
A full documentation manual for the indexed search extension can be found in the extension "doc_indexed_search" in the TER.
See http://typo3.org/documentation/document-library/extension-manuals/doc_indexed_search/current/view/
This is a list of all tables which are used by this extension:
index_phash
- Page information
index_fulltext
- Fulltext data
index_rel
- Relations between index_phash and index_words
index_words
- baseword table
index_section
- section index (= first 3 levels of the rootline for this document)
index_grlist
- group list information
- indicates which gr_list has access to which phash
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ext_conf_template.txt 2008-11-04 00:59:01.000000000 +0100
# cat=basic; type=boolean; label=Disable Indexing in Frontend: By default pages are indexed during viewing of pages in the frontend. You can disable this features so indexing of pages is only initiated through the backend page crawler.
disableFrontendIndexing = 0
# cat=basic; type=int; label=Enable metaphone search (sounds like). 0=disabled, 1=use internal metaphone parser, 2=use advanced doubleMetaphone parser.
enableMetaphoneSearch = 1
# cat=basic; type=int; label=Min TTL (hours) for indexed page: The time in hours that must pass before an indexed page can be indexed again regardless of changes on the page.
minAge = 24
......
# cat=basic; type=boolean; label=Use "crawler" extension to index external files: When external files are found on a page they are added to the "crawler" extensions queue and indexed via the cronscript running the crawler. This eliminates problems with for example many PDF files on a page. Requires a proper configuration of the "crawler" extension.
useCrawlerForExternalFiles = 0
# cat=basic; type=int; label=Bitmask for Flags (Advanced): By this value (0-255) you can filter the importance of <title> (128), <keywords> (64) and <description> (32) content from HTML documents. By default none of these will have any importance over the other. Setting the value to eg. 192 means that title-tag content and meta-keywords will be flagged (and rate higher in search results)
# cat=basic; type=int; label=Bitmask for Flags (Advanced): By this value (0-255) you can filter the importance of <title> (128), <keywords> (64) and <description> (32) content from HTML documents. By setting this to 0, none of these fields will have any importance over the other. The default value 192 means that title-tag content and meta-keywords will be flagged (and rated higher in search results)
flagBitMask = 192
# cat=basic; type=string; label=Ignore Extensions: List of file extensions that the external parser will ignore (despite having support for them). Comma list.
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ext_localconf.php 2008-11-04 00:59:01.000000000 +0100
'tif' => 'EXT:indexed_search/class.external_parser.php:&tx_indexed_search_extparse',
);
$TYPO3_CONF_VARS['EXTCONF']['indexed_search']['use_tables'] = 'index_phash,index_fulltext,index_rel,index_words,index_section,index_grlist,index_stat_search,index_stat_word,index_debug,index_config';
$_EXTCONF = unserialize($_EXTCONF); // unserializing the configuration so we can use it here:
// Use the advanced doubleMetaphone parser instead of the internal one (usage of metaphone parsers is generally disabled by default)
if (isset($_EXTCONF['enableMetaphoneSearch']) && intval($_EXTCONF['enableMetaphoneSearch'])==2) {
$TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
}
// EXAMPLE configuration of hooks:
/*
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ext_tables.sql 2008-11-04 00:59:01.000000000 +0100
CREATE TABLE index_fulltext (
phash int(11) DEFAULT '0' NOT NULL,
fulltextdata mediumtext,
metaphonedata mediumtext NOT NULL,
PRIMARY KEY (phash)
) ENGINE=InnoDB;
......
PRIMARY KEY (uid)
) ENGINE=InnoDB;
#
# Table structure for table 'index_stat_word'
#
......
word varchar(30) DEFAULT '' NOT NULL,
index_stat_search_id int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
pageid int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY tstamp (tstamp,word)
) ENGINE=InnoDB;
......
PRIMARY KEY (uid),
KEY parent (pid)
);
#
# Table structure for table 'index_stat_word'
#
... This diff was truncated because it exceeds the maximum size that can be displayed.
(3-3/3)