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
7022 7022
				if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all'))	{
7023 7023
					if (t3lib_extMgm::isLoaded('cms'))	{
7024 7024
						$this->internal_clearPageCache();
7025
						$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection','');
7025
						$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', '');
7026
						$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
7026 7027
					}
7027 7028
					$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash','');
7028 7029

  
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/ext_localconf.php 2008-11-04 00:59:01.000000000 +0100
21 21
);
22 22

  
23 23

  
24
	// registering hooks for the treelist cache
25
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
26
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][]  = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
27
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][]     = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
28

  
29

  
24 30
?>
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/cms/ext_tables.sql 2008-11-04 00:59:01.000000000 +0100
73 73

  
74 74

  
75 75
#
76
# Table structure for table 'cache_treelist'
77
#
78
CREATE TABLE cache_treelist (
79
  md5hash varchar(32) DEFAULT '' NOT NULL,
80
  pid int(11) DEFAULT '0' NOT NULL,
81
  treelist text NOT NULL,
82
  tstamp int(11) DEFAULT '0' NOT NULL,
83
  expires int(11) unsigned  DEFAULT '0' NOT NULL,
84
  PRIMARY KEY (md5hash)
85
) ENGINE=InnoDB;
86

  
87

  
88
#
76 89
# Table structure for table 'fe_groups'
77 90
#
78 91
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
6484 6484
	}
6485 6485

  
6486 6486
	/**
6487
	 * 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!)
6487
	 * Generates a list of Page-uid's from $id. List does not include $id itself
6488
	 * (unless the id specified is negative in which case it does!)
6488 6489
	 * The only pages WHICH PREVENTS DECENDING in a branch are
6489 6490
	 *    - deleted pages,
6490
	 *    - pages in a recycler or of the Backend User Section type
6491
	 *    - pages that has the extendToSubpages set, WHERE start/endtime, hidden and fe_users would hide the records.
6492
	 * 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!
6493
	 * Mount Pages are also descended but notice that these ID numbers are not useful for links unless the correct MPvar is set.
6491
	 *    - pages in a recycler (doktype = 255) or of the Backend User Section (doktpe = 6) type
6492
	 *    - pages that has the extendToSubpages set, WHERE start/endtime, hidden
6493
	 * 		and fe_users would hide the records.
6494
	 * Apart from that, pages with enable-fields excluding them, will also be
6495
	 * removed. HOWEVER $dontCheckEnableFields set will allow
6496
	 * enableFields-excluded pages to be included anyway - including
6497
	 * extendToSubpages sections!
6498
	 * Mount Pages are also descended but notice that these ID numbers are not
6499
	 * useful for links unless the correct MPvar is set.
6494 6500
	 *
6495 6501
	 * @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!
6496 6502
	 * @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...)
......
6503 6509
	 * @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.
6504 6510
	 * @see tslib_fe::checkEnableFields(), tslib_fe::checkPagerecordForIncludeSection()
6505 6511
	 */
6506
	function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)	{
6512
	public function getTreeList($id, $depth, $begin = 0, $dontCheckEnableFields = false, $addSelectFields = '', $moreWhereClauses = '', array $prevId_array = array(), $recursionLevel = 0)	{
6507 6513

  
6508 6514
			// Init vars:
6509
		$allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
6510
		$depth = intval($depth);
6511
		$begin = intval($begin);
6512
		$id = intval($id);
6513
		$theList = '';
6514
		$addId = 0;
6515
		$allFields   = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
6516
		$depth       = intval($depth);
6517
		$begin       = intval($begin);
6518
		$id          = intval($id);
6519
		$theList     = '';
6520
		$addId       = 0;
6521
		$requestHash = '';
6515 6522

  
6516
		if ($id)	{
6523
		if ($id) {
6517 6524

  
6518 6525
				// First level, check id (second level, this is done BEFORE the recursive call)
6519
			if (!$recursionLevel)	{
6526
			if (!$recursionLevel) {
6527

  
6528
					// check cache
6529

  
6530
					// first, create the hash for this request - not sure yet whether we need all these parameters though
6531
				$parameters = array(
6532
					$id,
6533
					$depth,
6534
					$begin,
6535
					$dontCheckEnableFields,
6536
					$addSelectFields,
6537
					$moreWhereClauses,
6538
					$prevId_array
6539
				);
6540
				$requestHash = md5(serialize($parameters));
6541

  
6542
				$cacheEntry = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
6543
					'treelist',
6544
					'cache_treelist',
6545
					'md5hash = \'' . $requestHash . '\' AND ( expires > ' . time() . ' OR expires = 0 )'
6546
				);
6547

  
6548
				if(!empty($cacheEntry[0]['treelist'])) {
6549
						// cache hit
6550
					t3lib_div::devLog('Cache Treelist: HIT', 'tslib_cObj');
6551
					return $cacheEntry[0]['treelist'];
6552
				} else {
6553
						// cache miss
6554
					t3lib_div::devLog('Cache Treelist: MISS', 'tslib_cObj');
6555
				}
6556

  
6520 6557
					// If Id less than zero it means we should add the real id to list:
6521
				if ($id < 0)	{
6558
				if ($id < 0) {
6522 6559
					$addId = $id = abs($id);
6523 6560
				}
6524 6561
					// Check start page:
6525
				if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id,'uid'))	{
6562
				if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages', $id, 'uid')) {
6526 6563

  
6527 6564
						// Find mount point if any:
6528 6565
					$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id);
6529
					if (is_array($mount_info))	{
6566
					if (is_array($mount_info)) {
6530 6567
						$id = $mount_info['mount_pid'];
6531 6568
							// In Overlay mode, use the mounted page uid as added ID!:
6532
						if ($addId && $mount_info['overlay'])	{
6569
						if ($addId && $mount_info['overlay']) {
6533 6570
							$addId = $id;
6534 6571
						}
6535 6572
					}
6536
				} else return '';	// Return blank if the start page was NOT found at all!
6573
				} else {
6574
					return '';	// Return blank if the start page was NOT found at all!
6575
				}
6537 6576
			}
6538 6577

  
6539 6578
				// Add this ID to the array of IDs
6540
			if ($begin<=0)	{
6579
			if ($begin <= 0) {
6541 6580
				$prevId_array[] = $id;
6542 6581
			}
6543 6582

  
6544 6583
				// Select sublevel:
6545
			if ($depth>0)	{
6546
				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
6547
				while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
6548
					$GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
6549

  
6550
					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.
6551

  
6552
					if (is_array($row))	{
6553
							// Find mount point if any:
6554
						$next_id = $row['uid'];
6555
						$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
6556
							// Overlay mode:
6557
						if (is_array($mount_info) && $mount_info['overlay'])	{
6558
							$next_id = $mount_info['mount_pid'];
6559
							$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
6560
							$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
6561
							$GLOBALS['TYPO3_DB']->sql_free_result($res2);
6562
							$GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
6584
			if ($depth > 0) {
6585
				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
6586
					$allFields,
6587
					'pages',
6588
					'pid = '.intval($id).' AND deleted = 0 '.$moreWhereClauses,
6589
					'',
6590
					'sorting'
6591
				);
6592

  
6593
				while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
6594
					$GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
6595

  
6596
					if ($row['doktype'] == 255 || $row['doktype'] == 6 || $row['t3ver_state'] > 0) {
6597
							// Doing this after the overlay to make sure changes
6598
							// in the overlay are respected.
6599
							// However, we do not process pages below of and
6600
							// including of type recycler and BE user section
6601
						continue;
6602
					}
6603

  
6604
						// Find mount point if any:
6605
					$next_id    = $row['uid'];
6606
					$mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
6563 6607

  
6564
							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.
6608
						// Overlay mode:
6609
					if (is_array($mount_info) && $mount_info['overlay']) {
6610
						$next_id = $mount_info['mount_pid'];
6611

  
6612
						$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
6613
							$allFields,
6614
							'pages',
6615
							'uid = '.intval($next_id).' AND deleted = 0 '.$moreWhereClauses,
6616
							'' ,
6617
							'sorting'
6618
						);
6619
						$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
6620
						$GLOBALS['TYPO3_DB']->sql_free_result($res2);
6621

  
6622
						$GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
6623

  
6624
						if ($row['doktype'] == 255 || $row['doktype'] == 6 || $row['t3ver_state'] > 0) {
6625
								// Doing this after the overlay to make sure
6626
								// changes in the overlay are respected.
6627

  
6628
								// see above
6629
							continue;
6565 6630
						}
6566
							// Add record:
6567
						if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)))	{
6568
								// Add ID to list:
6569
							if ($begin<=0)	{
6570
								if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))	{
6571
									$theList.= $next_id.',';
6572
								}
6631
					}
6632
						// Add record:
6633
					if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)) {
6634
							// Add ID to list:
6635
						if ($begin <= 0) {
6636
							if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row)) {
6637
								$theList.= $next_id.',';
6573 6638
							}
6574
								// Next level:
6575
							if ($depth>1 && !$row['php_tree_stop'])	{
6576
									// Normal mode:
6577
								if (is_array($mount_info) && !$mount_info['overlay'])	{
6578
									$next_id = $mount_info['mount_pid'];
6579
								}
6580
									// Call recursively, if the id is not in prevID_array:
6581
								if (!in_array($next_id,$prevId_array))	{
6582
									$theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
6583
								}
6639
						}
6640
							// Next level:
6641
						if ($depth > 1 && !$row['php_tree_stop']) {
6642
								// Normal mode:
6643
							if (is_array($mount_info) && !$mount_info['overlay']) {
6644
								$next_id = $mount_info['mount_pid'];
6645
							}
6646
								// Call recursively, if the id is not in prevID_array:
6647
							if (!in_array($next_id, $prevId_array)) {
6648
								$theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
6584 6649
							}
6585 6650
						}
6586 6651
					}
......
6589 6654
			}
6590 6655
		}
6591 6656
			// If first run, check if the ID should be returned:
6592
		if (!$recursionLevel)	{
6593
			if ($addId)	{
6594
				if ($begin>0)	{
6657
		if (!$recursionLevel) {
6658
			if ($addId) {
6659
				if ($begin > 0) {
6595 6660
					$theList.= 0;
6596 6661
				} else {
6597 6662
					$theList.= $addId;
6598 6663
				}
6599 6664
			}
6665

  
6666
			$GLOBALS['TYPO3_DB']->exec_INSERTquery(
6667
				'cache_treelist',
6668
				array(
6669
					'md5hash'  => $requestHash,
6670
					'pid'      => $id,
6671
					'treelist' => $theList,
6672
					'tstamp'   => time()
6673
				)
6674
			);
6600 6675
		}
6601 6676
			// Return list:
6602 6677
		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
3031 3031
	 * @see		INTincScript()
3032 3032
	 */
3033 3033
	protected function INTincScript_includeLibs($INTiS_config) {
3034
		global $TYPO3_CONF_VARS;
3034
		global $TYPO3_CONF_VARS, $TCA;
3035 3035

  
3036 3036
		$GLOBALS['TT']->push('Include libraries');
3037 3037
		foreach($INTiS_config as $INTiS_cPart)	{
......
4593 4593
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php'])	{
4594 4594
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
4595 4595
}
4596

  
4597 4596
?>
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
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2008 Ingo Renner (ingo@typo3.org)
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*  A copy is found in the textfile GPL.txt and important notices to the license
17
*  from the author is found in LICENSE.txt distributed with these scripts.
18
*
19
*
20
*  This script is distributed in the hope that it will be useful,
21
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
*  GNU General Public License for more details.
24
*
25
*  This copyright notice MUST APPEAR in all copies of the script!
26
***************************************************************/
27

  
28

  
29
/**
30
 * Class that hooks into TCEmain and listens for updates to pages to update the
31
 * treelist cache
32
 *
33
 * @author	Ingo Renner <ingo@typo3.org>
34
 * @package TYPO3
35
 * @subpackage tslib
36
 */
37
class tx_cms_treelistCacheUpdate {
38

  
39
		// should not be manipulated from others except through the
40
		// configuration provided @see __construct()
41
	private $updateRequiringFields = array(
42
		'pid',
43
		'php_tree_stop',
44
		'extendToSubpages'
45
	);
46

  
47
	/**
48
	 * constructor, adds update requiring fields to the default ones
49
	 *
50
	 */
51
	public function __construct() {
52

  
53
			// as enableFields can be set dynamically we add them here
54
		$pagesEnableFields = $GLOBALS['TCA']['pages']['ctrl']['enablecolumns'];
55
		foreach($pagesEnableFields as $pagesEnableField) {
56
			$this->updateRequiringFields[] = $pagesEnableField;
57
		}
58
		$this->updateRequiringFields[] = $GLOBALS['TCA']['pages']['ctrl']['delete'];
59

  
60
			// extension can add fields to the pages table that require an
61
			// update of the treelist cache, too; so we also add those
62
			// example: $TYPO3_CONF_VARS['BE']['additionalTreelistUpdateFields'] .= ',my_field';
63
		if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['additionalTreelistUpdateFields'])) {
64
			$additionalTreelistUpdateFields = t3lib_div::trimExplode(
65
				',',
66
				$GLOBALS['TYPO3_CONF_VARS']['BE']['additionalTreelistUpdateFields'],
67
				TRUE
68
			);
69

  
70
			foreach($additionalTreelistUpdateFields as $additionalTreelistUpdateField) {
71
				$this->updateRequiringFields[] = $additionalTreelistUpdateField;
72
			}
73
		}
74

  
75
	}
76

  
77
	/**
78
	 * waits for TCEmain commands and looks for changed pages, if found further
79
	 * changes take place to determine whether the cache needs to be updated
80
	 *
81
	 * @param	string	TCEmain operation status, either 'new' or 'update'
82
	 * @param	string	the DB table the operation was carried out on
83
	 * @param	mixed	the record's uid for update records, a string to look the record's uid up after it has been created
84
	 * @param	array	array of changed fiels and their new values
85
	 * @param	t3lib_TCEmain	TCEmain parent object
86
	 */
87
	public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, t3lib_TCEmain $tceMain) {
88

  
89
		if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
90
			$affectedPagePid = 0;
91
			$affectedPageUid = 0;
92

  
93
			if ($status == 'new') {
94
					// detect new pages
95

  
96
					// resolve the uid
97
				$affectedPageUid = $tceMain->substNEWwithIDs[$recordId];
98
				$affectedPagePid = $updatedFields['pid'];
99
			} elseif ($status == 'update') {
100
					// detect updated pages
101

  
102
				$affectedPageUid = $recordId;
103

  
104
				/*
105
				 when updating a page the pid is not directly available so we
106
				 need to retrieve it ourselves.
107
				*/
108
				$fullPageRecord  = t3lib_BEfunc::getRecord($table, $recordId);
109
				$affectedPagePid = $fullPageRecord['pid'];
110
			}
111

  
112
			$clearCacheActions = $this->determineClearCacheActions(
113
				$status,
114
				$updatedFields
115
			);
116

  
117
			$this->processClearCacheActions(
118
				$affectedPageUid,
119
				$affectedPagePid,
120
				$updatedFields,
121
				$clearCacheActions
122
			);
123
		}
124
	}
125

  
126
	/**
127
	 * waits for TCEmain commands and looks for deleted pages, if found further
128
	 * changes take place to determine whether the cache needs to be updated
129
	 *
130
	 * @param	string	the TCE command
131
	 * @param	string	the record's table
132
	 * @param	integer	the record's uid
133
	 * @param	array	the commands value, typically an array with more detailed command information
134
	 * @param	t3lib_TCEmain	the TCEmain parent object
135
	 */
136
	public function processCmdmap_postProcess($command, $table, $recordId, $commandValue, t3lib_TCEmain $tceMain) {
137

  
138
		if ($table == 'pages' && $command == 'delete') {
139

  
140
			$deletedRecord = t3lib_BEfunc::getRecord(
141
				$table,
142
				$recordId,
143
				'*',
144
				'',
145
				FALSE
146
			);
147

  
148
			$affectedPageUid = $deletedRecord['uid'];
149
			$affectedPagePid = $deletedRecord['pid'];
150
				// faking the updated fields
151
			$updatedFields   = array('deleted' => 1);
152

  
153
			$clearCacheActions = $this->determineClearCacheActions(
154
				'update',
155
				$updatedFields
156
			);
157

  
158
			$this->processClearCacheActions(
159
				$affectedPageUid,
160
				$affectedPagePid,
161
				$updatedFields,
162
				$clearCacheActions
163
			);
164
		}
165
	}
166

  
167
	/**
168
	 * waits for TCEmain commands and looks for moved pages, if found further
169
	 * changes take place to determine whether the cache needs to be updated
170
	 *
171
	 * @param	string	table name of the moved record
172
	 * @param	integer	the record's uid
173
	 * @param	integer	the record's destination page id
174
	 * @param	array	the record that moved
175
	 * @param	array	array of changed fields
176
	 * @param	t3lib_TCEmain	TCEmain parent object
177
	 */
178
	public function moveRecord_firstElementPostProcess($table, $recordId, $destinationPid, array $movedRecord, array $updatedFields, t3lib_TCEmain $tceMain) {
179

  
180
		if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
181

  
182
			$affectedPageUid    = $recordId;
183
			$affectedPageOldPid = $movedRecord['pid'];
184
			$affectedPageNewPid = $updatedFields['pid'];
185

  
186
			$clearCacheActions = $this->determineClearCacheActions(
187
				'update',
188
				$updatedFields
189
			);
190

  
191
				// clear treelist entries for old parent page
192
			$this->processClearCacheActions(
193
				$affectedPageUid,
194
				$affectedPageOldPid,
195
				$updatedFields,
196
				$clearCacheActions
197
			);
198
				// clear treelist entries for new parent page
199
			$this->processClearCacheActions(
200
				$affectedPageUid,
201
				$affectedPageNewPid,
202
				$updatedFields,
203
				$clearCacheActions
204
			);
205
		}
206
	}
207

  
208
	/**
209
	 * waits for TCEmain commands and looks for moved pages, if found further
210
	 * changes take place to determine whether the cache needs to be updated
211
	 *
212
	 * @param	string	table name of the moved record
213
	 * @param	integer	the record's uid
214
	 * @param	integer	the record's destination page id
215
	 * @param	integer	(negative) page id th page has been moved after
216
	 * @param	array	the record that moved
217
	 * @param	array	array of changed fields
218
	 * @param	t3lib_TCEmain	TCEmain parent object
219
	 */
220
	public function moveRecord_afterAnotherElementPostProcess($table, $recordId, $destinationPid, $originalDestinationPid, array $movedRecord, array $updatedFields, t3lib_TCEmain $tceMain) {
221

  
222
		if($table == 'pages' && $this->requiresUpdate($updatedFields)) {
223

  
224
			$affectedPageUid    = $recordId;
225
			$affectedPageOldPid = $movedRecord['pid'];
226
			$affectedPageNewPid = $updatedFields['pid'];
227

  
228
			$clearCacheActions = $this->determineClearCacheActions(
229
				'update',
230
				$updatedFields
231
			);
232

  
233
				// clear treelist entries for old parent page
234
			$this->processClearCacheActions(
235
				$affectedPageUid,
236
				$affectedPageOldPid,
237
				$updatedFields,
238
				$clearCacheActions
239
			);
240
				// clear treelist entries for new parent page
241
			$this->processClearCacheActions(
242
				$affectedPageUid,
243
				$affectedPageNewPid,
244
				$updatedFields,
245
				$clearCacheActions
246
			);
247
		}
248
	}
249

  
250
	/**
251
	 * checks whether the change requires an update of the treelist cache
252
	 *
253
	 * @param	array	array of changed fields
254
	 * @return	boolean	true if the treelist cache needs to be updated, false if no update to the cache is required
255
	 */
256
	protected function requiresUpdate(array $updatedFields) {
257
		$requiresUpdate = FALSE;
258

  
259
		$updatedFieldNames = array_keys($updatedFields);
260
		foreach ($updatedFieldNames as $updatedFieldName) {
261
			if(in_array($updatedFieldName, $this->updateRequiringFields)) {
262
				$requiresUpdate = TRUE;
263
				break;
264
			}
265
		}
266

  
267
		return	$requiresUpdate;
268
	}
269

  
270
	/**
271
	 * calls the cache maintainance functions according to the determined actions
272
	 *
273
	 * @param	integer	uid of the affected page
274
	 * @param	integer	parent uid of the affected page
275
	 * @param	array	array of updated fields and their new values
276
	 * @param	array	array of actions to carry out
277
	 */
278
	protected function processClearCacheActions($affectedPage, $affectedParentPage, $updatedFields, array $actions) {
279
		$actionNames = array_keys($actions);
280
		foreach ($actionNames as $actionName) {
281
			switch ($actionName) {
282
				case 'allParents':
283
					$this->clearCacheForAllParents($affectedParentPage);
284
					break;
285
				case 'setExpiration':
286
						// only used when setting an end time for a page
287
					$expirationTime = $updatedFields['endtime'];
288
					$this->setCacheExpiration($affectedPage, $expirationTime);
289
					break;
290
				case 'uidInTreelist':
291
					$this->clearCacheWhereUidInTreelist($affectedPage);
292
					break;
293
			}
294
		}
295

  
296
			// from time to time clean the cache from expired entries
297
			// (theoretically every 1000 calls)
298
		$randomNumber = rand(1, 1000);
299
		if($randomNumber == 500) {
300
			$this->removeExpiredCacheEntries();
301
		}
302
	}
303

  
304
	/**
305
	 * clears the treelist cache for all parents of a changed page.
306
	 * gets called after creating a new page and after moving a page
307
	 *
308
	 * @param	integer	parent page id of the changed page, the page to start clearing from
309
	 */
310
	protected function clearCacheForAllParents($affectedParentPage) {
311

  
312
		$rootline = t3lib_BEfunc::BEgetRootLine($affectedParentPage);
313

  
314
		$rootlineIds = array();
315
		foreach($rootline as $page) {
316
			if($page['uid'] != 0) {
317
				$rootlineIds[] = $page['uid'];
318
			}
319
		}
320

  
321
		foreach($rootlineIds as $rootlineId) {
322

  
323
				// delete the rootline, must contain
324
			$GLOBALS['TYPO3_DB']->exec_DELETEquery(
325
				'cache_treelist',
326
				'pid = ' . $rootlineId
327
			);
328
		}
329
	}
330

  
331
	/**
332
	 * clears the treelist cache for all pages where the affected page is found
333
	 * in the treelist
334
	 *
335
	 * @param	integer	Id of the changed page
336
	 */
337
	protected function clearCacheWhereUidInTreelist($affectedPage) {
338
		$GLOBALS['TYPO3_DB']->exec_DELETEquery(
339
			'cache_treelist',
340
			$GLOBALS['TYPO3_DB']->listQuery(
341
				'treelist',
342
				$affectedPage,
343
				'cache_treelist'
344
			)
345
		);
346
	}
347

  
348
	/**
349
	 * sets an expiration time for all cache entries having the changed page in
350
	 * the treelist.
351
	 *
352
	 * @param	integer	uid of the changed page
353
	 */
354
	protected function setCacheExpiration($affectedPage, $expirationTime) {
355

  
356
		$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
357
			'cache_treelist',
358
			$GLOBALS['TYPO3_DB']->listQuery(
359
				'treelist',
360
				$affectedPage,
361
				'cache_treelist'
362
			),
363
			array(
364
				'expires' => $expirationTime
365
			)
366
		);
367
	}
368

  
369
	/**
370
	 * removes all expired treelist cache entries
371
	 *
372
	 */
373
	protected function removeExpiredCacheEntries() {
374
		$GLOBALS['TYPO3_DB']->exec_DELETEquery(
375
			'cache_treelist',
376
			'expires <= ' . time()
377
		);
378
	}
379

  
380
	/**
381
	 * determines what happened to the page record, this is necessary to clear
382
	 * as less cache entries as needed later
383
	 *
384
	 * @param	string	TCEmain operation status, either 'new' or 'update'
385
	 * @param	array	array of updated fields
386
	 * @return	string	list of actions that happened to the page record
387
	 */
388
	protected function determineClearCacheActions($status, $updatedFields) {
389
		$actions = array();
390

  
391
		if ($status == 'new') {
392
				// new page
393
			$actions['allParents'] = TRUE;
394
		} elseif ($status == 'update') {
395
			$updatedFieldNames = array_keys($updatedFields);
396

  
397
			foreach ($updatedFieldNames as $updatedFieldName) {
398
				switch ($updatedFieldName) {
399
					case 'pid':
400
							// page moved
401
						$actions['allParents']    = TRUE;
402
						$actions['uidInTreelist'] = TRUE;
403
						break;
404
					case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['disabled']:
405
					case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['fe_group']:
406
					case $GLOBALS['TCA']['pages']['ctrl']['delete']:
407
					case 'extendToSubpages':
408
					case 'php_tree_stop':
409
							// page hidden / unhidden / deleted / extendToSubpages set
410
							// php_tree_stop and/or FE groups set
411
						$actions['uidInTreelist'] = TRUE;
412
						break;
413
					case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['starttime']:
414
							/*
415
							 start time set/unset
416
							 Doesn't matter whether it was set or unset, in both
417
							 cases the cache needs to be cleared. When setting a
418
							 start time the page must be removed from the
419
							 treelist. When unsetting the start time it must
420
							 become listed in the tree list again.
421
							*/
422
						$actions['uidInTreelist'] = TRUE;
423
						break;
424
					case $GLOBALS['TCA']['pages']['ctrl']['enablecolumns']['endtime']:
425
							/*
426
						 	 end time set/unset
427
							 When setting an end time the cache entry needs an
428
							 expiration time. When unsetting the end time the
429
							 page must become listed in the treelist again.
430
							*/
431
						if($updatedFields['endtime'] > 0) {
432
							$actions['setExpiration'] = TRUE;
433
						} else {
434
							$actions['uidInTreelist'] = TRUE;
435
						}
436
						break;
437
					default:
438
						if (in_array($updatedFieldName, $this->updateRequiringFields)) {
439
							$actions['uidInTreelist'] = TRUE;
440
						}
441
				}
442
			}
443
		}
444

  
445
		return $actions;
446
	}
447

  
448
}
449

  
450

  
451
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/hooks/class.tx_cms_treelistcacheupdate.php'])	{
452
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/hooks/class.tx_cms_treelistcacheupdate.php']);
453
}
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ChangeLog 2008-11-04 00:59:01.000000000 +0100
1
2008-11-03  Michael Stucki  <michael@typo3.org>
2

  
3
	* Check if files in search matches are still existing before displaying them
4

  
1 5
2008-04-01  Michael Stucki  <michael@typo3.org>
2 6

  
3 7
	* 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
36 36

  
37 37

  
38 38
// TYPO3: Had to change name to "user_DoubleMetaPhone" from just "DoubleMetaPhone" because TYPO3 requires a user class to be prefixed so:
39
// 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:
40
// TYPO3:			$TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
41
// TYPO3: Of course you can write your own metaphone hook methods by taking this class and configuration as example.
39
// 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
40
// TYPO3: Of course you can write your own metaphone hook methods by taking this class and configuration as example (also see ext_localconf.php)
42 41

  
43 42
class user_DoubleMetaPhone
44 43
{
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/class.indexer.php 2008-11-04 00:59:01.000000000 +0100
191 191
	var $freqRange = 32000;
192 192
	var $freqMax = 0.1;
193 193

  
194
	var $enableMetaphoneSearch = false;
195
	var $storeMetaphoneInfoAsWords;
196
	var $metaphoneContent = '';
197

  
194 198
		// Objects:
195 199
	/**
196 200
	 * Charset class object
......
452 456
		$this->maxExternalFiles = t3lib_div::intInRange($this->indexerConfig['maxExternalFiles'],0,1000,5);
453 457
		$this->flagBitMask = t3lib_div::intInRange($this->indexerConfig['flagBitMask'],0,255);
454 458

  
459
			// Workaround: If the extension configuration was not updated yet, the value is not existing
460
		$this->enableMetaphoneSearch = isset($this->indexerConfig['enableMetaphoneSearch']) ? ($this->indexerConfig['enableMetaphoneSearch'] ? 1 : 0) : 1;
461

  
462
		$this->storeMetaphoneInfoAsWords = $this->isTableUsed('index_words') ? false : ($this->enableMetaphoneSearch ? true : false);
463

  
455 464
			// Initialize external document parsers:
456 465
			// Example configuration, see ext_localconf.php of this file!
457 466
		if ($this->conf['index_externals'])	{
......
468 477

  
469 478
			// Initialize metaphone hook:
470 479
			// Example configuration (localconf.php) for this hook: $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
471
		if ($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'])	{
480
			// Make sure that the hook is loaded _after_ indexed_search as this may overwrite the hook depending on the configuration.
481
		if ($this->enableMetaphoneSearch && $TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'])	{
472 482
			$this->metaphoneObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone']);
473 483
			$this->metaphoneObj->pObj = &$this;
474 484
		}
......
550 560
			$this->log_pull();
551 561

  
552 562
				// 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!)
553
			$this->content_md5h = $this->md5inthash(implode($this->contentParts,''));
563
			$this->content_md5h = $this->md5inthash(implode('', $this->contentParts));
554 564

  
555 565
				// This function checks if there is already a page (with gr_list = 0,-1) indexed and if that page has the very same contentHash.
556 566
				// 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.
......
580 590

  
581 591
						// Check words and submit to word list if not there
582 592
				$this->log_push('Check word list and submit words','');
583
					$this->checkWordList($indexArr);
584
					$this->submitWords($indexArr,$this->hash['phash']);
593
					if ($this->isTableUsed('index_words')) {
594
						$this->checkWordList($indexArr);
595
						$this->submitWords($indexArr,$this->hash['phash']);
596
					}
585 597
				$this->log_pull();
586 598

  
587 599
						// Set parsetime
......
1055 1067

  
1056 1068
										// Check words and submit to word list if not there
1057 1069
									$this->log_push('Check word list and submit words','');
1058
										$this->checkWordList($indexArr);
1059
										$this->submitWords($indexArr,$phash_arr['phash']);
1070
										if ($this->isTableUsed('index_words')) {
1071
											$this->checkWordList($indexArr);
1072
											$this->submitWords($indexArr,$phash_arr['phash']);
1073
										}
1060 1074
									$this->log_pull();
1061 1075

  
1062 1076
										// Set parsetime
......
1244 1258
		$this->analyzeHeaderinfo($indexArr,$content,'description',5);
1245 1259
		$this->analyzeBody($indexArr,$content);
1246 1260

  
1247
		return ($indexArr);
1261
		return $indexArr;
1248 1262
	}
1249 1263

  
1250 1264
	/**
......
1257 1271
	 * @return	void
1258 1272
	 */
1259 1273
	function analyzeHeaderinfo(&$retArr,$content,$key,$offset) {
1260
		reset($content[$key]);
1261
		while(list(,$val)=each($content[$key]))  {
1262
			$val = substr($val,0,60);	// Max 60 - because the baseword varchar IS 60. This MUST be the same.
1274
		foreach ($content[$key] as $val) {
1275
			$val = substr($val,0,60);	// Cut after 60 chars because the index_words.baseword varchar field has this length. This MUST be the same.
1276

  
1277
			if (!isset($retArr[$val])) {
1278
					// Word ID (wid)
1279
				$retArr[$val]['hash'] = $this->md5inthash($val);
1280

  
1281
					// Metaphone value is also 60 only chars long
1282
				$metaphone = $this->enableMetaphoneSearch
1283
						? substr($this->metaphone($val,$this->storeMetaphoneInfoAsWords),0,60)
1284
						: '';
1285
				$retArr[$val]['metaphone'] = $metaphone;
1286
			}
1287

  
1288
				// Build metaphone fulltext string (can be used for fulltext indexing)
1289
			if ($this->storeMetaphoneInfoAsWords) {
1290
				$this->metaphoneContent.= ' '.$retArr[$val]['metaphone'];
1291
			}
1292

  
1293
				// Priority used for flagBitMask feature (see extension configuration)
1263 1294
			$retArr[$val]['cmp'] = $retArr[$val]['cmp']|pow(2,$offset);
1264
			$retArr[$val]['count'] = $retArr[$val]['count']+1;
1265
			$retArr[$val]['hash'] = hexdec(substr(md5($val),0,7));
1266
			$retArr[$val]['metaphone'] = $this->metaphone($val);
1295

  
1296
			$retArr[$val]['count']++;	// Increase number of occurences
1267 1297
			$this->wordcount++;
1268 1298
		}
1269 1299
	}
......
1276 1306
	 * @return	void
1277 1307
	 */
1278 1308
	function analyzeBody(&$retArr,$content) {
1279
		foreach($content['body'] as $key => $val)	{
1280
			$val = substr($val,0,60);	// Max 60 - because the baseword varchar IS 60. This MUST be the same.
1281
			if(!isset($retArr[$val])) {
1309
		foreach ($content['body'] as $key => $val) {
1310
			$val = substr($val,0,60);	// Cut after 60 chars because the index_words.baseword varchar field has this length. This MUST be the same.
1311

  
1312
			if (!isset($retArr[$val])) {
1313
					// First occurence (used for ranking results)
1282 1314
				$retArr[$val]['first'] = $key;
1283
				$retArr[$val]['hash'] = hexdec(substr(md5($val),0,7));
1284
				$retArr[$val]['metaphone'] = $this->metaphone($val);
1315

  
1316
					// Word ID (wid)
1317
				$retArr[$val]['hash'] = $this->md5inthash($val);
1318

  
1319
					// Metaphone value is also only 60 chars long
1320
				$metaphone = $this->enableMetaphoneSearch
1321
						? substr($this->metaphone($val,$this->storeMetaphoneInfoAsWords),0,60)
1322
						: '';
1323
				$retArr[$val]['metaphone'] = $metaphone;
1324
			}
1325

  
1326
				// Build metaphone fulltext string (can be used for fulltext indexing)
1327
			if ($this->storeMetaphoneInfoAsWords) {
1328
				$this->metaphoneContent.= ' '.$retArr[$val]['metaphone'];
1285 1329
			}
1286
			$retArr[$val]['count'] = $retArr[$val]['count']+1;
1330

  
1331
			$retArr[$val]['count']++;	// Increase number of occurences
1287 1332
			$this->wordcount++;
1288 1333
		}
1289 1334
	}
......
1300 1345
		if (is_object($this->metaphoneObj))	{
1301 1346
			$tmp = $this->metaphoneObj->metaphone($word, $this->conf['sys_language_uid']);
1302 1347
		} else {
1348
				// Use native PHP function instead of advanced doubleMetaphone class
1303 1349
			$tmp = metaphone($word);
1304 1350
		}
1305 1351

  
1306
			// Return raw value?
1307
		if ($retRaw)	return $tmp;
1352
		if ($retRaw) {	// Return raw value?
1353
			$ret = $tmp;
1354
		} elseif (strlen($tmp)) {	// Otherwise create hash and return integer
1355
			$ret = $this->md5inthash($tmp);
1356
		} else {
1357
			$ret = 0;
1358
		}
1308 1359

  
1309
			// Otherwise create hash and return integer
1310
		if($tmp=='') $ret=0; else $ret=hexdec(substr(md5($tmp),0,7));
1311 1360
		return $ret;
1312 1361
	}
1313 1362

  
......
1368 1417
 			'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
1369 1418
		);
1370 1419

  
1371
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
1420
		if ($this->isTableUsed('index_phash')) {
1421
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
1422
		}
1372 1423

  
1373 1424
			// PROCESSING index_section
1374 1425
		$this->submit_section($this->hash['phash'],$this->hash['phash']);
......
1379 1430
			// PROCESSING index_fulltext
1380 1431
		$fields = array(
1381 1432
			'phash' => $this->hash['phash'],
1382
			'fulltextdata' => implode(' ', $this->contentParts)
1433
			'fulltextdata' => implode(' ', $this->contentParts),
1434
			'metaphonedata' => $this->metaphoneContent
1383 1435
		);
1384 1436
		if ($this->indexerConfig['fullTextDataLength']>0)	{
1385 1437
			$fields['fulltextdata'] = substr($fields['fulltextdata'],0,$this->indexerConfig['fullTextDataLength']);
1386 1438
		}
1387
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
1439
		if ($this->isTableUsed('index_fulltext')) {
1440
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
1441
		}
1388 1442

  
1389 1443
			// PROCESSING index_debug
1390 1444
		if ($this->indexerConfig['debugMode'])	{
......
1399 1453
						'lexer' => $this->lexerObj->debugString,
1400 1454
					))
1401 1455
			);
1402
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
1456
			if ($this->isTableUsed('index_debug')) {
1457
				$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
1458
			}
1403 1459
		}
1404 1460
	}
1405 1461

  
......
1420 1476
			'hash_gr_list' => $this->md5inthash($this->conf['gr_list']),
1421 1477
			'gr_list' => $this->conf['gr_list']
1422 1478
		);
1423
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_grlist', $fields);
1479
		if ($this->isTableUsed('index_grlist')) {
1480
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_grlist', $fields);
1481
		}
1424 1482
	}
1425 1483

  
1426 1484
	/**
......
1440 1498

  
1441 1499
		$this->getRootLineFields($fields);
1442 1500

  
1443
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_section', $fields);
1501
		if ($this->isTableUsed('index_section')) {
1502
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_section', $fields);
1503
		}
1444 1504
	}
1445 1505

  
1446 1506
	/**
......
1452 1512
	function removeOldIndexedPages($phash)	{
1453 1513
			// Removing old registrations for all tables. Because the pages are TYPO3 pages there can be nothing else than 1-1 relations here.
1454 1514
		$tableArr = explode(',','index_phash,index_section,index_grlist,index_fulltext,index_debug');
1455
		foreach($tableArr as $table)	{
1456
			$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
1515
		foreach ($tableArr as $table) {
1516
			if ($this->isTableUsed($table)) {
1517
				$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
1518
			}
1457 1519
		}
1458 1520
			// 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).
1459
		$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3='.intval($phash));
1521
		if ($this->isTableUsed('index_section')) {
1522
			$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3='.intval($phash));
1523
		}
1460 1524
	}
1461 1525

  
1462 1526

  
......
1520 1584
			'tstamp' => time(),
1521 1585
			'crdate' => time(),
1522 1586
			'gr_list' => $this->conf['gr_list'],
1523
 			'externalUrl' => $fileParts['scheme'] ? 1 : 0,
1524
 			'recordUid' => intval($this->conf['recordUid']),
1525
 			'freeIndexUid' => intval($this->conf['freeIndexUid']),
1526
 			'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
1587
			'externalUrl' => $fileParts['scheme'] ? 1 : 0,
1588
			'recordUid' => intval($this->conf['recordUid']),
1589
			'freeIndexUid' => intval($this->conf['freeIndexUid']),
1590
			'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
1527 1591
		);
1528
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
1592
		if ($this->isTableUsed('index_phash')) {
1593
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
1594
		}
1529 1595

  
1530 1596
			// PROCESSING index_fulltext
1531 1597
		$fields = array(
1532 1598
			'phash' => $hash['phash'],
1533
			'fulltextdata' => implode(' ', $contentParts)
1599
			'fulltextdata' => implode(' ', $contentParts),
1600
			'metaphonedata' => $this->metaphoneContent
1534 1601
		);
1535 1602
		if ($this->indexerConfig['fullTextDataLength']>0)	{
1536 1603
			$fields['fulltextdata'] = substr($fields['fulltextdata'],0,$this->indexerConfig['fullTextDataLength']);
1537 1604
		}
1538
		$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
1605
		if ($this->isTableUsed('index_fulltext')) {
1606
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_fulltext', $fields);
1607
		}
1539 1608

  
1540 1609
			// PROCESSING index_debug
1541 1610
		if ($this->indexerConfig['debugMode'])	{
......
1548 1617
						'lexer' => $this->lexerObj->debugString,
1549 1618
					))
1550 1619
			);
1551
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
1620
			if ($this->isTableUsed('index_debug')) {
1621
				$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_debug', $fields);
1622
			}
1552 1623
		}
1553 1624
	}
1554 1625

  
......
1560 1631
	 */
1561 1632
	function submitFile_grlist($hash)	{
1562 1633
			// 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.
1563
		$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']).')');
1564
		if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
1634
		if ($this->isTableUsed('index_grlist')) {
1635
			$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']).')');
1636
		} else {
1637
			$res = false;
1638
		}
1639

  
1640
		if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
1565 1641
			$this->submit_grlist($hash,$hash);
1566 1642
		}
1567 1643
	}
......
1573 1649
	 * @return	void
1574 1650
	 */
1575 1651
	function submitFile_section($hash)	{
1576
			// Testing if there is a section
1577
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_section', 'phash='.intval($hash).' AND page_id='.intval($this->conf['id']));
1578
		if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
1652
			// Testing if there is already a section
1653
		if ($this->isTableUsed('index_section')) {
1654
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_section', 'phash='.intval($hash).' AND page_id='.intval($this->conf['id']));
1655
		} else {
1656
			$res = false;
1657
		}
1658

  
1659
		if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
1579 1660
			$this->submit_section($hash,$this->hash['phash']);
1580 1661
		}
1581 1662
	}
......
1587 1668
	 * @return	void
1588 1669
	 */
1589 1670
	function removeOldIndexedFiles($phash)	{
1590

  
1591 1671
			// Removing old registrations for tables.
1592 1672
		$tableArr = explode(',','index_phash,index_grlist,index_fulltext,index_debug');
1593
		foreach($tableArr as $table)	{
1594
			$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
1673
		foreach ($tableArr as $table) {
1674
			if ($this->isTableUsed($table)) {
1675
				$GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash='.intval($phash));
1676
			}
1595 1677
		}
1596 1678
	}
1597 1679

  
......
1623 1705
	 * @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.
1624 1706
	 */
1625 1707
	function checkMtimeTstamp($mtime,$phash)	{
1708
		$out = 0;
1626 1709

  
1627 1710
			// Select indexed page:
1628
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('item_mtime,tstamp', 'index_phash', 'phash='.intval($phash));
1629
		$out = 0;
1711
		if ($this->isTableUsed('index_phash')) {
1712
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('item_mtime,tstamp', 'index_phash', 'phash='.intval($phash));
1713
		} else {
1714
			$res = false;
1715
		}
1630 1716

  
1631 1717
			// If there was an indexing of the page...:
1632
		if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1718
		if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1633 1719
			if ($this->tstamp_maxAge && ($row['tstamp']+$this->tstamp_maxAge) < time())	{	// If max age is exceeded, index the page
1634 1720
				$out = 1;		// The configured max-age was exceeded for the document and thus it's indexed.
1635 1721
			} else {
......
1660 1746
	 */
1661 1747
	function checkContentHash()	{
1662 1748
			// With this query the page will only be indexed if it's content is different from the same "phash_grouping" -page.
1663
		$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));
1664
		if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1749
		if ($this->isTableUsed('index_phash')) {
1750
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_phash', 'phash_grouping='.intval($this->hash['phash_grouping']).' AND contentHash='.intval($this->content_md5h));
1751
		} else {
1752
			$res = false;
1753
		}
1754

  
1755
		if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1665 1756
			return $row;
1666 1757
		}
1667 1758
		return 1;
......
1676 1767
	 * @return	boolean		Returns true if the document needs to be indexed (that is, there was no result)
1677 1768
	 */
1678 1769
	function checkExternalDocContentHash($hashGr,$content_md5h)	{
1679
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A', 'A.phash_grouping='.intval($hashGr).' AND A.contentHash='.intval($content_md5h));
1680
		if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1770
		if ($this->isTableUsed('index_phash')) {
1771
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash', 'phash_grouping='.intval($hashGr).' AND contentHash='.intval($content_md5h));
1772
		} else {
1773
			$res = false;
1774
		}
1775

  
1776
		if ($res && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1681 1777
			return 0;
1682 1778
		}
1683 1779
		return 1;
......
1690 1786
	 * @return	void
1691 1787
	 */
1692 1788
	function is_grlist_set($phash_x)	{
1693
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash_x', 'index_grlist', 'phash_x='.intval($phash_x));
1694
		return $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1789
		if ($this->isTableUsed('index_grlist')) {
1790
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash_x', 'index_grlist', 'phash_x='.intval($phash_x));
1791
		} else {
1792
			$res = false;
1793
		}
1794
		return $res ? $GLOBALS['TYPO3_DB']->sql_num_rows($res) : false;
1695 1795
	}
1696 1796

  
1697 1797
	/**
......
1703 1803
	 * @see submit_grlist()
1704 1804
	 */
1705 1805
	function update_grlist($phash,$phash_x)	{
1706
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($phash).' AND hash_gr_list='.$this->md5inthash($this->conf['gr_list']));
1707
		if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
1806
		if ($this->isTableUsed('index_grlist')) {
1807
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($phash).' AND hash_gr_list='.$this->md5inthash($this->conf['gr_list']));
1808
		} else {
1809
			$res = false;
1810
		}
1811

  
1812
		if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
1708 1813
			$this->submit_grlist($phash,$phash_x);
1709 1814
			$this->log_setTSlogMessage("Inserted gr_list '".$this->conf['gr_list']."' for phash '".$phash."'",1);
1710 1815
		}
......
1723 1828
		);
1724 1829
		if ($mtime)	{ $updateFields['item_mtime'] = intval($mtime); }
1725 1830

  
1726
		$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1831
		if ($this->isTableUsed('index_phash')) {
1832
			$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1833
		}
1727 1834
	}
1728 1835

  
1729 1836
	/**
......
1737 1844
			'freeIndexSetId' => intval($this->conf['freeIndexSetId'])
1738 1845
		);
1739 1846

  
1740
		$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1847
		if ($this->isTableUsed('index_phash')) {
1848
			$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1849
		}
1741 1850
	}
1742 1851

  
1743 1852
	/**
......
1752 1861
			'parsetime' => intval($parsetime)
1753 1862
		);
1754 1863

  
1755
		$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1864
		if ($this->isTableUsed('index_phash')) {
1865
			$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash='.intval($phash), $updateFields);
1866
		}
1756 1867
	}
1757 1868

  
1758 1869
	/**
......
1765 1876
		$updateFields = array();
1766 1877
		$this->getRootLineFields($updateFields);
1767 1878

  
1768
		$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id='.intval($this->conf['id']), $updateFields);
1879
		if ($this->isTableUsed('index_section')) {
1880
			$GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id='.intval($this->conf['id']), $updateFields);
1881
		}
1769 1882
	}
1770 1883

  
1771 1884
	/**
......
1795 1908
	 * @return	void
1796 1909
	 */
1797 1910
	function removeLoginpagesWithContentHash()	{
1798
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A,index_grlist B', '
1911
		if ($this->isTableUsed('index_phash,index_grlist')) {
1912
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_phash A,index_grlist B', '
1799 1913
					A.phash=B.phash
1800 1914
					AND A.phash_grouping='.intval($this->hash['phash_grouping']).'
1801 1915
					AND B.hash_gr_list!='.$this->md5inthash($this->defaultGrList).'
1802 1916
					AND A.contentHash='.intval($this->content_md5h));
1803
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1804
			$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);
1805
			$this->removeOldIndexedPages($row['phash']);
1917
		} else {
1918
			$res = false;
1919
		}
1920

  
1921
		if ($res) {
1922
			while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
1923
				$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);
1924
				$this->removeOldIndexedPages($row['phash']);
1925
			}
1806 1926
		}
1807 1927
	}
1808 1928

  
......
1817 1937
		require_once(t3lib_extMgm::extPath('crawler').'class.tx_crawler_lib.php');
1818 1938
	}
1819 1939

  
1940
	/**
1941
	 * Check if the tables provided are configured for usage.
1942
	 * This becomes neccessary for extensions that provide additional database functionality like indexed_search_mysql.
1943
	 *
1944
	 * @param	string		Comma-separated list of tables
1945
	 * @return	boolean		True if given tables are enabled
1946
	 */
1947
	function isTableUsed($table_list) {
1948
		$OK = true;
1949
		$tableArr = t3lib_div::trimExplode(',', $table_list);
1950
		$enabledTableList = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['use_tables'];
1951

  
1952
		foreach ($tableArr as $table) {
1953
			if (!t3lib_div::inList($enabledTableList, $table)) {
1954
				$OK = false;
1955
			}
1956
		}
1957

  
1958
		return $OK;
1959
	}
1960

  
1820 1961

  
1821 1962

  
1822 1963

  
......
1846 1987
		}
1847 1988
		if (count($phashArr))	{
1848 1989
			$cwl = implode(',',$phashArr);
1849
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'index_words', 'wid IN ('.$cwl.')');
1990
			if ($this->isTableUsed('index_words')) {
1991
				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'index_words', 'wid IN ('.$cwl.')');
1992
			} else {
1993
				$res = false;
1994
			}
1850 1995

  
1851
			if($GLOBALS['TYPO3_DB']->sql_num_rows($res)!=count($wl)) {
1996
			if ($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res)!=count($wl)) {
1852 1997
				$this->log_setTSlogMessage('Inserting words: '.(count($wl)-$GLOBALS['TYPO3_DB']->sql_num_rows($res)),1);
1853
				while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1998
				while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1854 1999
					unset($wl[$row['baseword']]);
1855 2000
				}
1856 2001

  
1857 2002
				reset($wl);
1858
				while(list($key,$val)=each($wl)) {
2003
				while (list($key,$val)=each($wl)) {
1859 2004
					$insertFields = array(
1860 2005
						'wid' => $val['hash'],
1861 2006
						'baseword' => $key,
1862 2007
						'metaphone' => $val['metaphone']
1863 2008
					);
1864 2009
						// 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.
1865
					$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_words', $insertFields);
2010
					if ($this->isTableUsed('index_words')) {
2011
						$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_words', $insertFields);
2012
					}
1866 2013
				}
1867 2014
			}
1868 2015
		}
......
1876 2023
	 * @return	void
1877 2024
	 */
1878 2025
	function submitWords($wl,$phash) {
1879
		$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash='.intval($phash));
2026
		if ($this->isTableUsed('index_rel')) {
2027
			$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash='.intval($phash));
2028
		}
1880 2029

  
1881
		foreach($wl as $val)	{
2030
		foreach ($wl as $val) {
1882 2031
			$insertFields = array(
1883 2032
				'phash' => $phash,
1884 2033
				'wid' => $val['hash'],
......
1888 2037
				'flags' => ($val['cmp'] & $this->flagBitMask)
1889 2038
			);
1890 2039

  
1891
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields);
2040
			if ($this->isTableUsed('index_rel')) {
2041
				$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields);
2042
			}
1892 2043
		}
1893 2044
	}
1894 2045

  
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/doc/README.txt 2008-11-04 00:59:01.000000000 +0100
1 1
A full documentation manual for the indexed search extension can be found in the extension "doc_indexed_search" in the TER.
2 2
See http://typo3.org/documentation/document-library/extension-manuals/doc_indexed_search/current/view/
3

  
4

  
5
This is a list of all tables which are used by this extension:
6

  
7
index_phash
8
- Page information
9

  
10
index_fulltext
11
- Fulltext data
12

  
13
index_rel
14
- Relations between index_phash and index_words
15

  
16
index_words
17
- baseword table
18

  
19
index_section
20
- section index (= first 3 levels of the rootline for this document)
21

  
22
index_grlist
23
- group list information
24
- 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
28 28
  # 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.
29 29
disableFrontendIndexing = 0
30 30

  
31
  # cat=basic; type=int; label=Enable metaphone search (sounds like). 0=disabled, 1=use internal metaphone parser, 2=use advanced doubleMetaphone parser.
32
enableMetaphoneSearch = 1
33

  
31 34
  # 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.
32 35
minAge = 24
33 36

  
......
40 43
  # 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.
41 44
useCrawlerForExternalFiles = 0
42 45

  
43
  # 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)
46
  # 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)
44 47
flagBitMask = 192
45 48

  
46 49
  # 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
43 43
	'tif' => 'EXT:indexed_search/class.external_parser.php:&tx_indexed_search_extparse',
44 44
);
45 45

  
46
$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';
47

  
48
$_EXTCONF = unserialize($_EXTCONF);	// unserializing the configuration so we can use it here:
49

  
50
	// Use the advanced doubleMetaphone parser instead of the internal one (usage of metaphone parsers is generally disabled by default)
51
if (isset($_EXTCONF['enableMetaphoneSearch']) && intval($_EXTCONF['enableMetaphoneSearch'])==2) {
52
	$TYPO3_CONF_VARS['EXTCONF']['indexed_search']['metaphone'] = 'EXT:indexed_search/class.doublemetaphone.php:&user_DoubleMetaPhone';
53
}
46 54

  
47 55
	// EXAMPLE configuration of hooks:
48 56
/*
typo3_src-4.2.2_mysql_fulltext_index/typo3/sysext/indexed_search/ext_tables.sql 2008-11-04 00:59:01.000000000 +0100
38 38
CREATE TABLE index_fulltext (
39 39
  phash int(11) DEFAULT '0' NOT NULL,
40 40
  fulltextdata mediumtext,
41
  metaphonedata mediumtext NOT NULL,
41 42
  PRIMARY KEY (phash)
42 43
) ENGINE=InnoDB;
43 44

  
......
116 117
  PRIMARY KEY (uid)
117 118
) ENGINE=InnoDB;
118 119

  
119

  
120 120
#
121 121
# Table structure for table 'index_stat_word'
122 122
#
......
125 125
  word varchar(30) DEFAULT '' NOT NULL,
126 126
  index_stat_search_id int(11) DEFAULT '0' NOT NULL,
127 127
  tstamp int(11) DEFAULT '0' NOT NULL,
128
  pageid int(11) DEFAULT '0' NOT NULL,
128 129
  PRIMARY KEY (uid),
129 130
  KEY tstamp (tstamp,word)
130 131
) ENGINE=InnoDB;
......
177 178
  PRIMARY KEY (uid),
178 179
  KEY parent (pid)
179 180
);
180

  
181

  
182
#
183
# Table structure for table 'index_stat_word'
184
#
... This diff was truncated because it exceeds the maximum size that can be displayed.
(3-3/3)