2 /***************************************************************
5 * (c) 1999-2006 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 * 105: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 194: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 221: function substituteConstants($all)
43 * 234: function substituteConstantsCallBack($matches)
44 * 264: function substituteCMarkers($all)
45 * 286: function generateConfig_constants()
46 * 335: function ext_getSetup($theSetup,$theKey)
47 * 366: function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")
48 * 463: function lineNumberToScript($lnArr)
49 * 494: function makeHtmlspecialchars($theValue)
50 * 507: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
51 * 563: function ext_getRootlineNumber($pid)
52 * 581: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
53 * 640: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
54 * 671: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
55 * 698: function ext_fixed_lgd($string,$chars)
56 * 714: function ext_lnBreakPointWrap($ln,$str)
57 * 727: function ext_formatTS($input, $ln, $comments=1, $crop=0)
58 * 766: function ext_getFirstTemplate($id,$template_uid=0)
59 * 786: function ext_getAllTemplates($id)
60 * 807: function ext_compareFlatSetups($default)
61 * 873: function ext_categorizeEditableConstants($editConstArray)
62 * 896: function ext_getCategoryLabelArray()
63 * 913: function ext_getTypeData($type)
64 * 955: function ext_getTSCE_config($category)
65 * 994: function ext_getKeyImage($key)
66 * 1004: function ext_getTSCE_config_image($imgConf)
67 * 1028: function ext_resourceDims()
68 * 1058: function ext_readDirResources($path)
69 * 1073: function readDirectory($path,$type="file")
70 * 1098: function ext_fNandV($params)
71 * 1116: function ext_printFields($theConstants,$category)
73 * SECTION: Processing input values
74 * 1373: function ext_regObjectPositions($constants)
75 * 1388: function ext_regObjects($pre)
76 * 1433: function ext_putValueInConf($key, $var)
77 * 1456: function ext_removeValueInConf($key)
78 * 1472: function ext_depthKeys($arr,$settings)
79 * 1507: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
80 * 1634: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
81 * 1683: function ext_prevPageWithTemplate($id,$perms_clause)
82 * 1699: function ext_setStar($val)
83 * 1711: function ext_detectAndFixExtensionPrefix($value)
86 * (This index is automatically created/updated by the extension "extdeveval")
90 require_once(PATH_t3lib
."class.t3lib_tstemplate.php");
99 * TSParser extension class to t3lib_TStemplate
101 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
105 class t3lib_tsparser_ext
extends t3lib_TStemplate
{
107 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.
108 var $HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
111 var $categories = array(
112 "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.
113 "menu" => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
114 "content" => array(), // All constants related to the display of pagecontent elements
115 "page" => array(), // General configuration like metatags, link targets
116 "advanced" => array(), // Advanced functions, which are used very seldomly.
117 "all" => array() // All constants are put here also!
118 ); // This will be filled with the available categories of the current template.
119 var $subCategories = array(
120 // Standard categories:
121 "enable" => Array("Enable features", "a"),
122 "dims" => Array("Dimensions, widths, heights, pixels", "b"),
123 "file" => Array("Files", "c"),
124 "typo" => Array("Typography", "d"),
125 "color" => Array("Colors", "e"),
126 "links" => Array("Links and targets", "f"),
127 "language" => Array("Language specific constants", "g"),
129 // subcategories based on the default content elements
130 "cheader" => Array("Content: 'Header'", "ma"),
131 "cheader_g" => Array("Content: 'Header', Graphical", "ma"),
132 "ctext" => Array("Content: 'Text'", "mb"),
134 "cimage" => Array("Content: 'Image'", "md"),
135 "cbullets" => Array("Content: 'Bullet list'", "me"),
136 "ctable" => Array("Content: 'Table'", "mf"),
137 "cuploads" => Array("Content: 'Filelinks'", "mg"),
138 "cmultimedia" => Array("Content: 'Multimedia'", "mh"),
139 "cmailform" => Array("Content: 'Form'", "mi"),
140 "csearch" => Array("Content: 'Search'", "mj"),
141 "clogin" => Array("Content: 'Login'", "mk"),
142 "csplash" => Array("Content: 'Textbox'", "ml"),
143 "cmenu" => Array("Content: 'Menu/Sitemap'", "mm"),
144 "cshortcut" => Array("Content: 'Insert records'", "mn"),
145 "clist" => Array("Content: 'List of records'", "mo"),
146 "cscript" => Array("Content: 'Script'", "mp"),
147 "chtml" => Array("Content: 'HTML'", "mq")
149 var $resourceDimensions = array();
150 var $dirResources = array();
152 // var $matchAll = 0; // If set, all conditions are matched!
160 var $tsbrowser_searchKeys = array();
161 var $tsbrowser_depthKeys = array();
162 var $constantMode="";
165 var $resourceCheck=0;
166 var $ext_lineNumberOffset=0;
167 var $ext_localGfxPrefix="";
168 var $ext_localWebGfxPrefix="";
169 var $ext_expandAllNotes=0;
170 var $ext_noPMicons=0;
171 var $ext_noSpecialCharsOnLabels=0;
172 var $ext_listOfTemplatesArr=array();
173 var $ext_lineNumberOffset_mode="";
174 var $ext_dontCheckIssetValues=0; // Dont change...
175 var $ext_noCEUploadAndCopying=0;
177 var $ext_CEformName="forms[0]";
178 var $ext_defaultOnlineResourceFlag=0;
179 var $doNotSortCategoriesBeforeMakingForm = FALSE;
182 var $templateTitles=array();
186 * This flattens a hierarchical setuparray to $this->flatSetup
187 * The original function fetched the resource-file if any ("file."). This functions doesn't.
189 * @param [type] $setupArray: ...
190 * @param [type] $prefix: ...
191 * @param [type] $resourceFlag: ...
194 function flattenSetup($setupArray, $prefix, $resourceFlag) {
195 if (is_array($setupArray)) {
196 $this->getFileName_backPath
=PATH_site
; // Setting absolute prefixed path for relative resources.
198 while(list($key,$val)=each($setupArray)) {
199 if ($prefix ||
substr($key,0,16)!="TSConstantEditor") { // We don't want "TSConstantEditor" in the flattend setup.
200 if (is_array($val)) {
201 $this->flattenSetup($val,$prefix.$key, ($key=="file."));
202 } elseif ($resourceFlag && $this->resourceCheck
) {
203 $this->flatSetup
[$prefix.$key] = $this->getFileName($val);
204 if ($this->removeFromGetFilePath
&& substr($this->flatSetup
[$prefix.$key],0,strlen($this->removeFromGetFilePath
))==$this->removeFromGetFilePath
) {
205 $this->flatSetup
[$prefix.$key] = substr($this->flatSetup
[$prefix.$key],strlen($this->removeFromGetFilePath
));
208 $this->flatSetup
[$prefix.$key] = $val;
216 * [Describe function...]
218 * @param [type] $all: ...
221 function substituteConstants($all) {
222 $this->Cmarker
= substr(md5(uniqid("")),0,6);
224 return preg_replace_callback('/\{\$(.[^}]+)\}/', array($this, 'substituteConstantsCallBack'), $all);
228 * Call back method for preg_replace_callback in substituteConstants
230 * @param array Regular expression matches
231 * @return string Replacement
232 * @see substituteConstants()
234 function substituteConstantsCallBack($matches) {
235 switch($this->constantMode
) {
237 $ret_val = isset($this->flatSetup
[$matches[1]]) && !is_array($this->flatSetup
[$matches[1]]) ?
238 '##'.$this->Cmarker
.'_B##'.$matches[0].'##'.$this->Cmarker
.'_E##' :
242 $ret_val = isset($this->flatSetup
[$matches[1]]) && !is_array($this->flatSetup
[$matches[1]]) ?
243 '##'.$this->Cmarker
.'_B##'.$this->flatSetup
[$matches[1]].'##'.$this->Cmarker
.'_E##' :
247 $ret_val = $matches[0];
250 $ret_val = isset($this->flatSetup
[$matches[1]]) && !is_array($this->flatSetup
[$matches[1]]) ?
251 $this->flatSetup
[$matches[1]] :
259 * [Describe function...]
261 * @param [type] $all: ...
264 function substituteCMarkers($all) {
265 switch($this->constantMode
) {
267 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
268 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
271 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
272 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
282 * Parses the constants in $this->const with respect to the constant-editor in this module.
283 * In particular comments in the code are registered and the edit_divider is taken into account.
287 function generateConfig_constants() {
288 // These vars are also set lateron...
289 $this->setup
['resources'] = $this->resources
;
290 $this->setup
['sitetitle'] = $this->sitetitle
;
293 $constants = t3lib_div
::makeInstance("t3lib_TSparser");
294 $constants->regComments
=1; // Register comments!
295 $constants->setup
= $this->const;
296 $constants->setup
= $this->mergeConstantsFromPageTSconfig($constants->setup
);
298 $matchObj = t3lib_div
::makeInstance("t3lib_matchCondition");
299 // $matchObj->matchAlternative = array("[globalString = page | title = *test*]");
300 $matchObj->matchAll
=1; // Matches ALL conditions in TypoScript
303 $cc=count($this->constants
);
304 reset($this->constants
);
305 while (list(,$str)=each($this->constants
)) {
308 if (strstr($str,$this->edit_divider
)) {
309 $parts = explode($this->edit_divider
,$str,2);
311 $constants->parse($parts[0],$matchObj);
313 $this->flatSetup
= Array();
314 $this->flattenSetup($constants->setup
,"","");
315 $defaultConstants=$this->flatSetup
;
317 $constants->parse($str,$matchObj);
320 $this->flatSetup
= Array();
321 $this->flattenSetup($constants->setup
,"","");
322 $this->setup
["constants"] = $constants->setup
;
324 return $this->ext_compareFlatSetups($defaultConstants);
328 * [Describe function...]
330 * @param [type] $theSetup: ...
331 * @param [type] $theKey: ...
334 function ext_getSetup($theSetup,$theKey) {
335 $parts = explode(".",$theKey,2);
336 // debug("-----------",1);
338 if (strcmp($parts[0],"") && is_array($theSetup[$parts[0]."."])) {
339 // debug(trim($parts[1]),1);
340 if (strcmp(trim($parts[1]),"")) {
341 // debug(trim($parts[1]),1);
342 return $this->ext_getSetup($theSetup[$parts[0]."."],trim($parts[1]));
344 return array($theSetup[$parts[0]."."], $theSetup[$parts[0]]);
347 if (strcmp(trim($theKey),"")) {
348 return array(array(),$theSetup[$theKey]);
350 return array($theSetup,"");
356 * [Describe function...]
358 * @param [type] $arr: ...
359 * @param [type] $depth_in: ...
360 * @param [type] $depthData: ...
361 * @param [type] $parentType: ...
362 * @param [type] $parentValue: ...
363 * @param boolean $alphaSort sorts the array keys / tree by alphabet when set to 1
366 function ext_getObjTree($arr, $depth_in, $depthData, $parentType='',$parentValue='', $alphaSort='0') {
371 if($alphaSort == '1') {
375 $keyArr_alpha=array();
376 while (list($key,)=each($arr)) {
377 if (substr($key,-2)!="..") { // Don't do anything with comments / linenumber registrations...
378 $key=ereg_replace("\.$","",$key);
379 if (substr($key,-1)!=".") {
380 if (t3lib_div
::testInt($key)) {
381 $keyArr_num[$key]=$arr[$key];
383 $keyArr_alpha[$key]=$arr[$key];
389 $keyArr=$keyArr_num+
$keyArr_alpha;
392 if ($depth_in) {$depth_in = $depth_in.".";}
394 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
395 // debug($validate_info);
397 while (list($key,)=each($keyArr)) {
399 $depth=$depth_in.$key;
400 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
401 $goto = substr(md5($depth),0,6);
403 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
405 $LN = ($a==$c)?
"blank":"line";
406 $BTM = ($a==$c)?
"bottom":"";
407 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
410 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
414 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
415 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
419 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
420 $label='<font color="#666666">'.$label.'</font>';
422 if ($this->linkObjects
) {
423 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
424 if ($this->bType
!="const") {
425 $ln = is_array($arr[$key.'.ln..']) ?
'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
430 if ($this->tsbrowser_searchKeys
[$depth] & 4) { $label = '<b><font color="red">'.$label.'</font></b>'; } // The key has matched the search string
431 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
435 $HTML.="[".$label."]";
437 if (isset($arr[$key])) {
438 $theValue = $arr[$key];
439 if ($this->fixedLgd
) {
440 $imgBlocks = ceil(1+
strlen($depthData)/77);
441 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
442 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
444 if ($this->tsbrowser_searchKeys
[$depth] & 2) { // The value has matched the search string
445 $HTML.=' = <b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
447 $HTML.=" = <b>".$this->makeHtmlspecialchars($theValue)."</b>";
449 if ($this->ext_regComments
&& isset($arr[$key.'..'])) {
450 $comment = $arr[$key.'..'];
451 $comment = preg_replace('/[\r\n]/', ' ', $comment); // Remove linebreaks, replace with " "
452 $comment = preg_replace('/[#\*]{2,}/', '', $comment); // Remove # and * if more than twice in a row
453 $comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a "#".
454 $HTML.= ' <span class="comment">'.trim($comment).'</span>';
460 $HTML.=$this->ext_getObjTree($arr[$key."."], $depth, $depthData.'<img src="'.$GLOBALS["BACK_PATH"].'gfx/ol/'.$LN.'.gif" width="18" height="16" align="top" alt="" />', '' /* not used: $validate_info[$key] */, $arr[$key], $alphaSort);
468 * [Describe function...]
470 * @param [type] $lnArr: ...
473 function lineNumberToScript($lnArr) {
474 if (!is_array($this->lnToScript
)) {
475 $this->lnToScript
= array();
477 $c+
=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],chr(10))+
2;
478 $this->lnToScript
[$c] = '[Default]';
480 foreach($this->hierarchyInfoToRoot
as $info) {
481 $c+
=$info['configLines']+
1;
482 $this->lnToScript
[$c] = $info['title'];
486 foreach($lnArr as $k => $ln) {
487 foreach($this->lnToScript
as $endLn => $title) {
488 if ($endLn >= intval($ln)) {
489 $lnArr[$k] = '"'.$title.'", '.$ln;
495 return implode('; ',$lnArr);
499 * [Describe function...]
501 * @param [type] $theValue: ...
504 function makeHtmlspecialchars($theValue){
505 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
509 * [Describe function...]
511 * @param [type] $arr: ...
512 * @param [type] $depth_in: ...
513 * @param [type] $searchString: ...
514 * @param [type] $keyArray: ...
517 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
520 while (list($key,)=each($arr)) {
521 $key=ereg_replace('\.$','',$key);
522 if (substr($key,-1)!='.') {
529 if ($depth_in) { $depth_in = $depth_in.'.'; }
530 while (list($key,)=each($keyArr)) {
531 $depth=$depth_in.$key;
532 $deeper = is_array($arr[$key."."]);
534 if ($this->regexMode
) {
535 if (ereg($searchString,$arr[$key])) { // The value has matched
536 $this->tsbrowser_searchKeys
[$depth]+
=2;
538 if (ereg($searchString,$key)) { // The key has matched
539 $this->tsbrowser_searchKeys
[$depth]+
=4;
541 if (ereg($searchString,$depth_in)) { // Just open this subtree if the parent key has matched the search
542 $this->tsbrowser_searchKeys
[$depth]=1;
545 if (stristr($arr[$key],$searchString)) { // The value has matched
546 $this->tsbrowser_searchKeys
[$depth]+
=2;
548 if (stristr($key,$searchString)) { // The key has matches
549 $this->tsbrowser_searchKeys
[$depth]+
=4;
551 if (stristr($depth_in,$searchString)) { // Just open this subtree if the parent key has matched the search
552 $this->tsbrowser_searchKeys
[$depth]=1;
557 $cS = count($this->tsbrowser_searchKeys
);
558 $keyArray = $this->ext_getSearchKeys($arr[$key.'.'], $depth, $searchString, $keyArray);
559 if ($cS != count($this->tsbrowser_searchKeys
)) {
568 * [Describe function...]
570 * @param [type] $pid: ...
573 function ext_getRootlineNumber($pid) {
574 if ($pid && is_array($GLOBALS["rootLine"])) {
575 reset($GLOBALS["rootLine"]);
576 while(list($key,$val)=each($GLOBALS["rootLine"])) {
577 if ($val['uid']==$pid) return $key;
583 * [Describe function...]
585 * @param [type] $arr: ...
586 * @param [type] $depthData: ...
587 * @param [type] $keyArray: ...
588 * @param [type] $first: ...
591 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
594 while (list($key,)=each($arr)) {
595 $key=ereg_replace("\.$","",$key);
596 if (substr($key,-1)!=".") {
603 while (list($key,)=each($keyArr)) {
606 $deeper = is_array($arr[$key."."]);
610 $LN = ($a==$c)?
"blank":"line";
611 $BTM = ($a==$c)?
"top":"";
615 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
616 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
617 $alttext= "[".$row['templateID']."]";
618 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
619 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
620 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
626 $HTML.=($first?
'':'<IMG src="'.$GLOBALS["BACK_PATH"].'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." ";
627 $RL = $this->ext_getRootlineNumber($row['pid']);
629 <td nowrap>'.$HTML.'</td>
630 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
631 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
632 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
633 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
634 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
637 $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key."."], $depthData.($first?
'':'<IMG src="'.$GLOBALS["BACK_PATH"].'gfx/ol/'.$LN.'.gif" width="18" height="16" align="top">'), $keyArray);
644 * [Describe function...]
646 * @param [type] $depthDataArr: ...
647 * @param [type] $pointer: ...
650 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
651 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
652 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
654 $row = $this->hierarchyInfo
[$pointer];
656 $depthDataArr[$row['templateID']]=$row;
657 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
658 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
659 unset($this->clearList_setup_temp
[$row['templateID']]);
660 unset($this->clearList_const_temp
[$row['templateID']]);
661 $this->templateTitles
[$row['templateID']]=$row["title"];
663 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
664 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
667 return $depthDataArr;
671 * [Describe function...]
673 * @param [type] $config: ...
674 * @param [type] $lineNumbers: ...
675 * @param [type] $comments: ...
676 * @param [type] $crop: ...
677 * @param [type] $syntaxHL: ...
678 * @param [type] $syntaxHLBlockmode: ...
681 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
684 while (list(,$str)=each($config)) {
685 $all.="\n[GLOBAL]\n".$str;
689 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
691 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
692 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
693 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
695 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
700 * Returns a new string of max. $chars lenght
701 * If the string is longer, it will be truncated and prepended with "..."
702 * $chars must be an integer of at least 4
704 * @param [type] $string: ...
705 * @param [type] $chars: ...
708 function ext_fixed_lgd($string,$chars) {
710 if(strlen($string)>$chars) {
711 return substr($string, 0, $chars-3)."...";
718 * [Describe function...]
720 * @param [type] $ln: ...
721 * @param [type] $str: ...
724 function ext_lnBreakPointWrap($ln,$str) {
725 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
729 * [Describe function...]
731 * @param [type] $input: ...
732 * @param [type] $ln: ...
733 * @param [type] $comments: ...
734 * @param [type] $crop: ...
737 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
738 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
739 $input = chop($input);
740 $cArr = explode(chr(10),$input);
743 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
745 while(list($k,$v)=each($cArr)) {
746 $lln=$k+
$this->ext_lineNumberOffset+
1;
747 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
748 $v=htmlspecialchars($v);
749 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
750 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
752 $firstChar = substr(trim($v),0,1);
753 if ($firstChar=="[") {
754 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
755 } elseif ($firstChar=="/" ||
$firstChar=="#") {
757 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
765 $output = implode($cArr, "<BR>")."<BR>";
770 * [Describe function...]
772 * @param [type] $id: ...
773 * @param [type] $template_uid: ...
776 function ext_getFirstTemplate($id,$template_uid=0) {
777 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
780 $addC = " AND uid=".$template_uid;
782 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause
, '', 'sorting', '1');
783 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
784 t3lib_BEfunc
::workspaceOL('sys_template',$row);
785 $GLOBALS['TYPO3_DB']->sql_free_result($res);
786 return $row; // Returns the template row if found.
791 * [Describe function...]
793 * @param [type] $id: ...
796 function ext_getAllTemplates($id) {
797 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
800 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
801 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
802 t3lib_BEfunc
::workspaceOL('sys_template',$row);
803 if (is_array($row)) $outRes[] = $row;
805 $GLOBALS['TYPO3_DB']->sql_free_result($res);
806 return $outRes; // Returns the template rows in an array.
811 * This function compares the flattened constants (default and all).
812 * Returns an array with the constants from the whole template which may be edited by the module.
814 * @param [type] $default: ...
817 function ext_compareFlatSetups($default) {
818 $editableComments=array();
819 reset($this->flatSetup
);
820 while(list($const,$value)=each($this->flatSetup
)) {
821 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
822 $comment = trim($this->flatSetup
[$const.".."]);
823 $c_arr = explode(chr(10),$comment);
824 while(list($k,$v)=each($c_arr)) {
825 $line=trim(ereg_replace("^[#\/]*","",$v));
827 $parts = explode(";", $line);
828 while(list(,$par)=each($parts)) {
829 if (strstr($par,"=")) {
830 $keyValPair =explode("=",$par,2);
831 switch(trim(strtolower($keyValPair[0]))) {
835 int (range; low-high, list: item,item,item = selector),
842 $editableComments[$const]["type"] = trim($keyValPair[1]);
845 // list of categories.
846 $catSplit=explode("/",strtolower($keyValPair[1]));
847 $editableComments[$const]["cat"] = trim($catSplit[0]);
848 $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.
849 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
850 $editableComments[$const]["subcat_name"]=$catSplit[1];
851 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
853 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
858 $editableComments[$const]["label"] = trim($keyValPair[1]);
866 if (isset($editableComments[$const])) {
867 $editableComments[$const]["name"]=$const;
868 $editableComments[$const]["value"]=trim($value);
869 if (isset($default[$const])) {
870 $editableComments[$const]["default_value"]=trim($default[$const]);
874 return $editableComments;
878 * [Describe function...]
880 * @param [type] $editConstArray: ...
883 function ext_categorizeEditableConstants($editConstArray) {
884 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
885 reset($editConstArray);
886 while(list($constName,$constData)=each($editConstArray)) {
887 if (!$constData["type"]) {$constData["type"]="string";}
888 $cats = explode(",",$constData["cat"]);
890 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...
891 $theCat=trim($theCat);
893 $this->categories
[$theCat][$constName]=$constData["subcat"];
894 // $this->categories["all"][$constName]=$constData["subcat"];
898 // debug($this->categories);
902 * [Describe function...]
906 function ext_getCategoryLabelArray() {
907 // Returns array used for labels in the menu.
909 while(list($k,$v)=each($this->categories
)) {
911 $retArr[$k]=strtoupper($k)." (".count($v).")";
918 * [Describe function...]
920 * @param [type] $type: ...
923 function ext_getTypeData($type) {
927 $retArr["type"]="string";
929 $m=strcspn ($type," [");
930 $retArr["type"]=strtolower(substr($type,0,$m));
931 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
932 $p=trim(substr($type,$m));
934 ereg("\[(.*)\]",$p,$reg);
937 $retArr["paramstr"]=$p;
938 switch($retArr["type"]) {
940 if (substr($retArr["paramstr"],0,1)=="-") {
941 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
942 $retArr["params"][0]=intval("-".$retArr["params"][0]);
944 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
946 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
949 $retArr["params"]=explode(",",$retArr["paramstr"]);
960 * [Describe function...]
962 * @param [type] $category: ...
965 function ext_getTSCE_config($category) {
966 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
968 if (is_array($catConf)) {
970 while(list($key,$val)=each($catConf)) {
973 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
981 if (t3lib_div
::testInt($key)) {
982 $constRefs = explode(",",$val);
984 while(list(,$const)=each($constRefs)) {
986 if ($const && $const<=20) {
987 $out["constants"][$const].=$this->ext_getKeyImage($key);
995 $this->helpConfig
=$out;
999 * [Describe function...]
1001 * @param [type] $key: ...
1002 * @return [type] ...
1004 function ext_getKeyImage($key) {
1005 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
1009 * [Describe function...]
1011 * @param [type] $imgConf: ...
1012 * @return [type] ...
1014 function ext_getTSCE_config_image($imgConf) {
1015 if (substr($imgConf,0,4)=="gfx/") {
1016 $iFile=$this->ext_localGfxPrefix
.$imgConf;
1017 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
1018 } elseif (substr($imgConf,0,4)=='EXT:') {
1019 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
1021 $f = substr($iFile,strlen(PATH_site
));
1022 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
1025 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
1026 $iFile=PATH_site
.$f;
1027 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
1029 $imageInfo=@getImagesize
($iFile);
1030 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
1034 * [Describe function...]
1036 * @return [type] ...
1038 function ext_resourceDims() {
1039 if ($this->setup
["resources"]) {
1040 $rArr=explode(",",$this->setup
["resources"]);
1041 while(list($c,$val)=each($rArr)) {
1043 $theFile = PATH_site
."uploads/tf/".$val;
1044 if ($val && @is_file
($theFile)) {
1045 $imgInfo = @getimagesize
($theFile);
1047 if (is_array($imgInfo)) {
1048 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1052 reset($this->dirResources
);
1053 while(list($c,$val)=each($this->dirResources
)) {
1055 $imgInfo = @getimagesize
(PATH_site
.$val);
1056 if (is_array($imgInfo)) {
1057 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1063 * [Describe function...]
1065 * @param [type] $path: ...
1066 * @return [type] ...
1068 function ext_readDirResources($path) {
1070 if ($path && substr($path,0,10)=="fileadmin/") {
1071 $path = ereg_replace("\/$","",$path);
1072 $this->readDirectory(PATH_site
.$path);
1077 * [Describe function...]
1079 * @param [type] $path: ...
1080 * @param [type] $type: ...
1081 * @return [type] ...
1083 function readDirectory($path,$type="file") {
1084 if(@is_dir
($path)) {
1087 if (is_object($d)) {
1088 while($entry=$d->read()) {
1089 if ($entry!="." && $entry!="..") {
1090 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1091 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1092 $fI = t3lib_div
::split_fileref($wholePath);
1093 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1103 * [Describe function...]
1105 * @param [type] $params: ...
1106 * @return [type] ...
1108 function ext_fNandV($params) {
1109 $fN='data['.$params["name"].']';
1110 $fV=$params["value"];
1111 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1114 $fV=htmlspecialchars($fV);
1116 return array($fN,$fV,$params);
1120 * [Describe function...]
1122 * @param [type] $theConstants: ...
1123 * @param [type] $category: ...
1124 * @return [type] ...
1126 function ext_printFields($theConstants,$category) {
1127 // This functions returns the HTML-code that creates the editor-layout of the module.
1128 reset($theConstants);
1131 if (is_array($this->categories
[$category])) {
1133 $help=$this->helpConfig
;
1134 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1136 if (!$this->doNotSortCategoriesBeforeMakingForm
) asort($this->categories
[$category]);
1137 while(list($name,$type)=each($this->categories
[$category])) {
1138 $params = $theConstants[$name];
1139 if (is_array($params)) {
1140 if ($subcat!=$params["subcat_name"]) {
1141 $subcat=$params["subcat_name"];
1142 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1144 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1148 // if (substr($params["value"],0,2)!='{$') {
1149 $label=$GLOBALS["LANG"]->sL($params["label"]);
1150 $label_parts = explode(":",$label,2);
1151 if (count($label_parts)==2) {
1152 $head=trim($label_parts[0]);
1153 $body=trim($label_parts[1]);
1155 $head=trim($label_parts[0]);
1158 if (strlen($head)>35) {
1159 if (!$body) {$body=$head;}
1160 $head=t3lib_div
::fixed_lgd_cs($head,35);
1162 $typeDat=$this->ext_getTypeData($params["type"]);
1165 $raname = substr(md5($params["name"]),0,10);
1166 $aname="'".$raname."'";
1167 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1168 $checked=" checked";
1169 list($fN,$fV,$params)=$this->ext_fNandV($params);
1171 switch($typeDat["type"]) {
1174 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1175 if ($typeDat["paramstr"]) {
1176 $p_field.=' Range: '.$typeDat["paramstr"];
1177 } elseif ($typeDat["type"]=="int+") {
1178 $p_field.=' Range: 0 - ';
1180 $p_field.=' (Integer)';
1184 $colorNames=explode(",",",".$this->HTMLcolorList
);
1186 while(list(,$val)=each($colorNames)) {
1188 if ($val==strtolower($params["value"])) {$sel=" selected";}
1189 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1191 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1193 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1196 $wArr = explode("|",$fV);
1197 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1199 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1202 $wArr = explode(",",$fV);
1203 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1204 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1206 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1207 for ($aa=2;$aa<count($labels);$aa++
) {
1209 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1211 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1216 if (is_array($typeDat["params"])) {
1218 while(list(,$val)=each($typeDat["params"])) {
1219 $vParts = explode("=",$val,2);
1220 $label = $vParts[0];
1221 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1225 if ($val==$params["value"]) {$sel=" selected";}
1226 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1228 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1232 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1233 $sel=""; if ($fV) {$sel=" checked";}
1234 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1237 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1238 $sel=""; if (!$fV) {$sel=" checked";}
1239 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1242 $p_field='<option value=""></option>';
1243 // debug($params["value"]);
1246 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1247 if ($params["value"] && !$selectThisFile) {
1248 if (in_array($params["value"],$this->dirResources
)) {
1249 $selectThisFile=$params["value"];
1252 // debug($selectThisFile);
1254 $extList = $typeDat["paramstr"];
1255 $p_field='<option value="">('.$extList.')</option>';
1256 if ($extList=="IMAGE_EXT") {
1257 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1260 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1262 while(list($c,$val)=each($this->rArr
)) {
1264 $fI=t3lib_div
::split_fileref($val);
1266 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1267 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1268 if ($onlineResourceFlag<0) {
1269 $p_field.='<option value=""></option>';
1271 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1272 $onlineResourceFlag=1;
1274 $dims=$this->resourceDimensions
[$val];
1277 // Check if $params["value"] is in the list of resources.
1278 if ($selectThisFile && $selectThisFile==$val) {
1280 if ($onlineResourceFlag<=0) {
1281 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1283 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1287 if ($onlineResourceFlag<=0) {
1288 $onlineResourceFlag--;
1289 // Value is set with a *
1290 $val = $this->ext_setStar($val);
1291 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1293 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1297 if (trim($params["value"]) && !$selectThisFile) {
1298 $val = $params["value"];
1299 $p_field.='<option value=""></option>';
1300 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1303 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1304 $p_field.=$theImage;
1306 if (!$this->ext_noCEUploadAndCopying
) {
1308 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1310 if ($params["value"]) {
1311 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1314 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1318 if ($copyFile && @is_file
($copyFile)) {
1319 $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"])).'\'));}">';
1323 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1328 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1329 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1333 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1334 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1335 $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>';
1337 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1340 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1341 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1342 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1343 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1346 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1347 $output.='<td valign=top align="right">'.$p_name.'</td>';
1350 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1354 debug("Error. Constant did not exits. Should not happen.");
1357 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1373 /***************************
1375 * Processing input values
1377 ***************************/
1380 * @param [type] $constants: ...
1381 * @return [type] ...
1383 function ext_regObjectPositions($constants) {
1384 // 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
1385 $this->raw
= explode(chr(10),$constants);
1388 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1389 $this->ext_regObjects("");
1393 * [Describe function...]
1395 * @param [type] $pre: ...
1396 * @return [type] ...
1398 function ext_regObjects($pre) {
1399 // works with regObjectPositions. "expands" the names of the TypoScript objects
1400 while (isset($this->raw
[$this->rawP
])) {
1401 $line = ltrim($this->raw
[$this->rawP
]);
1402 if (strstr($line,$this->edit_divider
)) {
1403 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1407 if (substr($line,0,1)=="[") {
1409 } elseif (strcspn($line,"}#/")!=0) {
1410 $varL = strcspn($line," {=<");
1411 $var=substr($line,0,$varL);
1412 $line = ltrim(substr($line,$varL));
1413 switch(substr($line,0,1)) {
1415 $this->objReg
[$pre.$var]=$this->rawP
-1;
1418 $this->ext_inBrace++
;
1419 $this->ext_regObjects($pre.$var.".");
1422 $this->lastComment
="";
1423 } elseif (substr($line,0,1)=="}") {
1424 $this->lastComment
="";
1425 $this->ext_inBrace
--;
1426 if ($this->ext_inBrace
<0) {
1427 $this->ext_inBrace
=0;
1437 * [Describe function...]
1439 * @param [type] $key: ...
1440 * @param [type] $var: ...
1441 * @return [type] ...
1443 function ext_putValueInConf($key, $var) {
1444 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1445 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1446 $theValue = " ".trim($var);
1447 if (isset($this->objReg
[$key])) {
1448 $lineNum = $this->objReg
[$key];
1449 $parts = explode("=",$this->raw
[$lineNum],2);
1450 if (count($parts)==2) {
1451 $parts[1]= $theValue;
1453 $this->raw
[$lineNum]=implode($parts,"=");
1455 $this->raw
[]=$key." =".$theValue;
1461 * [Describe function...]
1463 * @param [type] $key: ...
1464 * @return [type] ...
1466 function ext_removeValueInConf($key) {
1467 // Removes the value in the configuration
1468 if (isset($this->objReg
[$key])) {
1469 $lineNum = $this->objReg
[$key];
1470 unset($this->raw
[$lineNum]);
1476 * [Describe function...]
1478 * @param [type] $arr: ...
1479 * @param [type] $settings: ...
1480 * @return [type] ...
1482 function ext_depthKeys($arr,$settings) {
1485 while(list($theK,$theV)=each($arr)) {
1486 $theKeyParts = explode(".",$theK);
1488 $c=count($theKeyParts);
1490 while(list(,$p)=each($theKeyParts)) {
1492 $depth.=($depth?
".":"").$p;
1493 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1498 while(list($theK,$theV)=each($tsbrArray)) {
1500 $settings[$theK] = 1;
1502 unset($settings[$theK]);
1509 * [Describe function...]
1511 * @param [type] $http_post_vars: ...
1512 * @param [type] $http_post_files: ...
1513 * @param [type] $theConstants: ...
1514 * @param [type] $tplRow: ...
1515 * @return [type] ...
1517 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1518 $data=$http_post_vars["data"];
1519 $check=$http_post_vars["check"];
1520 $copyResource=$http_post_vars["_copyResource"];
1521 $Wdata=$http_post_vars["Wdata"];
1522 $W2data=$http_post_vars["W2data"];
1523 $W3data=$http_post_vars["W3data"];
1524 $W4data=$http_post_vars["W4data"];
1525 $W5data=$http_post_vars["W5data"];
1527 if (is_array($data)) {
1529 while(list($key,$var)=each($data)) {
1530 if (isset($theConstants[$key])) {
1531 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1532 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1533 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1534 switch($typeDat["type"]) {
1536 if ($typeDat["paramstr"]) {
1537 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1543 $var=t3lib_div
::intInRange($var,0,10000);
1547 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1548 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1549 $col[]=HexDec(substr($var,0,2));
1550 $col[]=HexDec(substr($var,2,2));
1551 $col[]=HexDec(substr($var,4,2));
1552 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1563 if (isset($Wdata[$key])) {
1564 $var.="|".$Wdata[$key];
1568 if (isset($Wdata[$key])) {
1569 $var=intval($var).",".intval($Wdata[$key]);
1570 if (isset($W2data[$key])) {
1571 $var.=",".intval($W2data[$key]);
1572 if (isset($W3data[$key])) {
1573 $var.=",".intval($W3data[$key]);
1574 if (isset($W4data[$key])) {
1575 $var.=",".intval($W4data[$key]);
1576 if (isset($W5data[$key])) {
1577 $var.=",".intval($W5data[$key]);
1586 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1590 if (!$this->ext_noCEUploadAndCopying
) {
1591 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1592 $var = $this->upload_copy_file(
1595 trim($http_post_files["upload_data"]["name"][$key]),
1596 $http_post_files["upload_data"]["tmp_name"][$key]
1599 if ($copyResource[$key]) {
1600 $var = $this->upload_copy_file(
1603 basename($copyResource[$key]),
1610 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1611 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1613 unset($check[$key]); // Remove the entry because it has been "used"
1615 $this->ext_removeValueInConf($key);
1620 // 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...
1621 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1623 while(list($key,$var)=each($check)) {
1624 if (isset($theConstants[$key])) {
1625 $dValue = $theConstants[$key]["default_value"];
1627 $this->ext_putValueInConf($key, $dValue);
1632 // debug($this->objReg);
1636 * [Describe function...]
1638 * @param [type] $typeDat: ...
1639 * @param [type] $tplRow: ...
1640 * @param [type] $theRealFileName: ...
1641 * @param [type] $tmp_name: ...
1642 * @return [type] ...
1644 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1647 $extList = $typeDat["paramstr"];
1648 if ($extList=="IMAGE_EXT") {
1649 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1651 $fI=t3lib_div
::split_fileref($theRealFileName);
1652 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1653 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1656 $alternativeFileName=array();
1657 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1658 // Making list of resources
1659 $resList = $tplRow["resources"];
1660 $resList = $tmp_upload_name.",".$resList;
1661 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1662 // Making data-array
1663 $saveId = $tplRow['_ORIG_uid'] ?
$tplRow['_ORIG_uid'] : $tplRow['uid'];
1666 $recData["sys_template"][$saveId]["resources"] = $resList;
1668 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1669 $tce->stripslashes_values
=0;
1670 $tce->alternativeFileName
= $alternativeFileName;
1671 $tce->start($recData,Array());
1672 $tce->process_datamap();
1674 t3lib_div
::unlink_tempfile($tmp_upload_name);
1676 $tmpRow = t3lib_BEfunc
::getRecordWSOL("sys_template",$saveId,"resources");
1678 $tplRow["resources"] = $tmpRow["resources"];
1680 // Setting the value
1681 $var = $this->ext_setStar($theRealFileName);
1687 * [Describe function...]
1689 * @param [type] $id: ...
1690 * @param [type] $perms_clause: ...
1691 * @return [type] ...
1693 function ext_prevPageWithTemplate($id,$perms_clause) {
1694 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1696 while(list(,$p)=each($rootLine)) {
1697 if ($this->ext_getFirstTemplate($p["uid"])) {
1704 * [Describe function...]
1706 * @param [type] $val: ...
1707 * @return [type] ...
1709 function ext_setStar($val) {
1710 $fParts = explode(".",strrev($val),2);
1711 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1716 * [Describe function...]
1718 * @param [type] $value: ...
1719 * @return [type] ...
1721 function ext_detectAndFixExtensionPrefix($value) {
1722 if (substr($value,0,4)=="EXT:") {
1723 $parts = explode("/",substr($value,4),2);
1725 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1726 $value = $extPath.$parts[1];
1735 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1736 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);