159 'prespace' => array(
'<span class="ts-prespace">',
'</span>'),
161 'objstr_postspace' => array(
'<span class="ts-objstr_postspace">',
'</span>'),
163 'operator_postspace' => array(
'<span class="ts-operator_postspace">',
'</span>'),
165 'operator' => array(
'<span class="ts-operator">',
'</span>'),
167 'value' => array(
'<span class="ts-value">',
'</span>'),
169 'objstr' => array(
'<span class="ts-objstr">',
'</span>'),
171 'value_copy' => array(
'<span class="ts-value_copy">',
'</span>'),
173 'value_unset' => array(
'<span class="ts-value_unset">',
'</span>'),
175 'ignored' => array(
'<span class="ts-ignored">',
'</span>'),
177 'default' => array(
'<span class="ts-default">',
'</span>'),
179 'comment' => array(
'<span class="ts-comment">',
'</span>'),
181 'condition' => array(
'<span class="ts-condition">',
'</span>'),
183 'error' => array(
'<span class="ts-error">',
'</span>'),
185 'linenum' => array(
'<span class="ts-linenum">',
'</span>')
212 public function parse($string, $matchObj =
'') {
213 $this->raw = explode(LF, $string);
217 if ($this->breakPointLN && $pre ===
'[_BREAK]') {
218 $this->
error(
'Breakpoint at ' . ($this->lineNumberOffset + $this->rawP - 2) .
': Line content was "' . $this->raw[($this->rawP - 2)] .
'"', 1);
221 $preUppercase = strtoupper($pre);
222 if ($pre[0] ===
'[' &&
223 ($preUppercase ===
'[GLOBAL]' ||
224 $preUppercase ===
'[END]' ||
225 !$this->lastConditionTrue && $preUppercase ===
'[ELSE]')
227 $pre = trim($this->
parseSub($this->setup));
228 $this->lastConditionTrue = 1;
231 $specificSection = $preUppercase !==
'[ELSE]';
232 if ($specificSection) {
233 $this->sections[md5($pre)] = $pre;
236 if ($specificSection) {
237 $this->sectionsMatch[md5($pre)] = $pre;
239 $pre = trim($this->
parseSub($this->setup));
240 $this->lastConditionTrue = 1;
243 $this->lastConditionTrue = 0;
247 if ($this->inBrace) {
248 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': The script is short of ' . $this->inBrace .
' end brace(s)', 1);
250 if ($this->multiLineEnabled) {
251 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': A multiline value section is not ended with a parenthesis!', 1);
253 $this->lineNumberOffset += count($this->raw) + 1;
264 while (isset($this->raw[$this->rawP])) {
265 $line = trim($this->raw[$this->rawP]);
267 if ($line && $line[0] ===
'[') {
281 while (isset($this->raw[$this->rawP])) {
282 $line = ltrim($this->raw[$this->rawP]);
285 if ($this->syntaxHighLight) {
290 if ($this->breakPointLN && $this->lineNumberOffset + $this->rawP - 1 === $this->breakPointLN + 1) {
294 if (!$this->multiLineEnabled && strpos($line,
'/*') === 0) {
295 $this->commentSet = 1;
298 if (!$this->commentSet && ($line || $this->multiLineEnabled)) {
300 if ($this->multiLineEnabled) {
302 if ($line[0] ===
')') {
303 if ($this->syntaxHighLight) {
304 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
307 $this->multiLineEnabled = 0;
308 $theValue = implode($this->multiLineValue, LF);
309 if (strpos($this->multiLineObject,
'.') !== FALSE) {
311 $this->
setVal($this->multiLineObject, $setup, array($theValue));
315 if ($this->lastComment && $this->regComments) {
318 if ($this->regLinenumbers) {
319 $setup[$this->multiLineObject .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
323 if ($this->syntaxHighLight) {
326 $this->multiLineValue[] = $this->raw[$this->rawP - 1];
328 } elseif ($this->inBrace === 0 && $line[0] ===
'[') {
330 if ($this->syntaxHighLight) {
336 if ($line[0] ===
'[' && stripos($line,
'[GLOBAL]') !== FALSE) {
337 if ($this->syntaxHighLight) {
340 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': On return to [GLOBAL] scope, the script was short of ' . $this->inBrace .
' end brace(s)', 1);
343 } elseif ($line[0] !==
'}' && $line[0] !==
'#' && $line[0] !==
'/') {
346 $varL = strcspn($line, TAB .
' {=<>(');
348 if ($varL > 0 && substr($line, $varL-1, 2) ===
':=') {
352 $objStrName = substr($line, 0, $varL);
353 if ($this->syntaxHighLight) {
354 $this->
regHighLight(
'objstr', $lineP, strlen(substr($line, $varL)));
356 if ($objStrName !==
'') {
358 if ($this->strict && preg_match(
'/[^[:alnum:]_\\\\\\.:-]/i', $objStrName, $r)) {
359 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" contains invalid character "' . $r[0] .
'". Must be alphanumeric or one of: "_:-\\."');
361 $line = ltrim(substr($line, $varL));
362 if ($this->syntaxHighLight) {
363 $this->
regHighLight(
'objstr_postspace', $lineP, strlen($line));
365 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
366 $this->
regHighLight(
'operator_postspace', $lineP, strlen(ltrim(substr($line, 1))));
370 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" was not followed by any operator, =<>({');
374 if ($line[0] ===
':' && preg_match(
'/^:=\\s*([[:alpha:]]+)\\s*\\((.*)\\).*/', $line, $match)) {
376 $tsFuncArg = $match[2];
377 list($currentValue) = $this->
getVal($objStrName, $setup);
378 $tsFuncArg = str_replace(array(
'\\\\',
'\\n',
'\\t'), array(
'\\', LF, TAB), $tsFuncArg);
380 if (isset($newValue)) {
381 $line =
'= ' . $newValue;
386 if ($this->syntaxHighLight) {
387 $this->
regHighLight(
'value', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
389 if (strpos($objStrName,
'.') !== FALSE) {
391 $value[0] = trim(substr($line, 1));
392 $this->
setVal($objStrName, $setup, $value);
394 $setup[$objStrName] = trim(substr($line, 1));
395 if ($this->lastComment && $this->regComments) {
399 if ($this->regLinenumbers) {
400 $setup[$objStrName .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
406 if (strpos($objStrName,
'.') !== FALSE) {
412 if (!isset($setup[($objStrName .
'.')])) {
413 $setup[$objStrName .
'.'] = array();
415 $exitSig = $this->
parseSub($setup[$objStrName .
'.']);
422 $this->multiLineObject = $objStrName;
423 $this->multiLineEnabled = 1;
424 $this->multiLineValue = array();
427 if ($this->syntaxHighLight) {
428 $this->
regHighLight(
'value_copy', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
430 $theVal = trim(substr($line, 1));
431 if ($theVal[0] ===
'.') {
432 $res = $this->
getVal(substr($theVal, 1), $setup);
434 $res = $this->
getVal($theVal, $this->setup);
436 $this->
setVal($objStrName, $setup, unserialize(serialize($res)), 1);
440 if ($this->syntaxHighLight) {
441 $this->
regHighLight(
'value_unset', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
443 $this->
setVal($objStrName, $setup,
'UNSET');
446 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" was not followed by any operator, =<>({');
450 $this->lastComment =
'';
452 } elseif ($line[0] ===
'}') {
454 $this->lastComment =
'';
455 if ($this->syntaxHighLight) {
456 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
458 if ($this->inBrace < 0) {
459 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': An end brace is in excess.', 1);
465 if ($this->syntaxHighLight) {
469 if ($this->regComments) {
470 $this->lastComment .= rtrim($line) . LF;
474 $this->
error(substr($line, 11));
479 if ($this->commentSet) {
480 if ($this->syntaxHighLight) {
483 if (strpos($line,
'*/') === 0) {
484 $this->commentSet = 0;
501 switch ($modifierName) {
502 case 'prependString':
503 $newValue = $modifierArgument . $currentValue;
506 $newValue = $currentValue . $modifierArgument;
509 $newValue = str_replace($modifierArgument,
'', $currentValue);
511 case 'replaceString':
512 list($fromStr, $toStr) = explode(
'|', $modifierArgument, 2);
513 $newValue = str_replace($fromStr, $toStr, $currentValue);
516 $newValue = ((string)$currentValue !==
'' ? $currentValue .
',' :
'') . $modifierArgument;
518 case 'removeFromList':
521 if (count($removeElements)) {
522 $newValue = implode(
',', array_diff($existingElements, $removeElements));
527 $newValue = implode(
',', array_unique($elements));
531 $newValue = implode(
',', array_reverse($elements));
536 $arguments = array_map(
'strtolower', $arguments);
537 $sort_flags = SORT_REGULAR;
538 if (in_array(
'numeric', $arguments)) {
539 $sort_flags = SORT_NUMERIC;
541 sort($elements, $sort_flags);
542 if (in_array(
'descending', $arguments)) {
543 $elements = array_reverse($elements);
545 $newValue = implode(
',', $elements);
548 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsparser.php'][
'preParseFunc'][$modifierName])) {
549 $hookMethod =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsparser.php'][
'preParseFunc'][$modifierName];
550 $params = array(
'currentValue' => $currentValue,
'functionArgument' => $modifierArgument);
554 GeneralUtility::sysLog(
555 'Missing function definition for ' . $modifierName .
' on TypoScript',
575 if ((
string)$string ===
'') {
581 if (!isset($setup[$key])) {
582 $setup[$key] = array();
584 $exitSig = $remainingKey ===
'' 587 return $exitSig ?:
'';
600 if ((
string)$string ===
'') {
605 $subKey = $key .
'.';
606 if ($remainingKey ===
'') {
608 if (isset(
$setup[$key])) {
609 $retArr[0] =
$setup[$key];
611 if (isset(
$setup[$subKey])) {
612 $retArr[1] =
$setup[$subKey];
633 public function setVal($string, array &
$setup, $value, $wipeOut = FALSE) {
634 if ((
string)$string ===
'') {
639 $subKey = $key .
'.';
640 if ($remainingKey ===
'') {
641 if ($value ===
'UNSET') {
643 unset($setup[$subKey]);
644 if ($this->regLinenumbers) {
645 $setup[$key .
'.ln..'][] = ($this->lineNumberOffset + $this->rawP - 1) .
'>';
649 if ($wipeOut && $this->strict) {
651 unset($setup[$subKey]);
652 if ($this->regLinenumbers) {
653 $setup[$key .
'.ln..'][] = ($this->lineNumberOffset + $this->rawP - 1) .
'<';
657 if (isset($value[0])) {
658 $setup[$key] = $value[0];
660 if (isset($value[1])) {
661 $setup[$subKey] = $value[1];
663 if ($this->lastComment && $this->regComments) {
666 if ($this->regLinenumbers && !$lnRegisDone) {
667 $setup[$key .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
671 if (!isset($setup[$subKey])) {
672 $setup[$subKey] = array();
674 $this->
setVal($remainingKey, $setup[$subKey], $value);
691 $dotPosition = strpos($key,
'.');
692 if ($dotPosition === FALSE) {
693 return array($key,
'');
696 if (strpos($key,
'\\') !== FALSE) {
699 while ($dotPosition !== FALSE) {
700 if ($dotPosition > 0 && $key[$dotPosition - 1] !==
'\\' || $dotPosition > 1 && $key[$dotPosition - 2] ===
'\\') {
704 $dotPosition = strpos($key,
'.', $dotPosition + 1);
707 if ($dotPosition === FALSE) {
712 if ($dotPosition > 1 && $key[$dotPosition - 2] ===
'\\' && $key[$dotPosition - 1] ===
'\\') {
713 $keySegment = substr($key, 0, $dotPosition - 1);
715 $keySegment = substr($key, 0, $dotPosition);
717 $remainingKey = substr($key, $dotPosition + 1);
721 $keySegment = str_replace(
'\\.',
'.', $keySegment);
724 list($keySegment, $remainingKey) = explode(
'.', $key, 2);
726 return array($keySegment, $remainingKey);
738 public function error($err, $num = 2) {
740 $GLOBALS[
'TT']->setTSlogMessage($err, $num);
742 $this->errors[] = array($err, $num, $this->rawP - 1, $this->lineNumberOffset);
756 static public function checkIncludeLines($string, $cycle_counter = 1, $returnFiles = FALSE, $parentFilenameOrPath =
'') {
757 $includedFiles = array();
758 if ($cycle_counter > 100) {
759 GeneralUtility::sysLog(
'It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags',
'Core',
GeneralUtility::SYSLOG_SEVERITY_WARNING);
763 'files' => $includedFiles
768 ### ERROR: Recursion! 774 if (strpos($string,
'<INCLUDE_TYPOSCRIPT:') !== FALSE) {
775 $splitRegEx =
'/\r?\n\s*<INCLUDE_TYPOSCRIPT:\s*(?i)source\s*=\s*"((?i)file|dir):\s*([^"]*)"(.*)>[\ \t]*/';
776 $parts = preg_split($splitRegEx, LF . $string . LF, -1, PREG_SPLIT_DELIM_CAPTURE);
778 $newString = $parts[0] . LF;
779 $partCount = count($parts);
780 for ($i = 1; $i + 3 < $partCount; $i += 4) {
785 $includeType = $parts[$i];
786 $filename = $parts[$i + 1];
787 $originalFilename = $filename;
788 $optionalProperties = $parts[$i + 2];
789 $tsContentsTillNextInclude = $parts[$i + 3];
792 if ($parentFilenameOrPath !==
'' && $filename[0] ===
'.') {
798 if (!preg_match(
'/(^\\s*\\r?\\n|^$)/', $tsContentsTillNextInclude)) {
799 $newString .= self::typoscriptIncludeError(
'Invalid characters after <INCLUDE_TYPOSCRIPT: source="' . $includeType .
':' . $filename .
'">-tag (rest of line must be empty).');
800 } elseif (strpos(
'..', $filename) !== FALSE) {
801 $newString .= self::typoscriptIncludeError(
'Invalid filepath "' . $filename .
'" (containing "..").');
803 switch (strtolower($includeType)) {
805 self::includeFile($originalFilename, $cycle_counter, $returnFiles, $newString, $includedFiles, $optionalProperties, $parentFilenameOrPath);
808 self::includeDirectory($originalFilename, $cycle_counter, $returnFiles, $newString, $includedFiles, $optionalProperties, $parentFilenameOrPath);
811 $newString .= self::typoscriptIncludeError(
'No valid option for INCLUDE_TYPOSCRIPT source property (valid options are FILE or DIR)');
815 $newString .= $tsContentsTillNextInclude . LF;
820 $filePointer = strtolower($filename);
822 $filePointerPathParts = explode(
'/', substr($filePointer, 4));
825 list($includeType, ) = explode(
'.', array_pop($filePointerPathParts));
827 if (in_array($includeType, array(
'setup',
'constants'))) {
829 $filePointerPathParts[0] = str_replace(
'_',
'', $filePointerPathParts[0]);
832 $defaultTypoScriptKey = implode(
'/', $filePointerPathParts) .
'/';
833 if (in_array($defaultTypoScriptKey,
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'contentRenderingTemplates'], TRUE)) {
834 $newString .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_' . $includeType .
'.'][
'defaultContentRendering'];
841 $string = LF . trim($newString) . LF;
847 'typoscript' => $string,
848 'files' => $includedFiles
867 public static function includeFile($filename, $cycle_counter = 1, $returnFiles = FALSE, &$newString =
'', array &$includedFiles = array(), $optionalProperties =
'', $parentFilenameOrPath =
'') {
869 if ($parentFilenameOrPath !==
'' && $filename[0] ===
'.') {
872 $absfilename = $filename;
876 $newString .= LF .
'### <INCLUDE_TYPOSCRIPT: source="FILE:' . $filename .
'"' . $optionalProperties .
'> BEGIN:' . LF;
877 if ((
string)$filename !==
'') {
881 $newString .= self::typoscriptIncludeError(
'File "' . $filename .
'" was not included since it is not allowed due to fileDenyPattern.');
882 } elseif (!@file_exists($absfilename)) {
883 $newString .= self::typoscriptIncludeError(
'File "' . $filename .
'" was not found.');
885 $includedFiles[] = $absfilename;
887 $included_text = self::checkIncludeLines(
GeneralUtility::getUrl($absfilename), $cycle_counter + 1, $returnFiles, $absfilename);
890 if ($returnFiles && is_array($included_text)) {
891 $includedFiles = array_merge($includedFiles, $included_text[
'files']);
892 $included_text = $included_text[
'typoscript'];
894 $newString .= $included_text . LF;
897 $newString .=
'### <INCLUDE_TYPOSCRIPT: source="FILE:' . $filename .
'"' . $optionalProperties .
'> END:' . LF . LF;
915 protected static function includeDirectory($dirPath, $cycle_counter = 1, $returnFiles = FALSE, &$newString =
'', array &$includedFiles = array(), $optionalProperties =
'', $parentFilenameOrPath =
'') {
917 $matches = preg_split(
'#(?i)extensions\s*=\s*"([^"]*)"(\s*|>)#', $optionalProperties, 2, PREG_SPLIT_DELIM_CAPTURE);
918 if (count($matches) > 1) {
919 $includedFileExtensions = $matches[1];
921 $includedFileExtensions =
'';
925 if ($parentFilenameOrPath !==
'' && $dirPath[0] ===
'.') {
928 $resolvedDirPath = $dirPath;
932 $absDirPath = rtrim($absDirPath,
'/') .
'/';
933 $newString .= LF .
'### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath .
'"' . $optionalProperties .
'> BEGIN:' . LF;
937 $prefixLength = strlen(PATH_site);
938 foreach ($fileIndex as $absFileRef) {
939 $relFileRef = substr($absFileRef, $prefixLength);
940 self::includeFile($relFileRef, $cycle_counter, $returnFiles, $newString, $includedFiles,
'', $absDirPath);
942 $newString .=
'### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath .
'"' . $optionalProperties .
'> END:' . LF . LF;
944 $newString .= self::typoscriptIncludeError(
'The path "' . $resolvedDirPath .
'" is invalid.');
957 GeneralUtility::sysLog($error,
'Core', 2);
958 return "\n###\n### ERROR: " . $error .
"\n###\n\n";
968 foreach ($array as $k => $v) {
969 $array[$k] = self::checkIncludeLines($array[$k]);
987 static public function extractIncludes($string, $cycle_counter = 1, array $extractedFileNames = array(), $parentFilenameOrPath =
'') {
988 if ($cycle_counter > 10) {
989 GeneralUtility::sysLog(
'It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags',
'Core',
GeneralUtility::SYSLOG_SEVERITY_WARNING);
992 ### ERROR: Recursion! 996 $expectedEndTag =
'';
997 $fileContent = array();
998 $restContent = array();
1000 $inIncludePart = FALSE;
1001 $lines = preg_split(
"/\r\n|\n|\r/", $string);
1002 $skipNextLineIfEmpty = FALSE;
1003 $openingCommentedIncludeStatement = NULL;
1004 $optionalProperties =
'';
1005 foreach ($lines as $line) {
1008 if ($skipNextLineIfEmpty) {
1009 if (trim($line) ===
'') {
1012 $skipNextLineIfEmpty = FALSE;
1016 if (!$inIncludePart) {
1018 if (preg_match(
'/###\\s*<INCLUDE_TYPOSCRIPT:\\s*source\\s*=\\s*"\\s*((?i)file|dir)\\s*:\\s*([^"]*)"(.*)>\\s*BEGIN/i', $line, $matches)) {
1022 $openingCommentedIncludeStatement = trim($line);
1023 $openingCommentedIncludeStatement = preg_replace(
'/\\s*### Warning: .*###\\s*/',
'', $openingCommentedIncludeStatement);
1026 $inIncludePart = strtoupper($matches[1]);
1027 $fileName = $matches[2];
1028 $optionalProperties = $matches[3];
1030 $expectedEndTag =
'### <INCLUDE_TYPOSCRIPT: source="' . $inIncludePart .
':' . $fileName .
'"' . $optionalProperties .
'> END';
1032 $expectedEndTag = strtolower(preg_replace(
'/\s/',
'', $expectedEndTag));
1035 $restContent[] = $line;
1041 $strippedLine = preg_replace(
'/\s/',
'', $line);
1042 if (stripos($strippedLine, $expectedEndTag) !== FALSE) {
1044 $fileContentString = implode(PHP_EOL, $fileContent);
1049 if ($parentFilenameOrPath !==
'' && $fileName[0] ===
'.') {
1052 $realFileName = $fileName;
1056 if ($inIncludePart ===
'FILE') {
1059 throw new \UnexpectedValueException(sprintf(
'File "%s" was not included since it is not allowed due to fileDenyPattern.', $fileName), 1382651858);
1061 if (empty($realFileName)) {
1062 throw new \UnexpectedValueException(sprintf(
'"%s" is not a valid file location.', $fileName), 1294586441);
1064 if (!is_writable($realFileName)) {
1065 throw new \RuntimeException(sprintf(
'"%s" is not writable.', $fileName), 1294586442);
1067 if (in_array($realFileName, $extractedFileNames)) {
1068 throw new \RuntimeException(sprintf(
'Recursive/multiple inclusion of file "%s"', $realFileName), 1294586443);
1070 $extractedFileNames[] = $realFileName;
1073 $fileContentString = self::extractIncludes($fileContentString, $cycle_counter + 1, $extractedFileNames, $realFileName);
1077 throw new \RuntimeException(sprintf(
'Could not write file "%s"', $realFileName), 1294586444);
1080 $restContent[] =
'<INCLUDE_TYPOSCRIPT: source="FILE:' . $fileName .
'"' . $optionalProperties .
'>';
1085 if (empty($realFileName)) {
1086 throw new \UnexpectedValueException(sprintf(
'"%s" is not a valid location.', $fileName), 1366493602);
1088 if (!is_dir($realFileName)) {
1089 throw new \RuntimeException(sprintf(
'"%s" is not a directory.', $fileName), 1366493603);
1091 if (in_array($realFileName, $extractedFileNames)) {
1092 throw new \RuntimeException(sprintf(
'Recursive/multiple inclusion of directory "%s"', $realFileName), 1366493604);
1094 $extractedFileNames[] = $realFileName;
1097 self::extractIncludes($fileContentString, $cycle_counter + 1, $extractedFileNames, $realFileName);
1102 $restContent[] =
'<INCLUDE_TYPOSCRIPT: source="DIR:' . $fileName .
'"' . $optionalProperties .
'>';
1106 $fileContent = array();
1108 $inIncludePart = FALSE;
1109 $openingCommentedIncludeStatement = NULL;
1112 $skipNextLineIfEmpty = TRUE;
1115 $fileContent[] = $line;
1120 if ($inIncludePart) {
1121 $restContent[] = $openingCommentedIncludeStatement .
' ### Warning: Corresponding end line missing! ###';
1122 $restContent = array_merge($restContent, $fileContent);
1124 $restContentString = implode(PHP_EOL, $restContent);
1125 return $restContentString;
1135 foreach ($array as $k => $v) {
1136 $array[$k] = self::extractIncludes($array[$k]);
1157 $this->syntaxHighLight = 1;
1158 $this->highLightData = array();
1159 $this->
error = array();
1161 $string = str_replace(CR,
'', $string);
1162 $this->
parse($string);
1178 if ($strlen === -1) {
1179 $this->highLightData[$pointer] = array(array($code, 0));
1181 $this->highLightData[$pointer][] = array($code, $strlen);
1199 foreach ($this->errors as $err) {
1200 $errA[$err[2]][] = $err[0];
1204 foreach ($this->raw as
$rawP => $value) {
1206 $strlen = strlen($value);
1208 if (is_array($this->highLightData[
$rawP])) {
1209 foreach ($this->highLightData[$rawP] as $set) {
1210 $len = $strlen - $start - $set[1];
1212 $part = substr($value, $start, $len);
1214 $st = $this->highLightStyles[isset($this->highLightStyles[$set[0]]) ? $set[0] :
'default'];
1215 if (!$highlightBlockMode || $set[0] !==
'prespace') {
1216 $lineC .= $st[0] . htmlspecialchars($part) . $st[1];
1218 } elseif ($len < 0) {
1219 debug(array($len, $value, $rawP));
1223 debug(array($value));
1225 if (strlen(substr($value, $start))) {
1226 $lineC .= $this->highLightStyles[
'ignored'][0] . htmlspecialchars(substr($value, $start)) . $this->highLightStyles[
'ignored'][1];
1229 $lineC .= $this->highLightStyles[
'error'][0] .
'<strong> - ERROR:</strong> ' . htmlspecialchars(implode(
';', $errA[$rawP])) . $this->highLightStyles[
'error'][1];
1231 if ($highlightBlockMode && $this->highLightData_bracelevel[$rawP]) {
1232 $lineC = str_pad(
'', $this->highLightData_bracelevel[$rawP] * 2,
' ', STR_PAD_LEFT) .
'<span style="' . $this->highLightBlockStyles . ($this->highLightBlockStyles_basecolor ?
'background-color: ' .
GeneralUtility::modifyHTMLColorAll($this->highLightBlockStyles_basecolor, -$this->highLightData_bracelevel[$rawP] * 16) :
'') .
'">' . ($lineC !==
'' ? $lineC :
' ') .
'</span>';
1234 if (is_array($lineNumDat)) {
1235 $lineNum = $rawP + $lineNumDat[0];
1237 $lineNum = $this->parentObject->ext_lnBreakPointWrap($lineNum, $lineNum);
1239 $lineC = $this->highLightStyles[
'linenum'][0] . str_pad($lineNum, 4,
' ', STR_PAD_LEFT) .
':' . $this->highLightStyles[
'linenum'][1] .
' ' . $lineC;
1243 return '<pre class="ts-hl">' . implode(LF, $lines) .
'</pre>';
static getAllFilesAndFoldersInPath(array $fileArr, $path, $extList='', $regDirs=FALSE, $recursivityLevels=99, $excludePattern='')
static writeFile($file, $content, $changePermissions=FALSE)
static includeDirectory($dirPath, $cycle_counter=1, $returnFiles=FALSE, &$newString='', array &$includedFiles=array(), $optionalProperties='', $parentFilenameOrPath='')
static isFirstPartOfStr($str, $partStr)
static extractIncludes($string, $cycle_counter=1, array $extractedFileNames=array(), $parentFilenameOrPath='')
static modifyHTMLColorAll($color, $all)
$highLightBlockStyles_basecolor
parseNextKeySegment($key)
static getAbsolutePathOfRelativeReferencedFileOrPath($baseFilenameOrPath, $includeFileName)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static verifyFilenameAgainstDenyPattern($filename)
static checkIncludeLines($string, $cycle_counter=1, $returnFiles=FALSE, $parentFilenameOrPath='')
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static typoscriptIncludeError($error)
parse($string, $matchObj='')
const SYSLOG_SEVERITY_WARNING
static checkIncludeLines_array(array $array)
syntaxHighlight_print($lineNumDat, $highlightBlockMode)
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
regHighLight($code, $pointer, $strlen=-1)
doSyntaxHighlight($string, $lineNum='', $highlightBlockMode=FALSE)
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel=E_DEBUG)
$highLightData_bracelevel
executeValueModifier($modifierName, $modifierArgument=NULL, $currentValue=NULL)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static extractIncludes_array(array $array)
setVal($string, array &$setup, $value, $wipeOut=FALSE)
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
rollParseSub($string, array &$setup)
static includeFile($filename, $cycle_counter=1, $returnFiles=FALSE, &$newString='', array &$includedFiles=array(), $optionalProperties='', $parentFilenameOrPath='')