2 namespace TYPO3\CMS\Frontend\ContentObject;
17 use TYPO3\CMS\Compatibility6\ContentObject\OffsetTableContentObject;
24 use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
80 'stdWrapPreProcess' =>
'hook',
82 'cacheRead' =>
'hook',
84 'setContentToCurrent' =>
'boolean',
85 'setContentToCurrent.' =>
'array',
86 'addPageCacheTags' =>
'string',
87 'addPageCacheTags.' =>
'array',
88 'setCurrent' =>
'string',
89 'setCurrent.' =>
'array',
93 'field' =>
'fieldName',
95 'current' =>
'boolean',
96 'current.' =>
'array',
97 'cObject' =>
'cObject',
98 'cObject.' =>
'array',
99 'numRows.' =>
'array',
101 'filelist.' =>
'array',
102 'preUserFunc' =>
'functionName',
103 'stdWrapOverride' =>
'hook',
105 'override' =>
'string',
106 'override.' =>
'array',
107 'preIfEmptyListNum' =>
'listNum',
108 'preIfEmptyListNum.' =>
'array',
109 'ifNull' =>
'string',
110 'ifNull.' =>
'array',
111 'ifEmpty' =>
'string',
112 'ifEmpty.' =>
'array',
113 'ifBlank' =>
'string',
114 'ifBlank.' =>
'array',
115 'listNum' =>
'listNum',
116 'listNum.' =>
'array',
119 'strPad.' =>
'array',
120 'stdWrap' =>
'stdWrap',
121 'stdWrap.' =>
'array',
122 'stdWrapProcess' =>
'hook',
124 'required' =>
'boolean',
125 'required.' =>
'array',
127 'fieldRequired' =>
'fieldName',
128 'fieldRequired.' =>
'array',
129 'csConv' =>
'string',
130 'csConv.' =>
'array',
131 'parseFunc' =>
'objectpath',
132 'parseFunc.' =>
'array',
133 'HTMLparser' =>
'boolean',
134 'HTMLparser.' =>
'array',
136 'replacement.' =>
'array',
137 'prioriCalc' =>
'boolean',
138 'prioriCalc.' =>
'array',
141 'intval' =>
'boolean',
142 'intval.' =>
'array',
145 'round' =>
'boolean',
147 'numberFormat.' =>
'array',
148 'expandList' =>
'boolean',
149 'expandList.' =>
'array',
150 'date' =>
'dateconf',
152 'strtotime' =>
'strtotimeconf',
153 'strtotime.' =>
'array',
154 'strftime' =>
'strftimeconf',
155 'strftime.' =>
'array',
160 'bytes' =>
'boolean',
162 'substring' =>
'parameters',
163 'substring.' =>
'array',
164 'removeBadHTML' =>
'boolean',
165 'removeBadHTML.' =>
'array',
166 'cropHTML' =>
'crop',
167 'cropHTML.' =>
'array',
168 'stripHtml' =>
'boolean',
169 'stripHtml.' =>
'array',
172 'rawUrlEncode' =>
'boolean',
173 'rawUrlEncode.' =>
'array',
174 'htmlSpecialChars' =>
'boolean',
175 'htmlSpecialChars.' =>
'array',
176 'encodeForJavaScriptValue' =>
'boolean',
177 'encodeForJavaScriptValue.' =>
'array',
178 'doubleBrTag' =>
'string',
179 'doubleBrTag.' =>
'array',
184 'encapsLines.' =>
'array',
185 'keywords' =>
'boolean',
186 'keywords.' =>
'array',
187 'innerWrap' =>
'wrap',
188 'innerWrap.' =>
'array',
189 'innerWrap2' =>
'wrap',
190 'innerWrap2.' =>
'array',
192 'fontTag.' =>
'array',
193 'addParams.' =>
'array',
194 'textStyle.' =>
'array',
195 'tableStyle.' =>
'array',
196 'filelink.' =>
'array',
197 'preCObject' =>
'cObject',
198 'preCObject.' =>
'array',
199 'postCObject' =>
'cObject',
200 'postCObject.' =>
'array',
201 'wrapAlign' =>
'align',
202 'wrapAlign.' =>
'array',
203 'typolink.' =>
'array',
204 'TCAselectItem.' =>
'array',
207 'spaceBefore' =>
'int',
208 'spaceBefore.' =>
'array',
209 'spaceAfter' =>
'int',
210 'spaceAfter.' =>
'array',
213 'noTrimWrap' =>
'wrap',
214 'noTrimWrap.' =>
'array',
217 'dataWrap' =>
'dataWrap',
218 'dataWrap.' =>
'array',
219 'prepend' =>
'cObject',
220 'prepend.' =>
'array',
221 'append' =>
'cObject',
222 'append.' =>
'array',
225 'orderedStdWrap' =>
'stdWrap',
226 'orderedStdWrap.' =>
'array',
227 'outerWrap' =>
'wrap',
228 'outerWrap.' =>
'array',
229 'insertData' =>
'boolean',
230 'insertData.' =>
'array',
231 'offsetWrap' =>
'space',
232 'offsetWrap.' =>
'array',
233 'postUserFunc' =>
'functionName',
234 'postUserFuncInt' =>
'functionName',
235 'prefixComment' =>
'string',
236 'prefixComment.' =>
'array',
237 'editIcons' =>
'string',
238 'editIcons.' =>
'array',
239 'editPanel' =>
'boolean',
240 'editPanel.' =>
'array',
241 'cacheStore' =>
'hook',
243 'stdWrapPostProcess' =>
'hook',
245 'debug' =>
'boolean',
247 'debugFunc' =>
'boolean',
248 'debugFunc.' =>
'array',
249 'debugData' =>
'boolean',
250 'debugData.' =>
'array'
272 'params' =>
'-colors 128',
276 'params' =>
'-colors 64',
280 'params' =>
'-colors 32',
284 'params' =>
'-colors 16',
288 'params' =>
'-colors 8',
292 'params' =>
'-quality 100',
296 'params' =>
'-quality 90',
300 'params' =>
'-quality 80',
304 'params' =>
'-quality 70',
308 'params' =>
'-quality 60',
312 'params' =>
'-quality 50',
316 'params' =>
'-quality 40',
320 'params' =>
'-quality 30',
324 'params' =>
'-quality 20',
328 'params' =>
'-colors 256',
332 'params' =>
'-colors 128',
336 'params' =>
'-colors 64',
340 'params' =>
'-colors 32',
344 'params' =>
'-colors 16',
348 'params' =>
'-colors 8',
367 10 =>
'-colorspace GRAY',
587 $this->contentObjectClassMap =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'ContentObjects'];
600 $vars = get_object_vars($this);
601 unset($vars[
'typoScriptFrontendController']);
603 $this->currentFile =
'FileReference:' . $this->currentFile->getUid();
604 }
elseif ($this->currentFile instanceof
File) {
605 $this->currentFile =
'File:' . $this->currentFile->getIdentifier();
607 unset($vars[
'currentFile']);
609 return array_keys($vars);
620 $this->typoScriptFrontendController =
$GLOBALS[
'TSFE'];
622 if ($this->currentFile !== null && is_string($this->currentFile)) {
623 list($objectType, $identifier) = explode(
':', $this->currentFile, 2);
625 if ($objectType ===
'File') {
627 }
elseif ($objectType ===
'FileReference') {
631 $this->currentFile = null;
662 $this->contentObjectClassMap[$contentObjectName] = $className;
678 $this->currentRecord =
$table ?
$table .
':' . $this->data[
'uid'] :
'';
679 $this->parameters = array();
680 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'cObjTypeAndClass'])) {
681 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'cObjTypeAndClass'] as $classArr) {
682 $this->cObjHookObjectsRegistry[$classArr[0]] = $classArr[1];
685 $this->stdWrapHookObjects = array();
686 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'stdWrap'])) {
687 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'stdWrap'] as $classData) {
690 throw new \UnexpectedValueException($classData .
' must implement interface ' . ContentObjectStdWrapHookInterface::class, 1195043965);
692 $this->stdWrapHookObjects[] = $hookObject;
695 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'postInit'])) {
696 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'postInit'] as $classData) {
699 throw new \UnexpectedValueException($classData .
' must implement interface ' . ContentObjectPostInitHookInterface::class, 1274563549);
701 $postInitializationProcessor->postProcessContentObjectInitialization($this);
724 if (!isset($this->getImgResourceHookObjects)) {
725 $this->getImgResourceHookObjects = array();
726 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImgResource'])) {
727 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImgResource'] as $classData) {
730 throw new \UnexpectedValueException(
'$hookObject must implement interface ' . ContentObjectGetImageResourceHookInterface::class, 1218636383);
732 $this->getImgResourceHookObjects[] = $hookObject;
750 $this->parentRecord = array(
797 if (!is_array($setup)) {
802 foreach ($sKeyArray as $theKey) {
803 $theValue = $setup[$theKey];
804 if ((
int)$theKey && strpos($theKey,
'.') ===
false) {
805 $conf = $setup[$theKey .
'.'];
806 $content .= $this->cObjGetSingle($theValue, $conf, $addKey . $theKey);
821 public function cObjGetSingle($name, $conf, $TSkey =
'__')
829 if ($timeTracker->LR) {
830 $timeTracker->push($TSkey, $name);
833 if ($name[0] ===
'<') {
834 $key = trim(substr($name, 1));
837 $confOverride = is_array($conf) ? $conf : array();
839 $conf = array_replace_recursive(is_array($conf) ? $conf : array(), $confOverride);
841 $timeTracker->incStackPointer();
842 $content .= $this->cObjGetSingle($name, $conf, $key);
843 $timeTracker->decStackPointer();
847 if (!empty($this->cObjHookObjectsRegistry[$name])) {
848 if (empty($this->cObjHookObjectsArr[$name])) {
851 $hookObj = $this->cObjHookObjectsArr[$name];
852 if (method_exists($hookObj,
'cObjGetSingleExt')) {
853 $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
859 if ($contentObject) {
860 $content .= $this->render($contentObject, $conf);
863 if ($name && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'cObjTypeAndClassDefault'])) {
864 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'cObjTypeAndClassDefault'] as $classData) {
866 if (!$hookObject instanceof ContentObjectGetSingleHookInterface) {
867 throw new \UnexpectedValueException(
'$hookObject must implement interface ' . ContentObjectGetSingleHookInterface::class, 1195043731);
870 $content .= $hookObject->getSingleContentObject($name, (array)$conf, $TSkey, $this);
874 $warning = sprintf(
'Content Object "%s" does not exist', $name);
875 $timeTracker->setTSlogMessage($warning, 2);
880 if ($timeTracker->LR) {
881 $timeTracker->pull($content);
900 if (!isset($this->contentObjectClassMap[$name])) {
903 $fullyQualifiedClassName = $this->contentObjectClassMap[$name];
906 throw new ContentRenderingException(sprintf(
'Registered content object class name "%" must be an instance of AbstractContentObject, but is not!', $fullyQualifiedClassName), 1422564295);
908 return $contentObject;
933 $cacheConfiguration = isset($configuration[
'cache.']) ? $configuration[
'cache.'] : null;
934 if ($cacheConfiguration !== null) {
935 unset($configuration[
'cache.']);
936 $cache = $this->getFromCache($cacheConfiguration);
937 if ($cache !==
false) {
944 $content .= $contentObject->
render($configuration);
945 }
catch (ContentRenderingException $exception) {
949 }
catch (\Exception $exception) {
951 if ($exceptionHandler === null) {
954 $content = $exceptionHandler->handle($exception, $contentObject, $configuration);
959 if ($cacheConfiguration !== null) {
966 $cacheFrontend->set($key, $content, $tags, $lifetime);
983 $exceptionHandler = null;
985 if (!empty($exceptionHandlerClassName)) {
988 throw new ContentRenderingException(
'An exception handler was configured but the class does not exist or does not implement the ExceptionHandlerInterface', 1403653369);
992 return $exceptionHandler;
1003 $exceptionHandlerClassName = null;
1005 if (!isset($tsfe->config[
'config'][
'contentObjectExceptionHandler'])) {
1007 $exceptionHandlerClassName =
'1';
1010 $exceptionHandlerClassName = $tsfe->config[
'config'][
'contentObjectExceptionHandler'];
1013 if (isset($configuration[
'exceptionHandler'])) {
1014 $exceptionHandlerClassName = $configuration[
'exceptionHandler'];
1017 if ($exceptionHandlerClassName ===
'1') {
1018 $exceptionHandlerClassName = ProductionExceptionHandler::class;
1021 return $exceptionHandlerClassName;
1033 $exceptionHandlerConfiguration = array();
1035 if (!empty($tsfe->config[
'config'][
'contentObjectExceptionHandler.'])) {
1036 $exceptionHandlerConfiguration = $tsfe->config[
'config'][
'contentObjectExceptionHandler.'];
1038 if (!empty($configuration[
'exceptionHandler.'])) {
1039 $exceptionHandlerConfiguration = array_replace_recursive($exceptionHandlerConfiguration, $configuration[
'exceptionHandler.']);
1042 return $exceptionHandlerConfiguration;
1094 if ($ext ===
'INT') {
1109 public function USER($conf, $ext =
'')
1112 if ($ext ===
'INT') {
1150 if ($this->userObjectType !== self::OBJECTTYPE_USER) {
1151 $this->
getTimeTracker()->setTSlogMessage(ContentObjectRenderer::class .
'::convertToUserIntObject() is called in the wrong context or for the wrong object type', 2);
1153 $this->doConvertToUserIntObject =
true;
1340 if ($name ===
'RESTORE_REGISTER') {
1357 public function FORM($conf, $formData =
'')
1483 if ($recursive ===
false && is_string($flexData)) {
1486 if (is_array($flexData) && isset($flexData[
'data'][
'sDEF'][
'lDEF'])) {
1487 $flexData = $flexData[
'data'][
'sDEF'][
'lDEF'];
1489 if (!is_array($flexData)) {
1492 foreach ($flexData as $key => $value) {
1493 if (!is_array($value)) {
1496 if (isset($value[
'el'])) {
1497 if (is_array($value[
'el']) && !empty($value[
'el'])) {
1498 foreach ($value[
'el'] as $ekey => $element) {
1499 if (isset($element[
'vDEF'])) {
1500 $conf[$ekey] = $element[
'vDEF'];
1502 if (is_array($element)) {
1513 if (isset($value[
'vDEF'])) {
1514 $conf[$key] = $value[
'vDEF'];
1529 $pidList = isset($pidConf) ? trim($this->
stdWrap($pidList, $pidConf)) : trim($pidList);
1530 if ($pidList ===
'') {
1535 if (trim($pidList)) {
1540 if (is_array($listArr) && !empty($listArr)) {
1541 foreach ($listArr as $uid) {
1542 $page = $tsfe->sys_page->getPage($uid);
1543 if (!$page[
'is_siteroot']) {
1544 $pidList[] = $page[
'pid'];
1548 return implode(
',', $pidList);
1565 $info = $this->getImgResource($file, $conf[
'file.']);
1566 $tsfe->lastImageInfo = $info;
1567 if (!is_array($info)) {
1570 if (is_file(PATH_site . $info[
'3'])) {
1576 $layoutKey = $this->
stdWrap($conf[
'layoutKey'], $conf[
'layoutKey.']);
1581 $tsfe->imagesOnPage[] = $source;
1584 if ($params !==
'' && $params{0} !==
' ') {
1585 $params =
' ' . $params;
1588 $imageTagValues = array(
1589 'width' => $info[0],
1590 'height' => $info[1],
1591 'src' => htmlspecialchars($source),
1592 'params' => $params,
1593 'altParams' => $altParam,
1594 'border' => $this->
getBorderAttr(
' border="' . (
int)$conf[
'border'] .
'"'),
1595 'sourceCollection' => $sourceCollection,
1596 'selfClosingTagSlash' => (!empty($tsfe->xhtmlDoctype) ?
' /' :
''),
1599 $theValue = $this->
substituteMarkerArray($imageTagTemplate, $imageTagValues,
'###|###',
true,
true);
1601 $linkWrap = isset($conf[
'linkWrap.']) ? $this->
stdWrap($conf[
'linkWrap'], $conf[
'linkWrap.']) : $conf[
'linkWrap'];
1603 $theValue = $this->
linkWrap($theValue, $linkWrap);
1604 }
elseif ($conf[
'imageLinkWrap']) {
1605 $originalFile = !empty($info[
'originalFile']) ? $info[
'originalFile'] : $info[
'origFile'];
1606 $theValue = $this->
imageLinkWrap($theValue, $originalFile, $conf[
'imageLinkWrap.']);
1608 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
1610 $theValue = $this->
wrap($theValue, $conf[
'wrap']);
1625 if (!
GeneralUtility::inList(
'xhtml_strict,xhtml_11,xhtml_2', $tsfe->xhtmlDoctype) && $tsfe->config[
'config'][
'doctype'] !=
'html5' && !$tsfe->config[
'config'][
'disableImgBorderAttr']) {
1641 if ($layoutKey && isset($conf[
'layout.']) && isset($conf[
'layout.'][$layoutKey .
'.'])) {
1642 $imageTagLayout = $this->
stdWrap($conf[
'layout.'][$layoutKey .
'.'][
'element'], $conf[
'layout.'][$layoutKey .
'.'][
'element.']);
1644 $imageTagLayout =
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>';
1646 return $imageTagLayout;
1660 $sourceCollection =
'';
1661 if ($layoutKey && $conf[
'sourceCollection.'] && ($conf[
'layout.'][$layoutKey .
'.'][
'source'] || $conf[
'layout.'][$layoutKey .
'.'][
'source.'])) {
1664 $activeSourceCollections = array();
1665 foreach ($conf[
'sourceCollection.'] as $sourceCollectionKey => $sourceCollectionConfiguration) {
1666 if (substr($sourceCollectionKey, -1) ==
'.') {
1667 if (empty($sourceCollectionConfiguration[
'if.']) || $this->
checkIf($sourceCollectionConfiguration[
'if.'])) {
1668 $activeSourceCollections[] = $sourceCollectionConfiguration;
1675 $srcLayoutOptionSplitted = $tsfe->tmpl->splitConfArray($conf[
'layout.'][$layoutKey .
'.'], count($activeSourceCollections));
1678 foreach ($activeSourceCollections as $key => $sourceConfiguration) {
1679 $sourceLayout = $this->
stdWrap($srcLayoutOptionSplitted[$key][
'source'], $srcLayoutOptionSplitted[$key][
'source.']);
1681 $sourceRenderConfiguration = array(
1683 'file.' => $conf[
'file.']
1686 if (isset($sourceConfiguration[
'quality']) || isset($sourceConfiguration[
'quality.'])) {
1687 $imageQuality = isset($sourceConfiguration[
'quality']) ? $sourceConfiguration[
'quality'] :
'';
1688 if (isset($sourceConfiguration[
'quality.'])) {
1689 $imageQuality = $this->
stdWrap($sourceConfiguration[
'quality'], $sourceConfiguration[
'quality.']);
1691 if ($imageQuality) {
1692 $sourceRenderConfiguration[
'file.'][
'params'] =
'-quality ' . (int)$imageQuality;
1696 if (isset($sourceConfiguration[
'pixelDensity'])) {
1697 $pixelDensity = (int)$this->
stdWrap($sourceConfiguration[
'pixelDensity'], $sourceConfiguration[
'pixelDensity.']);
1701 $dimensionKeys = array(
'width',
'height',
'maxW',
'minW',
'maxH',
'minH');
1702 foreach ($dimensionKeys as $dimensionKey) {
1703 $dimension = $this->
stdWrap($sourceConfiguration[$dimensionKey], $sourceConfiguration[$dimensionKey .
'.']);
1705 $dimension = $this->
stdWrap($conf[
'file.'][$dimensionKey], $conf[
'file.'][$dimensionKey .
'.']);
1708 if (strstr($dimension,
'c') !==
false && ($dimensionKey ===
'width' || $dimensionKey ===
'height')) {
1709 $dimensionParts = explode(
'c', $dimension, 2);
1710 $dimension = (int)($dimensionParts[0] * $pixelDensity) .
'c';
1711 if ($dimensionParts[1]) {
1712 $dimension .= $dimensionParts[1];
1715 $dimension = (int)($dimension * $pixelDensity);
1717 $sourceRenderConfiguration[
'file.'][$dimensionKey] = $dimension;
1719 unset($sourceRenderConfiguration[
'file.'][$dimensionKey .
'.']);
1722 $sourceInfo = $this->getImgResource($sourceRenderConfiguration[
'file'], $sourceRenderConfiguration[
'file.']);
1724 $sourceConfiguration[
'width'] = $sourceInfo[0];
1725 $sourceConfiguration[
'height'] = $sourceInfo[1];
1727 if (parse_url($sourceInfo[3], PHP_URL_HOST) === null) {
1728 $urlPrefix = $tsfe->absRefPrefix;
1730 $sourceConfiguration[
'src'] = htmlspecialchars($urlPrefix . $sourceInfo[3]);
1731 $sourceConfiguration[
'selfClosingTagSlash'] = (!empty($tsfe->xhtmlDoctype) ?
' /' :
'');
1733 $oneSourceCollection = $this->
substituteMarkerArray($sourceLayout, $sourceConfiguration,
'###|###',
true,
true);
1735 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImageSourceCollection'])) {
1736 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImageSourceCollection'] as $classData) {
1739 throw new \UnexpectedValueException(
1740 '$hookObject must implement interface ' . ContentObjectOneSourceCollectionHookInterface::class,
1744 $oneSourceCollection = $hookObject->getOneSourceCollection((array)$sourceRenderConfiguration, (array)$sourceConfiguration, $oneSourceCollection, $this);
1748 $sourceCollection .= $oneSourceCollection;
1752 return $sourceCollection;
1766 $enable = isset($conf[
'enable.']) ? $this->
stdWrap($conf[
'enable'], $conf[
'enable.']) : $conf[
'enable'];
1770 $content = $this->typoLink($string, $conf[
'typolink.']);
1771 if (isset($conf[
'file.'])) {
1772 $imageFile = $this->
stdWrap($imageFile, $conf[
'file.']);
1775 if ($imageFile instanceof
File) {
1778 $file = $imageFile->getOriginalFile();
1788 if ($content == $string) {
1789 $parameterNames = array(
'width',
'height',
'effects',
'bodyTag',
'title',
'wrap');
1791 $sample = isset($conf[
'sample.']) ? $this->
stdWrap($conf[
'sample'], $conf[
'sample.']) : $conf[
'sample'];
1795 foreach ($parameterNames as $parameterName) {
1796 if (isset($conf[$parameterName .
'.'])) {
1797 $conf[$parameterName] = $this->
stdWrap($conf[$parameterName], $conf[$parameterName .
'.']);
1799 if (isset($conf[$parameterName]) && $conf[$parameterName]) {
1800 $parameters[$parameterName] = $conf[$parameterName];
1803 $parametersEncoded = base64_encode(serialize(
$parameters));
1805 $params =
'&md5=' . $hmac;
1806 foreach (str_split($parametersEncoded, 64) as $index => $chunk) {
1807 $params .=
'¶meters' . rawurlencode(
'[') . $index . rawurlencode(
']') .
'=' . rawurlencode($chunk);
1810 $directImageLink = isset($conf[
'directImageLink.']) ? $this->
stdWrap($conf[
'directImageLink'], $conf[
'directImageLink.']) : $conf[
'directImageLink'];
1811 if ($directImageLink) {
1812 $imgResourceConf = array(
1813 'file' => $imageFile,
1816 $url = $this->cObjGetSingle(
'IMG_RESOURCE', $imgResourceConf);
1824 $target = isset($conf[
'target.']) ? $this->
stdWrap($conf[
'target'], $conf[
'target.']) : $conf[
'target'];
1826 $target = sprintf(
' target="%s"', $target);
1828 $target =
' target="thePicture"';
1835 $conf[
'JSwindow'] = isset($conf[
'JSwindow.']) ? $this->
stdWrap($conf[
'JSwindow'], $conf[
'JSwindow.']) : $conf[
'JSwindow'];
1836 if ($conf[
'JSwindow']) {
1837 if ($conf[
'JSwindow.'][
'altUrl'] || $conf[
'JSwindow.'][
'altUrl.']) {
1838 $altUrl = isset($conf[
'JSwindow.'][
'altUrl.']) ? $this->
stdWrap($conf[
'JSwindow.'][
'altUrl'], $conf[
'JSwindow.'][
'altUrl.']) : $conf[
'JSwindow.'][
'altUrl'];
1840 $url = $altUrl . ($conf[
'JSwindow.'][
'altUrl_noDefaultParams'] ?
'' :
'?file=' . rawurlencode($imageFile) . $params);
1844 $processedFile = $file->process(
'Image.CropScaleMask', $conf);
1845 $JSwindowExpand = isset($conf[
'JSwindow.'][
'expand.']) ? $this->
stdWrap($conf[
'JSwindow.'][
'expand'], $conf[
'JSwindow.'][
'expand.']) : $conf[
'JSwindow.'][
'expand'];
1847 $newWindow = isset($conf[
'JSwindow.'][
'newWindow.']) ? $this->
stdWrap($conf[
'JSwindow.'][
'newWindow'], $conf[
'JSwindow.'][
'newWindow.']) : $conf[
'JSwindow.'][
'newWindow'];
1848 $onClick =
'openPic('
1850 .
'\'' . ($newWindow ? md5(
$url) :
'thePicture') .
'\',
'
1851 . GeneralUtility::quoteJSvalue('width=
' . ($processedFile->getProperty('width
') + $offset[0])
1852 . ',height=
' . ($processedFile->getProperty('height
') + $offset[1]) . ',status=0,menubar=0
')
1853 . ');
return false;
';
1854 $a1 = '<a href=
"' . htmlspecialchars($url) . '" onclick=
"' . htmlspecialchars($onClick) . '"' . $target . $this->getTypoScriptFrontendController()->ATagParams . '>
';
1856 $this->getTypoScriptFrontendController()->setJS('openPic
');
1858 $conf['linkParams.
']['parameter
'] = $url;
1859 $string = $this->typoLink($string, $conf['linkParams.
']);
1861 if (isset($conf['stdWrap.
'])) {
1862 $string = $this->stdWrap($string, $conf['stdWrap.
']);
1864 $content = $a1 . $string . $a2;
1877 public function fileResource($fName, $addParams = 'alt=
"" title=
""')
1879 $tsfe = $this->getTypoScriptFrontendController();
1880 $incFile = $tsfe->tmpl->getFileName($fName);
1881 if ($incFile && file_exists($incFile)) {
1882 $fileinfo = GeneralUtility::split_fileref($incFile);
1883 if (GeneralUtility::inList('jpg,gif,jpeg,png
', $fileinfo['fileext
'])) {
1884 $imgFile = $incFile;
1885 $imgInfo = @getImageSize($imgFile);
1886 return '<img src=
"' . $tsfe->absRefPrefix . $imgFile . '" width=
"' . $imgInfo[0] . '" height=
"' . $imgInfo[1] . '"' . $this->getBorderAttr(' border=
"0"') . ' ' . $addParams . ' />
';
1887 } elseif (filesize($incFile) < 1024 * 1024) {
1888 return $tsfe->tmpl->fileContent($incFile);
1903 public function lastChanged($tstamp)
1905 $tstamp = (int)$tstamp;
1906 $tsfe = $this->getTypoScriptFrontendController();
1907 if ($tstamp > (int)$tsfe->register['SYS_LASTCHANGED
']) {
1908 $tsfe->register['SYS_LASTCHANGED
'] = $tstamp;
1921 public function linkWrap($content, $wrap)
1923 $wrapArr = explode('|
', $wrap);
1924 if (preg_match('/\\{([0-9]*)\\}/
', $wrapArr[0], $reg)) {
1925 if ($uid = $this->getTypoScriptFrontendController()->tmpl->rootLine[$reg[1]]['uid
']) {
1926 $wrapArr[0] = str_replace($reg[0], $uid, $wrapArr[0]);
1929 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1941 public function getAltParam($conf, $longDesc = true)
1943 $altText = isset($conf['altText.
']) ? trim($this->stdWrap($conf['altText
'], $conf['altText.
'])) : trim($conf['altText
']);
1944 $titleText = isset($conf['titleText.
']) ? trim($this->stdWrap($conf['titleText
'], $conf['titleText.
'])) : trim($conf['titleText
']);
1945 if (isset($conf['longdescURL.
']) && $this->getTypoScriptFrontendController()->config['config
']['doctype
'] != 'html5
') {
1946 $longDescUrl = $this->typoLink_URL($conf['longdescURL.
']);
1948 $longDescUrl = trim($conf['longdescURL
']);
1950 $longDescUrl = strip_tags($longDescUrl);
1953 $altParam = ' alt=
"' . htmlspecialchars($altText) . '"';
1955 $emptyTitleHandling = isset($conf['emptyTitleHandling.
']) ? $this->stdWrap($conf['emptyTitleHandling
'], $conf['emptyTitleHandling.
']) : $conf['emptyTitleHandling
'];
1956 // Choices: 'keepEmpty
' | 'useAlt
' | 'removeAttr
'
1957 if ($titleText || $emptyTitleHandling == 'keepEmpty
') {
1958 $altParam .= ' title=
"' . htmlspecialchars($titleText) . '"';
1959 } elseif (!$titleText && $emptyTitleHandling == 'useAlt
') {
1960 $altParam .= ' title=
"' . htmlspecialchars($altText) . '"';
1963 if ($longDesc && !empty($longDescUrl)) {
1964 $altParam .= ' longdesc=
"' . htmlspecialchars($longDescUrl) . '"';
1977 public function cleanFormName($name)
1979 GeneralUtility::logDeprecatedFunction();
1980 // Turn data[x][y] into data:x:y:
1981 $name = preg_replace('/\\[|\\]\\[?/
', ':
', trim($name));
1982 // Remove illegal chars like _
1983 return preg_replace('#[^:a-zA-Z0-9]#
', '', $name);
1995 public function getATagParams($conf, $addGlobal = 1)
1998 if ($conf['ATagParams.
']) {
1999 $aTagParams = ' ' . $this->stdWrap($conf['ATagParams
'], $conf['ATagParams.
']);
2000 } elseif ($conf['ATagParams
']) {
2001 $aTagParams = ' ' . $conf['ATagParams
'];
2004 $aTagParams = ' ' . trim($this->getTypoScriptFrontendController()->ATagParams . $aTagParams);
2007 if (isset($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['tslib/
class.tslib_content.php
']['getATagParamsPostProc
']) && is_array($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['tslib/
class.tslib_content.php
']['getATagParamsPostProc
'])) {
2010 'aTagParams
' => &$aTagParams
2012 foreach ($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['tslib/
class.tslib_content.php
']['getATagParamsPostProc
'] as $objRef) {
2013 $processor =& GeneralUtility::getUserObj($objRef);
2014 $aTagParams = $processor->process($_params, $this);
2018 $aTagParams = trim($aTagParams);
2019 if (!empty($aTagParams)) {
2020 $aTagParams = ' ' . $aTagParams;
2034 public function extLinkATagParams($URL, $TYPE)
2037 if ($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['tslib/
class.tslib_content.php
']['extLinkATagParamsHandler
']) {
2038 $extLinkATagParamsHandler = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['tslib/
class.tslib_content.php
']['extLinkATagParamsHandler
']);
2039 if (method_exists($extLinkATagParamsHandler, 'main
')) {
2040 $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this));
2043 return trim($out) ? ' ' . trim($out) : '';
2046 /***********************************************
2048 * HTML template processing functions
2050 ***********************************************/
2069 public function getSubpart($content, $marker)
2071 return $this->templateService->getSubpart($content, $marker);
2086 public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1)
2088 return $this->templateService->substituteSubpart($content, $marker, $subpartContent, $recursive);
2098 public function substituteSubpartArray($content, array $subpartsContent)
2100 return $this->templateService->substituteSubpartArray($content, $subpartsContent);
2113 public function substituteMarker($content, $marker, $markContent)
2115 return $this->templateService->substituteMarker($content, $marker, $markContent);
2150 public function substituteMarkerArrayCached($content, array $markContentArray = null, array $subpartContentArray = null, array $wrappedSubpartContentArray = null)
2152 $timeTracker = $this->getTimeTracker();
2154 // If not arrays then set them
2155 if (is_null($markContentArray)) {
2157 $markContentArray = array();
2159 if (is_null($subpartContentArray)) {
2160 // Subparts being directly substituted
2161 $subpartContentArray = array();
2163 if (is_null($wrappedSubpartContentArray)) {
2164 // Subparts being wrapped
2165 $wrappedSubpartContentArray = array();
2167 // Finding keys and check hash:
2168 $sPkeys = array_keys($subpartContentArray);
2169 $wPkeys = array_keys($wrappedSubpartContentArray);
2170 $aKeys = array_merge(array_keys($markContentArray), $sPkeys, $wPkeys);
2171 if (empty($aKeys)) {
2172 $timeTracker->pull();
2176 $storeKey = md5('substituteMarkerArrayCached_storeKey:
' . serialize(array(
2180 if ($this->substMarkerCache[$storeKey]) {
2181 $storeArr = $this->substMarkerCache[$storeKey];
2182 $timeTracker->setTSlogMessage('Cached
', 0);
2184 $storeArrDat = $this->getTypoScriptFrontendController()->sys_page->getHash($storeKey);
2185 if (is_array($storeArrDat)) {
2186 $storeArr = $storeArrDat;
2188 $this->substMarkerCache[$storeKey] = $storeArr;
2189 $timeTracker->setTSlogMessage('Cached from DB
', 0);
2191 // Initialize storeArr
2192 $storeArr = array();
2193 // Finding subparts and substituting them with the subpart as a marker
2194 foreach ($sPkeys as $sPK) {
2195 $content = $this->substituteSubpart($content, $sPK, $sPK);
2197 // Finding subparts and wrapping them with markers
2198 foreach ($wPkeys as $wPK) {
2199 $content = $this->substituteSubpart($content, $wPK, array(
2204 // Traverse keys and quote them for reg ex.
2205 foreach ($aKeys as $tK => $tV) {
2206 $aKeys[$tK] = preg_quote($tV, '/
');
2208 $regex = '/
' . implode('|
', $aKeys) . '/
';
2210 $storeArr[
'c'] = preg_split($regex, $content);
2211 preg_match_all($regex, $content, $keyList);
2212 $storeArr[
'k'] = $keyList[0];
2214 $this->substMarkerCache[$storeKey] = $storeArr;
2217 $timeTracker->setTSlogMessage(
'Parsing', 0);
2222 $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
2223 $wSCA_reg = array();
2226 foreach ($storeArr[
'k'] as $n => $keyN) {
2227 $content .= $storeArr[
'c'][$n];
2228 if (!is_array($valueArr[$keyN])) {
2229 $content .= $valueArr[$keyN];
2231 $content .= $valueArr[$keyN][(int)$wSCA_reg[$keyN] % 2];
2235 $content .= $storeArr[
'c'][count($storeArr[
'k'])];
2236 $timeTracker->pull();
2259 public function substituteMarkerArray($content, array $markContentArray, $wrap =
'', $uppercase =
false, $deleteUnused =
false)
2261 return $this->templateService->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
2274 if (is_array($tree)) {
2275 foreach ($tree as $key => $value) {
2296 return $this->templateService->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
2311 public function fillInMarkerArray(array $markContentArray, array $row, $fieldList =
'', $nl2br =
true, $prefix =
'FIELD_', $HSC =
false)
2316 foreach ($fArr as $field) {
2317 $markContentArray[
'###' . $prefix . $field .
'###'] = $nl2br ? nl2br($row[$field], !empty($tsfe->xhtmlDoctype)) : $row[$field];
2320 if (is_array($row)) {
2321 foreach ($row as $field => $value) {
2324 $value = htmlspecialchars($value);
2326 $markContentArray[
'###' . $prefix . $field .
'###'] = $nl2br ? nl2br($value, !empty($tsfe->xhtmlDoctype)) : $value;
2331 return $markContentArray;
2341 $this->currentFile = $fileObject;
2370 public function stdWrap($content =
'', $conf = array())
2374 if ($this->stdWrapHookObjects) {
2375 $conf[
'stdWrapPreProcess'] = 1;
2376 $conf[
'stdWrapOverride'] = 1;
2377 $conf[
'stdWrapProcess'] = 1;
2378 $conf[
'stdWrapPostProcess'] = 1;
2381 if (!is_array($conf) || !$conf) {
2386 if (is_array($conf[
'cache.'])) {
2387 $conf[
'cache.'][
'key'] = $this->
stdWrap($conf[
'cache.'][
'key'], $conf[
'cache.'][
'key.']);
2388 $conf[
'cache.'][
'tags'] = $this->
stdWrap($conf[
'cache.'][
'tags'], $conf[
'cache.'][
'tags.']);
2389 $conf[
'cache.'][
'lifetime'] = $this->
stdWrap($conf[
'cache.'][
'lifetime'], $conf[
'cache.'][
'lifetime.']);
2390 $conf[
'cacheRead'] = 1;
2391 $conf[
'cacheStore'] = 1;
2395 $sortedConf = array_intersect_key($this->stdWrapOrder, $conf);
2397 $stdWrapDisabledFunctionTypes =
'cObject,functionName,stdWrap';
2399 $isExecuted = array();
2402 $this->stdWrapRecursionLevel++;
2405 foreach ($sortedConf as $stdWrapName => $functionType) {
2407 if (!$isExecuted[$stdWrapName] && !$this->stopRendering[$this->stdWrapRecursionLevel]) {
2408 $functionName = rtrim($stdWrapName,
'.');
2409 $functionProperties = $functionName .
'.';
2414 if ($functionName !==
'stdWrap' && !empty($conf[$functionProperties]) && !
GeneralUtility::inList($stdWrapDisabledFunctionTypes, $functionType)) {
2415 if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
2416 $conf[$functionName] = $this->
stdWrap($conf[$functionName], $conf[$functionProperties]);
2420 if ((isset($conf[$functionName]) || $conf[$functionProperties]) && ($functionType !==
'boolean' || $conf[$functionName])) {
2422 $singleConf = array(
2423 $functionName => $conf[$functionName],
2424 $functionProperties => $conf[$functionProperties]
2427 if ($functionName ===
'spaceBefore' || $functionName ===
'spaceAfter') {
2428 $singleConf[
'space.'] = $conf[
'space.'];
2431 if ($functionType ===
'hook') {
2432 $singleConf = $conf;
2435 $isExecuted[$functionName] =
true;
2436 $isExecuted[$functionProperties] =
true;
2438 $functionName =
'stdWrap_' . $functionName;
2439 $content = $this->{$functionName}($content, $singleConf);
2440 }
elseif ($functionType ==
'boolean' && !$conf[$functionName]) {
2441 $isExecuted[$functionName] =
true;
2442 $isExecuted[$functionProperties] =
true;
2446 unset($this->stopRendering[$this->stdWrapRecursionLevel]);
2447 $this->stdWrapRecursionLevel--;
2462 if (isset($config[$key])) {
2463 if (!isset($config[$key .
'.'])) {
2464 return $config[$key];
2466 }
elseif (isset($config[$key .
'.'])) {
2469 return $defaultValue;
2471 $stdWrapped = $this->
stdWrap($config[$key], $config[$key .
'.']);
2472 return $stdWrapped ?: $defaultValue;
2484 public function stdWrap_stdWrapPreProcess($content =
'', $conf = array())
2486 foreach ($this->stdWrapHookObjects as $hookObject) {
2488 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
2502 if (!isset($conf[
'cache.'])) {
2505 $result = $this->getFromCache($conf[
'cache.']);
2506 return $result ===
false ? $content : $result;
2518 $tags = isset($conf[
'addPageCacheTags.'])
2519 ? $this->
stdWrap($conf[
'addPageCacheTags'], $conf[
'addPageCacheTags.'])
2520 : $conf[
'addPageCacheTags'];
2521 if (!empty($tags)) {
2566 if (isset($conf[
'lang.']) && $tsfe->config[
'config'][
'language'] && isset($conf[
'lang.'][$tsfe->config[
'config'][
'language']])) {
2567 $content = $conf[
'lang.'][$tsfe->config[
'config'][
'language']];
2582 $content = $this->
getData($conf[
'data'], is_array($this->alternativeData) ? $this->alternativeData : $this->data);
2584 $this->alternativeData =
'';
2626 return $this->cObjGetSingle($conf[
'cObject'], $conf[
'cObject.'],
'/stdWrap/.cObject');
2640 return $this->
numRows($conf[
'numRows.']);
2653 return $this->
filelist($conf[
'filelist']);
2666 return $this->
callUserFunction($conf[
'preUserFunc'], $conf[
'preUserFunc.'], $content);
2678 public function stdWrap_stdWrapOverride($content =
'', $conf = array())
2680 foreach ($this->stdWrapHookObjects as $hookObject) {
2682 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2697 if (trim($conf[
'override'])) {
2698 $content = $conf[
'override'];
2714 return $this->
listNum($content, $conf[
'preIfEmptyListNum'], $conf[
'preIfEmptyListNum.'][
'splitChar']);
2727 return $content !== null ? $content : $conf[
'ifNull'];
2741 if (!trim($content)) {
2742 $content = $conf[
'ifEmpty'];
2758 if (trim($content) ===
'') {
2759 $content = $conf[
'ifBlank'];
2776 return $this->
listNum($content, $conf[
'listNum'], $conf[
'listNum.'][
'splitChar']);
2788 return trim($content);
2806 $padType = STR_PAD_RIGHT;
2807 if (!empty($conf[
'strPad.'][
'length'])) {
2808 $length = isset($conf[
'strPad.'][
'length.']) ? $this->
stdWrap($conf[
'strPad.'][
'length'], $conf[
'strPad.'][
'length.']) : $conf[
'strPad.'][
'length'];
2809 $length = (int)$length;
2811 if (isset($conf[
'strPad.'][
'padWith']) && (string)$conf[
'strPad.'][
'padWith'] !==
'') {
2812 $padWith = isset($conf[
'strPad.'][
'padWith.']) ? $this->
stdWrap($conf[
'strPad.'][
'padWith'], $conf[
'strPad.'][
'padWith.']) : $conf[
'strPad.'][
'padWith'];
2814 if (!empty($conf[
'strPad.'][
'type'])) {
2815 $type = isset($conf[
'strPad.'][
'type.']) ? $this->
stdWrap($conf[
'strPad.'][
'type'], $conf[
'strPad.'][
'type.']) : $conf[
'strPad.'][
'type'];
2816 if (strtolower($type) ===
'left') {
2817 $padType = STR_PAD_LEFT;
2818 }
elseif (strtolower($type) ===
'both') {
2819 $padType = STR_PAD_BOTH;
2822 return str_pad($content, $length, $padWith, $padType);
2838 return $this->
stdWrap($content, $conf[
'stdWrap.']);
2850 public function stdWrap_stdWrapProcess($content =
'', $conf = array())
2852 foreach ($this->stdWrapHookObjects as $hookObject) {
2854 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2869 if ((
string)$content ===
'') {
2887 if (empty($conf[
'if.']) || $this->
checkIf($conf[
'if.'])) {
2905 if (!trim($this->data[$conf[
'fieldRequired']])) {
2936 return $this->
parseFunc($content, $conf[
'parseFunc.'], $conf[
'parseFunc']);
2950 if (is_array($conf[
'HTMLparser.'])) {
2967 return $this->
splitObj($content, $conf[
'split.']);
2980 return $this->
replacement($content, $conf[
'replacement.']);
2995 if ($conf[
'prioriCalc'] ==
'intval') {
2996 $content = (int)$content;
3011 return chr((
int)$conf[
'char']);
3023 return (
int)$content;
3036 $algorithm = isset($conf[
'hash.']) ? $this->
stdWrap($conf[
'hash'], $conf[
'hash.']) : $conf[
'hash'];
3037 if (function_exists(
'hash') && in_array($algorithm, hash_algos())) {
3038 return hash($algorithm, $content);
3054 return $this->
round($content, $conf[
'round.']);
3067 return $this->
numberFormat($content, $conf[
'numberFormat.']);
3094 $content = $content ==
'' ?
$GLOBALS[
'EXEC_TIME'] : (int)$content;
3095 $content = $conf[
'date.'][
'GMT'] ? gmdate($conf[
'date'], $content) : date($conf[
'date'], $content);
3111 $content = $content ==
'' ?
$GLOBALS[
'EXEC_TIME'] : (int)$content;
3112 $content = $conf[
'strftime.'][
'GMT'] ? gmstrftime($conf[
'strftime'], $content) : strftime($conf[
'strftime'], $content);
3114 $tmp_charset = $conf[
'strftime.'][
'charset'] ? $conf[
'strftime.'][
'charset'] : $tsfe->localeCharset;
3116 $content = $tsfe->csConv($content, $tmp_charset);
3131 if ($conf[
'strtotime'] !==
'1') {
3132 $content .=
' ' . $conf[
'strtotime'];
3134 return strtotime($content,
$GLOBALS[
'EXEC_TIME']);
3147 return $this->
calcAge(
$GLOBALS[
'EXEC_TIME'] - $content, $conf[
'age']);
3187 return $this->
substring($content, $conf[
'substring']);
3213 return $this->
cropHTML($content, $conf[
'cropHTML']);
3225 return strip_tags($content);
3238 return $this->
crop($content, $conf[
'crop']);
3250 return rawurlencode($content);
3264 if (!empty($conf[
'htmlSpecialChars.'][
'preserveEntities'])) {
3265 $content = htmlspecialchars($content, ENT_COMPAT,
'UTF-8',
false);
3267 $content = htmlspecialchars($content);
3295 return preg_replace(
'/
3299 /', $conf[
'doubleBrTag'], $content);
3326 return str_replace(LF, $conf[
'brTag'], $content);
3366 return $this->
wrap($content, $conf[
'innerWrap']);
3380 return $this->
wrap($content, $conf[
'innerWrap2']);
3395 return $this->
wrap($content, $conf[
'fontTag']);
3408 return $this->
addParams($content, $conf[
'addParams.']);
3422 return $this->
textStyle($content, $conf[
'textStyle.']);
3436 return $this->
tableStyle($content, $conf[
'tableStyle.']);
3450 return $this->filelink($content, $conf[
'filelink.']);
3463 return $this->cObjGetSingle($conf[
'preCObject'], $conf[
'preCObject.'],
'/stdWrap/.preCObject') . $content;
3476 return $content . $this->cObjGetSingle($conf[
'postCObject'], $conf[
'postCObject.'],
'/stdWrap/.postCObject');
3490 $wrapAlign = trim($conf[
'wrapAlign']);
3492 $content = $this->
wrap($content,
'<div style="text-align:' . $wrapAlign .
';">|</div>');
3509 return $this->typoLink($content, $conf[
'typolink.']);
3522 if (is_array($conf[
'TCAselectItem.'])) {
3523 $content = $this->
TCAlookup($content, $conf[
'TCAselectItem.']);
3539 return $this->
wrapSpace($content, trim($conf[
'spaceBefore']) .
'|', $conf[
'space.']);
3553 return $this->
wrapSpace($content,
'|' . trim($conf[
'spaceAfter']), $conf[
'space.']);
3568 return $this->
wrapSpace($content, trim($conf[
'space']), $conf[
'space.']);
3585 return $this->
wrap($content, $conf[
'wrap'], $conf[
'wrap.'][
'splitChar'] ? $conf[
'wrap.'][
'splitChar'] :
'|');
3599 $splitChar = isset($conf[
'noTrimWrap.'][
'splitChar.'])
3600 ? $this->
stdWrap($conf[
'noTrimWrap.'][
'splitChar'], $conf[
'noTrimWrap.'][
'splitChar.'])
3601 : $conf[
'noTrimWrap.'][
'splitChar'];
3602 if ($splitChar === null || $splitChar ===
'') {
3607 $conf[
'noTrimWrap'],
3624 return $this->
wrap($content, $conf[
'wrap2'], $conf[
'wrap2.'][
'splitChar'] ? $conf[
'wrap2.'][
'splitChar'] :
'|');
3638 return $this->
dataWrap($content, $conf[
'dataWrap']);
3651 return $this->cObjGetSingle($conf[
'prepend'], $conf[
'prepend.'],
'/stdWrap/.prepend') . $content;
3664 return $content . $this->cObjGetSingle($conf[
'append'], $conf[
'append.'],
'/stdWrap/.append');
3678 return $this->
wrap($content, $conf[
'wrap3'], $conf[
'wrap3.'][
'splitChar'] ? $conf[
'wrap3.'][
'splitChar'] :
'|');
3692 foreach ($sortedKeysArray as $key) {
3693 $content = $this->
stdWrap($content, $conf[
'orderedStdWrap.'][$key .
'.']);
3708 return $this->
wrap($content, $conf[
'outerWrap']);
3735 if ($conf[
'offsetWrap.'][
'tableParams'] || $conf[
'offsetWrap.'][
'tableParams.']) {
3736 $controlTable->tableParams = isset($conf[
'offsetWrap.'][
'tableParams.'])
3737 ? $this->
stdWrap($conf[
'offsetWrap.'][
'tableParams'], $conf[
'offsetWrap.'][
'tableParams.'])
3738 : $conf[
'offsetWrap.'][
'tableParams'];
3740 if ($conf[
'offsetWrap.'][
'tdParams'] || $conf[
'offsetWrap.'][
'tdParams.']) {
3741 $controlTable->tdParams =
' ' . (isset($conf[
'offsetWrap.'][
'tdParams.'])
3742 ? $this->
stdWrap($conf[
'offsetWrap.'][
'tdParams'], $conf[
'offsetWrap.'][
'tdParams.'])
3743 : $conf[
'offsetWrap.'][
'tdParams']);
3745 $content = $controlTable->start($content, $conf[
'offsetWrap']);
3746 if ($conf[
'offsetWrap.'][
'stdWrap.']) {
3747 $content = $this->
stdWrap($content, $conf[
'offsetWrap.'][
'stdWrap.']);
3762 return $this->
callUserFunction($conf[
'postUserFunc'], $conf[
'postUserFunc.'], $content);
3778 'content' => $content,
3779 'postUserFunc' => $conf[
'postUserFuncInt'],
3780 'conf' => $conf[
'postUserFuncInt.'],
3781 'type' =>
'POSTUSERFUNC',
3782 'cObj' => serialize($this)
3784 $content =
'<!--' . $substKey .
'-->';
3799 $content = $this->
prefixComment($conf[
'prefixComment'], array(), $content);
3815 if (!is_array($conf[
'editIcons.'])) {
3816 $conf[
'editIcons.'] = array();
3818 $content = $this->
editIcons($content, $conf[
'editIcons'], $conf[
'editIcons.']);
3834 $content = $this->
editPanel($content, $conf[
'editPanel.']);
3846 public function stdWrap_cacheStore($content =
'', $conf = array())
3848 if (!isset($conf[
'cache.'])) {
3859 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'stdWrap_cacheStore'])) {
3860 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'stdWrap_cacheStore'] as $_funcRef) {
3863 'content' => $content,
3864 'lifetime' => $lifetime,
3870 $cacheFrontend->set($key, $content, $tags, $lifetime);
3883 public function stdWrap_stdWrapPostProcess($content =
'', $conf = array())
3885 foreach ($this->stdWrapHookObjects as $hookObject) {
3887 $content = $hookObject->stdWrapPostProcess($content, $conf, $this);
3901 return '<pre>' . htmlspecialchars($content) .
'</pre>';
3914 debug($conf[
'debugFunc'] == 2 ? array($content) : $content);
3927 debug($this->data,
'$cObj->data:');
3928 if (is_array($this->alternativeData)) {
3929 debug($this->alternativeData,
'$this->alternativeData');
3946 $conf[
'select.'][
'selectFields'] =
'count(*)';
3947 $res = $this->
exec_getQuery($conf[
'table'], $conf[
'select.']);
3949 if ($error = $db->sql_error()) {
3952 $row = $db->sql_fetch_row($res);
3953 $result = (int)$row[0];
3955 $db->sql_free_result($res);
3967 public function listNum($content, $listNum, $char)
3969 $char = $char ?:
',';
3973 $temp = explode($char, $content);
3974 $last =
'' . (count($temp) - 1);
3976 if ($listNum ===
'rand') {
3977 $listNum = rand(0, count($temp) - 1);
3979 $index = $this->
calc(str_ireplace(
'last', $last, $listNum));
3980 return $temp[$index];
3993 if (!is_array($conf)) {
3996 if (isset($conf[
'directReturn'])) {
3997 return (
bool)$conf[
'directReturn'];
4000 if (isset($conf[
'isNull.'])) {
4001 $isNull = $this->
stdWrap(
'', $conf[
'isNull.']);
4002 if ($isNull !== null) {
4006 if (isset($conf[
'isTrue']) || isset($conf[
'isTrue.'])) {
4007 $isTrue = isset($conf[
'isTrue.']) ? trim($this->
stdWrap($conf[
'isTrue'], $conf[
'isTrue.'])) : trim($conf[
'isTrue']);
4012 if (isset($conf[
'isFalse']) || isset($conf[
'isFalse.'])) {
4013 $isFalse = isset($conf[
'isFalse.']) ? trim($this->
stdWrap($conf[
'isFalse'], $conf[
'isFalse.'])) : trim($conf[
'isFalse']);
4018 if (isset($conf[
'isPositive']) || isset($conf[
'isPositive.'])) {
4019 $number = isset($conf[
'isPositive.']) ? $this->
calc($this->
stdWrap($conf[
'isPositive'], $conf[
'isPositive.'])) : $this->
calc($conf[
'isPositive']);
4025 $value = isset($conf[
'value.']) ? trim($this->
stdWrap($conf[
'value'], $conf[
'value.'])) : trim($conf[
'value']);
4026 if (isset($conf[
'isGreaterThan']) || isset($conf[
'isGreaterThan.'])) {
4027 $number = isset($conf[
'isGreaterThan.']) ? trim($this->
stdWrap($conf[
'isGreaterThan'], $conf[
'isGreaterThan.'])) : trim($conf[
'isGreaterThan']);
4028 if ($number <= $value) {
4032 if (isset($conf[
'isLessThan']) || isset($conf[
'isLessThan.'])) {
4033 $number = isset($conf[
'isLessThan.']) ? trim($this->
stdWrap($conf[
'isLessThan'], $conf[
'isLessThan.'])) : trim($conf[
'isLessThan']);
4034 if ($number >= $value) {
4038 if (isset($conf[
'equals']) || isset($conf[
'equals.'])) {
4039 $number = isset($conf[
'equals.']) ? trim($this->
stdWrap($conf[
'equals'], $conf[
'equals.'])) : trim($conf[
'equals']);
4040 if ($number != $value) {
4044 if (isset($conf[
'isInList']) || isset($conf[
'isInList.'])) {
4045 $number = isset($conf[
'isInList.']) ? trim($this->
stdWrap($conf[
'isInList'], $conf[
'isInList.'])) : trim($conf[
'isInList']);
4051 if ($conf[
'negate']) {
4072 $data_arr = explode(
'|',
$data);
4087 'sorting' => array()
4090 $sorting = trim($data_arr[2]);
4093 if (is_object($d)) {
4095 while ($entry = $d->read()) {
4096 if ($entry !=
'.' && $entry !=
'..') {
4098 $wholePath = $path .
'/' . $entry;
4099 if (file_exists($wholePath) && filetype($wholePath) ==
'file') {
4102 $items[
'files'][] = $info[
'file'];
4105 $items[
'sorting'][] = strtolower($info[
'file']);
4108 $items[
'sorting'][] = filesize($wholePath);
4111 $items[
'sorting'][] = $info[
'fileext'];
4114 $items[
'sorting'][] = filectime($wholePath);
4117 $items[
'sorting'][] = filemtime($wholePath);
4120 $items[
'sorting'][] = $count;
4130 if (!empty($items[
'sorting'])) {
4131 if (strtolower(trim($data_arr[3])) !=
'r') {
4132 asort($items[
'sorting']);
4134 arsort($items[
'sorting']);
4137 if (!empty($items[
'files'])) {
4139 reset($items[
'sorting']);
4140 $fullPath = trim($data_arr[4]);
4141 $list_arr = array();
4142 foreach ($items[
'sorting'] as $key => $v) {
4143 $list_arr[] = $fullPath ? $path .
'/' . $items[
'files'][$key] : $items[
'files'][$key];
4145 return implode(
',', $list_arr);
4163 $theDir = preg_replace(
'/[\\/\\. ]*$/',
'', $theDir);
4184 $htmlParserCfg = $htmlParser->HTMLparserConfig($conf);
4185 return $htmlParser->HTMLcleaner($theValue, $htmlParserCfg[0], $htmlParserCfg[1], $htmlParserCfg[2], $htmlParserCfg[3]);
4214 $totalLen = strlen($str);
4217 $len = strcspn(substr($str, $pointer),
'{');
4218 $newVal .= substr($str, $pointer, $len);
4221 $len = strcspn(substr($str, $pointer),
'}') + 1;
4222 $newVal .= $this->
getData(substr($str, $pointer + 1, $len - 2), $this->data);
4226 }
while ($pointer < $totalLen);
4245 $parts = explode(
'|', $str);
4246 $indent = (int)$parts[0];
4247 $comment = htmlspecialchars($this->
insertData($parts[1]));
4249 . str_pad(
'', $indent, TAB) .
'<!-- ' . $comment .
' [begin] -->' . LF
4250 . str_pad(
'', ($indent + 1), TAB) . $content . LF
4251 . str_pad(
'', $indent, TAB) .
'<!-- ' . $comment .
' [end] -->' . LF
4252 . str_pad(
'', ($indent + 1), TAB);
4270 return $tsfe->csConvObj->substr($tsfe->renderCharset, $content, $options[0], $options[1]);
4272 return $tsfe->csConvObj->substr($tsfe->renderCharset, $content, $options[0]);
4285 public function crop($content, $options)
4287 $options = explode(
'|', $options);
4288 $chars = (int)$options[0];
4289 $afterstring = trim($options[1]);
4290 $crop2space = trim($options[2]);
4293 if ($tsfe->csConvObj->strlen($tsfe->renderCharset, $content) > abs($chars)) {
4294 $truncatePosition =
false;
4296 $content = $tsfe->csConvObj->substr($tsfe->renderCharset, $content, $chars);
4298 $truncatePosition = strpos($content,
' ');
4300 $content = $truncatePosition ? $afterstring . substr($content, $truncatePosition) : $afterstring . $content;
4302 $content = $tsfe->csConvObj->substr($tsfe->renderCharset, $content, 0, $chars);
4304 $truncatePosition = strrpos($content,
' ');
4306 $content = $truncatePosition ? substr($content, 0, $truncatePosition) . $afterstring : $content . $afterstring;
4328 $options = explode(
'|', $options);
4329 $chars = (int)$options[0];
4330 $absChars = abs($chars);
4331 $replacementForEllipsis = trim($options[1]);
4332 $crop2space = trim($options[2]) ===
'1';
4334 $tags =
'a|abbr|address|area|article|aside|audio|b|bdi|bdo|blockquote|body|br|button|caption|cite|code|col|colgroup|data|datalist|dd|del|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|h1|h2|h3|h4|h5|h6|header|hr|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|main|map|mark|meter|nav|object|ol|optgroup|option|output|p|param|pre|progress|q|rb|rp|rt|rtc|ruby|s|samp|section|select|small|source|span|strong|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|tr|track|u|ul|ut|var|video|wbr';
4338 <!--.*?--> # a comment
4340 <canvas[^>]*>.*?</canvas> # a canvas tag
4342 <script[^>]*>.*?</script> # a script tag
4344 <noscript[^>]*>.*?</noscript> # a noscript tag
4346 <template[^>]*>.*?</template> # a template tag
4349 </?(?:' . $tags .
')+ # opening tag (\'<tag\') or closing tag (\'</tag\')
4353 \\s+\\w[\\w-]* # EITHER spaces, followed by attribute names
4357 ".*?" # attribute values in double-quotes
4359 \'.*?\' # attribute values in single-quotes
4361 [^\'">\\s]+ # plain attribute values
4365 | # OR a single dash (for TYPO3 link tag)
4373 /?> # closing the tag with \'>\' or \'/>\'
4375 $splittedContent = preg_split(
'%' . $tagsRegEx .
'%xs', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
4378 $splittedContent = array_reverse($splittedContent);
4383 $croppedOffset = null;
4385 $countSplittedContent = count($splittedContent);
4386 for ($offset = 0; $offset < $countSplittedContent; $offset++) {
4387 if ($offset % 2 === 0) {
4388 $tempContent = $tsfe->csConvObj->utf8_encode($splittedContent[$offset], $tsfe->renderCharset);
4389 $thisStrLen = $tsfe->csConvObj->strlen(
'utf-8', html_entity_decode($tempContent, ENT_COMPAT,
'UTF-8'));
4390 if ($strLen + $thisStrLen > $absChars) {
4391 $croppedOffset = $offset;
4392 $cropPosition = $absChars - $strLen;
4394 $patternMatchEntityAsSingleChar =
'(&[^&\\s;]{2,8};|.)';
4395 $cropRegEx = $chars < 0 ?
'#' . $patternMatchEntityAsSingleChar .
'{0,' . ($cropPosition + 1) .
'}$#uis' :
'#^' . $patternMatchEntityAsSingleChar .
'{0,' . ($cropPosition + 1) .
'}#uis';
4396 if (preg_match($cropRegEx, $tempContent, $croppedMatch)) {
4397 $tempContentPlusOneCharacter = $croppedMatch[0];
4399 $tempContentPlusOneCharacter =
false;
4401 $cropRegEx = $chars < 0 ?
'#' . $patternMatchEntityAsSingleChar .
'{0,' . $cropPosition .
'}$#uis' :
'#^' . $patternMatchEntityAsSingleChar .
'{0,' . $cropPosition .
'}#uis';
4402 if (preg_match($cropRegEx, $tempContent, $croppedMatch)) {
4403 $tempContent = $croppedMatch[0];
4404 if ($crop2space && $tempContentPlusOneCharacter !==
false) {
4405 $cropRegEx = $chars < 0 ?
'#(?<=\\s)' . $patternMatchEntityAsSingleChar .
'{0,' . $cropPosition .
'}$#uis' :
'#^' . $patternMatchEntityAsSingleChar .
'{0,' . $cropPosition .
'}(?=\\s)#uis';
4406 if (preg_match($cropRegEx, $tempContentPlusOneCharacter, $croppedMatch)) {
4407 $tempContent = $croppedMatch[0];
4411 $splittedContent[$offset] = $tsfe->csConvObj->utf8_decode($tempContent, $tsfe->renderCharset);
4414 $strLen += $thisStrLen;
4419 $closingTags = array();
4420 if ($croppedOffset !== null) {
4421 $openingTagRegEx =
'#^<(\\w+)(?:\\s|>)#';
4422 $closingTagRegEx =
'#^</(\\w+)(?:\\s|>)#';
4423 for ($offset = $croppedOffset - 1; $offset >= 0; $offset = $offset - 2) {
4424 if (substr($splittedContent[$offset], -2) ===
'/>') {
4428 preg_match($chars < 0 ? $closingTagRegEx : $openingTagRegEx, $splittedContent[$offset], $matches);
4429 $tagName = isset($matches[1]) ? $matches[1] : null;
4430 if ($tagName !== null) {
4432 $countSplittedContent = count($splittedContent);
4433 for ($seekingOffset = $offset + 2; $seekingOffset < $countSplittedContent; $seekingOffset = $seekingOffset + 2) {
4434 preg_match($chars < 0 ? $openingTagRegEx : $closingTagRegEx, $splittedContent[$seekingOffset], $matches);
4435 $seekingTagName = isset($matches[1]) ? $matches[1] : null;
4436 if ($tagName === $seekingTagName) {
4439 if ($seekingOffset > $croppedOffset) {
4440 $closingTags[] = $splittedContent[$seekingOffset];
4448 array_splice($splittedContent, $croppedOffset + 1);
4450 $splittedContent = array_merge($splittedContent, array(
4451 $croppedOffset !== null ? $replacementForEllipsis :
''
4455 $splittedContent = array_reverse($splittedContent);
4457 return implode(
'', $splittedContent);
4471 $text = preg_replace(array(
4472 '\'<script[^>]*?>.*?</script[^>]*?>\
'si',
4473 '\'<applet[^>]*?>.*?</applet[^>]*?>\
'si',
4474 '\'<
object[^>]*?>.*?</
object[^>]*?>\
'si',
4475 '\'<iframe[^>]*?>.*?</iframe[^>]*?>\
'si',
4476 '\'<frameset[^>]*?>.*?</frameset[^>]*?>\
'si',
4477 '\'<style[^>]*?>.*?</style[^>]*?>\
'si',
4478 '\'<marquee[^>]*?>.*?</marquee[^>]*?>\
'si',
4479 '\'<script[^>]*?>\
'si',
4480 '\'<meta[^>]*?>\
'si',
4481 '\'<base[^>]*?>\
'si',
4482 '\'<applet[^>]*?>\
'si',
4483 '\'<
object[^>]*?>\
'si',
4484 '\'<link[^>]*?>\
'si',
4485 '\'<iframe[^>]*?>\
'si',
4486 '\'<frame[^>]*?>\
'si',
4487 '\'<frameset[^>]*?>\
'si',
4488 '\'<input[^>]*?>\
'si',
4489 '\'<form[^>]*?>\
'si',
4490 '\'<embed[^>]*?>\
'si',
4491 '\'background-image:url\
'si',
4492 '\'<\\w+.*?(onabort|onbeforeunload|onblur|onchange|onclick|ondblclick|ondragdrop|onerror|onfilterchange|onfocus|onhelp|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onmove|onreadystatechange|onreset|onresize|onscroll|onselect|onselectstart|onsubmit|onunload).*?>\
'si'
4494 $text = preg_replace(
'/<a[^>]*href[[:space:]]*=[[:space:]]*["\']?[[:space:]]*javascript[^>]*/i',
'', $text);
4511 $this->
getTypoScriptFrontendController()->logDeprecatedTyposcript(
'textStyle',
'Deprecated since 7.1 and will be removed with CMS 8. Use CSS instead');
4512 $conf[
'face.'][1] =
'Times New Roman';
4513 $conf[
'face.'][2] =
'Verdana,Arial,Helvetica,Sans serif';
4514 $conf[
'face.'][3] =
'Arial,Helvetica,Sans serif';
4515 $conf[
'size.'][1] = 1;
4516 $conf[
'size.'][2] = 2;
4517 $conf[
'size.'][3] = 3;
4518 $conf[
'size.'][4] = 4;
4519 $conf[
'size.'][5] = 5;
4520 $conf[
'size.'][10] =
'+1';
4521 $conf[
'size.'][11] =
'-1';
4522 $conf[
'color.'][240] =
'black';
4523 $conf[
'color.'][241] =
'white';
4524 $conf[
'color.'][242] =
'#333333';
4525 $conf[
'color.'][243] =
'gray';
4526 $conf[
'color.'][244] =
'silver';
4527 $conf[
'color.'][245] =
'red';
4528 $conf[
'color.'][246] =
'navy';
4529 $conf[
'color.'][247] =
'yellow';
4530 $conf[
'color.'][248] =
'green';
4531 $conf[
'color.'][249] =
'olive';
4532 $conf[
'color.'][250] =
'maroon';
4533 $face = $this->data[$conf[
'face.'][
'field']];
4534 $size = $this->data[$conf[
'size.'][
'field']];
4535 $color = $this->data[$conf[
'color.'][
'field']];
4536 $align = $this->data[$conf[
'align.'][
'field']];
4537 $properties = $this->data[$conf[
'properties.'][
'field']];
4539 $properties = isset($conf[
'properties.'][
'default.']) ? $this->
stdWrap($conf[
'properties.'][
'default'], $conf[
'properties.'][
'default.']) : $conf[
'properties.'][
'default'];
4542 if ($properties & 8) {
4545 if ($properties & 1) {
4546 $theValue =
'<strong>' . $theValue .
'</strong>';
4548 if ($properties & 2) {
4549 $theValue =
'<i>' . $theValue .
'</i>';
4551 if ($properties & 4) {
4552 $theValue =
'<u>' . $theValue .
'</u>';
4555 $theFace = $conf[
'face.'][$face];
4557 $theFace = isset($conf[
'face.'][
'default.']) ? $this->
stdWrap($conf[
'face.'][
'default'], $conf[
'face.'][
'default.']) : $conf[
'face.'][
'default'];
4559 $theSize = $conf[
'size.'][$size];
4561 $theSize = isset($conf[
'size.'][
'default.']) ? $this->
stdWrap($conf[
'size.'][
'default'], $conf[
'size.'][
'default.']) : $conf[
'size.'][
'default'];
4563 $theColor = $conf[
'color.'][$color];
4565 $theColor = isset($conf[
'color.'][
'default.']) ? $this->
stdWrap($conf[
'color.'][
'default'], $conf[
'color.'][
'default.']) : $conf[
'color.'][
'default.'];
4567 if ($conf[
'altWrap']) {
4568 $theValue = $this->
wrap($theValue, $conf[
'altWrap']);
4569 }
elseif ($theFace || $theSize || $theColor) {
4570 $fontWrap =
'<font' . ($theFace ?
' face="' . $theFace .
'"' :
'') . ($theSize ?
' size="' . $theSize .
'"' :
'') . ($theColor ?
' color="' . $theColor .
'"' :
'') .
'>|</font>';
4571 $theValue = $this->
wrap($theValue, $fontWrap);
4575 $theValue = $this->
wrap($theValue,
'<div style="text-align:' .
$align .
';">|</div>');
4593 $this->
getTypoScriptFrontendController()->logDeprecatedTyposcript(
'tableStyle',
'Deprecated since 7.1 and will be removed with CMS 8. Use CSS instead');
4594 $conf[
'color.'][240] =
'black';
4595 $conf[
'color.'][241] =
'white';
4596 $conf[
'color.'][242] =
'#333333';
4597 $conf[
'color.'][243] =
'gray';
4598 $conf[
'color.'][244] =
'silver';
4599 $align = isset($conf[
'align.']) ? $this->
stdWrap($conf[
'align'], $conf[
'align.']) : $conf[
'align'];
4600 $border = isset($conf[
'border.']) ? (int)$this->
stdWrap($conf[
'border'], $conf[
'border.']) : (int)$conf[
'border'];
4601 $cellspacing = isset($conf[
'cellspacing.']) ? (int)$this->
stdWrap($conf[
'cellspacing'], $conf[
'cellspacing.']) : (int)$conf[
'cellspacing'];
4602 $cellpadding = isset($conf[
'cellpadding.']) ? (int)$this->
stdWrap($conf[
'cellpadding'], $conf[
'cellpadding.']) : (int)$conf[
'cellpadding'];
4603 $color = $this->data[$conf[
'color.'][
'field']];
4604 $theColor = $conf[
'color.'][$color] ? $conf[
'color.'][$color] : $conf[
'color.'][
'default'];
4606 $tableTagArray = array(
4609 $tableTagArray[] =
'border="' . $border .
'"';
4610 $tableTagArray[] =
'cellspacing="' . $cellspacing .
'"';
4611 $tableTagArray[] =
'cellpadding="' . $cellpadding .
'"';
4613 $tableTagArray[] =
'align="' .
$align .
'"';
4616 $tableTagArray[] =
'bgcolor="' . $theColor .
'"';
4618 if ($conf[
'params']) {
4619 $tableTagArray[] = $conf[
'params'];
4621 $tableWrap = implode(
' ', $tableTagArray) .
'> | </table>';
4622 $theValue = $this->
wrap($theValue, $tableWrap);
4638 $lowerCaseAttributes =
true;
4639 if (!is_array($conf)) {
4643 $parts = explode(
'<', $content);
4644 if ((
int)$conf[
'_offset']) {
4645 $key = (int)$conf[
'_offset'] < 0 ? count($parts) + (int)$conf[
'_offset'] : (
int)$conf[
'_offset'];
4647 $subparts = explode(
'>', $parts[$key]);
4648 if (trim($subparts[0])) {
4651 list($tagName) = explode(
' ', $subparts[0], 2);
4653 foreach ($conf as $pkey => $val) {
4654 if (substr($pkey, -1) !==
'.' && $pkey[0] !==
'_') {
4655 $tmpVal = isset($conf[$pkey .
'.']) ? $this->
stdWrap($conf[$pkey], $conf[$pkey .
'.']) : (string)$val;
4656 if ($lowerCaseAttributes) {
4657 $pkey = strtolower($pkey);
4659 if ($tmpVal !==
'') {
4660 $attribs[$pkey] = $tmpVal;
4666 $parts[$key] = implode(
'>', $subparts);
4667 $content = implode(
'<', $parts);
4682 public function filelink($theValue, $conf)
4684 $conf[
'path'] = isset($conf[
'path.']) ? $this->
stdWrap($conf[
'path'], $conf[
'path.']) : $conf[
'path'];
4685 $theFile = trim($conf[
'path']) . $theValue;
4686 if (!@is_file($theFile)) {
4689 $theFileEnc = str_replace(
'%2F',
'/', rawurlencode($theFile));
4690 $title = $conf[
'title'];
4691 if (isset($conf[
'title.'])) {
4692 $title = $this->
stdWrap($title, $conf[
'title.']);
4694 $target = $conf[
'target'];
4695 if (isset($conf[
'target.'])) {
4696 $target = $this->
stdWrap($target, $conf[
'target.']);
4700 $typoLinkConf = array(
4701 'parameter' => $theFileEnc,
4702 'fileTarget' => $target,
4707 if (isset($conf[
'typolinkConfiguration.'])) {
4708 $additionalTypoLinkConfiguration = $conf[
'typolinkConfiguration.'];
4711 $typoLinkConf = $additionalTypoLinkConfiguration;
4714 if (isset($conf[
'jumpurl']) || isset($conf[
'jumpurl.'])) {
4715 GeneralUtility::deprecationLog(
'The TypoScript jumpurl configuration is deprecated for file links since TYPO3 CMS 7 and will be removed in TYPO3 CMS 8. Pass this configuration in the typolinkConfiguration property instead.');
4716 if (isset($conf[
'jumpurl'])) {
4717 $typoLinkConf[
'jumpurl'] = $conf[
'jumpurl'];
4719 if (isset($conf[
'jumpurl.'])) {
4720 $typoLinkConf[
'jumpurl.'] = $conf[
'jumpurl.'];
4724 $theLinkWrap = $this->typoLink(
'|', $typoLinkConf);
4725 $theSize = filesize($theFile);
4728 if ($conf[
'icon']) {
4729 $conf[
'icon.'][
'path'] = isset($conf[
'icon.'][
'path.']) ? $this->
stdWrap($conf[
'icon.'][
'path'], $conf[
'icon.'][
'path.']) : $conf[
'icon.'][
'path'];
4731 $conf[
'icon.'][
'ext'] = isset($conf[
'icon.'][
'ext.']) ? $this->
stdWrap($conf[
'icon.'][
'ext'], $conf[
'icon.'][
'ext.']) : $conf[
'icon.'][
'ext'];
4732 $iconExt = !empty($conf[
'icon.'][
'ext']) ?
'.' . $conf[
'icon.'][
'ext'] :
'.gif';
4733 $icon = @is_file(($iconP . $fI[
'fileext'] . $iconExt)) ? $iconP . $fI[
'fileext'] . $iconExt : $iconP .
'default' . $iconExt;
4735 $IEList = isset($conf[
'icon_image_ext_list.']) ? $this->
stdWrap($conf[
'icon_image_ext_list'], $conf[
'icon_image_ext_list.']) : $conf[
'icon_image_ext_list'];
4736 $image_ext_list = str_replace(
' ',
'', strtolower($IEList));
4738 if ($conf[
'iconCObject']) {
4739 $icon = $this->cObjGetSingle($conf[
'iconCObject'], $conf[
'iconCObject.'],
'iconCObject');
4741 $notFoundThumb = TYPO3_mainDir .
'sysext/core/Resources/Public/Images/NotFound.gif';
4742 $sizeParts = array(64, 64);
4743 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'thumbnails']) {
4748 if ($fileObject->isMissing()) {
4749 $icon = $notFoundThumb;
4751 $fileExtension = $fileObject->getExtension();
4753 if ($conf[
'icon_thumbSize'] || $conf[
'icon_thumbSize.']) {
4754 $thumbSize = (isset($conf[
'icon_thumbSize.']) ? $this->
stdWrap($conf[
'icon_thumbSize'], $conf[
'icon_thumbSize.']) : $conf[
'icon_thumbSize']);
4755 $sizeParts = explode(
'x', $thumbSize);
4758 'width' => $sizeParts[0],
4759 'height' => $sizeParts[1]
4760 ))->getPublicUrl(
true);
4763 }
catch (ResourceDoesNotExistException $exception) {
4764 $icon = $notFoundThumb;
4767 $icon = $notFoundThumb;
4770 if (parse_url($icon, PHP_URL_HOST) === null) {
4771 $urlPrefix = $tsfe->absRefPrefix;
4773 $icon =
'<img src="' . htmlspecialchars($urlPrefix . $icon) .
'"' .
4774 'width="' . $sizeParts[0] .
'" height="' . $sizeParts[1] .
'" ' .
4778 $conf[
'icon.'][
'widthAttribute'] = isset($conf[
'icon.'][
'widthAttribute.']) ? $this->
stdWrap($conf[
'icon.'][
'widthAttribute'], $conf[
'icon.'][
'widthAttribute.']) : $conf[
'icon.'][
'widthAttribute'];
4779 $iconWidth = !empty($conf[
'icon.'][
'widthAttribute']) ? $conf[
'icon.'][
'widthAttribute'] : 18;
4780 $conf[
'icon.'][
'heightAttribute'] = isset($conf[
'icon.'][
'heightAttribute.']) ? $this->
stdWrap($conf[
'icon.'][
'heightAttribute'], $conf[
'icon.'][
'heightAttribute.']) : $conf[
'icon.'][
'heightAttribute'];
4781 $iconHeight = !empty($conf[
'icon.'][
'heightAttribute']) ? $conf[
'icon.'][
'heightAttribute'] : 16;
4782 $icon =
'<img src="' . htmlspecialchars($tsfe->absRefPrefix . $icon) .
'" width="' . $iconWidth .
'" height="' . $iconHeight .
'"' . $this->
getBorderAttr(
' border="0"') . $this->
getAltParam($conf) .
' />';
4784 if ($conf[
'icon_link'] && !$conf[
'combinedLink']) {
4785 $icon = $this->
wrap($icon, $theLinkWrap);
4787 $icon = isset($conf[
'icon.']) ? $this->
stdWrap($icon, $conf[
'icon.']) : $icon;
4790 if ($conf[
'size']) {
4791 $size = isset($conf[
'size.']) ? $this->
stdWrap($theSize, $conf[
'size.']) : $theSize;
4794 if ($conf[
'removePrependedNumbers']) {
4795 $theValue = preg_replace(
'/_[0-9][0-9](\\.[[:alnum:]]*)$/',
'\\1', $theValue);
4797 if (isset($conf[
'labelStdWrap.'])) {
4798 $theValue = $this->
stdWrap($theValue, $conf[
'labelStdWrap.']);
4801 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
4802 if ($conf[
'combinedLink']) {
4803 $theValue = $icon . $theValue;
4804 if ($conf[
'ATagBeforeWrap']) {
4805 $theValue = $this->
wrap($this->
wrap($theValue, $wrap), $theLinkWrap);
4807 $theValue = $this->
wrap($this->
wrap($theValue, $theLinkWrap), $wrap);
4809 $file = isset($conf[
'file.']) ? $this->
stdWrap($theValue, $conf[
'file.']) : $theValue;
4811 $output = $file . $size;
4813 if ($conf[
'ATagBeforeWrap']) {
4814 $theValue = $this->
wrap($this->
wrap($theValue, $wrap), $theLinkWrap);
4816 $theValue = $this->
wrap($this->
wrap($theValue, $theLinkWrap), $wrap);
4818 $file = isset($conf[
'file.']) ? $this->
stdWrap($theValue, $conf[
'file.']) : $theValue;
4820 $output = $icon . $file . $size;
4822 if (isset($conf[
'stdWrap.'])) {
4823 $output = $this->
stdWrap($output, $conf[
'stdWrap.']);
4839 foreach ($parts as $part) {
4842 if ((
string)(
int)$theVal === (
string)$theVal) {
4843 $theVal = (int)$theVal;
4855 $value /= (int)$theVal;
4876 $temp = explode($delim, $string);
4877 foreach ($temp as $key => $val) {
4878 $temp[$key] = (int)$this->
calc($val);
4896 $conf[
'token'] = isset($conf[
'token.']) ? $this->
stdWrap($conf[
'token'], $conf[
'token.']) : $conf[
'token'];
4897 if ($conf[
'token'] ===
'') {
4900 $valArr = explode($conf[
'token'], $value);
4904 $key = isset($conf[
'returnKey.']) ? (int)$this->
stdWrap($conf[
'returnKey'], $conf[
'returnKey.']) : (int)$conf[
'returnKey'];
4905 return isset($valArr[$key]) ? $valArr[$key] :
'';
4909 if (!empty($valArr) && ($conf[
'returnCount'] || $conf[
'returnCount.'])) {
4910 $returnCount = isset($conf[
'returnCount.']) ? (bool)$this->
stdWrap($conf[
'returnCount'], $conf[
'returnCount.']) : (bool)$conf[
'returnCount'];
4911 return $returnCount ? count($valArr) : 0;
4915 $conf[
'max'] = isset($conf[
'max.']) ? (int)$this->
stdWrap($conf[
'max'], $conf[
'max.']) : (int)$conf[
'max'];
4916 $conf[
'min'] = isset($conf[
'min.']) ? (int)$this->
stdWrap($conf[
'min'], $conf[
'min.']) : (int)$conf[
'min'];
4919 $splitCount = count($valArr);
4920 $max = isset($conf[
'max.']) ? $this->
stdWrap($conf[
'max'], $conf[
'max.']) : $conf[
'max'];
4921 if ($max && $splitCount > $max) {
4924 $min = isset($conf[
'min.']) ? $this->
stdWrap($conf[
'min'], $conf[
'min.']) : $conf[
'min'];
4925 if ($min && $splitCount < $min) {
4928 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
4929 $cObjNum = isset($conf[
'cObjNum.']) ? $this->
stdWrap($conf[
'cObjNum'], $conf[
'cObjNum.']) : $conf[
'cObjNum'];
4930 $splitArr = array();
4931 if ($wrap || $cObjNum) {
4932 $splitArr[
'wrap'] = $wrap;
4933 $splitArr[
'cObjNum'] = $cObjNum;
4934 $splitArr =
$GLOBALS[
'TSFE']->tmpl->splitConfArray($splitArr, $splitCount);
4937 for ($a = 0; $a < $splitCount; $a++) {
4939 $value =
'' . $valArr[$a];
4941 if ($splitArr[$a][
'cObjNum']) {
4942 $objName = (int)$splitArr[$a][
'cObjNum'];
4943 $value = isset($conf[$objName .
'.']) ? $this->
stdWrap($this->
cObjGet($conf[$objName .
'.'], $objName .
'.'), $conf[$objName .
'.']) : $this->
cObjGet($conf[$objName .
'.'], $objName .
'.');
4945 $wrap = isset($splitArr[$a][
'wrap.']) ? $this->
stdWrap($splitArr[$a][
'wrap'], $splitArr[$a][
'wrap.']) : $splitArr[$a][
'wrap'];
4947 $value = $this->
wrap($value, $wrap);
4964 ksort($configuration, SORT_NUMERIC);
4965 foreach ($configuration as $index => $action) {
4983 if ((isset($configuration[
'search']) || isset($configuration[
'search.'])) && (isset($configuration[
'replace']) || isset($configuration[
'replace.']))) {
4985 $search = isset($configuration[
'search.']) ? $this->
stdWrap($configuration[
'search'], $configuration[
'search.']) : $configuration[
'search'];
4986 $replace = isset($configuration[
'replace.']) ? $this->
stdWrap($configuration[
'replace'], $configuration[
'replace.']) : $configuration[
'replace'];
4988 if (isset($configuration[
'useRegExp']) || $configuration[
'useRegExp.']) {
4989 $useRegularExpression = isset($configuration[
'useRegExp.']) ? $this->
stdWrap($configuration[
'useRegExp'], $configuration[
'useRegExp.']) : $configuration[
'useRegExp'];
4992 if (isset($configuration[
'useOptionSplitReplace']) || isset($configuration[
'useOptionSplitReplace.'])) {
4993 $useOptionSplitReplace = isset($configuration[
'useOptionSplitReplace.']) ? $this->
stdWrap($configuration[
'useOptionSplitReplace'], $configuration[
'useOptionSplitReplace.']) : $configuration[
'useOptionSplitReplace'];
4997 if (isset($useRegularExpression)) {
4999 $separator = $search[0];
5000 $startModifiers = strrpos($search, $separator);
5001 if ($separator !==
false && $startModifiers > 0) {
5002 $modifiers = substr($search, $startModifiers + 1);
5004 $modifiers = str_replace(
'e',
'', $modifiers);
5005 $search = substr($search, 0, ($startModifiers + 1)) . $modifiers;
5007 if (empty($useOptionSplitReplace)) {
5008 $content = preg_replace($search, $replace, $content);
5011 $splitCount = preg_match_all($search, $content, $matches);
5015 $replaceCallback =
function ($match) use ($replaceArray, $search, &$replaceCount) {
5017 return preg_replace($search, $replaceArray[$replaceCount - 1][0], $match[0]);
5019 $content = preg_replace_callback($search, $replaceCallback, $content);
5022 if (empty($useOptionSplitReplace)) {
5023 $content = str_replace($search, $replace, $content);
5026 $searchPreg =
'#' . preg_quote($search,
'#') .
'#';
5029 $splitCount = preg_match_all($searchPreg, $content, $matches);
5033 $replaceCallback =
function () use ($replaceArray, $search, &$replaceCount) {
5035 return $replaceArray[$replaceCount - 1][0];
5037 $content = preg_replace_callback($searchPreg, $replaceCallback, $content);
5052 protected function round($content, array $conf = array())
5054 $decimals = isset($conf[
'decimals.']) ? $this->
stdWrap($conf[
'decimals'], $conf[
'decimals.']) : $conf[
'decimals'];
5055 $type = isset($conf[
'roundType.']) ? $this->
stdWrap($conf[
'roundType'], $conf[
'roundType.']) : $conf[
'roundType'];
5056 $floatVal = floatval($content);
5059 $content = ceil($floatVal);
5062 $content = floor($floatVal);
5067 $content =
round($floatVal, (
int)$decimals);
5082 $decimals = isset($conf[
'decimals.']) ? $this->
stdWrap($conf[
'decimals'], $conf[
'decimals.']) : $conf[
'decimals'];
5083 $dec_point = isset($conf[
'dec_point.']) ? $this->
stdWrap($conf[
'dec_point'], $conf[
'dec_point.']) : $conf[
'dec_point'];
5084 $thousands_sep = isset($conf[
'thousands_sep.']) ? $this->
stdWrap($conf[
'thousands_sep'], $conf[
'thousands_sep.']) : $conf[
'thousands_sep'];
5085 return number_format(floatval($content), $decimals, $dec_point, $thousands_sep);
5112 'parseFunc' => $ref,
5113 'parseFunc.' => $conf
5115 $temp_conf = $this->
mergeTSRef($temp_conf,
'parseFunc');
5116 $conf = $temp_conf[
'parseFunc.'];
5119 if ((
string)$conf[
'externalBlocks'] ===
'') {
5124 $parts = $htmlParser->splitIntoBlock($tags, $theValue);
5125 foreach ($parts as $k => $v) {
5128 $tagName = strtolower($htmlParser->getFirstTagName($v));
5129 $cfg = $conf[
'externalBlocks.'][$tagName .
'.'];
5130 if ($cfg[
'stripNLprev'] || $cfg[
'stripNL']) {
5131 $parts[$k - 1] = preg_replace(
'/' . CR .
'?' . LF .
'[ ]*$/',
'', $parts[$k - 1]);
5133 if ($cfg[
'stripNLnext'] || $cfg[
'stripNL']) {
5134 $parts[$k + 1] = preg_replace(
'/^[ ]*' . CR .
'?' . LF .
'/',
'', $parts[$k + 1]);
5138 foreach ($parts as $k => $v) {
5140 $tag = $htmlParser->getFirstTag($v);
5141 $tagName = strtolower($htmlParser->getFirstTagName($v));
5142 $cfg = $conf[
'externalBlocks.'][$tagName .
'.'];
5143 if ($cfg[
'callRecursive']) {
5144 $parts[$k] = $this->
parseFunc($htmlParser->removeFirstAndLastTag($v), $conf);
5145 if (!$cfg[
'callRecursive.'][
'dontWrapSelf']) {
5146 if ($cfg[
'callRecursive.'][
'alternativeWrap']) {
5147 $parts[$k] = $this->
wrap($parts[$k], $cfg[
'callRecursive.'][
'alternativeWrap']);
5149 if (is_array($cfg[
'callRecursive.'][
'tagStdWrap.'])) {
5150 $tag = $this->
stdWrap($tag, $cfg[
'callRecursive.'][
'tagStdWrap.']);
5152 $parts[$k] = $tag . $parts[$k] .
'</' . $tagName .
'>';
5155 }
elseif ($cfg[
'HTMLtableCells']) {
5156 $rowParts = $htmlParser->splitIntoBlock(
'tr', $parts[$k]);
5157 foreach ($rowParts as $kk => $vv) {
5159 $colParts = $htmlParser->splitIntoBlock(
'td,th', $vv);
5161 foreach ($colParts as $kkk => $vvv) {
5164 $tag = $htmlParser->getFirstTag($vvv);
5165 $tagName = strtolower($htmlParser->getFirstTagName($vvv));
5166 $colParts[$kkk] = $htmlParser->removeFirstAndLastTag($vvv);
5167 if ($cfg[
'HTMLtableCells.'][$cc .
'.'][
'callRecursive'] || !isset($cfg[
'HTMLtableCells.'][($cc .
'.')][
'callRecursive']) && $cfg[
'HTMLtableCells.'][
'default.'][
'callRecursive']) {
5168 if ($cfg[
'HTMLtableCells.'][
'addChr10BetweenParagraphs']) {
5169 $colParts[$kkk] = str_replace(
'</p><p>',
'</p>' . LF .
'<p>', $colParts[$kkk]);
5171 $colParts[$kkk] = $this->
parseFunc($colParts[$kkk], $conf);
5173 $tagStdWrap = is_array($cfg[
'HTMLtableCells.'][$cc .
'.'][
'tagStdWrap.']) ? $cfg[
'HTMLtableCells.'][$cc .
'.'][
'tagStdWrap.'] : $cfg[
'HTMLtableCells.'][
'default.'][
'tagStdWrap.'];
5174 if (is_array($tagStdWrap)) {
5175 $tag = $this->
stdWrap($tag, $tagStdWrap);
5177 $stdWrap = is_array($cfg[
'HTMLtableCells.'][$cc .
'.'][
'stdWrap.']) ? $cfg[
'HTMLtableCells.'][$cc .
'.'][
'stdWrap.'] : $cfg[
'HTMLtableCells.'][
'default.'][
'stdWrap.'];
5178 if (is_array($stdWrap)) {
5179 $colParts[$kkk] = $this->
stdWrap($colParts[$kkk], $stdWrap);
5181 $colParts[$kkk] = $tag . $colParts[$kkk] .
'</' . $tagName .
'>';
5184 $rowParts[$kk] = implode(
'', $colParts);
5187 $parts[$k] = implode(
'', $rowParts);
5189 if (is_array($cfg[
'stdWrap.'])) {
5190 $parts[$k] = $this->
stdWrap($parts[$k], $cfg[
'stdWrap.']);
5193 $parts[$k] = $this->
_parseFunc($parts[$k], $conf);
5196 return implode(
'', $parts);
5210 if (!empty($conf[
'if.']) && !$this->
checkIf($conf[
'if.'])) {
5220 $contentAccum = array();
5222 $allowTags = strtolower(str_replace(
' ',
'', $conf[
'allowTags']));
5223 $denyTags = strtolower(str_replace(
' ',
'', $conf[
'denyTags']));
5224 $totalLen = strlen($theValue);
5227 if (!is_array($currentTag)) {
5233 $len = strcspn(substr($theValue, $pointer + $len_p),
'<');
5235 $endChar = ord(strtolower(substr($theValue, $pointer + $len_p, 1)));
5237 }
while ($c > 0 && $endChar && ($endChar < 97 || $endChar > 122) && $endChar != 47);
5241 $tempContent = strtolower(substr($theValue, $pointer));
5242 $len = strpos($tempContent,
'</' . $currentTag[0]);
5243 if (is_string($len) && !$len) {
5244 $len = strlen($tempContent);
5249 $data = substr($theValue, $pointer, $len);
5253 $data = preg_replace(
'/^[ ]*' . CR .
'?' . LF .
'/',
'',
$data);
5256 if (!is_array($currentTag)) {
5259 $tmpConstants = $tsfe->tmpl->setup[
'constants.'];
5260 if ($conf[
'constants'] && is_array($tmpConstants)) {
5261 foreach ($tmpConstants as $key => $val) {
5262 if (is_string($val)) {
5263 $data = str_replace(
'###' . $key .
'###', $val,
$data);
5268 if (is_array($conf[
'short.'])) {
5269 $shortWords = $conf[
'short.'];
5270 krsort($shortWords);
5271 foreach ($shortWords as $key => $val) {
5272 if (is_string($val)) {
5278 if (is_array($conf[
'plainTextStdWrap.'])) {
5282 if ($conf[
'userFunc']) {
5286 if ($conf[
'makelinks']) {
5291 if ($tsfe->no_cache && $conf[
'sword'] && is_array($tsfe->sWordList) && $tsfe->sWordRegEx) {
5294 $pregSplitMode =
'i';
5295 if (isset($tsfe->config[
'config'][
'sword_noMixedCase']) && !empty($tsfe->config[
'config'][
'sword_noMixedCase'])) {
5296 $pregSplitMode =
'';
5298 $pieces = preg_split(
'/' . $tsfe->sWordRegEx .
'/' . $pregSplitMode,
$data, 2);
5299 $newstring .= $pieces[0];
5300 $match_len = strlen(
$data) - (strlen($pieces[0]) + strlen($pieces[1]));
5302 if (strstr($pieces[0],
'<') || strstr($pieces[0],
'>')) {
5307 $inTag = strrpos($pieces[0],
'<') > strrpos($pieces[0],
'>');
5310 $match = substr(
$data, strlen($pieces[0]), $match_len);
5311 if (trim($match) && strlen($match) > 1 && !$inTag) {
5312 $match = $this->
wrap($match, $conf[
'sword']);
5315 $newstring .= $match;
5317 }
while ($pieces[1]);
5321 $contentAccum[$contentAccumP] .=
$data;
5326 $len = strcspn(substr($theValue, $pointer),
'>') + 1;
5327 $data = substr($theValue, $pointer, $len);
5329 $tagContent = substr(
$data, 1, -2);
5331 $tagContent = substr(
$data, 1, -1);
5333 $tag = explode(
' ', trim($tagContent), 2);
5334 $tag[0] = strtolower($tag[0]);
5335 if ($tag[0][0] ===
'/') {
5336 $tag[0] = substr($tag[0], 1);
5339 if ($conf[
'tags.'][$tag[0]]) {
5343 if (!$currentTag && !$tag[
'out']) {
5349 if (preg_match(
'/^(area|base|br|col|hr|img|input|meta|param)$/i', $tag[0])) {
5354 if ($currentTag[0] == $tag[0] && $tag[
'out']) {
5355 $theName = $conf[
'tags.'][$tag[0]];
5356 $theConf = $conf[
'tags.'][$tag[0] .
'.'];
5358 $stripNL = $theConf[
'stripNL'] ? 1 : 0;
5360 $breakOut = $theConf[
'breakoutTypoTagContent'] ? 1 : 0;
5361 $this->parameters = array();
5362 if ($currentTag[1]) {
5364 if (is_array($params)) {
5365 foreach ($params as $option => $val) {
5366 $this->parameters[strtolower($option)] = $val;
5370 $this->parameters[
'allParams'] = trim($currentTag[1]);
5374 $contentAccum[$contentAccumP - 1] = preg_replace(
'/' . CR .
'?' . LF .
'[ ]*$/',
'', $contentAccum[$contentAccumP - 1]);
5375 $contentAccum[$contentAccumP] = preg_replace(
'/^[ ]*' . CR .
'?' . LF .
'/',
'', $contentAccum[$contentAccumP]);
5376 $contentAccum[$contentAccumP] = preg_replace(
'/' . CR .
'?' . LF .
'[ ]*$/',
'', $contentAccum[$contentAccumP]);
5379 $newInput = $this->cObjGetSingle($theName, $theConf,
'/parseFunc/.tags.' . $tag[0]);
5381 $contentAccum[$contentAccumP] = $newInput;
5385 $contentAccum[$contentAccumP - 2] .= $contentAccum[($contentAccumP - 1)] . $contentAccum[$contentAccumP];
5386 unset($contentAccum[$contentAccumP]);
5387 unset($contentAccum[$contentAccumP - 1]);
5388 $contentAccumP -= 2;
5395 $contentAccum[$contentAccumP] .=
$data;
5401 $contentAccum[$contentAccumP] .=
$data;
5403 $contentAccum[$contentAccumP] .= HTMLSpecialChars(
$data);
5409 }
while ($pointer < $totalLen);
5411 reset($contentAccum);
5412 $contentAccumCount = count($contentAccum);
5413 for ($a = 0; $a < $contentAccumCount; $a++) {
5416 if (is_array($conf[
'nonTypoTagStdWrap.'])) {
5417 $contentAccum[$a] = $this->
stdWrap($contentAccum[$a], $conf[
'nonTypoTagStdWrap.']);
5420 if ($conf[
'nonTypoTagUserFunc']) {
5421 $contentAccum[$a] = $this->
callUserFunction($conf[
'nonTypoTagUserFunc'], $conf[
'nonTypoTagUserFunc.'], $contentAccum[$a]);
5425 return implode(
'', $contentAccum);
5438 $lParts = explode(LF, $theValue);
5440 $nonWrappedTag = $conf[
'nonWrappedTag'];
5441 $defaultAlign = isset($conf[
'defaultAlign.']) ? trim($this->
stdWrap($conf[
'defaultAlign'], $conf[
'defaultAlign.'])) : trim($conf[
'defaultAlign']);
5442 if ((
string)$theValue ===
'') {
5446 foreach ($lParts as $k => $l) {
5453 if ($l[0] ===
'<' && substr($l, -1) ===
'>') {
5454 $fwParts = explode(
'>', substr($l, 1), 2);
5455 list($tagName) = explode(
' ', $fwParts[0], 2);
5457 if (substr($tagName, -1) ==
'/') {
5458 $tagName = substr($tagName, 0, -1);
5460 if (substr($fwParts[0], -1) ==
'/') {
5468 $str_content = $backParts[0];
5469 $sameBeginEnd = substr(strtolower($backParts[1]), 1, strlen($tagName)) == strtolower($tagName);
5472 if ($sameBeginEnd && in_array(strtolower($tagName), $encapTags)) {
5473 $uTagName = strtoupper($tagName);
5474 $uTagName = strtoupper($conf[
'remapTag.'][$uTagName] ? $conf[
'remapTag.'][$uTagName] : $uTagName);
5476 $uTagName = strtoupper($nonWrappedTag);
5479 $str_content = $lParts[$k];
5484 if (is_array($conf[
'innerStdWrap_all.'])) {
5485 $str_content = $this->
stdWrap($str_content, $conf[
'innerStdWrap_all.']);
5489 if (is_array($conf[
'addAttributes.'][$uTagName .
'.'])) {
5490 foreach ($conf[
'addAttributes.'][$uTagName .
'.'] as $kk => $vv) {
5491 if (!is_array($vv)) {
5492 if ((
string)$conf[
'addAttributes.'][($uTagName .
'.')][($kk .
'.')][
'setOnly'] ==
'blank') {
5493 if ((
string)$attrib[$kk] ===
'') {
5496 }
elseif ((
string)$conf[
'addAttributes.'][($uTagName .
'.')][($kk .
'.')][
'setOnly'] ==
'exists') {
5497 if (!isset($attrib[$kk])) {
5507 if (is_array($conf[
'encapsLinesStdWrap.'][$uTagName .
'.'])) {
5508 $str_content = $this->
stdWrap($str_content, $conf[
'encapsLinesStdWrap.'][$uTagName .
'.']);
5511 if (!$attrib[
'align'] && $defaultAlign) {
5512 $attrib[
'align'] = $defaultAlign;
5515 if (!($conf[
'removeWrapping'] && !($emptyTag && $conf[
'removeWrapping.'][
'keepSingleTag']))) {
5517 $str_content =
'<' . strtolower($uTagName) . (trim($params) ?
' ' . trim($params) :
'') .
' />';
5519 $str_content =
'<' . strtolower($uTagName) . (trim($params) ?
' ' . trim($params) :
'') .
'>' . $str_content .
'</' . strtolower($uTagName) .
'>';
5523 if ($nWrapped && $conf[
'wrapNonWrappedLines']) {
5524 $str_content = $this->
wrap($str_content, $conf[
'wrapNonWrappedLines']);
5526 $lParts[$k] = $str_content;
5528 return implode(LF, $lParts);
5545 foreach ([
'http://',
'https://' ] as $scheme) {
5546 $textpieces = explode($scheme,
$data);
5547 $pieces = count($textpieces);
5548 $textstr = $textpieces[0];
5549 for ($i = 1; $i < $pieces; $i++) {
5550 $len = strcspn($textpieces[$i], chr(32) . TAB . CRLF);
5551 if (trim(substr($textstr, -1)) ==
'' && $len) {
5552 $lastChar = substr($textpieces[$i], $len - 1, 1);
5553 if (!preg_match(
'/[A-Za-z0-9\\/#_-]/', $lastChar)) {
5557 $parts[0] = substr($textpieces[$i], 0, $len);
5558 $parts[1] = substr($textpieces[$i], $len);
5559 $keep = $conf[
'keep'];
5560 $linkParts = parse_url($scheme . $parts[0]);
5562 if (strstr($keep,
'scheme')) {
5565 $linktxt .= $linkParts[
'host'];
5566 if (strstr($keep,
'path')) {
5567 $linktxt .= $linkParts[
'path'];
5569 if (strstr($keep,
'query') && $linkParts[
'query']) {
5570 $linktxt .=
'?' . $linkParts[
'query'];
5571 }
elseif ($linkParts[
'path'] ==
'/') {
5572 $linktxt = substr($linktxt, 0, -1);
5575 if (isset($conf[
'extTarget'])) {
5576 if (isset($conf[
'extTarget.'])) {
5577 $target = $this->
stdWrap($conf[
'extTarget'], $conf[
'extTarget.']);
5579 $target = $conf[
'extTarget'];
5588 $res =
'<a href="' . htmlspecialchars($linkUrl) .
'"' . ($target ?
' target="' . $target .
'"' :
'') . $aTagParams . $this->
extLinkATagParams((
'http://' . $parts[0]),
'url') .
'>';
5590 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
5591 if ($conf[
'ATagBeforeWrap']) {
5592 $res = $res . $this->
wrap($linktxt, $wrap) .
'</a>';
5594 $res = $this->
wrap($res . $linktxt .
'</a>', $wrap);
5596 $textstr .= $res . $parts[1];
5598 $textstr .= $scheme . $textpieces[$i];
5619 $textpieces = explode(
'mailto:',
$data);
5620 $pieces = count($textpieces);
5621 $textstr = $textpieces[0];
5623 for ($i = 1; $i < $pieces; $i++) {
5624 $len = strcspn($textpieces[$i], chr(32) . TAB . CRLF);
5625 if (trim(substr($textstr, -1)) ==
'' && $len) {
5626 $lastChar = substr($textpieces[$i], $len - 1, 1);
5627 if (!preg_match(
'/[A-Za-z0-9]/', $lastChar)) {
5630 $parts[0] = substr($textpieces[$i], 0, $len);
5631 $parts[1] = substr($textpieces[$i], $len);
5632 $linktxt = preg_replace(
'/\\?.*/',
'', $parts[0]);
5633 list($mailToUrl, $linktxt) = $this->
getMailTo($parts[0], $linktxt);
5634 $mailToUrl = $tsfe->spamProtectEmailAddresses ===
'ascii' ? $mailToUrl : htmlspecialchars($mailToUrl);
5635 $res =
'<a href="' . $mailToUrl .
'"' . $aTagParams .
'>';
5636 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
5637 if ($conf[
'ATagBeforeWrap']) {
5638 $res = $res . $this->
wrap($linktxt, $wrap) .
'</a>';
5640 $res = $this->
wrap($res . $linktxt .
'</a>', $wrap);
5642 $textstr .= $res . $parts[1];
5644 $textstr .=
'mailto:' . $textpieces[$i];
5674 public function getImgResource($file, $fileArray)
5676 if (empty($file) && empty($fileArray)) {
5679 if (!is_array($fileArray)) {
5680 $fileArray = (array)$fileArray;
5682 $imageResource = null;
5684 if ($file ===
'GIFBUILDER') {
5687 $gifCreator->init();
5689 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib']) {
5690 $gifCreator->start($fileArray, $this->data);
5691 $theImage = $gifCreator->gifBuild();
5693 $imageResource = $gifCreator->getImageDimensions($theImage);
5694 $imageResource[
'origFile'] = $theImage;
5696 if ($file instanceof File) {
5697 $fileObject = $file;
5698 }
elseif ($file instanceof FileReference) {
5699 $fileObject = $file->getOriginalFile();
5700 if (!isset($fileArray[
'crop'])) {
5701 $fileArray[
'crop'] = $file->getProperty(
'crop');
5705 if ($fileArray[
'import.']) {
5706 $importedFile = trim($this->
stdWrap(
'', $fileArray[
'import.']));
5707 if (!empty($importedFile)) {
5708 $file = $importedFile;
5713 $treatIdAsReference = isset($fileArray[
'treatIdAsReference.']) ? $this->
stdWrap($fileArray[
'treatIdAsReference'], $fileArray[
'treatIdAsReference.']) : $fileArray[
'treatIdAsReference'];
5714 if (!empty($treatIdAsReference)) {
5716 $fileObject = $fileReference->getOriginalFile();
5717 if (!isset($fileArray[
'crop'])) {
5718 $fileArray[
'crop'] = $fileReference->getProperty(
'crop');
5723 }
elseif (preg_match(
'/^(0|[1-9][0-9]*):/', $file)) {
5726 if (isset($importedFile) && !empty($importedFile) && !empty($fileArray[
'import'])) {
5727 $file = $fileArray[
'import'] . $file;
5731 }
catch (Exception $exception) {
5734 $logger->warning(
'The image "' . $file .
'" could not be found and won\'t be included in frontend output');
5738 if ($fileObject instanceof File) {
5739 $processingConfiguration = array();
5740 $processingConfiguration[
'width'] = isset($fileArray[
'width.']) ? $this->
stdWrap($fileArray[
'width'], $fileArray[
'width.']) : $fileArray[
'width'];
5741 $processingConfiguration[
'height'] = isset($fileArray[
'height.']) ? $this->
stdWrap($fileArray[
'height'], $fileArray[
'height.']) : $fileArray[
'height'];
5742 $processingConfiguration[
'fileExtension'] = isset($fileArray[
'ext.']) ? $this->
stdWrap($fileArray[
'ext'], $fileArray[
'ext.']) : $fileArray[
'ext'];
5743 $processingConfiguration[
'maxWidth'] = isset($fileArray[
'maxW.']) ? (int)$this->
stdWrap($fileArray[
'maxW'], $fileArray[
'maxW.']) : (int)$fileArray[
'maxW'];
5744 $processingConfiguration[
'maxHeight'] = isset($fileArray[
'maxH.']) ? (int)$this->
stdWrap($fileArray[
'maxH'], $fileArray[
'maxH.']) : (int)$fileArray[
'maxH'];
5745 $processingConfiguration[
'minWidth'] = isset($fileArray[
'minW.']) ? (int)$this->
stdWrap($fileArray[
'minW'], $fileArray[
'minW.']) : (int)$fileArray[
'minW'];
5746 $processingConfiguration[
'minHeight'] = isset($fileArray[
'minH.']) ? (int)$this->
stdWrap($fileArray[
'minH'], $fileArray[
'minH.']) : (int)$fileArray[
'minH'];
5747 $processingConfiguration[
'noScale'] = isset($fileArray[
'noScale.']) ? $this->
stdWrap($fileArray[
'noScale'], $fileArray[
'noScale.']) : $fileArray[
'noScale'];
5748 $processingConfiguration[
'additionalParameters'] = isset($fileArray[
'params.']) ? $this->
stdWrap($fileArray[
'params'], $fileArray[
'params.']) : $fileArray[
'params'];
5749 $processingConfiguration[
'frame'] = isset($fileArray[
'frame.']) ? (int)$this->
stdWrap($fileArray[
'frame'], $fileArray[
'frame.']) : (int)$fileArray[
'frame'];
5750 $processingConfiguration[
'crop'] = isset($fileArray[
'crop.']) ? $this->
stdWrap($fileArray[
'crop'], $fileArray[
'crop.']) : (isset($fileArray[
'crop']) ? $fileArray[
'crop'] : null);
5753 if (isset($fileArray[
'stripProfile'])) {
5754 $processingConfiguration[
'stripProfile'] = $fileArray[
'stripProfile'];
5758 $maskArray = $fileArray[
'm.'];
5761 if (is_array($maskArray)) {
5762 $mask = $this->getImgResource($maskArray[
'mask'], $maskArray[
'mask.']);
5763 $bgImg = $this->getImgResource($maskArray[
'bgImg'], $maskArray[
'bgImg.']);
5764 $bottomImg = $this->getImgResource($maskArray[
'bottomImg'], $maskArray[
'bottomImg.']);
5765 $bottomImg_mask = $this->getImgResource($maskArray[
'bottomImg_mask'], $maskArray[
'bottomImg_mask.']);
5767 $processingConfiguration[
'maskImages'][
'maskImage'] = $mask[
'processedFile'];
5768 $processingConfiguration[
'maskImages'][
'backgroundImage'] = $bgImg[
'processedFile'];
5769 $processingConfiguration[
'maskImages'][
'maskBottomImage'] = $bottomImg[
'processedFile'];
5770 $processingConfiguration[
'maskImages'][
'maskBottomImageMask'] = $bottomImg_mask[
'processedFile'];
5773 $hash = $processedFileObject->calculateChecksum();
5775 if ($processedFileObject->isProcessed() && !isset($tsfe->tmpl->fileCache[$hash])) {
5776 $tsfe->tmpl->fileCache[$hash] = array(
5777 0 => $processedFileObject->getProperty(
'width'),
5778 1 => $processedFileObject->getProperty(
'height'),
5779 2 => $processedFileObject->getExtension(),
5780 3 => $processedFileObject->getPublicUrl(),
5781 'origFile' => $fileObject->getPublicUrl(),
5782 'origFile_mtime' => $fileObject->getModificationTime(),
5785 'originalFile' => $fileObject,
5786 'processedFile' => $processedFileObject,
5787 'fileCacheHash' => $hash
5790 $imageResource = $tsfe->tmpl->fileCache[$hash];
5796 if (!isset($imageResource)) {
5797 $theImage = $tsfe->tmpl->getFileName($file);
5801 $gifCreator->init();
5802 $info = $gifCreator->imageMagickConvert($theImage,
'WEB');
5803 $info[
'origFile'] = $theImage;
5805 $info[
'origFile_mtime'] = @filemtime($theImage);
5806 $imageResource = $info;
5810 if (isset($imageResource)) {
5813 $imageResource = $hookObject->getImgResourcePostProcess($file, (array)$fileArray, $imageResource, $this);
5816 return $imageResource;
5832 if (!strstr($field,
'//')) {
5833 return $this->data[trim($field)];
5836 foreach ($sections as $k) {
5837 if ((
string)$this->data[$k] !==
'') {
5838 return $this->data[$k];
5853 public function getData($string, $fieldArray = null)
5856 if (!is_array($fieldArray)) {
5857 $fieldArray = $tsfe->page;
5860 $sections = explode(
'//', $string);
5861 foreach ($sections as $secKey => $secVal) {
5865 $parts = explode(
':', $secVal, 2);
5866 $type = strtolower(trim($parts[0]));
5867 $typesWithOutParameters = array(
'level',
'date',
'current',
'pagelayout');
5868 $key = trim($parts[1]);
5869 if (($key !=
'') || in_array($type, $typesWithOutParameters)) {
5875 $retVal = $this->
getGlobal($key, $getPostArray);
5878 $retVal = $this->
getGlobal(
'TSFE|' . $key);
5881 $retVal = getenv($key);
5887 $retVal = $this->
getGlobal($key, $fieldArray);
5890 $retVal = $this->getFileDataKey($key);
5893 $retVal = $this->parameters[$key];
5896 $retVal = $tsfe->register[$key];
5902 $retVal = count($tsfe->tmpl->rootLine) - 1;
5906 $numericKey = $this->
getKey($keyParts[0], $tsfe->tmpl->rootLine);
5907 $retVal = $this->
rootLineValue($numericKey,
'title', strtolower($keyParts[1]) ===
'slide');
5911 $numericKey = $this->
getKey($keyParts[0], $tsfe->tmpl->rootLine);
5912 $retVal = $this->
rootLineValue($numericKey,
'media', strtolower($keyParts[1]) ===
'slide');
5915 $numericKey = $this->
getKey($key, $tsfe->tmpl->rootLine);
5920 $numericKey = $this->
getKey($keyParts[0], $tsfe->tmpl->rootLine);
5921 $retVal = $this->
rootLineValue($numericKey, $keyParts[1], strtolower($keyParts[2]) ===
'slide');
5923 case 'fullrootline':
5925 $fullKey = (int)$keyParts[0] - count($tsfe->tmpl->rootLine) + count($tsfe->rootLine);
5926 if ($fullKey >= 0) {
5927 $retVal = $this->
rootLineValue($fullKey, $keyParts[1], stristr($keyParts[2],
'slide'), $tsfe->rootLine);
5934 $retVal = date($key,
$GLOBALS[
'EXEC_TIME']);
5937 $retVal = $tsfe->page[$key];
5946 $retVal =
$GLOBALS[
'TSFE']->page[
'backend_layout'];
5949 if ($retVal ===
'-1') {
5951 }
elseif ($retVal ===
'' || $retVal ===
'0') {
5955 $rootLine = $tsfe->rootLine;
5956 array_shift($rootLine);
5957 foreach ($rootLine as $rootLinePage) {
5958 $retVal = (string) $rootLinePage[
'backend_layout_next_level'];
5960 if ($retVal ===
'-1') {
5963 }
elseif ($retVal !==
'' && $retVal !==
'0') {
5969 if ($retVal ===
'0' || $retVal ===
'') {
5970 $retVal =
'default';
5978 $db_rec = $tsfe->sys_page->getRawRecord($selectParts[0], $selectParts[1]);
5979 if (is_array($db_rec) && $selectParts[2]) {
5980 $retVal = $db_rec[$selectParts[2]];
5984 $retVal = $tsfe->sL(
'LLL:' . $key);
5987 $retVal = $tsfe->tmpl->getFileName($key);
5991 case 'parentRecordNumber':
6001 case 'fullRootLine':
6017 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getData'])) {
6018 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getData'] as $classData) {
6021 throw new \UnexpectedValueException(
'$hookObject must implement interface ' . ContentObjectGetDataHookInterface::class, 1195044480);
6023 $retVal = $hookObject->getDataExtension($string, $fieldArray, $secVal, $retVal, $this);
6039 protected function getFileDataKey($key)
6041 $parts = explode(
':', $key);
6042 $fileUidOrCurrentKeyword = $parts[0];
6043 $requestedFileInformationKey = $parts[1];
6045 if ($fileUidOrCurrentKeyword ===
'current') {
6050 $fileObject = $fileFactory->getFileObject($fileUidOrCurrentKeyword);
6054 }
catch (Exception $exception) {
6057 $logger->warning(
'The file "' . $fileUidOrCurrentKeyword .
'" could not be found and won\'t be included in frontend output');
6061 if ($fileObject instanceof FileInterface) {
6063 switch ($requestedFileInformationKey) {
6065 return $fileObject->getName();
6067 if (method_exists($fileObject,
'getUid')) {
6068 return $fileObject->getUid();
6072 if ($fileObject instanceof FileReference) {
6073 return $fileObject->getOriginalFile()->getUid();
6077 return $fileObject->getSize();
6079 return $fileObject->getSha1();
6081 return $fileObject->getExtension();
6083 return $fileObject->getMimeType();
6085 return $fileObject->getContents();
6087 return $fileObject->getPublicUrl();
6090 return $fileObject->getProperty($requestedFileInformationKey);
6094 return 'Error: no file object';
6113 return $rootLine[$key][$field];
6115 for ($a = $key; $a >= 0; $a--) {
6116 $val = $rootLine[$a][$field];
6136 $keys = explode(
'|', $keyString);
6137 $numberOfLevels = count($keys);
6138 $rootKey = trim($keys[0]);
6139 $value = isset($source) ? $source[$rootKey] :
$GLOBALS[$rootKey];
6140 for ($i = 1; $i < $numberOfLevels && isset($value); $i++) {
6141 $currentKey = trim($keys[$i]);
6142 if (is_object($value)) {
6143 $value = $value->{$currentKey};
6144 }
elseif (is_array($value)) {
6145 $value = $value[$currentKey];
6151 if (!is_scalar($value)) {
6170 if (is_array($arr)) {
6172 $key = count($arr) + $key;
6193 $field = $conf[
'field'];
6194 $delimiter = $conf[
'delimiter'] ? $conf[
'delimiter'] :
' ,';
6195 if (is_array(
$GLOBALS[
'TCA'][
$table]) && is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field]) && is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'items'])) {
6199 foreach ($values as $value) {
6201 foreach (
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'items'] as $item) {
6203 if ((
string)$item[1] === trim($value)) {
6204 $output[] = $tsfe->sL($item[0]);
6208 $returnValue = implode($delimiter, $output);
6210 $returnValue = $inputValue;
6212 return $returnValue;
6235 $linkParameter = null;
6241 list($linkHandlerKeyword, $linkHandlerValue) = explode(
':', $linkParameterParts[
'url'], 2);
6242 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typolinkLinkHandler'][$linkHandlerKeyword] && (
string)$linkHandlerValue !==
'') {
6243 $linkHandlerObj =
GeneralUtility::getUserObj(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typolinkLinkHandler'][$linkHandlerKeyword]);
6244 if (method_exists($linkHandlerObj,
'main')) {
6245 return $linkHandlerObj->main($linkText, $configuration, $linkHandlerKeyword, $linkHandlerValue, $mixedLinkParameter, $this);
6252 $fileOrFolderObject = $this->
getResourceFactory()->retrieveFileOrFolderObject($linkHandlerValue);
6254 if ($fileOrFolderObject instanceof File || $fileOrFolderObject instanceof
Folder) {
6255 $linkParameter = $fileOrFolderObject->getPublicUrl();
6257 $linkParameter = null;
6259 }
catch (\RuntimeException $e) {
6261 $linkParameter = null;
6267 $linkParameter = $linkParameterParts[
'url'];
6271 if ($linkParameterParts[
'additionalParams'] !==
'') {
6272 $forceParams = $linkParameterParts[
'additionalParams'];
6274 $configuration[
'additionalParams'] .= $forceParams[0] ==
'&' ? $forceParams :
'&' . $forceParams;
6278 'href' => $linkParameter,
6279 'target' => $linkParameterParts[
'target'],
6280 'class' => $linkParameterParts[
'class'],
6281 'title' => $linkParameterParts[
'title']
6302 $linkParts = parse_url($linkParameter);
6305 if (strpos($linkParameter,
'@') > 0 && (!$linkParts[
'scheme'] || $linkParts[
'scheme'] ==
'mailto')) {
6310 $fileChar = intval(strpos($linkParameter,
'/'));
6311 $urlChar = intval(strpos($linkParameter,
'.'));
6313 $containsSlash =
false;
6317 list($rootFileDat) = explode(
'?', rawurldecode($linkParameter));
6318 $containsSlash = strpos($rootFileDat,
'/') !==
false;
6319 $rFD_fI = pathinfo($rootFileDat);
6320 if (trim($rootFileDat) && !$containsSlash && (@is_file((PATH_site . $rootFileDat)) ||
GeneralUtility::inList(
'php,html,htm', strtolower($rFD_fI[
'extension'])))) {
6322 }
elseif ($containsSlash) {
6329 if ($linkParts[
'scheme'] || $isLocalFile != 1 && $urlChar && (!$containsSlash || $urlChar < $fileChar)) {
6333 }
elseif ($containsSlash || $isLocalFile) {
6356 public function typoLink($linktxt, $conf)
6361 $finalTagParts = array();
6363 $linkParameter = isset($conf[
'parameter.']) ? trim($this->
stdWrap($conf[
'parameter'], $conf[
'parameter.'])) : trim($conf[
'parameter']);
6364 $this->lastTypoLinkUrl =
'';
6365 $this->lastTypoLinkTarget =
'';
6369 if (!is_array($resolvedLinkParameters)) {
6370 return $resolvedLinkParameters;
6373 $linkParameter = $resolvedLinkParameters[
'href'];
6374 $forceTarget = $resolvedLinkParameters[
'target'];
6375 $linkClass = $resolvedLinkParameters[
'class'];
6376 $forceTitle = $resolvedLinkParameters[
'title'];
6378 if (!$linkParameter) {
6383 $JSwindowParts = array();
6384 $JSwindowParams =
'';
6385 if ($forceTarget && preg_match(
'/^([0-9]+)x([0-9]+)(:(.*)|.*)$/', $forceTarget, $JSwindowParts)) {
6388 $JSwindow_paramsArr = array();
6389 foreach ($JSwindow_tempParamsArr as $JSv) {
6390 list($JSp, $JSv) = explode(
'=', $JSv);
6391 $JSwindow_paramsArr[$JSp] = $JSp .
'=' . $JSv;
6394 $JSwindow_paramsArr[
'width'] =
'width=' . $JSwindowParts[1];
6395 $JSwindow_paramsArr[
'height'] =
'height=' . $JSwindowParts[2];
6397 $JSwindowParams = implode(
',', $JSwindow_paramsArr);
6403 if ($tsfe->dtdAllowsFrames) {
6404 $target = isset($conf[
'target']) ? $conf[
'target'] : $tsfe->intTarget;
6406 $target = isset($conf[
'target']) ? $conf[
'target'] :
'';
6408 if ($conf[
'target.']) {
6409 $target = $this->
stdWrap($target, $conf[
'target.']);
6413 $title = $conf[
'title'];
6414 if ($conf[
'title.']) {
6415 $title = $this->
stdWrap($title, $conf[
'title.']);
6421 switch ($linkType) {
6424 $linkParameter = preg_replace(
'/^mailto:/i',
'', $linkParameter);
6425 list($this->lastTypoLinkUrl, $linktxt) = $this->
getMailTo($linkParameter, $linktxt);
6431 if ($tsfe->dtdAllowsFrames) {
6432 $target = isset($conf[
'extTarget']) ? $conf[
'extTarget'] : $tsfe->extTarget;
6434 $target = isset($conf[
'extTarget']) ? $conf[
'extTarget'] :
'';
6436 if ($conf[
'extTarget.']) {
6437 $target = $this->
stdWrap($target, $conf[
'extTarget.']);
6440 $target = $forceTarget;
6442 if ($linktxt ==
'') {
6443 $linktxt = $this->
parseFunc($linkParameter, array(
'makelinks' => 0),
'< lib.parseFunc');
6446 $urlParts = parse_url($linkParameter);
6447 if (!$urlParts[
'scheme']) {
6448 $scheme =
'http://';
6455 $this->lastTypoLinkTarget = $target;
6457 $finalTagParts[
'targetParams'] = $target ?
' target="' . $target .
'"' :
'';
6458 $finalTagParts[
'aTagParams'] .= $this->
extLinkATagParams($finalTagParts[
'url'], $linkType);
6464 $splitLinkParam = explode(
'?', $linkParameter);
6467 if (file_exists(rawurldecode($splitLinkParam[0])) || strpos($linkParameter,
'/') !==
false) {
6468 if ($linktxt ==
'') {
6469 $linktxt = $this->
parseFunc(rawurldecode($linkParameter), array(
'makelinks' => 0),
'< lib.parseFunc');
6472 $this->lastTypoLinkUrl = $this->
forceAbsoluteUrl($this->lastTypoLinkUrl, $conf);
6473 $target = isset($conf[
'fileTarget']) ? $conf[
'fileTarget'] : $tsfe->fileTarget;
6474 if ($conf[
'fileTarget.']) {
6475 $target = $this->
stdWrap($target, $conf[
'fileTarget.']);
6478 $target = $forceTarget;
6480 $this->lastTypoLinkTarget = $target;
6482 $finalTagParts[
'targetParams'] = $target ?
' target="' . $target .
'"' :
'';
6483 $finalTagParts[
'aTagParams'] .= $this->
extLinkATagParams($finalTagParts[
'url'], $linkType);
6485 $this->
getTimeTracker()->setTSlogMessage(
'typolink(): File \'' . $splitLinkParam[0] .
'\' did not exist, so \
'' . $linktxt .
'\' was not linked.
', 1);
6490 // Integer or alias (alias is without slashes or periods or commas, that is
6491 // 'nospace,alphanum_x,lower,unique
' according to definition in $GLOBALS['TCA
']!)
6493 $enableLinksAcrossDomains = $tsfe->config['config
']['typolinkEnableLinksAcrossDomains
'];
6495 if ($conf['no_cache.
']) {
6496 $conf['no_cache
'] = $this->stdWrap($conf['no_cache
'], $conf['no_cache.
']);
6498 // Splitting the parameter by ',
' and if the array counts more than 1 element it's an
id/type/parameters triplet
6500 $linkParameter = $pairParts[0];
6501 $link_params_parts = explode(
'#', $linkParameter);
6503 $linkParameter = trim($link_params_parts[0]);
6505 if ($linkParameter ===
'') {
6506 $linkParameter = $tsfe->id;
6509 $sectionMark = isset($conf[
'section.']) ? trim($this->
stdWrap($conf[
'section'], $conf[
'section.'])) : trim($conf[
'section']);
6512 if ($link_params_parts[1] && !$sectionMark) {
6513 $sectionMark = trim($link_params_parts[1]);
6516 if (count($pairParts) > 1) {
6518 $theTypeP = isset($pairParts[1]) ? $pairParts[1] : 0;
6519 $conf[
'additionalParams'] .= isset($pairParts[2]) ? $pairParts[2] :
'';
6523 $linkParameter = $tsfe->sys_page->getPageIdFromAlias($linkParameter);
6526 if (isset($conf[
'linkAccessRestrictedPages'])) {
6527 $disableGroupAccessCheck = (bool)$conf[
'linkAccessRestrictedPages'];
6529 $disableGroupAccessCheck = (bool)$tsfe->config[
'config'][
'typolinkLinkAccessRestrictedPages'];
6532 $page = $tsfe->sys_page->getPage($linkParameter, $disableGroupAccessCheck);
6533 if (!empty($page)) {
6535 $MPvarAcc = array();
6536 if (!$tsfe->config[
'config'][
'MP_disableTypolinkClosestMPvalue']) {
6539 $MPvarAcc[
'closest'] = $temp_MP;
6543 $mount_info = $tsfe->sys_page->getMountPointInfo($page[
'uid'], $page);
6544 if (is_array($mount_info) && $mount_info[
'overlay']) {
6545 $page = $tsfe->sys_page->getPage($mount_info[
'mount_pid'], $disableGroupAccessCheck);
6547 $this->
getTimeTracker()->setTSlogMessage(
'typolink(): Mount point \'' . $mount_info[
'mount_pid'] .
'\' was not available, so \
'' . $linktxt .
'\' was not linked.
', 1);
6550 $MPvarAcc['re-map
'] = $mount_info['MPvar
'];
6552 // Setting title if blank value to link:
6553 if ($linktxt == '') {
6554 $linktxt = $this->parseFunc($page['title
'], array('makelinks
' => 0), '< lib.parseFunc
');
6557 $addQueryParams = $conf['addQueryString
'] ? $this->getQueryArguments($conf['addQueryString.
']) : '';
6558 $addQueryParams .= isset($conf['additionalParams.
']) ? trim($this->stdWrap($conf['additionalParams
'], $conf['additionalParams.
'])) : trim($conf['additionalParams
']);
6559 if ($addQueryParams === '&
' || $addQueryParams[0] !== '&
') {
6560 $addQueryParams = '';
6562 if ($conf['useCacheHash
']) {
6563 // Mind the order below! See http://forge.typo3.org/issues/17070
6564 $params = $tsfe->linkVars . $addQueryParams;
6565 if (trim($params, '&
') != '') {
6567 $cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class);
6568 $cHash = $cacheHash->generateForParameters($params);
6569 $addQueryParams .= $cHash ? '&cHash=
' . $cHash : '';
6574 $currentDomain = $this->getEnvironmentVariable('HTTP_HOST
');
6575 // Mount pages are always local and never link to another domain
6576 if (!empty($MPvarAcc)) {
6578 $addQueryParams .= '&MP=
' . rawurlencode(implode(',
', $MPvarAcc));
6579 } elseif (strpos($addQueryParams, '&MP=
') === false && $tsfe->config['config
']['typolinkCheckRootline
']) {
6580 // We do not come here if additionalParams had '&MP=
'. This happens when typoLink is called from
6581 // menu. Mount points always work in the content of the current domain and we must not change
6582 // domain if MP variables exist.
6583 // If we link across domains and page is free type shortcut, we must resolve the shortcut first!
6584 // If we do not do it, TYPO3 will fail to (1) link proper page in RealURL/CoolURI because
6585 // they return relative links and (2) show proper page if no RealURL/CoolURI exists when link is clicked
6586 if ($enableLinksAcrossDomains && $page['doktype
'] == PageRepository::DOKTYPE_SHORTCUT && $page['shortcut_mode
'] == PageRepository::SHORTCUT_MODE_NONE) {
6587 // Save in case of broken destination or endless loop
6589 // Same as in RealURL, seems enough
6591 while ($maxLoopCount && is_array($page) && $page['doktype
'] == PageRepository::DOKTYPE_SHORTCUT && $page['shortcut_mode
'] == PageRepository::SHORTCUT_MODE_NONE) {
6592 $page = $tsfe->sys_page->getPage($page['shortcut
'], $disableGroupAccessCheck);
6595 if (empty($page) || $maxLoopCount == 0) {
6596 // We revert if shortcut is broken or maximum number of loops is exceeded (indicates endless loop)
6601 $targetDomain = $tsfe->getDomainNameForPid($page['uid
']);
6602 // Do not prepend the domain if it is the current hostname
6603 if (!$targetDomain || $tsfe->domainNameMatchesCurrentRequest($targetDomain)) {
6607 $absoluteUrlScheme = 'http
';
6608 // URL shall be absolute:
6613 } elseif ($page['url_scheme
'] > 0) {
6614 $absoluteUrlScheme = (int)$page['url_scheme
'] === HttpUtility::SCHEME_HTTP ? 'http
' : 'https
';
6615 } elseif ($this->getEnvironmentVariable('TYPO3_SSL
')) {
6616 $absoluteUrlScheme = 'https
';
6618 // If no domain records are defined, use current domain:
6619 $currentUrlScheme = parse_url($this->getEnvironmentVariable('TYPO3_REQUEST_URL
'), PHP_URL_SCHEME);
6620 if ($targetDomain === '' && ($conf['forceAbsoluteUrl'] || $absoluteUrlScheme !== $currentUrlScheme)) {
6621 $targetDomain = $currentDomain;
6623 // If go for an absolute link, add site path if it's not taken care about by absRefPrefix
6624 if (!$tsfe->config[
'config'][
'absRefPrefix'] && $targetDomain == $currentDomain) {
6629 if ($targetDomain !==
'' && $targetDomain !== $currentDomain && !$enableLinksAcrossDomains) {
6630 $target = isset($conf[
'extTarget']) ? $conf[
'extTarget'] : $tsfe->extTarget;
6631 if ($conf[
'extTarget.']) {
6632 $target = $this->
stdWrap($target, $conf[
'extTarget.']);
6635 $target = $forceTarget;
6637 $LD[
'target'] = $target;
6639 if (!preg_match(
'/^[a-z0-9.\\-]*$/i', $targetDomain)) {
6642 $this->lastTypoLinkUrl = $this->
URLqMark(($absoluteUrlScheme .
'://' . $targetDomain .
'/index.php?id=' . $page[
'uid']), $addQueryParams) . $sectionMark;
6646 $target = $forceTarget;
6648 $LD = $tsfe->tmpl->linkData($page, $target, $conf[
'no_cache'],
'',
'', $addQueryParams, $theTypeP, $targetDomain);
6649 if ($targetDomain !==
'') {
6651 if ($enableLinksAcrossDomains && $targetDomain !== $currentDomain) {
6656 $prefixLength = strlen($tsfe->config[
'config'][
'absRefPrefix']);
6657 if (substr($LD[
'totalURL'], 0, $prefixLength) == $tsfe->config[
'config'][
'absRefPrefix']) {
6658 $LD[
'totalURL'] = substr($LD[
'totalURL'], $prefixLength);
6661 $urlParts = parse_url($LD[
'totalURL']);
6662 if ($urlParts[
'host'] ==
'') {
6663 $LD[
'totalURL'] = $absoluteUrlScheme .
'://' . $targetDomain . ($LD[
'totalURL'][0] ==
'/' ?
'' :
'/') . $LD[
'totalURL'];
6666 $this->lastTypoLinkUrl = $this->
URLqMark($LD[
'totalURL'],
'') . $sectionMark;
6668 $this->lastTypoLinkTarget = $LD[
'target'];
6669 $targetPart = $LD[
'target'] ?
' target="' . htmlspecialchars($LD[
'target']) .
'"' :
'';
6671 if ($sectionMark && !$tsfe->config[
'config'][
'baseURL'] && $page[
'uid'] == $tsfe->id && !trim($addQueryParams) && !($conf[
'addQueryString'] && $conf[
'addQueryString.'])) {
6673 if (!trim($currentQueryParams)) {
6674 list(, $URLparams) = explode(
'?', $this->lastTypoLinkUrl);
6675 list($URLparams) = explode(
'#', $URLparams);
6676 parse_str($URLparams . $LD[
'orig_type'], $URLparamsArray);
6678 if ((
int)$URLparamsArray[
'type'] == $tsfe->type) {
6679 unset($URLparamsArray[
'id']);
6680 unset($URLparamsArray[
'type']);
6682 if (empty($URLparamsArray)) {
6683 $this->lastTypoLinkUrl = $sectionMark;
6689 if (empty($conf[
'linkAccessRestrictedPages']) && $tsfe->config[
'config'][
'typolinkLinkAccessRestrictedPages'] && $tsfe->config[
'config'][
'typolinkLinkAccessRestrictedPages'] !==
'NONE' && !$tsfe->checkPageGroupAccess($page)) {
6690 $thePage = $tsfe->sys_page->getPage($tsfe->config[
'config'][
'typolinkLinkAccessRestrictedPages']);
6691 $addParams = str_replace(
6697 rawurlencode($this->lastTypoLinkUrl),
6700 $tsfe->config[
'config'][
'typolinkLinkAccessRestrictedPages_addParams']
6702 $this->lastTypoLinkUrl = $this->
getTypoLink_URL($thePage[
'uid'] . ($theTypeP ?
',' . $theTypeP :
''), $addParams, $target);
6703 $this->lastTypoLinkUrl = $this->
forceAbsoluteUrl($this->lastTypoLinkUrl, $conf);
6709 $finalTagParts[
'targetParams'] = $targetPart;
6711 $this->
getTimeTracker()->setTSlogMessage(
'typolink(): Page id \'' . $linkParameter .
'\' was not found, so \
'' . $linktxt .
'\' was not linked.
', 1);
6717 $finalTagParts['TYPE
'] = $linkType;
6718 $this->lastTypoLinkLD = $LD;
6721 $title = $forceTitle;
6724 if ($JSwindowParams) {
6725 // Create TARGET-attribute only if the right doctype is used
6726 if (!GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2
', $tsfe->xhtmlDoctype)) {
6727 $target = ' target=
"FEopenLink"';
6731 $onClick = 'vHWin=window.open(
' . GeneralUtility::quoteJSvalue($tsfe->baseUrlWrap($finalTagParts['url
'])) . ',\
'FEopenLink\',' .
GeneralUtility::quoteJSvalue($JSwindowParams) .
');vHWin.focus();return false;';
6732 $finalAnchorTag =
'<a href="' . htmlspecialchars($finalTagParts[
'url']) .
'"' . $target .
' onclick="' . htmlspecialchars($onClick) .
'"' . ($title ?
' title="' . htmlspecialchars($title) .
'"' :
'') . ($linkClass ?
' class="' . $linkClass .
'"' :
'') . $finalTagParts[
'aTagParams'] .
'>';
6734 if ($tsfe->spamProtectEmailAddresses ===
'ascii' && $linkType ===
'mailto') {
6735 $finalAnchorTag =
'<a href="' . $finalTagParts[
'url'] .
'"';
6737 $finalAnchorTag =
'<a href="' . htmlspecialchars($finalTagParts[
'url']) .
'"';
6739 $finalAnchorTag .= ($title ?
' title="' . htmlspecialchars($title) .
'"' :
'') . $finalTagParts[
'targetParams'] . ($linkClass ?
' class="' . $linkClass .
'"' :
'') . $finalTagParts[
'aTagParams'] .
'>';
6743 if ($conf[
'userFunc']) {
6744 $finalTagParts[
'TAG'] = $finalAnchorTag;
6745 $finalAnchorTag = $this->
callUserFunction($conf[
'userFunc'], $conf[
'userFunc.'], $finalTagParts);
6749 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typoLink_PostProc']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typoLink_PostProc'])) {
6752 'linktxt' => &$linktxt,
6753 'finalTag' => &$finalAnchorTag,
6754 'finalTagParts' => &$finalTagParts
6756 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typoLink_PostProc'] as $_funcRef) {
6762 if ($conf[
'returnLast']) {
6763 switch ($conf[
'returnLast']) {
6773 $wrap = isset($conf[
'wrap.']) ? $this->
stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
6775 if ($conf[
'ATagBeforeWrap']) {
6776 return $finalAnchorTag . $this->
wrap($linktxt, $wrap) .
'</a>';
6778 return $this->
wrap($finalAnchorTag . $linktxt .
'</a>', $wrap);
6790 if (!empty(
$url) && !empty($configuration[
'forceAbsoluteUrl']) && preg_match(
'#^(?:([a-z]+)(://)([^/]*)/?)?(.*)$#',
$url, $matches)) {
6792 'scheme' => $matches[1],
6793 'delimiter' =>
'://',
6794 'host' => $matches[3],
6795 'path' => $matches[4]
6797 $isUrlModified =
false;
6799 if (empty($urlParts[
'host'])) {
6800 $urlParts[
'scheme'] =
'http';
6802 $urlParts[
'path'] =
'/' . ltrim($urlParts[
'path'],
'/');
6809 $isUrlModified =
true;
6812 $forceAbsoluteUrl = &$configuration[
'forceAbsoluteUrl.'][
'scheme'];
6813 if (!empty($forceAbsoluteUrl) && $urlParts[
'scheme'] !== $forceAbsoluteUrl) {
6814 $urlParts[
'scheme'] = $forceAbsoluteUrl;
6815 $isUrlModified =
true;
6818 if ($isUrlModified) {
6819 $url = implode(
'', $urlParts);
6834 $this->typoLink(
'|', $conf);
6851 public function getTypoLink($label, $params, $urlParameters = array(), $target =
'')
6854 $conf[
'parameter'] = $params;
6856 $conf[
'target'] = $target;
6857 $conf[
'extTarget'] = $target;
6858 $conf[
'fileTarget'] = $target;
6860 if (is_array($urlParameters)) {
6861 if (!empty($urlParameters)) {
6865 $conf[
'additionalParams'] .= $urlParameters;
6867 $out = $this->typoLink($label, $conf);
6882 if ($addQueryString) {
6883 $conf[
'addQueryString'] =
'1';
6885 $conf[
'addQueryString.'] = array(
6887 'exclude' =>
'id,type,cHash' . ($linkVars ?
',' . $linkVars :
'')
6906 $this->
getTypoLink(
'', $params, $urlParameters, $target);
6919 $k = md5(microtime());
6920 return explode($k, $this->typoLink($k, $conf));
6934 return $this->
getTypoLink_URL($id ?: $tsfe->id, $urlParameters, $tsfe->sPre);
6946 protected function processUrl($context,
$url, $typolinkConfiguration = array())
6949 empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'urlProcessing'][
'urlProcessors'])
6950 || !is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'urlProcessing'][
'urlProcessors'])
6955 $urlProcessors =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'urlProcessing'][
'urlProcessors'];
6956 foreach ($urlProcessors as $identifier => $configuration) {
6957 if (empty($configuration) || !is_array($configuration)) {
6958 throw new \RuntimeException(
'Missing configuration for URI processor "' . $identifier .
'".', 1442050529);
6960 if (!is_string($configuration[
'processor']) || empty($configuration[
'processor']) || !class_exists($configuration[
'processor']) || !is_subclass_of($configuration[
'processor'], UrlProcessorInterface::class)) {
6961 throw new \RuntimeException(
'The URI processor "' . $identifier .
'" defines an invalid provider. Ensure the class exists and implements the "' . UrlProcessorInterface::class .
'".', 1442050579);
6966 $keepProcessing =
true;
6968 foreach ($orderedProcessors as $configuration) {
6971 $url = $urlProcessor->process($context,
$url, $typolinkConfiguration, $this, $keepProcessing);
6972 if (!$keepProcessing) {
6992 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'enable_mount_pids']) || !$tsfe->MP) {
6998 if ((
int)$tsfe->id === (
int)$pageId) {
7003 $tCR_rootline = $tsfe->sys_page->getRootLine($pageId,
'',
true);
7004 $inverseTmplRootline = array_reverse($tsfe->tmpl->rootLine);
7005 $rl_mpArray = array();
7006 $startMPaccu =
false;
7008 foreach ($tCR_rootline as $tCR_data) {
7009 foreach ($inverseTmplRootline as $rlKey => $invTmplRLRec) {
7011 if ($invTmplRLRec[
'_MOUNT_OL'] && $tCR_data[
'uid'] == $invTmplRLRec[
'uid']) {
7012 $startMPaccu =
true;
7015 if ($startMPaccu && $invTmplRLRec[
'_MP_PARAM']) {
7016 $rl_mpArray[] = $invTmplRLRec[
'_MP_PARAM'];
7021 if ($tCR_data[
'pid'] == $invTmplRLRec[
'pid'] && count($inverseTmplRootline) !== $rlKey + 1) {
7022 $startMPaccu =
true;
7030 if (!empty($rl_mpArray)) {
7031 $MP = implode(
',', array_reverse($rl_mpArray));
7034 return $raw ? $MP : ($MP ?
'&MP=' . rawurlencode($MP) :
'');
7048 if ((
string)$linktxt ===
'') {
7049 $linktxt = $mailAddress;
7052 $originalMailToUrl =
'mailto:' . $mailAddress;
7057 if ($mailToUrl === $originalMailToUrl) {
7058 if ($tsfe->spamProtectEmailAddresses) {
7059 if ($tsfe->spamProtectEmailAddresses ===
'ascii') {
7060 $mailToUrl = $tsfe->encryptEmail($mailToUrl);
7065 if ($tsfe->config[
'config'][
'spamProtectEmailAddresses_atSubst']) {
7066 $atLabel = trim($tsfe->config[
'config'][
'spamProtectEmailAddresses_atSubst']);
7068 $spamProtectedMailAddress = str_replace(
'@', $atLabel ? $atLabel :
'(at)', $mailAddress);
7069 if ($tsfe->config[
'config'][
'spamProtectEmailAddresses_lastDotSubst']) {
7070 $lastDotLabel = trim($tsfe->config[
'config'][
'spamProtectEmailAddresses_lastDotSubst']);
7071 $lastDotLabel = $lastDotLabel ? $lastDotLabel :
'(dot)';
7072 $spamProtectedMailAddress = preg_replace(
'/\\.([^\\.]+)$/', $lastDotLabel .
'$1', $spamProtectedMailAddress);
7074 $linktxt = str_ireplace($mailAddress, $spamProtectedMailAddress, $linktxt);
7078 return array($mailToUrl, $linktxt);
7090 public function getQueryArguments($conf, $overruleQueryArguments = array(), $forceOverruleArguments =
false)
7092 switch ((
string)$conf[
'method']) {
7110 if ($conf[
'exclude']) {
7111 $exclude = str_replace(
',',
'&', $conf[
'exclude']);
7117 $newQueryArray = $currentQueryArray;
7119 if ($forceOverruleArguments) {
7143 public function wrap($content, $wrap, $char =
'|')
7146 $wrapArr = explode($char, $wrap);
7147 $content = trim($wrapArr[0]) . $content . trim($wrapArr[1]);
7165 $wrapArr = explode($char, $wrap);
7166 $content = $wrapArr[1] . $content . $wrapArr[2];
7179 public function wrapSpace($content, $wrap, array $conf = null)
7182 $wrapArray = explode(
'|', $wrap);
7183 $wrapBefore = (int)$wrapArray[0];
7184 $wrapAfter = (int)$wrapArray[1];
7185 $useDivTag = isset($conf[
'useDiv']) && $conf[
'useDiv'];
7188 $content =
'<div class="content-spacer spacer-before" style="height:' . $wrapBefore .
'px;"></div>' . $content;
7190 $content =
'<span style="width: 1px; height: ' . $wrapBefore .
'px; display: inline-block;"></span><br />' . $content;
7195 $content .=
'<div class="content-spacer spacer-after" style="height:' . $wrapAfter .
'px;"></div>';
7197 $content .=
'<span style="width: 1px; height: ' . $wrapAfter .
'px; display: inline-block;"></span><br />';
7217 $parts = explode(
'->', $funcName);
7218 if (count($parts) === 2) {
7223 if (is_object($classObj) && method_exists($classObj, $parts[1])) {
7224 $classObj->cObj = $this;
7225 $content = call_user_func_array(array(
7233 $this->
getTimeTracker()->setTSlogMessage(
'Method "' . $parts[1] .
'" did not exist in class "' . $parts[0] .
'"', 3);
7236 $this->
getTimeTracker()->setTSlogMessage(
'Class "' . $parts[0] .
'" did not exist', 3);
7238 }
elseif (function_exists($funcName)) {
7239 $content = call_user_func($funcName, $content, $conf);
7241 $this->
getTimeTracker()->setTSlogMessage(
'Function "' . $funcName .
'" did not exist', 3);
7255 $paramArr = array();
7257 foreach ($lines as $val) {
7258 $pair = explode(
'=', $val, 2);
7259 $pair[0] = trim($pair[0]);
7261 $paramArr[$pair[0]] = trim($pair[1]);
7275 $listArr = preg_split(
'/[,;' . LF .
']/', $content);
7276 foreach ($listArr as $k => $v) {
7277 $listArr[$k] = trim($v);
7279 return implode(
',', $listArr);
7293 switch (strtolower($case)) {
7295 $theValue = $tsfe->csConvObj->conv_case($tsfe->renderCharset, $theValue,
'toUpper');
7298 $theValue = $tsfe->csConvObj->conv_case($tsfe->renderCharset, $theValue,
'toLower');
7301 $theValue = ucwords($theValue);
7304 $theValue = $tsfe->csConvObj->convCaseFirst($tsfe->renderCharset, $theValue,
'toUpper');
7307 $theValue = $tsfe->csConvObj->convCaseFirst($tsfe->renderCharset, $theValue,
'toLower');
7309 case 'uppercamelcase':
7312 case 'lowercamelcase':
7332 $totalLen = strlen($theValue);
7335 $len = strcspn(substr($theValue, $pointer),
'<');
7336 $newVal .= $this->
caseshift(substr($theValue, $pointer, $len), $case);
7339 $len = strcspn(substr($theValue, $pointer),
'>') + 1;
7340 $newVal .= substr($theValue, $pointer, $len);
7344 }
while ($pointer < $totalLen);
7358 $labels =
' min| hrs| days| yrs| min| hour| day| year';
7360 $labels = str_replace(
'"',
'', $labels);
7362 $labelArr = explode(
'|', $labels);
7363 if (count($labelArr) === 4) {
7364 $labelArr = array_merge($labelArr, $labelArr);
7366 $absSeconds = abs($seconds);
7367 $sign = $seconds > 0 ? 1 : -1;
7368 if ($absSeconds < 3600) {
7369 $val =
round($absSeconds / 60);
7370 $seconds = $sign * $val . ($val == 1 ? $labelArr[4] : $labelArr[0]);
7371 }
elseif ($absSeconds < 24 * 3600) {
7372 $val =
round($absSeconds / 3600);
7373 $seconds = $sign * $val . ($val == 1 ? $labelArr[5] : $labelArr[1]);
7374 }
elseif ($absSeconds < 365 * 24 * 3600) {
7375 $val =
round($absSeconds / (24 * 3600));
7376 $seconds = $sign * $val . ($val == 1 ? $labelArr[6] : $labelArr[2]);
7378 $val =
round($absSeconds / (365 * 24 * 3600));
7379 $seconds = $sign * $val . ($val == 1 ? $labelArr[7] : $labelArr[3]);
7395 public function sendNotifyEmail($message, $recipients, $cc, $senderAddress, $senderName =
'', $replyTo =
'')
7399 $senderName = trim($senderName);
7400 $senderAddress = trim($senderAddress);
7401 if ($senderName !==
'' && $senderAddress !==
'') {
7402 $sender = array($senderAddress => $senderName);
7403 }
elseif ($senderAddress !==
'') {
7404 $sender = array($senderAddress);
7408 $mail->setFrom($sender);
7409 $parsedReplyTo = MailUtility::parseAddresses($replyTo);
7410 if (!empty($parsedReplyTo)) {
7411 $mail->setReplyTo($parsedReplyTo);
7413 $message = trim($message);
7414 if ($message !==
'') {
7416 $messageParts = explode(LF, $message, 2);
7417 $subject = trim($messageParts[0]);
7418 $plainMessage = trim($messageParts[1]);
7419 $parsedRecipients = MailUtility::parseAddresses($recipients);
7420 if (!empty($parsedRecipients)) {
7421 $mail->setTo($parsedRecipients)
7422 ->setSubject($subject)
7423 ->setBody($plainMessage);
7426 $parsedCc = MailUtility::parseAddresses($cc);
7427 if (!empty($parsedCc)) {
7430 if (!empty($parsedReplyTo)) {
7431 $mail->setReplyTo($parsedReplyTo);
7433 $mail->setFrom($sender)
7435 ->setSubject($subject)
7436 ->setBody($plainMessage);
7453 if ($params && !strstr(
$url,
'?')) {
7454 return $url .
'?' . $params;
7456 return $url . $params;
7470 $list = explode(
',', $propList);
7471 foreach (
$list as $prop) {
7472 $prop = trim($prop);
7473 unset($TSArr[$prop]);
7474 unset($TSArr[$prop .
'.']);
7489 if ($confArr[$prop][0] ===
'<') {
7490 $key = trim(substr($confArr[$prop], 1));
7493 $old_conf = $confArr[$prop .
'.'];
7495 if (is_array($old_conf) && !empty($old_conf)) {
7496 $conf = is_array($conf) ? array_replace_recursive($conf, $old_conf) : $old_conf;
7498 $confArr[$prop .
'.'] = $conf;
7513 $chars = (int)$conf[
'chars'] ?: 20;
7514 $lineDist = (int)$conf[
'lineDist'] ?: 20;
7515 $Valign = strtolower(trim($conf[
'Valign']));
7516 $tmplObjNumber = (int)$conf[
'tmplObjNumber'];
7517 $maxLines = (int)$conf[
'maxLines'];
7518 if ($tmplObjNumber && $gifbuilderConf[$tmplObjNumber] ==
'TEXT') {
7519 $textArr = $this->
linebreaks($text, $chars, $maxLines);
7520 $angle = (int)$gifbuilderConf[$tmplObjNumber .
'.'][
'angle'];
7521 foreach ($textArr as $c => $textChunk) {
7522 $index = $tmplObjNumber + 1 + $c * 2;
7525 $rad_angle = 2 * pi() / 360 * $angle;
7526 $x_d = sin($rad_angle) * $lineDist;
7527 $y_d = cos($rad_angle) * $lineDist;
7530 if ($Valign ==
'center') {
7531 $diff_x_d = $x_d * count($textArr);
7532 $diff_x_d = $diff_x_d / 2;
7533 $diff_y_d = $y_d * count($textArr);
7534 $diff_y_d = $diff_y_d / 2;
7536 $x_d =
round($x_d * $c - $diff_x_d);
7537 $y_d =
round($y_d * $c - $diff_y_d);
7538 $gifbuilderConf[$index] =
'WORKAREA';
7539 $gifbuilderConf[$index .
'.'][
'set'] = $x_d .
',' . $y_d;
7543 $gifbuilderConf[$index] =
'TEXT';
7544 $gifbuilderConf[$index .
'.'] = $this->
clearTSProperties($gifbuilderConf[$tmplObjNumber .
'.'],
'text');
7545 $gifbuilderConf[$index .
'.'][
'text'] = $textChunk;
7549 return $gifbuilderConf;
7564 $lines = explode(LF, $string);
7567 foreach ($lines as $paragraph) {
7568 $words = explode(
' ', $paragraph);
7569 foreach ($words as $word) {
7570 if (strlen($lineArr[$c] . $word) > $chars) {
7573 if (!$maxLines || $c < $maxLines) {
7574 $lineArr[$c] .= $word .
' ';
7590 $librariesIncluded =
false;
7591 if (isset($config[
'includeLibs']) && $config[
'includeLibs']) {
7594 $librariesIncluded =
true;
7596 return $librariesIncluded;
7620 if (class_exists($className)) {
7625 if (isset($pluginConfiguration[
'includeLibs']) && $pluginConfiguration[
'includeLibs']) {
7626 $config[
'includeLibs'] = $pluginConfiguration[
'includeLibs'];
7656 $updateFields = array();
7658 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
7659 $updateFields[$GLOBALS[
'TCA'][
$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
7662 return $db->exec_UPDATEquery($table,
'uid=' . $uid, $updateFields);
7664 return $db->UPDATEquery($table,
'uid=' . $uid, $updateFields);
7667 return $db->exec_DELETEquery($table,
'uid=' . $uid);
7669 return $db->DELETEquery($table,
'uid=' . $uid);
7690 unset($dataArr[
'uid']);
7694 $updateFields = array();
7695 foreach ($dataArr as $f => $v) {
7697 $updateFields[$f] = $v;
7701 $updateFields[
$GLOBALS[
'TCA'][
$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
7703 if (!empty($updateFields)) {
7732 $dataArr[$field] =
$GLOBALS[
'EXEC_TIME'];
7733 $extraList .=
',' . $field;
7735 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']) {
7737 $dataArr[$field] =
$GLOBALS[
'EXEC_TIME'];
7738 $extraList .=
',' . $field;
7740 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']) {
7742 $dataArr[$field] = 0;
7743 $extraList .=
',' . $field;
7745 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_cruser_id']) {
7748 $extraList .=
',' . $field;
7750 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_crgroup_id']) {
7753 $dataArr[$field] = (int)$dataArr[$field];
7754 $extraList .=
',' . $field;
7757 unset($dataArr[
'uid']);
7759 $dataArr[
'pid'] = $pid;
7763 $insertFields = array();
7764 foreach ($dataArr as $f => $v) {
7766 $insertFields[$f] = $v;
7794 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_cruser_id']) {
7795 $rowFEUser = (int)$row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_cruser_id']];
7796 if ($rowFEUser && $rowFEUser == $feUserRow[
'uid']) {
7801 if ($feEditSelf && $table ==
'fe_users' && (
int)$feUserRow[
'uid'] === (int)$row[
'uid']) {
7805 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_crgroup_id']) {
7806 $rowFEUser = (int)$row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_crgroup_id']];
7836 $OR_arr[] =
$GLOBALS[
'TCA'][
$table][
'ctrl'][
'fe_cruser_id'] .
'=' . $feUserRow[
'uid'];
7839 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_crgroup_id']) {
7841 foreach ($values as $theGroupUid) {
7843 $OR_arr[] =
$GLOBALS[
'TCA'][
$table][
'ctrl'][
'fe_crgroup_id'] .
'=' . $theGroupUid;
7848 if ($feEditSelf && $table ==
'fe_users') {
7849 $OR_arr[] =
'uid=' . (int)$feUserRow[
'uid'];
7851 $whereDef =
' AND 1=0';
7852 if (!empty($OR_arr)) {
7853 $whereDef =
' AND (' . implode(
' OR ', $OR_arr) .
')';
7854 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'fe_admin_lock']) {
7855 $whereDef .=
' AND ' .
$GLOBALS[
'TCA'][
$table][
'ctrl'][
'fe_admin_lock'] .
'=0';
7879 $show_hidden = $show_hidden ?: (
$table ===
'pages' ? $tsfe->showHiddenPage : $tsfe->showHiddenRecords);
7880 return $tsfe->sys_page->enableFields(
$table, $show_hidden, $ignore_array);
7909 public function getTreeList($id, $depth, $begin = 0, $dontCheckEnableFields =
false, $addSelectFields =
'', $moreWhereClauses =
'', array $prevId_array = array(), $recursionLevel = 0)
7917 $allFields =
'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state' . $addSelectFields;
7918 $depth = (int)$depth;
7919 $begin = (int)$begin;
7927 if (!$recursionLevel) {
7934 $dontCheckEnableFields,
7941 $cacheEntry = $db->exec_SELECTgetSingleRow(
7944 'md5hash = \'' . $requestHash .
'\' AND ( expires >
' . $GLOBALS['EXEC_TIME
'] . ' OR expires = 0 )
'
7946 if (is_array($cacheEntry)) {
7948 return $cacheEntry['treelist
'];
7950 // If Id less than zero it means we should add the real id to list:
7952 $addId = ($id = abs($id));
7954 // Check start page:
7955 if ($tsfe->sys_page->getRawRecord('pages
', $id, 'uid
')) {
7956 // Find mount point if any:
7957 $mount_info = $tsfe->sys_page->getMountPointInfo($id);
7958 if (is_array($mount_info)) {
7959 $id = $mount_info['mount_pid
'];
7960 // In Overlay mode, use the mounted page uid as added ID!:
7961 if ($addId && $mount_info['overlay
']) {
7966 // Return blank if the start page was NOT found at all!
7970 // Add this ID to the array of IDs
7972 $prevId_array[] = $id;
7976 $rows = $db->exec_SELECTgetRows(
7979 'pid =
' . (int)$id . ' AND deleted = 0
' . $moreWhereClauses,
7983 if (is_array($rows)) {
7984 foreach ($rows as $row) {
7986 $versionState = VersionState::cast($row['t3ver_state
']);
7987 $tsfe->sys_page->versionOL('pages
', $row);
7988 if ($row['doktype
'] == PageRepository::DOKTYPE_RECYCLER
7989 || $row['doktype
'] == PageRepository::DOKTYPE_BE_USER_SECTION
7990 || $versionState->indicatesPlaceholder()
7992 // Doing this after the overlay to make sure changes
7993 // in the overlay are respected.
7994 // However, we do not process pages below of and
7995 // including of type recycler and BE user section
7998 // Find mount point if any:
7999 $next_id = $row['uid
'];
8000 $mount_info = $tsfe->sys_page->getMountPointInfo($next_id, $row);
8002 if (is_array($mount_info) && $mount_info['overlay
']) {
8003 $next_id = $mount_info['mount_pid
'];
8004 $row = $db->exec_SELECTgetSingleRow(
8007 'uid =
' . (int)$next_id . ' AND deleted = 0
' . $moreWhereClauses,
8011 $tsfe->sys_page->versionOL('pages
', $row);
8012 if ($row['doktype
'] == PageRepository::DOKTYPE_RECYCLER
8013 || $row['doktype
'] == PageRepository::DOKTYPE_BE_USER_SECTION
8014 || $versionState->indicatesPlaceholder()
8016 // Doing this after the overlay to make sure
8017 // changes in the overlay are respected.
8023 if ($dontCheckEnableFields || $tsfe->checkPagerecordForIncludeSection($row)) {
8026 if ($dontCheckEnableFields || $tsfe->checkEnableFields($row)) {
8027 $theList[] = $next_id;
8031 if ($depth > 1 && !$row['php_tree_stop
']) {
8033 if (is_array($mount_info) && !$mount_info['overlay
']) {
8034 $next_id = $mount_info['mount_pid
'];
8036 // Call recursively, if the id is not in prevID_array:
8037 if (!in_array($next_id, $prevId_array)) {
8038 $theList = array_merge(
8039 GeneralUtility::intExplode(
8041 $this->getTreeList($next_id, $depth - 1, $begin - 1,
8042 $dontCheckEnableFields, $addSelectFields, $moreWhereClauses,
8043 $prevId_array, $recursionLevel + 1),
8054 // If first run, check if the ID should be returned:
8055 if (!$recursionLevel) {
8060 $theList[] = $addId;
8063 $db->exec_INSERTquery('cache_treelist
', array(
8064 'md5hash
' => $requestHash,
8066 'treelist
' => implode(',
', $theList),
8067 'tstamp
' => $GLOBALS['EXEC_TIME
']
8071 return implode(',
', $theList);
8088 public function exec_mm_query($select, $local_table, $mm_table, $foreign_table, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '')
8090 return $this->getDatabaseConnection()->exec_SELECTquery(
8092 $local_table . ',
' . $mm_table . ($foreign_table ? ',
' . $foreign_table : ''),
8093 $local_table . '.uid=
' . $mm_table . '.uid_local
' . ($foreign_table ? ' AND
' . $foreign_table . '.uid=
' . $mm_table . '.uid_foreign
' : '') . $whereClause,
8115 public function exec_mm_query_uidList($select, $local_table_uidlist, $mm_table, $foreign_table = '', $whereClause = '', $groupBy = '', $orderBy = '', $limit = '')
8117 return $this->getDatabaseConnection()->exec_SELECTquery(
8119 $mm_table . ($foreign_table ? ',
' . $foreign_table : ''),
8120 $mm_table . '.uid_local IN (
' . $local_table_uidlist . ')
' . ($foreign_table ? ' AND
' . $foreign_table . '.uid=
' . $mm_table . '.uid_foreign
' : '') . $whereClause,
8136 public function searchWhere($sw, $searchFieldList, $searchTable = '')
8138 $prefixTableName = $searchTable ? $searchTable . '.
' : '';
8141 $searchFields = explode(',
', $searchFieldList);
8142 $kw = preg_split('/[ ,]/
', $sw);
8143 $db = $this->getDatabaseConnection();
8144 foreach ($kw as $val) {
8147 if (strlen($val) >= 2) {
8148 $val = $db->escapeStrForLike($db->quoteStr($val, $searchTable), $searchTable);
8149 foreach ($searchFields as $field) {
8150 $where_p[] = $prefixTableName . $field . ' LIKE \
'%' . $val .
'%\'';
8153 if (!empty($where_p)) {
8154 $where .=
' AND (' . implode(
' OR ', $where_p) .
')';
8170 public function exec_getQuery($table, $conf)
8172 $queryParts = $this->getQuery($table, $conf,
true);
8173 return $this->getDatabaseConnection()->exec_SELECT_queryArray($queryParts);
8184 public function getRecords($tableName, array $queryConfiguration)
8188 $res = $this->exec_getQuery($tableName, $queryConfiguration);
8190 $db = $this->getDatabaseConnection();
8191 if ($error = $db->sql_error()) {
8192 $this->getTimeTracker()->setTSlogMessage($error, 3);
8194 $tsfe = $this->getTypoScriptFrontendController();
8195 while (($row = $db->sql_fetch_assoc($res)) !==
false) {
8198 $tsfe->sys_page->versionOL($tableName, $row,
true);
8201 if (is_array($row) && $tsfe->sys_language_contentOL) {
8202 if ($tableName ===
'pages') {
8203 $row = $tsfe->sys_page->getPageOverlay($row);
8205 $row = $tsfe->sys_page->getRecordOverlay(
8208 $tsfe->sys_language_content,
8209 $tsfe->sys_language_contentOL
8215 if (is_array($row)) {
8219 $db->sql_free_result($res);
8236 public function getQuery($table, $conf, $returnQueryArray =
false)
8239 $properties = array(
8254 foreach ($properties as $property) {
8255 $conf[$property] = trim(isset($conf[$property .
'.'])
8256 ? $this->stdWrap($conf[$property], $conf[$property .
'.'])
8259 if ($conf[$property] ===
'') {
8260 unset($conf[$property]);
8262 if (isset($conf[$property .
'.'])) {
8264 unset($conf[$property .
'.']);
8268 $queryMarkers = $this->getQueryMarkers($table, $conf);
8270 foreach ($queryMarkers as $marker => $markerValue) {
8271 $properties = array(
8283 foreach ($properties as $property) {
8284 if ($conf[$property]) {
8285 $conf[$property] = str_replace(
'###' . $marker .
'###', $markerValue, $conf[$property]);
8291 if (isset($conf[
'recursive'])) {
8292 $conf[
'recursive'] = (int)$conf[
'recursive'];
8293 if ($conf[
'recursive'] > 0) {
8294 $pidList = GeneralUtility::trimExplode(
',', $conf[
'pidInList'],
true);
8295 array_walk($pidList,
function (&$storagePid) {
8296 if ($storagePid ===
'this') {
8297 $storagePid = $this->getTypoScriptFrontendController()->id;
8299 if ($storagePid > 0) {
8300 $storagePid = -$storagePid;
8303 $expandedPidList = array();
8304 foreach ($pidList as $value) {
8307 $expandedPidList = array_merge(
8308 GeneralUtility::intExplode(
',', $this->getTreeList($value, $conf[
'recursive'])),
8312 $conf[
'pidInList'] = implode(
',', $expandedPidList);
8315 if ((
string)$conf[
'pidInList'] ===
'') {
8316 $conf[
'pidInList'] =
'this';
8318 $queryParts = $this->getWhere($table, $conf,
true);
8320 if ($conf[
'selectFields']) {
8321 $queryParts[
'SELECT'] = $this->sanitizeSelectPart($conf[
'selectFields'], $table);
8323 $queryParts[
'SELECT'] =
'*';
8326 $db = $this->getDatabaseConnection();
8328 if ($conf[
'max'] || $conf[
'begin']) {
8330 if (strstr(strtolower($conf[
'begin'] . $conf[
'max']),
'total')) {
8331 $res = $db->exec_SELECTquery(
'count(*)', $table, $queryParts[
'WHERE'], $queryParts[
'GROUPBY']);
8332 if ($error = $db->sql_error()) {
8333 $this->getTimeTracker()->setTSlogMessage($error);
8335 $row = $db->sql_fetch_row($res);
8336 $conf[
'max'] = str_ireplace(
'total', $row[0], $conf[
'max']);
8337 $conf[
'begin'] = str_ireplace(
'total', $row[0], $conf[
'begin']);
8339 $db->sql_free_result($res);
8342 $conf[
'begin'] = MathUtility::forceIntegerInRange(ceil($this->calc($conf[
'begin'])), 0);
8343 $conf[
'max'] = MathUtility::forceIntegerInRange(ceil($this->calc($conf[
'max'])), 0);
8344 if ($conf[
'begin'] && !$conf[
'max']) {
8345 $conf[
'max'] = 100000;
8347 if ($conf[
'begin'] && $conf[
'max']) {
8348 $queryParts[
'LIMIT'] = $conf[
'begin'] .
',' . $conf[
'max'];
8349 }
elseif (!$conf[
'begin'] && $conf[
'max']) {
8350 $queryParts[
'LIMIT'] = $conf[
'max'];
8357 if ($conf[
'join']) {
8358 $joinPart =
'JOIN ' . $conf[
'join'];
8359 }
elseif ($conf[
'leftjoin']) {
8360 $joinPart =
'LEFT OUTER JOIN ' . $conf[
'leftjoin'];
8361 }
elseif ($conf[
'rightjoin']) {
8362 $joinPart =
'RIGHT OUTER JOIN ' . $conf[
'rightjoin'];
8365 $queryParts[
'FROM'] = trim($table .
' ' . $joinPart);
8368 foreach ($queryMarkers as $marker => $markerValue) {
8369 foreach ($queryParts as $queryPartKey => &$queryPartValue) {
8370 $queryPartValue = str_replace(
'###' . $marker .
'###', $markerValue, $queryPartValue);
8372 unset($queryPartValue);
8374 $query = $db->SELECTquery($queryParts[
'SELECT'], $queryParts[
'FROM'], $queryParts[
'WHERE'], $queryParts[
'GROUPBY'], $queryParts[
'ORDERBY'], $queryParts[
'LIMIT']);
8375 return $returnQueryArray ? $queryParts : $query;
8390 public function getWhere($table, $conf, $returnQueryArray =
false)
8395 $enableFieldsIgnore = array();
8396 $queryParts = array(
8404 $tsfe = $this->getTypoScriptFrontendController();
8405 $considerMovePlaceholders = (
8406 $tsfe->sys_page->versioningPreview && $table !==
'pages'
8407 && !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'])
8409 if (trim($conf[
'uidInList'])) {
8410 $listArr = GeneralUtility::intExplode(
',', str_replace(
'this', $tsfe->contentPid, $conf[
'uidInList']));
8411 if (count($listArr) === 1) {
8412 $comparison =
'=' . (int)$listArr[0];
8414 $comparison =
' IN (' . implode(
',', $this->getDatabaseConnection()->cleanIntArray($listArr)) .
')';
8417 if ($considerMovePlaceholders) {
8418 $movePlaceholderComparison = $table .
'.t3ver_state=' . VersionState::cast(VersionState::MOVE_PLACEHOLDER) .
' AND ' . $table .
'.t3ver_move_id' . $comparison;
8419 $query .=
' AND (' . $table .
'.uid' . $comparison .
' OR ' . $movePlaceholderComparison .
')';
8421 $query .=
' AND ' . $table .
'.uid' . $comparison;
8426 if (substr($table, 0, 7) ==
'static_') {
8429 if (trim($conf[
'pidInList'])) {
8430 $listArr = GeneralUtility::intExplode(
',', str_replace(
'this', $tsfe->contentPid, $conf[
'pidInList']));
8432 $listArr = $this->checkPidArray($listArr);
8433 if (GeneralUtility::inList($conf[
'pidInList'],
'root')) {
8436 if (GeneralUtility::inList($conf[
'pidInList'],
'-1')) {
8438 $enableFieldsIgnore[
'pid'] =
true;
8440 if (!empty($listArr)) {
8441 $query .=
' AND ' . $table .
'.pid IN (' . implode(
',', array_map(
'intval', $listArr)) .
')';
8449 if (!$pid_uid_flag) {
8450 $query .=
' AND ' . $table .
'.uid=0';
8452 $where = isset($conf[
'where.']) ? trim($this->stdWrap($conf[
'where'], $conf[
'where.'])) : trim($conf[
'where']);
8454 $query .=
' AND ' . $where;
8458 $languageField =
'';
8459 if (!empty($conf[
'languageField']) || !isset($conf[
'languageField'])) {
8460 if (isset($conf[
'languageField']) && !empty(
$GLOBALS[
'TCA'][$table][
'columns'][$conf[
'languageField']])) {
8461 $languageField = $conf[
'languageField'];
8462 }
elseif (!empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) && !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'])) {
8463 $languageField = $table .
'.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
8467 if (!empty($languageField)) {
8469 $sys_language_content = (int)$tsfe->sys_language_content;
8471 if ($tsfe->sys_language_contentOL && !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'])) {
8474 $languageQuery = $languageField .
' IN (0,-1)';
8477 $includeRecordsWithoutDefaultTranslation = isset($conf[
'includeRecordsWithoutDefaultTranslation.']) ?
8478 $this->stdWrap($conf[
'includeRecordsWithoutDefaultTranslation'], $conf[
'includeRecordsWithoutDefaultTranslation.']) :
8479 $conf[
'includeRecordsWithoutDefaultTranslation'];
8480 if (!empty(trim($includeRecordsWithoutDefaultTranslation))) {
8481 $languageQuery .=
' OR (' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] .
' = 0 AND ' .
8482 $languageField .
' = ' . $sys_language_content .
')';
8485 $languageQuery = $languageField .
' = ' . $sys_language_content;
8487 $query .=
' AND (' . $languageQuery .
')';
8489 $andWhere = isset($conf[
'andWhere.']) ? trim($this->stdWrap($conf[
'andWhere'], $conf[
'andWhere.'])) : trim($conf[
'andWhere']);
8491 GeneralUtility::deprecationLog(
'Usage of TypoScript property "andWhere" is deprecated since 7.1 in favor of "where". It has been used to query the table "' . $table .
'".');
8492 $query .=
' AND ' . $andWhere;
8495 if ($table ==
'pages') {
8496 $query .=
' ' . $tsfe->sys_page->where_hid_del . $tsfe->sys_page->where_groupAccess;
8498 $query .= $this->enableFields($table,
false, $enableFieldsIgnore);
8503 $queryParts[
'WHERE'] = trim(substr($query, 4));
8504 $query =
'WHERE ' . $queryParts[
'WHERE'];
8507 if (trim($conf[
'groupBy'])) {
8508 $queryParts[
'GROUPBY'] = isset($conf[
'groupBy.']) ? trim($this->stdWrap($conf[
'groupBy'], $conf[
'groupBy.'])) : trim($conf[
'groupBy']);
8509 $query .=
' GROUP BY ' . $queryParts[
'GROUPBY'];
8512 if (trim($conf[
'orderBy'])) {
8513 $queryParts[
'ORDERBY'] = isset($conf[
'orderBy.']) ? trim($this->stdWrap($conf[
'orderBy'], $conf[
'orderBy.'])) : trim($conf[
'orderBy']);
8514 $query .=
' ORDER BY ' . $queryParts[
'ORDERBY'];
8517 return $returnQueryArray ? $queryParts : $query;
8532 protected function sanitizeSelectPart($selectPart, $table)
8535 $matchStart =
'/(^\\s*|,\\s*|' . $table .
'\\.)';
8536 $matchEnd =
'(\\s*,|\\s*$)/';
8537 $necessaryFields = array(
'uid',
'pid');
8538 $wsFields = array(
't3ver_state');
8539 if (isset(
$GLOBALS[
'TCA'][$table]) && !preg_match(($matchStart .
'\\*' . $matchEnd), $selectPart) && !preg_match(
'/(count|max|min|avg|sum)\\([^\\)]+\\)/i', $selectPart)) {
8540 foreach ($necessaryFields as $field) {
8541 $match = $matchStart . $field . $matchEnd;
8542 if (!preg_match($match, $selectPart)) {
8543 $selectPart .=
', ' . $table .
'.' . $field .
' as ' . $field;
8546 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
8547 foreach ($wsFields as $field) {
8548 $match = $matchStart . $field . $matchEnd;
8549 if (!preg_match($match, $selectPart)) {
8550 $selectPart .=
', ' . $table .
'.' . $field .
' as ' . $field;
8566 public function checkPidArray($listArr)
8568 if (!is_array($listArr) || empty($listArr)) {
8572 $db = $this->getDatabaseConnection();
8573 $res = $db->exec_SELECTquery(
'uid',
'pages',
'uid IN (' . implode(
',', $listArr) .
')' . $this->enableFields(
'pages') .
' AND doktype NOT IN (' . $this->checkPid_badDoktypeList .
')');
8574 if ($error = $db->sql_error()) {
8575 $this->getTimeTracker()->setTSlogMessage($error .
': ' . $db->debug_lastBuiltQuery, 3);
8577 while ($row = $db->sql_fetch_assoc($res)) {
8578 $outArr[] = $row[
'uid'];
8581 $db->sql_free_result($res);
8593 public function checkPid($uid)
8596 if (!isset($this->checkPid_cache[$uid])) {
8597 $count = $this->getDatabaseConnection()->exec_SELECTcountRows(
'uid',
'pages',
'uid=' . $uid . $this->enableFields(
'pages') .
' AND doktype NOT IN (' . $this->checkPid_badDoktypeList .
')');
8598 $this->checkPid_cache[$uid] = (bool)$count;
8600 return $this->checkPid_cache[$uid];
8613 public function getQueryMarkers($table, $conf)
8615 if (!is_array($conf[
'markers.'])) {
8619 $db = $this->getDatabaseConnection();
8620 $markerValues = array();
8621 foreach ($conf[
'markers.'] as $dottedMarker => $dummy) {
8622 $marker = rtrim($dottedMarker,
'.');
8623 if ($dottedMarker != $marker .
'.') {
8627 $tempValue = isset($conf[
'markers.'][$dottedMarker])
8628 ? $this->stdWrap($conf[
'markers.'][$dottedMarker][
'value'], $conf[
'markers.'][$dottedMarker])
8629 : $conf[
'markers.'][$dottedMarker][
'value'];
8631 if (is_numeric($tempValue)) {
8632 if ((
int)$tempValue == $tempValue) {
8634 $markerValues[$marker] = (int)$tempValue;
8637 $markerValues[$marker] = floatval($tempValue);
8639 }
elseif (is_null($tempValue)) {
8641 $markerValues[$marker] =
'NULL';
8642 }
elseif ($conf[
'markers.'][$dottedMarker][
'commaSeparatedList'] == 1) {
8644 $explodeValues = GeneralUtility::trimExplode(
',', $tempValue);
8645 if (count($explodeValues) > 1) {
8647 $tempArray = array();
8648 foreach ($explodeValues as $listValue) {
8649 if (is_numeric($listValue)) {
8650 if ((
int)$listValue == $listValue) {
8651 $tempArray[] = (int)$listValue;
8653 $tempArray[] = floatval($listValue);
8658 if (preg_match(
'/^\'([^\']*)\'$/', $listValue, $matches)) {
8659 $listValue = $matches[1];
8660 }
elseif (preg_match(
'/^\\"([^\\"]*)\\"$/', $listValue, $matches)) {
8661 $listValue = $matches[1];
8663 $tempArray[] = $db->fullQuoteStr($listValue, $table);
8666 $markerValues[$marker] = implode(
',', $tempArray);
8669 $markerValues[$marker] = $db->fullQuoteStr($tempValue, $table);
8673 $markerValues[$marker] = $db->fullQuoteStr($tempValue, $table);
8676 return $markerValues;
8695 public function editPanel($content, $conf, $currentRecord =
'', $dataArr = array())
8697 if ($this->getTypoScriptFrontendController()->beUserLogin && $this->getFrontendBackendUser()->frontendEdit instanceof
FrontendEditingController) {
8698 if (!$currentRecord) {
8699 $currentRecord = $this->currentRecord;
8701 if (empty($dataArr)) {
8702 $dataArr = $this->data;
8705 $content = $this->getFrontendBackendUser()->frontendEdit->displayEditPanel($content, $conf, $currentRecord, $dataArr);
8722 public function editIcons($content, $params, array $conf = array(), $currentRecord =
'', $dataArr = array(), $addUrlParamStr =
'')
8724 if ($this->getTypoScriptFrontendController()->beUserLogin && $this->getFrontendBackendUser()->frontendEdit instanceof
FrontendEditingController) {
8725 if (!$currentRecord) {
8726 $currentRecord = $this->currentRecord;
8728 if (empty($dataArr)) {
8729 $dataArr = $this->data;
8732 $content = $this->getFrontendBackendUser()->frontendEdit->displayEditIcons($content, $params, $conf, $currentRecord, $dataArr, $addUrlParamStr);
8746 public function isDisabled($table, $row)
8748 $tsfe = $this->getTypoScriptFrontendController();
8749 $enablecolumns =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'];
8750 return $enablecolumns[
'disabled'] && $row[$enablecolumns[
'disabled']]
8751 || $enablecolumns[
'fe_group'] && $tsfe->simUserGroup && $row[$enablecolumns[
'fe_group']] == $tsfe->simUserGroup
8752 || $enablecolumns[
'starttime'] && $row[$enablecolumns[
'starttime']] >
$GLOBALS[
'EXEC_TIME']
8753 || $enablecolumns[
'endtime'] && $row[$enablecolumns[
'endtime']] && $row[$enablecolumns[
'endtime']] <
$GLOBALS[
'EXEC_TIME'];
8761 protected function getResourceFactory()
8763 return ResourceFactory::getInstance();
8773 protected function getEnvironmentVariable($key)
8775 return GeneralUtility::getIndpEnv($key);
8785 protected function getFromCache(array $configuration)
8789 $cacheKey = $this->calculateCacheKey($configuration);
8790 if (!empty($cacheKey)) {
8792 $cacheFrontend = GeneralUtility::makeInstance(CacheManager::class)
8793 ->getCache(
'cache_hash');
8794 $content = $cacheFrontend->get($cacheKey);
8805 protected function calculateCacheLifetime(array $configuration)
8807 $lifetimeConfiguration = isset($configuration[
'lifetime'])
8808 ? $configuration[
'lifetime']
8810 $lifetimeConfiguration = isset($configuration[
'lifetime.'])
8811 ? $this->stdWrap($lifetimeConfiguration, $configuration[
'lifetime.'])
8812 : $lifetimeConfiguration;
8815 if (strtolower($lifetimeConfiguration) ===
'unlimited') {
8817 }
elseif ($lifetimeConfiguration > 0) {
8818 $lifetime = (int)$lifetimeConfiguration;
8829 protected function calculateCacheTags(array $configuration)
8831 $tags = isset($configuration[
'tags']) ? $configuration[
'tags'] :
'';
8832 $tags = isset($configuration[
'tags.'])
8833 ? $this->stdWrap($tags, $configuration[
'tags.'])
8835 return empty($tags) ? [] : GeneralUtility::trimExplode(
',', $tags);
8844 protected function calculateCacheKey(array $configuration)
8846 $key = isset($configuration[
'key']) ? $configuration[
'key'] :
'';
8847 return isset($configuration[
'key.'])
8848 ? $this->stdWrap($key, $configuration[
'key.'])
8857 protected function getFrontendBackendUser()
8867 protected function getDatabaseConnection()
8875 protected function getTimeTracker()
8883 protected function getTypoScriptFrontendController()
8885 return $this->typoScriptFrontendController ?:
$GLOBALS[
'TSFE'];