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 * 712: function ext_getAllTemplates($id)
58 * 732: function ext_compareFlatSetups($default)
59 * 798: function ext_categorizeEditableConstants($editConstArray)
60 * 821: function ext_getCategoryLabelArray()
61 * 838: function ext_getTypeData($type)
62 * 879: function ext_getTSCE_config($category)
63 * 918: function ext_getKeyImage($key)
64 * 928: function ext_getTSCE_config_image($imgConf)
65 * 952: function ext_resourceDims()
66 * 982: function ext_readDirResources($path)
67 * 997: function readDirectory($path,$type="file")
68 * 1022: function ext_fNandV($params)
69 * 1040: function ext_printFields($theConstants,$category)
71 * SECTION: Processing input values
72 * 1297: function ext_regObjectPositions($constants)
73 * 1312: function ext_regObjects($pre)
74 * 1357: function ext_putValueInConf($key, $var)
75 * 1380: function ext_removeValueInConf($key)
76 * 1396: function ext_depthKeys($arr,$settings)
77 * 1431: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
78 * 1558: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
79 * 1604: function ext_prevPageWithTemplate($id,$perms_clause)
80 * 1620: function ext_setStar($val)
81 * 1632: 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 if (substr($key,-2)!="..") { // Don't do anything with comments / linenumber registrations...
358 $key=ereg_replace("\.$","",$key);
359 if (substr($key,-1)!=".") {
360 if (t3lib_div
::testInt($key)) {
361 $keyArr_num[$key]=$arr[$key];
363 $keyArr_alpha[$key]=$arr[$key];
369 $keyArr=$keyArr_num+
$keyArr_alpha;
372 if ($depth_in) {$depth_in = $depth_in.".";}
374 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
375 // debug($validate_info);
377 while (list($key,)=each($keyArr)) {
379 $depth=$depth_in.$key;
380 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
381 $goto = substr(md5($depth),0,6);
383 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
385 $LN = ($a==$c)?
"blank":"line";
386 $BTM = ($a==$c)?
"bottom":"";
387 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
390 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
394 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
395 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
399 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
400 $label='<font color="#666666">'.$label.'</font>';
402 if ($this->linkObjects
) {
403 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
404 if ($this->bType
!="const") {
405 $ln = is_array($arr[$key.'.ln..']) ?
'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
409 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
413 $HTML.="[".$label."]";
415 if (isset($arr[$key])) {
416 $theValue = $arr[$key];
417 if ($this->fixedLgd
) {
418 $imgBlocks = ceil(1+
strlen($depthData)/77);
419 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
420 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
422 if ($this->tsbrowser_searchKeys
[$depth]) {
423 $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
425 $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
431 $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]);
439 function lineNumberToScript($lnArr) {
440 if (!is_array($this->lnToScript
)) {
441 $this->lnToScript
= array();
443 $c+
=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],chr(10))+
2;
444 $this->lnToScript
[$c] = '[Default]';
446 foreach($this->hierarchyInfoToRoot
as $info) {
447 $c+
=$info['configLines']+
1;
448 $this->lnToScript
[$c] = $info['title'];
452 foreach($lnArr as $k => $ln) {
453 foreach($this->lnToScript
as $endLn => $title) {
454 if ($endLn >= intval($ln)) {
455 $lnArr[$k] = '"'.$title.'", '.$ln;
461 return implode('; ',$lnArr);
465 * [Describe function...]
467 * @param [type] $theValue: ...
470 function makeHtmlspecialchars($theValue){
471 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
475 * [Describe function...]
477 * @param [type] $arr: ...
478 * @param [type] $depth_in: ...
479 * @param [type] $searchString: ...
480 * @param [type] $keyArray: ...
483 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
486 while (list($key,)=each($arr)) {
487 $key=ereg_replace("\.$","",$key);
488 if (substr($key,-1)!=".") {
495 if ($depth_in) {$depth_in = $depth_in.".";}
496 while (list($key,)=each($keyArr)) {
497 $depth=$depth_in.$key;
498 $deeper = is_array($arr[$key."."]);
500 if ($this->regexMode
) {
501 if (ereg($searchString,$arr[$key])) { $this->tsbrowser_searchKeys
[$depth]=1; }
503 if (stristr($arr[$key],$searchString)) { $this->tsbrowser_searchKeys
[$depth]=1; }
507 $cS = count($this->tsbrowser_searchKeys
);
508 $keyArray = $this->ext_getSearchKeys($arr[$key."."], $depth, $searchString, $keyArray);
509 if ($cS != count($this->tsbrowser_searchKeys
)) {
518 * [Describe function...]
520 * @param [type] $pid: ...
523 function ext_getRootlineNumber($pid) {
524 if ($pid && is_array($GLOBALS["rootLine"])) {
525 reset($GLOBALS["rootLine"]);
526 while(list($key,$val)=each($GLOBALS["rootLine"])) {
527 if ($val['uid']==$pid) return $key;
533 * [Describe function...]
535 * @param [type] $arr: ...
536 * @param [type] $depthData: ...
537 * @param [type] $keyArray: ...
538 * @param [type] $first: ...
541 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
544 while (list($key,)=each($arr)) {
545 $key=ereg_replace("\.$","",$key);
546 if (substr($key,-1)!=".") {
553 while (list($key,)=each($keyArr)) {
556 $deeper = is_array($arr[$key."."]);
560 $LN = ($a==$c)?
"blank":"line";
561 $BTM = ($a==$c)?
"top":"";
565 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
566 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
567 $alttext= "[".$row['templateID']."]";
568 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
569 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
570 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
576 $HTML.=($first?
'':'<IMG src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border=0>').'<IMG src="'.$GLOBALS["BACK_PATH"].$icon.'" width="18" height="16" align="top" title="'.$alttext.'">'.$A_B.t3lib_div
::fixed_lgd_cs($row['title'],$GLOBALS["BE_USER"]->uc
["titleLen"]).$A_E." ";
577 $RL = $this->ext_getRootlineNumber($row['pid']);
579 <td nowrap>'.$HTML.'</td>
580 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
581 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
582 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
583 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
584 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
587 $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);
594 * [Describe function...]
596 * @param [type] $depthDataArr: ...
597 * @param [type] $pointer: ...
600 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
601 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
602 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
604 $row = $this->hierarchyInfo
[$pointer];
606 $depthDataArr[$row['templateID']]=$row;
607 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
608 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
609 unset($this->clearList_setup_temp
[$row['templateID']]);
610 unset($this->clearList_const_temp
[$row['templateID']]);
611 $this->templateTitles
[$row['templateID']]=$row["title"];
613 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
614 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
617 return $depthDataArr;
621 * [Describe function...]
623 * @param [type] $config: ...
624 * @param [type] $lineNumbers: ...
625 * @param [type] $comments: ...
626 * @param [type] $crop: ...
627 * @param [type] $syntaxHL: ...
628 * @param [type] $syntaxHLBlockmode: ...
631 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
634 while (list(,$str)=each($config)) {
635 $all.="\n[GLOBAL]\n".$str;
639 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
641 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
642 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
643 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
645 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
650 * Returns a new string of max. $chars lenght
651 * If the string is longer, it will be truncated and prepended with "..."
652 * $chars must be an integer of at least 4
654 * @param [type] $string: ...
655 * @param [type] $chars: ...
658 function ext_fixed_lgd($string,$chars) {
660 if(strlen($string)>$chars) {
661 return substr($string, 0, $chars-3)."...";
668 * [Describe function...]
670 * @param [type] $ln: ...
671 * @param [type] $str: ...
674 function ext_lnBreakPointWrap($ln,$str) {
675 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
679 * [Describe function...]
681 * @param [type] $input: ...
682 * @param [type] $ln: ...
683 * @param [type] $comments: ...
684 * @param [type] $crop: ...
687 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
688 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
689 $input = chop($input);
690 $cArr = explode(chr(10),$input);
693 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
695 while(list($k,$v)=each($cArr)) {
696 $lln=$k+
$this->ext_lineNumberOffset+
1;
697 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
698 $v=htmlspecialchars($v);
699 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
700 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
702 $firstChar = substr(trim($v),0,1);
703 if ($firstChar=="[") {
704 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
705 } elseif ($firstChar=="/" ||
$firstChar=="#") {
707 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
715 $output = implode($cArr, "<BR>")."<BR>";
720 * [Describe function...]
722 * @param [type] $id: ...
723 * @param [type] $template_uid: ...
726 function ext_getFirstTemplate($id,$template_uid=0) {
727 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
730 $addC = " AND uid=".$template_uid;
732 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause
, '', 'sorting', '1');
733 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
734 $GLOBALS['TYPO3_DB']->sql_free_result($res);
735 return $row; // Returns the template row if found.
740 * [Describe function...]
742 * @param [type] $id: ...
745 function ext_getAllTemplates($id) {
746 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
749 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
750 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
753 $GLOBALS['TYPO3_DB']->sql_free_result($res);
754 return $outRes; // Returns the template rows in an array.
759 * This function compares the flattened constants (default and all).
760 * Returns an array with the constants from the whole template which may be edited by the module.
762 * @param [type] $default: ...
765 function ext_compareFlatSetups($default) {
766 $editableComments=array();
767 reset($this->flatSetup
);
768 while(list($const,$value)=each($this->flatSetup
)) {
769 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
770 $comment = trim($this->flatSetup
[$const.".."]);
771 $c_arr = explode(chr(10),$comment);
772 while(list($k,$v)=each($c_arr)) {
773 $line=trim(ereg_replace("^[#\/]*","",$v));
775 $parts = explode(";", $line);
776 while(list(,$par)=each($parts)) {
777 if (strstr($par,"=")) {
778 $keyValPair =explode("=",$par,2);
779 switch(trim(strtolower($keyValPair[0]))) {
783 int (range; low-high, list: item,item,item = selector),
790 $editableComments[$const]["type"] = trim($keyValPair[1]);
793 // list of categories.
794 $catSplit=explode("/",strtolower($keyValPair[1]));
795 $editableComments[$const]["cat"] = trim($catSplit[0]);
796 $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.
797 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
798 $editableComments[$const]["subcat_name"]=$catSplit[1];
799 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
801 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
806 $editableComments[$const]["label"] = trim($keyValPair[1]);
814 if (isset($editableComments[$const])) {
815 $editableComments[$const]["name"]=$const;
816 $editableComments[$const]["value"]=trim($value);
817 if (isset($default[$const])) {
818 $editableComments[$const]["default_value"]=trim($default[$const]);
822 return $editableComments;
826 * [Describe function...]
828 * @param [type] $editConstArray: ...
831 function ext_categorizeEditableConstants($editConstArray) {
832 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
833 reset($editConstArray);
834 while(list($constName,$constData)=each($editConstArray)) {
835 if (!$constData["type"]) {$constData["type"]="string";}
836 $cats = explode(",",$constData["cat"]);
838 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...
839 $theCat=trim($theCat);
841 $this->categories
[$theCat][$constName]=$constData["subcat"];
842 // $this->categories["all"][$constName]=$constData["subcat"];
846 // debug($this->categories);
850 * [Describe function...]
854 function ext_getCategoryLabelArray() {
855 // Returns array used for labels in the menu.
857 while(list($k,$v)=each($this->categories
)) {
859 $retArr[$k]=strtoupper($k)." (".count($v).")";
866 * [Describe function...]
868 * @param [type] $type: ...
871 function ext_getTypeData($type) {
875 $retArr["type"]="string";
877 $m=strcspn ($type," [");
878 $retArr["type"]=strtolower(substr($type,0,$m));
879 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
880 $p=trim(substr($type,$m));
881 ereg("\[(.*)\]",$p,$reg);
884 $retArr["paramstr"]=$p;
885 switch($retArr["type"]) {
887 if (substr($retArr["paramstr"],0,1)=="-") {
888 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
889 $retArr["params"][0]=intval("-".$retArr["params"][0]);
891 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
893 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
896 $retArr["params"]=explode(",",$retArr["paramstr"]);
907 * [Describe function...]
909 * @param [type] $category: ...
912 function ext_getTSCE_config($category) {
913 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
915 if (is_array($catConf)) {
917 while(list($key,$val)=each($catConf)) {
920 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
928 if (t3lib_div
::testInt($key)) {
929 $constRefs = explode(",",$val);
931 while(list(,$const)=each($constRefs)) {
933 if ($const && $const<=20) {
934 $out["constants"][$const].=$this->ext_getKeyImage($key);
942 $this->helpConfig
=$out;
946 * [Describe function...]
948 * @param [type] $key: ...
951 function ext_getKeyImage($key) {
952 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
956 * [Describe function...]
958 * @param [type] $imgConf: ...
961 function ext_getTSCE_config_image($imgConf) {
962 if (substr($imgConf,0,4)=="gfx/") {
963 $iFile=$this->ext_localGfxPrefix
.$imgConf;
964 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
965 } elseif (substr($imgConf,0,4)=='EXT:') {
966 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
968 $f = substr($iFile,strlen(PATH_site
));
969 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
972 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
974 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
976 $imageInfo=@getImagesize
($iFile);
977 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
981 * [Describe function...]
985 function ext_resourceDims() {
986 if ($this->setup
["resources"]) {
987 $rArr=explode(",",$this->setup
["resources"]);
988 while(list($c,$val)=each($rArr)) {
990 $theFile = PATH_site
."uploads/tf/".$val;
991 if ($val && @is_file
($theFile)) {
992 $imgInfo = @getimagesize
($theFile);
994 if (is_array($imgInfo)) {
995 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
999 reset($this->dirResources
);
1000 while(list($c,$val)=each($this->dirResources
)) {
1002 $imgInfo = @getimagesize
(PATH_site
.$val);
1003 if (is_array($imgInfo)) {
1004 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1010 * [Describe function...]
1012 * @param [type] $path: ...
1013 * @return [type] ...
1015 function ext_readDirResources($path) {
1017 if ($path && substr($path,0,10)=="fileadmin/") {
1018 $path = ereg_replace("\/$","",$path);
1019 $this->readDirectory(PATH_site
.$path);
1024 * [Describe function...]
1026 * @param [type] $path: ...
1027 * @param [type] $type: ...
1028 * @return [type] ...
1030 function readDirectory($path,$type="file") {
1031 if(@is_dir
($path)) {
1034 if (is_object($d)) {
1035 while($entry=$d->read()) {
1036 if ($entry!="." && $entry!="..") {
1037 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1038 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1039 $fI = t3lib_div
::split_fileref($wholePath);
1040 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1050 * [Describe function...]
1052 * @param [type] $params: ...
1053 * @return [type] ...
1055 function ext_fNandV($params) {
1056 $fN='data['.$params["name"].']';
1057 $fV=$params["value"];
1058 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1061 $fV=htmlspecialchars($fV);
1063 return array($fN,$fV,$params);
1067 * [Describe function...]
1069 * @param [type] $theConstants: ...
1070 * @param [type] $category: ...
1071 * @return [type] ...
1073 function ext_printFields($theConstants,$category) {
1074 // This functions returns the HTML-code that creates the editor-layout of the module.
1075 reset($theConstants);
1078 if (is_array($this->categories
[$category])) {
1080 $help=$this->helpConfig
;
1081 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1083 asort($this->categories
[$category]);
1084 while(list($name,$type)=each($this->categories
[$category])) {
1085 $params = $theConstants[$name];
1086 if (is_array($params)) {
1087 if ($subcat!=$params["subcat_name"]) {
1088 $subcat=$params["subcat_name"];
1089 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1091 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1095 // if (substr($params["value"],0,2)!='{$') {
1096 $label=$GLOBALS["LANG"]->sL($params["label"]);
1097 $label_parts = explode(":",$label,2);
1098 if (count($label_parts)==2) {
1099 $head=trim($label_parts[0]);
1100 $body=trim($label_parts[1]);
1102 $head=trim($label_parts[0]);
1105 if (strlen($head)>35) {
1106 if (!$body) {$body=$head;}
1107 $head=t3lib_div
::fixed_lgd_cs($head,35);
1109 $typeDat=$this->ext_getTypeData($params["type"]);
1112 $raname = substr(md5($params["name"]),0,10);
1113 $aname="'".$raname."'";
1114 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1115 $checked=" checked";
1116 list($fN,$fV,$params)=$this->ext_fNandV($params);
1118 switch($typeDat["type"]) {
1121 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1122 if ($typeDat["paramstr"]) {
1123 $p_field.=' Range: '.$typeDat["paramstr"];
1124 } elseif ($typeDat["type"]=="int+") {
1125 $p_field.=' Range: 0 - ';
1127 $p_field.=' (Integer)';
1131 $colorNames=explode(",",",".$this->HTMLcolorList
);
1133 while(list(,$val)=each($colorNames)) {
1135 if ($val==strtolower($params["value"])) {$sel=" selected";}
1136 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1138 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1140 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1143 $wArr = explode("|",$fV);
1144 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1146 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1149 $wArr = explode(",",$fV);
1150 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1151 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1153 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1154 for ($aa=2;$aa<count($labels);$aa++
) {
1156 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1158 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1163 if (is_array($typeDat["params"])) {
1165 while(list(,$val)=each($typeDat["params"])) {
1166 $vParts = explode("=",$val,2);
1167 $label = $vParts[0];
1168 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1172 if ($val==$params["value"]) {$sel=" selected";}
1173 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1175 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1179 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1180 $sel=""; if ($fV) {$sel=" checked";}
1181 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1184 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1185 $sel=""; if (!$fV) {$sel=" checked";}
1186 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1189 $p_field='<option value=""></option>';
1190 // debug($params["value"]);
1193 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1194 if ($params["value"] && !$selectThisFile) {
1195 if (in_array($params["value"],$this->dirResources
)) {
1196 $selectThisFile=$params["value"];
1199 // debug($selectThisFile);
1201 $extList = $typeDat["paramstr"];
1202 $p_field='<option value="">('.$extList.')</option>';
1203 if ($extList=="IMAGE_EXT") {
1204 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1207 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1209 while(list($c,$val)=each($this->rArr
)) {
1211 $fI=t3lib_div
::split_fileref($val);
1213 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1214 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1215 if ($onlineResourceFlag<0) {
1216 $p_field.='<option value=""></option>';
1218 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1219 $onlineResourceFlag=1;
1221 $dims=$this->resourceDimensions
[$val];
1224 // Check if $params["value"] is in the list of resources.
1225 if ($selectThisFile && $selectThisFile==$val) {
1227 if ($onlineResourceFlag<=0) {
1228 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1230 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1234 if ($onlineResourceFlag<=0) {
1235 $onlineResourceFlag--;
1236 // Value is set with a *
1237 $val = $this->ext_setStar($val);
1238 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1240 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1244 if (trim($params["value"]) && !$selectThisFile) {
1245 $val = $params["value"];
1246 $p_field.='<option value=""></option>';
1247 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1250 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1251 $p_field.=$theImage;
1253 if (!$this->ext_noCEUploadAndCopying
) {
1255 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1257 if ($params["value"]) {
1258 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1261 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1265 if ($copyFile && @is_file
($copyFile)) {
1266 $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"])).'\'));}">';
1270 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1275 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1276 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1280 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1281 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1282 $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>';
1284 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1287 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1288 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1289 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1290 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1293 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1294 $output.='<td valign=top align="right">'.$p_name.'</td>';
1297 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1301 debug("Error. Constant did not exits. Should not happen.");
1304 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1320 /***************************
1322 * Processing input values
1324 ***************************/
1327 * @param [type] $constants: ...
1328 * @return [type] ...
1330 function ext_regObjectPositions($constants) {
1331 // 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
1332 $this->raw
= explode(chr(10),$constants);
1335 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1336 $this->ext_regObjects("");
1340 * [Describe function...]
1342 * @param [type] $pre: ...
1343 * @return [type] ...
1345 function ext_regObjects($pre) {
1346 // works with regObjectPositions. "expands" the names of the TypoScript objects
1347 while (isset($this->raw
[$this->rawP
])) {
1348 $line = ltrim($this->raw
[$this->rawP
]);
1349 if (strstr($line,$this->edit_divider
)) {
1350 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1354 if (substr($line,0,1)=="[") {
1356 } elseif (strcspn($line,"}#/")!=0) {
1357 $varL = strcspn($line," {=<");
1358 $var=substr($line,0,$varL);
1359 $line = ltrim(substr($line,$varL));
1360 switch(substr($line,0,1)) {
1362 $this->objReg
[$pre.$var]=$this->rawP
-1;
1365 $this->ext_inBrace++
;
1366 $this->ext_regObjects($pre.$var.".");
1369 $this->lastComment
="";
1370 } elseif (substr($line,0,1)=="}") {
1371 $this->lastComment
="";
1372 $this->ext_inBrace
--;
1373 if ($this->ext_inBrace
<0) {
1374 $this->ext_inBrace
=0;
1384 * [Describe function...]
1386 * @param [type] $key: ...
1387 * @param [type] $var: ...
1388 * @return [type] ...
1390 function ext_putValueInConf($key, $var) {
1391 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1392 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1393 $theValue = " ".trim($var);
1394 if (isset($this->objReg
[$key])) {
1395 $lineNum = $this->objReg
[$key];
1396 $parts = explode("=",$this->raw
[$lineNum],2);
1397 if (count($parts)==2) {
1398 $parts[1]= $theValue;
1400 $this->raw
[$lineNum]=implode($parts,"=");
1402 $this->raw
[]=$key." =".$theValue;
1408 * [Describe function...]
1410 * @param [type] $key: ...
1411 * @return [type] ...
1413 function ext_removeValueInConf($key) {
1414 // Removes the value in the configuration
1415 if (isset($this->objReg
[$key])) {
1416 $lineNum = $this->objReg
[$key];
1417 unset($this->raw
[$lineNum]);
1423 * [Describe function...]
1425 * @param [type] $arr: ...
1426 * @param [type] $settings: ...
1427 * @return [type] ...
1429 function ext_depthKeys($arr,$settings) {
1432 while(list($theK,$theV)=each($arr)) {
1433 $theKeyParts = explode(".",$theK);
1435 $c=count($theKeyParts);
1437 while(list(,$p)=each($theKeyParts)) {
1439 $depth.=($depth?
".":"").$p;
1440 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1445 while(list($theK,$theV)=each($tsbrArray)) {
1447 $settings[$theK] = 1;
1449 unset($settings[$theK]);
1456 * [Describe function...]
1458 * @param [type] $http_post_vars: ...
1459 * @param [type] $http_post_files: ...
1460 * @param [type] $theConstants: ...
1461 * @param [type] $tplRow: ...
1462 * @return [type] ...
1464 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1465 $data=$http_post_vars["data"];
1466 $check=$http_post_vars["check"];
1467 $copyResource=$http_post_vars["_copyResource"];
1468 $Wdata=$http_post_vars["Wdata"];
1469 $W2data=$http_post_vars["W2data"];
1470 $W3data=$http_post_vars["W3data"];
1471 $W4data=$http_post_vars["W4data"];
1472 $W5data=$http_post_vars["W5data"];
1474 if (is_array($data)) {
1476 while(list($key,$var)=each($data)) {
1477 if (isset($theConstants[$key])) {
1478 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1479 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1480 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1481 switch($typeDat["type"]) {
1483 if ($typeDat["paramstr"]) {
1484 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1490 $var=t3lib_div
::intInRange($var,0,10000);
1494 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1495 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1496 $col[]=HexDec(substr($var,0,2));
1497 $col[]=HexDec(substr($var,2,2));
1498 $col[]=HexDec(substr($var,4,2));
1499 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1510 if (isset($Wdata[$key])) {
1511 $var.="|".$Wdata[$key];
1515 if (isset($Wdata[$key])) {
1516 $var=intval($var).",".intval($Wdata[$key]);
1517 if (isset($W2data[$key])) {
1518 $var.=",".intval($W2data[$key]);
1519 if (isset($W3data[$key])) {
1520 $var.=",".intval($W3data[$key]);
1521 if (isset($W4data[$key])) {
1522 $var.=",".intval($W4data[$key]);
1523 if (isset($W5data[$key])) {
1524 $var.=",".intval($W5data[$key]);
1533 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1537 if (!$this->ext_noCEUploadAndCopying
) {
1538 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1539 $var = $this->upload_copy_file(
1542 trim($http_post_files["upload_data"]["name"][$key]),
1543 $http_post_files["upload_data"]["tmp_name"][$key]
1546 if ($copyResource[$key]) {
1547 $var = $this->upload_copy_file(
1550 basename($copyResource[$key]),
1557 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1558 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1560 unset($check[$key]); // Remove the entry because it has been "used"
1562 $this->ext_removeValueInConf($key);
1567 // 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...
1568 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1570 while(list($key,$var)=each($check)) {
1571 if (isset($theConstants[$key])) {
1572 $dValue = $theConstants[$key]["default_value"];
1574 $this->ext_putValueInConf($key, $dValue);
1579 // debug($this->objReg);
1583 * [Describe function...]
1585 * @param [type] $typeDat: ...
1586 * @param [type] $tplRow: ...
1587 * @param [type] $theRealFileName: ...
1588 * @param [type] $tmp_name: ...
1589 * @return [type] ...
1591 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1594 $extList = $typeDat["paramstr"];
1595 if ($extList=="IMAGE_EXT") {
1596 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1598 $fI=t3lib_div
::split_fileref($theRealFileName);
1599 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1600 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1603 $alternativeFileName=array();
1604 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1605 // Making list of resources
1606 $resList = $tplRow["resources"];
1607 $resList = $tmp_upload_name.",".$resList;
1608 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1609 // Making data-array
1611 $recData["sys_template"][$tplRow["uid"]]["resources"] = $resList;
1613 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1614 $tce->stripslashes_values
=0;
1615 $tce->alternativeFileName
= $alternativeFileName;
1616 $tce->start($recData,Array());
1617 $tce->process_datamap();
1619 t3lib_div
::unlink_tempfile($tmp_upload_name);
1621 $tmpRow = t3lib_BEfunc
::getRecord("sys_template",$tplRow["uid"],"resources");
1622 $tplRow["resources"] = $tmpRow["resources"];
1624 // Setting the value
1625 $var = $this->ext_setStar($theRealFileName);
1631 * [Describe function...]
1633 * @param [type] $id: ...
1634 * @param [type] $perms_clause: ...
1635 * @return [type] ...
1637 function ext_prevPageWithTemplate($id,$perms_clause) {
1638 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1640 while(list(,$p)=each($rootLine)) {
1641 if ($this->ext_getFirstTemplate($p["uid"])) {
1648 * [Describe function...]
1650 * @param [type] $val: ...
1651 * @return [type] ...
1653 function ext_setStar($val) {
1654 $fParts = explode(".",strrev($val),2);
1655 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1660 * [Describe function...]
1662 * @param [type] $value: ...
1663 * @return [type] ...
1665 function ext_detectAndFixExtensionPrefix($value) {
1666 if (substr($value,0,4)=="EXT:") {
1667 $parts = explode("/",substr($value,4),2);
1669 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1670 $value = $extPath.$parts[1];
1679 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1680 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);