2 namespace TYPO3\CMS\Core\Database;
31 public $storeList =
'search_query_smallparts,search_result_labels,labels_noprefix,show_deleted,queryConfig,queryTable,queryFields,queryLimit,queryOrder,queryOrderDesc,queryOrder2,queryOrder2Desc,queryGroup,search_query_makeQuery';
68 $GLOBALS[
'LANG']->includeLLFile(
'EXT:lang/locallang_t3lib_fullsearch.xlf');
80 <div class="form-group">
81 <input placeholder="Search Word" class="form-control" type="search" name="SET[sword]" value="' . htmlspecialchars(
$GLOBALS[
'SOBE']->MOD_SETTINGS[
'sword']) .
'">
83 <div class="form-group">
84 <input class="btn btn-default" type="submit" name="submit" value="Search All Records">
100 foreach ($storeArray as $k => $v) {
101 $opt[] =
'<option value="' . $k .
'">' . htmlspecialchars($v) .
'</option>';
104 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'sys_action') &&
$GLOBALS[
'BE_USER']->isAdmin()) {
105 $rows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'*',
'sys_action',
'type=2',
'',
'title');
106 $opt[] =
'<option value="0">__Save to Action:__</option>';
107 foreach ($rows as $row) {
108 $opt[] =
'<option value="-' . $row[
'uid'] .
'">' . htmlspecialchars(($row[
'title'] .
' [' . $row[
'uid'] .
']')) .
'</option>';
111 return '<div class="load-queries">
112 <div class="form-inline">
113 <div class="form-group">
114 <select class="form-control" 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>
115 <input class="btn btn-default" type="submit" name="storeControl[LOAD]" value="Load">
118 <div class="form-inline">
119 <div class="form-group">
120 <input name="storeControl[title]" value="" type="text" max="80" class="form-control">
121 <input class="btn btn-default" 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?\');">
122 <input class="btn btn-default" type="submit" name="storeControl[REMOVE]" value="Remove">
138 $savedStoreArray = unserialize(
$GLOBALS[
'SOBE']->MOD_SETTINGS[
'storeArray']);
139 if (is_array($savedStoreArray)) {
140 $storeArray = array_merge($storeArray, $savedStoreArray);
154 if (is_array($storeQueryConfigs)) {
155 foreach ($storeQueryConfigs as $k => $v) {
156 if (!isset($storeArray[$k])) {
157 unset($storeQueryConfigs[$k]);
161 return $storeQueryConfigs;
173 $keyArr = explode(
',', $this->storeList);
174 $storeQueryConfigs[$index] = array();
175 foreach ($keyArr as $k) {
176 $storeQueryConfigs[$index][$k] =
$GLOBALS[
'SOBE']->MOD_SETTINGS[$k];
178 return $storeQueryConfigs;
187 public function saveQueryInAction($uid)
189 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'sys_action')) {
190 $keyArr = explode(
',', $this->storeList);
192 foreach ($keyArr as $k) {
193 $saveArr[$k] =
$GLOBALS[
'SOBE']->MOD_SETTINGS[$k];
197 if ($saveArr[
'queryTable']) {
200 $qGen->init(
'queryConfig', $saveArr[
'queryTable']);
201 $qGen->makeSelectorTable($saveArr);
202 $qGen->enablePrefix = 1;
203 $qString = $qGen->getQuery($qGen->queryConfig);
205 $qSelect = $qGen->getSelectQuery($qString);
206 $res = @
$GLOBALS[
'TYPO3_DB']->sql_query($qCount);
207 if (!
$GLOBALS[
'TYPO3_DB']->sql_error()) {
208 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
210 $dA[
't2_data'] = serialize(array(
213 'qSelect' => $qSelect,
214 'qString' => $qString
216 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery(
'sys_action',
'uid=' . (
int)$uid, $dA);
234 if ($storeQueryConfigs[$storeIndex]) {
235 $keyArr = explode(
',', $this->storeList);
236 foreach ($keyArr as $k) {
237 $writeArray[$k] = $storeQueryConfigs[$storeIndex][$k];
251 $storeQueryConfigs = unserialize(
$GLOBALS[
'SOBE']->MOD_SETTINGS[
'storeQueryConfigs']);
253 $storeIndex = (int)$storeControl[
'STORE'];
255 $writeArray = array();
256 if (is_array($storeControl)) {
258 if ($storeControl[
'LOAD']) {
259 if ($storeIndex > 0) {
262 $flashMessage =
GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, sprintf(
$GLOBALS[
'LANG']->getLL(
'query_loaded'), htmlspecialchars($storeArray[$storeIndex])));
263 }
elseif ($storeIndex < 0 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'sys_action')) {
265 if (is_array($actionRecord)) {
266 $dA = unserialize($actionRecord[
't2_data']);
268 if (is_array($dA[
'qC'])) {
269 $dbSC[0] = $dA[
'qC'];
273 $flashMessage =
GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, sprintf(
$GLOBALS[
'LANG']->getLL(
'query_from_action_loaded'), htmlspecialchars($actionRecord[
'title'])));
276 }
elseif ($storeControl[
'SAVE']) {
277 if ($storeIndex < 0) {
278 $qOK = $this->saveQueryInAction(abs($storeIndex));
285 if (trim($storeControl[
'title'])) {
286 if ($storeIndex > 0) {
287 $storeArray[$storeIndex] = $storeControl[
'title'];
289 $storeArray[] = $storeControl[
'title'];
291 $storeIndex = key($storeArray);
298 }
elseif ($storeControl[
'REMOVE']) {
299 if ($storeIndex > 0) {
300 $flashMessage =
GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, sprintf(
$GLOBALS[
'LANG']->getLL(
'query_removed'), htmlspecialchars($storeArray[$storeControl[
'STORE']])));
302 unset($storeArray[$storeControl[
'STORE']]);
307 $msg = $flashMessage->render();
310 if ($saveStoreArray) {
312 unset($storeArray[0]);
313 $writeArray[
'storeArray'] = serialize($storeArray);
314 $writeArray[
'storeQueryConfigs'] = serialize($this->
cleanStoreQueryConfigs($storeQueryConfigs, $storeArray));
328 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
't3lib_fullsearch'])) {
329 $this->hookArray =
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
't3lib_fullsearch'];
332 if (!
$GLOBALS[
'BE_USER']->userTS[
'mod.'][
'dbint.'][
'disableStoreControl']) {
333 $output .=
'<h2>Load/Save Query</h2><div>' . $this->
makeStoreControl() .
'</div>';
335 $output .=
'<br />' . $msg;
337 $output .=
'<div style="padding-top: 20px;"></div>';
341 $qGen->init(
'queryConfig',
$GLOBALS[
'SOBE']->MOD_SETTINGS[
'queryTable']);
342 if ($this->formName) {
343 $qGen->setFormName($this->formName);
345 $tmpCode = $qGen->makeSelectorTable(
$GLOBALS[
'SOBE']->MOD_SETTINGS);
346 $output .=
'<div id="query"></div>' .
'<h2>Make query</h2><div>' . $tmpCode .
'</div>';
347 $mQ =
$GLOBALS[
'SOBE']->MOD_SETTINGS[
'search_query_makeQuery'];
349 if ($qGen->table && is_array(
$GLOBALS[
'TCA'][$qGen->table])) {
352 $qGen->enablePrefix = 1;
353 $qString = $qGen->getQuery($qGen->queryConfig);
359 $qExplain = $qGen->getSelectQuery($qString);
360 if ($mQ ==
'explain') {
361 $qExplain =
'EXPLAIN ' . $qExplain;
364 if (!
$GLOBALS[
'BE_USER']->userTS[
'mod.'][
'dbint.'][
'disableShowSQLQuery']) {
365 $output .=
'<h2>SQL query</h2><div>' . $this->
tableWrap(htmlspecialchars($qExplain)) .
'</div>';
367 $res = @
$GLOBALS[
'TYPO3_DB']->sql_query($qExplain);
368 if (
$GLOBALS[
'TYPO3_DB']->sql_error()) {
369 $out =
'<BR><strong>Error:</strong><BR><font color="red"><strong>' .
$GLOBALS[
'TYPO3_DB']->sql_error() .
'</strong></font>';
370 $output .=
'<h2>SQL error</h2><div>' . $out .
'</div>';
373 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
374 $output .=
'<h2>' . $cPR[
'header'] .
'</h2><div>' . $cPR[
'content'] .
'</div>';
378 return '<div class="query-builder">' . $output .
'</div>';
395 $row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_row($res);
396 $cPR[
'header'] =
'Count';
397 $cPR[
'content'] =
'<BR><strong>' . $row[0] .
'</strong> records selected.';
401 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
405 if (is_array($this->hookArray[
'beforeResultTable'])) {
406 foreach ($this->hookArray[
'beforeResultTable'] as $_funcRef) {
410 if (!empty($rowArr)) {
411 $out .=
'<table class="table table-striped table-hover">' . $this->
resultRowTitles($lrow,
$GLOBALS[
'TCA'][$table], $table) . implode(LF, $rowArr) .
'</table>';
414 $out =
'<div class="alert-info">No rows selected!</div>';
416 $cPR[
'header'] =
'Result';
417 $cPR[
'content'] = $out;
422 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
424 $rowArr[] = $this->
csvValues(array_keys($row),
',',
'');
429 if (!empty($rowArr)) {
430 $out .=
'<textarea name="whatever" rows="20" wrap="off"' .
$GLOBALS[
'SOBE']->getModuleTemplate()->formWidth($this->formW) .
' class="text-monospace">' . htmlspecialchars(implode(LF, $rowArr)) .
'</textarea>';
431 if (!$this->noDownloadB) {
432 $out .=
'<br><input class="btn btn-default" type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript .
'\';
">';
435 if (GeneralUtility::_GP('download_file')) {
436 $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.csv';
437 $mimeType = 'application/octet-stream';
438 header('Content-Type: ' . $mimeType);
439 header('Content-Disposition: attachment; filename=' . $filename);
440 echo implode(CRLF, $rowArr);
445 $out = '<em>No rows selected!</em>';
447 $cPR['header'] = 'Result';
448 $cPR['content'] = $out;
453 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
454 $out .= '<br />' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($row);
456 $cPR['header'] = 'Explain SQL query';
457 $cPR['content'] = $out;
472 public function csvValues($row, $delim = ',', $quote = '"', $conf = array(), $table = '')
475 if ($GLOBALS['SOBE
']->MOD_SETTINGS['search_result_labels
'] && $table) {
476 foreach ($valueArray as $key => $val) {
477 $valueArray[$key] = $this->getProcessedValueExtra($table, $key, $val, $conf, ';
');
480 return GeneralUtility::csvValues($valueArray, $delim, $quote);
489 public function tableWrap($str)
491 return '<pre>
' . $str . '</pre>
';
499 public function search()
501 $SET = $GLOBALS['SOBE
']->MOD_SETTINGS;
502 $swords = $SET['sword
'];
506 foreach ($GLOBALS['TCA
'] as $table => $value) {
508 $conf = $GLOBALS['TCA
'][$table];
509 // Avoid querying tables with no columns
510 if (empty($conf['columns
'])) {
513 $fieldsInDatabase = $GLOBALS['TYPO3_DB
']->admin_get_fields($table);
514 $list = array_intersect(array_keys($conf['columns
']), array_keys($fieldsInDatabase));
516 $qp = $GLOBALS['TYPO3_DB
']->searchQuery(array($swords), $list, $table);
518 $count = $GLOBALS['TYPO3_DB
']->exec_SELECTcountRows('*
', $table, $qp . BackendUtility::deleteClause($table));
521 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery('uid,
' . $conf['ctrl
']['label
'], $table, $qp . BackendUtility::deleteClause($table), '', '', $limit);
522 while ($row = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($res)) {
523 $rowArr[] = $this->resultRowDisplay($row, $conf, $table);
526 $GLOBALS['TYPO3_DB
']->sql_free_result($res);
527 $out .= '<div
class=
"panel panel-default">
528 <div
class=
"panel-heading">
' . $GLOBALS['LANG
']->sL($conf['ctrl
']['title
'], true) . ' (
' . $count . ')</div>
529 <table
class=
"table table-striped table-hover">
' .
530 $this->resultRowTitles($lrow, $conf, $table) .
531 implode(LF, $rowArr) .
548 public function resultRowDisplay($row, $conf, $table)
550 $SET = $GLOBALS['SOBE
']->MOD_SETTINGS;
552 foreach ($row as $fieldName => $fieldValue) {
553 if (GeneralUtility::inList($SET['queryFields
'], $fieldName) || !$SET['queryFields
'] && $fieldName != 'pid
' && $fieldName != 'deleted
') {
554 if ($SET['search_result_labels
']) {
555 $fVnew = $this->getProcessedValueExtra($table, $fieldName, $fieldValue, $conf, '<br />
');
557 $fVnew = htmlspecialchars($fieldValue);
559 $out .= '<td>
' . $fVnew . '</td>
';
562 $out .= '<td><div
class=
"btn-group">
';
563 if (!$row['deleted
']) {
564 $url = BackendUtility::getModuleUrl('record_edit
', [
567 $row['uid
'] => 'edit
'
570 'returnUrl
' => GeneralUtility::getIndpEnv('REQUEST_URI
') . GeneralUtility::implodeArrayForUrl('SET
', (array)GeneralUtility::_POST('SET
'))
572 $out .= '<a
class=
"btn btn-default" href=
"#" onClick=
"top.launchView(\'' . $table . '\',' . $row['uid'] . ',\'' . $GLOBALS['BACK_PATH'] . '\');return false;">
' . $this->iconFactory->getIcon('actions-document-info
', Icon::SIZE_SMALL)->render() . '</a>
';
573 $out .= '<a
class=
"btn btn-default" href=
"' . htmlspecialchars($url) . '">
' . $this->iconFactory->getIcon('actions-document-open
', Icon::SIZE_SMALL)->render() . '</a>
';
575 $out .= '<a
class=
"btn btn-default" href=
"' . GeneralUtility::linkThisUrl(BackendUtility::getModuleUrl('tce_db'), array(
576 ('cmd[' . $table . '][' . $row['uid'] . '][undelete]') => '1',
577 'redirect' => GeneralUtility::linkThisScript(array())
578 )) . '" title=
"' . $GLOBALS['LANG']->getLL('undelete_only', true) . '">
';
579 $out .= $this->iconFactory->getIcon('actions-edit-restore
', Icon::SIZE_SMALL)->render() . '</a>
';
580 $formEngineParameters = array(
581 'edit[
' . $table . '][
' . $row['uid
'] . ']
' => 'edit
',
582 'returnUrl
' => GeneralUtility::linkThisScript(array())
584 $redirectUrl = BackendUtility::getModuleUrl('record_edit
', $formEngineParameters);
585 $out .= '<a
class=
"btn btn-default" href=
"' . GeneralUtility::linkThisUrl(BackendUtility::getModuleUrl('tce_db'), array(
586 ('cmd[' . $table . '][' . $row['uid'] . '][undelete]') => '1',
587 'redirect' => $redirectUrl
588 )) . '" title=
"' . $GLOBALS['LANG']->getLL('undelete_and_edit', true) . '">
';
589 $out .= $this->iconFactory->getIcon('actions-edit-restore-edit
', Icon::SIZE_SMALL)->render() . '</a>
';
591 $_params = array($table => $row);
592 if (is_array($this->hookArray['additionalButtons
'])) {
593 foreach ($this->hookArray['additionalButtons
'] as $_funcRef) {
594 $out .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
613 public function getProcessedValueExtra($table, $fieldName, $fieldValue, $conf, $splitString)
616 // Analysing the fields in the table.
617 if (is_array($GLOBALS['TCA
'][$table])) {
618 $fC = $GLOBALS['TCA
'][$table]['columns
'][$fieldName];
619 $fields = $fC['config
'];
620 $fields['exclude
'] = $fC['exclude
'];
621 if (is_array($fC) && $fC['label
']) {
622 $fields['label
'] = preg_replace('/:$/
', '', trim($GLOBALS['LANG
']->sL($fC['label
'])));
623 switch ($fields['type
']) {
625 if (preg_match('/
int|year/i
', $fields['eval
'])) {
626 $fields['type
'] = 'number
';
627 } elseif (preg_match('/time/i
', $fields['eval
'])) {
628 $fields['type
'] = 'time
';
629 } elseif (preg_match('/date/i
', $fields['eval
'])) {
630 $fields['type
'] = 'date
';
632 $fields['type
'] = 'text
';
636 if (!$fields['items
']) {
637 $fields['type
'] = 'boolean';
639 $fields['type
'] = 'binary
';
643 $fields['type
'] = 'multiple
';
646 $fields['type
'] = 'multiple
';
647 if ($fields['foreign_table
']) {
648 $fields['type
'] = 'relation
';
650 if ($fields['special
']) {
651 $fields['type
'] = 'text
';
655 $fields['type
'] = 'files
';
656 if ($fields['internal_type
'] == 'db
') {
657 $fields['type
'] = 'relation
';
666 $fields['type
'] = 'text
';
669 $fields['label
'] = '[FIELD:
' . $fieldName . ']
';
670 switch ($fieldName) {
672 $fields['type
'] = 'relation
';
673 $fields['allowed
'] = 'pages
';
676 $fields['type
'] = 'relation
';
677 $fields['allowed
'] = 'be_users
';
682 $fields['type
'] = 'time
';
685 $fields['type
'] = 'number
';
689 switch ($fields['type
']) {
691 if ($fieldValue != -1) {
692 $out = strftime('%e-%m-%Y
', $fieldValue);
696 if ($fieldValue != -1) {
697 if ($splitString == '<br />
') {
698 $out = strftime('%H:%M
' . $splitString . '%e-%m-%Y
', $fieldValue);
700 $out = strftime('%H:%M %e-%m-%Y
', $fieldValue);
707 $out = $this->makeValueList($fieldName, $fieldValue, $fields, $table, $splitString);
710 $out = $fieldValue ? 'True
' : 'False
';
714 $out = htmlspecialchars($fieldValue);
728 public function getTreeList($id, $depth, $begin = 0, $perms_clause)
730 $depth = (int)$depth;
731 $begin = (int)$begin;
741 if ($id && $depth > 0) {
742 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery('uid
', 'pages
', 'pid=
' . $id . ' ' . BackendUtility::deleteClause('pages
') . ' AND
' . $perms_clause);
743 while ($row = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($res)) {
745 $theList .= ',
' . $row['uid
'];
748 $theList .= $this->getTreeList($row['uid
'], $depth - 1, $begin - 1, $perms_clause);
751 $GLOBALS['TYPO3_DB
']->sql_free_result($res);
766 public function makeValueList($fieldName, $fieldValue, $conf, $table, $splitString)
770 if ($fieldSetup['type
'] == 'files
') {
771 $d = dir(PATH_site . $fieldSetup['uploadfolder
']);
772 while (false !== ($entry = $d->read())) {
773 if ($entry == '.
' || $entry == '..
') {
776 $fileArray[] = $entry;
779 natcasesort($fileArray);
780 foreach ($fileArray as $fileName) {
781 if (GeneralUtility::inList($fieldValue, $fileName) || $fieldValue == $fileName) {
783 $out = htmlspecialchars($fileName);
785 $out .= $splitString . htmlspecialchars($fileName);
790 if ($fieldSetup['type
'] == 'multiple
') {
791 foreach ($fieldSetup['items
'] as $key => $val) {
792 if (substr($val[0], 0, 4) == 'LLL:
') {
793 $value = $GLOBALS['LANG
']->sL($val[0]);
797 if (GeneralUtility::inList($fieldValue, $val[1]) || $fieldValue == $val[1]) {
799 $out = htmlspecialchars($value);
801 $out .= $splitString . htmlspecialchars($value);
806 if ($fieldSetup['type
'] == 'binary
') {
807 foreach ($fieldSetup['items
'] as $Key => $val) {
808 if (substr($val[0], 0, 4) == 'LLL:
') {
809 $value = $GLOBALS['LANG
']->sL($val[0]);
814 $out = htmlspecialchars($value);
816 $out .= $splitString . htmlspecialchars($value);
820 if ($fieldSetup['type
'] == 'relation
') {
821 if ($fieldSetup['items
']) {
822 foreach ($fieldSetup['items
'] as $key => $val) {
823 if (substr($val[0], 0, 4) == 'LLL:
') {
824 $value = $GLOBALS['LANG
']->sL($val[0]);
828 if (GeneralUtility::inList($fieldValue, $value) || $fieldValue == $value) {
830 $out = htmlspecialchars($value);
832 $out .= $splitString . htmlspecialchars($value);
837 if (stristr($fieldSetup['allowed
'], ',
')) {
838 $from_table_Arr = explode(',
', $fieldSetup['allowed
']);
840 if (!$fieldSetup['prepend_tname
']) {
841 $checkres = $GLOBALS['TYPO3_DB
']->exec_SELECTquery($fieldName, $table, 'uid
' . BackendUtility::deleteClause($table), ($groupBy = ''), ($orderBy = ''), ($limit = ''));
843 while ($row = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($checkres)) {
844 if (stristr($row[$fieldName], ',
')) {
845 $checkContent = explode(',
', $row[$fieldName]);
846 foreach ($checkContent as $singleValue) {
847 if (!stristr($singleValue, '_
')) {
848 $dontPrefixFirstTable = 1;
852 $singleValue = $row[$fieldName];
853 if ($singleValue !== '' && !stristr($singleValue, '_
')) {
854 $dontPrefixFirstTable = 1;
858 $GLOBALS['TYPO3_DB
']->sql_free_result($checkres);
862 $from_table_Arr[0] = $fieldSetup['allowed
'];
864 if ($fieldSetup['prepend_tname
']) {
867 if ($fieldSetup['foreign_table
']) {
868 $from_table_Arr[0] = $fieldSetup['foreign_table
'];
871 foreach ($from_table_Arr as $from_table) {
872 if ($useTablePrefix && !$dontPrefixFirstTable && $counter != 1 || $counter == 1) {
873 $tablePrefix = $from_table . '_
';
876 if (is_array($GLOBALS['TCA
'][$from_table])) {
877 $labelField = $GLOBALS['TCA
'][$from_table]['ctrl
']['label
'];
878 $altLabelField = $GLOBALS['TCA
'][$from_table]['ctrl
']['label_alt
'];
879 if ($GLOBALS['TCA
'][$from_table]['columns
'][$labelField]['config
']['items
']) {
880 foreach ($GLOBALS['TCA
'][$from_table]['columns
'][$labelField]['config
']['items
'] as $labelArray) {
881 if (substr($labelArray[0], 0, 4) == 'LLL:
') {
882 $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG
']->sL($labelArray[0]);
884 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
887 $useSelectLabels = 1;
889 if ($GLOBALS['TCA
'][$from_table]['columns
'][$altLabelField]['config
']['items
']) {
890 foreach ($GLOBALS['TCA
'][$from_table]['columns
'][$altLabelField]['config
']['items
'] as $altLabelArray) {
891 if (substr($altLabelArray[0], 0, 4) == 'LLL:
') {
892 $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG
']->sL($altLabelArray[0]);
894 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
897 $useAltSelectLabels = 1;
899 $altLabelFieldSelect = $altLabelField ? ',
' . $altLabelField : '';
900 $select_fields = 'uid,
' . $labelField . $altLabelFieldSelect;
901 if (!$GLOBALS['BE_USER
']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS
']['BE
']['lockBeUserToDBmounts
']) {
902 $webMounts = $GLOBALS['BE_USER
']->returnWebmounts();
903 $perms_clause = $GLOBALS['BE_USER
']->getPagePermsClause(1);
904 $webMountPageTree = '';
905 foreach ($webMounts as $key => $val) {
906 if ($webMountPageTree) {
907 $webMountPageTreePrefix = ',
';
909 $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, ($begin = 0), $perms_clause);
911 if ($from_table == 'pages
') {
912 $where_clause = 'uid IN (
' . $webMountPageTree . ')
' . BackendUtility::deleteClause($from_table) . ' AND
' . $perms_clause;
914 $where_clause = 'pid IN (
' . $webMountPageTree . ')
' . BackendUtility::deleteClause($from_table);
917 $where_clause = 'uid
' . BackendUtility::deleteClause($from_table);
920 if (!$this->tableArray[$from_table]) {
921 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery($select_fields, $from_table, $where_clause, ($groupBy = ''), $orderBy, ($limit = ''));
922 $this->tableArray[$from_table] = array();
925 while ($row = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($res)) {
926 $this->tableArray[$from_table][] = $row;
928 $GLOBALS['TYPO3_DB
']->sql_free_result($res);
930 foreach ($this->tableArray[$from_table] as $key => $val) {
931 $GLOBALS['SOBE
']->MOD_SETTINGS['labels_noprefix
'] = $GLOBALS['SOBE
']->MOD_SETTINGS['labels_noprefix
'] == 1 ? 'on
' : $GLOBALS['SOBE
']->MOD_SETTINGS['labels_noprefix
'];
932 $prefixString = $GLOBALS['SOBE
']->MOD_SETTINGS['labels_noprefix
'] == 'on
' ? '' : ' [
' . $tablePrefix . $val['uid
'] . ']
';
933 if (GeneralUtility::inList($fieldValue, $tablePrefix . $val['uid
']) || $fieldValue == $tablePrefix . $val['uid
']) {
934 if ($useSelectLabels) {
936 $out = htmlspecialchars($prefixString . $labelFieldSelect[$val[$labelField]]);
938 $out .= $splitString . htmlspecialchars(($prefixString . $labelFieldSelect[$val[$labelField]]));
940 } elseif ($val[$labelField]) {
942 $out = htmlspecialchars($prefixString . $val[$labelField]);
944 $out .= $splitString . htmlspecialchars(($prefixString . $val[$labelField]));
946 } elseif ($useAltSelectLabels) {
948 $out = htmlspecialchars($prefixString . $altLabelFieldSelect[$val[$altLabelField]]);
950 $out .= $splitString . htmlspecialchars(($prefixString . $altLabelFieldSelect[$val[$altLabelField]]));
954 $out = htmlspecialchars($prefixString . $val[$altLabelField]);
956 $out .= $splitString . htmlspecialchars(($prefixString . $val[$altLabelField]));
975 public function resultRowTitles($row, $conf, $table)
977 $SET = $GLOBALS['SOBE
']->MOD_SETTINGS;
978 $tableHeader = array();
980 $tableHeader[] = '<thead><tr>
';
981 // Iterate over given columns
982 foreach ($row as $fieldName => $fieldValue) {
983 if (GeneralUtility::inList($SET['queryFields
'], $fieldName) || !$SET['queryFields
'] && $fieldName != 'pid
' && $fieldName != 'deleted
') {
984 if ($GLOBALS['SOBE
']->MOD_SETTINGS['search_result_labels
']) {
985 $title = $GLOBALS['LANG
']->sL($conf['columns
'][$fieldName]['label
'] ? $conf['columns
'][$fieldName]['label
'] : $fieldName, true);
987 $title = $GLOBALS['LANG
']->sL($fieldName, true);
989 $tableHeader[] = '<th>
' . $title . '</th>
';
992 // Add empty icon column
993 $tableHeader[] = '<th></th>
';
995 $tableHeader[] = '</tr></thead>
';
996 return implode(LF, $tableHeader);
1007 public function csvRowTitles($row, $conf, $table)
1010 $SET = $GLOBALS['SOBE
']->MOD_SETTINGS;
1011 foreach ($row as $fieldName => $fieldValue) {
1012 if (GeneralUtility::inList($SET['queryFields
'], $fieldName) || !$SET['queryFields
'] && $fieldName != 'pid
') {
1014 if ($GLOBALS['SOBE
']->MOD_SETTINGS['search_result_labels
']) {
1015 $out = $GLOBALS['LANG
']->sL($conf['columns
'][$fieldName]['label
'] ? $conf['columns
'][$fieldName]['label
'] : $fieldName, true);
1017 $out = $GLOBALS['LANG
']->sL($fieldName, true);
1020 if ($GLOBALS['SOBE
']->MOD_SETTINGS['search_result_labels
']) {
1021 $out .= ',
' . $GLOBALS['LANG
']->sL(($conf['columns
'][$fieldName]['label
'] ? $conf['columns
'][$fieldName]['label
'] : $fieldName), true);
1023 $out .= ',
' . $GLOBALS['LANG
']->sL($fieldName, true);
1037 public function setFormName($formName)
1039 $this->formName = trim($formName);