75 public $internal = array(
'res_count' => 0,
'results_at_a_time' => 20,
'maxPages' => 10,
'currentRow' => array(),
'currentTable' =>
'');
209 public function __construct() {
211 if ($this->prefixId) {
216 if ($this->pi_checkCHash && count($this->piVars)) {
220 if (!empty(
$GLOBALS[
'TSFE']->config[
'config'][
'language'])) {
221 $this->LLkey =
$GLOBALS[
'TSFE']->config[
'config'][
'language'];
222 if (empty(
$GLOBALS[
'TSFE']->config[
'config'][
'language_alt'])) {
225 if (in_array($this->LLkey,
$locales->getLocales())) {
226 $this->altLLkey =
'';
227 foreach (
$locales->getLocaleDependencies($this->LLkey) as $language) {
228 $this->altLLkey .= $language .
',';
230 $this->altLLkey = rtrim($this->altLLkey,
',');
233 $this->altLLkey =
$GLOBALS[
'TSFE']->config[
'config'][
'language_alt'];
246 foreach ($conf as $key => $confNextLevel) {
247 if (strpos($key,
'.') !== FALSE) {
248 $key = substr($key, 0, -1);
251 foreach ($confNextLevel as $subKey => $subConfNextLevel) {
252 if (is_array($subConfNextLevel) && strpos($subKey,
'.') !== FALSE && $subKey !==
'stdWrap.') {
253 $subKey = substr($subKey, 0, -1);
259 foreach ($confNextLevel as $subKey => $subConfNextLevel) {
260 if (is_array($subConfNextLevel) && $subKey ===
'stdWrap.') {
261 $conf[$key] = $this->cObj->stdWrap($conf[$key], $conf[$key .
'.'][
'stdWrap.']);
262 unset($conf[$key .
'.'][
'stdWrap.']);
263 if (!count($conf[$key .
'.'])) {
264 unset($conf[$key .
'.']);
279 if (isset($this->conf[
'_DEFAULT_PI_VARS.']) && is_array($this->conf[
'_DEFAULT_PI_VARS.'])) {
281 $tmp = $this->conf[
'_DEFAULT_PI_VARS.'];
283 $this->piVars = $tmp;
308 return $this->cObj->getTypoLink_URL($id, $urlParameters, $target);
324 public function pi_linkToPage($str, $id, $target =
'', $urlParameters = array()) {
325 return $this->cObj->getTypoLink($str, $id, $urlParameters, $target);
340 public function pi_linkTP($str, $urlParameters = array(), $cache = 0, $altPageId = 0) {
342 $conf[
'useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
343 $conf[
'no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
344 $conf[
'parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId :
$GLOBALS[
'TSFE']->id);
346 return $this->cObj->typoLink($str,
$conf);
363 public function pi_linkTP_keepPIvars($str, $overrulePIvars = array(), $cache = 0, $clearAnyway = 0, $altPageId = 0) {
364 if (is_array($this->piVars) && is_array($overrulePIvars) && !$clearAnyway) {
369 if ($this->pi_autoCacheEn) {
373 $res = $this->
pi_linkTP($str, array($this->prefixId => $overrulePIvars), $cache, $altPageId);
391 return $this->cObj->lastTypoLinkUrl;
409 if ($this->prefixId) {
411 $overrulePIvars =
$uid ? array(
'showUid' =>
$uid) : array();
412 $overrulePIvars = array_merge($overrulePIvars, (array) $mergeArr);
413 $str = $this->
pi_linkTP($str, array($this->prefixId => $overrulePIvars), $cache, $altPageId);
415 $overrulePIvars = array(
'showUid' =>
$uid ?:
'');
416 $overrulePIvars = array_merge($overrulePIvars, (array) $mergeArr);
421 $str = $this->cObj->lastTypoLinkUrl;
436 public function pi_openAtagHrefInJSwindow($str, $winName =
'', $winParams =
'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1') {
437 if (preg_match(
'/(.*)(<a[^>]*>)(.*)/i', $str, $match)) {
439 $match[2] =
'<a href="#" onclick="' . htmlspecialchars((
'vHWin=window.open(\'' .
$GLOBALS[
'TSFE']->baseUrlWrap($aTagContent[
'href']) .
'\',\
'' . ($winName ? $winName : md5($aTagContent[
'href'])) .
'\',\
'' . $winParams .
'\');vHWin.focus();
return false;
')) . '">'; 440 $str = $match[1] . $match[2] . $match[3]; 445 /*************************** 447 * Functions for listing, browsing, searching etc. 449 **************************/ 475 public function pi_list_browseresults($showResultCount = 1, $tableParams = '', $wrapArr = array(), $pointerName = 'pointer', $hscText = TRUE, $forceOutput = FALSE) { 476 // example $wrapArr-array how it could be traversed from an extension 478 'browseBoxWrap' => '<div class="browseBoxWrap
">|</div>', 479 'showResultsWrap' => '<div class="showResultsWrap
">|</div>', 480 'browseLinksWrap' => '<div class="browseLinksWrap
">|</div>', 481 'showResultsNumbersWrap' => '<span class="showResultsNumbersWrap
">|</span>', 482 'disabledLinkWrap' => '<span class="disabledLinkWrap
">|</span>', 483 'inactiveLinkWrap' => '<span class="inactiveLinkWrap
">|</span>', 484 'activeLinkWrap' => '<span class="activeLinkWrap
">|</span>' 486 // Initializing variables: 487 $pointer = (int)$this->piVars[$pointerName]; 488 $count = (int)$this->internal['res_count']; 489 $results_at_a_time = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->internal['results_at_a_time'], 1, 1000); 490 $totalPages = ceil($count / $results_at_a_time); 491 $maxPages = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->internal['maxPages'], 1, 100); 492 $pi_isOnlyFields = $this->pi_isOnlyFields($this->pi_isOnlyFields); 493 if (!$forceOutput && $count <= $results_at_a_time) { 496 // $showResultCount determines how the results of the pagerowser will be shown. 497 // If set to 0: only the result-browser will be shown 498 // 1: (default) the text "Displaying results...
" and the result-browser will be shown. 499 // 2: only the text "Displaying results...
" will be shown 500 $showResultCount = (int)$showResultCount; 501 // If this is set, two links named "<< First
" and "LAST >>
" will be shown and point to the very first or last page. 502 $showFirstLast = $this->internal['showFirstLast']; 503 // If this has a value the "previous
" button is always visible (will be forced if "showFirstLast
" is set) 504 $alwaysPrev = $showFirstLast ? 1 : $this->pi_alwaysPrev; 505 if (isset($this->internal['pagefloat'])) { 506 if (strtoupper($this->internal['pagefloat']) == 'CENTER') { 507 $pagefloat = ceil(($maxPages - 1) / 2); 509 // pagefloat set as integer. 0 = left, value >= $this->internal['maxPages'] = right 510 $pagefloat = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->internal['pagefloat'], -1, $maxPages - 1); 513 // pagefloat disabled 516 // Default values for "traditional
" wrapping with a table. Can be overwritten by vars from $wrapArr 517 $wrapper['disabledLinkWrap'] = '<td nowrap="nowrap
"><p>|</p></td>'; 518 $wrapper['inactiveLinkWrap'] = '<td nowrap="nowrap
"><p>|</p></td>'; 519 $wrapper['activeLinkWrap'] = '<td' . $this->pi_classParam('browsebox-SCell') . ' nowrap="nowrap
"><p>|</p></td>'; 520 $wrapper['browseLinksWrap'] = trim(('<table ' . $tableParams)) . '><tr>|</tr></table>'; 521 $wrapper['showResultsWrap'] = '<p>|</p>'; 522 $wrapper['browseBoxWrap'] = ' 526 <div ' . $this->pi_classParam('browsebox') . '> 529 // Now overwrite all entries in $wrapper which are also in $wrapArr 530 $wrapper = array_merge($wrapper, $wrapArr); 532 if ($showResultCount != 2) { 533 if ($pagefloat > -1) { 534 $lastPage = min($totalPages, max($pointer + 1 + $pagefloat, $maxPages)); 535 $firstPage = max(0, $lastPage - $maxPages); 538 $lastPage = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($totalPages, 1, $maxPages); 541 // Make browse-table/links: 542 // Link to first page 543 if ($showFirstLast) { 545 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_first', '<< First', $hscText), array($pointerName => NULL), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); 547 $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_first', '<< First', $hscText), $wrapper['disabledLinkWrap']); 550 // Link to previous page 551 if ($alwaysPrev >= 0) { 553 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), array($pointerName => ($pointer - 1) ?: ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); 554 } elseif ($alwaysPrev) { 555 $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), $wrapper['disabledLinkWrap']); 559 for ($a = $firstPage; $a < $lastPage; $a++) { 560 if ($this->internal['showRange']) { 561 $pageText = ($a * $results_at_a_time + 1) . '-' . min($count, ($a + 1) * $results_at_a_time); 563 $pageText = trim($this->pi_getLL('pi_list_browseresults_page', 'Page', $hscText) . ' ' . ($a + 1)); 566 if ($pointer == $a) { 567 if ($this->internal['dontLinkActivePage']) { 568 $links[] = $this->cObj->wrap($pageText, $wrapper['activeLinkWrap']); 570 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ?: ''), $pi_isOnlyFields), $wrapper['activeLinkWrap']); 573 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ?: ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); 576 if ($pointer < $totalPages - 1 || $showFirstLast) { 578 if ($pointer >= $totalPages - 1) { 579 $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_next', 'Next >', $hscText), $wrapper['disabledLinkWrap']); 581 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_next', 'Next >', $hscText), array($pointerName => $pointer + 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); 585 if ($showFirstLast) { 586 if ($pointer < $totalPages - 1) { 587 $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), array($pointerName => $totalPages - 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); 589 $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), $wrapper['disabledLinkWrap']); 592 $theLinks = $this->cObj->wrap(implode(LF, $links), $wrapper['browseLinksWrap']); 596 $pR1 = $pointer * $results_at_a_time + 1; 597 $pR2 = $pointer * $results_at_a_time + $results_at_a_time; 598 if ($showResultCount) { 599 if ($wrapper['showResultsNumbersWrap']) { 600 // This will render the resultcount in a more flexible way using markers (new in TYPO3 3.8.0). 601 // The formatting string is expected to hold template markers (see function header). Example: 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###' 602 $markerArray['###FROM###'] = $this->cObj->wrap($this->internal['res_count'] > 0 ? $pR1 : 0, $wrapper['showResultsNumbersWrap']); 603 $markerArray['###TO###'] = $this->cObj->wrap(min($this->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']); 604 $markerArray['###OUT_OF###'] = $this->cObj->wrap($this->internal['res_count'], $wrapper['showResultsNumbersWrap']); 605 $markerArray['###FROM_TO###'] = $this->cObj->wrap(($this->internal['res_count'] > 0 ? $pR1 : 0) . ' ' . $this->pi_getLL('pi_list_browseresults_to', 'to') . ' ' . min($this->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']); 606 $markerArray['###CURRENT_PAGE###'] = $this->cObj->wrap($pointer + 1, $wrapper['showResultsNumbersWrap']); 607 $markerArray['###TOTAL_PAGES###'] = $this->cObj->wrap($totalPages, $wrapper['showResultsNumbersWrap']); 608 // Substitute markers 609 $resultCountMsg = $this->cObj->substituteMarkerArray($this->pi_getLL('pi_list_browseresults_displays', 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###'), $markerArray); 611 // Render the resultcount in the "traditional
" way using sprintf 612 $resultCountMsg = sprintf(str_replace('###SPAN_BEGIN###', '<span' . $this->pi_classParam('browsebox-strong') . '>', $this->pi_getLL('pi_list_browseresults_displays', 'Displaying results ###SPAN_BEGIN###%s to %s</span> out of ###SPAN_BEGIN###%s</span>')), $count > 0 ? $pR1 : 0, min($count, $pR2), $count); 614 $resultCountMsg = $this->cObj->wrap($resultCountMsg, $wrapper['showResultsWrap']); 616 $resultCountMsg = ''; 618 $sTables = $this->cObj->wrap($resultCountMsg . $theLinks, $wrapper['browseBoxWrap']); 630 public function pi_list_searchBox($tableParams = '') { 631 // Search box design: 637 <div' . $this->pi_classParam('searchbox') . '> 638 <form action="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI
')) . '" method="post
" style="margin: 0 0 0 0;
"> 639 <' . trim(('table ' . $tableParams)) . '> 641 <td><input type="text
" name="' . $this->prefixId . '[sword]
" value="' . htmlspecialchars($this->piVars['sword
']) . '"' . $this->pi_classParam('searchbox-sword') . ' /></td> 642 <td><input type="submit
" value="' . $this->pi_getLL('pi_list_searchBox_search
', 'Search
', TRUE) . '"' . $this->pi_classParam('searchbox-button') . ' />' . '<input type="hidden
" name="no_cache
" value="1
" />' . '<input type="hidden
" name="' . $this->prefixId . '[pointer]
" value="" />' . '</td> 658 public function pi_list_modeSelector($items = array(), $tableParams = '') { 660 foreach ($items as $k => $v) { 662 <td' . ($this->piVars['mode'] == $k ? $this->pi_classParam('modeSelector-SCell') : '') . '><p>' . $this->pi_linkTP_keepPIvars(htmlspecialchars($v), array('mode' => $k), $this->pi_isOnlyFields($this->pi_isOnlyFields)) . '</p></td>'; 667 Mode selector (menu for list): 669 <div' . $this->pi_classParam('modeSelector') . '> 670 <' . trim(('table ' . $tableParams)) . '> 672 ' . implode('', $cells) . ' 692 public function pi_list_makelist($res, $tableParams = '') { 693 // Make list table header: 695 $this->internal['currentRow'] = ''; 696 $tRows[] = $this->pi_list_header(); 697 // Make list table rows 699 while ($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 700 $tRows[] = $this->pi_list_row($c); 708 <div' . $this->pi_classParam('listrow') . '> 709 <' . trim(('table ' . $tableParams)) . '> 710 ' . implode('', $tRows) . ' 725 public function pi_list_row($c) { 727 return '<tr' . ($c % 2 ? $this->pi_classParam('listrow-odd') : '') . '><td><p>[dummy row]</p></td></tr>'; 738 public function pi_list_header() { 739 return '<tr' . $this->pi_classParam('listrow-header') . '><td><p>[dummy header row]</p></td></tr>'; 742 /*************************** 746 **************************/ 754 public function pi_getClassName($class) { 755 return str_replace('_', '-', $this->prefixId) . ($this->prefixId ? '-' : '') . $class; 768 public function pi_classParam($class, $addClasses = '') { 770 foreach (GeneralUtility::trimExplode(',', $class) as $v) { 771 $output .= ' ' . $this->pi_getClassName($v); 773 foreach (GeneralUtility::trimExplode(',', $addClasses) as $v) { 776 return ' class="' . trim($output) . '"'; 787 public function pi_wrapInBaseClass($str) { 788 $content = '<div class="' . str_replace('_
', '-
', $this->prefixId) . '"> 792 if (!$GLOBALS['TSFE']->config['config']['disablePrefixComment']) { 798 BEGIN: Content of extension "' . $this->extKey . '", plugin "' . $this->prefixId . '" 802 <!-- END: Content of extension "' . $this->extKey . '", plugin "' . $this->prefixId . '" --> 809 /*************************** 811 * Frontend editing: Edit panel, edit icons 813 **************************/ 825 public function pi_getEditPanel($row = '', $tablename = '', $label = '', $conf = array()) { 827 if (!$row || !$tablename) { 828 $row = $this->internal['currentRow']; 829 $tablename = $this->internal['currentTable']; 831 if ($GLOBALS['TSFE']->beUserLogin) { 832 // Create local cObj if not set: 833 if (!is_object($this->pi_EPtemp_cObj)) { 834 $this->pi_EPtemp_cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); 835 $this->pi_EPtemp_cObj->setParent($this->cObj->data, $this->cObj->currentRecord); 837 // Initialize the cObj object with current row 838 $this->pi_EPtemp_cObj->start($row, $tablename); 839 // Setting TypoScript values in the $conf array. See documentation in TSref for the EDITPANEL cObject. 840 $conf['allow'] = 'edit,new,delete,move,hide'; 841 $panel = $this->pi_EPtemp_cObj->cObjGetSingle('EDITPANEL', $conf, 'editpanel'); 845 return '<!-- BEGIN: EDIT PANEL --><table border="0
" cellpadding="0
" cellspacing="0
" width="100%
"><tr><td valign="top
">' . $label . '</td><td valign="top
" align="right
">' . $panel . '</td></tr></table><!-- END: EDIT PANEL -->'; 847 return '<!-- BEGIN: EDIT PANEL -->' . $panel . '<!-- END: EDIT PANEL -->'; 868 public function pi_getEditIcon($content, $fields, $title = '', $row = '', $tablename = '', $oConf = array()) { 869 if ($GLOBALS['TSFE']->beUserLogin) { 870 if (!$row || !$tablename) { 871 $row = $this->internal['currentRow']; 872 $tablename = $this->internal['currentTable']; 874 $conf = array_merge(array( 875 'beforeLastTag' => 1, 876 'iconTitle' => $title 878 $content = $this->cObj->editIcons($content, $tablename . ':' . $fields, $conf, $tablename . ':' . $row['uid'], $row, '&viewUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))); 883 /*************************** 885 * Localization, locallang functions 887 **************************/ 897 public function pi_getLL($key, $alternativeLabel = '', $hsc = FALSE) { 899 if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0]['target']) 900 || isset($this->LOCAL_LANG_UNSET[$this->LLkey][$key]) 902 // The "from
" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG 903 if (isset($this->LOCAL_LANG_charset[$this->LLkey][$key])) { 904 $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->LLkey][$key][0]['target'], $this->LOCAL_LANG_charset[$this->LLkey][$key]); 906 $word = $this->LOCAL_LANG[$this->LLkey][$key][0]['target']; 908 } elseif ($this->altLLkey) { 909 $alternativeLanguageKeys = GeneralUtility::trimExplode(',', $this->altLLkey, TRUE); 910 $alternativeLanguageKeys = array_reverse($alternativeLanguageKeys); 911 foreach ($alternativeLanguageKeys as $languageKey) { 912 if (!empty($this->LOCAL_LANG[$languageKey][$key][0]['target']) 913 || isset($this->LOCAL_LANG_UNSET[$languageKey][$key]) 915 // Alternative language translation for key exists 916 $word = $this->LOCAL_LANG[$languageKey][$key][0]['target']; 917 // The "from
" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG 918 if (isset($this->LOCAL_LANG_charset[$languageKey][$key])) { 919 $word = $GLOBALS['TSFE']->csConv( 921 $this->LOCAL_LANG_charset[$this->altLLkey][$key] 928 if ($word === NULL) { 929 if (!empty($this->LOCAL_LANG['default'][$key][0]['target']) 930 || isset($this->LOCAL_LANG_UNSET['default'][$key]) 932 // Get default translation (without charset conversion, english) 933 $word = $this->LOCAL_LANG['default'][$key][0]['target']; 935 // Return alternative string or empty 936 $word = isset($this->LLtestPrefixAlt) ? $this->LLtestPrefixAlt . $alternativeLabel : $alternativeLabel; 939 $output = isset($this->LLtestPrefix) ? $this->LLtestPrefix . $word : $word; 941 $output = htmlspecialchars($output); 955 public function pi_loadLL() { 956 if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) { 957 $basePath = 'EXT:' . $this->extKey . '/' . dirname($this->scriptRelPath) . '/locallang.xml'; 958 // Read the strings in the required charset (since TYPO3 4.2) 959 $this->LOCAL_LANG = GeneralUtility::readLLfile($basePath, $this->LLkey, $GLOBALS['TSFE']->renderCharset); 960 $alternativeLanguageKeys = GeneralUtility::trimExplode(',', $this->altLLkey, TRUE); 961 foreach ($alternativeLanguageKeys as $languageKey) { 962 $tempLL = GeneralUtility::readLLfile($basePath, $languageKey); 963 if ($this->LLkey !== 'default' && isset($tempLL[$languageKey])) { 964 $this->LOCAL_LANG[$languageKey] = $tempLL[$languageKey]; 967 // Overlaying labels from TypoScript (including fictitious language keys for non-system languages!): 968 if (isset($this->conf['_LOCAL_LANG.'])) { 969 // Clear the "unset memory
" 970 $this->LOCAL_LANG_UNSET = array(); 971 foreach ($this->conf['_LOCAL_LANG.'] as $languageKey => $languageArray) { 972 // Remove the dot after the language key 973 $languageKey = substr($languageKey, 0, -1); 974 // Don't process label if the language is not loaded 975 if (is_array($languageArray) && isset($this->LOCAL_LANG[$languageKey])) { 976 foreach ($languageArray as $labelKey => $labelValue) { 977 if (!is_array($labelValue)) { 978 $this->LOCAL_LANG[$languageKey][$labelKey][0]['target'] = $labelValue; 979 if ($labelValue === '') { 980 $this->LOCAL_LANG_UNSET[$languageKey][$labelKey] = ''; 982 $this->LOCAL_LANG_charset[$languageKey][$labelKey] = 'utf-8'; 989 $this->LOCAL_LANG_loaded = 1; 992 /*************************** 996 **************************/ 1012 public function pi_exec_query($table, $count = 0, $addWhere = '', $mm_cat = '', $groupBy = '', $orderBy = '', $query = '') { 1015 // Fetches the list of PIDs to select from. 1016 // TypoScript property .pidList is a comma list of pids. If blank, current page id is used. 1017 // TypoScript property .recursive is a int+ which determines how many levels down from the pids in the pid-list subpages should be included in the select. 1018 $pidList = $this->pi_getPidList($this->conf['pidList'], $this->conf['recursive']); 1019 if (is_array($mm_cat)) { 1020 // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT 1021 // selected, if they should not! Almost ALWAYS add this to your queries! 1022 $query = 'FROM ' . $table . ',' . $mm_cat['table'] . ',' . $mm_cat['mmtable'] . LF . ' WHERE ' . $table . '.uid=' . $mm_cat['mmtable'] . '.uid_local AND ' . $mm_cat['table'] . '.uid=' . $mm_cat['mmtable'] . '.uid_foreign ' . LF . (strcmp($mm_cat['catUidList'], '') ? ' AND ' . $mm_cat['table'] . '.uid IN (' . $mm_cat['catUidList'] . ')' : '') . LF . ' AND ' . $table . '.pid IN (' . $pidList . ')' . LF . $this->cObj->enableFields($table) . LF; 1024 // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT 1025 // selected, if they should not! Almost ALWAYS add this to your queries! 1026 $query = 'FROM ' . $table . ' WHERE pid IN (' . $pidList . ')' . LF . $this->cObj->enableFields($table) . LF; 1029 // Split the "FROM ... WHERE
" string so we get the WHERE part and TABLE names separated...: 1030 list($TABLENAMES, $WHERE) = preg_split('/WHERE/i', trim($query), 2); 1031 $TABLENAMES = trim(substr(trim($TABLENAMES), 5)); 1032 $WHERE = trim($WHERE); 1035 $WHERE .= ' ' . $addWhere . LF; 1038 if ($this->piVars['sword'] && $this->internal['searchFieldList']) { 1039 $WHERE .= $this->cObj->searchWhere($this->piVars['sword'], $this->internal['searchFieldList'], $table) . LF; 1042 $queryParts = array( 1043 'SELECT' => 'count(*)', 1044 'FROM' => $TABLENAMES, 1052 if (!$orderBy && $this->internal['orderBy']) { 1053 if (GeneralUtility::inList($this->internal['orderByList'], $this->internal['orderBy'])) { 1054 $orderBy = 'ORDER BY ' . $table . '.' . $this->internal['orderBy'] . ($this->internal['descFlag'] ? ' DESC' : ''); 1058 $pointer = (int)$this->piVars['pointer']; 1059 $results_at_a_time = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->internal['results_at_a_time'], 1, 1000); 1060 $LIMIT = $pointer * $results_at_a_time . ',' . $results_at_a_time; 1062 $queryParts = array( 1063 'SELECT' => $this->pi_prependFieldsWithTable($table, $this->pi_listFields), 1064 'FROM' => $TABLENAMES, 1066 'GROUPBY' => $GLOBALS['TYPO3_DB']->stripGroupBy($groupBy), 1067 'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), 1071 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 1084 public function pi_getRecord($table, $uid, $checkPage = 0) { 1085 return $GLOBALS['TSFE']->sys_page->checkRecord($table, $uid, $checkPage); 1096 public function pi_getPidList($pid_list, $recursive = 0) { 1097 if (!strcmp($pid_list, '')) { 1098 $pid_list = $GLOBALS['TSFE']->id; 1100 $recursive = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($recursive, 0); 1101 $pid_list_arr = array_unique(GeneralUtility::trimExplode(',', $pid_list, TRUE)); 1102 $pid_list = array(); 1103 foreach ($pid_list_arr as $val) { 1104 $val = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($val, 0); 1106 $_list = $this->cObj->getTreeList(-1 * $val, $recursive); 1108 $pid_list[] = $_list; 1112 return implode(',', $pid_list); 1123 public function pi_prependFieldsWithTable($table, $fieldList) { 1124 $list = GeneralUtility::trimExplode(',', $fieldList, TRUE); 1126 foreach ($list as $listItem) { 1127 $return[] = $table . '.' . $listItem; 1129 return implode(',', $return); 1144 public function pi_getCategoryTableContents($table, $pid, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '') { 1145 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . (int)$pid . $this->cObj->enableFields($table) . ' ' . $whereClause, $groupBy, $orderBy, $limit); 1147 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 1148 $outArr[$row['uid']] = $row; 1150 $GLOBALS['TYPO3_DB']->sql_free_result($res); 1154 /*************************** 1158 **************************/ 1168 public function pi_isOnlyFields($fList, $lowerThan = -1) { 1169 $lowerThan = $lowerThan == -1 ? $this->pi_lowerThan : $lowerThan; 1170 $fList = GeneralUtility::trimExplode(',', $fList, TRUE); 1171 $tempPiVars = $this->piVars; 1172 foreach ($fList as $k) { 1173 if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($tempPiVars[$k]) || $tempPiVars[$k] < $lowerThan) { 1174 unset($tempPiVars[$k]); 1177 if (!count($tempPiVars)) { 1192 public function pi_autoCache($inArray) { 1193 if (is_array($inArray)) { 1194 foreach ($inArray as $fN => $fV) { 1195 if (!strcmp($inArray[$fN], '')) { 1196 unset($inArray[$fN]); 1197 } elseif (is_array($this->pi_autoCacheFields[$fN])) { 1198 if (is_array($this->pi_autoCacheFields[$fN]['range']) && (int)$inArray[$fN] >= (int)$this->pi_autoCacheFields[$fN]['range'][0] && (int)$inArray[$fN] <= (int)$this->pi_autoCacheFields[$fN]['range'][1]) { 1199 unset($inArray[$fN]); 1201 if (is_array($this->pi_autoCacheFields[$fN]['list']) && in_array($inArray[$fN], $this->pi_autoCacheFields[$fN]['list'])) { 1202 unset($inArray[$fN]); 1207 if (!count($inArray)) { 1222 public function pi_RTEcssText($str) { 1223 $parseFunc = $GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']; 1224 if (is_array($parseFunc)) { 1225 $str = $this->cObj->parseFunc($str, $parseFunc); 1230 /******************************* 1232 * FlexForms related functions 1234 *******************************/ 1242 public function pi_initPIflexForm($field = 'pi_flexform') { 1243 // Converting flexform data into array: 1244 if (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) { 1245 $this->cObj->data[$field] = GeneralUtility::xml2array($this->cObj->data[$field]); 1246 if (!is_array($this->cObj->data[$field])) { 1247 $this->cObj->data[$field] = array(); 1263 public function pi_getFFvalue($T3FlexForm_array, $fieldName, $sheet = 'sDEF', $lang = 'lDEF', $value = 'vDEF') { 1264 $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$lang] : ''; 1265 if (is_array($sheetArray)) { 1266 return $this->pi_getFFvalueFromSheetArray($sheetArray, explode('/', $fieldName), $value); 1281 public function pi_getFFvalueFromSheetArray($sheetArray, $fieldNameArr, $value) { 1282 $tempArr = $sheetArray; 1283 foreach ($fieldNameArr as $k => $v) { 1284 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($v)) { 1285 if (is_array($tempArr)) { 1287 foreach ($tempArr as $values) { 1296 $tempArr = $tempArr[$v]; 1299 return $tempArr[$value]; pi_linkTP_keepPIvars_url($overrulePIvars=array(), $cache=0, $clearAnyway=0, $altPageId=0)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
pi_list_linkSingle($str, $uid, $cache=FALSE, $mergeArr=array(), $urlOnly=FALSE, $altPageId=0)
applyStdWrapRecursive(array $conf, $level=0)
static makeInstance($className)
static get_tag_attributes($tag)
pi_getPageLink($id, $target='', $urlParameters=array())
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=FALSE, $rawurlencodeParamName=FALSE)
pi_linkToPage($str, $id, $target='', $urlParameters=array())
static _GPmerged($parameter)
pi_linkTP($str, $urlParameters=array(), $cache=0, $altPageId=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
pi_linkTP_keepPIvars($str, $overrulePIvars=array(), $cache=0, $clearAnyway=0, $altPageId=0)
pi_openAtagHrefInJSwindow($str, $winName='', $winParams='width=670, height=500, status=0, menubar=0, scrollbars=1, resizable=1')