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 $GLOBALS['TYPO3_DB']->sql_free_result($res);
760 return $row; // Returns the template row if found.
765 * [Describe function...]
767 * @param [type] $id: ...
770 function ext_getAllTemplates($id) {
771 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
774 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
775 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
778 $GLOBALS['TYPO3_DB']->sql_free_result($res);
779 return $outRes; // Returns the template rows in an array.
784 * This function compares the flattened constants (default and all).
785 * Returns an array with the constants from the whole template which may be edited by the module.
787 * @param [type] $default: ...
790 function ext_compareFlatSetups($default) {
791 $editableComments=array();
792 reset($this->flatSetup
);
793 while(list($const,$value)=each($this->flatSetup
)) {
794 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
795 $comment = trim($this->flatSetup
[$const.".."]);
796 $c_arr = explode(chr(10),$comment);
797 while(list($k,$v)=each($c_arr)) {
798 $line=trim(ereg_replace("^[#\/]*","",$v));
800 $parts = explode(";", $line);
801 while(list(,$par)=each($parts)) {
802 if (strstr($par,"=")) {
803 $keyValPair =explode("=",$par,2);
804 switch(trim(strtolower($keyValPair[0]))) {
808 int (range; low-high, list: item,item,item = selector),
815 $editableComments[$const]["type"] = trim($keyValPair[1]);
818 // list of categories.
819 $catSplit=explode("/",strtolower($keyValPair[1]));
820 $editableComments[$const]["cat"] = trim($catSplit[0]);
821 $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.
822 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
823 $editableComments[$const]["subcat_name"]=$catSplit[1];
824 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
826 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
831 $editableComments[$const]["label"] = trim($keyValPair[1]);
839 if (isset($editableComments[$const])) {
840 $editableComments[$const]["name"]=$const;
841 $editableComments[$const]["value"]=trim($value);
842 if (isset($default[$const])) {
843 $editableComments[$const]["default_value"]=trim($default[$const]);
847 return $editableComments;
851 * [Describe function...]
853 * @param [type] $editConstArray: ...
856 function ext_categorizeEditableConstants($editConstArray) {
857 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
858 reset($editConstArray);
859 while(list($constName,$constData)=each($editConstArray)) {
860 if (!$constData["type"]) {$constData["type"]="string";}
861 $cats = explode(",",$constData["cat"]);
863 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...
864 $theCat=trim($theCat);
866 $this->categories
[$theCat][$constName]=$constData["subcat"];
867 // $this->categories["all"][$constName]=$constData["subcat"];
871 // debug($this->categories);
875 * [Describe function...]
879 function ext_getCategoryLabelArray() {
880 // Returns array used for labels in the menu.
882 while(list($k,$v)=each($this->categories
)) {
884 $retArr[$k]=strtoupper($k)." (".count($v).")";
891 * [Describe function...]
893 * @param [type] $type: ...
896 function ext_getTypeData($type) {
900 $retArr["type"]="string";
902 $m=strcspn ($type," [");
903 $retArr["type"]=strtolower(substr($type,0,$m));
904 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
905 $p=trim(substr($type,$m));
906 ereg("\[(.*)\]",$p,$reg);
909 $retArr["paramstr"]=$p;
910 switch($retArr["type"]) {
912 if (substr($retArr["paramstr"],0,1)=="-") {
913 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
914 $retArr["params"][0]=intval("-".$retArr["params"][0]);
916 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
918 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
921 $retArr["params"]=explode(",",$retArr["paramstr"]);
932 * [Describe function...]
934 * @param [type] $category: ...
937 function ext_getTSCE_config($category) {
938 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
940 if (is_array($catConf)) {
942 while(list($key,$val)=each($catConf)) {
945 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
953 if (t3lib_div
::testInt($key)) {
954 $constRefs = explode(",",$val);
956 while(list(,$const)=each($constRefs)) {
958 if ($const && $const<=20) {
959 $out["constants"][$const].=$this->ext_getKeyImage($key);
967 $this->helpConfig
=$out;
971 * [Describe function...]
973 * @param [type] $key: ...
976 function ext_getKeyImage($key) {
977 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
981 * [Describe function...]
983 * @param [type] $imgConf: ...
986 function ext_getTSCE_config_image($imgConf) {
987 if (substr($imgConf,0,4)=="gfx/") {
988 $iFile=$this->ext_localGfxPrefix
.$imgConf;
989 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
990 } elseif (substr($imgConf,0,4)=='EXT:') {
991 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
993 $f = substr($iFile,strlen(PATH_site
));
994 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
997 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
999 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
1001 $imageInfo=@getImagesize
($iFile);
1002 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
1006 * [Describe function...]
1008 * @return [type] ...
1010 function ext_resourceDims() {
1011 if ($this->setup
["resources"]) {
1012 $rArr=explode(",",$this->setup
["resources"]);
1013 while(list($c,$val)=each($rArr)) {
1015 $theFile = PATH_site
."uploads/tf/".$val;
1016 if ($val && @is_file
($theFile)) {
1017 $imgInfo = @getimagesize
($theFile);
1019 if (is_array($imgInfo)) {
1020 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1024 reset($this->dirResources
);
1025 while(list($c,$val)=each($this->dirResources
)) {
1027 $imgInfo = @getimagesize
(PATH_site
.$val);
1028 if (is_array($imgInfo)) {
1029 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1035 * [Describe function...]
1037 * @param [type] $path: ...
1038 * @return [type] ...
1040 function ext_readDirResources($path) {
1042 if ($path && substr($path,0,10)=="fileadmin/") {
1043 $path = ereg_replace("\/$","",$path);
1044 $this->readDirectory(PATH_site
.$path);
1049 * [Describe function...]
1051 * @param [type] $path: ...
1052 * @param [type] $type: ...
1053 * @return [type] ...
1055 function readDirectory($path,$type="file") {
1056 if(@is_dir
($path)) {
1059 if (is_object($d)) {
1060 while($entry=$d->read()) {
1061 if ($entry!="." && $entry!="..") {
1062 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1063 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1064 $fI = t3lib_div
::split_fileref($wholePath);
1065 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1075 * [Describe function...]
1077 * @param [type] $params: ...
1078 * @return [type] ...
1080 function ext_fNandV($params) {
1081 $fN='data['.$params["name"].']';
1082 $fV=$params["value"];
1083 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1086 $fV=htmlspecialchars($fV);
1088 return array($fN,$fV,$params);
1092 * [Describe function...]
1094 * @param [type] $theConstants: ...
1095 * @param [type] $category: ...
1096 * @return [type] ...
1098 function ext_printFields($theConstants,$category) {
1099 // This functions returns the HTML-code that creates the editor-layout of the module.
1100 reset($theConstants);
1103 if (is_array($this->categories
[$category])) {
1105 $help=$this->helpConfig
;
1106 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1108 if (!$this->doNotSortCategoriesBeforeMakingForm
) asort($this->categories
[$category]);
1109 while(list($name,$type)=each($this->categories
[$category])) {
1110 $params = $theConstants[$name];
1111 if (is_array($params)) {
1112 if ($subcat!=$params["subcat_name"]) {
1113 $subcat=$params["subcat_name"];
1114 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1116 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1120 // if (substr($params["value"],0,2)!='{$') {
1121 $label=$GLOBALS["LANG"]->sL($params["label"]);
1122 $label_parts = explode(":",$label,2);
1123 if (count($label_parts)==2) {
1124 $head=trim($label_parts[0]);
1125 $body=trim($label_parts[1]);
1127 $head=trim($label_parts[0]);
1130 if (strlen($head)>35) {
1131 if (!$body) {$body=$head;}
1132 $head=t3lib_div
::fixed_lgd_cs($head,35);
1134 $typeDat=$this->ext_getTypeData($params["type"]);
1137 $raname = substr(md5($params["name"]),0,10);
1138 $aname="'".$raname."'";
1139 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1140 $checked=" checked";
1141 list($fN,$fV,$params)=$this->ext_fNandV($params);
1143 switch($typeDat["type"]) {
1146 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1147 if ($typeDat["paramstr"]) {
1148 $p_field.=' Range: '.$typeDat["paramstr"];
1149 } elseif ($typeDat["type"]=="int+") {
1150 $p_field.=' Range: 0 - ';
1152 $p_field.=' (Integer)';
1156 $colorNames=explode(",",",".$this->HTMLcolorList
);
1158 while(list(,$val)=each($colorNames)) {
1160 if ($val==strtolower($params["value"])) {$sel=" selected";}
1161 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1163 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1165 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1168 $wArr = explode("|",$fV);
1169 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1171 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1174 $wArr = explode(",",$fV);
1175 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1176 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1178 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1179 for ($aa=2;$aa<count($labels);$aa++
) {
1181 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1183 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1188 if (is_array($typeDat["params"])) {
1190 while(list(,$val)=each($typeDat["params"])) {
1191 $vParts = explode("=",$val,2);
1192 $label = $vParts[0];
1193 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1197 if ($val==$params["value"]) {$sel=" selected";}
1198 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1200 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1204 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1205 $sel=""; if ($fV) {$sel=" checked";}
1206 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1209 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1210 $sel=""; if (!$fV) {$sel=" checked";}
1211 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1214 $p_field='<option value=""></option>';
1215 // debug($params["value"]);
1218 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1219 if ($params["value"] && !$selectThisFile) {
1220 if (in_array($params["value"],$this->dirResources
)) {
1221 $selectThisFile=$params["value"];
1224 // debug($selectThisFile);
1226 $extList = $typeDat["paramstr"];
1227 $p_field='<option value="">('.$extList.')</option>';
1228 if ($extList=="IMAGE_EXT") {
1229 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1232 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1234 while(list($c,$val)=each($this->rArr
)) {
1236 $fI=t3lib_div
::split_fileref($val);
1238 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1239 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1240 if ($onlineResourceFlag<0) {
1241 $p_field.='<option value=""></option>';
1243 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1244 $onlineResourceFlag=1;
1246 $dims=$this->resourceDimensions
[$val];
1249 // Check if $params["value"] is in the list of resources.
1250 if ($selectThisFile && $selectThisFile==$val) {
1252 if ($onlineResourceFlag<=0) {
1253 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1255 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1259 if ($onlineResourceFlag<=0) {
1260 $onlineResourceFlag--;
1261 // Value is set with a *
1262 $val = $this->ext_setStar($val);
1263 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1265 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1269 if (trim($params["value"]) && !$selectThisFile) {
1270 $val = $params["value"];
1271 $p_field.='<option value=""></option>';
1272 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1275 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1276 $p_field.=$theImage;
1278 if (!$this->ext_noCEUploadAndCopying
) {
1280 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1282 if ($params["value"]) {
1283 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1286 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1290 if ($copyFile && @is_file
($copyFile)) {
1291 $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"])).'\'));}">';
1295 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1300 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1301 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1305 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1306 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1307 $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>';
1309 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1312 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1313 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1314 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1315 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1318 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1319 $output.='<td valign=top align="right">'.$p_name.'</td>';
1322 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1326 debug("Error. Constant did not exits. Should not happen.");
1329 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1345 /***************************
1347 * Processing input values
1349 ***************************/
1352 * @param [type] $constants: ...
1353 * @return [type] ...
1355 function ext_regObjectPositions($constants) {
1356 // 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
1357 $this->raw
= explode(chr(10),$constants);
1360 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1361 $this->ext_regObjects("");
1365 * [Describe function...]
1367 * @param [type] $pre: ...
1368 * @return [type] ...
1370 function ext_regObjects($pre) {
1371 // works with regObjectPositions. "expands" the names of the TypoScript objects
1372 while (isset($this->raw
[$this->rawP
])) {
1373 $line = ltrim($this->raw
[$this->rawP
]);
1374 if (strstr($line,$this->edit_divider
)) {
1375 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1379 if (substr($line,0,1)=="[") {
1381 } elseif (strcspn($line,"}#/")!=0) {
1382 $varL = strcspn($line," {=<");
1383 $var=substr($line,0,$varL);
1384 $line = ltrim(substr($line,$varL));
1385 switch(substr($line,0,1)) {
1387 $this->objReg
[$pre.$var]=$this->rawP
-1;
1390 $this->ext_inBrace++
;
1391 $this->ext_regObjects($pre.$var.".");
1394 $this->lastComment
="";
1395 } elseif (substr($line,0,1)=="}") {
1396 $this->lastComment
="";
1397 $this->ext_inBrace
--;
1398 if ($this->ext_inBrace
<0) {
1399 $this->ext_inBrace
=0;
1409 * [Describe function...]
1411 * @param [type] $key: ...
1412 * @param [type] $var: ...
1413 * @return [type] ...
1415 function ext_putValueInConf($key, $var) {
1416 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1417 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1418 $theValue = " ".trim($var);
1419 if (isset($this->objReg
[$key])) {
1420 $lineNum = $this->objReg
[$key];
1421 $parts = explode("=",$this->raw
[$lineNum],2);
1422 if (count($parts)==2) {
1423 $parts[1]= $theValue;
1425 $this->raw
[$lineNum]=implode($parts,"=");
1427 $this->raw
[]=$key." =".$theValue;
1433 * [Describe function...]
1435 * @param [type] $key: ...
1436 * @return [type] ...
1438 function ext_removeValueInConf($key) {
1439 // Removes the value in the configuration
1440 if (isset($this->objReg
[$key])) {
1441 $lineNum = $this->objReg
[$key];
1442 unset($this->raw
[$lineNum]);
1448 * [Describe function...]
1450 * @param [type] $arr: ...
1451 * @param [type] $settings: ...
1452 * @return [type] ...
1454 function ext_depthKeys($arr,$settings) {
1457 while(list($theK,$theV)=each($arr)) {
1458 $theKeyParts = explode(".",$theK);
1460 $c=count($theKeyParts);
1462 while(list(,$p)=each($theKeyParts)) {
1464 $depth.=($depth?
".":"").$p;
1465 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1470 while(list($theK,$theV)=each($tsbrArray)) {
1472 $settings[$theK] = 1;
1474 unset($settings[$theK]);
1481 * [Describe function...]
1483 * @param [type] $http_post_vars: ...
1484 * @param [type] $http_post_files: ...
1485 * @param [type] $theConstants: ...
1486 * @param [type] $tplRow: ...
1487 * @return [type] ...
1489 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1490 $data=$http_post_vars["data"];
1491 $check=$http_post_vars["check"];
1492 $copyResource=$http_post_vars["_copyResource"];
1493 $Wdata=$http_post_vars["Wdata"];
1494 $W2data=$http_post_vars["W2data"];
1495 $W3data=$http_post_vars["W3data"];
1496 $W4data=$http_post_vars["W4data"];
1497 $W5data=$http_post_vars["W5data"];
1499 if (is_array($data)) {
1501 while(list($key,$var)=each($data)) {
1502 if (isset($theConstants[$key])) {
1503 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1504 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1505 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1506 switch($typeDat["type"]) {
1508 if ($typeDat["paramstr"]) {
1509 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1515 $var=t3lib_div
::intInRange($var,0,10000);
1519 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1520 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1521 $col[]=HexDec(substr($var,0,2));
1522 $col[]=HexDec(substr($var,2,2));
1523 $col[]=HexDec(substr($var,4,2));
1524 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1535 if (isset($Wdata[$key])) {
1536 $var.="|".$Wdata[$key];
1540 if (isset($Wdata[$key])) {
1541 $var=intval($var).",".intval($Wdata[$key]);
1542 if (isset($W2data[$key])) {
1543 $var.=",".intval($W2data[$key]);
1544 if (isset($W3data[$key])) {
1545 $var.=",".intval($W3data[$key]);
1546 if (isset($W4data[$key])) {
1547 $var.=",".intval($W4data[$key]);
1548 if (isset($W5data[$key])) {
1549 $var.=",".intval($W5data[$key]);
1558 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1562 if (!$this->ext_noCEUploadAndCopying
) {
1563 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1564 $var = $this->upload_copy_file(
1567 trim($http_post_files["upload_data"]["name"][$key]),
1568 $http_post_files["upload_data"]["tmp_name"][$key]
1571 if ($copyResource[$key]) {
1572 $var = $this->upload_copy_file(
1575 basename($copyResource[$key]),
1582 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1583 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1585 unset($check[$key]); // Remove the entry because it has been "used"
1587 $this->ext_removeValueInConf($key);
1592 // 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...
1593 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1595 while(list($key,$var)=each($check)) {
1596 if (isset($theConstants[$key])) {
1597 $dValue = $theConstants[$key]["default_value"];
1599 $this->ext_putValueInConf($key, $dValue);
1604 // debug($this->objReg);
1608 * [Describe function...]
1610 * @param [type] $typeDat: ...
1611 * @param [type] $tplRow: ...
1612 * @param [type] $theRealFileName: ...
1613 * @param [type] $tmp_name: ...
1614 * @return [type] ...
1616 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1619 $extList = $typeDat["paramstr"];
1620 if ($extList=="IMAGE_EXT") {
1621 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1623 $fI=t3lib_div
::split_fileref($theRealFileName);
1624 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1625 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1628 $alternativeFileName=array();
1629 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1630 // Making list of resources
1631 $resList = $tplRow["resources"];
1632 $resList = $tmp_upload_name.",".$resList;
1633 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1634 // Making data-array
1636 $recData["sys_template"][$tplRow["uid"]]["resources"] = $resList;
1638 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1639 $tce->stripslashes_values
=0;
1640 $tce->alternativeFileName
= $alternativeFileName;
1641 $tce->start($recData,Array());
1642 $tce->process_datamap();
1644 t3lib_div
::unlink_tempfile($tmp_upload_name);
1646 $tmpRow = t3lib_BEfunc
::getRecord("sys_template",$tplRow["uid"],"resources");
1647 $tplRow["resources"] = $tmpRow["resources"];
1649 // Setting the value
1650 $var = $this->ext_setStar($theRealFileName);
1656 * [Describe function...]
1658 * @param [type] $id: ...
1659 * @param [type] $perms_clause: ...
1660 * @return [type] ...
1662 function ext_prevPageWithTemplate($id,$perms_clause) {
1663 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1665 while(list(,$p)=each($rootLine)) {
1666 if ($this->ext_getFirstTemplate($p["uid"])) {
1673 * [Describe function...]
1675 * @param [type] $val: ...
1676 * @return [type] ...
1678 function ext_setStar($val) {
1679 $fParts = explode(".",strrev($val),2);
1680 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1685 * [Describe function...]
1687 * @param [type] $value: ...
1688 * @return [type] ...
1690 function ext_detectAndFixExtensionPrefix($value) {
1691 if (substr($value,0,4)=="EXT:") {
1692 $parts = explode("/",substr($value,4),2);
1694 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1695 $value = $extPath.$parts[1];
1704 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1705 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);