Fixed bug #15092: Ajax loaded items of inline records are encoded twice (Thanks to...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsparser_ext.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * TSParser extension class to t3lib_TStemplate
29 *
30 * $Id$
31 * Contains functions for the TS module in TYPO3 backend
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 105: class t3lib_tsparser_ext extends t3lib_TStemplate
41 * 191: function flattenSetup($setupArray, $prefix, $resourceFlag)
42 * 218: function substituteConstants($all)
43 * 231: function substituteConstantsCallBack($matches)
44 * 261: function substituteCMarkers($all)
45 * 284: function generateConfig_constants()
46 * 330: function ext_getSetup($theSetup,$theKey)
47 * 358: function ext_getObjTree($arr, $depth_in, $depthData, $parentType='',$parentValue='', $alphaSort='0')
48 * 463: function lineNumberToScript($lnArr)
49 * 494: function makeHtmlspecialchars($theValue)
50 * 507: function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)
51 * 562: function ext_getRootlineNumber($pid)
52 * 580: function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)
53 * 639: function ext_process_hierarchyInfo($depthDataArr,&$pointer)
54 * 670: function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0)
55 * 697: function ext_fixed_lgd($string,$chars)
56 * 713: function ext_lnBreakPointWrap($ln,$str)
57 * 726: function ext_formatTS($input, $ln, $comments=1, $crop=0)
58 * 765: function ext_getFirstTemplate($id,$template_uid=0)
59 * 785: function ext_getAllTemplates($id)
60 * 806: function ext_compareFlatSetups($default)
61 * 872: function ext_categorizeEditableConstants($editConstArray)
62 * 895: function ext_getCategoryLabelArray()
63 * 912: function ext_getTypeData($type)
64 * 953: function ext_getTSCE_config($category)
65 * 992: function ext_getKeyImage($key)
66 * 1002: function ext_getTSCE_config_image($imgConf)
67 * 1026: function ext_resourceDims()
68 * 1056: function ext_readDirResources($path)
69 * 1071: function readDirectory($path,$type='file')
70 * 1096: function ext_fNandV($params)
71 * 1114: function ext_printFields($theConstants,$category)
72 *
73 * SECTION: Processing input values
74 * 1408: function ext_regObjectPositions($constants)
75 * 1423: function ext_regObjects($pre)
76 * 1468: function ext_putValueInConf($key, $var)
77 * 1491: function ext_removeValueInConf($key)
78 * 1507: function ext_depthKeys($arr,$settings)
79 * 1542: function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)
80 * 1666: function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)
81 * 1715: function ext_prevPageWithTemplate($id,$perms_clause)
82 * 1731: function ext_setStar($val)
83 * 1743: function ext_detectAndFixExtensionPrefix($value)
84 *
85 * TOTAL FUNCTIONS: 41
86 * (This index is automatically created/updated by the extension "extdeveval")
87 *
88 */
89
90
91
92
93
94
95
96
97 /**
98 * TSParser extension class to t3lib_TStemplate
99 *
100 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
101 * @package TYPO3
102 * @subpackage t3lib
103 */
104 class t3lib_tsparser_ext extends t3lib_TStemplate {
105
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,beige,black,blue,brown,fuchsia,gold,gray,green,lime,maroon,navy,olive,orange,purple,red,silver,tan,teal,turquoise,yellow,white';
108
109 // internal
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'),
127
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'),
132 'cimage' => Array('Content: \'Image\'', 'md'),
133 'cbullets' => Array('Content: \'Bullet list\'', 'me'),
134 'ctable' => Array('Content: \'Table\'', 'mf'),
135 'cuploads' => Array('Content: \'Filelinks\'', 'mg'),
136 'cmultimedia' => Array('Content: \'Multimedia\'', 'mh'),
137 'cmedia' => Array('Content: \'Media\'', 'mr'),
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')
147 );
148 var $resourceDimensions = array();
149 var $dirResources = array();
150
151 var $backend_info=1;
152
153 // tsconstanteditor
154 var $ext_inBrace=0;
155
156 // tsbrowser
157 var $tsbrowser_searchKeys = array();
158 var $tsbrowser_depthKeys = array();
159 var $constantMode='';
160 var $regexMode='';
161 var $fixedLgd='';
162 var $resourceCheck=0;
163 var $ext_lineNumberOffset=0;
164 var $ext_localGfxPrefix='';
165 var $ext_localWebGfxPrefix='';
166 var $ext_expandAllNotes=0;
167 var $ext_noPMicons=0;
168 var $ext_noSpecialCharsOnLabels=0;
169 var $ext_listOfTemplatesArr=array();
170 var $ext_lineNumberOffset_mode='';
171 var $ext_dontCheckIssetValues=0; // Dont change...
172 var $ext_noCEUploadAndCopying=0;
173 var $ext_printAll=0;
174 var $ext_CEformName='forms[0]';
175 var $ext_defaultOnlineResourceFlag=0;
176 var $doNotSortCategoriesBeforeMakingForm = FALSE;
177
178 // ts analyzer
179 var $templateTitles=array();
180
181
182 /**
183 * This flattens a hierarchical setuparray to $this->flatSetup
184 * The original function fetched the resource-file if any ('file.'). This functions doesn't.
185 *
186 * @param [type] $setupArray: ...
187 * @param [type] $prefix: ...
188 * @param [type] $resourceFlag: ...
189 * @return [type] ...
190 */
191 function flattenSetup($setupArray, $prefix, $resourceFlag) {
192 if (is_array($setupArray)) {
193 $this->getFileName_backPath=PATH_site; // Setting absolute prefixed path for relative resources.
194 foreach ($setupArray as $key => $val) {
195 if ($prefix || substr($key,0,16)!='TSConstantEditor') { // We don't want 'TSConstantEditor' in the flattend setup.
196 if (is_array($val)) {
197 $this->flattenSetup($val,$prefix.$key, ($key=='file.'));
198 } elseif ($resourceFlag && $this->resourceCheck) {
199 $this->flatSetup[$prefix.$key] = $this->getFileName($val);
200 if ($this->removeFromGetFilePath && substr($this->flatSetup[$prefix.$key],0,strlen($this->removeFromGetFilePath))==$this->removeFromGetFilePath) {
201 $this->flatSetup[$prefix.$key] = substr($this->flatSetup[$prefix.$key],strlen($this->removeFromGetFilePath));
202 }
203 } else {
204 $this->flatSetup[$prefix.$key] = $val;
205 }
206 }
207 }
208 }
209 }
210
211 /**
212 * [Describe function...]
213 *
214 * @param [type] $all: ...
215 * @return [type] ...
216 */
217 function substituteConstants($all) {
218 $this->Cmarker = substr(md5(uniqid('')),0,6);
219
220 return preg_replace_callback('/\{\$(.[^}]+)\}/', array($this, 'substituteConstantsCallBack'), $all);
221 }
222
223 /**
224 * Call back method for preg_replace_callback in substituteConstants
225 *
226 * @param array Regular expression matches
227 * @return string Replacement
228 * @see substituteConstants()
229 */
230 function substituteConstantsCallBack($matches) {
231 switch($this->constantMode) {
232 case 'const':
233 $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ?
234 '##'.$this->Cmarker.'_B##'.$matches[0].'##'.$this->Cmarker.'_E##' :
235 $matches[0];
236 break;
237 case 'subst':
238 $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ?
239 '##'.$this->Cmarker.'_B##'.$this->flatSetup[$matches[1]].'##'.$this->Cmarker.'_E##' :
240 $matches[0];
241 break;
242 case 'untouched':
243 $ret_val = $matches[0];
244 break;
245 default:
246 $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ?
247 $this->flatSetup[$matches[1]] :
248 $matches[0];
249 }
250
251 return $ret_val;
252 }
253
254 /**
255 * [Describe function...]
256 *
257 * @param [type] $all: ...
258 * @return [type] ...
259 */
260 function substituteCMarkers($all) {
261 switch($this->constantMode) {
262 case 'const':
263 $all = str_replace('##'.$this->Cmarker.'_B##', '<font color="green"><strong>', $all);
264 $all = str_replace('##'.$this->Cmarker.'_E##', '</strong></font>', $all);
265 break;
266 case 'subst':
267 $all = str_replace('##'.$this->Cmarker.'_B##', '<font color="green"><strong>', $all);
268 $all = str_replace('##'.$this->Cmarker.'_E##', '</strong></font>', $all);
269 break;
270 default:
271 $all = $all;
272 break;
273 }
274 return $all;
275 }
276
277 /**
278 * Parses the constants in $this->const with respect to the constant-editor in this module.
279 * In particular comments in the code are registered and the edit_divider is taken into account.
280 *
281 * @return [type] ...
282 */
283 function generateConfig_constants() {
284 // These vars are also set lateron...
285 $this->setup['resources'] = $this->resources;
286 $this->setup['sitetitle'] = $this->sitetitle;
287
288 // parse constants
289 $constants = t3lib_div::makeInstance('t3lib_TSparser');
290 $constants->regComments=1; // Register comments!
291 $constants->setup = $this->const;
292 $constants->setup = $this->mergeConstantsFromPageTSconfig($constants->setup);
293
294 /* @var $matchObj t3lib_matchCondition_frontend */
295 $matchObj = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
296 $matchObj->setSimulateMatchResult(true); // Matches ALL conditions in TypoScript
297
298 $c=0;
299 $cc=count($this->constants);
300 foreach ($this->constants as $str) {
301 $c++;
302 if ($c==$cc) {
303 if (strstr($str,$this->edit_divider)) {
304 $parts = explode($this->edit_divider,$str,2);
305 $str=$parts[1];
306 $constants->parse($parts[0],$matchObj);
307 }
308 $this->flatSetup = Array();
309 $this->flattenSetup($constants->setup,'','');
310 $defaultConstants=$this->flatSetup;
311 }
312 $constants->parse($str,$matchObj);
313 }
314
315 $this->flatSetup = Array();
316 $this->flattenSetup($constants->setup,'','');
317 $this->setup['constants'] = $constants->setup;
318
319 return $this->ext_compareFlatSetups($defaultConstants);
320 }
321
322 /**
323 * [Describe function...]
324 *
325 * @param [type] $theSetup: ...
326 * @param [type] $theKey: ...
327 * @return [type] ...
328 */
329 function ext_getSetup($theSetup,$theKey) {
330 $parts = explode('.',$theKey,2);
331 if (strcmp($parts[0],'') && is_array($theSetup[$parts[0].'.'])) {
332 if (strcmp(trim($parts[1]),'')) {
333 return $this->ext_getSetup($theSetup[$parts[0].'.'],trim($parts[1]));
334 } else {
335 return array($theSetup[$parts[0].'.'], $theSetup[$parts[0]]);
336 }
337 } else {
338 if (strcmp(trim($theKey),'')) {
339 return array(array(),$theSetup[$theKey]);
340 } else {
341 return array($theSetup,'');
342 }
343 }
344 }
345
346 /**
347 * [Describe function...]
348 *
349 * @param [type] $arr: ...
350 * @param [type] $depth_in: ...
351 * @param [type] $depthData: ...
352 * @param [type] $parentType: ...
353 * @param [type] $parentValue: ...
354 * @param boolean $alphaSort sorts the array keys / tree by alphabet when set to 1
355 * @return [type] ...
356 */
357 function ext_getObjTree($arr, $depth_in, $depthData, $parentType='',$parentValue='', $alphaSort='0') {
358 $HTML='';
359 $a=0;
360
361 if($alphaSort == '1') {
362 ksort($arr);
363 }
364 $keyArr_num=array();
365 $keyArr_alpha=array();
366 foreach ($arr as $key => $value) {
367 if (substr($key,-2)!='..') { // Don't do anything with comments / linenumber registrations...
368 $key=preg_replace('/\.$/','',$key);
369 if (substr($key,-1)!='.') {
370 if (t3lib_div::testInt($key)) {
371 $keyArr_num[$key]=$arr[$key];
372 } else {
373 $keyArr_alpha[$key]=$arr[$key];
374 }
375 }
376 }
377 }
378 ksort($keyArr_num);
379 $keyArr=$keyArr_num+$keyArr_alpha;
380 $c=count($keyArr);
381 if ($depth_in) {$depth_in = $depth_in.'.';}
382
383 foreach ($keyArr as $key => $value) {
384 $a++;
385 $depth=$depth_in.$key;
386 if ($this->bType!='const' || substr($depth,0,1)!='_') { // this excludes all constants starting with '_' from being shown.
387 $goto = substr(md5($depth),0,6);
388 $deeper = (is_array($arr[$key.'.']) && ($this->tsbrowser_depthKeys[$depth] || $this->ext_expandAllNotes)) ? 1 : 0;
389 $PM = 'join';
390 $LN = ($a==$c)?'blank':'line';
391 $BTM = ($a==$c)?'bottom':'';
392 $PM = is_array($arr[$key.'.']) && !$this->ext_noPMicons ? ($deeper ? 'minus':'plus') : 'join';
393
394 $HTML.=$depthData;
395 $theIcon='<img src="'.$GLOBALS['BACK_PATH'].'gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
396 if ($PM=='join') {
397 $HTML.=$theIcon;
398 } else {
399 $aHref='index.php?id=' . $GLOBALS['SOBE']->id .
400 '&tsbr[' . $depth.']=' . ($deeper ? 0 : 1) .
401 (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : '') .
402 '#' .$goto;
403 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
404 }
405
406 $label = $key;
407 if (t3lib_div::inList('types,resources,sitetitle',$depth) && $this->bType=='setup') { // Read only...
408 $label='<font color="#666666">'.$label.'</font>';
409 } else {
410 if ($this->linkObjects) {
411 $aHref = 'index.php?id='.$GLOBALS['SOBE']->id .
412 '&sObj=' . $depth .
413 (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : '');
414 if ($this->bType!='const') {
415 $ln = is_array($arr[$key.'.ln..']) ? 'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
416 } else {
417 $ln = '';
418 }
419
420 if ($this->tsbrowser_searchKeys[$depth] & 4) { $label = '<strong><font color="red">'.$label.'</font></strong>'; } // The key has matched the search string
421 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
422 }
423 }
424
425 $HTML.='['.$label.']';
426
427 if (isset($arr[$key])) {
428 $theValue = $arr[$key];
429 if ($this->fixedLgd) {
430 $imgBlocks = ceil(1+strlen($depthData)/77);
431 $lgdChars = 68-ceil(strlen('['.$key.']')*0.8)-$imgBlocks*3;
432 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
433 }
434 if ($this->tsbrowser_searchKeys[$depth] & 2) { // The value has matched the search string
435 $HTML.='&nbsp;=&nbsp;<strong><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></strong>';
436 } else {
437 $HTML.='&nbsp;=&nbsp;<strong>'.$this->makeHtmlspecialchars($theValue).'</strong>';
438 }
439 if ($this->ext_regComments && isset($arr[$key.'..'])) {
440 $comment = $arr[$key.'..'];
441 if (!preg_match('/### <INCLUDE_TYPOSCRIPT:.*/', $comment)) { // Skip INCLUDE_TYPOSCRIPT comments, they are almost useless
442 $comment = preg_replace('/[\r\n]/', ' ', $comment); // Remove linebreaks, replace with ' '
443 $comment = preg_replace('/[#\*]{2,}/', '', $comment); // Remove # and * if more than twice in a row
444 $comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a '#'.
445 $comment = $this->makeHtmlspecialchars($comment); // Masking HTML Tags: Replace < with &lt; and > with &gt;
446 $HTML.= ' <span class="comment">'.trim($comment).'</span>';
447 }
448 }
449 }
450 $HTML.='<br />';
451
452 if ($deeper) {
453 $HTML.=$this->ext_getObjTree($arr[$key.'.'], $depth, $depthData.'<img src="'.$GLOBALS['BACK_PATH'].'gfx/ol/'.$LN.'.gif" width="18" height="16" align="top" alt="" />', '' /* not used: $validate_info[$key] */, $arr[$key], $alphaSort);
454 }
455 }
456 }
457 return $HTML;
458 }
459
460 /**
461 * [Describe function...]
462 *
463 * @param [type] $lnArr: ...
464 * @return [type] ...
465 */
466 function lineNumberToScript($lnArr) {
467 if (!is_array($this->lnToScript)) {
468 $this->lnToScript = array();
469 $c=1;
470 $c+=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],LF)+2;
471 $this->lnToScript[$c] = '[Default]';
472
473 foreach($this->hierarchyInfoToRoot as $info) {
474 $c+=$info['configLines']+1;
475 $this->lnToScript[$c] = $info['title'];
476 }
477 }
478
479 foreach($lnArr as $k => $ln) {
480 foreach($this->lnToScript as $endLn => $title) {
481 if ($endLn >= intval($ln)) {
482 $lnArr[$k] = '"'.$title.'", '.$ln;
483 break;
484 }
485 }
486 }
487
488 return implode('; ',$lnArr);
489 }
490
491 /**
492 * [Describe function...]
493 *
494 * @param [type] $theValue: ...
495 * @return [type] ...
496 */
497 function makeHtmlspecialchars($theValue){
498 return $this->ext_noSpecialCharsOnLabels ? $theValue : htmlspecialchars($theValue);
499 }
500
501 /**
502 * [Describe function...]
503 *
504 * @param [type] $arr: ...
505 * @param [type] $depth_in: ...
506 * @param [type] $searchString: ...
507 * @param [type] $keyArray: ...
508 * @return [type] ...
509 */
510 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
511 $keyArr=array();
512 foreach ($arr as $key => $value) {
513 $key=preg_replace('/\.$/','',$key);
514 if (substr($key,-1)!='.') {
515 $keyArr[$key]=1;
516 }
517 }
518 $c=count($keyArr);
519 if ($depth_in) { $depth_in = $depth_in.'.'; }
520 foreach ($keyArr as $key => $value) {
521 $depth=$depth_in.$key;
522 $deeper = is_array($arr[$key.'.']);
523
524 if ($this->regexMode) {
525 if (preg_match('/'.$searchString.'/',$arr[$key])) { // The value has matched
526 $this->tsbrowser_searchKeys[$depth]+=2;
527 }
528 if (preg_match('/'.$searchString.'/',$key)) { // The key has matched
529 $this->tsbrowser_searchKeys[$depth]+=4;
530 }
531 if (preg_match('/'.$searchString.'/',$depth_in)) { // Just open this subtree if the parent key has matched the search
532 $this->tsbrowser_searchKeys[$depth]=1;
533 }
534 } else {
535 if (stristr($arr[$key],$searchString)) { // The value has matched
536 $this->tsbrowser_searchKeys[$depth]+=2;
537 }
538 if (stristr($key,$searchString)) { // The key has matches
539 $this->tsbrowser_searchKeys[$depth]+=4;
540 }
541 if (stristr($depth_in,$searchString)) { // Just open this subtree if the parent key has matched the search
542 $this->tsbrowser_searchKeys[$depth]=1;
543 }
544 }
545
546 if ($deeper) {
547 $cS = count($this->tsbrowser_searchKeys);
548 $keyArray = $this->ext_getSearchKeys($arr[$key.'.'], $depth, $searchString, $keyArray);
549 if ($cS != count($this->tsbrowser_searchKeys)) {
550 $keyArray[$depth]=1;
551 }
552 }
553 }
554 return $keyArray;
555 }
556
557 /**
558 * [Describe function...]
559 *
560 * @param [type] $pid: ...
561 * @return [type] ...
562 */
563 function ext_getRootlineNumber($pid) {
564 if ($pid && is_array($GLOBALS['rootLine'])) {
565 foreach ($GLOBALS['rootLine'] as $key => $val) {
566 if ($val['uid']==$pid) return $key;
567 }
568 }
569 }
570
571 /**
572 * [Describe function...]
573 *
574 * @param [type] $arr: ...
575 * @param [type] $depthData: ...
576 * @param [type] $keyArray: ...
577 * @param [type] $first: ...
578 * @return [type] ...
579 */
580 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
581 $keyArr=array();
582 foreach ($arr as $key => $value) {
583 $key=preg_replace('/\.$/','',$key);
584 if (substr($key,-1)!='.') {
585 $keyArr[$key]=1;
586 }
587 }
588 $a=0;
589 $c=count($keyArr);
590 static $i;
591 foreach ($keyArr as $key => $value) {
592 $HTML = '';
593 $a++;
594 $deeper = is_array($arr[$key . '.']);
595 $row = $arr[$key];
596
597 $PM = 'join';
598 $LN = ($a==$c) ? 'blank' : 'line';
599 $BTM = ($a==$c) ? 'top' : '';
600 $PM = 'join';
601
602 $HTML .= $depthData;
603
604 $alttext = '[' . $row['templateID'] . ']';
605 $alttext .= $row['pid'] ? ' - ' . t3lib_BEfunc::getRecordPath($row['pid'], $GLOBALS['SOBE']->perms_clause, 20) : '';
606
607 $icon = (substr($row['templateID'],0,3) == 'sys' ?
608 t3lib_iconWorks::getSpriteIconForRecord('sys_template', $row, array('title' => $alttext))
609 : t3lib_iconWorks::getSpriteIcon('mimetypes-x-content-template-static', array('title' => $alttext))
610 );
611 if (in_array($row['templateID'], $this->clearList_const) || in_array($row['templateID'], $this->clearList_setup)) {
612 $A_B = '<a href="index.php?id=' . htmlspecialchars($GLOBALS['SOBE']->id . '&template=' . $row['templateID']) . '">';
613 $A_E = '</a>';
614 if (t3lib_div::_GP('template') == $row['templateID']) {
615 $A_B = '<strong>' . $A_B;
616 $A_E .= '</strong>';
617 }
618 } else {
619 $A_B = '';
620 $A_E = '';
621 }
622 $HTML .= ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $PM . $BTM . '.gif" width="18" height="16" align="top" border="0" alt="" />') .
623 $icon .
624 $A_B . t3lib_div::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen']) . $A_E . '&nbsp;&nbsp;';
625 $RL = $this->ext_getRootlineNumber($row['pid']);
626 $keyArray[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
627 <td nowrap="nowrap">' . $HTML . '</td>
628 <td align="center">' . ($row['root'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '&nbsp;&nbsp;</td>
629 <td align="center">' . ($row['clConf'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') :'') . '&nbsp;&nbsp;' . '</td>
630 <td align="center">' . ($row['clConst'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '&nbsp;&nbsp;' . '</td>
631 <td align="center">' . ($row['pid'] ? $row['pid'] : '') . '</td>
632 <td align="center">' . (strcmp($RL, '') ? $RL : '') . '</td>
633 <td>' . ($row['next'] ? '&nbsp;' . $row['next'] . '&nbsp;&nbsp;' : '') . '</td>
634 </tr>';
635 if ($deeper) {
636 $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $LN . '.gif" width="18" height="16" align="top" />'), $keyArray);
637 }
638 }
639 return $keyArray;
640 }
641
642 /**
643 * [Describe function...]
644 *
645 * @param [type] $depthDataArr: ...
646 * @param [type] $pointer: ...
647 * @return [type] ...
648 */
649 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
650 $parent = $this->hierarchyInfo[$pointer-1]['templateParent'];
651 while ($pointer>0 && $this->hierarchyInfo[$pointer-1]['templateParent']==$parent) {
652 $pointer--;
653 $row = $this->hierarchyInfo[$pointer];
654
655 $depthDataArr[$row['templateID']]=$row;
656 $depthDataArr[$row['templateID']]['bgcolor_setup'] = isset($this->clearList_setup_temp[$row['templateID']])?' class="bgColor5"':'';
657 $depthDataArr[$row['templateID']]['bgcolor_const'] = isset($this->clearList_const_temp[$row['templateID']])?' class="bgColor5"':'';
658 unset($this->clearList_setup_temp[$row['templateID']]);
659 unset($this->clearList_const_temp[$row['templateID']]);
660 $this->templateTitles[$row['templateID']]=$row['title'];
661
662 if ($row['templateID']==$this->hierarchyInfo[$pointer-1]['templateParent']) {
663 $depthDataArr[$row['templateID'].'.'] = $this->ext_process_hierarchyInfo(array(), $pointer);
664 }
665 }
666 return $depthDataArr;
667 }
668
669 /**
670 * [Describe function...]
671 *
672 * @param [type] $config: ...
673 * @param [type] $lineNumbers: ...
674 * @param [type] $comments: ...
675 * @param [type] $crop: ...
676 * @param [type] $syntaxHL: ...
677 * @param [type] $syntaxHLBlockmode: ...
678 * @return [type] ...
679 */
680 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
681 $all='';
682 foreach ($config as $str) {
683 $all .= LF .'[GLOBAL]' . LF . $str;
684 }
685
686 if ($syntaxHL) {
687 $all = preg_replace('/^[^'.LF.']*./','',$all);
688 $all = chop($all);
689 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
690 $tsparser->lineNumberOffset=$this->ext_lineNumberOffset+1;
691 $tsparser->parentObject = $this;
692 return $tsparser->doSyntaxHighlight($all,$lineNumbers?array($this->ext_lineNumberOffset+1):'',$syntaxHLBlockmode);
693 } else {
694 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
695 }
696 }
697
698 /**
699 * Returns a new string of max. $chars lenght
700 * If the string is longer, it will be truncated and prepended with '...'
701 * $chars must be an integer of at least 4
702 *
703 * @param [type] $string: ...
704 * @param [type] $chars: ...
705 * @return [type] ...
706 */
707 function ext_fixed_lgd($string,$chars) {
708 if ($chars >= 4) {
709 if(strlen($string)>$chars) {
710 if(strlen($string)>24 && substr($string,0,12) == '##'.$this->Cmarker.'_B##') {
711 return '##'.$this->Cmarker.'_B##'.t3lib_div::fixed_lgd_cs(substr($string,12,-12), $chars-3).'##'.$this->Cmarker.'_E##';
712 } else {
713 return t3lib_div::fixed_lgd_cs($string, $chars-3);
714 }
715 }
716 }
717 return $string;
718 }
719
720 /**
721 * [Describe function...]
722 *
723 * @param [type] $ln: ...
724 * @param [type] $str: ...
725 * @return [type] ...
726 */
727 function ext_lnBreakPointWrap($ln,$str) {
728 return '<a href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode=="setup"?1:0).');">'.$str.'</a>';
729 }
730
731 /**
732 * [Describe function...]
733 *
734 * @param [type] $input: ...
735 * @param [type] $ln: ...
736 * @param [type] $comments: ...
737 * @param [type] $crop: ...
738 * @return [type] ...
739 */
740 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
741 $input = preg_replace('/^[^'.LF.']*./','',$input);
742 $input = chop($input);
743 $cArr = explode(LF,$input);
744
745 $n = ceil(log10(count($cArr)+$this->ext_lineNumberOffset));
746 $lineNum='';
747 foreach ($cArr as $k => $v) {
748 $lln=$k+$this->ext_lineNumberOffset+1;
749 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(' ','&nbsp;',sprintf('% '.$n.'d',$lln))).': ';
750 $v=htmlspecialchars($v);
751 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?71:77));}
752 $cArr[$k] = $lineNum.str_replace(' ','&nbsp;',$v);
753
754 $firstChar = substr(trim($v),0,1);
755 if ($firstChar=='[') {
756 $cArr[$k] = '<font color="green"><strong>'.$cArr[$k].'</strong></font>';
757 } elseif ($firstChar=='/' || $firstChar=='#') {
758 if ($comments) {
759 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
760 } else {
761 unset($cArr[$k]);
762 }
763 }
764
765
766 }
767 $output = implode($cArr, '<br />').'<br />';
768 return $output;
769 }
770
771 /**
772 * [Describe function...]
773 *
774 * @param [type] $id: ...
775 * @param [type] $template_uid: ...
776 * @return [type] ...
777 */
778 function ext_getFirstTemplate($id,$template_uid=0) {
779 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
780 if (intval($id)) {
781 if ($template_uid) {
782 $addC = ' AND uid='.$template_uid;
783 }
784 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause, '', 'sorting', '1');
785 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
786 t3lib_BEfunc::workspaceOL('sys_template',$row);
787 $GLOBALS['TYPO3_DB']->sql_free_result($res);
788 return $row; // Returns the template row if found.
789 }
790 }
791
792 /**
793 * [Describe function...]
794 *
795 * @param [type] $id: ...
796 * @return [type] ...
797 */
798 function ext_getAllTemplates($id) {
799 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
800 if (intval($id)) {
801 $outRes=array();
802 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause, '', 'sorting');
803 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
804 t3lib_BEfunc::workspaceOL('sys_template',$row);
805 if (is_array($row)) $outRes[] = $row;
806 }
807 $GLOBALS['TYPO3_DB']->sql_free_result($res);
808 return $outRes; // Returns the template rows in an array.
809 }
810 }
811
812 /**
813 * This function compares the flattened constants (default and all).
814 * Returns an array with the constants from the whole template which may be edited by the module.
815 *
816 * @param [type] $default: ...
817 * @return [type] ...
818 */
819 function ext_compareFlatSetups($default) {
820 $editableComments=array();
821 reset($this->flatSetup);
822 foreach ($this->flatSetup as $const => $value) {
823 if (substr($const,-2)!='..' && isset($this->flatSetup[$const.'..'])) {
824 $comment = trim($this->flatSetup[$const.'..']);
825 $c_arr = explode(LF,$comment);
826 foreach ($c_arr as $k => $v) {
827 $line=trim(preg_replace('/^[#\/]*/','',$v));
828 if ($line) {
829 $parts = explode(';', $line);
830 foreach ($parts as $par) {
831 if (strstr($par,'=')) {
832 $keyValPair =explode('=',$par,2);
833 switch(trim(strtolower($keyValPair[0]))) {
834 case 'type':
835 // Type:
836 /*
837 int (range; low-high, list: item,item,item = selector),
838 boolean (check),
839 string (default),
840 wrap,
841 html-color ...,
842 file
843 */
844 $editableComments[$const]['type'] = trim($keyValPair[1]);
845 break;
846 case 'cat':
847 // list of categories.
848 $catSplit=explode('/',strtolower($keyValPair[1]));
849 $editableComments[$const]['cat'] = trim($catSplit[0]);
850 $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.
851 if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) {
852 $editableComments[$const]['subcat_name']=$catSplit[1];
853 $editableComments[$const]['subcat']=$this->subCategories[$catSplit[1]][1].'/'.$catSplit[1].'/'.trim($catSplit[2]).'z';
854 } else {
855 $editableComments[$const]['subcat']='x'.'/'.trim($catSplit[2]).'z';
856 }
857 break;
858 case 'label':
859 // label
860 $editableComments[$const]['label'] = trim($keyValPair[1]);
861 break;
862 case 'customsubcategory':
863 // custom subCategory label
864 $customSubcategory = explode('=',$keyValPair[1],2);
865 if (trim($customSubcategory[0])) {
866 $subCategoryKey = strtolower($customSubcategory[0]);
867 $this->subCategories[$subCategoryKey][0] = $GLOBALS['LANG']->sL($customSubcategory[1]);
868 }
869 break;
870 }
871 }
872 }
873 }
874 }
875 }
876 if (isset($editableComments[$const])) {
877 $editableComments[$const]['name']=$const;
878 $editableComments[$const]['value']=trim($value);
879 if (isset($default[$const])) {
880 $editableComments[$const]['default_value']=trim($default[$const]);
881 }
882 }
883 }
884 return $editableComments;
885 }
886
887 /**
888 * [Describe function...]
889 *
890 * @param [type] $editConstArray: ...
891 * @return [type] ...
892 */
893 function ext_categorizeEditableConstants($editConstArray) {
894 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
895 foreach ($editConstArray as $constName => $constData) {
896 if (!$constData['type']) {
897 $constData['type']='string';
898 }
899 $cats = explode(',',$constData['cat']);
900 foreach ($cats as $theCat) { // if = only one category, while allows for many. We have agreed on only one category is the most basic way...
901 $theCat=trim($theCat);
902 if ($theCat) {
903 $this->categories[$theCat][$constName]=$constData['subcat'];
904 }
905 }
906 }
907 }
908
909 /**
910 * [Describe function...]
911 *
912 * @return [type] ...
913 */
914 function ext_getCategoryLabelArray() {
915 // Returns array used for labels in the menu.
916 $retArr = array();
917 foreach ($this->categories as $k => $v) {
918 if (count($v)) {
919 $retArr[$k]=strtoupper($k).' ('.count($v).')';
920 }
921 }
922 return $retArr;
923 }
924
925 /**
926 * [Describe function...]
927 *
928 * @param [type] $type: ...
929 * @return [type] ...
930 */
931 function ext_getTypeData($type) {
932 $retArr = array();
933 $type=trim($type);
934 if (!$type) {
935 $retArr['type']='string';
936 } else {
937 $m=strcspn ($type,' [');
938 $retArr['type']=strtolower(substr($type,0,$m));
939 if (t3lib_div::inList('int,options,file,boolean,offset,user', $retArr['type'])) {
940 $p=trim(substr($type,$m));
941 $reg = array();
942 preg_match('/\[(.*)\]/',$p,$reg);
943 $p=trim($reg[1]);
944 if ($p) {
945 $retArr['paramstr']=$p;
946 switch($retArr['type']) {
947 case 'int':
948 if (substr($retArr['paramstr'],0,1)=='-') {
949 $retArr['params']=t3lib_div::intExplode('-',substr($retArr['paramstr'],1));
950 $retArr['params'][0]=intval('-'.$retArr['params'][0]);
951 } else {
952 $retArr['params']=t3lib_div::intExplode('-',$retArr['paramstr']);
953 }
954 $retArr['paramstr']=$retArr['params'][0].' - '.$retArr['params'][1];
955 break;
956 case 'options':
957 $retArr['params']=explode(',',$retArr['paramstr']);
958 break;
959 }
960 }
961 }
962 }
963 return $retArr;
964 }
965
966 /**
967 * [Describe function...]
968 *
969 * @param [type] $category: ...
970 * @return [type] ...
971 */
972 function ext_getTSCE_config($category) {
973 $catConf=$this->setup['constants']['TSConstantEditor.'][$category.'.'];
974 $out=array();
975 if (is_array($catConf)) {
976 foreach ($catConf as $key => $val) {
977 switch($key) {
978 case 'image':
979 $out['imagetag'] = $this->ext_getTSCE_config_image($catConf['image']);
980 break;
981 case 'description':
982 case 'bulletlist':
983 case 'header':
984 $out[$key] = $val;
985 break;
986 default:
987 if (t3lib_div::testInt($key)) {
988 $constRefs = explode(',',$val);
989 foreach ($constRefs as $const) {
990 $const=trim($const);
991 if ($const && $const<=20) {
992 $out['constants'][$const].=$this->ext_getKeyImage($key);
993 }
994 }
995 }
996 break;
997 }
998 }
999 }
1000 $this->helpConfig=$out;
1001 }
1002
1003 /**
1004 * [Describe function...]
1005 *
1006 * @param [type] $key: ...
1007 * @return [type] ...
1008 */
1009 function ext_getKeyImage($key) {
1010 return '<img src="'.$this->ext_localWebGfxPrefix.'gfx/'.$key.'.gif" align="top" hspace=2>';
1011 }
1012
1013 /**
1014 * [Describe function...]
1015 *
1016 * @param [type] $imgConf: ...
1017 * @return [type] ...
1018 */
1019 function ext_getTSCE_config_image($imgConf) {
1020 if (substr($imgConf,0,4)=='gfx/') {
1021 $iFile=$this->ext_localGfxPrefix.$imgConf;
1022 $tFile=$this->ext_localWebGfxPrefix.$imgConf;
1023 } elseif (substr($imgConf,0,4)=='EXT:') {
1024 $iFile = t3lib_div::getFileAbsFileName($imgConf);
1025 if ($iFile) {
1026 $f = substr($iFile,strlen(PATH_site));
1027 $tFile=$GLOBALS['BACK_PATH'].'../'.$f;
1028 }
1029 } else {
1030 $f = 'uploads/tf/'.$this->extractFromResources($this->setup['resources'],$imgConf);
1031 $iFile=PATH_site.$f;
1032 $tFile=$GLOBALS['BACK_PATH'].'../'.$f;
1033 }
1034 $imageInfo=@getImagesize($iFile);
1035 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
1036 }
1037
1038 /**
1039 * [Describe function...]
1040 *
1041 * @return [type] ...
1042 */
1043 function ext_resourceDims() {
1044 if ($this->setup['resources']) {
1045 $rArr=explode(',',$this->setup['resources']);
1046 foreach ($rArr as $c => $val) {
1047 $val=trim($val);
1048 $theFile = PATH_site.'uploads/tf/'.$val;
1049 if ($val && @is_file($theFile)) {
1050 $imgInfo = @getimagesize($theFile);
1051 }
1052 if (is_array($imgInfo)) {
1053 $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')';
1054 }
1055 }
1056 }
1057 foreach ($this->dirResources as $c => $val) {
1058 $val=trim($val);
1059 $imgInfo = @getimagesize(PATH_site.$val);
1060 if (is_array($imgInfo)) {
1061 $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')';
1062 }
1063 }
1064 }
1065
1066 /**
1067 * [Describe function...]
1068 *
1069 * @param [type] $path: ...
1070 * @return [type] ...
1071 */
1072 function ext_readDirResources($path) {
1073 $path = trim($path);
1074 if ($path && strstr($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) {
1075 $path = rtrim($path, '/');
1076 $this->readDirectory(PATH_site . $path);
1077 }
1078 }
1079
1080 /**
1081 * [Describe function...]
1082 *
1083 * @param [type] $path: ...
1084 * @param [type] $type: ...
1085 * @return [type] ...
1086 */
1087 function readDirectory($path,$type='file') {
1088 if(@is_dir($path)) {
1089 $d = @dir($path);
1090 $tempArray=Array();
1091 if (is_object($d)) {
1092 while($entry=$d->read()) {
1093 if ($entry!='.' && $entry!='..') {
1094 $wholePath = $path.'/'.$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1095 if (file_exists($wholePath) && (!$type || filetype($wholePath)==$type)) {
1096 $fI = t3lib_div::split_fileref($wholePath);
1097 $this->dirResources[]=substr($wholePath,strlen(PATH_site));
1098 }
1099 }
1100 }
1101 $d->close();
1102 }
1103 }
1104 }
1105
1106 /**
1107 * [Describe function...]
1108 *
1109 * @param [type] $params: ...
1110 * @return [type] ...
1111 */
1112 function ext_fNandV($params) {
1113 $fN='data['.$params['name'].']';
1114 $fV=$params['value'];
1115 if (preg_match('/^{[\$][a-zA-Z0-9\.]*}$/',trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1116 $fV='';
1117 }
1118 $fV=htmlspecialchars($fV);
1119
1120 return array($fN,$fV,$params);
1121 }
1122
1123 /**
1124 * This functions returns the HTML-code that creates the editor-layout of the module.
1125 *
1126 * @param [type] $theConstants: ...
1127 * @param [type] $category: ...
1128 * @return [type] ...
1129 */
1130 function ext_printFields($theConstants,$category) {
1131 reset($theConstants);
1132 $output='<script type="text/javascript" src="'.$GLOBALS['BACK_PATH'].'js/constantEditor.js"></script>
1133 ';
1134 $subcat='';
1135 if (is_array($this->categories[$category])) {
1136
1137 $help=$this->helpConfig;
1138 $this->rArr=explode(',',$this->setup['resources'].','.implode($this->dirResources,','));
1139
1140 if (!$this->doNotSortCategoriesBeforeMakingForm) asort($this->categories[$category]);
1141 foreach ($this->categories[$category] as $name => $type) {
1142 $params = $theConstants[$name];
1143 if (is_array($params)) {
1144 if ($subcat!=$params['subcat_name']) {
1145 $subcat=$params['subcat_name'];
1146 $subcat_name = $params['subcat_name'] ? $this->subCategories[$params['subcat_name']][0] : 'Others';
1147
1148 $output.='<h2 class="typo3-tstemplate-ceditor-subcat">'.$subcat_name.'</h2>';
1149 }
1150
1151 $label=$GLOBALS['LANG']->sL($params['label']);
1152 $label_parts = explode(':',$label,2);
1153 if (count($label_parts)==2) {
1154 $head=trim($label_parts[0]);
1155 $body=trim($label_parts[1]);
1156 } else {
1157 $head=trim($label_parts[0]);
1158 $body='';
1159 }
1160 if (strlen($head)>35) {
1161 if (!$body) {$body=$head;}
1162 $head=t3lib_div::fixed_lgd_cs($head,35);
1163 }
1164 $typeDat=$this->ext_getTypeData($params['type']);
1165 $checked='';
1166 $p_field='';
1167 $raname = substr(md5($params['name']),0,10);
1168 $aname='\''.$raname.'\'';
1169
1170 list($fN,$fV,$params)=$this->ext_fNandV($params);
1171
1172 switch($typeDat['type']) {
1173 case 'int':
1174 case 'int+':
1175 $p_field='<input id="'.$fN.'" type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' onChange="uFormUrl('.$aname.')" />';
1176 if ($typeDat['paramstr']) {
1177 $p_field.=' Range: '.$typeDat['paramstr'];
1178 } elseif ($typeDat['type']=='int+') {
1179 $p_field.=' Range: 0 - ';
1180 } else {
1181 $p_field.=' (Integer)';
1182 }
1183 break;
1184 case 'color':
1185 $colorNames=explode(',',','.$this->HTMLcolorList);
1186 $p_field='';
1187 foreach ($colorNames as $val) {
1188 $sel='';
1189 if ($val==strtolower($params['value'])) {
1190 $sel = ' selected';
1191 }
1192 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1193 }
1194 $p_field='<select id="select-'.$fN.'" rel="'.$fN.'" name="C'.$fN.'" class="typo3-tstemplate-ceditor-color-select" onChange="uFormUrl('.$aname.');">'.$p_field.'</select>';
1195
1196 $p_field.='<input type="text" id="input-'.$fN.'" rel="'.$fN.'" name="'.$fN.'" class="typo3-tstemplate-ceditor-color-input" value="'.$fV.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(7).' onChange="uFormUrl('.$aname.')" />';
1197 break;
1198 case 'wrap':
1199 $wArr = explode('|',$fV);
1200 $p_field='<input type="text" id="'.$fN.'" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(29).' onChange="uFormUrl('.$aname.')" />';
1201 $p_field.=' | ';
1202 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(15).' onChange="uFormUrl('.$aname.')" />';
1203 break;
1204 case 'offset':
1205 $wArr = explode(',',$fV);
1206 $labels = t3lib_div::trimExplode(',',$typeDat['paramstr']);
1207 $p_field=($labels[0]?$labels[0]:'x').':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1208 $p_field.=' , ';
1209 $p_field.=($labels[1]?$labels[1]:'y').':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1210 for ($aa=2;$aa<count($labels);$aa++) {
1211 if ($labels[$aa]) {
1212 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1213 } else {
1214 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'" />';
1215 }
1216 }
1217 break;
1218 case 'options':
1219 if (is_array($typeDat['params'])) {
1220 $p_field='';
1221 foreach ($typeDat['params'] as $val) {
1222 $vParts = explode('=',$val,2);
1223 $label = $vParts[0];
1224 $val = isset($vParts[1]) ? $vParts[1] : $vParts[0];
1225
1226 // option tag:
1227 $sel='';
1228 if ($val==$params['value']) {
1229 $sel=' selected';
1230 }
1231 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS['LANG']->sL($label).'</option>';
1232 }
1233 $p_field='<select id="'.$fN.'" name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1234 }
1235 break;
1236 case 'boolean':
1237 $p_field='<input type="hidden" name="'.$fN.'" value="0" />';
1238 $sel='';
1239 if ($fV) {
1240 $sel=' checked';
1241 }
1242 $p_field.='<input id="'.$fN.'" type="checkbox" name="'.$fN.'" value="'.($typeDat['paramstr']?$typeDat['paramstr']:1).'"'.$sel.' onClick="uFormUrl('.$aname.')" />';
1243 break;
1244 case 'comment':
1245 $p_field='<input type="hidden" name="'.$fN.'" value="#" />';
1246 $sel='';
1247 if (!$fV) {
1248 $sel=' checked';
1249 }
1250 $p_field.='<input id="'.$fN.'" type="checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')" />';
1251 break;
1252 case 'file':
1253 $p_field='<option value=""></option>';
1254 $theImage='';
1255 $selectThisFile = $this->extractFromResources($this->setup['resources'],$params['value']);
1256 if ($params['value'] && !$selectThisFile) {
1257 if (in_array($params['value'],$this->dirResources)) {
1258 $selectThisFile=$params['value'];
1259 }
1260 }
1261 // extensionlist
1262 $extList = $typeDat['paramstr'];
1263 $p_field='<option value="">('.$extList.')</option>';
1264 if ($extList=='IMAGE_EXT') {
1265 $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
1266 }
1267 reset($this->rArr);
1268 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag;
1269
1270 foreach ($this->rArr as $c => $val) {
1271 $val=trim($val);
1272 $fI=t3lib_div::split_fileref($val);
1273 if ($val && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) {
1274 if ($onlineResourceFlag <= 0 && strstr($fI['path'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) {
1275 if ($onlineResourceFlag<0) {
1276 $p_field.='<option value=""></option>';
1277 }
1278 $p_field.='<option value="">__'.$fI['path'].'__:</option>';
1279 $onlineResourceFlag=1;
1280 }
1281 $dims=$this->resourceDimensions[$val];
1282 $sel='';
1283
1284 // Check if $params['value'] is in the list of resources.
1285 if ($selectThisFile && $selectThisFile==$val) {
1286 $sel=' selected';
1287 if ($onlineResourceFlag<=0) {
1288 $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$selectThisFile),'sys_template','resources',$GLOBALS['BACK_PATH'],'');
1289 } else {
1290 $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$fI['file']),'sys_template','resources',$GLOBALS['BACK_PATH'],'',$fI['path']);
1291 }
1292 }
1293
1294 if ($onlineResourceFlag<=0) {
1295 $onlineResourceFlag--;
1296 // Value is set with a *
1297 $val = $this->ext_setStar($val);
1298 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1299 } else {
1300 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI['file'].$dims.'</option>';
1301 }
1302 }
1303 }
1304
1305 if (trim($params['value']) && !$selectThisFile) {
1306 $val = $params['value'];
1307 $p_field.='<option value=""></option>';
1308 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1309 }
1310
1311 $p_field='<select id="'.$fN.'" name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1312 $p_field.=$theImage;
1313
1314 if (!$this->ext_noCEUploadAndCopying) {
1315 // Copy a resource
1316 $copyFile = $this->extractFromResources($this->setup['resources'],$params['value']);
1317 if (!$copyFile) {
1318 if ($params['value']) {
1319 $copyFile=PATH_site.$this->ext_detectAndFixExtensionPrefix($params['value']);
1320 }
1321 } else {
1322 $copyFile='';
1323 }
1324
1325 if ($copyFile && @is_file($copyFile)) {
1326 $p_field .= '<img src="clear.gif" width="20" ' . 'height="1" alt="" />' . t3lib_iconWorks::getSpriteIcon('actions-edit-copy') . '<input type="checkbox" ' . 'name="_copyResource[' . $params['name'] . ']" value="' . htmlspecialchars($copyFile) . '" onclick="uFormUrl(' . $aname . ');if (this.checked && !confirm(\'' . t3lib_div::slashJS(htmlspecialchars(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsparser.xml:tsparser_ext.make_copy'), $params['value']))) . '\')) this.checked=false;" />';
1327 }
1328
1329 // Upload?
1330 $p_field.='<br />';
1331 $p_field.='<input id="'.$fN.'" type="file" name="upload_'.$fN.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1332 }
1333 break;
1334 case 'user':
1335 $userFunction = $typeDat['paramstr'];
1336 $userFunctionParams = array('fieldName' => $fN, 'fieldValue' => $fV);
1337 $p_field = t3lib_div::callUserFunction($userFunction, $userFunctionParams, $this, '');
1338 break;
1339 case 'small':
1340 default:
1341 $fwidth= $typeDat['type']=='small' ? 10 : 46;
1342 $p_field='<input id="'.$fN.'" type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($fwidth).' onChange="uFormUrl('.$aname.')" />';
1343 break;
1344 }
1345
1346 // Define default names and IDs
1347 $userTyposcriptID = 'userTS-'.$params['name'];
1348 $defaultTyposcriptID = 'defaultTS-'.$params['name'];
1349 $checkboxName = 'check['.$params['name'].']';
1350 $checkboxID = $checkboxName;
1351
1352 // Handle type=color specially
1353 if ($typeDat['type']=='color' && substr($params['value'],0,2)!='{$') {
1354 $color = '<div id="colorbox-'.$fN.'" class="typo3-tstemplate-ceditor-colorblock" style="background-color:'.$params['value'].';">&nbsp;</div>';
1355 } else {
1356 $color = '';
1357 }
1358
1359 if (!$this->ext_dontCheckIssetValues) {
1360
1361 /* Set the default styling options */
1362 if(isset($this->objReg[$params['name']])) {
1363 $checkboxValue = 'checked';
1364 $userTyposcriptStyle = '';
1365 $defaultTyposcriptStyle = 'style="display:none;"';
1366 } else {
1367 $checkboxValue = '';
1368 $userTyposcriptStyle = 'style="display:none;"';
1369 $defaultTyposcriptStyle = '';
1370 }
1371
1372
1373 $deleteIconHTML = t3lib_iconWorks::getSpriteIcon('actions-edit-undo',array('class'=>"typo3-tstemplate-ceditor-control undoIcon",'alt'=>"Revert to default Constant",'title'=>"Revert to default Constant",'rel'=>$params['name']));
1374 $editIconHTML = t3lib_iconWorks::getSpriteIcon('actions-document-open',array('class'=>"typo3-tstemplate-ceditor-control editIcon",'alt'=>"Edit this Constant",'title'=>"Edit this Constant",'rel'=>$params['name']));
1375 $constantCheckbox = '<input type="hidden" name="'.$checkboxName.'" id="'.$checkboxID.'" value="'.$checkboxValue.'"/>';
1376
1377 // If there's no default value for the field, use a static label.
1378 if(!$params['default_value']) {
1379 $params['default_value'] = '[Empty]';
1380 }
1381
1382 $constantDefaultRow='<div class="typo3-tstemplate-ceditor-row" id="'.$defaultTyposcriptID.'" '.$defaultTyposcriptStyle.'>'.$editIconHTML.htmlspecialchars($params['default_value']).$color.'</div>';
1383 }
1384
1385 $constantEditRow = '<div class="typo3-tstemplate-ceditor-row" id="'.$userTyposcriptID.'" '.$userTyposcriptStyle.'>'.$deleteIconHTML.$p_field.$color.'</div>';
1386
1387 $constantLabel = '<dt class="typo3-tstemplate-ceditor-label">'.htmlspecialchars($head).'</dt>';
1388 $constantName = '<dt class="typo3-dimmed">['.$params['name'].']</dt>';
1389 $constantDescription = $body ? '<dd>'.htmlspecialchars($body).'</dd>' : '';
1390 $constantData = '<dd>'.$constantCheckbox.$constantEditRow.$constantDefaultRow.'</dd>';
1391
1392 $output.='<a name="'.$raname.'"></a>'.$help['constants'][$params['name']];
1393 $output.='<dl class="typo3-tstemplate-ceditor-constant">'.$constantLabel.$constantName.$constantDescription.$constantData.'</dl>';
1394 } else {
1395 debug('Error. Constant did not exist. Should not happen.');
1396 }
1397 }
1398 }
1399 return $output;
1400 }
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413 /***************************
1414 *
1415 * Processing input values
1416 *
1417 ***************************/
1418
1419 /**
1420 * @param [type] $constants: ...
1421 * @return [type] ...
1422 */
1423 function ext_regObjectPositions($constants) {
1424 // 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
1425 $this->raw = explode(LF,$constants);
1426 $this->rawP=0;
1427
1428 $this->objReg=array(); // resetting the objReg if the divider is found!!
1429 $this->ext_regObjects('');
1430 }
1431
1432 /**
1433 * [Describe function...]
1434 *
1435 * @param [type] $pre: ...
1436 * @return [type] ...
1437 */
1438 function ext_regObjects($pre) {
1439 // works with regObjectPositions. "expands" the names of the TypoScript objects
1440 while (isset($this->raw[$this->rawP])) {
1441 $line = ltrim($this->raw[$this->rawP]);
1442 if (strstr($line,$this->edit_divider)) {
1443 $this->objReg=array(); // resetting the objReg if the divider is found!!
1444 }
1445 $this->rawP++;
1446 if ($line) {
1447 if (substr($line,0,1)=='[') {
1448 // return $line;
1449 } elseif (strcspn($line,'}#/')!=0) {
1450 $varL = strcspn($line,' {=<');
1451 $var=substr($line,0,$varL);
1452 $line = ltrim(substr($line,$varL));
1453 switch(substr($line,0,1)) {
1454 case '=':
1455 $this->objReg[$pre.$var]=$this->rawP-1;
1456 break;
1457 case '{':
1458 $this->ext_inBrace++;
1459 $this->ext_regObjects($pre.$var.'.');
1460 break;
1461 }
1462 $this->lastComment='';
1463 } elseif (substr($line,0,1)=='}') {
1464 $this->lastComment='';
1465 $this->ext_inBrace--;
1466 if ($this->ext_inBrace<0) {
1467 $this->ext_inBrace=0;
1468 } else {
1469 break;
1470 }
1471 }
1472 }
1473 }
1474 }
1475
1476 /**
1477 * [Describe function...]
1478 *
1479 * @param [type] $key: ...
1480 * @param [type] $var: ...
1481 * @return [type] ...
1482 */
1483 function ext_putValueInConf($key, $var) {
1484 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1485 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1486 $theValue = ' '.trim($var);
1487 if (isset($this->objReg[$key])) {
1488 $lineNum = $this->objReg[$key];
1489 $parts = explode('=',$this->raw[$lineNum],2);
1490 if (count($parts)==2) {
1491 $parts[1]= $theValue;
1492 }
1493 $this->raw[$lineNum]=implode($parts,'=');
1494 } else {
1495 $this->raw[]=$key.' ='.$theValue;
1496 }
1497 $this->changed=1;
1498 }
1499
1500 /**
1501 * [Describe function...]
1502 *
1503 * @param [type] $key: ...
1504 * @return [type] ...
1505 */
1506 function ext_removeValueInConf($key) {
1507 // Removes the value in the configuration
1508 if (isset($this->objReg[$key])) {
1509 $lineNum = $this->objReg[$key];
1510 unset($this->raw[$lineNum]);
1511 }
1512 $this->changed=1;
1513 }
1514
1515 /**
1516 * [Describe function...]
1517 *
1518 * @param [type] $arr: ...
1519 * @param [type] $settings: ...
1520 * @return [type] ...
1521 */
1522 function ext_depthKeys($arr,$settings) {
1523 $tsbrArray=array();
1524 foreach ($arr as $theK => $theV) {
1525 $theKeyParts = explode('.',$theK);
1526 $depth='';
1527 $c=count($theKeyParts);
1528 $a=0;
1529 foreach ($theKeyParts as $p) {
1530 $a++;
1531 $depth.=($depth?'.':'').$p;
1532 $tsbrArray[$depth]= ($c==$a) ? $theV : 1;
1533 }
1534 }
1535 // Modify settings
1536 foreach ($tsbrArray as $theK => $theV) {
1537 if ($theV) {
1538 $settings[$theK] = 1;
1539 } else {
1540 unset($settings[$theK]);
1541 }
1542 }
1543 return $settings;
1544 }
1545
1546 /**
1547 * [Describe function...]
1548 *
1549 * @param [type] $http_post_vars: ...
1550 * @param [type] $http_post_files: ...
1551 * @param [type] $theConstants: ...
1552 * @param [type] $tplRow: ...
1553 * @return [type] ...
1554 */
1555 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1556 $data=$http_post_vars['data'];
1557 $check=$http_post_vars['check'];
1558 $copyResource=$http_post_vars['_copyResource'];
1559 $Wdata=$http_post_vars['Wdata'];
1560 $W2data=$http_post_vars['W2data'];
1561 $W3data=$http_post_vars['W3data'];
1562 $W4data=$http_post_vars['W4data'];
1563 $W5data=$http_post_vars['W5data'];
1564
1565 if (is_array($data)) {
1566 foreach ($data as $key => $var) {
1567 if (isset($theConstants[$key])) {
1568 if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // If checkbox is set, update the value
1569 list($var) = explode(LF,$var); // exploding with linebreak, just to make sure that no multiline input is given!
1570 $typeDat=$this->ext_getTypeData($theConstants[$key]['type']);
1571 switch($typeDat['type']) {
1572 case 'int':
1573 if ($typeDat['paramstr']) {
1574 $var=t3lib_div::intInRange($var,$typeDat['params'][0],$typeDat['params'][1]);
1575 } else {
1576 $var=intval($var);
1577 }
1578 break;
1579 case 'int+':
1580 $var = max(0, intval($var));
1581 break;
1582 case 'color':
1583 $col=array();
1584 if($var && !t3lib_div::inList($this->HTMLcolorList,strtolower($var))) {
1585 $var = preg_replace('/[^A-Fa-f0-9]*/','',$var);
1586 $useFullHex = strlen($var) > 3;
1587
1588 $col[]=HexDec(substr($var,0,1));
1589 $col[]=HexDec(substr($var,1,1));
1590 $col[]=HexDec(substr($var,2,1));
1591
1592 if($useFullHex) {
1593 $col[]=HexDec(substr($var,3,1));
1594 $col[]=HexDec(substr($var,4,1));
1595 $col[]=HexDec(substr($var,5,1));
1596 }
1597
1598 $var = substr('0'.DecHex($col[0]),-1).substr('0'.DecHex($col[1]),-1).substr('0'.DecHex($col[2]),-1);
1599 if($useFullHex) {
1600 $var .= substr('0'.DecHex($col[3]),-1).substr('0'.DecHex($col[4]),-1).substr('0'.DecHex($col[5]),-1);
1601 }
1602
1603 $var = '#'.strtoupper($var);
1604 }
1605 break;
1606 case 'comment':
1607 if ($var) {
1608 $var='#';
1609 } else {
1610 $var='';
1611 }
1612 break;
1613 case 'wrap':
1614 if (isset($Wdata[$key])) {
1615 $var.='|'.$Wdata[$key];
1616 }
1617 break;
1618 case 'offset':
1619 if (isset($Wdata[$key])) {
1620 $var=intval($var).','.intval($Wdata[$key]);
1621 if (isset($W2data[$key])) {
1622 $var.=','.intval($W2data[$key]);
1623 if (isset($W3data[$key])) {
1624 $var.=','.intval($W3data[$key]);
1625 if (isset($W4data[$key])) {
1626 $var.=','.intval($W4data[$key]);
1627 if (isset($W5data[$key])) {
1628 $var.=','.intval($W5data[$key]);
1629 }
1630 }
1631 }
1632 }
1633 }
1634 break;
1635 case 'boolean':
1636 if ($var) {
1637 $var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1;
1638 }
1639 break;
1640 case 'file':
1641 if (!$this->ext_noCEUploadAndCopying) {
1642 if ($http_post_files['upload_data']['name'][$key] && $http_post_files['upload_data']['tmp_name'][$key]!='none') {
1643 $var = $this->upload_copy_file(
1644 $typeDat,
1645 $tplRow,
1646 trim($http_post_files['upload_data']['name'][$key]),
1647 $http_post_files['upload_data']['tmp_name'][$key]
1648 );
1649 }
1650 if ($copyResource[$key]) {
1651 $var = $this->upload_copy_file(
1652 $typeDat,
1653 $tplRow,
1654 basename($copyResource[$key]),
1655 $copyResource[$key]
1656 );
1657 }
1658 }
1659 break;
1660 }
1661 if ($this->ext_printAll || strcmp($theConstants[$key]['value'],$var)) {
1662 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1663 }
1664 unset($check[$key]); // Remove the entry because it has been "used"
1665 } else {
1666 $this->ext_removeValueInConf($key);
1667 }
1668 }
1669 }
1670 }
1671 // 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...
1672 if (!$this->ext_dontCheckIssetValues && is_array($check)) {
1673 foreach ($check as $key => $var) {
1674 if (isset($theConstants[$key])) {
1675 $dValue = $theConstants[$key]['default_value'];
1676 $this->ext_putValueInConf($key, $dValue);
1677 }
1678 }
1679 }
1680 }
1681
1682 /**
1683 * [Describe function...]
1684 *
1685 * @param [type] $typeDat: ...
1686 * @param [type] $tplRow: ...
1687 * @param [type] $theRealFileName: ...
1688 * @param [type] $tmp_name: ...
1689 * @return [type] ...
1690 */
1691 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1692
1693 // extensions
1694 $extList = $typeDat['paramstr'];
1695 if ($extList=='IMAGE_EXT') {
1696 $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
1697 }
1698 $fI=t3lib_div::split_fileref($theRealFileName);
1699 if ($theRealFileName && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) {
1700 $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1701
1702 // Saving resource
1703 $alternativeFileName=array();
1704 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1705 // Making list of resources
1706 $resList = $tplRow['resources'];
1707 $resList = $tmp_upload_name.','.$resList;
1708 $resList=implode(t3lib_div::trimExplode(',',$resList,1),',');
1709 // Making data-array
1710 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
1711
1712 $recData=array();
1713 $recData['sys_template'][$saveId]['resources'] = $resList;
1714 // Saving
1715 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1716 $tce->stripslashes_values=0;
1717 $tce->alternativeFileName = $alternativeFileName;
1718 $tce->start($recData,Array());
1719 $tce->process_datamap();
1720
1721 t3lib_div::unlink_tempfile($tmp_upload_name);
1722
1723 $tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template',$saveId,'resources');
1724
1725 $tplRow['resources'] = $tmpRow['resources'];
1726
1727 // Setting the value
1728 $var = $this->ext_setStar($theRealFileName);
1729 }
1730 return $var;
1731 }
1732
1733 /**
1734 * [Describe function...]
1735 *
1736 * @param [type] $id: ...
1737 * @param [type] $perms_clause: ...
1738 * @return [type] ...
1739 */
1740 function ext_prevPageWithTemplate($id,$perms_clause) {
1741 $rootLine = t3lib_BEfunc::BEgetRootLine($id,$perms_clause?' AND '.$perms_clause:'');
1742 foreach ($rootLine as $p) {
1743 if ($this->ext_getFirstTemplate($p['uid'])) {
1744 return $p;
1745 }
1746 }
1747 }
1748
1749 /**
1750 * [Describe function...]
1751 *
1752 * @param [type] $val: ...
1753 * @return [type] ...
1754 */
1755 function ext_setStar($val) {
1756 $fParts = explode('.',strrev($val),2);
1757 $val=preg_replace('/_[0-9][0-9]$/','',strrev($fParts[1])).'*.'.strrev($fParts[0]);
1758 return $val;
1759 }
1760
1761 /**
1762 * [Describe function...]
1763 *
1764 * @param [type] $value: ...
1765 * @return [type] ...
1766 */
1767 function ext_detectAndFixExtensionPrefix($value) {
1768 if (substr($value,0,4)=='EXT:') {
1769 $parts = explode('/',substr($value,4),2);
1770
1771 $extPath = t3lib_extMgm::siteRelPath($parts[0]);
1772 $value = $extPath.$parts[1];
1773 return $value;
1774 } else {
1775 return $value;
1776 }
1777 }
1778 }
1779
1780
1781 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1782 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);
1783 }
1784
1785 ?>