2 namespace TYPO3\CMS\Frontend\Plugin;
86 public $internal = array(
'res_count' => 0,
'results_at_a_time' => 20,
'maxPages' => 10,
'currentRow' => array(),
'currentTable' =>
'');
251 if ($this->prefixId) {
256 if ($this->pi_checkCHash && !empty($this->piVars)) {
257 $this->frontendController->reqCHash();
260 if (!empty($this->frontendController->config[
'config'][
'language'])) {
261 $this->LLkey = $this->frontendController->config[
'config'][
'language'];
262 if (empty($this->frontendController->config[
'config'][
'language_alt'])) {
265 if (in_array($this->LLkey,
$locales->getLocales())) {
266 $this->altLLkey =
'';
267 foreach (
$locales->getLocaleDependencies($this->LLkey) as $language) {
268 $this->altLLkey .= $language .
',';
270 $this->altLLkey = rtrim($this->altLLkey,
',');
273 $this->altLLkey = $this->frontendController->config[
'config'][
'language_alt'];
287 foreach ($conf as $key => $confNextLevel) {
288 if (strpos($key,
'.') !==
false) {
289 $key = substr($key, 0, -1);
292 foreach ($confNextLevel as $subKey => $subConfNextLevel) {
293 if (is_array($subConfNextLevel) && strpos($subKey,
'.') !==
false && $subKey !==
'stdWrap.') {
299 foreach ($confNextLevel as $subKey => $subConfNextLevel) {
300 if (is_array($subConfNextLevel) && $subKey ===
'stdWrap.') {
301 $conf[$key] = $this->cObj->stdWrap($conf[$key], $conf[$key .
'.'][
'stdWrap.']);
302 unset($conf[$key .
'.'][
'stdWrap.']);
303 if (empty($conf[$key .
'.'])) {
304 unset($conf[$key .
'.']);
320 if (isset($this->conf[
'_DEFAULT_PI_VARS.']) && is_array($this->conf[
'_DEFAULT_PI_VARS.'])) {
322 $tmp = $this->conf[
'_DEFAULT_PI_VARS.'];
324 $this->piVars = $tmp;
349 return $this->cObj->getTypoLink_URL($id, $urlParameters, $target);
364 public function pi_linkToPage($str, $id, $target =
'', $urlParameters = array())
366 return $this->cObj->getTypoLink($str, $id, $urlParameters, $target);
380 public function pi_linkTP($str, $urlParameters = array(), $cache =
false, $altPageId = 0)
383 $conf[
'useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
384 $conf[
'no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
385 $conf[
'parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId : $this->frontendController->id);
387 return $this->cObj->typoLink($str,
$conf);
403 public function pi_linkTP_keepPIvars($str, $overrulePIvars = array(), $cache =
false, $clearAnyway =
false, $altPageId = 0)
405 if (is_array($this->piVars) && is_array($overrulePIvars) && !$clearAnyway) {
410 if ($this->pi_autoCacheEn) {
414 return $this->
pi_linkTP($str, array($this->prefixId => $overrulePIvars), $cache, $altPageId);
431 return $this->cObj->lastTypoLinkUrl;
447 public function pi_list_linkSingle($str, $uid, $cache =
false, $mergeArr = array(), $urlOnly =
false, $altPageId = 0)
449 if ($this->prefixId) {
451 $overrulePIvars = $uid ? array(
'showUid' => $uid) : array();
452 $overrulePIvars = array_merge($overrulePIvars, (array)$mergeArr);
453 $str = $this->
pi_linkTP($str, array($this->prefixId => $overrulePIvars), $cache, $altPageId);
455 $overrulePIvars = array(
'showUid' => $uid ?:
'');
456 $overrulePIvars = array_merge($overrulePIvars, (array)$mergeArr);
461 $str = $this->cObj->lastTypoLinkUrl;
475 public function pi_openAtagHrefInJSwindow($str, $winName =
'', $winParams =
'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1')
477 if (preg_match(
'/(.*)(<a[^>]*>)(.*)/i', $str, $match)) {
479 $onClick =
'vHWin=window.open('
483 $match[2] =
'<a href="#" onclick="' . htmlspecialchars($onClick) .
'">';
484 $str = $match[1] . $match[2] . $match[3];
518 public function pi_list_browseresults($showResultCount = 1, $tableParams =
'', $wrapArr = array(), $pointerName =
'pointer', $hscText =
true, $forceOutput =
false)
531 $pointer = (int)$this->piVars[$pointerName];
532 $count = (int)$this->
internal[
'res_count'];
534 $totalPages = ceil($count / $results_at_a_time);
537 if (!$forceOutput && $count <= $results_at_a_time) {
544 $showResultCount = (int)$showResultCount;
546 $showFirstLast = $this->
internal[
'showFirstLast'];
549 if (isset($this->
internal[
'pagefloat'])) {
550 if (strtoupper($this->
internal[
'pagefloat']) ==
'CENTER') {
551 $pagefloat = ceil(($maxPages - 1) / 2);
561 $wrapper[
'disabledLinkWrap'] =
'<td nowrap="nowrap"><p>|</p></td>';
562 $wrapper[
'inactiveLinkWrap'] =
'<td nowrap="nowrap"><p>|</p></td>';
563 $wrapper[
'activeLinkWrap'] =
'<td' . $this->
pi_classParam(
'browsebox-SCell') .
' nowrap="nowrap"><p>|</p></td>';
564 $wrapper[
'browseLinksWrap'] = rtrim(
'<table ' . $tableParams) .
'><tr>|</tr></table>';
565 $wrapper[
'showResultsWrap'] =
'<p>|</p>';
566 $wrapper[
'browseBoxWrap'] =
'
574 $wrapper = array_merge($wrapper, $wrapArr);
576 if ($showResultCount != 2) {
577 if ($pagefloat > -1) {
578 $lastPage = min($totalPages, max($pointer + 1 + $pagefloat, $maxPages));
579 $firstPage = max(0, $lastPage - $maxPages);
587 if ($showFirstLast) {
591 $links[] = $this->cObj->wrap($this->
pi_getLL(
'pi_list_browseresults_first',
'<< First', $hscText), $wrapper[
'disabledLinkWrap']);
595 if ($alwaysPrev >= 0) {
597 $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']);
599 $links[] = $this->cObj->wrap($this->
pi_getLL(
'pi_list_browseresults_prev',
'< Previous', $hscText), $wrapper[
'disabledLinkWrap']);
603 for ($a = $firstPage; $a < $lastPage; $a++) {
604 if ($this->
internal[
'showRange']) {
605 $pageText = ($a * $results_at_a_time + 1) .
'-' . min($count, ($a + 1) * $results_at_a_time);
607 $pageText = trim($this->
pi_getLL(
'pi_list_browseresults_page',
'Page', $hscText) .
' ' . ($a + 1));
610 if ($pointer == $a) {
611 if ($this->
internal[
'dontLinkActivePage']) {
612 $links[] = $this->cObj->wrap($pageText, $wrapper[
'activeLinkWrap']);
620 if ($pointer < $totalPages - 1 || $showFirstLast) {
622 if ($pointer >= $totalPages - 1) {
623 $links[] = $this->cObj->wrap($this->
pi_getLL(
'pi_list_browseresults_next',
'Next >', $hscText), $wrapper[
'disabledLinkWrap']);
629 if ($showFirstLast) {
630 if ($pointer < $totalPages - 1) {
633 $links[] = $this->cObj->wrap($this->
pi_getLL(
'pi_list_browseresults_last',
'Last >>', $hscText), $wrapper[
'disabledLinkWrap']);
636 $theLinks = $this->cObj->wrap(implode(LF, $links), $wrapper[
'browseLinksWrap']);
640 $pR1 = $pointer * $results_at_a_time + 1;
641 $pR2 = $pointer * $results_at_a_time + $results_at_a_time;
642 if ($showResultCount) {
643 if ($wrapper[
'showResultsNumbersWrap']) {
646 $markerArray[
'###FROM###'] = $this->cObj->wrap($this->
internal[
'res_count'] > 0 ? $pR1 : 0, $wrapper[
'showResultsNumbersWrap']);
647 $markerArray[
'###TO###'] = $this->cObj->wrap(min($this->
internal[
'res_count'], $pR2), $wrapper[
'showResultsNumbersWrap']);
648 $markerArray[
'###OUT_OF###'] = $this->cObj->wrap($this->
internal[
'res_count'], $wrapper[
'showResultsNumbersWrap']);
649 $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']);
650 $markerArray[
'###CURRENT_PAGE###'] = $this->cObj->wrap($pointer + 1, $wrapper[
'showResultsNumbersWrap']);
651 $markerArray[
'###TOTAL_PAGES###'] = $this->cObj->wrap($totalPages, $wrapper[
'showResultsNumbersWrap']);
653 $resultCountMsg = $this->cObj->substituteMarkerArray($this->
pi_getLL(
'pi_list_browseresults_displays',
'Displaying results ###FROM### to ###TO### out of ###OUT_OF###'), $markerArray);
656 $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);
658 $resultCountMsg = $this->cObj->wrap($resultCountMsg, $wrapper[
'showResultsWrap']);
660 $resultCountMsg =
'';
662 $sTables = $this->cObj->wrap($resultCountMsg . $theLinks, $wrapper[
'browseBoxWrap']);
685 <' . rtrim(
'table ' . $tableParams) .
'>
687 <td><input type="text" name="' . $this->prefixId .
'[sword]" value="' . htmlspecialchars($this->piVars[
'sword']) .
'"' . $this->
pi_classParam(
'searchbox-sword') .
' /></td>
688 <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>
706 foreach ($items as $k => $v) {
713 Mode selector (menu for list):
716 <' . rtrim(
'table ' . $tableParams) .
'>
718 ' . implode(
'', $cells) .
'
741 $this->
internal[
'currentRow'] =
'';
745 while ($this->
internal[
'currentRow'] = $this->databaseConnection->sql_fetch_assoc($res)) {
755 <' . rtrim(
'table ' . $tableParams) .
'>
756 ' . implode(
'', $tRows) .
'
773 return '<tr' . ($c % 2 ? $this->
pi_classParam(
'listrow-odd') :
'') .
'><td><p>[dummy row]</p></td></tr>';
785 return '<tr' . $this->
pi_classParam(
'listrow-header') .
'><td><p>[dummy header row]</p></td></tr>';
801 return str_replace(
'_',
'-', $this->prefixId) . ($this->prefixId ?
'-' :
'') . $class;
817 foreach ($classNames as $className) {
821 foreach ($additionalClassNames as $additionalClassName) {
822 $output .=
' ' . $additionalClassName;
824 return ' class="' . trim($output) .
'"';
836 $content =
'<div class="' . str_replace(
'_',
'-', $this->prefixId) .
'">
840 if (!$this->frontendController->config[
'config'][
'disablePrefixComment']) {
846 BEGIN: Content of extension "' . $this->extKey .
'", plugin "' . $this->prefixId .
'"
850 <!-- END: Content of extension "' . $this->extKey .
'", plugin "' . $this->prefixId .
'" -->
875 if (!$row || !$tablename) {
876 $row = $this->
internal[
'currentRow'];
877 $tablename = $this->
internal[
'currentTable'];
879 if ($this->frontendController->beUserLogin) {
881 if (!is_object($this->pi_EPtemp_cObj)) {
883 $this->pi_EPtemp_cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
886 $this->pi_EPtemp_cObj->start($row, $tablename);
888 $conf[
'allow'] =
'edit,new,delete,move,hide';
889 $panel = $this->pi_EPtemp_cObj->cObjGetSingle(
'EDITPANEL',
$conf,
'editpanel');
893 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 -->';
895 return '<!-- BEGIN: EDIT PANEL -->' . $panel .
'<!-- END: EDIT PANEL -->';
915 public function pi_getEditIcon($content, $fields, $title =
'', $row = array(), $tablename =
'', $oConf = array())
917 if ($this->frontendController->beUserLogin) {
918 if (!$row || !$tablename) {
919 $row = $this->
internal[
'currentRow'];
920 $tablename = $this->
internal[
'currentTable'];
922 $conf = array_merge(array(
923 'beforeLastTag' => 1,
924 'iconTitle' => $title
926 $content = $this->cObj->editIcons($content, $tablename .
':' . $fields,
$conf, $tablename .
':' . $row[
'uid'], $row,
'&viewUrl=' . rawurlencode(
GeneralUtility::getIndpEnv(
'REQUEST_URI')));
945 public function pi_getLL($key, $alternativeLabel =
'', $hsc =
false)
948 if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0][
'target'])
949 || isset($this->LOCAL_LANG_UNSET[$this->LLkey][$key])
952 if (isset($this->LOCAL_LANG_charset[$this->LLkey][$key])) {
953 $word = $this->frontendController->csConv($this->LOCAL_LANG[$this->LLkey][$key][0][
'target'], $this->LOCAL_LANG_charset[$this->LLkey][$key]);
955 $word = $this->LOCAL_LANG[
$this->LLkey][$key][0][
'target'];
957 }
elseif ($this->altLLkey) {
959 $alternativeLanguageKeys = array_reverse($alternativeLanguageKeys);
960 foreach ($alternativeLanguageKeys as $languageKey) {
961 if (!empty($this->LOCAL_LANG[$languageKey][$key][0][
'target'])
962 || isset($this->LOCAL_LANG_UNSET[$languageKey][$key])
965 $word = $this->LOCAL_LANG[$languageKey][$key][0][
'target'];
967 if (isset($this->LOCAL_LANG_charset[$languageKey][$key])) {
968 $word = $this->frontendController->csConv(
970 $this->LOCAL_LANG_charset[$this->altLLkey][$key]
977 if ($word === null) {
978 if (!empty($this->LOCAL_LANG[
'default'][$key][0][
'target'])
979 || isset($this->LOCAL_LANG_UNSET[
'default'][$key])
982 $word = $this->LOCAL_LANG[
'default'][$key][0][
'target'];
985 $word = isset($this->LLtestPrefixAlt) ? $this->LLtestPrefixAlt . $alternativeLabel : $alternativeLabel;
988 $output = isset($this->LLtestPrefix) ? $this->LLtestPrefix . $word : $word;
990 $output = htmlspecialchars($output);
1006 public function pi_loadLL($languageFilePath =
'')
1008 if ($this->LOCAL_LANG_loaded) {
1012 if ($languageFilePath ===
'' && $this->scriptRelPath) {
1013 $languageFilePath =
'EXT:' . $this->extKey .
'/' . dirname($this->scriptRelPath) .
'/locallang.xlf';
1015 if ($languageFilePath !==
'') {
1019 $this->LOCAL_LANG = $languageFactory->getParsedData($languageFilePath, $this->LLkey, $this->frontendController->renderCharset);
1021 foreach ($alternativeLanguageKeys as $languageKey) {
1022 $tempLL = $languageFactory->getParsedData($languageFilePath, $languageKey);
1023 if ($this->LLkey !==
'default' && isset($tempLL[$languageKey])) {
1024 $this->LOCAL_LANG[$languageKey] = $tempLL[$languageKey];
1028 if (isset($this->conf[
'_LOCAL_LANG.'])) {
1030 $this->LOCAL_LANG_UNSET = array();
1031 foreach ($this->conf[
'_LOCAL_LANG.'] as $languageKey => $languageArray) {
1033 $languageKey = substr($languageKey, 0, -1);
1035 if (is_array($languageArray) && isset($this->LOCAL_LANG[$languageKey])) {
1036 foreach ($languageArray as $labelKey => $labelValue) {
1037 if (!is_array($labelValue)) {
1038 $this->LOCAL_LANG[$languageKey][$labelKey][0][
'target'] = $labelValue;
1039 if ($labelValue ===
'') {
1040 $this->LOCAL_LANG_UNSET[$languageKey][$labelKey] =
'';
1042 $this->LOCAL_LANG_charset[$languageKey][$labelKey] =
'utf-8';
1049 $this->LOCAL_LANG_loaded = 1;
1071 public function pi_exec_query($table, $count =
false, $addWhere =
'', $mm_cat =
'', $groupBy =
'', $orderBy =
'', $query =
'')
1078 $pidList = $this->
pi_getPidList($this->conf[
'pidList'], $this->conf[
'recursive']);
1079 if (is_array($mm_cat)) {
1082 $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;
1086 $query =
'FROM ' . $table .
' WHERE pid IN (' . $pidList .
')' . LF . $this->cObj->enableFields($table) . LF;
1090 list($TABLENAMES, $WHERE) = preg_split(
'/WHERE/i', trim($query), 2);
1091 $TABLENAMES = trim(substr(trim($TABLENAMES), 5));
1092 $WHERE = trim($WHERE);
1095 $WHERE .=
' ' . $addWhere . LF;
1098 if ($this->piVars[
'sword'] && $this->
internal[
'searchFieldList']) {
1099 $WHERE .= $this->cObj->searchWhere($this->piVars[
'sword'], $this->
internal[
'searchFieldList'], $table) . LF;
1102 $queryParts = array(
1103 'SELECT' =>
'count(*)',
1104 'FROM' => $TABLENAMES,
1112 if (!$orderBy && $this->
internal[
'orderBy']) {
1114 $orderBy =
'ORDER BY ' . $table .
'.' . $this->
internal[
'orderBy'] . ($this->
internal[
'descFlag'] ?
' DESC' :
'');
1118 $pointer = (int)$this->piVars[
'pointer'];
1120 $LIMIT = $pointer * $results_at_a_time .
',' . $results_at_a_time;
1122 $queryParts = array(
1124 'FROM' => $TABLENAMES,
1126 'GROUPBY' => $this->databaseConnection->stripGroupBy($groupBy),
1127 'ORDERBY' => $this->databaseConnection->stripOrderBy($orderBy),
1131 return $this->databaseConnection->exec_SELECT_queryArray($queryParts);
1145 return $this->frontendController->sys_page->checkRecord($table, $uid, $checkPage);
1157 if (!strcmp($pid_list,
'')) {
1158 $pid_list = $this->frontendController->id;
1162 $pid_list = array();
1163 foreach ($pid_list_arr as $val) {
1166 $_list = $this->cObj->getTreeList(-1 * $val, $recursive);
1168 $pid_list[] = $_list;
1172 return implode(
',', $pid_list);
1186 foreach (
$list as $listItem) {
1187 $return[] = $table .
'.' . $listItem;
1189 return implode(
',', $return);
1205 $res = $this->databaseConnection->exec_SELECTquery(
'*', $table,
'pid=' . (
int)$pid . $this->cObj->enableFields($table) .
' ' . $whereClause, $groupBy, $orderBy, $limit);
1207 while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
1208 $outArr[$row[
'uid']] = $row;
1210 $this->databaseConnection->sql_free_result($res);
1229 $lowerThan = $lowerThan == -1 ? $this->pi_lowerThan : $lowerThan;
1232 foreach ($fList as $k) {
1234 unset($tempPiVars[$k]);
1237 if (empty($tempPiVars)) {
1255 if (is_array($inArray)) {
1256 foreach ($inArray as $fN => $fV) {
1257 if (!strcmp($inArray[$fN],
'')) {
1258 unset($inArray[$fN]);
1259 }
elseif (is_array($this->pi_autoCacheFields[$fN])) {
1260 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]) {
1261 unset($inArray[$fN]);
1263 if (is_array($this->pi_autoCacheFields[$fN][
'list']) && in_array($inArray[$fN], $this->pi_autoCacheFields[$fN][
'list'])) {
1264 unset($inArray[$fN]);
1269 if (empty($inArray)) {
1287 $parseFunc = $this->frontendController->tmpl->setup[
'lib.'][
'parseFunc_RTE.'];
1288 if (is_array($parseFunc)) {
1289 $str = $this->cObj->parseFunc($str, $parseFunc);
1308 if (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) {
1310 if (!is_array($this->cObj->data[$field])) {
1311 $this->cObj->data[$field] = array();
1326 public function pi_getFFvalue($T3FlexForm_array, $fieldName, $sheet =
'sDEF',
$lang =
'lDEF', $value =
'vDEF')
1328 $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array[
'data'][$sheet][
$lang] :
'';
1329 if (is_array($sheetArray)) {
1347 $tempArr = $sheetArray;
1348 foreach ($fieldNameArr as $k => $v) {
1350 if (is_array($tempArr)) {
1352 foreach ($tempArr as $values) {
1361 $tempArr = $tempArr[$v];
1364 return $tempArr[$value];