2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * TSParser extension class to t3lib_TStemplate
31 * Contains functions for the TS module in TYPO3 backend
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 104: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 192: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 219: function substituteConstants($all)
43 * 248: function substituteCMarkers($all)
44 * 270: function generateConfig_constants()
45 * 319: function ext_getSetup($theSetup,$theKey)
46 * 350: function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")
47 * 445: function lineNumberToScript($lnArr)
48 * 476: function makeHtmlspecialchars($theValue)
49 * 489: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
50 * 529: function ext_getRootlineNumber($pid)
51 * 547: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
52 * 606: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
53 * 637: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
54 * 664: function ext_fixed_lgd($string,$chars)
55 * 680: function ext_lnBreakPointWrap($ln,$str)
56 * 693: function ext_formatTS($input, $ln, $comments=1, $crop=0)
57 * 732: function ext_getFirstTemplate($id,$template_uid=0)
58 * 751: function ext_getAllTemplates($id)
59 * 771: function ext_compareFlatSetups($default)
60 * 837: function ext_categorizeEditableConstants($editConstArray)
61 * 860: function ext_getCategoryLabelArray()
62 * 877: function ext_getTypeData($type)
63 * 918: function ext_getTSCE_config($category)
64 * 957: function ext_getKeyImage($key)
65 * 967: function ext_getTSCE_config_image($imgConf)
66 * 991: function ext_resourceDims()
67 * 1021: function ext_readDirResources($path)
68 * 1036: function readDirectory($path,$type="file")
69 * 1061: function ext_fNandV($params)
70 * 1079: function ext_printFields($theConstants,$category)
72 * SECTION: Processing input values
73 * 1336: function ext_regObjectPositions($constants)
74 * 1351: function ext_regObjects($pre)
75 * 1396: function ext_putValueInConf($key, $var)
76 * 1419: function ext_removeValueInConf($key)
77 * 1435: function ext_depthKeys($arr,$settings)
78 * 1470: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
79 * 1597: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
80 * 1643: function ext_prevPageWithTemplate($id,$perms_clause)
81 * 1659: function ext_setStar($val)
82 * 1671: function ext_detectAndFixExtensionPrefix($value)
85 * (This index is automatically created/updated by the extension "extdeveval")
89 require_once(PATH_t3lib
."class.t3lib_tstemplate.php");
98 * TSParser extension class to t3lib_TStemplate
100 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
104 class t3lib_tsparser_ext
extends t3lib_TStemplate
{
106 var $edit_divider = "###MOD_TS:EDITABLE_CONSTANTS###"; // This string is used to indicate the point in a template from where the editable constants are listed. Any vars before this point (if it exists though) is regarded as default values.
107 var $HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
110 var $categories = array(
111 "basic" => array(), // Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure.
112 "menu" => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
113 "content" => array(), // All constants related to the display of pagecontent elements
114 "page" => array(), // General configuration like metatags, link targets
115 "advanced" => array(), // Advanced functions, which are used very seldomly.
116 "all" => array() // All constants are put here also!
117 ); // This will be filled with the available categories of the current template.
118 var $subCategories = array(
119 // Standard categories:
120 "enable" => Array("Enable features", "a"),
121 "dims" => Array("Dimensions, widths, heights, pixels", "b"),
122 "file" => Array("Files", "c"),
123 "typo" => Array("Typography", "d"),
124 "color" => Array("Colors", "e"),
125 "links" => Array("Links and targets", "f"),
126 "language" => Array("Language specific constants", "g"),
128 // subcategories based on the default content elements
129 "cheader" => Array("Content: 'Header'", "ma"),
130 "cheader_g" => Array("Content: 'Header', Graphical", "ma"),
131 "ctext" => Array("Content: 'Text'", "mb"),
133 "cimage" => Array("Content: 'Image'", "md"),
134 "cbullets" => Array("Content: 'Bullet list'", "me"),
135 "ctable" => Array("Content: 'Table'", "mf"),
136 "cuploads" => Array("Content: 'Filelinks'", "mg"),
137 "cmultimedia" => Array("Content: 'Multimedia'", "mh"),
138 "cmailform" => Array("Content: 'Form'", "mi"),
139 "csearch" => Array("Content: 'Search'", "mj"),
140 "clogin" => Array("Content: 'Login'", "mk"),
141 "csplash" => Array("Content: 'Textbox'", "ml"),
142 "cmenu" => Array("Content: 'Menu/Sitemap'", "mm"),
143 "cshortcut" => Array("Content: 'Insert records'", "mn"),
144 "clist" => Array("Content: 'List of records'", "mo"),
145 "cscript" => Array("Content: 'Script'", "mp"),
146 "chtml" => Array("Content: 'HTML'", "mq")
148 var $resourceDimensions = array();
149 var $dirResources = array();
151 // var $matchAll = 0; // If set, all conditions are matched!
159 var $tsbrowser_searchKeys = array();
160 var $tsbrowser_depthKeys = array();
161 var $constantMode="";
164 var $resourceCheck=0;
165 var $ext_lineNumberOffset=0;
166 var $ext_localGfxPrefix="";
167 var $ext_localWebGfxPrefix="";
168 var $ext_expandAllNotes=0;
169 var $ext_noPMicons=0;
170 var $ext_noSpecialCharsOnLabels=0;
171 var $ext_listOfTemplatesArr=array();
172 var $ext_lineNumberOffset_mode="";
173 var $ext_dontCheckIssetValues=0; // Dont change...
174 var $ext_noCEUploadAndCopying=0;
176 var $ext_CEformName="forms[0]";
177 var $ext_defaultOnlineResourceFlag=0;
180 var $templateTitles=array();
184 * This flattens a hierarchical setuparray to $this->flatSetup
185 * The original function fetched the resource-file if any ("file."). This functions doesn't.
187 * @param [type] $setupArray: ...
188 * @param [type] $prefix: ...
189 * @param [type] $resourceFlag: ...
192 function flattenSetup($setupArray, $prefix, $resourceFlag) {
193 if (is_array($setupArray)) {
194 $this->getFileName_backPath
=PATH_site
; // Setting absolute prefixed path for relative resources.
196 while(list($key,$val)=each($setupArray)) {
197 if ($prefix ||
substr($key,0,16)!="TSConstantEditor") { // We don't want "TSConstantEditor" in the flattend setup.
198 if (is_array($val)) {
199 $this->flattenSetup($val,$prefix.$key, ($key=="file."));
200 } elseif ($resourceFlag && $this->resourceCheck
) {
201 $this->flatSetup
[$prefix.$key] = $this->getFileName($val);
202 if ($this->removeFromGetFilePath
&& substr($this->flatSetup
[$prefix.$key],0,strlen($this->removeFromGetFilePath
))==$this->removeFromGetFilePath
) {
203 $this->flatSetup
[$prefix.$key] = substr($this->flatSetup
[$prefix.$key],strlen($this->removeFromGetFilePath
));
206 $this->flatSetup
[$prefix.$key] = $val;
214 * [Describe function...]
216 * @param [type] $all: ...
219 function substituteConstants($all) {
220 $this->Cmarker
=substr(md5(uniqid("")),0,6);
221 reset($this->flatSetup
);
222 while (list($const,$val)=each($this->flatSetup
)) {
223 if (!is_array($val)) {
224 switch($this->constantMode
) {
226 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##{$'.$const.'}##'.$this->Cmarker
.'_E##',$all);
229 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##'.$val.'##'.$this->Cmarker
.'_E##',$all);
234 $all = str_replace('{$'.$const.'}',$val,$all);
243 * [Describe function...]
245 * @param [type] $all: ...
248 function substituteCMarkers($all) {
249 switch($this->constantMode
) {
251 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
252 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
255 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
256 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
266 * [Describe function...]
270 function generateConfig_constants() {
271 // Parses the constants in $this->const with respect to the constant-editor in this module.
272 // In particular comments in the code are registered and the edit_divider is taken into account.
273 // These vars are also set lateron...
274 $this->setup
["resources"]= $this->resources
;
275 $this->setup
["sitetitle"]= $this->sitetitle
;
278 $constants = t3lib_div
::makeInstance("t3lib_TSparser");
279 $constants->regComments
=1; // Register comments!
280 $constants->setup
= $this->const;
281 $constants->setup
= $this->mergeConstantsFromPageTSconfig($constants->setup
);
283 $matchObj = t3lib_div
::makeInstance("t3lib_matchCondition");
284 // $matchObj->matchAlternative = array("[globalString = page | title = *test*]");
285 $matchObj->matchAll
=1; // Matches ALL conditions in TypoScript
288 $cc=count($this->constants
);
289 reset($this->constants
);
290 while (list(,$str)=each($this->constants
)) {
293 if (strstr($str,$this->edit_divider
)) {
294 $parts = explode($this->edit_divider
,$str,2);
296 $constants->parse($parts[0],$matchObj);
298 $this->flatSetup
= Array();
299 $this->flattenSetup($constants->setup
,"","");
300 $defaultConstants=$this->flatSetup
;
302 $constants->parse($str,$matchObj);
305 $this->flatSetup
= Array();
306 $this->flattenSetup($constants->setup
,"","");
307 $this->setup
["constants"] = $constants->setup
;
309 return $this->ext_compareFlatSetups($defaultConstants);
313 * [Describe function...]
315 * @param [type] $theSetup: ...
316 * @param [type] $theKey: ...
319 function ext_getSetup($theSetup,$theKey) {
320 $parts = explode(".",$theKey,2);
321 // debug("-----------",1);
323 if (strcmp($parts[0],"") && is_array($theSetup[$parts[0]."."])) {
324 // debug(trim($parts[1]),1);
325 if (strcmp(trim($parts[1]),"")) {
326 // debug(trim($parts[1]),1);
327 return $this->ext_getSetup($theSetup[$parts[0]."."],trim($parts[1]));
329 return array($theSetup[$parts[0]."."], $theSetup[$parts[0]]);
332 if (strcmp(trim($theKey),"")) {
333 return array(array(),$theSetup[$theKey]);
335 return array($theSetup,"");
341 * [Describe function...]
343 * @param [type] $arr: ...
344 * @param [type] $depth_in: ...
345 * @param [type] $depthData: ...
346 * @param [type] $parentType: ...
347 * @param [type] $parentValue: ...
350 function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="") {
356 $keyArr_alpha=array();
357 while (list($key,)=each($arr)) {
358 if (substr($key,-2)!="..") { // Don't do anything with comments / linenumber registrations...
359 $key=ereg_replace("\.$","",$key);
360 if (substr($key,-1)!=".") {
361 if (t3lib_div
::testInt($key)) {
362 $keyArr_num[$key]=$arr[$key];
364 $keyArr_alpha[$key]=$arr[$key];
370 $keyArr=$keyArr_num+
$keyArr_alpha;
373 if ($depth_in) {$depth_in = $depth_in.".";}
375 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
376 // debug($validate_info);
378 while (list($key,)=each($keyArr)) {
380 $depth=$depth_in.$key;
381 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
382 $goto = substr(md5($depth),0,6);
384 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
386 $LN = ($a==$c)?
"blank":"line";
387 $BTM = ($a==$c)?
"bottom":"";
388 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
391 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
395 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
396 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
400 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
401 $label='<font color="#666666">'.$label.'</font>';
403 if ($this->linkObjects
) {
404 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
405 if ($this->bType
!="const") {
406 $ln = is_array($arr[$key.'.ln..']) ?
'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
410 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
414 $HTML.="[".$label."]";
416 if (isset($arr[$key])) {
417 $theValue = $arr[$key];
418 if ($this->fixedLgd
) {
419 $imgBlocks = ceil(1+
strlen($depthData)/77);
420 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
421 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
423 if ($this->tsbrowser_searchKeys
[$depth]) {
424 $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
426 $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
432 $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]);
440 * [Describe function...]
442 * @param [type] $lnArr: ...
445 function lineNumberToScript($lnArr) {
446 if (!is_array($this->lnToScript
)) {
447 $this->lnToScript
= array();
449 $c+
=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],chr(10))+
2;
450 $this->lnToScript
[$c] = '[Default]';
452 foreach($this->hierarchyInfoToRoot
as $info) {
453 $c+
=$info['configLines']+
1;
454 $this->lnToScript
[$c] = $info['title'];
458 foreach($lnArr as $k => $ln) {
459 foreach($this->lnToScript
as $endLn => $title) {
460 if ($endLn >= intval($ln)) {
461 $lnArr[$k] = '"'.$title.'", '.$ln;
467 return implode('; ',$lnArr);
471 * [Describe function...]
473 * @param [type] $theValue: ...
476 function makeHtmlspecialchars($theValue){
477 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
481 * [Describe function...]
483 * @param [type] $arr: ...
484 * @param [type] $depth_in: ...
485 * @param [type] $searchString: ...
486 * @param [type] $keyArray: ...
489 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
492 while (list($key,)=each($arr)) {
493 $key=ereg_replace("\.$","",$key);
494 if (substr($key,-1)!=".") {
501 if ($depth_in) {$depth_in = $depth_in.".";}
502 while (list($key,)=each($keyArr)) {
503 $depth=$depth_in.$key;
504 $deeper = is_array($arr[$key."."]);
506 if ($this->regexMode
) {
507 if (ereg($searchString,$arr[$key])) { $this->tsbrowser_searchKeys
[$depth]=1; }
509 if (stristr($arr[$key],$searchString)) { $this->tsbrowser_searchKeys
[$depth]=1; }
513 $cS = count($this->tsbrowser_searchKeys
);
514 $keyArray = $this->ext_getSearchKeys($arr[$key."."], $depth, $searchString, $keyArray);
515 if ($cS != count($this->tsbrowser_searchKeys
)) {
524 * [Describe function...]
526 * @param [type] $pid: ...
529 function ext_getRootlineNumber($pid) {
530 if ($pid && is_array($GLOBALS["rootLine"])) {
531 reset($GLOBALS["rootLine"]);
532 while(list($key,$val)=each($GLOBALS["rootLine"])) {
533 if ($val['uid']==$pid) return $key;
539 * [Describe function...]
541 * @param [type] $arr: ...
542 * @param [type] $depthData: ...
543 * @param [type] $keyArray: ...
544 * @param [type] $first: ...
547 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
550 while (list($key,)=each($arr)) {
551 $key=ereg_replace("\.$","",$key);
552 if (substr($key,-1)!=".") {
559 while (list($key,)=each($keyArr)) {
562 $deeper = is_array($arr[$key."."]);
566 $LN = ($a==$c)?
"blank":"line";
567 $BTM = ($a==$c)?
"top":"";
571 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
572 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
573 $alttext= "[".$row['templateID']."]";
574 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
575 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
576 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
582 $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." ";
583 $RL = $this->ext_getRootlineNumber($row['pid']);
585 <td nowrap>'.$HTML.'</td>
586 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
587 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
588 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
589 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
590 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
593 $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);
600 * [Describe function...]
602 * @param [type] $depthDataArr: ...
603 * @param [type] $pointer: ...
606 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
607 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
608 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
610 $row = $this->hierarchyInfo
[$pointer];
612 $depthDataArr[$row['templateID']]=$row;
613 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
614 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
615 unset($this->clearList_setup_temp
[$row['templateID']]);
616 unset($this->clearList_const_temp
[$row['templateID']]);
617 $this->templateTitles
[$row['templateID']]=$row["title"];
619 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
620 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
623 return $depthDataArr;
627 * [Describe function...]
629 * @param [type] $config: ...
630 * @param [type] $lineNumbers: ...
631 * @param [type] $comments: ...
632 * @param [type] $crop: ...
633 * @param [type] $syntaxHL: ...
634 * @param [type] $syntaxHLBlockmode: ...
637 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
640 while (list(,$str)=each($config)) {
641 $all.="\n[GLOBAL]\n".$str;
645 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
647 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
648 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
649 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
651 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
656 * Returns a new string of max. $chars lenght
657 * If the string is longer, it will be truncated and prepended with "..."
658 * $chars must be an integer of at least 4
660 * @param [type] $string: ...
661 * @param [type] $chars: ...
664 function ext_fixed_lgd($string,$chars) {
666 if(strlen($string)>$chars) {
667 return substr($string, 0, $chars-3)."...";
674 * [Describe function...]
676 * @param [type] $ln: ...
677 * @param [type] $str: ...
680 function ext_lnBreakPointWrap($ln,$str) {
681 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
685 * [Describe function...]
687 * @param [type] $input: ...
688 * @param [type] $ln: ...
689 * @param [type] $comments: ...
690 * @param [type] $crop: ...
693 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
694 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
695 $input = chop($input);
696 $cArr = explode(chr(10),$input);
699 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
701 while(list($k,$v)=each($cArr)) {
702 $lln=$k+
$this->ext_lineNumberOffset+
1;
703 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
704 $v=htmlspecialchars($v);
705 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
706 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
708 $firstChar = substr(trim($v),0,1);
709 if ($firstChar=="[") {
710 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
711 } elseif ($firstChar=="/" ||
$firstChar=="#") {
713 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
721 $output = implode($cArr, "<BR>")."<BR>";
726 * [Describe function...]
728 * @param [type] $id: ...
729 * @param [type] $template_uid: ...
732 function ext_getFirstTemplate($id,$template_uid=0) {
733 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
736 $addC = " AND uid=".$template_uid;
738 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause
, '', 'sorting', '1');
739 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
740 $GLOBALS['TYPO3_DB']->sql_free_result($res);
741 return $row; // Returns the template row if found.
746 * [Describe function...]
748 * @param [type] $id: ...
751 function ext_getAllTemplates($id) {
752 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
755 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
756 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
759 $GLOBALS['TYPO3_DB']->sql_free_result($res);
760 return $outRes; // Returns the template rows in an array.
765 * This function compares the flattened constants (default and all).
766 * Returns an array with the constants from the whole template which may be edited by the module.
768 * @param [type] $default: ...
771 function ext_compareFlatSetups($default) {
772 $editableComments=array();
773 reset($this->flatSetup
);
774 while(list($const,$value)=each($this->flatSetup
)) {
775 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
776 $comment = trim($this->flatSetup
[$const.".."]);
777 $c_arr = explode(chr(10),$comment);
778 while(list($k,$v)=each($c_arr)) {
779 $line=trim(ereg_replace("^[#\/]*","",$v));
781 $parts = explode(";", $line);
782 while(list(,$par)=each($parts)) {
783 if (strstr($par,"=")) {
784 $keyValPair =explode("=",$par,2);
785 switch(trim(strtolower($keyValPair[0]))) {
789 int (range; low-high, list: item,item,item = selector),
796 $editableComments[$const]["type"] = trim($keyValPair[1]);
799 // list of categories.
800 $catSplit=explode("/",strtolower($keyValPair[1]));
801 $editableComments[$const]["cat"] = trim($catSplit[0]);
802 $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.
803 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
804 $editableComments[$const]["subcat_name"]=$catSplit[1];
805 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
807 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
812 $editableComments[$const]["label"] = trim($keyValPair[1]);
820 if (isset($editableComments[$const])) {
821 $editableComments[$const]["name"]=$const;
822 $editableComments[$const]["value"]=trim($value);
823 if (isset($default[$const])) {
824 $editableComments[$const]["default_value"]=trim($default[$const]);
828 return $editableComments;
832 * [Describe function...]
834 * @param [type] $editConstArray: ...
837 function ext_categorizeEditableConstants($editConstArray) {
838 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
839 reset($editConstArray);
840 while(list($constName,$constData)=each($editConstArray)) {
841 if (!$constData["type"]) {$constData["type"]="string";}
842 $cats = explode(",",$constData["cat"]);
844 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...
845 $theCat=trim($theCat);
847 $this->categories
[$theCat][$constName]=$constData["subcat"];
848 // $this->categories["all"][$constName]=$constData["subcat"];
852 // debug($this->categories);
856 * [Describe function...]
860 function ext_getCategoryLabelArray() {
861 // Returns array used for labels in the menu.
863 while(list($k,$v)=each($this->categories
)) {
865 $retArr[$k]=strtoupper($k)." (".count($v).")";
872 * [Describe function...]
874 * @param [type] $type: ...
877 function ext_getTypeData($type) {
881 $retArr["type"]="string";
883 $m=strcspn ($type," [");
884 $retArr["type"]=strtolower(substr($type,0,$m));
885 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
886 $p=trim(substr($type,$m));
887 ereg("\[(.*)\]",$p,$reg);
890 $retArr["paramstr"]=$p;
891 switch($retArr["type"]) {
893 if (substr($retArr["paramstr"],0,1)=="-") {
894 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
895 $retArr["params"][0]=intval("-".$retArr["params"][0]);
897 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
899 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
902 $retArr["params"]=explode(",",$retArr["paramstr"]);
913 * [Describe function...]
915 * @param [type] $category: ...
918 function ext_getTSCE_config($category) {
919 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
921 if (is_array($catConf)) {
923 while(list($key,$val)=each($catConf)) {
926 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
934 if (t3lib_div
::testInt($key)) {
935 $constRefs = explode(",",$val);
937 while(list(,$const)=each($constRefs)) {
939 if ($const && $const<=20) {
940 $out["constants"][$const].=$this->ext_getKeyImage($key);
948 $this->helpConfig
=$out;
952 * [Describe function...]
954 * @param [type] $key: ...
957 function ext_getKeyImage($key) {
958 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
962 * [Describe function...]
964 * @param [type] $imgConf: ...
967 function ext_getTSCE_config_image($imgConf) {
968 if (substr($imgConf,0,4)=="gfx/") {
969 $iFile=$this->ext_localGfxPrefix
.$imgConf;
970 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
971 } elseif (substr($imgConf,0,4)=='EXT:') {
972 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
974 $f = substr($iFile,strlen(PATH_site
));
975 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
978 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
980 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
982 $imageInfo=@getImagesize
($iFile);
983 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
987 * [Describe function...]
991 function ext_resourceDims() {
992 if ($this->setup
["resources"]) {
993 $rArr=explode(",",$this->setup
["resources"]);
994 while(list($c,$val)=each($rArr)) {
996 $theFile = PATH_site
."uploads/tf/".$val;
997 if ($val && @is_file
($theFile)) {
998 $imgInfo = @getimagesize
($theFile);
1000 if (is_array($imgInfo)) {
1001 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1005 reset($this->dirResources
);
1006 while(list($c,$val)=each($this->dirResources
)) {
1008 $imgInfo = @getimagesize
(PATH_site
.$val);
1009 if (is_array($imgInfo)) {
1010 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1016 * [Describe function...]
1018 * @param [type] $path: ...
1019 * @return [type] ...
1021 function ext_readDirResources($path) {
1023 if ($path && substr($path,0,10)=="fileadmin/") {
1024 $path = ereg_replace("\/$","",$path);
1025 $this->readDirectory(PATH_site
.$path);
1030 * [Describe function...]
1032 * @param [type] $path: ...
1033 * @param [type] $type: ...
1034 * @return [type] ...
1036 function readDirectory($path,$type="file") {
1037 if(@is_dir
($path)) {
1040 if (is_object($d)) {
1041 while($entry=$d->read()) {
1042 if ($entry!="." && $entry!="..") {
1043 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1044 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1045 $fI = t3lib_div
::split_fileref($wholePath);
1046 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1056 * [Describe function...]
1058 * @param [type] $params: ...
1059 * @return [type] ...
1061 function ext_fNandV($params) {
1062 $fN='data['.$params["name"].']';
1063 $fV=$params["value"];
1064 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1067 $fV=htmlspecialchars($fV);
1069 return array($fN,$fV,$params);
1073 * [Describe function...]
1075 * @param [type] $theConstants: ...
1076 * @param [type] $category: ...
1077 * @return [type] ...
1079 function ext_printFields($theConstants,$category) {
1080 // This functions returns the HTML-code that creates the editor-layout of the module.
1081 reset($theConstants);
1084 if (is_array($this->categories
[$category])) {
1086 $help=$this->helpConfig
;
1087 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1089 asort($this->categories
[$category]);
1090 while(list($name,$type)=each($this->categories
[$category])) {
1091 $params = $theConstants[$name];
1092 if (is_array($params)) {
1093 if ($subcat!=$params["subcat_name"]) {
1094 $subcat=$params["subcat_name"];
1095 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1097 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1101 // if (substr($params["value"],0,2)!='{$') {
1102 $label=$GLOBALS["LANG"]->sL($params["label"]);
1103 $label_parts = explode(":",$label,2);
1104 if (count($label_parts)==2) {
1105 $head=trim($label_parts[0]);
1106 $body=trim($label_parts[1]);
1108 $head=trim($label_parts[0]);
1111 if (strlen($head)>35) {
1112 if (!$body) {$body=$head;}
1113 $head=t3lib_div
::fixed_lgd_cs($head,35);
1115 $typeDat=$this->ext_getTypeData($params["type"]);
1118 $raname = substr(md5($params["name"]),0,10);
1119 $aname="'".$raname."'";
1120 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1121 $checked=" checked";
1122 list($fN,$fV,$params)=$this->ext_fNandV($params);
1124 switch($typeDat["type"]) {
1127 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1128 if ($typeDat["paramstr"]) {
1129 $p_field.=' Range: '.$typeDat["paramstr"];
1130 } elseif ($typeDat["type"]=="int+") {
1131 $p_field.=' Range: 0 - ';
1133 $p_field.=' (Integer)';
1137 $colorNames=explode(",",",".$this->HTMLcolorList
);
1139 while(list(,$val)=each($colorNames)) {
1141 if ($val==strtolower($params["value"])) {$sel=" selected";}
1142 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1144 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1146 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1149 $wArr = explode("|",$fV);
1150 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1152 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1155 $wArr = explode(",",$fV);
1156 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1157 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1159 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1160 for ($aa=2;$aa<count($labels);$aa++
) {
1162 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1164 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1169 if (is_array($typeDat["params"])) {
1171 while(list(,$val)=each($typeDat["params"])) {
1172 $vParts = explode("=",$val,2);
1173 $label = $vParts[0];
1174 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1178 if ($val==$params["value"]) {$sel=" selected";}
1179 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1181 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1185 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1186 $sel=""; if ($fV) {$sel=" checked";}
1187 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1190 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1191 $sel=""; if (!$fV) {$sel=" checked";}
1192 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1195 $p_field='<option value=""></option>';
1196 // debug($params["value"]);
1199 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1200 if ($params["value"] && !$selectThisFile) {
1201 if (in_array($params["value"],$this->dirResources
)) {
1202 $selectThisFile=$params["value"];
1205 // debug($selectThisFile);
1207 $extList = $typeDat["paramstr"];
1208 $p_field='<option value="">('.$extList.')</option>';
1209 if ($extList=="IMAGE_EXT") {
1210 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1213 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1215 while(list($c,$val)=each($this->rArr
)) {
1217 $fI=t3lib_div
::split_fileref($val);
1219 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1220 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1221 if ($onlineResourceFlag<0) {
1222 $p_field.='<option value=""></option>';
1224 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1225 $onlineResourceFlag=1;
1227 $dims=$this->resourceDimensions
[$val];
1230 // Check if $params["value"] is in the list of resources.
1231 if ($selectThisFile && $selectThisFile==$val) {
1233 if ($onlineResourceFlag<=0) {
1234 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1236 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1240 if ($onlineResourceFlag<=0) {
1241 $onlineResourceFlag--;
1242 // Value is set with a *
1243 $val = $this->ext_setStar($val);
1244 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1246 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1250 if (trim($params["value"]) && !$selectThisFile) {
1251 $val = $params["value"];
1252 $p_field.='<option value=""></option>';
1253 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1256 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1257 $p_field.=$theImage;
1259 if (!$this->ext_noCEUploadAndCopying
) {
1261 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1263 if ($params["value"]) {
1264 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1267 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1271 if ($copyFile && @is_file
($copyFile)) {
1272 $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"])).'\'));}">';
1276 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1281 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1282 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1286 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1287 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1288 $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>';
1290 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1293 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1294 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1295 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1296 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1299 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1300 $output.='<td valign=top align="right">'.$p_name.'</td>';
1303 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1307 debug("Error. Constant did not exits. Should not happen.");
1310 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1326 /***************************
1328 * Processing input values
1330 ***************************/
1333 * @param [type] $constants: ...
1334 * @return [type] ...
1336 function ext_regObjectPositions($constants) {
1337 // 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
1338 $this->raw
= explode(chr(10),$constants);
1341 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1342 $this->ext_regObjects("");
1346 * [Describe function...]
1348 * @param [type] $pre: ...
1349 * @return [type] ...
1351 function ext_regObjects($pre) {
1352 // works with regObjectPositions. "expands" the names of the TypoScript objects
1353 while (isset($this->raw
[$this->rawP
])) {
1354 $line = ltrim($this->raw
[$this->rawP
]);
1355 if (strstr($line,$this->edit_divider
)) {
1356 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1360 if (substr($line,0,1)=="[") {
1362 } elseif (strcspn($line,"}#/")!=0) {
1363 $varL = strcspn($line," {=<");
1364 $var=substr($line,0,$varL);
1365 $line = ltrim(substr($line,$varL));
1366 switch(substr($line,0,1)) {
1368 $this->objReg
[$pre.$var]=$this->rawP
-1;
1371 $this->ext_inBrace++
;
1372 $this->ext_regObjects($pre.$var.".");
1375 $this->lastComment
="";
1376 } elseif (substr($line,0,1)=="}") {
1377 $this->lastComment
="";
1378 $this->ext_inBrace
--;
1379 if ($this->ext_inBrace
<0) {
1380 $this->ext_inBrace
=0;
1390 * [Describe function...]
1392 * @param [type] $key: ...
1393 * @param [type] $var: ...
1394 * @return [type] ...
1396 function ext_putValueInConf($key, $var) {
1397 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1398 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1399 $theValue = " ".trim($var);
1400 if (isset($this->objReg
[$key])) {
1401 $lineNum = $this->objReg
[$key];
1402 $parts = explode("=",$this->raw
[$lineNum],2);
1403 if (count($parts)==2) {
1404 $parts[1]= $theValue;
1406 $this->raw
[$lineNum]=implode($parts,"=");
1408 $this->raw
[]=$key." =".$theValue;
1414 * [Describe function...]
1416 * @param [type] $key: ...
1417 * @return [type] ...
1419 function ext_removeValueInConf($key) {
1420 // Removes the value in the configuration
1421 if (isset($this->objReg
[$key])) {
1422 $lineNum = $this->objReg
[$key];
1423 unset($this->raw
[$lineNum]);
1429 * [Describe function...]
1431 * @param [type] $arr: ...
1432 * @param [type] $settings: ...
1433 * @return [type] ...
1435 function ext_depthKeys($arr,$settings) {
1438 while(list($theK,$theV)=each($arr)) {
1439 $theKeyParts = explode(".",$theK);
1441 $c=count($theKeyParts);
1443 while(list(,$p)=each($theKeyParts)) {
1445 $depth.=($depth?
".":"").$p;
1446 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1451 while(list($theK,$theV)=each($tsbrArray)) {
1453 $settings[$theK] = 1;
1455 unset($settings[$theK]);
1462 * [Describe function...]
1464 * @param [type] $http_post_vars: ...
1465 * @param [type] $http_post_files: ...
1466 * @param [type] $theConstants: ...
1467 * @param [type] $tplRow: ...
1468 * @return [type] ...
1470 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1471 $data=$http_post_vars["data"];
1472 $check=$http_post_vars["check"];
1473 $copyResource=$http_post_vars["_copyResource"];
1474 $Wdata=$http_post_vars["Wdata"];
1475 $W2data=$http_post_vars["W2data"];
1476 $W3data=$http_post_vars["W3data"];
1477 $W4data=$http_post_vars["W4data"];
1478 $W5data=$http_post_vars["W5data"];
1480 if (is_array($data)) {
1482 while(list($key,$var)=each($data)) {
1483 if (isset($theConstants[$key])) {
1484 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1485 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1486 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1487 switch($typeDat["type"]) {
1489 if ($typeDat["paramstr"]) {
1490 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1496 $var=t3lib_div
::intInRange($var,0,10000);
1500 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1501 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1502 $col[]=HexDec(substr($var,0,2));
1503 $col[]=HexDec(substr($var,2,2));
1504 $col[]=HexDec(substr($var,4,2));
1505 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1516 if (isset($Wdata[$key])) {
1517 $var.="|".$Wdata[$key];
1521 if (isset($Wdata[$key])) {
1522 $var=intval($var).",".intval($Wdata[$key]);
1523 if (isset($W2data[$key])) {
1524 $var.=",".intval($W2data[$key]);
1525 if (isset($W3data[$key])) {
1526 $var.=",".intval($W3data[$key]);
1527 if (isset($W4data[$key])) {
1528 $var.=",".intval($W4data[$key]);
1529 if (isset($W5data[$key])) {
1530 $var.=",".intval($W5data[$key]);
1539 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1543 if (!$this->ext_noCEUploadAndCopying
) {
1544 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1545 $var = $this->upload_copy_file(
1548 trim($http_post_files["upload_data"]["name"][$key]),
1549 $http_post_files["upload_data"]["tmp_name"][$key]
1552 if ($copyResource[$key]) {
1553 $var = $this->upload_copy_file(
1556 basename($copyResource[$key]),
1563 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1564 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1566 unset($check[$key]); // Remove the entry because it has been "used"
1568 $this->ext_removeValueInConf($key);
1573 // 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...
1574 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1576 while(list($key,$var)=each($check)) {
1577 if (isset($theConstants[$key])) {
1578 $dValue = $theConstants[$key]["default_value"];
1580 $this->ext_putValueInConf($key, $dValue);
1585 // debug($this->objReg);
1589 * [Describe function...]
1591 * @param [type] $typeDat: ...
1592 * @param [type] $tplRow: ...
1593 * @param [type] $theRealFileName: ...
1594 * @param [type] $tmp_name: ...
1595 * @return [type] ...
1597 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1600 $extList = $typeDat["paramstr"];
1601 if ($extList=="IMAGE_EXT") {
1602 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1604 $fI=t3lib_div
::split_fileref($theRealFileName);
1605 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1606 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1609 $alternativeFileName=array();
1610 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1611 // Making list of resources
1612 $resList = $tplRow["resources"];
1613 $resList = $tmp_upload_name.",".$resList;
1614 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1615 // Making data-array
1617 $recData["sys_template"][$tplRow["uid"]]["resources"] = $resList;
1619 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1620 $tce->stripslashes_values
=0;
1621 $tce->alternativeFileName
= $alternativeFileName;
1622 $tce->start($recData,Array());
1623 $tce->process_datamap();
1625 t3lib_div
::unlink_tempfile($tmp_upload_name);
1627 $tmpRow = t3lib_BEfunc
::getRecord("sys_template",$tplRow["uid"],"resources");
1628 $tplRow["resources"] = $tmpRow["resources"];
1630 // Setting the value
1631 $var = $this->ext_setStar($theRealFileName);
1637 * [Describe function...]
1639 * @param [type] $id: ...
1640 * @param [type] $perms_clause: ...
1641 * @return [type] ...
1643 function ext_prevPageWithTemplate($id,$perms_clause) {
1644 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1646 while(list(,$p)=each($rootLine)) {
1647 if ($this->ext_getFirstTemplate($p["uid"])) {
1654 * [Describe function...]
1656 * @param [type] $val: ...
1657 * @return [type] ...
1659 function ext_setStar($val) {
1660 $fParts = explode(".",strrev($val),2);
1661 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1666 * [Describe function...]
1668 * @param [type] $value: ...
1669 * @return [type] ...
1671 function ext_detectAndFixExtensionPrefix($value) {
1672 if (substr($value,0,4)=="EXT:") {
1673 $parts = explode("/",substr($value,4),2);
1675 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1676 $value = $extPath.$parts[1];
1685 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1686 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);