2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * TSParser extension class to t3lib_TStemplate
31 * Contains functions for the TS module in TYPO3 backend
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 104: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 193: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 220: function substituteConstants($all)
43 * 249: function substituteCMarkers($all)
44 * 271: function generateConfig_constants()
45 * 320: function ext_getSetup($theSetup,$theKey)
46 * 351: function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")
47 * 446: function lineNumberToScript($lnArr)
48 * 477: function makeHtmlspecialchars($theValue)
49 * 490: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
50 * 530: function ext_getRootlineNumber($pid)
51 * 548: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
52 * 607: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
53 * 638: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
54 * 665: function ext_fixed_lgd($string,$chars)
55 * 681: function ext_lnBreakPointWrap($ln,$str)
56 * 694: function ext_formatTS($input, $ln, $comments=1, $crop=0)
57 * 733: function ext_getFirstTemplate($id,$template_uid=0)
58 * 752: function ext_getAllTemplates($id)
59 * 772: function ext_compareFlatSetups($default)
60 * 838: function ext_categorizeEditableConstants($editConstArray)
61 * 861: function ext_getCategoryLabelArray()
62 * 878: function ext_getTypeData($type)
63 * 919: function ext_getTSCE_config($category)
64 * 958: function ext_getKeyImage($key)
65 * 968: function ext_getTSCE_config_image($imgConf)
66 * 992: function ext_resourceDims()
67 * 1022: function ext_readDirResources($path)
68 * 1037: function readDirectory($path,$type="file")
69 * 1062: function ext_fNandV($params)
70 * 1080: function ext_printFields($theConstants,$category)
72 * SECTION: Processing input values
73 * 1337: function ext_regObjectPositions($constants)
74 * 1352: function ext_regObjects($pre)
75 * 1397: function ext_putValueInConf($key, $var)
76 * 1420: function ext_removeValueInConf($key)
77 * 1436: function ext_depthKeys($arr,$settings)
78 * 1471: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
79 * 1598: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
80 * 1644: function ext_prevPageWithTemplate($id,$perms_clause)
81 * 1660: function ext_setStar($val)
82 * 1672: function ext_detectAndFixExtensionPrefix($value)
85 * (This index is automatically created/updated by the extension "extdeveval")
89 require_once(PATH_t3lib
."class.t3lib_tstemplate.php");
98 * TSParser extension class to t3lib_TStemplate
100 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
104 class t3lib_tsparser_ext
extends t3lib_TStemplate
{
106 var $edit_divider = "###MOD_TS:EDITABLE_CONSTANTS###"; // This string is used to indicate the point in a template from where the editable constants are listed. Any vars before this point (if it exists though) is regarded as default values.
107 var $HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
110 var $categories = array(
111 "basic" => array(), // Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure.
112 "menu" => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
113 "content" => array(), // All constants related to the display of pagecontent elements
114 "page" => array(), // General configuration like metatags, link targets
115 "advanced" => array(), // Advanced functions, which are used very seldomly.
116 "all" => array() // All constants are put here also!
117 ); // This will be filled with the available categories of the current template.
118 var $subCategories = array(
119 // Standard categories:
120 "enable" => Array("Enable features", "a"),
121 "dims" => Array("Dimensions, widths, heights, pixels", "b"),
122 "file" => Array("Files", "c"),
123 "typo" => Array("Typography", "d"),
124 "color" => Array("Colors", "e"),
125 "links" => Array("Links and targets", "f"),
126 "language" => Array("Language specific constants", "g"),
128 // subcategories based on the default content elements
129 "cheader" => Array("Content: 'Header'", "ma"),
130 "cheader_g" => Array("Content: 'Header', Graphical", "ma"),
131 "ctext" => Array("Content: 'Text'", "mb"),
133 "cimage" => Array("Content: 'Image'", "md"),
134 "cbullets" => Array("Content: 'Bullet list'", "me"),
135 "ctable" => Array("Content: 'Table'", "mf"),
136 "cuploads" => Array("Content: 'Filelinks'", "mg"),
137 "cmultimedia" => Array("Content: 'Multimedia'", "mh"),
138 "cmailform" => Array("Content: 'Form'", "mi"),
139 "csearch" => Array("Content: 'Search'", "mj"),
140 "clogin" => Array("Content: 'Login'", "mk"),
141 "csplash" => Array("Content: 'Textbox'", "ml"),
142 "cmenu" => Array("Content: 'Menu/Sitemap'", "mm"),
143 "cshortcut" => Array("Content: 'Insert records'", "mn"),
144 "clist" => Array("Content: 'List of records'", "mo"),
145 "cscript" => Array("Content: 'Script'", "mp"),
146 "chtml" => Array("Content: 'HTML'", "mq")
148 var $resourceDimensions = array();
149 var $dirResources = array();
151 // var $matchAll = 0; // If set, all conditions are matched!
159 var $tsbrowser_searchKeys = array();
160 var $tsbrowser_depthKeys = array();
161 var $constantMode="";
164 var $resourceCheck=0;
165 var $ext_lineNumberOffset=0;
166 var $ext_localGfxPrefix="";
167 var $ext_localWebGfxPrefix="";
168 var $ext_expandAllNotes=0;
169 var $ext_noPMicons=0;
170 var $ext_noSpecialCharsOnLabels=0;
171 var $ext_listOfTemplatesArr=array();
172 var $ext_lineNumberOffset_mode="";
173 var $ext_dontCheckIssetValues=0; // Dont change...
174 var $ext_noCEUploadAndCopying=0;
176 var $ext_CEformName="forms[0]";
177 var $ext_defaultOnlineResourceFlag=0;
178 var $doNotSortCategoriesBeforeMakingForm = FALSE;
181 var $templateTitles=array();
185 * This flattens a hierarchical setuparray to $this->flatSetup
186 * The original function fetched the resource-file if any ("file."). This functions doesn't.
188 * @param [type] $setupArray: ...
189 * @param [type] $prefix: ...
190 * @param [type] $resourceFlag: ...
193 function flattenSetup($setupArray, $prefix, $resourceFlag) {
194 if (is_array($setupArray)) {
195 $this->getFileName_backPath
=PATH_site
; // Setting absolute prefixed path for relative resources.
197 while(list($key,$val)=each($setupArray)) {
198 if ($prefix ||
substr($key,0,16)!="TSConstantEditor") { // We don't want "TSConstantEditor" in the flattend setup.
199 if (is_array($val)) {
200 $this->flattenSetup($val,$prefix.$key, ($key=="file."));
201 } elseif ($resourceFlag && $this->resourceCheck
) {
202 $this->flatSetup
[$prefix.$key] = $this->getFileName($val);
203 if ($this->removeFromGetFilePath
&& substr($this->flatSetup
[$prefix.$key],0,strlen($this->removeFromGetFilePath
))==$this->removeFromGetFilePath
) {
204 $this->flatSetup
[$prefix.$key] = substr($this->flatSetup
[$prefix.$key],strlen($this->removeFromGetFilePath
));
207 $this->flatSetup
[$prefix.$key] = $val;
215 * [Describe function...]
217 * @param [type] $all: ...
220 function substituteConstants($all) {
221 $this->Cmarker
=substr(md5(uniqid("")),0,6);
222 reset($this->flatSetup
);
223 while (list($const,$val)=each($this->flatSetup
)) {
224 if (!is_array($val)) {
225 switch($this->constantMode
) {
227 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##{$'.$const.'}##'.$this->Cmarker
.'_E##',$all);
230 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##'.$val.'##'.$this->Cmarker
.'_E##',$all);
235 $all = str_replace('{$'.$const.'}',$val,$all);
244 * [Describe function...]
246 * @param [type] $all: ...
249 function substituteCMarkers($all) {
250 switch($this->constantMode
) {
252 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
253 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
256 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
257 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
267 * [Describe function...]
271 function generateConfig_constants() {
272 // Parses the constants in $this->const with respect to the constant-editor in this module.
273 // In particular comments in the code are registered and the edit_divider is taken into account.
274 // These vars are also set lateron...
275 $this->setup
["resources"]= $this->resources
;
276 $this->setup
["sitetitle"]= $this->sitetitle
;
279 $constants = t3lib_div
::makeInstance("t3lib_TSparser");
280 $constants->regComments
=1; // Register comments!
281 $constants->setup
= $this->const;
282 $constants->setup
= $this->mergeConstantsFromPageTSconfig($constants->setup
);
284 $matchObj = t3lib_div
::makeInstance("t3lib_matchCondition");
285 // $matchObj->matchAlternative = array("[globalString = page | title = *test*]");
286 $matchObj->matchAll
=1; // Matches ALL conditions in TypoScript
289 $cc=count($this->constants
);
290 reset($this->constants
);
291 while (list(,$str)=each($this->constants
)) {
294 if (strstr($str,$this->edit_divider
)) {
295 $parts = explode($this->edit_divider
,$str,2);
297 $constants->parse($parts[0],$matchObj);
299 $this->flatSetup
= Array();
300 $this->flattenSetup($constants->setup
,"","");
301 $defaultConstants=$this->flatSetup
;
303 $constants->parse($str,$matchObj);
306 $this->flatSetup
= Array();
307 $this->flattenSetup($constants->setup
,"","");
308 $this->setup
["constants"] = $constants->setup
;
310 return $this->ext_compareFlatSetups($defaultConstants);
314 * [Describe function...]
316 * @param [type] $theSetup: ...
317 * @param [type] $theKey: ...
320 function ext_getSetup($theSetup,$theKey) {
321 $parts = explode(".",$theKey,2);
322 // debug("-----------",1);
324 if (strcmp($parts[0],"") && is_array($theSetup[$parts[0]."."])) {
325 // debug(trim($parts[1]),1);
326 if (strcmp(trim($parts[1]),"")) {
327 // debug(trim($parts[1]),1);
328 return $this->ext_getSetup($theSetup[$parts[0]."."],trim($parts[1]));
330 return array($theSetup[$parts[0]."."], $theSetup[$parts[0]]);
333 if (strcmp(trim($theKey),"")) {
334 return array(array(),$theSetup[$theKey]);
336 return array($theSetup,"");
342 * [Describe function...]
344 * @param [type] $arr: ...
345 * @param [type] $depth_in: ...
346 * @param [type] $depthData: ...
347 * @param [type] $parentType: ...
348 * @param [type] $parentValue: ...
351 function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="") {
357 $keyArr_alpha=array();
358 while (list($key,)=each($arr)) {
359 if (substr($key,-2)!="..") { // Don't do anything with comments / linenumber registrations...
360 $key=ereg_replace("\.$","",$key);
361 if (substr($key,-1)!=".") {
362 if (t3lib_div
::testInt($key)) {
363 $keyArr_num[$key]=$arr[$key];
365 $keyArr_alpha[$key]=$arr[$key];
371 $keyArr=$keyArr_num+
$keyArr_alpha;
374 if ($depth_in) {$depth_in = $depth_in.".";}
376 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
377 // debug($validate_info);
379 while (list($key,)=each($keyArr)) {
381 $depth=$depth_in.$key;
382 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
383 $goto = substr(md5($depth),0,6);
385 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
387 $LN = ($a==$c)?
"blank":"line";
388 $BTM = ($a==$c)?
"bottom":"";
389 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
392 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
396 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
397 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
401 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
402 $label='<font color="#666666">'.$label.'</font>';
404 if ($this->linkObjects
) {
405 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
406 if ($this->bType
!="const") {
407 $ln = is_array($arr[$key.'.ln..']) ?
'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
412 if ($this->tsbrowser_searchKeys
[$depth] & 4) { $label = '<b><font color="red">'.$label.'</font></b>'; } // The key has matched the search string
413 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
417 $HTML.="[".$label."]";
419 if (isset($arr[$key])) {
420 $theValue = $arr[$key];
421 if ($this->fixedLgd
) {
422 $imgBlocks = ceil(1+
strlen($depthData)/77);
423 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
424 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
426 if ($this->tsbrowser_searchKeys
[$depth] & 2) { // The value has matched the search string
427 $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
429 $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
435 $HTML.=$this->ext_getObjTree($arr[$key."."], $depth, $depthData.'<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top" alt="" />', $validate_info[$key], $arr[$key]);
443 * [Describe function...]
445 * @param [type] $lnArr: ...
448 function lineNumberToScript($lnArr) {
449 if (!is_array($this->lnToScript
)) {
450 $this->lnToScript
= array();
452 $c+
=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],chr(10))+
2;
453 $this->lnToScript
[$c] = '[Default]';
455 foreach($this->hierarchyInfoToRoot
as $info) {
456 $c+
=$info['configLines']+
1;
457 $this->lnToScript
[$c] = $info['title'];
461 foreach($lnArr as $k => $ln) {
462 foreach($this->lnToScript
as $endLn => $title) {
463 if ($endLn >= intval($ln)) {
464 $lnArr[$k] = '"'.$title.'", '.$ln;
470 return implode('; ',$lnArr);
474 * [Describe function...]
476 * @param [type] $theValue: ...
479 function makeHtmlspecialchars($theValue){
480 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
484 * [Describe function...]
486 * @param [type] $arr: ...
487 * @param [type] $depth_in: ...
488 * @param [type] $searchString: ...
489 * @param [type] $keyArray: ...
492 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
495 while (list($key,)=each($arr)) {
496 $key=ereg_replace('\.$','',$key);
497 if (substr($key,-1)!='.') {
504 if ($depth_in) { $depth_in = $depth_in.'.'; }
505 while (list($key,)=each($keyArr)) {
506 $depth=$depth_in.$key;
507 $deeper = is_array($arr[$key."."]);
509 if ($this->regexMode
) {
510 if (ereg($searchString,$arr[$key])) { // The value has matched
511 $this->tsbrowser_searchKeys
[$depth]+
=2;
513 if (ereg($searchString,$key)) { // The key has matched
514 $this->tsbrowser_searchKeys
[$depth]+
=4;
516 if (ereg($searchString,$depth_in)) { // Just open this subtree if the parent key has matched the search
517 $this->tsbrowser_searchKeys
[$depth]=1;
520 if (stristr($arr[$key],$searchString)) { // The value has matched
521 $this->tsbrowser_searchKeys
[$depth]+
=2;
523 if (stristr($key,$searchString)) { // The key has matches
524 $this->tsbrowser_searchKeys
[$depth]+
=4;
526 if (stristr($depth_in,$searchString)) { // Just open this subtree if the parent key has matched the search
527 $this->tsbrowser_searchKeys
[$depth]=1;
532 $cS = count($this->tsbrowser_searchKeys
);
533 $keyArray = $this->ext_getSearchKeys($arr[$key.'.'], $depth, $searchString, $keyArray);
534 if ($cS != count($this->tsbrowser_searchKeys
)) {
543 * [Describe function...]
545 * @param [type] $pid: ...
548 function ext_getRootlineNumber($pid) {
549 if ($pid && is_array($GLOBALS["rootLine"])) {
550 reset($GLOBALS["rootLine"]);
551 while(list($key,$val)=each($GLOBALS["rootLine"])) {
552 if ($val['uid']==$pid) return $key;
558 * [Describe function...]
560 * @param [type] $arr: ...
561 * @param [type] $depthData: ...
562 * @param [type] $keyArray: ...
563 * @param [type] $first: ...
566 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
569 while (list($key,)=each($arr)) {
570 $key=ereg_replace("\.$","",$key);
571 if (substr($key,-1)!=".") {
578 while (list($key,)=each($keyArr)) {
581 $deeper = is_array($arr[$key."."]);
585 $LN = ($a==$c)?
"blank":"line";
586 $BTM = ($a==$c)?
"top":"";
590 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
591 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
592 $alttext= "[".$row['templateID']."]";
593 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
594 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
595 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
601 $HTML.=($first?
'':'<IMG src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border=0>').'<IMG src="'.$GLOBALS["BACK_PATH"].$icon.'" width="18" height="16" align="top" title="'.$alttext.'">'.$A_B.t3lib_div
::fixed_lgd_cs($row['title'],$GLOBALS["BE_USER"]->uc
["titleLen"]).$A_E." ";
602 $RL = $this->ext_getRootlineNumber($row['pid']);
604 <td nowrap>'.$HTML.'</td>
605 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
606 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
607 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
608 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
609 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
612 $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key."."], $depthData.($first?
'':'<IMG src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top">'), $keyArray);
619 * [Describe function...]
621 * @param [type] $depthDataArr: ...
622 * @param [type] $pointer: ...
625 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
626 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
627 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
629 $row = $this->hierarchyInfo
[$pointer];
631 $depthDataArr[$row['templateID']]=$row;
632 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
633 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
634 unset($this->clearList_setup_temp
[$row['templateID']]);
635 unset($this->clearList_const_temp
[$row['templateID']]);
636 $this->templateTitles
[$row['templateID']]=$row["title"];
638 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
639 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
642 return $depthDataArr;
646 * [Describe function...]
648 * @param [type] $config: ...
649 * @param [type] $lineNumbers: ...
650 * @param [type] $comments: ...
651 * @param [type] $crop: ...
652 * @param [type] $syntaxHL: ...
653 * @param [type] $syntaxHLBlockmode: ...
656 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
659 while (list(,$str)=each($config)) {
660 $all.="\n[GLOBAL]\n".$str;
664 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
666 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
667 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
668 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
670 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
675 * Returns a new string of max. $chars lenght
676 * If the string is longer, it will be truncated and prepended with "..."
677 * $chars must be an integer of at least 4
679 * @param [type] $string: ...
680 * @param [type] $chars: ...
683 function ext_fixed_lgd($string,$chars) {
685 if(strlen($string)>$chars) {
686 return substr($string, 0, $chars-3)."...";
693 * [Describe function...]
695 * @param [type] $ln: ...
696 * @param [type] $str: ...
699 function ext_lnBreakPointWrap($ln,$str) {
700 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
704 * [Describe function...]
706 * @param [type] $input: ...
707 * @param [type] $ln: ...
708 * @param [type] $comments: ...
709 * @param [type] $crop: ...
712 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
713 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
714 $input = chop($input);
715 $cArr = explode(chr(10),$input);
718 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
720 while(list($k,$v)=each($cArr)) {
721 $lln=$k+
$this->ext_lineNumberOffset+
1;
722 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
723 $v=htmlspecialchars($v);
724 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
725 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
727 $firstChar = substr(trim($v),0,1);
728 if ($firstChar=="[") {
729 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
730 } elseif ($firstChar=="/" ||
$firstChar=="#") {
732 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
740 $output = implode($cArr, "<BR>")."<BR>";
745 * [Describe function...]
747 * @param [type] $id: ...
748 * @param [type] $template_uid: ...
751 function ext_getFirstTemplate($id,$template_uid=0) {
752 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
755 $addC = " AND uid=".$template_uid;
757 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause
, '', 'sorting', '1');
758 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
759 t3lib_BEfunc
::workspaceOL('sys_template',$row);
760 $GLOBALS['TYPO3_DB']->sql_free_result($res);
761 return $row; // Returns the template row if found.
766 * [Describe function...]
768 * @param [type] $id: ...
771 function ext_getAllTemplates($id) {
772 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
775 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
776 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
777 t3lib_BEfunc
::workspaceOL('sys_template',$row);
778 if (is_array($row)) $outRes[] = $row;
780 $GLOBALS['TYPO3_DB']->sql_free_result($res);
781 return $outRes; // Returns the template rows in an array.
786 * This function compares the flattened constants (default and all).
787 * Returns an array with the constants from the whole template which may be edited by the module.
789 * @param [type] $default: ...
792 function ext_compareFlatSetups($default) {
793 $editableComments=array();
794 reset($this->flatSetup
);
795 while(list($const,$value)=each($this->flatSetup
)) {
796 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
797 $comment = trim($this->flatSetup
[$const.".."]);
798 $c_arr = explode(chr(10),$comment);
799 while(list($k,$v)=each($c_arr)) {
800 $line=trim(ereg_replace("^[#\/]*","",$v));
802 $parts = explode(";", $line);
803 while(list(,$par)=each($parts)) {
804 if (strstr($par,"=")) {
805 $keyValPair =explode("=",$par,2);
806 switch(trim(strtolower($keyValPair[0]))) {
810 int (range; low-high, list: item,item,item = selector),
817 $editableComments[$const]["type"] = trim($keyValPair[1]);
820 // list of categories.
821 $catSplit=explode("/",strtolower($keyValPair[1]));
822 $editableComments[$const]["cat"] = trim($catSplit[0]);
823 $catSplit[1]=trim($catSplit[1]); // This is the subcategory. Must be a key in $this->subCategories[]. catSplit[2] represents the search-order within the subcat.
824 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
825 $editableComments[$const]["subcat_name"]=$catSplit[1];
826 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
828 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
833 $editableComments[$const]["label"] = trim($keyValPair[1]);
841 if (isset($editableComments[$const])) {
842 $editableComments[$const]["name"]=$const;
843 $editableComments[$const]["value"]=trim($value);
844 if (isset($default[$const])) {
845 $editableComments[$const]["default_value"]=trim($default[$const]);
849 return $editableComments;
853 * [Describe function...]
855 * @param [type] $editConstArray: ...
858 function ext_categorizeEditableConstants($editConstArray) {
859 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
860 reset($editConstArray);
861 while(list($constName,$constData)=each($editConstArray)) {
862 if (!$constData["type"]) {$constData["type"]="string";}
863 $cats = explode(",",$constData["cat"]);
865 while (list(,$theCat)=each($cats)) { // if = only one category, while allows for many. We have agreed on only one category is the most basic way...
866 $theCat=trim($theCat);
868 $this->categories
[$theCat][$constName]=$constData["subcat"];
869 // $this->categories["all"][$constName]=$constData["subcat"];
873 // debug($this->categories);
877 * [Describe function...]
881 function ext_getCategoryLabelArray() {
882 // Returns array used for labels in the menu.
884 while(list($k,$v)=each($this->categories
)) {
886 $retArr[$k]=strtoupper($k)." (".count($v).")";
893 * [Describe function...]
895 * @param [type] $type: ...
898 function ext_getTypeData($type) {
902 $retArr["type"]="string";
904 $m=strcspn ($type," [");
905 $retArr["type"]=strtolower(substr($type,0,$m));
906 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
907 $p=trim(substr($type,$m));
908 ereg("\[(.*)\]",$p,$reg);
911 $retArr["paramstr"]=$p;
912 switch($retArr["type"]) {
914 if (substr($retArr["paramstr"],0,1)=="-") {
915 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
916 $retArr["params"][0]=intval("-".$retArr["params"][0]);
918 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
920 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
923 $retArr["params"]=explode(",",$retArr["paramstr"]);
934 * [Describe function...]
936 * @param [type] $category: ...
939 function ext_getTSCE_config($category) {
940 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
942 if (is_array($catConf)) {
944 while(list($key,$val)=each($catConf)) {
947 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
955 if (t3lib_div
::testInt($key)) {
956 $constRefs = explode(",",$val);
958 while(list(,$const)=each($constRefs)) {
960 if ($const && $const<=20) {
961 $out["constants"][$const].=$this->ext_getKeyImage($key);
969 $this->helpConfig
=$out;
973 * [Describe function...]
975 * @param [type] $key: ...
978 function ext_getKeyImage($key) {
979 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
983 * [Describe function...]
985 * @param [type] $imgConf: ...
988 function ext_getTSCE_config_image($imgConf) {
989 if (substr($imgConf,0,4)=="gfx/") {
990 $iFile=$this->ext_localGfxPrefix
.$imgConf;
991 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
992 } elseif (substr($imgConf,0,4)=='EXT:') {
993 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
995 $f = substr($iFile,strlen(PATH_site
));
996 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
999 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
1000 $iFile=PATH_site
.$f;
1001 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
1003 $imageInfo=@getImagesize
($iFile);
1004 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
1008 * [Describe function...]
1010 * @return [type] ...
1012 function ext_resourceDims() {
1013 if ($this->setup
["resources"]) {
1014 $rArr=explode(",",$this->setup
["resources"]);
1015 while(list($c,$val)=each($rArr)) {
1017 $theFile = PATH_site
."uploads/tf/".$val;
1018 if ($val && @is_file
($theFile)) {
1019 $imgInfo = @getimagesize
($theFile);
1021 if (is_array($imgInfo)) {
1022 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1026 reset($this->dirResources
);
1027 while(list($c,$val)=each($this->dirResources
)) {
1029 $imgInfo = @getimagesize
(PATH_site
.$val);
1030 if (is_array($imgInfo)) {
1031 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1037 * [Describe function...]
1039 * @param [type] $path: ...
1040 * @return [type] ...
1042 function ext_readDirResources($path) {
1044 if ($path && substr($path,0,10)=="fileadmin/") {
1045 $path = ereg_replace("\/$","",$path);
1046 $this->readDirectory(PATH_site
.$path);
1051 * [Describe function...]
1053 * @param [type] $path: ...
1054 * @param [type] $type: ...
1055 * @return [type] ...
1057 function readDirectory($path,$type="file") {
1058 if(@is_dir
($path)) {
1061 if (is_object($d)) {
1062 while($entry=$d->read()) {
1063 if ($entry!="." && $entry!="..") {
1064 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1065 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1066 $fI = t3lib_div
::split_fileref($wholePath);
1067 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1077 * [Describe function...]
1079 * @param [type] $params: ...
1080 * @return [type] ...
1082 function ext_fNandV($params) {
1083 $fN='data['.$params["name"].']';
1084 $fV=$params["value"];
1085 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1088 $fV=htmlspecialchars($fV);
1090 return array($fN,$fV,$params);
1094 * [Describe function...]
1096 * @param [type] $theConstants: ...
1097 * @param [type] $category: ...
1098 * @return [type] ...
1100 function ext_printFields($theConstants,$category) {
1101 // This functions returns the HTML-code that creates the editor-layout of the module.
1102 reset($theConstants);
1105 if (is_array($this->categories
[$category])) {
1107 $help=$this->helpConfig
;
1108 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1110 if (!$this->doNotSortCategoriesBeforeMakingForm
) asort($this->categories
[$category]);
1111 while(list($name,$type)=each($this->categories
[$category])) {
1112 $params = $theConstants[$name];
1113 if (is_array($params)) {
1114 if ($subcat!=$params["subcat_name"]) {
1115 $subcat=$params["subcat_name"];
1116 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1118 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1122 // if (substr($params["value"],0,2)!='{$') {
1123 $label=$GLOBALS["LANG"]->sL($params["label"]);
1124 $label_parts = explode(":",$label,2);
1125 if (count($label_parts)==2) {
1126 $head=trim($label_parts[0]);
1127 $body=trim($label_parts[1]);
1129 $head=trim($label_parts[0]);
1132 if (strlen($head)>35) {
1133 if (!$body) {$body=$head;}
1134 $head=t3lib_div
::fixed_lgd_cs($head,35);
1136 $typeDat=$this->ext_getTypeData($params["type"]);
1139 $raname = substr(md5($params["name"]),0,10);
1140 $aname="'".$raname."'";
1141 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1142 $checked=" checked";
1143 list($fN,$fV,$params)=$this->ext_fNandV($params);
1145 switch($typeDat["type"]) {
1148 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1149 if ($typeDat["paramstr"]) {
1150 $p_field.=' Range: '.$typeDat["paramstr"];
1151 } elseif ($typeDat["type"]=="int+") {
1152 $p_field.=' Range: 0 - ';
1154 $p_field.=' (Integer)';
1158 $colorNames=explode(",",",".$this->HTMLcolorList
);
1160 while(list(,$val)=each($colorNames)) {
1162 if ($val==strtolower($params["value"])) {$sel=" selected";}
1163 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1165 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1167 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1170 $wArr = explode("|",$fV);
1171 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1173 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1176 $wArr = explode(",",$fV);
1177 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1178 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1180 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1181 for ($aa=2;$aa<count($labels);$aa++
) {
1183 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1185 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1190 if (is_array($typeDat["params"])) {
1192 while(list(,$val)=each($typeDat["params"])) {
1193 $vParts = explode("=",$val,2);
1194 $label = $vParts[0];
1195 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1199 if ($val==$params["value"]) {$sel=" selected";}
1200 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1202 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1206 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1207 $sel=""; if ($fV) {$sel=" checked";}
1208 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1211 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1212 $sel=""; if (!$fV) {$sel=" checked";}
1213 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1216 $p_field='<option value=""></option>';
1217 // debug($params["value"]);
1220 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1221 if ($params["value"] && !$selectThisFile) {
1222 if (in_array($params["value"],$this->dirResources
)) {
1223 $selectThisFile=$params["value"];
1226 // debug($selectThisFile);
1228 $extList = $typeDat["paramstr"];
1229 $p_field='<option value="">('.$extList.')</option>';
1230 if ($extList=="IMAGE_EXT") {
1231 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1234 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1236 while(list($c,$val)=each($this->rArr
)) {
1238 $fI=t3lib_div
::split_fileref($val);
1240 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1241 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1242 if ($onlineResourceFlag<0) {
1243 $p_field.='<option value=""></option>';
1245 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1246 $onlineResourceFlag=1;
1248 $dims=$this->resourceDimensions
[$val];
1251 // Check if $params["value"] is in the list of resources.
1252 if ($selectThisFile && $selectThisFile==$val) {
1254 if ($onlineResourceFlag<=0) {
1255 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1257 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1261 if ($onlineResourceFlag<=0) {
1262 $onlineResourceFlag--;
1263 // Value is set with a *
1264 $val = $this->ext_setStar($val);
1265 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1267 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1271 if (trim($params["value"]) && !$selectThisFile) {
1272 $val = $params["value"];
1273 $p_field.='<option value=""></option>';
1274 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1277 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1278 $p_field.=$theImage;
1280 if (!$this->ext_noCEUploadAndCopying
) {
1282 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1284 if ($params["value"]) {
1285 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1288 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1292 if ($copyFile && @is_file
($copyFile)) {
1293 $p_field.='<img src="clear.gif" width="20" height="1" alt="" /><img'.t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'],'gfx/clip_copy.gif','width="12" height="12"').' border="0" alt="" /><input type="Checkbox" name="_copyResource['.$params["name"].']" value="'.htmlspecialchars($copyFile).'" onClick="uFormUrl('.$aname.');if (this.checked) {alert(unescape(\''.rawurlencode(sprintf("This will make a copy of the current file, '%s'. Do you really want that?",$params["value"])).'\'));}">';
1297 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1302 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1303 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1307 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1308 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1309 $p_field='<table border=0 cellpadding=0 cellspacing=0><tr><td nowrap>'.$p_field.'</td><td> </td><td bgcolor="'.$params["value"].'"><img src="clear.gif" width=50 height=10></td></tr></table>';
1311 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1314 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1315 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1316 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1317 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1320 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1321 $output.='<td valign=top align="right">'.$p_name.'</td>';
1324 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1328 debug("Error. Constant did not exits. Should not happen.");
1331 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1347 /***************************
1349 * Processing input values
1351 ***************************/
1354 * @param [type] $constants: ...
1355 * @return [type] ...
1357 function ext_regObjectPositions($constants) {
1358 // This runs through the lines of the constants-field of the active template and registers the constants-names and linepositions in an array, $this->objReg
1359 $this->raw
= explode(chr(10),$constants);
1362 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1363 $this->ext_regObjects("");
1367 * [Describe function...]
1369 * @param [type] $pre: ...
1370 * @return [type] ...
1372 function ext_regObjects($pre) {
1373 // works with regObjectPositions. "expands" the names of the TypoScript objects
1374 while (isset($this->raw
[$this->rawP
])) {
1375 $line = ltrim($this->raw
[$this->rawP
]);
1376 if (strstr($line,$this->edit_divider
)) {
1377 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1381 if (substr($line,0,1)=="[") {
1383 } elseif (strcspn($line,"}#/")!=0) {
1384 $varL = strcspn($line," {=<");
1385 $var=substr($line,0,$varL);
1386 $line = ltrim(substr($line,$varL));
1387 switch(substr($line,0,1)) {
1389 $this->objReg
[$pre.$var]=$this->rawP
-1;
1392 $this->ext_inBrace++
;
1393 $this->ext_regObjects($pre.$var.".");
1396 $this->lastComment
="";
1397 } elseif (substr($line,0,1)=="}") {
1398 $this->lastComment
="";
1399 $this->ext_inBrace
--;
1400 if ($this->ext_inBrace
<0) {
1401 $this->ext_inBrace
=0;
1411 * [Describe function...]
1413 * @param [type] $key: ...
1414 * @param [type] $var: ...
1415 * @return [type] ...
1417 function ext_putValueInConf($key, $var) {
1418 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1419 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1420 $theValue = " ".trim($var);
1421 if (isset($this->objReg
[$key])) {
1422 $lineNum = $this->objReg
[$key];
1423 $parts = explode("=",$this->raw
[$lineNum],2);
1424 if (count($parts)==2) {
1425 $parts[1]= $theValue;
1427 $this->raw
[$lineNum]=implode($parts,"=");
1429 $this->raw
[]=$key." =".$theValue;
1435 * [Describe function...]
1437 * @param [type] $key: ...
1438 * @return [type] ...
1440 function ext_removeValueInConf($key) {
1441 // Removes the value in the configuration
1442 if (isset($this->objReg
[$key])) {
1443 $lineNum = $this->objReg
[$key];
1444 unset($this->raw
[$lineNum]);
1450 * [Describe function...]
1452 * @param [type] $arr: ...
1453 * @param [type] $settings: ...
1454 * @return [type] ...
1456 function ext_depthKeys($arr,$settings) {
1459 while(list($theK,$theV)=each($arr)) {
1460 $theKeyParts = explode(".",$theK);
1462 $c=count($theKeyParts);
1464 while(list(,$p)=each($theKeyParts)) {
1466 $depth.=($depth?
".":"").$p;
1467 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1472 while(list($theK,$theV)=each($tsbrArray)) {
1474 $settings[$theK] = 1;
1476 unset($settings[$theK]);
1483 * [Describe function...]
1485 * @param [type] $http_post_vars: ...
1486 * @param [type] $http_post_files: ...
1487 * @param [type] $theConstants: ...
1488 * @param [type] $tplRow: ...
1489 * @return [type] ...
1491 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1492 $data=$http_post_vars["data"];
1493 $check=$http_post_vars["check"];
1494 $copyResource=$http_post_vars["_copyResource"];
1495 $Wdata=$http_post_vars["Wdata"];
1496 $W2data=$http_post_vars["W2data"];
1497 $W3data=$http_post_vars["W3data"];
1498 $W4data=$http_post_vars["W4data"];
1499 $W5data=$http_post_vars["W5data"];
1501 if (is_array($data)) {
1503 while(list($key,$var)=each($data)) {
1504 if (isset($theConstants[$key])) {
1505 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1506 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1507 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1508 switch($typeDat["type"]) {
1510 if ($typeDat["paramstr"]) {
1511 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1517 $var=t3lib_div
::intInRange($var,0,10000);
1521 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1522 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1523 $col[]=HexDec(substr($var,0,2));
1524 $col[]=HexDec(substr($var,2,2));
1525 $col[]=HexDec(substr($var,4,2));
1526 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1537 if (isset($Wdata[$key])) {
1538 $var.="|".$Wdata[$key];
1542 if (isset($Wdata[$key])) {
1543 $var=intval($var).",".intval($Wdata[$key]);
1544 if (isset($W2data[$key])) {
1545 $var.=",".intval($W2data[$key]);
1546 if (isset($W3data[$key])) {
1547 $var.=",".intval($W3data[$key]);
1548 if (isset($W4data[$key])) {
1549 $var.=",".intval($W4data[$key]);
1550 if (isset($W5data[$key])) {
1551 $var.=",".intval($W5data[$key]);
1560 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1564 if (!$this->ext_noCEUploadAndCopying
) {
1565 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1566 $var = $this->upload_copy_file(
1569 trim($http_post_files["upload_data"]["name"][$key]),
1570 $http_post_files["upload_data"]["tmp_name"][$key]
1573 if ($copyResource[$key]) {
1574 $var = $this->upload_copy_file(
1577 basename($copyResource[$key]),
1584 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1585 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1587 unset($check[$key]); // Remove the entry because it has been "used"
1589 $this->ext_removeValueInConf($key);
1594 // Remaining keys in $check indicates fields that are just clicked "on" to be edited. Therefore we get the default value and puts that in the template as a start...
1595 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1597 while(list($key,$var)=each($check)) {
1598 if (isset($theConstants[$key])) {
1599 $dValue = $theConstants[$key]["default_value"];
1601 $this->ext_putValueInConf($key, $dValue);
1606 // debug($this->objReg);
1610 * [Describe function...]
1612 * @param [type] $typeDat: ...
1613 * @param [type] $tplRow: ...
1614 * @param [type] $theRealFileName: ...
1615 * @param [type] $tmp_name: ...
1616 * @return [type] ...
1618 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1621 $extList = $typeDat["paramstr"];
1622 if ($extList=="IMAGE_EXT") {
1623 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1625 $fI=t3lib_div
::split_fileref($theRealFileName);
1626 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1627 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1630 $alternativeFileName=array();
1631 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1632 // Making list of resources
1633 $resList = $tplRow["resources"];
1634 $resList = $tmp_upload_name.",".$resList;
1635 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1636 // Making data-array
1637 $saveId = $tplRow['_ORIG_uid'] ?
$tplRow['_ORIG_uid'] : $tplRow['uid'];
1640 $recData["sys_template"][$saveId]["resources"] = $resList;
1642 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1643 $tce->stripslashes_values
=0;
1644 $tce->alternativeFileName
= $alternativeFileName;
1645 $tce->start($recData,Array());
1646 $tce->process_datamap();
1648 t3lib_div
::unlink_tempfile($tmp_upload_name);
1650 $tmpRow = t3lib_BEfunc
::getRecordWSOL("sys_template",$saveId,"resources");
1652 $tplRow["resources"] = $tmpRow["resources"];
1654 // Setting the value
1655 $var = $this->ext_setStar($theRealFileName);
1661 * [Describe function...]
1663 * @param [type] $id: ...
1664 * @param [type] $perms_clause: ...
1665 * @return [type] ...
1667 function ext_prevPageWithTemplate($id,$perms_clause) {
1668 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1670 while(list(,$p)=each($rootLine)) {
1671 if ($this->ext_getFirstTemplate($p["uid"])) {
1678 * [Describe function...]
1680 * @param [type] $val: ...
1681 * @return [type] ...
1683 function ext_setStar($val) {
1684 $fParts = explode(".",strrev($val),2);
1685 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1690 * [Describe function...]
1692 * @param [type] $value: ...
1693 * @return [type] ...
1695 function ext_detectAndFixExtensionPrefix($value) {
1696 if (substr($value,0,4)=="EXT:") {
1697 $parts = explode("/",substr($value,4),2);
1699 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1700 $value = $extPath.$parts[1];
1709 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1710 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);