2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * TSParser extension class to t3lib_TStemplate
31 * Contains functions for the TS module in TYPO3 backend
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 104: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 193: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 220: function substituteConstants($all)
43 * 249: function substituteCMarkers($all)
44 * 271: function generateConfig_constants()
45 * 320: function ext_getSetup($theSetup,$theKey)
46 * 351: function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")
47 * 446: function lineNumberToScript($lnArr)
48 * 477: function makeHtmlspecialchars($theValue)
49 * 490: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
50 * 530: function ext_getRootlineNumber($pid)
51 * 548: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
52 * 607: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
53 * 638: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
54 * 665: function ext_fixed_lgd($string,$chars)
55 * 681: function ext_lnBreakPointWrap($ln,$str)
56 * 694: function ext_formatTS($input, $ln, $comments=1, $crop=0)
57 * 733: function ext_getFirstTemplate($id,$template_uid=0)
58 * 752: function ext_getAllTemplates($id)
59 * 772: function ext_compareFlatSetups($default)
60 * 838: function ext_categorizeEditableConstants($editConstArray)
61 * 861: function ext_getCategoryLabelArray()
62 * 878: function ext_getTypeData($type)
63 * 919: function ext_getTSCE_config($category)
64 * 958: function ext_getKeyImage($key)
65 * 968: function ext_getTSCE_config_image($imgConf)
66 * 992: function ext_resourceDims()
67 * 1022: function ext_readDirResources($path)
68 * 1037: function readDirectory($path,$type="file")
69 * 1062: function ext_fNandV($params)
70 * 1080: function ext_printFields($theConstants,$category)
72 * SECTION: Processing input values
73 * 1337: function ext_regObjectPositions($constants)
74 * 1352: function ext_regObjects($pre)
75 * 1397: function ext_putValueInConf($key, $var)
76 * 1420: function ext_removeValueInConf($key)
77 * 1436: function ext_depthKeys($arr,$settings)
78 * 1471: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
79 * 1598: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
80 * 1644: function ext_prevPageWithTemplate($id,$perms_clause)
81 * 1660: function ext_setStar($val)
82 * 1672: function ext_detectAndFixExtensionPrefix($value)
85 * (This index is automatically created/updated by the extension "extdeveval")
89 require_once(PATH_t3lib
."class.t3lib_tstemplate.php");
98 * TSParser extension class to t3lib_TStemplate
100 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
104 class t3lib_tsparser_ext
extends t3lib_TStemplate
{
106 var $edit_divider = "###MOD_TS:EDITABLE_CONSTANTS###"; // This string is used to indicate the point in a template from where the editable constants are listed. Any vars before this point (if it exists though) is regarded as default values.
107 var $HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
110 var $categories = array(
111 "basic" => array(), // Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure.
112 "menu" => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
113 "content" => array(), // All constants related to the display of pagecontent elements
114 "page" => array(), // General configuration like metatags, link targets
115 "advanced" => array(), // Advanced functions, which are used very seldomly.
116 "all" => array() // All constants are put here also!
117 ); // This will be filled with the available categories of the current template.
118 var $subCategories = array(
119 // Standard categories:
120 "enable" => Array("Enable features", "a"),
121 "dims" => Array("Dimensions, widths, heights, pixels", "b"),
122 "file" => Array("Files", "c"),
123 "typo" => Array("Typography", "d"),
124 "color" => Array("Colors", "e"),
125 "links" => Array("Links and targets", "f"),
126 "language" => Array("Language specific constants", "g"),
128 // subcategories based on the default content elements
129 "cheader" => Array("Content: 'Header'", "ma"),
130 "cheader_g" => Array("Content: 'Header', Graphical", "ma"),
131 "ctext" => Array("Content: 'Text'", "mb"),
133 "cimage" => Array("Content: 'Image'", "md"),
134 "cbullets" => Array("Content: 'Bullet list'", "me"),
135 "ctable" => Array("Content: 'Table'", "mf"),
136 "cuploads" => Array("Content: 'Filelinks'", "mg"),
137 "cmultimedia" => Array("Content: 'Multimedia'", "mh"),
138 "cmailform" => Array("Content: 'Form'", "mi"),
139 "csearch" => Array("Content: 'Search'", "mj"),
140 "clogin" => Array("Content: 'Login'", "mk"),
141 "csplash" => Array("Content: 'Textbox'", "ml"),
142 "cmenu" => Array("Content: 'Menu/Sitemap'", "mm"),
143 "cshortcut" => Array("Content: 'Insert records'", "mn"),
144 "clist" => Array("Content: 'List of records'", "mo"),
145 "cscript" => Array("Content: 'Script'", "mp"),
146 "chtml" => Array("Content: 'HTML'", "mq")
148 var $resourceDimensions = array();
149 var $dirResources = array();
151 // var $matchAll = 0; // If set, all conditions are matched!
159 var $tsbrowser_searchKeys = array();
160 var $tsbrowser_depthKeys = array();
161 var $constantMode="";
164 var $resourceCheck=0;
165 var $ext_lineNumberOffset=0;
166 var $ext_localGfxPrefix="";
167 var $ext_localWebGfxPrefix="";
168 var $ext_expandAllNotes=0;
169 var $ext_noPMicons=0;
170 var $ext_noSpecialCharsOnLabels=0;
171 var $ext_listOfTemplatesArr=array();
172 var $ext_lineNumberOffset_mode="";
173 var $ext_dontCheckIssetValues=0; // Dont change...
174 var $ext_noCEUploadAndCopying=0;
176 var $ext_CEformName="forms[0]";
177 var $ext_defaultOnlineResourceFlag=0;
178 var $doNotSortCategoriesBeforeMakingForm = FALSE;
181 var $templateTitles=array();
185 * This flattens a hierarchical setuparray to $this->flatSetup
186 * The original function fetched the resource-file if any ("file."). This functions doesn't.
188 * @param [type] $setupArray: ...
189 * @param [type] $prefix: ...
190 * @param [type] $resourceFlag: ...
193 function flattenSetup($setupArray, $prefix, $resourceFlag) {
194 if (is_array($setupArray)) {
195 $this->getFileName_backPath
=PATH_site
; // Setting absolute prefixed path for relative resources.
197 while(list($key,$val)=each($setupArray)) {
198 if ($prefix ||
substr($key,0,16)!="TSConstantEditor") { // We don't want "TSConstantEditor" in the flattend setup.
199 if (is_array($val)) {
200 $this->flattenSetup($val,$prefix.$key, ($key=="file."));
201 } elseif ($resourceFlag && $this->resourceCheck
) {
202 $this->flatSetup
[$prefix.$key] = $this->getFileName($val);
203 if ($this->removeFromGetFilePath
&& substr($this->flatSetup
[$prefix.$key],0,strlen($this->removeFromGetFilePath
))==$this->removeFromGetFilePath
) {
204 $this->flatSetup
[$prefix.$key] = substr($this->flatSetup
[$prefix.$key],strlen($this->removeFromGetFilePath
));
207 $this->flatSetup
[$prefix.$key] = $val;
215 * [Describe function...]
217 * @param [type] $all: ...
220 function substituteConstants($all) {
221 $this->Cmarker
=substr(md5(uniqid("")),0,6);
222 reset($this->flatSetup
);
223 while (list($const,$val)=each($this->flatSetup
)) {
224 if (!is_array($val)) {
225 switch($this->constantMode
) {
227 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##{$'.$const.'}##'.$this->Cmarker
.'_E##',$all);
230 $all = str_replace('{$'.$const.'}','##'.$this->Cmarker
.'_B##'.$val.'##'.$this->Cmarker
.'_E##',$all);
235 $all = str_replace('{$'.$const.'}',$val,$all);
244 * [Describe function...]
246 * @param [type] $all: ...
249 function substituteCMarkers($all) {
250 switch($this->constantMode
) {
252 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
253 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
256 $all = str_replace('##'.$this->Cmarker
.'_B##', '<font color="green"><B>', $all);
257 $all = str_replace('##'.$this->Cmarker
.'_E##', '</b></font>', $all);
267 * [Describe function...]
271 function generateConfig_constants() {
272 // Parses the constants in $this->const with respect to the constant-editor in this module.
273 // In particular comments in the code are registered and the edit_divider is taken into account.
274 // These vars are also set lateron...
275 $this->setup
["resources"]= $this->resources
;
276 $this->setup
["sitetitle"]= $this->sitetitle
;
279 $constants = t3lib_div
::makeInstance("t3lib_TSparser");
280 $constants->regComments
=1; // Register comments!
281 $constants->setup
= $this->const;
282 $constants->setup
= $this->mergeConstantsFromPageTSconfig($constants->setup
);
284 $matchObj = t3lib_div
::makeInstance("t3lib_matchCondition");
285 // $matchObj->matchAlternative = array("[globalString = page | title = *test*]");
286 $matchObj->matchAll
=1; // Matches ALL conditions in TypoScript
289 $cc=count($this->constants
);
290 reset($this->constants
);
291 while (list(,$str)=each($this->constants
)) {
294 if (strstr($str,$this->edit_divider
)) {
295 $parts = explode($this->edit_divider
,$str,2);
297 $constants->parse($parts[0],$matchObj);
299 $this->flatSetup
= Array();
300 $this->flattenSetup($constants->setup
,"","");
301 $defaultConstants=$this->flatSetup
;
303 $constants->parse($str,$matchObj);
306 $this->flatSetup
= Array();
307 $this->flattenSetup($constants->setup
,"","");
308 $this->setup
["constants"] = $constants->setup
;
310 return $this->ext_compareFlatSetups($defaultConstants);
314 * [Describe function...]
316 * @param [type] $theSetup: ...
317 * @param [type] $theKey: ...
320 function ext_getSetup($theSetup,$theKey) {
321 $parts = explode(".",$theKey,2);
322 // debug("-----------",1);
324 if (strcmp($parts[0],"") && is_array($theSetup[$parts[0]."."])) {
325 // debug(trim($parts[1]),1);
326 if (strcmp(trim($parts[1]),"")) {
327 // debug(trim($parts[1]),1);
328 return $this->ext_getSetup($theSetup[$parts[0]."."],trim($parts[1]));
330 return array($theSetup[$parts[0]."."], $theSetup[$parts[0]]);
333 if (strcmp(trim($theKey),"")) {
334 return array(array(),$theSetup[$theKey]);
336 return array($theSetup,"");
342 * [Describe function...]
344 * @param [type] $arr: ...
345 * @param [type] $depth_in: ...
346 * @param [type] $depthData: ...
347 * @param [type] $parentType: ...
348 * @param [type] $parentValue: ...
351 function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="") {
357 $keyArr_alpha=array();
358 while (list($key,)=each($arr)) {
359 if (substr($key,-2)!="..") { // Don't do anything with comments / linenumber registrations...
360 $key=ereg_replace("\.$","",$key);
361 if (substr($key,-1)!=".") {
362 if (t3lib_div
::testInt($key)) {
363 $keyArr_num[$key]=$arr[$key];
365 $keyArr_alpha[$key]=$arr[$key];
371 $keyArr=$keyArr_num+
$keyArr_alpha;
374 if ($depth_in) {$depth_in = $depth_in.".";}
376 // $validate_info= verify_TSobjects($keyArr,$parentType,$parentValue);
377 // debug($validate_info);
379 while (list($key,)=each($keyArr)) {
381 $depth=$depth_in.$key;
382 if ($this->bType
!="const" ||
substr($depth,0,1)!="_") { // this excludes all constants starting with "_" from being shown.
383 $goto = substr(md5($depth),0,6);
385 $deeper = (is_array($arr[$key."."]) && ($this->tsbrowser_depthKeys
[$depth] ||
$this->ext_expandAllNotes
)) ?
1 : 0;
387 $LN = ($a==$c)?
"blank":"line";
388 $BTM = ($a==$c)?
"bottom":"";
389 $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ?
($deeper ?
"minus":"plus") : "join";
392 $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
396 $aHref='index.php?id='.$GLOBALS["SOBE"]->id
.'&tsbr['.$depth.']='.($deeper?
0:1).'#'.$goto;
397 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
401 if (t3lib_div
::inList("types,resources,sitetitle",$depth) && $this->bType
=="setup") { // Read only...
402 $label='<font color="#666666">'.$label.'</font>';
404 if ($this->linkObjects
) {
405 $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id
.'&sObj='.$depth;
406 if ($this->bType
!="const") {
407 $ln = is_array($arr[$key.'.ln..']) ?
'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
411 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
415 $HTML.="[".$label."]";
417 if (isset($arr[$key])) {
418 $theValue = $arr[$key];
419 if ($this->fixedLgd
) {
420 $imgBlocks = ceil(1+
strlen($depthData)/77);
421 $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
422 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
424 if ($this->tsbrowser_searchKeys
[$depth]) {
425 $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
427 $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
433 $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]);
441 * [Describe function...]
443 * @param [type] $lnArr: ...
446 function lineNumberToScript($lnArr) {
447 if (!is_array($this->lnToScript
)) {
448 $this->lnToScript
= array();
450 $c+
=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],chr(10))+
2;
451 $this->lnToScript
[$c] = '[Default]';
453 foreach($this->hierarchyInfoToRoot
as $info) {
454 $c+
=$info['configLines']+
1;
455 $this->lnToScript
[$c] = $info['title'];
459 foreach($lnArr as $k => $ln) {
460 foreach($this->lnToScript
as $endLn => $title) {
461 if ($endLn >= intval($ln)) {
462 $lnArr[$k] = '"'.$title.'", '.$ln;
468 return implode('; ',$lnArr);
472 * [Describe function...]
474 * @param [type] $theValue: ...
477 function makeHtmlspecialchars($theValue){
478 return $this->ext_noSpecialCharsOnLabels ?
$theValue : htmlspecialchars($theValue);
482 * [Describe function...]
484 * @param [type] $arr: ...
485 * @param [type] $depth_in: ...
486 * @param [type] $searchString: ...
487 * @param [type] $keyArray: ...
490 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
493 while (list($key,)=each($arr)) {
494 $key=ereg_replace("\.$","",$key);
495 if (substr($key,-1)!=".") {
502 if ($depth_in) {$depth_in = $depth_in.".";}
503 while (list($key,)=each($keyArr)) {
504 $depth=$depth_in.$key;
505 $deeper = is_array($arr[$key."."]);
507 if ($this->regexMode
) {
508 if (ereg($searchString,$arr[$key])) { $this->tsbrowser_searchKeys
[$depth]=1; }
510 if (stristr($arr[$key],$searchString)) { $this->tsbrowser_searchKeys
[$depth]=1; }
514 $cS = count($this->tsbrowser_searchKeys
);
515 $keyArray = $this->ext_getSearchKeys($arr[$key."."], $depth, $searchString, $keyArray);
516 if ($cS != count($this->tsbrowser_searchKeys
)) {
525 * [Describe function...]
527 * @param [type] $pid: ...
530 function ext_getRootlineNumber($pid) {
531 if ($pid && is_array($GLOBALS["rootLine"])) {
532 reset($GLOBALS["rootLine"]);
533 while(list($key,$val)=each($GLOBALS["rootLine"])) {
534 if ($val['uid']==$pid) return $key;
540 * [Describe function...]
542 * @param [type] $arr: ...
543 * @param [type] $depthData: ...
544 * @param [type] $keyArray: ...
545 * @param [type] $first: ...
548 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
551 while (list($key,)=each($arr)) {
552 $key=ereg_replace("\.$","",$key);
553 if (substr($key,-1)!=".") {
560 while (list($key,)=each($keyArr)) {
563 $deeper = is_array($arr[$key."."]);
567 $LN = ($a==$c)?
"blank":"line";
568 $BTM = ($a==$c)?
"top":"";
572 $icon = substr($row["templateID"],0,3)=="sys" ? t3lib_iconWorks
::getIcon("sys_template",array("root"=>$row["root"])) :
573 (substr($row["templateID"],0,6)=="static" ? t3lib_iconWorks
::getIcon("static_template",array()) : 'gfx/i/default.gif');
574 $alttext= "[".$row['templateID']."]";
575 $alttext.= $row['pid'] ?
" - ".t3lib_BEfunc
::getRecordPath($row['pid'],$GLOBALS["SOBE"]->perms_clause
,20) : "";
576 if (in_array($row['templateID'],$this->clearList_const
) ||
in_array($row['templateID'],$this->clearList_setup
)) {
577 $A_B='<a href="index.php?id='.$GLOBALS["SOBE"]->id
.'&template='.$row['templateID'].'">';
583 $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." ";
584 $RL = $this->ext_getRootlineNumber($row['pid']);
586 <td nowrap>'.$HTML.'</td>
587 <td align=center>'.($row["root"]?
"<b>X</b>":"").' </td>
588 <td align=center'.$row["bgcolor_setup"].'>'.fw(($row["clConf"]?
"<b>X</b>":"")." ").'</td>
589 <td align=center'.$row["bgcolor_const"].'>'.fw(($row["clConst"]?
"<b>X</b>":"")." ").'</td>
590 <td>'.($row["pid"]?
" ".$row["pid"].(strcmp($RL,"")?
" (".$RL.")":"")." ":"").'</td>
591 <td>'.($row["next"]?
" ".$row["next"]." ":"").'</td>
594 $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);
601 * [Describe function...]
603 * @param [type] $depthDataArr: ...
604 * @param [type] $pointer: ...
607 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
608 $parent = $this->hierarchyInfo
[$pointer-1]['templateParent'];
609 while ($pointer>0 && $this->hierarchyInfo
[$pointer-1]['templateParent']==$parent) {
611 $row = $this->hierarchyInfo
[$pointer];
613 $depthDataArr[$row['templateID']]=$row;
614 $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp
[$row['templateID']])?
' class="bgColor5"':'';
615 $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp
[$row['templateID']])?
' class="bgColor5"':'';
616 unset($this->clearList_setup_temp
[$row['templateID']]);
617 unset($this->clearList_const_temp
[$row['templateID']]);
618 $this->templateTitles
[$row['templateID']]=$row["title"];
620 if ($row['templateID']==$this->hierarchyInfo
[$pointer-1]['templateParent']) {
621 $depthDataArr[$row['templateID']."."] = $this->ext_process_hierarchyInfo(array(), $pointer);
624 return $depthDataArr;
628 * [Describe function...]
630 * @param [type] $config: ...
631 * @param [type] $lineNumbers: ...
632 * @param [type] $comments: ...
633 * @param [type] $crop: ...
634 * @param [type] $syntaxHL: ...
635 * @param [type] $syntaxHLBlockmode: ...
638 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
641 while (list(,$str)=each($config)) {
642 $all.="\n[GLOBAL]\n".$str;
646 $all = ereg_replace("^[^".chr(10)."]*.","",$all);
648 $tsparser = t3lib_div
::makeInstance("t3lib_TSparser");
649 $tsparser->lineNumberOffset
=$this->ext_lineNumberOffset+
1;
650 return $tsparser->doSyntaxHighlight($all,$lineNumbers?
array($this->ext_lineNumberOffset+
1):'',$syntaxHLBlockmode);
652 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
657 * Returns a new string of max. $chars lenght
658 * If the string is longer, it will be truncated and prepended with "..."
659 * $chars must be an integer of at least 4
661 * @param [type] $string: ...
662 * @param [type] $chars: ...
665 function ext_fixed_lgd($string,$chars) {
667 if(strlen($string)>$chars) {
668 return substr($string, 0, $chars-3)."...";
675 * [Describe function...]
677 * @param [type] $ln: ...
678 * @param [type] $str: ...
681 function ext_lnBreakPointWrap($ln,$str) {
682 return '<A href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode
=="setup"?
1:0).');">'.$str.'</a>';
686 * [Describe function...]
688 * @param [type] $input: ...
689 * @param [type] $ln: ...
690 * @param [type] $comments: ...
691 * @param [type] $crop: ...
694 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
695 $input = ereg_replace("^[^".chr(10)."]*.","",$input);
696 $input = chop($input);
697 $cArr = explode(chr(10),$input);
700 $n = ceil(log10(count($cArr)+
$this->ext_lineNumberOffset
));
702 while(list($k,$v)=each($cArr)) {
703 $lln=$k+
$this->ext_lineNumberOffset+
1;
704 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(" ",' ',sprintf("% ".$n."d",$lln))).": ";
705 $v=htmlspecialchars($v);
706 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?
71:77));}
707 $cArr[$k] = $lineNum.str_replace(" ",' ',$v);
709 $firstChar = substr(trim($v),0,1);
710 if ($firstChar=="[") {
711 $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
712 } elseif ($firstChar=="/" ||
$firstChar=="#") {
714 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
722 $output = implode($cArr, "<BR>")."<BR>";
727 * [Describe function...]
729 * @param [type] $id: ...
730 * @param [type] $template_uid: ...
733 function ext_getFirstTemplate($id,$template_uid=0) {
734 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
737 $addC = " AND uid=".$template_uid;
739 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause
, '', 'sorting', '1');
740 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
741 $GLOBALS['TYPO3_DB']->sql_free_result($res);
742 return $row; // Returns the template row if found.
747 * [Describe function...]
749 * @param [type] $id: ...
752 function ext_getAllTemplates($id) {
753 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
756 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause
, '', 'sorting');
757 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
760 $GLOBALS['TYPO3_DB']->sql_free_result($res);
761 return $outRes; // Returns the template rows in an array.
766 * This function compares the flattened constants (default and all).
767 * Returns an array with the constants from the whole template which may be edited by the module.
769 * @param [type] $default: ...
772 function ext_compareFlatSetups($default) {
773 $editableComments=array();
774 reset($this->flatSetup
);
775 while(list($const,$value)=each($this->flatSetup
)) {
776 if (substr($const,-2)!=".." && isset($this->flatSetup
[$const.".."])) {
777 $comment = trim($this->flatSetup
[$const.".."]);
778 $c_arr = explode(chr(10),$comment);
779 while(list($k,$v)=each($c_arr)) {
780 $line=trim(ereg_replace("^[#\/]*","",$v));
782 $parts = explode(";", $line);
783 while(list(,$par)=each($parts)) {
784 if (strstr($par,"=")) {
785 $keyValPair =explode("=",$par,2);
786 switch(trim(strtolower($keyValPair[0]))) {
790 int (range; low-high, list: item,item,item = selector),
797 $editableComments[$const]["type"] = trim($keyValPair[1]);
800 // list of categories.
801 $catSplit=explode("/",strtolower($keyValPair[1]));
802 $editableComments[$const]["cat"] = trim($catSplit[0]);
803 $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.
804 if ($catSplit[1] && isset($this->subCategories
[$catSplit[1]])) {
805 $editableComments[$const]["subcat_name"]=$catSplit[1];
806 $editableComments[$const]["subcat"]=$this->subCategories
[$catSplit[1]][1]."/".$catSplit[1]."/".trim($catSplit[2])."z";
808 $editableComments[$const]["subcat"]="x"."/".trim($catSplit[2])."z";
813 $editableComments[$const]["label"] = trim($keyValPair[1]);
821 if (isset($editableComments[$const])) {
822 $editableComments[$const]["name"]=$const;
823 $editableComments[$const]["value"]=trim($value);
824 if (isset($default[$const])) {
825 $editableComments[$const]["default_value"]=trim($default[$const]);
829 return $editableComments;
833 * [Describe function...]
835 * @param [type] $editConstArray: ...
838 function ext_categorizeEditableConstants($editConstArray) {
839 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
840 reset($editConstArray);
841 while(list($constName,$constData)=each($editConstArray)) {
842 if (!$constData["type"]) {$constData["type"]="string";}
843 $cats = explode(",",$constData["cat"]);
845 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...
846 $theCat=trim($theCat);
848 $this->categories
[$theCat][$constName]=$constData["subcat"];
849 // $this->categories["all"][$constName]=$constData["subcat"];
853 // debug($this->categories);
857 * [Describe function...]
861 function ext_getCategoryLabelArray() {
862 // Returns array used for labels in the menu.
864 while(list($k,$v)=each($this->categories
)) {
866 $retArr[$k]=strtoupper($k)." (".count($v).")";
873 * [Describe function...]
875 * @param [type] $type: ...
878 function ext_getTypeData($type) {
882 $retArr["type"]="string";
884 $m=strcspn ($type," [");
885 $retArr["type"]=strtolower(substr($type,0,$m));
886 if (t3lib_div
::inList("int,options,file,boolean,offset",$retArr["type"])) {
887 $p=trim(substr($type,$m));
888 ereg("\[(.*)\]",$p,$reg);
891 $retArr["paramstr"]=$p;
892 switch($retArr["type"]) {
894 if (substr($retArr["paramstr"],0,1)=="-") {
895 $retArr["params"]=t3lib_div
::intExplode("-",substr($retArr["paramstr"],1));
896 $retArr["params"][0]=intval("-".$retArr["params"][0]);
898 $retArr["params"]=t3lib_div
::intExplode("-",$retArr["paramstr"]);
900 $retArr["paramstr"]=$retArr["params"][0]." - ".$retArr["params"][1];
903 $retArr["params"]=explode(",",$retArr["paramstr"]);
914 * [Describe function...]
916 * @param [type] $category: ...
919 function ext_getTSCE_config($category) {
920 $catConf=$this->setup
["constants"]["TSConstantEditor."][$category."."];
922 if (is_array($catConf)) {
924 while(list($key,$val)=each($catConf)) {
927 $out["imagetag"] = $this->ext_getTSCE_config_image($catConf["image"]);
935 if (t3lib_div
::testInt($key)) {
936 $constRefs = explode(",",$val);
938 while(list(,$const)=each($constRefs)) {
940 if ($const && $const<=20) {
941 $out["constants"][$const].=$this->ext_getKeyImage($key);
949 $this->helpConfig
=$out;
953 * [Describe function...]
955 * @param [type] $key: ...
958 function ext_getKeyImage($key) {
959 return '<img src="'.$this->ext_localWebGfxPrefix
.'gfx/'.$key.'.gif" align="top" hspace=2>';
963 * [Describe function...]
965 * @param [type] $imgConf: ...
968 function ext_getTSCE_config_image($imgConf) {
969 if (substr($imgConf,0,4)=="gfx/") {
970 $iFile=$this->ext_localGfxPrefix
.$imgConf;
971 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
972 } elseif (substr($imgConf,0,4)=='EXT:') {
973 $iFile = t3lib_div
::getFileAbsFileName($imgConf);
975 $f = substr($iFile,strlen(PATH_site
));
976 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
979 $f = "uploads/tf/".$this->extractFromResources($this->setup
["resources"],$imgConf);
981 $tFile=$GLOBALS["BACK_PATH"]."../".$f;
983 $imageInfo=@getImagesize
($iFile);
984 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
988 * [Describe function...]
992 function ext_resourceDims() {
993 if ($this->setup
["resources"]) {
994 $rArr=explode(",",$this->setup
["resources"]);
995 while(list($c,$val)=each($rArr)) {
997 $theFile = PATH_site
."uploads/tf/".$val;
998 if ($val && @is_file
($theFile)) {
999 $imgInfo = @getimagesize
($theFile);
1001 if (is_array($imgInfo)) {
1002 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1006 reset($this->dirResources
);
1007 while(list($c,$val)=each($this->dirResources
)) {
1009 $imgInfo = @getimagesize
(PATH_site
.$val);
1010 if (is_array($imgInfo)) {
1011 $this->resourceDimensions
[$val]=" (".$imgInfo[0]."x".$imgInfo[1].")";
1017 * [Describe function...]
1019 * @param [type] $path: ...
1020 * @return [type] ...
1022 function ext_readDirResources($path) {
1024 if ($path && substr($path,0,10)=="fileadmin/") {
1025 $path = ereg_replace("\/$","",$path);
1026 $this->readDirectory(PATH_site
.$path);
1031 * [Describe function...]
1033 * @param [type] $path: ...
1034 * @param [type] $type: ...
1035 * @return [type] ...
1037 function readDirectory($path,$type="file") {
1038 if(@is_dir
($path)) {
1041 if (is_object($d)) {
1042 while($entry=$d->read()) {
1043 if ($entry!="." && $entry!="..") {
1044 $wholePath = $path."/".$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1045 if (@file_exists
($wholePath) && (!$type ||
filetype($wholePath)==$type)) {
1046 $fI = t3lib_div
::split_fileref($wholePath);
1047 $this->dirResources
[]=substr($wholePath,strlen(PATH_site
));
1057 * [Describe function...]
1059 * @param [type] $params: ...
1060 * @return [type] ...
1062 function ext_fNandV($params) {
1063 $fN='data['.$params["name"].']';
1064 $fV=$params["value"];
1065 if (ereg("^{[\$][a-zA-Z0-9\.]*}$",trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1068 $fV=htmlspecialchars($fV);
1070 return array($fN,$fV,$params);
1074 * [Describe function...]
1076 * @param [type] $theConstants: ...
1077 * @param [type] $category: ...
1078 * @return [type] ...
1080 function ext_printFields($theConstants,$category) {
1081 // This functions returns the HTML-code that creates the editor-layout of the module.
1082 reset($theConstants);
1085 if (is_array($this->categories
[$category])) {
1087 $help=$this->helpConfig
;
1088 $this->rArr
=explode(",",$this->setup
["resources"].",".implode($this->dirResources
,","));
1090 if (!$this->doNotSortCategoriesBeforeMakingForm
) asort($this->categories
[$category]);
1091 while(list($name,$type)=each($this->categories
[$category])) {
1092 $params = $theConstants[$name];
1093 if (is_array($params)) {
1094 if ($subcat!=$params["subcat_name"]) {
1095 $subcat=$params["subcat_name"];
1096 $subcat_name = $params["subcat_name"] ?
$this->subCategories
[$params["subcat_name"]][0] : "Others";
1098 $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
1102 // if (substr($params["value"],0,2)!='{$') {
1103 $label=$GLOBALS["LANG"]->sL($params["label"]);
1104 $label_parts = explode(":",$label,2);
1105 if (count($label_parts)==2) {
1106 $head=trim($label_parts[0]);
1107 $body=trim($label_parts[1]);
1109 $head=trim($label_parts[0]);
1112 if (strlen($head)>35) {
1113 if (!$body) {$body=$head;}
1114 $head=t3lib_div
::fixed_lgd_cs($head,35);
1116 $typeDat=$this->ext_getTypeData($params["type"]);
1119 $raname = substr(md5($params["name"]),0,10);
1120 $aname="'".$raname."'";
1121 if ($this->ext_dontCheckIssetValues ||
isset($this->objReg
[$params["name"]])) {
1122 $checked=" checked";
1123 list($fN,$fV,$params)=$this->ext_fNandV($params);
1125 switch($typeDat["type"]) {
1128 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).' onChange="uFormUrl('.$aname.')">';
1129 if ($typeDat["paramstr"]) {
1130 $p_field.=' Range: '.$typeDat["paramstr"];
1131 } elseif ($typeDat["type"]=="int+") {
1132 $p_field.=' Range: 0 - ';
1134 $p_field.=' (Integer)';
1138 $colorNames=explode(",",",".$this->HTMLcolorList
);
1140 while(list(,$val)=each($colorNames)) {
1142 if ($val==strtolower($params["value"])) {$sel=" selected";}
1143 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1145 $p_field='<select name="C'.$fN.'" onChange="document.'.$this->ext_CEformName
.'[\''.$fN.'\'].value=this.options[this.selectedIndex].value; uFormUrl('.$aname.');">'.$p_field.'</select>';
1147 $p_field.='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(7).' onChange="uFormUrl('.$aname.')">';
1150 $wArr = explode("|",$fV);
1151 $p_field='<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(29).' onChange="uFormUrl('.$aname.')">';
1153 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(15).' onChange="uFormUrl('.$aname.')">';
1156 $wArr = explode(",",$fV);
1157 $labels = t3lib_div
::trimExplode(",",$typeDat["paramstr"]);
1158 $p_field=($labels[0]?
$labels[0]:"x").':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1160 $p_field.=($labels[1]?
$labels[1]:"y").':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1161 for ($aa=2;$aa<count($labels);$aa++
) {
1163 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).' onChange="uFormUrl('.$aname.')">';
1165 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'">';
1170 if (is_array($typeDat["params"])) {
1172 while(list(,$val)=each($typeDat["params"])) {
1173 $vParts = explode("=",$val,2);
1174 $label = $vParts[0];
1175 $val = isset($vParts[1]) ?
$vParts[1] : $vParts[0];
1179 if ($val==$params["value"]) {$sel=" selected";}
1180 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS["LANG"]->sL($label).'</option>';
1182 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1186 $p_field='<input type="Hidden" name="'.$fN.'" value="0">';
1187 $sel=""; if ($fV) {$sel=" checked";}
1188 $p_field.='<input type="Checkbox" name="'.$fN.'" value="'.($typeDat["paramstr"]?
$typeDat["paramstr"]:1).'"'.$sel.' onClick="uFormUrl('.$aname.')">';
1191 $p_field='<input type="Hidden" name="'.$fN.'" value="#">';
1192 $sel=""; if (!$fV) {$sel=" checked";}
1193 $p_field.='<input type="Checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')">';
1196 $p_field='<option value=""></option>';
1197 // debug($params["value"]);
1200 $selectThisFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1201 if ($params["value"] && !$selectThisFile) {
1202 if (in_array($params["value"],$this->dirResources
)) {
1203 $selectThisFile=$params["value"];
1206 // debug($selectThisFile);
1208 $extList = $typeDat["paramstr"];
1209 $p_field='<option value="">('.$extList.')</option>';
1210 if ($extList=="IMAGE_EXT") {
1211 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1214 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag
;
1216 while(list($c,$val)=each($this->rArr
)) {
1218 $fI=t3lib_div
::split_fileref($val);
1220 if ($val && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1221 if ($onlineResourceFlag<=0 && substr($fI["path"],0,10)=="fileadmin/") {
1222 if ($onlineResourceFlag<0) {
1223 $p_field.='<option value=""></option>';
1225 $p_field.='<option value="">__'.$fI["path"].'__:</option>';
1226 $onlineResourceFlag=1;
1228 $dims=$this->resourceDimensions
[$val];
1231 // Check if $params["value"] is in the list of resources.
1232 if ($selectThisFile && $selectThisFile==$val) {
1234 if ($onlineResourceFlag<=0) {
1235 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$selectThisFile),"sys_template","resources",$GLOBALS["BACK_PATH"],"");
1237 $theImage=t3lib_BEfunc
::thumbCode(array("resources"=>$fI["file"]),"sys_template","resources",$GLOBALS["BACK_PATH"],"",$fI["path"]);
1241 if ($onlineResourceFlag<=0) {
1242 $onlineResourceFlag--;
1243 // Value is set with a *
1244 $val = $this->ext_setStar($val);
1245 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1247 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI["file"].$dims.'</option>';
1251 if (trim($params["value"]) && !$selectThisFile) {
1252 $val = $params["value"];
1253 $p_field.='<option value=""></option>';
1254 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1257 $p_field='<select name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1258 $p_field.=$theImage;
1260 if (!$this->ext_noCEUploadAndCopying
) {
1262 $copyFile = $this->extractFromResources($this->setup
["resources"],$params["value"]);
1264 if ($params["value"]) {
1265 $copyFile=PATH_site
.$this->ext_detectAndFixExtensionPrefix($params["value"]);
1268 // $copyFile=PATH_site."uploads/tf/".$copyFile;
1272 if ($copyFile && @is_file
($copyFile)) {
1273 $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"])).'\'));}">';
1277 $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1282 $fwidth= $typeDat["type"]=="small" ?
10 : 46;
1283 $p_field='<input type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth($fwidth).' onChange="uFormUrl('.$aname.')">';
1287 if (!$this->ext_dontCheckIssetValues
) $p_field='<input type="Checkbox" name="check['.$params["name"].']" value="1"'.$checked.' onClick="uFormUrl('.$aname.')">'.$p_field;
1288 if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$') {
1289 $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>';
1291 $p_field='<span class="nobr">'.$p_field.'</span><br />';
1294 $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
1295 $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';
1296 $p_label = '<b>'.htmlspecialchars($head).'</b>';
1297 $p_descrip = $body ?
htmlspecialchars($body)."<BR>" : "";
1300 $output.='<td valign=top nowrap><a name="'.$raname.'"></a>'.$help["constants"][$params["name"]].$p_label.'</td>';
1301 $output.='<td valign=top align="right">'.$p_name.'</td>';
1304 $output.='<td colspan=2>'.$p_descrip.$p_field.$p_dlabel.'<br></td>';
1308 debug("Error. Constant did not exits. Should not happen.");
1311 $output='<table border=0 cellpadding=0 cellspacing=0>'.$output.'</table>';
1327 /***************************
1329 * Processing input values
1331 ***************************/
1334 * @param [type] $constants: ...
1335 * @return [type] ...
1337 function ext_regObjectPositions($constants) {
1338 // 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
1339 $this->raw
= explode(chr(10),$constants);
1342 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1343 $this->ext_regObjects("");
1347 * [Describe function...]
1349 * @param [type] $pre: ...
1350 * @return [type] ...
1352 function ext_regObjects($pre) {
1353 // works with regObjectPositions. "expands" the names of the TypoScript objects
1354 while (isset($this->raw
[$this->rawP
])) {
1355 $line = ltrim($this->raw
[$this->rawP
]);
1356 if (strstr($line,$this->edit_divider
)) {
1357 $this->objReg
=array(); // resetting the objReg if the divider is found!!
1361 if (substr($line,0,1)=="[") {
1363 } elseif (strcspn($line,"}#/")!=0) {
1364 $varL = strcspn($line," {=<");
1365 $var=substr($line,0,$varL);
1366 $line = ltrim(substr($line,$varL));
1367 switch(substr($line,0,1)) {
1369 $this->objReg
[$pre.$var]=$this->rawP
-1;
1372 $this->ext_inBrace++
;
1373 $this->ext_regObjects($pre.$var.".");
1376 $this->lastComment
="";
1377 } elseif (substr($line,0,1)=="}") {
1378 $this->lastComment
="";
1379 $this->ext_inBrace
--;
1380 if ($this->ext_inBrace
<0) {
1381 $this->ext_inBrace
=0;
1391 * [Describe function...]
1393 * @param [type] $key: ...
1394 * @param [type] $var: ...
1395 * @return [type] ...
1397 function ext_putValueInConf($key, $var) {
1398 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1399 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1400 $theValue = " ".trim($var);
1401 if (isset($this->objReg
[$key])) {
1402 $lineNum = $this->objReg
[$key];
1403 $parts = explode("=",$this->raw
[$lineNum],2);
1404 if (count($parts)==2) {
1405 $parts[1]= $theValue;
1407 $this->raw
[$lineNum]=implode($parts,"=");
1409 $this->raw
[]=$key." =".$theValue;
1415 * [Describe function...]
1417 * @param [type] $key: ...
1418 * @return [type] ...
1420 function ext_removeValueInConf($key) {
1421 // Removes the value in the configuration
1422 if (isset($this->objReg
[$key])) {
1423 $lineNum = $this->objReg
[$key];
1424 unset($this->raw
[$lineNum]);
1430 * [Describe function...]
1432 * @param [type] $arr: ...
1433 * @param [type] $settings: ...
1434 * @return [type] ...
1436 function ext_depthKeys($arr,$settings) {
1439 while(list($theK,$theV)=each($arr)) {
1440 $theKeyParts = explode(".",$theK);
1442 $c=count($theKeyParts);
1444 while(list(,$p)=each($theKeyParts)) {
1446 $depth.=($depth?
".":"").$p;
1447 $tsbrArray[$depth]= ($c==$a) ?
$theV : 1;
1452 while(list($theK,$theV)=each($tsbrArray)) {
1454 $settings[$theK] = 1;
1456 unset($settings[$theK]);
1463 * [Describe function...]
1465 * @param [type] $http_post_vars: ...
1466 * @param [type] $http_post_files: ...
1467 * @param [type] $theConstants: ...
1468 * @param [type] $tplRow: ...
1469 * @return [type] ...
1471 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1472 $data=$http_post_vars["data"];
1473 $check=$http_post_vars["check"];
1474 $copyResource=$http_post_vars["_copyResource"];
1475 $Wdata=$http_post_vars["Wdata"];
1476 $W2data=$http_post_vars["W2data"];
1477 $W3data=$http_post_vars["W3data"];
1478 $W4data=$http_post_vars["W4data"];
1479 $W5data=$http_post_vars["W5data"];
1481 if (is_array($data)) {
1483 while(list($key,$var)=each($data)) {
1484 if (isset($theConstants[$key])) {
1485 if ($this->ext_dontCheckIssetValues ||
isset($check[$key])) { // If checkbox is set, update the value
1486 list($var) = explode(chr(10),$var); // exploding with linebreak, just to make sure that no multiline input is given!
1487 $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
1488 switch($typeDat["type"]) {
1490 if ($typeDat["paramstr"]) {
1491 $var=t3lib_div
::intInRange($var,$typeDat["params"][0],$typeDat["params"][1]);
1497 $var=t3lib_div
::intInRange($var,0,10000);
1501 if($var && !t3lib_div
::inList($this->HTMLcolorList
,strtolower($var))) {
1502 $var = ereg_replace("[^A-Fa-f0-9]*","",$var);
1503 $col[]=HexDec(substr($var,0,2));
1504 $col[]=HexDec(substr($var,2,2));
1505 $col[]=HexDec(substr($var,4,2));
1506 $var="#".strtoupper(substr("0".DecHex($col[0]),-2).substr("0".DecHex($col[1]),-2).substr("0".DecHex($col[2]),-2));
1517 if (isset($Wdata[$key])) {
1518 $var.="|".$Wdata[$key];
1522 if (isset($Wdata[$key])) {
1523 $var=intval($var).",".intval($Wdata[$key]);
1524 if (isset($W2data[$key])) {
1525 $var.=",".intval($W2data[$key]);
1526 if (isset($W3data[$key])) {
1527 $var.=",".intval($W3data[$key]);
1528 if (isset($W4data[$key])) {
1529 $var.=",".intval($W4data[$key]);
1530 if (isset($W5data[$key])) {
1531 $var.=",".intval($W5data[$key]);
1540 $var = $typeDat["paramstr"] ?
$typeDat["paramstr"] : 1;
1544 if (!$this->ext_noCEUploadAndCopying
) {
1545 if ($http_post_files["upload_data"]["name"][$key] && $http_post_files["upload_data"]["tmp_name"][$key]!="none") {
1546 $var = $this->upload_copy_file(
1549 trim($http_post_files["upload_data"]["name"][$key]),
1550 $http_post_files["upload_data"]["tmp_name"][$key]
1553 if ($copyResource[$key]) {
1554 $var = $this->upload_copy_file(
1557 basename($copyResource[$key]),
1564 if ($this->ext_printAll ||
strcmp($theConstants[$key]["value"],$var)) {
1565 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1567 unset($check[$key]); // Remove the entry because it has been "used"
1569 $this->ext_removeValueInConf($key);
1574 // 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...
1575 if (!$this->ext_dontCheckIssetValues
&& is_array($check)) {
1577 while(list($key,$var)=each($check)) {
1578 if (isset($theConstants[$key])) {
1579 $dValue = $theConstants[$key]["default_value"];
1581 $this->ext_putValueInConf($key, $dValue);
1586 // debug($this->objReg);
1590 * [Describe function...]
1592 * @param [type] $typeDat: ...
1593 * @param [type] $tplRow: ...
1594 * @param [type] $theRealFileName: ...
1595 * @param [type] $tmp_name: ...
1596 * @return [type] ...
1598 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1601 $extList = $typeDat["paramstr"];
1602 if ($extList=="IMAGE_EXT") {
1603 $extList = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"];
1605 $fI=t3lib_div
::split_fileref($theRealFileName);
1606 if ($theRealFileName && (!$extList || t3lib_div
::inList($extList,$fI["fileext"]))) {
1607 $tmp_upload_name = t3lib_div
::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1610 $alternativeFileName=array();
1611 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1612 // Making list of resources
1613 $resList = $tplRow["resources"];
1614 $resList = $tmp_upload_name.",".$resList;
1615 $resList=implode(t3lib_div
::trimExplode(",",$resList,1),",");
1616 // Making data-array
1618 $recData["sys_template"][$tplRow["uid"]]["resources"] = $resList;
1620 $tce = t3lib_div
::makeInstance("t3lib_TCEmain");
1621 $tce->stripslashes_values
=0;
1622 $tce->alternativeFileName
= $alternativeFileName;
1623 $tce->start($recData,Array());
1624 $tce->process_datamap();
1626 t3lib_div
::unlink_tempfile($tmp_upload_name);
1628 $tmpRow = t3lib_BEfunc
::getRecord("sys_template",$tplRow["uid"],"resources");
1629 $tplRow["resources"] = $tmpRow["resources"];
1631 // Setting the value
1632 $var = $this->ext_setStar($theRealFileName);
1638 * [Describe function...]
1640 * @param [type] $id: ...
1641 * @param [type] $perms_clause: ...
1642 * @return [type] ...
1644 function ext_prevPageWithTemplate($id,$perms_clause) {
1645 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,$perms_clause?
" AND ".$perms_clause:"");
1647 while(list(,$p)=each($rootLine)) {
1648 if ($this->ext_getFirstTemplate($p["uid"])) {
1655 * [Describe function...]
1657 * @param [type] $val: ...
1658 * @return [type] ...
1660 function ext_setStar($val) {
1661 $fParts = explode(".",strrev($val),2);
1662 $val=ereg_replace("_[0-9][0-9]$","",strrev($fParts[1]))."*.".strrev($fParts[0]);
1667 * [Describe function...]
1669 * @param [type] $value: ...
1670 * @return [type] ...
1672 function ext_detectAndFixExtensionPrefix($value) {
1673 if (substr($value,0,4)=="EXT:") {
1674 $parts = explode("/",substr($value,4),2);
1676 $extPath = t3lib_extMgm
::siteRelPath($parts[0]);
1677 $value = $extPath.$parts[1];
1686 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1687 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);