2 namespace TYPO3\CMS\Core\TypoScript\Parser;
182 'prespace' => array(
'<span class="ts-prespace">',
'</span>'),
184 'objstr_postspace' => array(
'<span class="ts-objstr_postspace">',
'</span>'),
186 'operator_postspace' => array(
'<span class="ts-operator_postspace">',
'</span>'),
188 'operator' => array(
'<span class="ts-operator">',
'</span>'),
190 'value' => array(
'<span class="ts-value">',
'</span>'),
192 'objstr' => array(
'<span class="ts-objstr">',
'</span>'),
194 'value_copy' => array(
'<span class="ts-value_copy">',
'</span>'),
196 'value_unset' => array(
'<span class="ts-value_unset">',
'</span>'),
198 'ignored' => array(
'<span class="ts-ignored">',
'</span>'),
200 'default' => array(
'<span class="ts-default">',
'</span>'),
202 'comment' => array(
'<span class="ts-comment">',
'</span>'),
204 'condition' => array(
'<span class="ts-condition">',
'</span>'),
206 'error' => array(
'<span class="ts-error">',
'</span>'),
208 'linenum' => array(
'<span class="ts-linenum">',
'</span>')
238 public function parse($string, $matchObj =
'')
240 $this->raw = explode(LF, $string);
244 if ($this->breakPointLN && $pre ===
'[_BREAK]') {
245 $this->
error(
'Breakpoint at ' . ($this->lineNumberOffset + $this->rawP - 2) .
': Line content was "' . $this->raw[($this->rawP - 2)] .
'"', 1);
248 $preUppercase = strtoupper($pre);
249 if ($pre[0] ===
'[' &&
250 ($preUppercase ===
'[GLOBAL]' ||
251 $preUppercase ===
'[END]' ||
252 !$this->lastConditionTrue && $preUppercase ===
'[ELSE]')
254 $pre = trim($this->
parseSub($this->setup));
255 $this->lastConditionTrue = 1;
258 $specificSection = $preUppercase !==
'[ELSE]';
259 if ($specificSection) {
260 $this->sections[md5($pre)] = $pre;
263 if ($specificSection) {
264 $this->sectionsMatch[md5($pre)] = $pre;
266 $pre = trim($this->
parseSub($this->setup));
267 $this->lastConditionTrue = 1;
270 $this->lastConditionTrue = 0;
274 if ($this->inBrace) {
275 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': The script is short of ' . $this->inBrace .
' end brace(s)', 1);
277 if ($this->multiLineEnabled) {
278 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': A multiline value section is not ended with a parenthesis!', 1);
280 $this->lineNumberOffset += count($this->raw) + 1;
291 while (isset($this->raw[$this->rawP])) {
292 $line = trim($this->raw[$this->rawP]);
294 if ($line && $line[0] ===
'[') {
309 while (isset($this->raw[$this->rawP])) {
310 $line = ltrim($this->raw[$this->rawP]);
313 if ($this->syntaxHighLight) {
318 if ($this->breakPointLN && $this->lineNumberOffset + $this->rawP - 1 === $this->breakPointLN + 1) {
322 if (!$this->multiLineEnabled && strpos($line,
'/*') === 0) {
323 $this->commentSet = 1;
326 if (!$this->commentSet && ($line || $this->multiLineEnabled)) {
328 if ($this->multiLineEnabled) {
330 if ($line[0] ===
')') {
331 if ($this->syntaxHighLight) {
332 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
335 $this->multiLineEnabled = 0;
336 $theValue = implode($this->multiLineValue, LF);
337 if (strpos($this->multiLineObject,
'.') !==
false) {
339 $this->
setVal($this->multiLineObject, $setup, array($theValue));
343 if ($this->lastComment && $this->regComments) {
346 if ($this->regLinenumbers) {
347 $setup[$this->multiLineObject .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
351 if ($this->syntaxHighLight) {
354 $this->multiLineValue[] = $this->raw[$this->rawP - 1];
356 }
elseif ($this->inBrace === 0 && $line[0] ===
'[') {
358 if ($this->syntaxHighLight) {
364 if ($line[0] ===
'[' && stripos($line,
'[GLOBAL]') !==
false) {
365 if ($this->syntaxHighLight) {
368 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': On return to [GLOBAL] scope, the script was short of ' . $this->inBrace .
' end brace(s)', 1);
371 }
elseif ($line[0] !==
'}' && $line[0] !==
'#' && $line[0] !==
'/') {
374 $varL = strcspn($line, TAB .
' {=<>(');
376 if ($varL > 0 && substr($line, $varL-1, 2) ===
':=') {
380 $objStrName = substr($line, 0, $varL);
381 if ($this->syntaxHighLight) {
382 $this->
regHighLight(
'objstr', $lineP, strlen(substr($line, $varL)));
384 if ($objStrName !==
'') {
386 if ($this->strict && preg_match(
'/[^[:alnum:]_\\\\\\.:-]/i', $objStrName, $r)) {
387 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" contains invalid character "' . $r[0] .
'". Must be alphanumeric or one of: "_:-\\."');
389 $line = ltrim(substr($line, $varL));
390 if ($this->syntaxHighLight) {
391 $this->
regHighLight(
'objstr_postspace', $lineP, strlen($line));
393 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
394 $this->
regHighLight(
'operator_postspace', $lineP, strlen(ltrim(substr($line, 1))));
398 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" was not followed by any operator, =<>({');
402 if ($line[0] ===
':' && preg_match(
'/^:=\\s*([[:alpha:]]+)\\s*\\((.*)\\).*/', $line, $match)) {
404 $tsFuncArg = $match[2];
405 list($currentValue) = $this->
getVal($objStrName, $setup);
406 $tsFuncArg = str_replace(array(
'\\\\',
'\\n',
'\\t'), array(
'\\', LF, TAB), $tsFuncArg);
408 if (isset($newValue)) {
409 $line =
'= ' . $newValue;
414 if ($this->syntaxHighLight) {
415 $this->
regHighLight(
'value', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
417 if (strpos($objStrName,
'.') !==
false) {
419 $value[0] = trim(substr($line, 1));
420 $this->
setVal($objStrName, $setup, $value);
422 $setup[$objStrName] = trim(substr($line, 1));
423 if ($this->lastComment && $this->regComments) {
427 if ($this->regLinenumbers) {
428 $setup[$objStrName .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
434 if (strpos($objStrName,
'.') !==
false) {
440 if (!isset($setup[($objStrName .
'.')])) {
441 $setup[$objStrName .
'.'] = array();
443 $exitSig = $this->
parseSub($setup[$objStrName .
'.']);
450 $this->multiLineObject = $objStrName;
451 $this->multiLineEnabled = 1;
452 $this->multiLineValue = array();
455 if ($this->syntaxHighLight) {
456 $this->
regHighLight(
'value_copy', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
458 $theVal = trim(substr($line, 1));
459 if ($theVal[0] ===
'.') {
460 $res = $this->
getVal(substr($theVal, 1), $setup);
462 $res = $this->
getVal($theVal, $this->setup);
464 $this->
setVal($objStrName, $setup, unserialize(serialize($res)), 1);
468 if ($this->syntaxHighLight) {
469 $this->
regHighLight(
'value_unset', $lineP, strlen(ltrim(substr($line, 1))) - strlen(trim(substr($line, 1))));
471 $this->
setVal($objStrName, $setup,
'UNSET');
474 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': Object Name String, "' . htmlspecialchars($objStrName) .
'" was not followed by any operator, =<>({');
478 $this->lastComment =
'';
480 }
elseif ($line[0] ===
'}') {
482 $this->lastComment =
'';
483 if ($this->syntaxHighLight) {
484 $this->
regHighLight(
'operator', $lineP, strlen($line) - 1);
486 if ($this->inBrace < 0) {
487 $this->
error(
'Line ' . ($this->lineNumberOffset + $this->rawP - 1) .
': An end brace is in excess.', 1);
493 if ($this->syntaxHighLight) {
497 if ($this->regComments) {
498 $this->lastComment .= rtrim($line) . LF;
502 $this->
error(substr($line, 11));
507 if ($this->commentSet) {
508 if ($this->syntaxHighLight) {
511 if (strpos($line,
'*/') === 0) {
512 $this->commentSet = 0;
531 switch ($modifierName) {
532 case 'prependString':
533 $newValue = $modifierArgument . $currentValue;
536 $newValue = $currentValue . $modifierArgument;
539 $newValue = str_replace($modifierArgument,
'', $currentValue);
541 case 'replaceString':
542 list($fromStr, $toStr) = explode(
'|', $modifierArgument, 2);
543 $newValue = str_replace($fromStr, $toStr, $currentValue);
546 $newValue = ((string)$currentValue !==
'' ? $currentValue .
',' :
'') . $modifierArgument;
548 case 'removeFromList':
551 if (!empty($removeElements)) {
552 $newValue = implode(
',', array_diff($existingElements, $removeElements));
557 $newValue = implode(
',', array_unique($elements));
561 $newValue = implode(
',', array_reverse($elements));
566 $arguments = array_map(
'strtolower', $arguments);
567 $sort_flags = SORT_REGULAR;
568 if (in_array(
'numeric', $arguments)) {
569 $sort_flags = SORT_NUMERIC;
574 foreach ($elements as $element) {
575 if (!is_numeric($element)) {
576 throw new \InvalidArgumentException(
'The list "' . $currentValue .
'" should be sorted numerically but contains a non-numeric value', 1438191758);
580 sort($elements, $sort_flags);
581 if (in_array(
'descending', $arguments)) {
582 $elements = array_reverse($elements);
584 $newValue = implode(
',', $elements);
587 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsparser.php'][
'preParseFunc'][$modifierName])) {
588 $hookMethod =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsparser.php'][
'preParseFunc'][$modifierName];
589 $params = array(
'currentValue' => $currentValue,
'functionArgument' => $modifierArgument);
593 GeneralUtility::sysLog(
594 'Missing function definition for ' . $modifierName .
' on TypoScript',
614 if ((
string)$string ===
'') {
620 if (!isset($setup[$key])) {
621 $setup[$key] = array();
623 $exitSig = $remainingKey ===
''
626 return $exitSig ?:
'';
639 if ((
string)$string ===
'') {
644 $subKey = $key .
'.';
645 if ($remainingKey ===
'') {
647 if (isset(
$setup[$key])) {
648 $retArr[0] =
$setup[$key];
650 if (isset(
$setup[$subKey])) {
651 $retArr[1] =
$setup[$subKey];
671 public function setVal($string, array &
$setup, $value, $wipeOut =
false)
673 if ((
string)$string ===
'') {
678 $subKey = $key .
'.';
679 if ($remainingKey ===
'') {
680 if ($value ===
'UNSET') {
682 unset($setup[$subKey]);
683 if ($this->regLinenumbers) {
684 $setup[$key .
'.ln..'][] = ($this->lineNumberOffset + $this->rawP - 1) .
'>';
688 if ($wipeOut && $this->strict) {
690 unset($setup[$subKey]);
691 if ($this->regLinenumbers) {
692 $setup[$key .
'.ln..'][] = ($this->lineNumberOffset + $this->rawP - 1) .
'<';
696 if (isset($value[0])) {
697 $setup[$key] = $value[0];
699 if (isset($value[1])) {
700 $setup[$subKey] = $value[1];
702 if ($this->lastComment && $this->regComments) {
705 if ($this->regLinenumbers && !$lnRegisDone) {
706 $setup[$key .
'.ln..'][] = $this->lineNumberOffset + $this->rawP - 1;
710 if (!isset($setup[$subKey])) {
711 $setup[$subKey] = array();
713 $this->
setVal($remainingKey, $setup[$subKey], $value);
731 $dotPosition = strpos($key,
'.');
732 if ($dotPosition ===
false) {
733 return array($key,
'');
736 if (strpos($key,
'\\') !==
false) {
739 while ($dotPosition !==
false) {
740 if ($dotPosition > 0 && $key[$dotPosition - 1] !==
'\\' || $dotPosition > 1 && $key[$dotPosition - 2] ===
'\\') {
744 $dotPosition = strpos($key,
'.', $dotPosition + 1);
747 if ($dotPosition ===
false) {
752 if ($dotPosition > 1 && $key[$dotPosition - 2] ===
'\\' && $key[$dotPosition - 1] ===
'\\') {
753 $keySegment = substr($key, 0, $dotPosition - 1);
755 $keySegment = substr($key, 0, $dotPosition);
757 $remainingKey = substr($key, $dotPosition + 1);
761 $keySegment = str_replace(
'\\.',
'.', $keySegment);
764 list($keySegment, $remainingKey) = explode(
'.', $key, 2);
766 return array($keySegment, $remainingKey);
777 public function error($err, $num = 2)
781 $tt->setTSlogMessage($err, $num);
783 $this->errors[] = array($err, $num, $this->rawP - 1, $this->lineNumberOffset);
797 public static function checkIncludeLines($string, $cycle_counter = 1, $returnFiles =
false, $parentFilenameOrPath =
'')
799 $includedFiles = array();
800 if ($cycle_counter > 100) {
801 GeneralUtility::sysLog(
'It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags',
'core',
GeneralUtility::SYSLOG_SEVERITY_WARNING);
805 'files' => $includedFiles
810 ### ERROR: Recursion!
816 if (strpos($string,
'<INCLUDE_TYPOSCRIPT:') !==
false) {
817 $splitRegEx =
'/\r?\n\s*<INCLUDE_TYPOSCRIPT:\s*(?i)source\s*=\s*"((?i)file|dir):\s*([^"]*)"(.*)>[\ \t]*/';
818 $parts = preg_split($splitRegEx, LF . $string . LF, -1, PREG_SPLIT_DELIM_CAPTURE);
820 $newString = $parts[0] . LF;
821 $partCount = count($parts);
822 for ($i = 1; $i + 3 < $partCount; $i += 4) {
827 $includeType = $parts[$i];
830 $optionalProperties = $parts[$i + 2];
831 $tsContentsTillNextInclude = $parts[$i + 3];
834 $matches = preg_split(
'#(?i)condition\\s*=\\s*"((?:\\\\\\\\|\\\\"|[^\\"])*)"(\\s*|>)#', $optionalProperties, 2, PREG_SPLIT_DELIM_CAPTURE);
836 if (count($matches) > 1) {
838 $condition = trim(stripslashes($matches[1]));
840 if ($condition[0] !==
'[') {
841 $condition =
'[' . $condition .
']';
846 if (!$conditionMatcher->match($condition)) {
852 if ($parentFilenameOrPath !==
'' &&
$filename[0] ===
'.') {
858 if (!preg_match(
'/(^\\s*\\r?\\n|^$)/', $tsContentsTillNextInclude)) {
859 $newString .= self::typoscriptIncludeError(
'Invalid characters after <INCLUDE_TYPOSCRIPT: source="' . $includeType .
':' .
$filename .
'">-tag (rest of line must be empty).');
861 $newString .= self::typoscriptIncludeError(
'Invalid filepath "' .
$filename .
'" (containing "..").');
863 switch (strtolower($includeType)) {
865 self::includeFile($originalFilename, $cycle_counter, $returnFiles, $newString, $includedFiles, $optionalProperties, $parentFilenameOrPath);
868 self::includeDirectory($originalFilename, $cycle_counter, $returnFiles, $newString, $includedFiles, $optionalProperties, $parentFilenameOrPath);
871 $newString .= self::typoscriptIncludeError(
'No valid option for INCLUDE_TYPOSCRIPT source property (valid options are FILE or DIR)');
875 $newString .= $tsContentsTillNextInclude . LF;
882 $filePointerPathParts = explode(
'/', substr($filePointer, 4));
885 list($includeType, ) = explode(
'.', array_pop($filePointerPathParts));
887 if (in_array($includeType, array(
'setup',
'constants'))) {
889 $filePointerPathParts[0] = str_replace(
'_',
'', $filePointerPathParts[0]);
892 $defaultTypoScriptKey = implode(
'/', $filePointerPathParts) .
'/';
893 if (in_array($defaultTypoScriptKey,
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'contentRenderingTemplates'],
true)) {
894 $newString .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_' . $includeType .
'.'][
'defaultContentRendering'];
900 $string = LF . trim($newString) . LF;
906 'typoscript' => $string,
907 'files' => $includedFiles
926 public static function includeFile(
$filename, $cycle_counter = 1, $returnFiles =
false, &$newString =
'', array &$includedFiles = array(), $optionalProperties =
'', $parentFilenameOrPath =
'')
929 if ($parentFilenameOrPath !==
'' &&
$filename[0] ===
'.') {
936 $newString .= LF .
'### <INCLUDE_TYPOSCRIPT: source="FILE:' .
$filename .
'"' . $optionalProperties .
'> BEGIN:' . LF;
941 $newString .= self::typoscriptIncludeError(
'File "' .
$filename .
'" was not included since it is not allowed due to fileDenyPattern.');
942 }
elseif (!@file_exists($absfilename)) {
943 $newString .= self::typoscriptIncludeError(
'File "' .
$filename .
'" was not found.');
945 $includedFiles[] = $absfilename;
947 $included_text = self::checkIncludeLines(
GeneralUtility::getUrl($absfilename), $cycle_counter + 1, $returnFiles, $absfilename);
950 if ($returnFiles && is_array($included_text)) {
951 $includedFiles = array_merge($includedFiles, $included_text[
'files']);
952 $included_text = $included_text[
'typoscript'];
954 $newString .= $included_text . LF;
957 $newString .=
'### <INCLUDE_TYPOSCRIPT: source="FILE:' .
$filename .
'"' . $optionalProperties .
'> END:' . LF . LF;
975 protected static function includeDirectory($dirPath, $cycle_counter = 1, $returnFiles =
false, &$newString =
'', array &$includedFiles = array(), $optionalProperties =
'', $parentFilenameOrPath =
'')
978 $matches = preg_split(
'#(?i)extensions\s*=\s*"([^"]*)"(\s*|>)#', $optionalProperties, 2, PREG_SPLIT_DELIM_CAPTURE);
979 if (count($matches) > 1) {
980 $includedFileExtensions = $matches[1];
982 $includedFileExtensions =
'';
986 if ($parentFilenameOrPath !==
'' && $dirPath[0] ===
'.') {
989 $resolvedDirPath = $dirPath;
993 $absDirPath = rtrim($absDirPath,
'/') .
'/';
994 $newString .= LF .
'### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath .
'"' . $optionalProperties .
'> BEGIN:' . LF;
998 $prefixLength = strlen(PATH_site);
999 foreach ($fileIndex as $absFileRef) {
1000 $relFileRef = substr($absFileRef, $prefixLength);
1001 self::includeFile($relFileRef, $cycle_counter, $returnFiles, $newString, $includedFiles,
'', $absDirPath);
1003 $newString .=
'### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath .
'"' . $optionalProperties .
'> END:' . LF . LF;
1005 $newString .= self::typoscriptIncludeError(
'The path "' . $resolvedDirPath .
'" is invalid.');
1020 return "\n###\n### ERROR: " . $error .
"\n###\n\n";
1031 foreach ($array as $k => $v) {
1032 $array[$k] = self::checkIncludeLines($array[$k]);
1050 public static function extractIncludes($string, $cycle_counter = 1, array $extractedFileNames = array(), $parentFilenameOrPath =
'')
1052 if ($cycle_counter > 10) {
1053 GeneralUtility::sysLog(
'It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags',
'core',
GeneralUtility::SYSLOG_SEVERITY_WARNING);
1056 ### ERROR: Recursion!
1060 $expectedEndTag =
'';
1061 $fileContent = array();
1062 $restContent = array();
1064 $inIncludePart =
false;
1065 $lines = preg_split(
"/\r\n|\n|\r/", $string);
1066 $skipNextLineIfEmpty =
false;
1067 $openingCommentedIncludeStatement = null;
1068 $optionalProperties =
'';
1069 foreach ($lines as $line) {
1072 if ($skipNextLineIfEmpty) {
1073 if (trim($line) ===
'') {
1076 $skipNextLineIfEmpty =
false;
1080 if (!$inIncludePart) {
1082 if (preg_match(
'/###\\s*<INCLUDE_TYPOSCRIPT:\\s*source\\s*=\\s*"\\s*((?i)file|dir)\\s*:\\s*([^"]*)"(.*)>\\s*BEGIN/i', $line, $matches)) {
1086 $openingCommentedIncludeStatement = trim($line);
1087 $openingCommentedIncludeStatement = preg_replace(
'/\\s*### Warning: .*###\\s*/',
'', $openingCommentedIncludeStatement);
1090 $inIncludePart = strtoupper($matches[1]);
1091 $fileName = $matches[2];
1092 $optionalProperties = $matches[3];
1094 $expectedEndTag =
'### <INCLUDE_TYPOSCRIPT: source="' . $inIncludePart .
':' . $fileName .
'"' . $optionalProperties .
'> END';
1096 $expectedEndTag = strtolower(preg_replace(
'/\s/',
'', $expectedEndTag));
1099 $restContent[] = $line;
1105 $strippedLine = preg_replace(
'/\s/',
'', $line);
1106 if (stripos($strippedLine, $expectedEndTag) !==
false) {
1108 $fileContentString = implode(PHP_EOL, $fileContent);
1113 if ($parentFilenameOrPath !==
'' && $fileName[0] ===
'.') {
1116 $realFileName = $fileName;
1120 if ($inIncludePart ===
'FILE') {
1123 throw new \UnexpectedValueException(sprintf(
'File "%s" was not included since it is not allowed due to fileDenyPattern.', $fileName), 1382651858);
1125 if (empty($realFileName)) {
1126 throw new \UnexpectedValueException(sprintf(
'"%s" is not a valid file location.', $fileName), 1294586441);
1128 if (!is_writable($realFileName)) {
1129 throw new \RuntimeException(sprintf(
'"%s" is not writable.', $fileName), 1294586442);
1131 if (in_array($realFileName, $extractedFileNames)) {
1132 throw new \RuntimeException(sprintf(
'Recursive/multiple inclusion of file "%s"', $realFileName), 1294586443);
1134 $extractedFileNames[] = $realFileName;
1137 $fileContentString = self::extractIncludes($fileContentString, $cycle_counter + 1, $extractedFileNames, $realFileName);
1141 throw new \RuntimeException(sprintf(
'Could not write file "%s"', $realFileName), 1294586444);
1144 $restContent[] =
'<INCLUDE_TYPOSCRIPT: source="FILE:' . $fileName .
'"' . $optionalProperties .
'>';
1149 if (empty($realFileName)) {
1150 throw new \UnexpectedValueException(sprintf(
'"%s" is not a valid location.', $fileName), 1366493602);
1152 if (!is_dir($realFileName)) {
1153 throw new \RuntimeException(sprintf(
'"%s" is not a directory.', $fileName), 1366493603);
1155 if (in_array($realFileName, $extractedFileNames)) {
1156 throw new \RuntimeException(sprintf(
'Recursive/multiple inclusion of directory "%s"', $realFileName), 1366493604);
1158 $extractedFileNames[] = $realFileName;
1161 self::extractIncludes($fileContentString, $cycle_counter + 1, $extractedFileNames, $realFileName);
1166 $restContent[] =
'<INCLUDE_TYPOSCRIPT: source="DIR:' . $fileName .
'"' . $optionalProperties .
'>';
1170 $fileContent = array();
1172 $inIncludePart =
false;
1173 $openingCommentedIncludeStatement = null;
1176 $skipNextLineIfEmpty =
true;
1179 $fileContent[] = $line;
1184 if ($inIncludePart) {
1185 $restContent[] = $openingCommentedIncludeStatement .
' ### Warning: Corresponding end line missing! ###';
1186 $restContent = array_merge($restContent, $fileContent);
1188 $restContentString = implode(PHP_EOL, $restContent);
1189 return $restContentString;
1200 foreach ($array as $k => $v) {
1201 $array[$k] = self::extractIncludes($array[$k]);
1222 $this->syntaxHighLight = 1;
1223 $this->highLightData = array();
1224 $this->errors = array();
1226 $string = str_replace(CR,
'', $string);
1227 $this->
parse($string);
1243 if ($strlen === -1) {
1244 $this->highLightData[$pointer] = array(array($code, 0));
1246 $this->highLightData[$pointer][] = array($code, $strlen);
1264 foreach ($this->errors as $err) {
1265 $errA[$err[2]][] = $err[0];
1269 foreach ($this->raw as
$rawP => $value) {
1271 $strlen = strlen($value);
1273 if (is_array($this->highLightData[
$rawP])) {
1274 foreach ($this->highLightData[$rawP] as $set) {
1275 $len = $strlen - $start - $set[1];
1277 $part = substr($value, $start, $len);
1279 $st = $this->highLightStyles[isset($this->highLightStyles[$set[0]]) ? $set[0] :
'default'];
1280 if (!$highlightBlockMode || $set[0] !==
'prespace') {
1281 $lineC .= $st[0] . htmlspecialchars($part) . $st[1];
1284 debug(array($len, $value, $rawP));
1288 debug(array($value));
1290 if (strlen($value) > $start) {
1291 $lineC .= $this->highLightStyles[
'ignored'][0] . htmlspecialchars(substr($value, $start)) . $this->highLightStyles[
'ignored'][1];
1294 $lineC .= $this->highLightStyles[
'error'][0] .
'<strong> - ERROR:</strong> ' . htmlspecialchars(implode(
';', $errA[$rawP])) . $this->highLightStyles[
'error'][1];
1296 if ($highlightBlockMode && $this->highLightData_bracelevel[$rawP]) {
1297 $lineC = str_pad(
'', $this->highLightData_bracelevel[$rawP] * 2,
' ', STR_PAD_LEFT) .
'<span style="' . $this->highLightBlockStyles . ($this->highLightBlockStyles_basecolor ?
'background-color: ' . $this->
modifyHTMLColorAll($this->highLightBlockStyles_basecolor, -$this->highLightData_bracelevel[$rawP] * 16) :
'') .
'">' . ($lineC !==
'' ? $lineC :
' ') .
'</span>';
1299 if (is_array($lineNumDat)) {
1300 $lineNum = $rawP + $lineNumDat[0];
1302 $lineNum = $this->parentObject->ext_lnBreakPointWrap($lineNum, $lineNum);
1304 $lineC = $this->highLightStyles[
'linenum'][0] . str_pad($lineNum, 4,
' ', STR_PAD_LEFT) .
':' . $this->highLightStyles[
'linenum'][1] .
' ' . $lineC;
1308 return '<pre class="ts-hl">' . implode(LF, $lines) .
'</pre>';
1336 return '#' . substr((
'0' . dechex($nR)), -2) . substr((
'0' . dechex($nG)), -2) . substr((
'0' . dechex($nB)), -2);