2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 103: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 191: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 218: function substituteConstants($all)
43 * 247: function substituteCMarkers($all)
44 * 269: function generateConfig_constants()
45 * 318: function ext_getSetup($theSetup,$theKey)
46 * 349: function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")
47 * 437: function makeHtmlspecialchars($theValue)
48 * 450: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
49 * 490: function ext_getRootlineNumber($pid)
50 * 508: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
51 * 567: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
52 * 598: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
53 * 625: function ext_fixed_lgd($string,$chars)
54 * 641: function ext_lnBreakPointWrap($ln,$str)
55 * 654: function ext_formatTS($input, $ln, $comments=1, $crop=0)
56 * 693: function ext_getFirstTemplate($id,$template_uid=0)
57 * 713: function ext_getAllTemplates($id)
58 * 734: function ext_compareFlatSetups($default)
59 * 800: function ext_categorizeEditableConstants($editConstArray)
60 * 823: function ext_getCategoryLabelArray()
61 * 840: function ext_getTypeData($type)
62 * 881: function ext_getTSCE_config($category)
63 * 920: function ext_getKeyImage($key)
64 * 930: function ext_getTSCE_config_image($imgConf)
65 * 954: function ext_resourceDims()
66 * 984: function ext_readDirResources($path)
67 * 999: function readDirectory($path,$type="file")
68 * 1024: function ext_fNandV($params)
69 * 1042: function ext_printFields($theConstants,$category)
71 * SECTION: Processing input values
72 * 1299: function ext_regObjectPositions($constants)
73 * 1314: function ext_regObjects($pre)
74 * 1359: function ext_putValueInConf($key, $var)
75 * 1382: function ext_removeValueInConf($key)
76 * 1398: function ext_depthKeys($arr,$settings)
77 * 1433: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
78 * 1560: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
79 * 1601: function ext_prevPageWithTemplate($id,$perms_clause)
80 * 1617: function ext_setStar($val)
81 * 1629: function ext_detectAndFixExtensionPrefix($value)
84 * (This index is automatically created/updated by the extension "extdeveval")
88 require_once(PATH_t3lib
."class.t3lib_tstemplate.php");
97 * TSParser extension class to t3lib_TStemplate
99 * @author Kasper Skaarhoj <kasper@typo3.com>
103 class t3lib_tsparser_ext
extends t3lib_TStemplate
{
105 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.
106 var $HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
109 var $categories = array(
110 "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.
111 "menu" => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
112 "content" => array(), // All constants related to the display of pagecontent elements
113 "page" => array(), // General configuration like metatags, link targets
114 "advanced" => array(), // Advanced functions, which are used very seldomly.
115 "all" => array() // All constants are put here also!
116 ); // This will be filled with the available categories of the current template.
117 var $subCategories = array(
118 // Standard categories:
119 "enable" => Array("Enable features", "a"),
120 "dims" => Array("Dimensions, widths, heights, pixels", "b"),
121 "file" => Array("Files", "c"),
122 "typo" => Array("Typography", "d"),
123 "color" => Array("Colors", "e"),
124 "links" => Array("Links and targets", "f"),
125 "language" => Array("Language specific constants", "g"),
127 // subcategories based on the default content elements
128 "cheader" => Array("Content: 'Header'", "ma"),
129 "cheader_g" => Array("Content: 'Header', Graphical", "ma"),
130 "ctext" => Array("Content: 'Text'", "mb"),
132 "cimage" => Array("Content: 'Image'", "md"),
133 "cbullets" => Array("Content: 'Bullet list'", "me"),
134 "ctable" => Array("Content: 'Table'", "mf"),
135 "cuploads" => Array("Content: 'Filelinks'", "mg"),
136 "cmultimedia" => Array("Content: 'Multimedia'", "mh"),
137 "cmailform" => Array("Content: 'Form'", "mi"),
138 "csearch" => Array("Content: 'Search'", "mj"),
139 "clogin" => Array("Content: 'Login'", "mk"),
140 "csplash" => Array("Content: 'Textbox'", "ml"),
141 "cmenu" => Array("Content: 'Menu/Sitemap'", "mm"),
142 "cshortcut" => Array("Content: 'Insert records'", "mn"),
143 "clist" => Array("Content: 'List of records'", "mo"),
144 "cscript" => Array("Content: 'Script'", "mp"),
145 "chtml" => Array("Content: 'HTML'", "mq")
147 var $resourceDimensions = array();
148 var $dirResources = array();
150 // var $matchAll = 0; // If set, all conditions are matched!
158 var $tsbrowser_searchKeys = array();
159 var $tsbrowser_depthKeys = array();
160 var $constantMode="";
163 var $resourceCheck=0;
164 var $ext_lineNumberOffset=0;
165 var $ext_localGfxPrefix="";
166 var $ext_localWebGfxPrefix="";
167 var $ext_expandAllNotes=0;
168 var $ext_noPMicons=0;
169 var $ext_noSpecialCharsOnLabels=0;
170 var $ext_listOfTemplatesArr=array();
171 var $ext_lineNumberOffset_mode="";
172 var $ext_dontCheckIssetValues=0; // Dont change...
173 var $ext_noCEUploadAndCopying=0;
175 var $ext_CEformName="forms[0]";
176 var $ext_defaultOnlineResourceFlag=0;
179 var $templateTitles=array();
183 * This flattens a hierarchical setuparray to $this->flatSetup
184 * The original function fetched the resource-file if any ("file."). This functions doesn't.
186 * @param [type] $setupArray: ...
187 * @param [type] $prefix: ...
188 * @param [type] $resourceFlag: ...
191 function flattenSetup($setupArray, $prefix, $resourceFlag) {
192 if (is_array($setupArray)) {
193 $this->getFileName_backPath
=PATH_site
; // Setting absolute prefixed path for relative resources.
195 while(list($key,$val)=each($setupArray)) {
196 if ($prefix ||
substr($key,0,16)!="TSConstantEditor") { // We don't want "TSConstantEditor" in the flattend setup.
197 if (is_array($val)) {
198 $this->flattenSetup($val,$prefix.$key, ($key=="file."));
199 } elseif ($resourceFlag && $this->resourceCheck
) {
200 $this->flatSetup
[$prefix.$key] = $this->getFileName($val);
201 if ($this->removeFromGetFilePath
&& substr($this->flatSetup
[$prefix.$key],0,strlen($this->removeFromGetFilePath
))==$this->removeFromGetFilePath
) {
202 $this->flatSetup
[$prefix.$key] = substr($this->flatSetup
[$prefix.$key],strlen($this->removeFromGetFilePath
));
205 $this->flatSetup
[$prefix.$key] = $val;
213 * [Describe function...]
215 * @param [type] $all: ...
218 function substituteConstants($all) {
219 $this->Cmarker
=substr(md5(uniqid("")),0,6);
220 reset($this->flatSetup
);
221 while (list($const,$val)=each($this->flatSetup
)) {
222 if (!is_array($val)) {
223 switch($this->constantMode
) {
225 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##{$'.$const.'}##'.$this->Cmarker
.'_E##',$all);
228 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##'.$val.'##'.$this->Cmarker
.'_E##',$all);
233 $all = str_replace('{$'.$const.'}',$val,$all);
242 * [Describe function...]
244 * @param [type] $all: ...
247 function substituteCMarkers($all) {
248 switch($this->constantMode
) {
250 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
251 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
254 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
255 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
265 * [Describe function...]
269 function generateConfig_constants() {
270 // Parses the constants in $this->const with respect to the constant-editor in this module.
271 // In particular comments in the code are registered and the edit_divider is taken into account.
272 // These vars are also set lateron...
273 $this->setup
["resources"]= $this->resources
;
274 $this->setup
["sitetitle"]= $this->sitetitle
;
277 $constants = t3lib_div
::makeInstance("t3lib_TSparser");
278 $constants->regComments
=1; // Register comments!
279 $constants->setup
= $this->const;
280 $constants->setup
= $this->mergeConstantsFromPageTSconfig($constants->setup
);
282 $matchObj = t3lib_div
::makeInstance("t3lib_matchCondition");
283 // $matchObj->matchAlternative = array("[globalString = page | title = *test*]");
284 $matchObj->matchAll
=1; // Matches ALL conditions in TypoScript
287 $cc=count($this->constants
);
288 reset($this->constants
);
289 while (list(,$str)=each($this->constants
)) {
292 if (strstr($str,$this->edit_divider
)) {
293 $parts = explode($this->edit_divider
,$str,2);
295 $constants->parse($parts[0],$matchObj);
297 $this->flatSetup
= Array();
298 $this->flattenSetup($constants->setup
,"","");
299 $defaultConstants=$this->flatSetup
;
301 $constants->parse($str,$matchObj);
304 $this->flatSetup
= Array();
305 $this->flattenSetup($constants->setup
,"","");
306 $this->setup
["constants"] = $constants->setup
;
308 return $this->ext_compareFlatSetups($defaultConstants);
312 * [Describe function...]
314 * @param [type] $theSetup: ...
315 * @param [type] $theKey: ...
318 function ext_getSetup($theSetup,$theKey) {
319 $parts = explode(".",$theKey,2);
320 // debug("-----------",1);
322 if (strcmp($parts[0],"") && is_array($theSetup[$parts[0]."."])) {
323 // debug(trim($parts[1]),1);
324 if (strcmp(trim($parts[1]),"")) {
325 // debug(trim($parts[1]),1);
326 return $this->ext_getSetup($theSetup[$parts[0]."."],trim($parts[1]));
328 return array($theSetup[$parts[0]."."], $theSetup[$parts[0]]);
331 if (strcmp(trim($theKey),"")) {
332 return array(array(),$theSetup[$theKey]);
334 return array($theSetup,"");
340 * [Describe function...]
342 * @param [type] $arr: ...
343 * @param [type] $depth_in: ...
344 * @param [type] $depthData: ...
345 * @param [type] $parentType: ...
346 * @param [type] $parentValue: ...
349 function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="") {
355 $keyArr_alpha=array();
356 while (list($key,)=each($arr)) {
357 $key=ereg_replace("\.$","",$key);
358 if (substr($key,-1)!=".") {
359 if (t3lib_div
::testInt($key)) {
360 $keyArr_num[$key]=$arr[$key];
362 $keyArr_alpha[$key]=$arr[$key];
367 $keyArr=$keyArr_num+
$keyArr_alpha;
370 if ($depth_in) {$depth_in = $depth_in.".";}
372 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
373 // debug($validate_info);
375 while (list($key,)=each($keyArr)) {
377 $depth=$depth_in.$key;
378 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
379 $goto = substr(md5($depth),0,6);
381 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
383 $LN = ($a==$c)?
"blank":"line";
384 $BTM = ($a==$c)?
"bottom":"";
385 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
388 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
392 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
393 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
397 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
398 $label='<font color="#666666">'.$label.'</font>';
400 if ($this->linkObjects
) {
401 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
402 $label = '<a href="'.htmlspecialchars($aHref).'">'.$label.'</a>';
406 $HTML.="[".$label."]";
408 if (isset($arr[$key])) {
409 $theValue = $arr[$key];
410 if ($this->fixedLgd
) {
411 $imgBlocks = ceil(1+
strlen($depthData)/77);
412 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
413 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
415 if ($this->tsbrowser_searchKeys
[$depth]) {
416 $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
418 $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
424 $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]);
432 * [Describe function...]
434 * @param [type] $theValue: ...
437 function makeHtmlspecialchars($theValue){
438 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
442 * [Describe function...]
444 * @param [type] $arr: ...
445 * @param [type] $depth_in: ...
446 * @param [type] $searchString: ...
447 * @param [type] $keyArray: ...
450 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
453 while (list($key,)=each($arr)) {
454 $key=ereg_replace("\.$","",$key);
455 if (substr($key,-1)!=".") {
462 if ($depth_in) {$depth_in = $depth_in.".";}
463 while (list($key,)=each($keyArr)) {
464 $depth=$depth_in.$key;
465 $deeper = is_array($arr[$key."."]);
467 if ($this->regexMode
) {
468 if (ereg($searchString,$arr[$key])) { $this->tsbrowser_searchKeys
[$depth]=1; }
470 if (stristr($arr[$key],$searchString)) { $this->tsbrowser_searchKeys
[$depth]=1; }
474 $cS = count($this->tsbrowser_searchKeys
);
475 $keyArray = $this->ext_getSearchKeys($arr[$key."."], $depth, $searchString, $keyArray);
476 if ($cS != count($this->tsbrowser_searchKeys
)) {
485 * [Describe function...]
487 * @param [type] $pid: ...
490 function ext_getRootlineNumber($pid) {
491 if ($pid && is_array($GLOBALS["rootLine"])) {
492 reset($GLOBALS["rootLine"]);
493 while(list($key,$val)=each($GLOBALS["rootLine"])) {
494 if ($val['uid']==$pid) return $key;
500 * [Describe function...]
502 * @param [type] $arr: ...
503 * @param [type] $depthData: ...
504 * @param [type] $keyArray: ...
505 * @param [type] $first: ...
508 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
511 while (list($key,)=each($arr)) {
512 $key=ereg_replace("\.$","",$key);
513 if (substr($key,-1)!=".") {
520 while (list($key,)=each($keyArr)) {
523 $deeper = is_array($arr[$key."."]);
527 $LN = ($a==$c)?
"blank":"line";
528 $BTM = ($a==$c)?
"top":"";
532 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
533 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
534 $alttext= "[".$row['templateID']."]";
535 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
536 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
537 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
543 $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($row['title'],$GLOBALS["BE_USER"]->uc
["titleLen"]).$A_E." ";
544 $RL = $this->ext_getRootlineNumber($row['pid']);
546 <td nowrap>'.$HTML.'</td>
547 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
548 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
549 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
550 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
551 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
554 $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);
561 * [Describe function...]
563 * @param [type] $depthDataArr: ...
564 * @param [type] $pointer: ...
567 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
568 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
569 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
571 $row = $this->hierarchyInfo
[$pointer];
573 $depthDataArr[$row['templateID']]=$row;
574 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
575 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
576 unset($this->clearList_setup_temp
[$row['templateID']]);
577 unset($this->clearList_const_temp
[$row['templateID']]);
578 $this->templateTitles
[$row['templateID']]=$row["title"];
580 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
581 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
584 return $depthDataArr;
588 * [Describe function...]
590 * @param [type] $config: ...
591 * @param [type] $lineNumbers: ...
592 * @param [type] $comments: ...
593 * @param [type] $crop: ...
594 * @param [type] $syntaxHL: ...
595 * @param [type] $syntaxHLBlockmode: ...
598 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
601 while (list(,$str)=each($config)) {
602 $all.="\n[GLOBAL]\n".$str;
606 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
608 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
609 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
610 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
612 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
617 * Returns a new string of max. $chars lenght
618 * If the string is longer, it will be truncated and prepended with "..."
619 * $chars must be an integer of at least 4
621 * @param [type] $string: ...
622 * @param [type] $chars: ...
625 function ext_fixed_lgd($string,$chars) {
627 if(strlen($string)>$chars) {
628 return substr($string, 0, $chars-3)."...";
635 * [Describe function...]
637 * @param [type] $ln: ...
638 * @param [type] $str: ...
641 function ext_lnBreakPointWrap($ln,$str) {
642 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
646 * [Describe function...]
648 * @param [type] $input: ...
649 * @param [type] $ln: ...
650 * @param [type] $comments: ...
651 * @param [type] $crop: ...
654 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
655 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
656 $input = chop($input);
657 $cArr = explode(chr(10),$input);
660 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
662 while(list($k,$v)=each($cArr)) {
663 $lln=$k+
$this->ext_lineNumberOffset+
1;
664 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
665 $v=htmlspecialchars($v);
666 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
667 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
669 $firstChar = substr(trim($v),0,1);
670 if ($firstChar=="[") {
671 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
672 } elseif ($firstChar=="/" ||
$firstChar=="#") {
674 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
682 $output = implode($cArr, "<BR>")."<BR>";
687 * [Describe function...]
689 * @param [type] $id: ...
690 * @param [type] $template_uid: ...
693 function ext_getFirstTemplate($id,$template_uid=0) {
694 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
697 $addC = " AND uid=".$template_uid;
699 $query = "SELECT * FROM sys_template WHERE pid = ".intval($id).$addC." ".$this->whereClause
." ORDER BY sorting LIMIT 1";
700 $res = mysql(TYPO3_db
, $query);
702 $row = mysql_fetch_assoc($res);
703 return $row; // Returns the template row if found.
708 * [Describe function...]
710 * @param [type] $id: ...
713 function ext_getAllTemplates($id) {
714 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
716 $query = "SELECT * FROM sys_template WHERE pid = ".intval($id)." ".$this->whereClause
." ORDER BY sorting";
717 $res = mysql(TYPO3_db
, $query);
720 while($row = mysql_fetch_assoc($res)) {
723 return $outRes; // Returns the template rows in an array.
728 * This function compares the flattened constants (default and all).
729 * Returns an array with the constants from the whole template which may be edited by the module.
731 * @param [type] $default: ...
734 function ext_compareFlatSetups($default) {
735 $editableComments=array();
736 reset($this->flatSetup
);
737 while(list($const,$value)=each($this->flatSetup
)) {
738 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
739 $comment = trim($this->flatSetup
[$const.".."]);
740 $c_arr = explode(chr(10),$comment);
741 while(list($k,$v)=each($c_arr)) {
742 $line=trim(ereg_replace("^[#\/]*","",$v));
744 $parts = explode(";", $line);
745 while(list(,$par)=each($parts)) {
746 if (strstr($par,"=")) {
747 $keyValPair =explode("=",$par,2);
748 switch(trim(strtolower($keyValPair[0]))) {
752 int (range; low-high, list: item,item,item = selector),
759 $editableComments[$const]["type"] = trim($keyValPair[1]);
762 // list of categories.
763 $catSplit=explode("/",strtolower($keyValPair[1]));
764 $editableComments[$const]["cat"] = trim($catSplit[0]);
765 $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.
766 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
767 $editableComments[$const]["subcat_name"]=$catSplit[1];
768 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
770 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
775 $editableComments[$const]["label"] = trim($keyValPair[1]);
783 if (isset($editableComments[$const])) {
784 $editableComments[$const]["name"]=$const;
785 $editableComments[$const]["value"]=trim($value);
786 if (isset($default[$const])) {
787 $editableComments[$const]["default_value"]=trim($default[$const]);
791 return $editableComments;
795 * [Describe function...]
797 * @param [type] $editConstArray: ...
800 function ext_categorizeEditableConstants($editConstArray) {
801 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
802 reset($editConstArray);
803 while(list($constName,$constData)=each($editConstArray)) {
804 if (!$constData["type"]) {$constData["type"]="string";}
805 $cats = explode(",",$constData["cat"]);
807 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...
808 $theCat=trim($theCat);
810 $this->categories
[$theCat][$constName]=$constData["subcat"];
811 // $this->categories["all"][$constName]=$constData["subcat"];
815 // debug($this->categories);
819 * [Describe function...]
823 function ext_getCategoryLabelArray() {
824 // Returns array used for labels in the menu.
826 while(list($k,$v)=each($this->categories
)) {
828 $retArr[$k]=strtoupper($k)." (".count($v).")";
835 * [Describe function...]
837 * @param [type] $type: ...
840 function ext_getTypeData($type) {
844 $retArr["type"]="string";
846 $m=strcspn ($type," [");
847 $retArr["type"]=strtolower(substr($type,0,$m));
848 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
849 $p=trim(substr($type,$m));
850 ereg("\[(.*)\]",$p,$reg);
853 $retArr["paramstr"]=$p;
854 switch($retArr["type"]) {
856 if (substr($retArr["paramstr"],0,1)=="-") {
857 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
858 $retArr["params"][0]=intval("-".$retArr["params"][0]);
860 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
862 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
865 $retArr["params"]=explode(",",$retArr["paramstr"]);
876 * [Describe function...]
878 * @param [type] $category: ...
881 function ext_getTSCE_config($category) {
882 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
884 if (is_array($catConf)) {
886 while(list($key,$val)=each($catConf)) {
889 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
897 if (t3lib_div
::testInt($key)) {
898 $constRefs = explode(",",$val);
900 while(list(,$const)=each($constRefs)) {
902 if ($const && $const<=20) {
903 $out["constants"][$const].=$this->ext_getKeyImage($key);
911 $this->helpConfig
=$out;
915 * [Describe function...]
917 * @param [type] $key: ...
920 function ext_getKeyImage($key) {
921 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
925 * [Describe function...]
927 * @param [type] $imgConf: ...
930 function ext_getTSCE_config_image($imgConf) {
931 if (substr($imgConf,0,4)=="gfx/") {
932 $iFile=$this->ext_localGfxPrefix
.$imgConf;
933 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
934 } elseif (substr($imgConf,0,4)=='EXT:') {
935 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
937 $f = substr($iFile,strlen(PATH_site
));
938 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
941 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
943 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
945 $imageInfo=@getImagesize
($iFile);
946 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
950 * [Describe function...]
954 function ext_resourceDims() {
955 if ($this->setup
["resources"]) {
956 $rArr=explode(",",$this->setup
["resources"]);
957 while(list($c,$val)=each($rArr)) {
959 $theFile = PATH_site
."uploads/tf/".$val;
960 if ($val && @is_file
($theFile)) {
961 $imgInfo = @getimagesize
($theFile);
963 if (is_array($imgInfo)) {
964 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
968 reset($this->dirResources
);
969 while(list($c,$val)=each($this->dirResources
)) {
971 $imgInfo = @getimagesize
(PATH_site
.$val);
972 if (is_array($imgInfo)) {
973 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
979 * [Describe function...]
981 * @param [type] $path: ...
984 function ext_readDirResources($path) {
986 if ($path && substr($path,0,10)=="fileadmin/") {
987 $path = ereg_replace("\/$","",$path);
988 $this->readDirectory(PATH_site
.$path);
993 * [Describe function...]
995 * @param [type] $path: ...
996 * @param [type] $type: ...
999 function readDirectory($path,$type="file") {
1000 if(@is_dir
($path)) {
1003 if (is_object($d)) {
1004 while($entry=$d->read()) {
1005 if ($entry!="." && $entry!="..") {
1006 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1007 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1008 $fI = t3lib_div
::split_fileref($wholePath);
1009 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1019 * [Describe function...]
1021 * @param [type] $params: ...
1022 * @return [type] ...
1024 function ext_fNandV($params) {
1025 $fN='data['.$params["name"].']';
1026 $fV=$params["value"];
1027 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1030 $fV=htmlspecialchars($fV);
1032 return array($fN,$fV,$params);
1036 * [Describe function...]
1038 * @param [type] $theConstants: ...
1039 * @param [type] $category: ...
1040 * @return [type] ...
1042 function ext_printFields($theConstants,$category) {
1043 // This functions returns the HTML-code that creates the editor-layout of the module.
1044 reset($theConstants);
1047 if (is_array($this->categories
[$category])) {
1049 $help=$this->helpConfig
;
1050 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1052 asort($this->categories
[$category]);
1053 while(list($name,$type)=each($this->categories
[$category])) {
1054 $params = $theConstants[$name];
1055 if (is_array($params)) {
1056 if ($subcat!=$params["subcat_name"]) {
1057 $subcat=$params["subcat_name"];
1058 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1060 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1064 // if (substr($params["value"],0,2)!='{$') {
1065 $label=$GLOBALS["LANG"]->sL($params["label"]);
1066 $label_parts = explode(":",$label,2);
1067 if (count($label_parts)==2) {
1068 $head=trim($label_parts[0]);
1069 $body=trim($label_parts[1]);
1071 $head=trim($label_parts[0]);
1074 if (strlen($head)>35) {
1075 if (!$body) {$body=$head;}
1076 $head=t3lib_div
::fixed_lgd($head,35);
1078 $typeDat=$this->ext_getTypeData($params["type"]);
1081 $raname = substr(md5($params["name"]),0,10);
1082 $aname="'".$raname."'";
1083 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1084 $checked=" checked";
1085 list($fN,$fV,$params)=$this->ext_fNandV($params);
1087 switch($typeDat["type"]) {
1090 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1091 if ($typeDat["paramstr"]) {
1092 $p_field.=' Range: '.$typeDat["paramstr"];
1093 } elseif ($typeDat["type"]=="int+") {
1094 $p_field.=' Range: 0 - ';
1096 $p_field.=' (Integer)';
1100 $colorNames=explode(",",",".$this->HTMLcolorList
);
1102 while(list(,$val)=each($colorNames)) {
1104 if ($val==strtolower($params["value"])) {$sel=" selected";}
1105 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1107 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1109 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1112 $wArr = explode("|",$fV);
1113 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1115 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1118 $wArr = explode(",",$fV);
1119 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1120 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1122 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1123 for ($aa=2;$aa<count($labels);$aa++
) {
1125 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1127 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1132 if (is_array($typeDat["params"])) {
1134 while(list(,$val)=each($typeDat["params"])) {
1135 $vParts = explode("=",$val,2);
1136 $label = $vParts[0];
1137 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1141 if ($val==$params["value"]) {$sel=" selected";}
1142 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1144 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1148 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1149 $sel=""; if ($fV) {$sel=" checked";}
1150 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1153 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1154 $sel=""; if (!$fV) {$sel=" checked";}
1155 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1158 $p_field='<option value=""></option>';
1159 // debug($params["value"]);
1162 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1163 if ($params["value"] && !$selectThisFile) {
1164 if (in_array($params["value"],$this->dirResources
)) {
1165 $selectThisFile=$params["value"];
1168 // debug($selectThisFile);
1170 $extList = $typeDat["paramstr"];
1171 $p_field='<option value="">('.$extList.')</option>';
1172 if ($extList=="IMAGE_EXT") {
1173 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1176 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1178 while(list($c,$val)=each($this->rArr
)) {
1180 $fI=t3lib_div
::split_fileref($val);
1182 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1183 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1184 if ($onlineResourceFlag<0) {
1185 $p_field.='<option value=""></option>';
1187 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1188 $onlineResourceFlag=1;
1190 $dims=$this->resourceDimensions
[$val];
1193 // Check if $params["value"] is in the list of resources.
1194 if ($selectThisFile && $selectThisFile==$val) {
1196 if ($onlineResourceFlag<=0) {
1197 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1199 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1203 if ($onlineResourceFlag<=0) {
1204 $onlineResourceFlag--;
1205 // Value is set with a *
1206 $val = $this->ext_setStar($val);
1207 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1209 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1213 if (trim($params["value"]) && !$selectThisFile) {
1214 $val = $params["value"];
1215 $p_field.='<option value=""></option>';
1216 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1219 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1220 $p_field.=$theImage;
1222 if (!$this->ext_noCEUploadAndCopying
) {
1224 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1226 if ($params["value"]) {
1227 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1230 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1234 if ($copyFile && @is_file
($copyFile)) {
1235 $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"])).'\'));}">';
1239 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1244 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1245 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1249 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1250 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1251 $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>';
1253 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1256 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1257 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1258 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1259 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1262 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1263 $output.='<td valign=top align="right">'.$p_name.'</td>';
1266 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1270 debug("Error. Constant did not exits. Should not happen.");
1273 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1289 /***************************
1291 * Processing input values
1293 ***************************/
1296 * @param [type] $constants: ...
1297 * @return [type] ...
1299 function ext_regObjectPositions($constants) {
1300 // 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
1301 $this->raw
= explode(chr(10),$constants);
1304 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1305 $this->ext_regObjects("");
1309 * [Describe function...]
1311 * @param [type] $pre: ...
1312 * @return [type] ...
1314 function ext_regObjects($pre) {
1315 // works with regObjectPositions. "expands" the names of the TypoScript objects
1316 while (isset($this->raw
[$this->rawP
])) {
1317 $line = ltrim($this->raw
[$this->rawP
]);
1318 if (strstr($line,$this->edit_divider
)) {
1319 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1323 if (substr($line,0,1)=="[") {
1325 } elseif (strcspn($line,"}#/")!=0) {
1326 $varL = strcspn($line," {=<");
1327 $var=substr($line,0,$varL);
1328 $line = ltrim(substr($line,$varL));
1329 switch(substr($line,0,1)) {
1331 $this->objReg
[$pre.$var]=$this->rawP
-1;
1334 $this->ext_inBrace++
;
1335 $this->ext_regObjects($pre.$var.".");
1338 $this->lastComment
="";
1339 } elseif (substr($line,0,1)=="}") {
1340 $this->lastComment
="";
1341 $this->ext_inBrace
--;
1342 if ($this->ext_inBrace
<0) {
1343 $this->ext_inBrace
=0;
1353 * [Describe function...]
1355 * @param [type] $key: ...
1356 * @param [type] $var: ...
1357 * @return [type] ...
1359 function ext_putValueInConf($key, $var) {
1360 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1361 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1362 $theValue = " ".trim($var);
1363 if (isset($this->objReg
[$key])) {
1364 $lineNum = $this->objReg
[$key];
1365 $parts = explode("=",$this->raw
[$lineNum],2);
1366 if (count($parts)==2) {
1367 $parts[1]= $theValue;
1369 $this->raw
[$lineNum]=implode($parts,"=");
1371 $this->raw
[]=$key." =".$theValue;
1377 * [Describe function...]
1379 * @param [type] $key: ...
1380 * @return [type] ...
1382 function ext_removeValueInConf($key) {
1383 // Removes the value in the configuration
1384 if (isset($this->objReg
[$key])) {
1385 $lineNum = $this->objReg
[$key];
1386 unset($this->raw
[$lineNum]);
1392 * [Describe function...]
1394 * @param [type] $arr: ...
1395 * @param [type] $settings: ...
1396 * @return [type] ...
1398 function ext_depthKeys($arr,$settings) {
1401 while(list($theK,$theV)=each($arr)) {
1402 $theKeyParts = explode(".",$theK);
1404 $c=count($theKeyParts);
1406 while(list(,$p)=each($theKeyParts)) {
1408 $depth.=($depth?
".":"").$p;
1409 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1414 while(list($theK,$theV)=each($tsbrArray)) {
1416 $settings[$theK] = 1;
1418 unset($settings[$theK]);
1425 * [Describe function...]
1427 * @param [type] $http_post_vars: ...
1428 * @param [type] $http_post_files: ...
1429 * @param [type] $theConstants: ...
1430 * @param [type] $tplRow: ...
1431 * @return [type] ...
1433 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1434 $data=$http_post_vars["data"];
1435 $check=$http_post_vars["check"];
1436 $copyResource=$http_post_vars["_copyResource"];
1437 $Wdata=$http_post_vars["Wdata"];
1438 $W2data=$http_post_vars["W2data"];
1439 $W3data=$http_post_vars["W3data"];
1440 $W4data=$http_post_vars["W4data"];
1441 $W5data=$http_post_vars["W5data"];
1443 if (is_array($data)) {
1445 while(list($key,$var)=each($data)) {
1446 if (isset($theConstants[$key])) {
1447 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1448 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1449 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1450 switch($typeDat["type"]) {
1452 if ($typeDat["paramstr"]) {
1453 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1459 $var=t3lib_div
::intInRange($var,0,10000);
1463 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1464 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1465 $col[]=HexDec(substr($var,0,2));
1466 $col[]=HexDec(substr($var,2,2));
1467 $col[]=HexDec(substr($var,4,2));
1468 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1479 if (isset($Wdata[$key])) {
1480 $var.="|".$Wdata[$key];
1484 if (isset($Wdata[$key])) {
1485 $var=intval($var).",".intval($Wdata[$key]);
1486 if (isset($W2data[$key])) {
1487 $var.=",".intval($W2data[$key]);
1488 if (isset($W3data[$key])) {
1489 $var.=",".intval($W3data[$key]);
1490 if (isset($W4data[$key])) {
1491 $var.=",".intval($W4data[$key]);
1492 if (isset($W5data[$key])) {
1493 $var.=",".intval($W5data[$key]);
1502 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1506 if (!$this->ext_noCEUploadAndCopying
) {
1507 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1508 $var = $this->upload_copy_file(
1511 trim($http_post_files["upload_data"]["name"][$key]),
1512 $http_post_files["upload_data"]["tmp_name"][$key]
1515 if ($copyResource[$key]) {
1516 $var = $this->upload_copy_file(
1519 basename($copyResource[$key]),
1526 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1527 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1529 unset($check[$key]); // Remove the entry because it has been "used"
1531 $this->ext_removeValueInConf($key);
1536 // 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...
1537 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1539 while(list($key,$var)=each($check)) {
1540 if (isset($theConstants[$key])) {
1541 $dValue = $theConstants[$key]["default_value"];
1543 $this->ext_putValueInConf($key, $dValue);
1548 // debug($this->objReg);
1552 * [Describe function...]
1554 * @param [type] $typeDat: ...
1555 * @param [type] $tplRow: ...
1556 * @param [type] $theRealFileName: ...
1557 * @param [type] $tmp_name: ...
1558 * @return [type] ...
1560 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1563 $extList = $typeDat["paramstr"];
1564 if ($extList=="IMAGE_EXT") {
1565 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1567 $fI=t3lib_div
::split_fileref($theRealFileName);
1568 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1569 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1572 $alternativeFileName=array();
1573 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1574 // Making list of resources
1575 $resList = $tplRow["resources"];
1576 $resList = $tmp_upload_name.",".$resList;
1577 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1578 // Making data-array
1580 $recData["sys_template"][$tplRow["uid"]]["resources"] = $resList;
1582 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1583 $tce->stripslashes_values
=0;
1584 $tce->alternativeFileName
= $alternativeFileName;
1585 $tce->start($recData,Array());
1586 $tce->process_datamap();
1588 t3lib_div
::unlink_tempfile($tmp_upload_name);
1590 $tmpRow = t3lib_BEfunc
::getRecord("sys_template",$tplRow["uid"],"resources");
1591 $tplRow["resources"] = $tmpRow["resources"];
1593 // Setting the value
1594 $var = $this->ext_setStar($theRealFileName);
1600 * [Describe function...]
1602 * @param [type] $id: ...
1603 * @param [type] $perms_clause: ...
1604 * @return [type] ...
1606 function ext_prevPageWithTemplate($id,$perms_clause) {
1607 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1609 while(list(,$p)=each($rootLine)) {
1610 if ($this->ext_getFirstTemplate($p["uid"])) {
1617 * [Describe function...]
1619 * @param [type] $val: ...
1620 * @return [type] ...
1622 function ext_setStar($val) {
1623 $fParts = explode(".",strrev($val),2);
1624 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1629 * [Describe function...]
1631 * @param [type] $value: ...
1632 * @return [type] ...
1634 function ext_detectAndFixExtensionPrefix($value) {
1635 if (substr($value,0,4)=="EXT:") {
1636 $parts = explode("/",substr($value,4),2);
1638 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1639 $value = $extPath.$parts[1];
1648 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1649 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);