/***************************************************************
* 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
*
*/
+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.
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.
$result['relations'] = $relations;
} else return FALSE; // Weird mistake I would say...
-
+
// Words:
if (!$testOnly) $this->wordIndexing($table,$uid);
}
list($record) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*',$table,'uid='.intval($uid));
if (is_array($record)) {
-
+
// Initialize:
$this->words_strings = array();
$this->words = array();
// 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;
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);
* @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(
if ($returnDataArray) {
return $dataArray;
} else {
+
// Execute CMD array:
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = FALSE;
$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);
* 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) {
*/
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));
$hashArr = array();
foreach($wl as $w) {
- $hashArr[] = t3lib_div::md5int($w);
+ $hashArr[] = t3lib_div::md5int($w);
}
$wl = array_flip($wl);
$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).