X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/49632368c2951ea3fcf5a152b291a7ae57398508..53ef6f4240bb31e05fe4da6471427e2cdb8d42b3:/t3lib/class.t3lib_refindex.php diff --git a/t3lib/class.t3lib_refindex.php b/t3lib/class.t3lib_refindex.php index 3ecb6620bba..ec4f67c9cbd 100755 --- a/t3lib/class.t3lib_refindex.php +++ b/t3lib/class.t3lib_refindex.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * -* (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com) +* (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -60,9 +60,10 @@ * */ +require_once(PATH_t3lib.'class.t3lib_befunc.php'); require_once(PATH_t3lib.'class.t3lib_tcemain.php'); require_once(PATH_t3lib.'class.t3lib_flexformtools.php'); -require_once(PATH_typo3.'sysext/indexed_search/class.lexer.php'); +//require_once(PATH_typo3.'sysext/indexed_search/class.lexer.php'); // Disabled until Kasper finishes this feature. Apart from that, t3lib classes should never require stuff from extensions. @@ -89,7 +90,7 @@ class t3lib_refindex { var $words_strings = array(); var $words = array(); - + var $hashVersion = 1; // Number which we can increase if a change in the code means we will have to force a re-generation of the index. @@ -150,7 +151,7 @@ class t3lib_refindex { $result['relations'] = $relations; } else return FALSE; // Weird mistake I would say... - + // Words: if (!$testOnly) $this->wordIndexing($table,$uid); } @@ -184,7 +185,7 @@ class t3lib_refindex { list($record) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*',$table,'uid='.intval($uid)); if (is_array($record)) { - + // Initialize: $this->words_strings = array(); $this->words = array(); @@ -202,12 +203,8 @@ class t3lib_refindex { // Based on type, switch((string)$dat['type']) { case 'db': - case 'select': $this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']); break; - case 'inline': - $this->createEntryData_inlineRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']); - break; case 'file': $this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']); break; @@ -427,7 +424,7 @@ class t3lib_refindex { if ($conf['type']=='flex') { // Get current value array: - // NOTICE: failure to resolve Data Structures can lead to integrity problems with the reference index. Please look up the note in the JavaDoc documentation for the function t3lib_BEfunc::getFlexFormDS() + // NOTICE: failure to resolve Data Structures can lead to integrity problems with the reference index. Please look up the note in the JavaDoc documentation for the function t3lib_BEfunc::getFlexFormDS() $dataStructArray = t3lib_BEfunc::getFlexFormDS($conf, $row, $table,'',$this->WSOL); $currentValueArray = t3lib_div::xml2array($value); @@ -635,11 +632,12 @@ class t3lib_refindex { * @param string 32-byte hash string identifying the record from sys_refindex which you wish to change the value for * @param mixed Value you wish to set for reference. If NULL, the reference is removed (unless a soft-reference in which case it can only be set to a blank string). If you wish to set a database reference, use the format "[table]:[uid]". Any other case, the input value is set as-is * @param boolean Return $dataArray only, do not submit it to database. + * @param boolean If set, it will bypass check for workspace-zero and admin user * @return string If a return string, that carries an error message, otherwise false (=OK) (except if $returnDataArray is set!) */ - function setReferenceValue($hash,$newValue,$returnDataArray=FALSE) { - - if ($GLOBALS['BE_USER']->workspace===0 && $GLOBALS['BE_USER']->isAdmin()) { + function setReferenceValue($hash,$newValue,$returnDataArray=FALSE,$bypassWorkspaceAdminCheck=FALSE) { + + if (($GLOBALS['BE_USER']->workspace===0 && $GLOBALS['BE_USER']->isAdmin()) || $bypassWorkspaceAdminCheck) { // Get current index from Database: list($refRec) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( @@ -704,6 +702,7 @@ class t3lib_refindex { if ($returnDataArray) { return $dataArray; } else { + // Execute CMD array: $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = FALSE; @@ -711,10 +710,10 @@ class t3lib_refindex { $tce->bypassWorkspaceRestrictions = TRUE; $tce->bypassFileHandling = TRUE; $tce->bypassAccessCheckForRecords = TRUE; // Otherwise this cannot update things in deleted records... - + $tce->start($dataArray,array()); // check has been done previously that there is a backend user which is Admin and also in live workspace $tce->process_datamap(); - + // Return errors if any: if (count($tce->errorLog)) { return chr(10).'TCEmain:'.implode(chr(10).'TCEmain:',$tce->errorLog); @@ -853,12 +852,17 @@ class t3lib_refindex { * Indexing words * *******************************/ - + /** - * + * Indexing words from table records. Can be useful for quick backend look ups in records across the system. */ function wordIndexing($table,$uid) { - + return; // Disabled until Kasper finishes this feature. If someone else needs it in the meantime you are welcome to complete it. Below my todo list. + + // TODO: + // - Flag to disable indexing + // - Clean-up to remove words not used anymore and indexes for records not in the system anymore. + // - UTF-8 compliant substr() $lexer = t3lib_div::makeInstance('tx_indexedsearch_lexer'); $words = $lexer->split2Words(implode(' ',$this->words_strings)); foreach($words as $w) { @@ -878,9 +882,9 @@ class t3lib_refindex { */ function updateWordIndex($words,$table,$uid) { - // Submit words to + // Submit words to $this->submitWords($words); - + // Result id and remove relations: $rid = t3lib_div::md5int($table.':'.$uid); $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_refindex_rel', 'rid='.intval($rid)); @@ -915,7 +919,7 @@ class t3lib_refindex { $hashArr = array(); foreach($wl as $w) { - $hashArr[] = t3lib_div::md5int($w); + $hashArr[] = t3lib_div::md5int($w); } $wl = array_flip($wl); @@ -999,7 +1003,7 @@ class t3lib_refindex { $recCount=0; $tableCount=0; - $headerContent = $testOnly ? 'Reference Index being TESTED (nothing written)' : 'Reference Index being Updated'; + $headerContent = $testOnly ? 'Reference Index being TESTED (nothing written, use "-e" to update)' : 'Reference Index being Updated'; if ($cli_echo) echo '*******************************************'.chr(10). $headerContent.chr(10).