2 /***************************************************************
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Class used in module tools/dbint (advanced search) and which may hold code specific for that module
29 * However the class has a general principle in it which may be used in the web/export module.
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @coauthor Jo Hasenau <info@cybercraft.de>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 88: class t3lib_fullsearch
42 * 103: function form()
43 * 117: function makeStoreControl()
44 * 156: function initStoreArray()
45 * 176: function cleanStoreQueryConfigs($storeQueryConfigs,$storeArray)
46 * 193: function addToStoreQueryConfigs($storeQueryConfigs,$index)
47 * 209: function saveQueryInAction($uid)
48 * 256: function loadStoreQueryConfigs($storeQueryConfigs,$storeIndex,$writeArray)
49 * 272: function procesStoreControl()
50 * 344: function queryMaker()
51 * 414: function getQueryResultCode($mQ,$res,$table)
52 * 534: function csvValues($row, $delim=',', $quote='"', $conf=array(), $table='')
53 * 550: function tableWrap($str)
54 * 559: function search()
55 * 614: function resultRowDisplay($row,$conf,$table)
56 * 662: function getProcessedValueExtra($table, $fN, $fV, $conf, $splitString)
57 * 781: function getTreeList($id, $depth, $begin = 0, $perms_clause)
58 * 818: function makeValueList($fN, $fV, $conf, $table, $splitString)
59 * 1028: function resultRowTitles($row,$conf,$table)
60 * 1058: function csvRowTitles($row, $conf, $table)
63 * (This index is automatically created/updated by the extension "extdeveval")
81 * Class used in module tools/dbint (advanced search) and which may hold code specific for that module
82 * However the class has a general principle in it which may be used in the web/export module.
84 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
88 class t3lib_fullsearch
{
89 var $storeList = 'search_query_smallparts,search_result_labels,labels_noprefix,show_deleted,queryConfig,queryTable,queryFields,queryLimit,queryOrder,queryOrderDesc,queryOrder2,queryOrder2Desc,queryGroup,search_query_makeQuery';
90 var $downloadScript = 'index.php';
94 protected $formName = '';
99 public function __construct() {
100 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_t3lib_fullsearch.xml');
105 * [Describe function...]
112 <input type="text" name="SET[sword]" value="'.htmlspecialchars($GLOBALS['SOBE']->MOD_SETTINGS
['sword']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).'><input type="submit" name="submit" value="Search All Records">
119 * [Describe function...]
123 function makeStoreControl() {
125 $storeArray = $this->initStoreArray();
130 foreach ($storeArray as $k => $v) {
131 $opt[]='<option value="'.$k.'"'.(!strcmp($cur,$v)?
' selected':'').'>'.htmlspecialchars($v).'</option>';
135 if (t3lib_extMgm
::isLoaded('sys_action') && $GLOBALS['BE_USER']->isAdmin()) {
136 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_action', 'type=2', '', 'title');
137 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
138 $opt[]='<option value="0">__Save to Action:__</option>';
139 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
140 $opt[]='<option value="-'.$row['uid'].'"'.(!strcmp($cur,'-'.$row['uid'])?
' selected':'').'>'.htmlspecialchars($row['title'].' ['.$row['uid'].']').'</option>';
143 $GLOBALS['TYPO3_DB']->sql_free_result($res);
146 $TDparams=' nowrap="nowrap" class="bgColor4"';
148 <table border="0" cellpadding="3" cellspacing="1">
149 <tr'.$TDparams.'><td><select name="storeControl[STORE]" onChange="document.forms[0][\'storeControl[title]\'].value= this.options[this.selectedIndex].value!=0 ? this.options[this.selectedIndex].text : \'\';">'.implode(LF
,$opt).'</select><input type="submit" name="storeControl[LOAD]" value="Load"></td></tr>
150 <tr'.$TDparams.'><td nowrap><input name="storeControl[title]" value="" type="text" max="80"'.$GLOBALS['SOBE']->doc
->formWidth().'><input type="submit" name="storeControl[SAVE]" value="Save" onClick="if (document.forms[0][\'storeControl[STORE]\'].options[document.forms[0][\'storeControl[STORE]\'].selectedIndex].value<0) return confirm(\'Are you sure you want to overwrite the existing query in this action?\');"><input type="submit" name="storeControl[REMOVE]" value="Remove"></td></tr>
157 * [Describe function...]
161 function initStoreArray() {
166 $savedStoreArray = unserialize($GLOBALS['SOBE']->MOD_SETTINGS
['storeArray']);
168 if (is_array($savedStoreArray)) {
169 $storeArray = array_merge($storeArray,$savedStoreArray);
175 * [Describe function...]
177 * @param [type] $storeQueryConfigs: ...
178 * @param [type] $storeArray: ...
181 function cleanStoreQueryConfigs($storeQueryConfigs,$storeArray) {
182 if (is_array($storeQueryConfigs)) {
183 foreach ($storeQueryConfigs as $k => $v) {
184 if (!isset($storeArray[$k])) unset($storeQueryConfigs[$k]);
187 return $storeQueryConfigs;
191 * [Describe function...]
193 * @param [type] $storeQueryConfigs: ...
194 * @param [type] $index: ...
197 function addToStoreQueryConfigs($storeQueryConfigs,$index) {
198 $keyArr = explode(',',$this->storeList
);
199 $storeQueryConfigs[$index]=array();
200 foreach ($keyArr as $k) {
201 $storeQueryConfigs[$index][$k]=$GLOBALS['SOBE']->MOD_SETTINGS
[$k];
203 return $storeQueryConfigs;
207 * [Describe function...]
209 * @param [type] $uid: ...
212 function saveQueryInAction($uid) {
213 if (t3lib_extMgm
::isLoaded('sys_action')) {
214 $keyArr = explode(',',$this->storeList
);
216 foreach ($keyArr as $k) {
217 $saveArr[$k]=$GLOBALS['SOBE']->MOD_SETTINGS
[$k];
222 if ($saveArr['queryTable']) {
223 /* @var t3lib_queryGenerator */
224 $qGen = t3lib_div
::makeInstance('t3lib_queryGenerator');
225 $qGen->init('queryConfig',$saveArr['queryTable']);
226 $qGen->makeSelectorTable($saveArr);
228 $qGen->enablePrefix
=1;
229 $qString = $qGen->getQuery($qGen->queryConfig
);
230 $qCount = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', $qGen->table
, $qString.t3lib_BEfunc
::deleteClause($qGen->table
));
231 $qSelect = $qGen->getSelectQuery($qString);
233 $res = @$GLOBALS['TYPO3_DB']->sql_query($qCount);
234 if (!$GLOBALS['TYPO3_DB']->sql_error()) {
235 $GLOBALS['TYPO3_DB']->sql_free_result($res);
237 $dA['t2_data'] = serialize(array(
240 'qSelect' => $qSelect,
241 'qString' => $qString
243 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_action', 'uid='.intval($uid), $dA);
253 * [Describe function...]
255 * @param [type] $storeQueryConfigs: ...
256 * @param [type] $storeIndex: ...
257 * @param [type] $writeArray: ...
260 function loadStoreQueryConfigs($storeQueryConfigs,$storeIndex,$writeArray) {
261 if ($storeQueryConfigs[$storeIndex]) {
262 $keyArr = explode(',',$this->storeList
);
263 foreach ($keyArr as $k) {
264 $writeArray[$k]=$storeQueryConfigs[$storeIndex][$k];
271 * [Describe function...]
275 function procesStoreControl() {
276 $storeArray = $this->initStoreArray();
277 $storeQueryConfigs = unserialize($GLOBALS['SOBE']->MOD_SETTINGS
['storeQueryConfigs']);
279 $storeControl = t3lib_div
::_GP('storeControl');
280 $storeIndex = intval($storeControl['STORE']);
283 if (is_array($storeControl)) {
285 if ($storeControl['LOAD']) {
287 $writeArray=$this->loadStoreQueryConfigs($storeQueryConfigs,$storeIndex,$writeArray);
289 $flashMessage = t3lib_div
::makeInstance(
290 't3lib_FlashMessage',
291 sprintf($GLOBALS['LANG']->getLL('query_loaded'), htmlspecialchars($storeArray[$storeIndex]))
293 } elseif ($storeIndex<0 && t3lib_extMgm
::isLoaded('sys_action')) {
294 $actionRecord=t3lib_BEfunc
::getRecord('sys_action',abs($storeIndex));
295 if (is_array($actionRecord)) {
296 $dA = unserialize($actionRecord['t2_data']);
298 if (is_array($dA['qC'])) {
299 $dbSC[0] = $dA['qC'];
301 $writeArray=$this->loadStoreQueryConfigs($dbSC,'0',$writeArray);
304 $flashMessage = t3lib_div
::makeInstance(
305 't3lib_FlashMessage',
306 sprintf($GLOBALS['LANG']->getLL('query_from_action_loaded'), htmlspecialchars($actionRecord['title']))
310 } elseif ($storeControl['SAVE']) {
312 $qOK = $this->saveQueryInAction(abs($storeIndex));
314 $flashMessage = t3lib_div
::makeInstance(
315 't3lib_FlashMessage',
316 $GLOBALS['LANG']->getLL('query_saved')
319 $flashMessage = t3lib_div
::makeInstance(
320 't3lib_FlashMessage',
321 $GLOBALS['LANG']->getLL('query_notsaved'),
323 t3lib_FlashMessage
::ERROR
327 if (trim($storeControl['title'])) {
329 $storeArray[$storeIndex]=$storeControl['title'];
331 $storeArray[]=$storeControl['title'];
333 $storeIndex=key($storeArray);
335 $storeQueryConfigs=$this->addToStoreQueryConfigs($storeQueryConfigs,$storeIndex);
337 $flashMessage = t3lib_div
::makeInstance(
338 't3lib_FlashMessage',
339 $GLOBALS['LANG']->getLL('query_saved')
343 } elseif ($storeControl['REMOVE']) {
345 $flashMessage = t3lib_div
::makeInstance(
346 't3lib_FlashMessage',
347 sprintf($GLOBALS['LANG']->getLL('query_removed'), htmlspecialchars($storeArray[$storeControl['STORE']]))
349 unset($storeArray[$storeControl['STORE']]); // Removing
354 $msg = $flashMessage->render();
357 if ($saveStoreArray) {
358 unset($storeArray[0]); // making sure, index 0 is not set!
359 $writeArray['storeArray']=serialize($storeArray);
360 $writeArray['storeQueryConfigs']=serialize($this->cleanStoreQueryConfigs($storeQueryConfigs,$storeArray));
361 $GLOBALS['SOBE']->MOD_SETTINGS
= t3lib_BEfunc
::getModuleData($GLOBALS['SOBE']->MOD_MENU
, $writeArray, $GLOBALS['SOBE']->MCONF
['name'], 'ses');
367 * [Describe function...]
371 function queryMaker() {
374 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['t3lib_fullsearch'])) {
375 $this->hookArray
= $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['t3lib_fullsearch'];
377 $msg=$this->procesStoreControl();
379 if (!$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableStoreControl']) {
380 $output.= $GLOBALS['SOBE']->doc
->section('Load/Save Query',$this->makeStoreControl(),0,1);
382 $output .= '<br />' . $msg;
384 $output.= $GLOBALS['SOBE']->doc
->spacer(20);
389 $qGen = t3lib_div
::makeInstance('t3lib_queryGenerator');
390 $qGen->init('queryConfig',$GLOBALS['SOBE']->MOD_SETTINGS
['queryTable']);
391 if ($this->formName
) {
392 $qGen->setFormName($this->formName
);
394 $tmpCode=$qGen->makeSelectorTable($GLOBALS['SOBE']->MOD_SETTINGS
);
395 $output.= $GLOBALS['SOBE']->doc
->section('Make query',$tmpCode,0,1);
397 $mQ = $GLOBALS['SOBE']->MOD_SETTINGS
['search_query_makeQuery'];
399 // Make form elements:
400 if ($qGen->table
&& is_array($TCA[$qGen->table
])) {
403 $qGen->enablePrefix
=1;
404 $qString = $qGen->getQuery($qGen->queryConfig
);
405 // debug($qGen->queryConfig);
409 $qExplain = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', $qGen->table
, $qString.t3lib_BEfunc
::deleteClause($qGen->table
));
412 $qExplain = $qGen->getSelectQuery($qString);
413 if ($mQ=='explain') {
414 $qExplain='EXPLAIN '.$qExplain;
419 if (!$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableShowSQLQuery']) {
420 $output.= $GLOBALS['SOBE']->doc
->section('SQL query',$this->tableWrap(htmlspecialchars($qExplain)),0,1);
423 $res = @$GLOBALS['TYPO3_DB']->sql_query($qExplain);
424 if ($GLOBALS['TYPO3_DB']->sql_error()) {
425 $out.='<BR><strong>Error:</strong><BR><font color="red"><strong>'.$GLOBALS['TYPO3_DB']->sql_error().'</strong></font>';
426 $output.= $GLOBALS['SOBE']->doc
->section('SQL error',$out,0,1);
428 $cPR = $this->getQueryResultCode($mQ,$res,$qGen->table
);
429 $GLOBALS['TYPO3_DB']->sql_free_result($res);
430 $output.=$GLOBALS['SOBE']->doc
->section($cPR['header'],$cPR['content'],0,1);
438 * [Describe function...]
440 * @param [type] $mQ: ...
441 * @param [type] $res: ...
442 * @param [type] $table: ...
445 function getQueryResultCode($mQ,$res,$table) {
451 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
452 $cPR['header']='Count';
453 $cPR['content']='<BR><strong>'.$row[0]. '</strong> records selected.';
457 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
458 $rowArr[]=$this->resultRowDisplay($row,$TCA[$table],$table);
461 if (is_array($this->hookArray
['beforeResultTable'])) {
462 foreach ($this->hookArray
['beforeResultTable'] as $_funcRef) {
463 $out.=t3lib_div
::callUserFunction($_funcRef, $GLOBALS['SOBE']->MOD_SETTINGS
, $this);
466 if (count($rowArr)) {
467 $out.='<table border="0" cellpadding="2" cellspacing="1" width="100%">'.$this->resultRowTitles($lrow, $TCA[$table], $table).implode(LF
, $rowArr).'</table>';
469 if (!$out) $out='<em>No rows selected!</em>';
470 $cPR['header']='Result';
471 $cPR['content']=$out;
476 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
478 $rowArr[]=$this->csvValues(array_keys($row),',','');
481 $rowArr[]=$this->csvValues($row, ',', '"', $TCA[$table], $table);
483 if (count($rowArr)) {
484 $out.='<textarea name="whatever" rows="20" wrap="off"'.$GLOBALS['SOBE']->doc
->formWidthText($this->formW
,'','off').' class="fixed-font">'.t3lib_div
::formatForTextarea(implode(LF
,$rowArr)).'</textarea>';
485 if (!$this->noDownloadB
) {
486 $out.='<BR><input type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\''.$this->downloadScript
.'\';">'; // document.forms[0].target=\'_blank\';
489 if (t3lib_div
::_GP('download_file')) {
490 $filename='TYPO3_'.$table.'_export_'.date('dmy-Hi').'.csv';
491 $mimeType = 'application/octet-stream';
492 header('Content-Type: '.$mimeType);
493 header('Content-Disposition: attachment; filename='.$filename);
494 echo implode(CRLF
,$rowArr);
498 if (!$out) $out='<em>No rows selected!</em>';
499 $cPR['header']='Result';
500 $cPR['content']=$out;
503 $xmlObj = t3lib_div
::makeInstance('t3lib_xml', 'typo3_export');
504 $xmlObj->includeNonEmptyValues
=1;
505 $xmlObj->renderHeader();
507 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
509 $xmlObj->setRecFields($table,implode(',',array_keys($row)));
513 if ($GLOBALS['SOBE']->MOD_SETTINGS
['search_result_labels']) {
514 foreach ($valueArray as $key => $val) {
515 $valueArray[$key] = $this->getProcessedValueExtra($table, $key, $val, array(), ',');
518 $xmlObj->addRecord($table, $valueArray);
520 $xmlObj->renderFooter();
521 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
522 $xmlData=$xmlObj->getResult();
523 $out.='<textarea name="whatever" rows="20" wrap="off"'.$GLOBALS['SOBE']->doc
->formWidthText($this->formW
,'','off').' class="fixed-font">'.t3lib_div
::formatForTextarea($xmlData).'</textarea>';
524 if (!$this->noDownloadB
) {
525 $out.='<BR><input type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\''.$this->downloadScript
.'\';">'; // document.forms[0].target=\'_blank\';
528 if (t3lib_div
::_GP('download_file')) {
529 $filename='TYPO3_'.$table.'_export_'.date('dmy-Hi').'.xml';
530 $mimeType = 'application/octet-stream';
531 header('Content-Type: '.$mimeType);
532 header('Content-Disposition: attachment; filename='.$filename);
537 if (!$out) $out='<em>No rows selected!</em>';
538 $cPR['header']='Result';
539 $cPR['content']=$out;
543 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
544 $out .= '<br />' . t3lib_utility_Debug
::viewArray($row);
546 $cPR['header']='Explain SQL query';
547 $cPR['content']=$out;
554 * [Describe function...]
556 * @param [type] $row: ...
557 * @param [type] $delim: ...
558 * @param [type] $quote: ...
559 * @param [type] $conf: ...
560 * @param [type] $table: ...
563 function csvValues($row, $delim=',', $quote='"', $conf=array(), $table='') {
565 if ($GLOBALS['SOBE']->MOD_SETTINGS
['search_result_labels'] && $table) {
566 foreach ($valueArray as $key => $val) {
567 $valueArray[$key] = $this->getProcessedValueExtra($table, $key, $val, $conf, ';');
570 return t3lib_div
::csvValues($valueArray, $delim, $quote);
574 * [Describe function...]
576 * @param [type] $str: ...
579 function tableWrap($str) {
580 return '<table border="0" cellpadding="10" cellspacing="0" class="bgColor4"><tr><td nowrap><pre>'.$str.'</pre></td></tr></table>';
584 * [Describe function...]
590 $SET = $GLOBALS['SOBE']->MOD_SETTINGS
;
591 $swords = $SET['sword'];
596 foreach ($TCA as $table => $value) {
598 t3lib_div
::loadTCA($table);
601 // avoid querying tables with no columns
602 if (empty($conf['columns'])) {
606 $list = array_keys($conf['columns']);
608 $qp = $GLOBALS['TYPO3_DB']->searchQuery(array($swords), $list, $table);
611 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $table, $qp . t3lib_BEfunc
::deleteClause($table));
612 if($count ||
$showAlways) {
614 $out.='<strong>TABLE:</strong> '.$GLOBALS['LANG']->sL($conf['ctrl']['title']).'<BR>';
615 $out.='<strong>Results:</strong> '.$count.'<BR>';
620 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,'.$conf['ctrl']['label'], $table, $qp.t3lib_BEfunc
::deleteClause($table), '', '', $limit);
621 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
622 $rowArr[]=$this->resultRowDisplay($row,$conf,$table);
625 $GLOBALS['TYPO3_DB']->sql_free_result($res);
626 $out.='<table border="0" cellpadding="2" cellspacing="1">'.$this->resultRowTitles($lrow,$conf,$table).implode(LF
,$rowArr).'</table>';
636 * [Describe function...]
638 * @param [type] $row: ...
639 * @param [type] $conf: ...
640 * @param [type] $table: ...
643 function resultRowDisplay($row,$conf,$table) {
644 static $even = false
;
645 $tce = t3lib_div
::makeInstance('t3lib_TCEmain');
646 $SET = $GLOBALS['SOBE']->MOD_SETTINGS
;
647 $out='<tr class="bgColor' . ($even ?
'6' : '4') . '">';
649 foreach ($row as $fN => $fV) {
650 if (t3lib_div
::inList($SET['queryFields'], $fN) ||
(!$SET['queryFields'] && $fN!='pid' && $fN!='deleted')) {
651 if ($SET['search_result_labels']) {
652 $fVnew = $this->getProcessedValueExtra($table, $fN, $fV, $conf, '<br />');
654 $fVnew = htmlspecialchars($fV);
656 $out.='<td>' . $fVnew . '</td>';
659 $params = '&edit['.$table.']['.$row['uid'].']=edit';
661 if (!$row['deleted']) {
662 $out .= '<a href="#" onClick="top.launchView(\''.$table.'\','.$row['uid'].',\''.$GLOBALS['BACK_PATH'].'\');return false;">' . t3lib_iconWorks
::getSpriteIcon('status-dialog-information') . '</a>';
663 $out .= '<a href="#" onClick="'.t3lib_BEfunc
::editOnClick($params, $GLOBALS['BACK_PATH'], t3lib_div
::getIndpEnv('REQUEST_URI').t3lib_div
::implodeArrayForUrl('SET', (array)t3lib_div
::_POST('SET'))).'">' . t3lib_iconWorks
::getSpriteIcon('actions-document-open') . '</a>';
665 $out.= '<a href="'.t3lib_div
::linkThisUrl($GLOBALS['BACK_PATH'].'tce_db.php', array('cmd['.$table.']['.$row['uid'].'][undelete]' => '1', 'redirect' => t3lib_div
::linkThisScript(array()))).'">';
666 $out.= t3lib_iconWorks
::getSpriteIcon('actions-edit-restore', array('title' => 'undelete only')) . '</a>';
667 $out.= '<a href="'.t3lib_div
::linkThisUrl($GLOBALS['BACK_PATH'].'tce_db.php', array('cmd['.$table.']['.$row['uid'].'][undelete]' => '1', 'redirect' => t3lib_div
::linkThisUrl('alt_doc.php', array('edit['.$table.']['.$row['uid'].']' => 'edit', 'returnUrl' => t3lib_div
::linkThisScript(array()))))).'">';
668 $out.= t3lib_iconWorks
::getSpriteIcon('actions-edit-restore-edit', array('title' => 'undelete and edit')) . '</a>';
670 $_params = array($table=>$row);
671 if (is_array($this->hookArray
['additionalButtons'])) {
672 foreach ($this->hookArray
['additionalButtons'] as $_funcRef) {
673 $out.=t3lib_div
::callUserFunction($_funcRef, $_params, $this);
683 * [Describe function...]
685 * @param [type] $table: ...
686 * @param [type] $fN: ...
687 * @param [type] $fV: ...
688 * @param [type] $conf: ...
689 * @param [type] $splitString: ...
692 function getProcessedValueExtra($table, $fN, $fV, $conf, $splitString) {
694 // Analysing the fields in the table.
695 if (is_array($TCA[$table])) {
696 t3lib_div
::loadTCA($table);
697 $fC = $TCA[$table]['columns'][$fN];
698 $fields = $fC['config'];
699 $fields['exclude'] = $fC['exclude'];
700 if (is_array($fC) && $fC['label']) {
701 $fields['label'] = preg_replace('/:$/', '', trim($GLOBALS['LANG']->sL($fC['label'])));
703 switch ($fields['type']) {
705 if (preg_match('/int|year/i', $fields['eval'])) {
706 $fields['type'] = 'number';
707 } elseif (preg_match('/time/i', $fields['eval'])) {
708 $fields['type'] = 'time';
709 } elseif (preg_match('/date/i', $fields['eval'])) {
710 $fields['type'] = 'date';
712 $fields['type'] = 'text';
716 if (!$fields['items']) {
717 $fields['type'] = 'boolean';
719 $fields['type'] = 'binary';
723 $fields['type'] = 'multiple';
726 $fields['type'] = 'multiple';
727 if ($fields['foreign_table']) {
728 $fields['type'] = 'relation';
730 if ($fields['special']) {
731 $fields['type'] = 'text';
735 $fields['type'] = 'files';
736 if ($fields['internal_type']=='db') {
737 $fields['type'] = 'relation';
746 $fields['type'] = 'text';
750 $fields['label'] = '[FIELD: '.$fN.']';
753 $fields['type'] = 'relation';
754 $fields['allowed'] = 'pages';
757 $fields['type'] = 'relation';
758 $fields['allowed'] = 'be_users';
762 $fields['type'] = 'time';
765 $fields['type'] = 'number';
771 switch ($fields['type']) {
774 $out = strftime('%e-%m-%Y', $fV);
779 if ($splitString=='<br />') {
780 $out = strftime('%H:%M'.$splitString.'%e-%m-%Y', $fV);
782 $out = strftime('%H:%M %e-%m-%Y', $fV);
789 $out = $this->makeValueList($fN, $fV, $fields, $table, $splitString);
792 $out = $fV ?
'True' : 'False';
796 $out = htmlspecialchars($fV);
803 * [Describe function...]
805 * @param [type] $qString: ...
806 * @param [type] $depth: ...
807 * @param [type] $begin: ...
808 * @param [type] $perms_clause: ...
811 function getTreeList($id, $depth, $begin = 0, $perms_clause) {
812 $depth = intval($depth);
813 $begin = intval($begin);
820 if ($id && $depth > 0) {
821 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
824 'pid='.$id.' '.t3lib_BEfunc
::deleteClause('pages').' AND '.$perms_clause
826 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
828 $theList .= ','.$row['uid'];
831 $theList .= $this->getTreeList($row['uid'], $depth-1, $begin-1, $perms_clause);
834 $GLOBALS['TYPO3_DB']->sql_free_result($res);
840 * [Describe function...]
842 * @param [type] $fN: ...
843 * @param [type] $fV: ...
844 * @param [type] $conf: ...
845 * @param [type] $table: ...
846 * @param [type] $splitString: ...
849 function makeValueList($fN, $fV, $conf, $table, $splitString) {
852 if ($fieldSetup['type'] == 'files') {
853 $d = dir(PATH_site
. $fieldSetup['uploadfolder']);
854 while (false
!== ($entry = $d->read())) {
855 if ($entry == '.' ||
$entry == '..') {
858 $fileArray[] = $entry;
861 natcasesort($fileArray);
862 while (list(, $fileName) = each($fileArray)) {
863 if (t3lib_div
::inList($fV, $fileName) ||
$fV == $fileName) {
865 $out = htmlspecialchars($fileName);
867 $out .= $splitString.htmlspecialchars($fileName);
872 if ($fieldSetup['type'] == 'multiple') {
873 foreach ($fieldSetup['items'] as $key => $val) {
874 if (substr($val[0], 0, 4) == 'LLL:') {
875 $value = $GLOBALS['LANG']->sL($val[0]);
879 if (t3lib_div
::inList($fV, $val[1]) ||
$fV == $val[1]) {
881 $out = htmlspecialchars($value);
883 $out .= $splitString.htmlspecialchars($value);
888 if ($fieldSetup['type'] == 'binary') {
889 foreach($fieldSetup['items'] as $Key => $val) {
890 if (substr($val[0], 0, 4) == 'LLL:') {
891 $value = $GLOBALS['LANG']->sL($val[0]);
896 $out = htmlspecialchars($value);
898 $out .= $splitString.htmlspecialchars($value);
902 if ($fieldSetup['type']=='relation') {
903 if ($fieldSetup['items']) {
904 foreach($fieldSetup['items'] as $key => $val) {
905 if (substr($val[0], 0, 4) == 'LLL:') {
906 $value = $GLOBALS['LANG']->sL($val[0]);
910 if (t3lib_div
::inList($fV, $value) ||
$fV == $value) {
912 $out = htmlspecialchars($value);
914 $out .= $splitString.htmlspecialchars($value);
920 if (stristr($fieldSetup['allowed'], ',')) {
921 $from_table_Arr = explode(',', $fieldSetup['allowed']);
923 if (!$fieldSetup['prepend_tname']) {
924 $checkres = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fN, $table, 'uid '.t3lib_BEfunc
::deleteClause($table), $groupBy = '', $orderBy = '', $limit = '');
926 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($checkres)) {
927 if (stristr($row[$fN], ',')) {
928 $checkContent = explode(',', $row[$fN]);
929 foreach($checkContent as $singleValue) {
930 if (!stristr($singleValue, '_')) {
931 $dontPrefixFirstTable = 1;
935 $singleValue = $row[$fN];
936 if (strlen($singleValue) && !stristr($singleValue, '_')) {
937 $dontPrefixFirstTable = 1;
941 $GLOBALS['TYPO3_DB']->sql_free_result($checkres);
945 $from_table_Arr[0] = $fieldSetup['allowed'];
947 if ($fieldSetup['prepend_tname']) {
950 if ($fieldSetup['foreign_table']) {
951 $from_table_Arr[0] = $fieldSetup['foreign_table'];
954 foreach($from_table_Arr as $from_table) {
955 if (($useTablePrefix && !$dontPrefixFirstTable && $counter != 1) ||
$counter == 1) {
956 $tablePrefix = $from_table.'_';
959 if (is_array($TCA[$from_table])) {
960 t3lib_div
::loadTCA($from_table);
961 $labelField = $TCA[$from_table]['ctrl']['label'];
962 $altLabelField = $TCA[$from_table]['ctrl']['label_alt'];
963 if ($TCA[$from_table]['columns'][$labelField]['config']['items']) {
964 reset($TCA[$from_table]['columns'][$labelField]['config']['items']);
965 while (list(, $labelArray) = each($TCA[$from_table]['columns'][$labelField]['config']['items'])) {
966 if (substr($labelArray[0], 0, 4) == 'LLL:') {
967 $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]);
969 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
972 $useSelectLabels = 1;
974 if ($TCA[$from_table]['columns'][$altLabelField]['config']['items']) {
975 reset($TCA[$from_table]['columns'][$altLabelField]['config']['items']);
976 foreach($TCA[$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) {
977 if (substr($altLabelArray[0], 0, 4) == 'LLL:') {
978 $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]);
980 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
983 $useAltSelectLabels = 1;
985 $altLabelFieldSelect = $altLabelField ?
','.$altLabelField : '';
986 $select_fields = 'uid,'.$labelField.$altLabelFieldSelect;
987 if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) {
988 $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
989 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
990 $webMountPageTree = '';
991 foreach($webMounts as $key => $val) {
992 if ($webMountPageTree) {
993 $webMountPageTreePrefix = ',';
995 $webMountPageTree .= $webMountPageTreePrefix.$this->getTreeList($val, 999, $begin = 0, $perms_clause);
997 if ($from_table == 'pages') {
998 $where_clause = 'uid IN ('.$webMountPageTree.') '.t3lib_BEfunc
::deleteClause($from_table).' AND '.$perms_clause;
1000 $where_clause = 'pid IN ('.$webMountPageTree.') '.t3lib_BEfunc
::deleteClause($from_table);
1003 $where_clause = 'uid'.t3lib_BEfunc
::deleteClause($from_table);
1006 if (!$this->tableArray
[$from_table]) {
1007 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy, $limit = '');
1008 $this->tableArray
[$from_table] = array();
1011 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1012 $this->tableArray
[$from_table][] = $row;
1014 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1016 reset($this->tableArray
[$from_table]);
1017 foreach ($this->tableArray
[$from_table] as $key => $val) {
1018 $GLOBALS['SOBE']->MOD_SETTINGS
['labels_noprefix'] = $GLOBALS['SOBE']->MOD_SETTINGS
['labels_noprefix'] == 1 ?
'on' :
1019 $GLOBALS['SOBE']->MOD_SETTINGS
['labels_noprefix'];
1020 $prefixString = $GLOBALS['SOBE']->MOD_SETTINGS
['labels_noprefix'] == 'on' ?
'' : ' ['.$tablePrefix.$val['uid'].'] ';
1021 if (t3lib_div
::inList($fV, $tablePrefix.$val['uid']) ||
$fV == $tablePrefix.$val['uid']) {
1022 if ($useSelectLabels) {
1024 $out = htmlspecialchars($prefixString.$labelFieldSelect[$val[$labelField]]);
1026 $out .= $splitString.htmlspecialchars($prefixString.$labelFieldSelect[$val[$labelField]]);
1028 } elseif ($val[$labelField]) {
1030 $out = htmlspecialchars($prefixString.$val[$labelField]);
1032 $out .= $splitString.htmlspecialchars($prefixString.$val[$labelField]);
1034 } elseif ($useAltSelectLabels) {
1036 $out = htmlspecialchars($prefixString.$altLabelFieldSelect[$val[$altLabelField]]);
1038 $out .= $splitString.htmlspecialchars($prefixString.$altLabelFieldSelect[$val[$altLabelField]]);
1042 $out = htmlspecialchars($prefixString.$val[$altLabelField]);
1044 $out .= $splitString.htmlspecialchars($prefixString.$val[$altLabelField]);
1056 * Render table header
1058 * @param array row: Table columns
1059 * @param array conf: Table TCA
1060 * @param string table: Table name
1061 * @return string HTML of table header
1063 function resultRowTitles($row, $conf, $table) {
1064 $SET = $GLOBALS['SOBE']->MOD_SETTINGS
;
1066 $tableHeader = array();
1069 $tableHeader[] = '<thead><tr class="bgColor5">';
1071 // Iterate over given columns
1072 foreach ($row as $fieldName => $fieldValue) {
1073 if (t3lib_div
::inList($SET['queryFields'], $fieldName) ||
(!$SET['queryFields'] && $fieldName != 'pid' && $fieldName != 'deleted')) {
1074 $THparams = (strlen($fieldValue) < 50) ?
' style="white-space:nowrap;"' : '';
1076 if ($GLOBALS['SOBE']->MOD_SETTINGS
['search_result_labels']) {
1077 $title = $GLOBALS['LANG']->sL($conf['columns'][$fieldName]['label'] ?
$conf['columns'][$fieldName]['label'] : $fieldName, 1);
1079 $title = $GLOBALS['LANG']->sL($fieldName, 1);
1082 $tableHeader[] = '<th' . $THparams . '>' . $title . '</th>';
1086 // Add empty icon column
1087 $tableHeader[] = '<th style="white-space:nowrap;"></th>';
1089 $tableHeader[] = '</tr></thead>';
1091 return implode($tableHeader, LF
);
1095 * [Describe function...]
1097 * @param [type] $row: ...
1098 * @param [type] $conf: ...
1099 * @param [type] $table: ...
1100 * @return [type] ...
1102 function csvRowTitles($row, $conf, $table) {
1104 $SET = $GLOBALS['SOBE']->MOD_SETTINGS
;
1105 foreach ($row as $fN => $fV) {
1106 if (t3lib_div
::inList($SET['queryFields'], $fN) ||
(!$SET['queryFields'] && $fN!='pid')) {
1108 if ($GLOBALS['SOBE']->MOD_SETTINGS
['search_result_labels']) {
1109 $out = $GLOBALS['LANG']->sL($conf['columns'][$fN]['label']?
$conf['columns'][$fN]['label']:$fN, 1);
1111 $out = $GLOBALS['LANG']->sL($fN, 1);
1114 if ($GLOBALS['SOBE']->MOD_SETTINGS
['search_result_labels']) {
1115 $out.= ','.$GLOBALS['LANG']->sL($conf['columns'][$fN]['label']?
$conf['columns'][$fN]['label']:$fN, 1);
1117 $out.= ','.$GLOBALS['LANG']->sL($fN, 1);
1126 * Sets the current name of the input form.
1128 * @param string $formName: The name of the form.
1131 public function setFormName($formName) {
1132 $this->formName
= trim($formName);
1136 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_fullsearch.php']) {
1137 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_fullsearch.php']);