Fixed bug #15188: Remove default greyed out effect for CEs (Thanks to Steffen Gebert)
[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.'&tsbr['.$depth.']='.($deeper?0:1).'#'.$goto;
400 $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
401 }
402
403 $label = $key;
404 if (t3lib_div::inList('types,resources,sitetitle',$depth) && $this->bType=='setup') { // Read only...
405 $label='<font color="#666666">'.$label.'</font>';
406 } else {
407 if ($this->linkObjects) {
408 $aHref = 'index.php?id='.$GLOBALS['SOBE']->id.'&sObj='.$depth;
409 if ($this->bType!='const') {
410 $ln = is_array($arr[$key.'.ln..']) ? 'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A';
411 } else {
412 $ln = '';
413 }
414
415 if ($this->tsbrowser_searchKeys[$depth] & 4) { $label = '<strong><font color="red">'.$label.'</font></strong>'; } // The key has matched the search string
416 $label = '<a href="'.htmlspecialchars($aHref).'" title="'.htmlspecialchars($ln).'">'.$label.'</a>';
417 }
418 }
419
420 $HTML.='['.$label.']';
421
422 if (isset($arr[$key])) {
423 $theValue = $arr[$key];
424 if ($this->fixedLgd) {
425 $imgBlocks = ceil(1+strlen($depthData)/77);
426 $lgdChars = 68-ceil(strlen('['.$key.']')*0.8)-$imgBlocks*3;
427 $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
428 }
429 if ($this->tsbrowser_searchKeys[$depth] & 2) { // The value has matched the search string
430 $HTML.='&nbsp;=&nbsp;<strong><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></strong>';
431 } else {
432 $HTML.='&nbsp;=&nbsp;<strong>'.$this->makeHtmlspecialchars($theValue).'</strong>';
433 }
434 if ($this->ext_regComments && isset($arr[$key.'..'])) {
435 $comment = $arr[$key.'..'];
436 if (!preg_match('/### <INCLUDE_TYPOSCRIPT:.*/', $comment)) { // Skip INCLUDE_TYPOSCRIPT comments, they are almost useless
437 $comment = preg_replace('/[\r\n]/', ' ', $comment); // Remove linebreaks, replace with ' '
438 $comment = preg_replace('/[#\*]{2,}/', '', $comment); // Remove # and * if more than twice in a row
439 $comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a '#'.
440 $comment = $this->makeHtmlspecialchars($comment); // Masking HTML Tags: Replace < with &lt; and > with &gt;
441 $HTML.= ' <span class="comment">'.trim($comment).'</span>';
442 }
443 }
444 }
445 $HTML.='<br />';
446
447 if ($deeper) {
448 $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);
449 }
450 }
451 }
452 return $HTML;
453 }
454
455 /**
456 * [Describe function...]
457 *
458 * @param [type] $lnArr: ...
459 * @return [type] ...
460 */
461 function lineNumberToScript($lnArr) {
462 if (!is_array($this->lnToScript)) {
463 $this->lnToScript = array();
464 $c=1;
465 $c+=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],LF)+2;
466 $this->lnToScript[$c] = '[Default]';
467
468 foreach($this->hierarchyInfoToRoot as $info) {
469 $c+=$info['configLines']+1;
470 $this->lnToScript[$c] = $info['title'];
471 }
472 }
473
474 foreach($lnArr as $k => $ln) {
475 foreach($this->lnToScript as $endLn => $title) {
476 if ($endLn >= intval($ln)) {
477 $lnArr[$k] = '"'.$title.'", '.$ln;
478 break;
479 }
480 }
481 }
482
483 return implode('; ',$lnArr);
484 }
485
486 /**
487 * [Describe function...]
488 *
489 * @param [type] $theValue: ...
490 * @return [type] ...
491 */
492 function makeHtmlspecialchars($theValue){
493 return $this->ext_noSpecialCharsOnLabels ? $theValue : htmlspecialchars($theValue);
494 }
495
496 /**
497 * [Describe function...]
498 *
499 * @param [type] $arr: ...
500 * @param [type] $depth_in: ...
501 * @param [type] $searchString: ...
502 * @param [type] $keyArray: ...
503 * @return [type] ...
504 */
505 function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) {
506 $keyArr=array();
507 foreach ($arr as $key => $value) {
508 $key=preg_replace('/\.$/','',$key);
509 if (substr($key,-1)!='.') {
510 $keyArr[$key]=1;
511 }
512 }
513 $c=count($keyArr);
514 if ($depth_in) { $depth_in = $depth_in.'.'; }
515 foreach ($keyArr as $key => $value) {
516 $depth=$depth_in.$key;
517 $deeper = is_array($arr[$key.'.']);
518
519 if ($this->regexMode) {
520 if (preg_match('/'.$searchString.'/',$arr[$key])) { // The value has matched
521 $this->tsbrowser_searchKeys[$depth]+=2;
522 }
523 if (preg_match('/'.$searchString.'/',$key)) { // The key has matched
524 $this->tsbrowser_searchKeys[$depth]+=4;
525 }
526 if (preg_match('/'.$searchString.'/',$depth_in)) { // Just open this subtree if the parent key has matched the search
527 $this->tsbrowser_searchKeys[$depth]=1;
528 }
529 } else {
530 if (stristr($arr[$key],$searchString)) { // The value has matched
531 $this->tsbrowser_searchKeys[$depth]+=2;
532 }
533 if (stristr($key,$searchString)) { // The key has matches
534 $this->tsbrowser_searchKeys[$depth]+=4;
535 }
536 if (stristr($depth_in,$searchString)) { // Just open this subtree if the parent key has matched the search
537 $this->tsbrowser_searchKeys[$depth]=1;
538 }
539 }
540
541 if ($deeper) {
542 $cS = count($this->tsbrowser_searchKeys);
543 $keyArray = $this->ext_getSearchKeys($arr[$key.'.'], $depth, $searchString, $keyArray);
544 if ($cS != count($this->tsbrowser_searchKeys)) {
545 $keyArray[$depth]=1;
546 }
547 }
548 }
549 return $keyArray;
550 }
551
552 /**
553 * [Describe function...]
554 *
555 * @param [type] $pid: ...
556 * @return [type] ...
557 */
558 function ext_getRootlineNumber($pid) {
559 if ($pid && is_array($GLOBALS['rootLine'])) {
560 foreach ($GLOBALS['rootLine'] as $key => $val) {
561 if ($val['uid']==$pid) return $key;
562 }
563 }
564 }
565
566 /**
567 * [Describe function...]
568 *
569 * @param [type] $arr: ...
570 * @param [type] $depthData: ...
571 * @param [type] $keyArray: ...
572 * @param [type] $first: ...
573 * @return [type] ...
574 */
575 function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) {
576 $keyArr=array();
577 foreach ($arr as $key => $value) {
578 $key=preg_replace('/\.$/','',$key);
579 if (substr($key,-1)!='.') {
580 $keyArr[$key]=1;
581 }
582 }
583 $a=0;
584 $c=count($keyArr);
585 static $i;
586 foreach ($keyArr as $key => $value) {
587 $HTML = '';
588 $a++;
589 $deeper = is_array($arr[$key . '.']);
590 $row = $arr[$key];
591
592 $PM = 'join';
593 $LN = ($a==$c) ? 'blank' : 'line';
594 $BTM = ($a==$c) ? 'top' : '';
595 $PM = 'join';
596
597 $HTML .= $depthData;
598
599 $alttext = '[' . $row['templateID'] . ']';
600 $alttext .= $row['pid'] ? ' - ' . t3lib_BEfunc::getRecordPath($row['pid'], $GLOBALS['SOBE']->perms_clause, 20) : '';
601
602 $icon = (substr($row['templateID'],0,3) == 'sys' ?
603 t3lib_iconWorks::getSpriteIconForRecord('sys_template', $row, array('title' => $alttext))
604 : t3lib_iconWorks::getSpriteIcon('mimetypes-x-content-template-static', array('title' => $alttext))
605 );
606 if (in_array($row['templateID'], $this->clearList_const) || in_array($row['templateID'], $this->clearList_setup)) {
607 $A_B = '<a href="index.php?id=' . $GLOBALS['SOBE']->id . '&template=' . $row['templateID'] . '">';
608 $A_E = '</a>';
609 if (t3lib_div::_GP('template') == $row['templateID']) {
610 $A_B = '<strong>' . $A_B;
611 $A_E .= '</strong>';
612 }
613 } else {
614 $A_B = '';
615 $A_E = '';
616 }
617 $HTML .= ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $PM . $BTM . '.gif" width="18" height="16" align="top" border="0" />') .
618 $icon .
619 $A_B . t3lib_div::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen']) . $A_E . '&nbsp;&nbsp;';
620 $RL = $this->ext_getRootlineNumber($row['pid']);
621 $keyArray[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
622 <td nowrap>' . $HTML . '</td>
623 <td align="center">' . ($row['root'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '&nbsp;&nbsp;</td>
624 <td align="center">' . ($row['clConf'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') :'') . '&nbsp;&nbsp;' . '</td>
625 <td align="center">' . ($row['clConst'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '&nbsp;&nbsp;' . '</td>
626 <td align="center">' . ($row['pid'] ? $row['pid'] : '') . '</td>
627 <td align="center">' . (strcmp($RL, '') ? $RL : '') . '</td>
628 <td>' . ($row['next'] ? '&nbsp;' . $row['next'] . '&nbsp;&nbsp;' : '') . '</td>
629 </tr>';
630 if ($deeper) {
631 $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $LN . '.gif" width="18" height="16" align="top" />'), $keyArray);
632 }
633 }
634 return $keyArray;
635 }
636
637 /**
638 * [Describe function...]
639 *
640 * @param [type] $depthDataArr: ...
641 * @param [type] $pointer: ...
642 * @return [type] ...
643 */
644 function ext_process_hierarchyInfo($depthDataArr,&$pointer) {
645 $parent = $this->hierarchyInfo[$pointer-1]['templateParent'];
646 while ($pointer>0 && $this->hierarchyInfo[$pointer-1]['templateParent']==$parent) {
647 $pointer--;
648 $row = $this->hierarchyInfo[$pointer];
649
650 $depthDataArr[$row['templateID']]=$row;
651 $depthDataArr[$row['templateID']]['bgcolor_setup'] = isset($this->clearList_setup_temp[$row['templateID']])?' class="bgColor5"':'';
652 $depthDataArr[$row['templateID']]['bgcolor_const'] = isset($this->clearList_const_temp[$row['templateID']])?' class="bgColor5"':'';
653 unset($this->clearList_setup_temp[$row['templateID']]);
654 unset($this->clearList_const_temp[$row['templateID']]);
655 $this->templateTitles[$row['templateID']]=$row['title'];
656
657 if ($row['templateID']==$this->hierarchyInfo[$pointer-1]['templateParent']) {
658 $depthDataArr[$row['templateID'].'.'] = $this->ext_process_hierarchyInfo(array(), $pointer);
659 }
660 }
661 return $depthDataArr;
662 }
663
664 /**
665 * [Describe function...]
666 *
667 * @param [type] $config: ...
668 * @param [type] $lineNumbers: ...
669 * @param [type] $comments: ...
670 * @param [type] $crop: ...
671 * @param [type] $syntaxHL: ...
672 * @param [type] $syntaxHLBlockmode: ...
673 * @return [type] ...
674 */
675 function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
676 $all='';
677 foreach ($config as $str) {
678 $all .= LF .'[GLOBAL]' . LF . $str;
679 }
680
681 if ($syntaxHL) {
682 $all = preg_replace('/^[^'.LF.']*./','',$all);
683 $all = chop($all);
684 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
685 $tsparser->lineNumberOffset=$this->ext_lineNumberOffset+1;
686 $tsparser->parentObject = $this;
687 return $tsparser->doSyntaxHighlight($all,$lineNumbers?array($this->ext_lineNumberOffset+1):'',$syntaxHLBlockmode);
688 } else {
689 return $this->ext_formatTS($all,$lineNumbers,$comments,$crop);
690 }
691 }
692
693 /**
694 * Returns a new string of max. $chars lenght
695 * If the string is longer, it will be truncated and prepended with '...'
696 * $chars must be an integer of at least 4
697 *
698 * @param [type] $string: ...
699 * @param [type] $chars: ...
700 * @return [type] ...
701 */
702 function ext_fixed_lgd($string,$chars) {
703 if ($chars >= 4) {
704 if(strlen($string)>$chars) {
705 if(strlen($string)>24 && substr($string,0,12) == '##'.$this->Cmarker.'_B##') {
706 return '##'.$this->Cmarker.'_B##'.t3lib_div::fixed_lgd_cs(substr($string,12,-12), $chars-3).'##'.$this->Cmarker.'_E##';
707 } else {
708 return t3lib_div::fixed_lgd_cs($string, $chars-3);
709 }
710 }
711 }
712 return $string;
713 }
714
715 /**
716 * [Describe function...]
717 *
718 * @param [type] $ln: ...
719 * @param [type] $str: ...
720 * @return [type] ...
721 */
722 function ext_lnBreakPointWrap($ln,$str) {
723 return '<a href="#" onClick="return brPoint('.$ln.','.($this->ext_lineNumberOffset_mode=="setup"?1:0).');">'.$str.'</a>';
724 }
725
726 /**
727 * [Describe function...]
728 *
729 * @param [type] $input: ...
730 * @param [type] $ln: ...
731 * @param [type] $comments: ...
732 * @param [type] $crop: ...
733 * @return [type] ...
734 */
735 function ext_formatTS($input, $ln, $comments=1, $crop=0) {
736 $input = preg_replace('/^[^'.LF.']*./','',$input);
737 $input = chop($input);
738 $cArr = explode(LF,$input);
739
740 $n = ceil(log10(count($cArr)+$this->ext_lineNumberOffset));
741 $lineNum='';
742 foreach ($cArr as $k => $v) {
743 $lln=$k+$this->ext_lineNumberOffset+1;
744 if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(' ','&nbsp;',sprintf('% '.$n.'d',$lln))).': ';
745 $v=htmlspecialchars($v);
746 if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?71:77));}
747 $cArr[$k] = $lineNum.str_replace(' ','&nbsp;',$v);
748
749 $firstChar = substr(trim($v),0,1);
750 if ($firstChar=='[') {
751 $cArr[$k] = '<font color="green"><strong>'.$cArr[$k].'</strong></font>';
752 } elseif ($firstChar=='/' || $firstChar=='#') {
753 if ($comments) {
754 $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
755 } else {
756 unset($cArr[$k]);
757 }
758 }
759
760
761 }
762 $output = implode($cArr, '<br />').'<br />';
763 return $output;
764 }
765
766 /**
767 * [Describe function...]
768 *
769 * @param [type] $id: ...
770 * @param [type] $template_uid: ...
771 * @return [type] ...
772 */
773 function ext_getFirstTemplate($id,$template_uid=0) {
774 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
775 if (intval($id)) {
776 if ($template_uid) {
777 $addC = ' AND uid='.$template_uid;
778 }
779 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause, '', 'sorting', '1');
780 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
781 t3lib_BEfunc::workspaceOL('sys_template',$row);
782 $GLOBALS['TYPO3_DB']->sql_free_result($res);
783 return $row; // Returns the template row if found.
784 }
785 }
786
787 /**
788 * [Describe function...]
789 *
790 * @param [type] $id: ...
791 * @return [type] ...
792 */
793 function ext_getAllTemplates($id) {
794 // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
795 if (intval($id)) {
796 $outRes=array();
797 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause, '', 'sorting');
798 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
799 t3lib_BEfunc::workspaceOL('sys_template',$row);
800 if (is_array($row)) $outRes[] = $row;
801 }
802 $GLOBALS['TYPO3_DB']->sql_free_result($res);
803 return $outRes; // Returns the template rows in an array.
804 }
805 }
806
807 /**
808 * This function compares the flattened constants (default and all).
809 * Returns an array with the constants from the whole template which may be edited by the module.
810 *
811 * @param [type] $default: ...
812 * @return [type] ...
813 */
814 function ext_compareFlatSetups($default) {
815 $editableComments=array();
816 reset($this->flatSetup);
817 foreach ($this->flatSetup as $const => $value) {
818 if (substr($const,-2)!='..' && isset($this->flatSetup[$const.'..'])) {
819 $comment = trim($this->flatSetup[$const.'..']);
820 $c_arr = explode(LF,$comment);
821 foreach ($c_arr as $k => $v) {
822 $line=trim(preg_replace('/^[#\/]*/','',$v));
823 if ($line) {
824 $parts = explode(';', $line);
825 foreach ($parts as $par) {
826 if (strstr($par,'=')) {
827 $keyValPair =explode('=',$par,2);
828 switch(trim(strtolower($keyValPair[0]))) {
829 case 'type':
830 // Type:
831 /*
832 int (range; low-high, list: item,item,item = selector),
833 boolean (check),
834 string (default),
835 wrap,
836 html-color ...,
837 file
838 */
839 $editableComments[$const]['type'] = trim($keyValPair[1]);
840 break;
841 case 'cat':
842 // list of categories.
843 $catSplit=explode('/',strtolower($keyValPair[1]));
844 $editableComments[$const]['cat'] = trim($catSplit[0]);
845 $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.
846 if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) {
847 $editableComments[$const]['subcat_name']=$catSplit[1];
848 $editableComments[$const]['subcat']=$this->subCategories[$catSplit[1]][1].'/'.$catSplit[1].'/'.trim($catSplit[2]).'z';
849 } else {
850 $editableComments[$const]['subcat']='x'.'/'.trim($catSplit[2]).'z';
851 }
852 break;
853 case 'label':
854 // label
855 $editableComments[$const]['label'] = trim($keyValPair[1]);
856 break;
857 case 'customsubcategory':
858 // custom subCategory label
859 $customSubcategory = explode('=',$keyValPair[1],2);
860 if (trim($customSubcategory[0])) {
861 $subCategoryKey = strtolower($customSubcategory[0]);
862 $this->subCategories[$subCategoryKey][0] = $GLOBALS['LANG']->sL($customSubcategory[1]);
863 }
864 break;
865 }
866 }
867 }
868 }
869 }
870 }
871 if (isset($editableComments[$const])) {
872 $editableComments[$const]['name']=$const;
873 $editableComments[$const]['value']=trim($value);
874 if (isset($default[$const])) {
875 $editableComments[$const]['default_value']=trim($default[$const]);
876 }
877 }
878 }
879 return $editableComments;
880 }
881
882 /**
883 * [Describe function...]
884 *
885 * @param [type] $editConstArray: ...
886 * @return [type] ...
887 */
888 function ext_categorizeEditableConstants($editConstArray) {
889 // Runs through the available constants and fills the $this->categories array with pointers and priority-info
890 foreach ($editConstArray as $constName => $constData) {
891 if (!$constData['type']) {
892 $constData['type']='string';
893 }
894 $cats = explode(',',$constData['cat']);
895 foreach ($cats as $theCat) { // if = only one category, while allows for many. We have agreed on only one category is the most basic way...
896 $theCat=trim($theCat);
897 if ($theCat) {
898 $this->categories[$theCat][$constName]=$constData['subcat'];
899 }
900 }
901 }
902 }
903
904 /**
905 * [Describe function...]
906 *
907 * @return [type] ...
908 */
909 function ext_getCategoryLabelArray() {
910 // Returns array used for labels in the menu.
911 $retArr = array();
912 foreach ($this->categories as $k => $v) {
913 if (count($v)) {
914 $retArr[$k]=strtoupper($k).' ('.count($v).')';
915 }
916 }
917 return $retArr;
918 }
919
920 /**
921 * [Describe function...]
922 *
923 * @param [type] $type: ...
924 * @return [type] ...
925 */
926 function ext_getTypeData($type) {
927 $retArr = array();
928 $type=trim($type);
929 if (!$type) {
930 $retArr['type']='string';
931 } else {
932 $m=strcspn ($type,' [');
933 $retArr['type']=strtolower(substr($type,0,$m));
934 if (t3lib_div::inList('int,options,file,boolean,offset,user', $retArr['type'])) {
935 $p=trim(substr($type,$m));
936 $reg = array();
937 preg_match('/\[(.*)\]/',$p,$reg);
938 $p=trim($reg[1]);
939 if ($p) {
940 $retArr['paramstr']=$p;
941 switch($retArr['type']) {
942 case 'int':
943 if (substr($retArr['paramstr'],0,1)=='-') {
944 $retArr['params']=t3lib_div::intExplode('-',substr($retArr['paramstr'],1));
945 $retArr['params'][0]=intval('-'.$retArr['params'][0]);
946 } else {
947 $retArr['params']=t3lib_div::intExplode('-',$retArr['paramstr']);
948 }
949 $retArr['paramstr']=$retArr['params'][0].' - '.$retArr['params'][1];
950 break;
951 case 'options':
952 $retArr['params']=explode(',',$retArr['paramstr']);
953 break;
954 }
955 }
956 }
957 }
958 return $retArr;
959 }
960
961 /**
962 * [Describe function...]
963 *
964 * @param [type] $category: ...
965 * @return [type] ...
966 */
967 function ext_getTSCE_config($category) {
968 $catConf=$this->setup['constants']['TSConstantEditor.'][$category.'.'];
969 $out=array();
970 if (is_array($catConf)) {
971 foreach ($catConf as $key => $val) {
972 switch($key) {
973 case 'image':
974 $out['imagetag'] = $this->ext_getTSCE_config_image($catConf['image']);
975 break;
976 case 'description':
977 case 'bulletlist':
978 case 'header':
979 $out[$key] = $val;
980 break;
981 default:
982 if (t3lib_div::testInt($key)) {
983 $constRefs = explode(',',$val);
984 foreach ($constRefs as $const) {
985 $const=trim($const);
986 if ($const && $const<=20) {
987 $out['constants'][$const].=$this->ext_getKeyImage($key);
988 }
989 }
990 }
991 break;
992 }
993 }
994 }
995 $this->helpConfig=$out;
996 }
997
998 /**
999 * [Describe function...]
1000 *
1001 * @param [type] $key: ...
1002 * @return [type] ...
1003 */
1004 function ext_getKeyImage($key) {
1005 return '<img src="'.$this->ext_localWebGfxPrefix.'gfx/'.$key.'.gif" align="top" hspace=2>';
1006 }
1007
1008 /**
1009 * [Describe function...]
1010 *
1011 * @param [type] $imgConf: ...
1012 * @return [type] ...
1013 */
1014 function ext_getTSCE_config_image($imgConf) {
1015 if (substr($imgConf,0,4)=='gfx/') {
1016 $iFile=$this->ext_localGfxPrefix.$imgConf;
1017 $tFile=$this->ext_localWebGfxPrefix.$imgConf;
1018 } elseif (substr($imgConf,0,4)=='EXT:') {
1019 $iFile = t3lib_div::getFileAbsFileName($imgConf);
1020 if ($iFile) {
1021 $f = substr($iFile,strlen(PATH_site));
1022 $tFile=$GLOBALS['BACK_PATH'].'../'.$f;
1023 }
1024 } else {
1025 $f = 'uploads/tf/'.$this->extractFromResources($this->setup['resources'],$imgConf);
1026 $iFile=PATH_site.$f;
1027 $tFile=$GLOBALS['BACK_PATH'].'../'.$f;
1028 }
1029 $imageInfo=@getImagesize($iFile);
1030 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
1031 }
1032
1033 /**
1034 * [Describe function...]
1035 *
1036 * @return [type] ...
1037 */
1038 function ext_resourceDims() {
1039 if ($this->setup['resources']) {
1040 $rArr=explode(',',$this->setup['resources']);
1041 foreach ($rArr as $c => $val) {
1042 $val=trim($val);
1043 $theFile = PATH_site.'uploads/tf/'.$val;
1044 if ($val && @is_file($theFile)) {
1045 $imgInfo = @getimagesize($theFile);
1046 }
1047 if (is_array($imgInfo)) {
1048 $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')';
1049 }
1050 }
1051 }
1052 foreach ($this->dirResources as $c => $val) {
1053 $val=trim($val);
1054 $imgInfo = @getimagesize(PATH_site.$val);
1055 if (is_array($imgInfo)) {
1056 $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')';
1057 }
1058 }
1059 }
1060
1061 /**
1062 * [Describe function...]
1063 *
1064 * @param [type] $path: ...
1065 * @return [type] ...
1066 */
1067 function ext_readDirResources($path) {
1068 $path = trim($path);
1069 if ($path && strstr($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) {
1070 $path = rtrim($path, '/');
1071 $this->readDirectory(PATH_site . $path);
1072 }
1073 }
1074
1075 /**
1076 * [Describe function...]
1077 *
1078 * @param [type] $path: ...
1079 * @param [type] $type: ...
1080 * @return [type] ...
1081 */
1082 function readDirectory($path,$type='file') {
1083 if(@is_dir($path)) {
1084 $d = @dir($path);
1085 $tempArray=Array();
1086 if (is_object($d)) {
1087 while($entry=$d->read()) {
1088 if ($entry!='.' && $entry!='..') {
1089 $wholePath = $path.'/'.$entry; // Because of odd PHP-error where <BR>-tag is sometimes placed after a filename!!
1090 if (file_exists($wholePath) && (!$type || filetype($wholePath)==$type)) {
1091 $fI = t3lib_div::split_fileref($wholePath);
1092 $this->dirResources[]=substr($wholePath,strlen(PATH_site));
1093 }
1094 }
1095 }
1096 $d->close();
1097 }
1098 }
1099 }
1100
1101 /**
1102 * [Describe function...]
1103 *
1104 * @param [type] $params: ...
1105 * @return [type] ...
1106 */
1107 function ext_fNandV($params) {
1108 $fN='data['.$params['name'].']';
1109 $fV=$params['value'];
1110 if (preg_match('/^{[\$][a-zA-Z0-9\.]*}$/',trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set {
1111 $fV='';
1112 }
1113 $fV=htmlspecialchars($fV);
1114
1115 return array($fN,$fV,$params);
1116 }
1117
1118 /**
1119 * This functions returns the HTML-code that creates the editor-layout of the module.
1120 *
1121 * @param [type] $theConstants: ...
1122 * @param [type] $category: ...
1123 * @return [type] ...
1124 */
1125 function ext_printFields($theConstants,$category) {
1126 reset($theConstants);
1127 $output='<script type="text/javascript" src="'.$GLOBALS['BACK_PATH'].'js/constantEditor.js"></script>
1128 ';
1129 $subcat='';
1130 if (is_array($this->categories[$category])) {
1131
1132 $help=$this->helpConfig;
1133 $this->rArr=explode(',',$this->setup['resources'].','.implode($this->dirResources,','));
1134
1135 if (!$this->doNotSortCategoriesBeforeMakingForm) asort($this->categories[$category]);
1136 foreach ($this->categories[$category] as $name => $type) {
1137 $params = $theConstants[$name];
1138 if (is_array($params)) {
1139 if ($subcat!=$params['subcat_name']) {
1140 $subcat=$params['subcat_name'];
1141 $subcat_name = $params['subcat_name'] ? $this->subCategories[$params['subcat_name']][0] : 'Others';
1142
1143 $output.='<h2 class="typo3-tstemplate-ceditor-subcat">'.$subcat_name.'</h2>';
1144 }
1145
1146 $label=$GLOBALS['LANG']->sL($params['label']);
1147 $label_parts = explode(':',$label,2);
1148 if (count($label_parts)==2) {
1149 $head=trim($label_parts[0]);
1150 $body=trim($label_parts[1]);
1151 } else {
1152 $head=trim($label_parts[0]);
1153 $body='';
1154 }
1155 if (strlen($head)>35) {
1156 if (!$body) {$body=$head;}
1157 $head=t3lib_div::fixed_lgd_cs($head,35);
1158 }
1159 $typeDat=$this->ext_getTypeData($params['type']);
1160 $checked='';
1161 $p_field='';
1162 $raname = substr(md5($params['name']),0,10);
1163 $aname='\''.$raname.'\'';
1164
1165 list($fN,$fV,$params)=$this->ext_fNandV($params);
1166
1167 switch($typeDat['type']) {
1168 case 'int':
1169 case 'int+':
1170 $p_field='<input id="'.$fN.'" type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' onChange="uFormUrl('.$aname.')" />';
1171 if ($typeDat['paramstr']) {
1172 $p_field.=' Range: '.$typeDat['paramstr'];
1173 } elseif ($typeDat['type']=='int+') {
1174 $p_field.=' Range: 0 - ';
1175 } else {
1176 $p_field.=' (Integer)';
1177 }
1178 break;
1179 case 'color':
1180 $colorNames=explode(',',','.$this->HTMLcolorList);
1181 $p_field='';
1182 foreach ($colorNames as $val) {
1183 $sel='';
1184 if ($val==strtolower($params['value'])) {
1185 $sel = ' selected';
1186 }
1187 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.'</option>';
1188 }
1189 $p_field='<select id="select-'.$fN.'" rel="'.$fN.'" name="C'.$fN.'" class="typo3-tstemplate-ceditor-color-select" onChange="uFormUrl('.$aname.');">'.$p_field.'</select>';
1190
1191 $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.')" />';
1192 break;
1193 case 'wrap':
1194 $wArr = explode('|',$fV);
1195 $p_field='<input type="text" id="'.$fN.'" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(29).' onChange="uFormUrl('.$aname.')" />';
1196 $p_field.=' | ';
1197 $p_field.='<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(15).' onChange="uFormUrl('.$aname.')" />';
1198 break;
1199 case 'offset':
1200 $wArr = explode(',',$fV);
1201 $labels = t3lib_div::trimExplode(',',$typeDat['paramstr']);
1202 $p_field=($labels[0]?$labels[0]:'x').':<input type="text" name="'.$fN.'" value="'.$wArr[0].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1203 $p_field.=' , ';
1204 $p_field.=($labels[1]?$labels[1]:'y').':<input type="text" name="W'.$fN.'" value="'.$wArr[1].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1205 for ($aa=2;$aa<count($labels);$aa++) {
1206 if ($labels[$aa]) {
1207 $p_field.=' , '.$labels[$aa].':<input type="text" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' onChange="uFormUrl('.$aname.')" />';
1208 } else {
1209 $p_field.='<input type="hidden" name="W'.$aa.$fN.'" value="'.$wArr[$aa].'" />';
1210 }
1211 }
1212 break;
1213 case 'options':
1214 if (is_array($typeDat['params'])) {
1215 $p_field='';
1216 foreach ($typeDat['params'] as $val) {
1217 $vParts = explode('=',$val,2);
1218 $label = $vParts[0];
1219 $val = isset($vParts[1]) ? $vParts[1] : $vParts[0];
1220
1221 // option tag:
1222 $sel='';
1223 if ($val==$params['value']) {
1224 $sel=' selected';
1225 }
1226 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$GLOBALS['LANG']->sL($label).'</option>';
1227 }
1228 $p_field='<select id="'.$fN.'" name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1229 }
1230 break;
1231 case 'boolean':
1232 $p_field='<input type="hidden" name="'.$fN.'" value="0" />';
1233 $sel='';
1234 if ($fV) {
1235 $sel=' checked';
1236 }
1237 $p_field.='<input id="'.$fN.'" type="checkbox" name="'.$fN.'" value="'.($typeDat['paramstr']?$typeDat['paramstr']:1).'"'.$sel.' onClick="uFormUrl('.$aname.')" />';
1238 break;
1239 case 'comment':
1240 $p_field='<input type="hidden" name="'.$fN.'" value="#" />';
1241 $sel='';
1242 if (!$fV) {
1243 $sel=' checked';
1244 }
1245 $p_field.='<input id="'.$fN.'" type="checkbox" name="'.$fN.'" value=""'.$sel.' onClick="uFormUrl('.$aname.')" />';
1246 break;
1247 case 'file':
1248 $p_field='<option value=""></option>';
1249 $theImage='';
1250 $selectThisFile = $this->extractFromResources($this->setup['resources'],$params['value']);
1251 if ($params['value'] && !$selectThisFile) {
1252 if (in_array($params['value'],$this->dirResources)) {
1253 $selectThisFile=$params['value'];
1254 }
1255 }
1256 // extensionlist
1257 $extList = $typeDat['paramstr'];
1258 $p_field='<option value="">('.$extList.')</option>';
1259 if ($extList=='IMAGE_EXT') {
1260 $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
1261 }
1262 reset($this->rArr);
1263 $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag;
1264
1265 foreach ($this->rArr as $c => $val) {
1266 $val=trim($val);
1267 $fI=t3lib_div::split_fileref($val);
1268 if ($val && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) {
1269 if ($onlineResourceFlag <= 0 && strstr($fI['path'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) {
1270 if ($onlineResourceFlag<0) {
1271 $p_field.='<option value=""></option>';
1272 }
1273 $p_field.='<option value="">__'.$fI['path'].'__:</option>';
1274 $onlineResourceFlag=1;
1275 }
1276 $dims=$this->resourceDimensions[$val];
1277 $sel='';
1278
1279 // Check if $params['value'] is in the list of resources.
1280 if ($selectThisFile && $selectThisFile==$val) {
1281 $sel=' selected';
1282 if ($onlineResourceFlag<=0) {
1283 $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$selectThisFile),'sys_template','resources',$GLOBALS['BACK_PATH'],'');
1284 } else {
1285 $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$fI['file']),'sys_template','resources',$GLOBALS['BACK_PATH'],'',$fI['path']);
1286 }
1287 }
1288
1289 if ($onlineResourceFlag<=0) {
1290 $onlineResourceFlag--;
1291 // Value is set with a *
1292 $val = $this->ext_setStar($val);
1293 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$val.$dims.'</option>';
1294 } else {
1295 $p_field.='<option value="'.htmlspecialchars($val).'"'.$sel.'>'.$fI['file'].$dims.'</option>';
1296 }
1297 }
1298 }
1299
1300 if (trim($params['value']) && !$selectThisFile) {
1301 $val = $params['value'];
1302 $p_field.='<option value=""></option>';
1303 $p_field.='<option value="'.htmlspecialchars($val).'" selected>'.$val.'</option>';
1304 }
1305
1306 $p_field='<select id="'.$fN.'" name="'.$fN.'" onChange="uFormUrl('.$aname.')">'.$p_field.'</select>';
1307 $p_field.=$theImage;
1308
1309 if (!$this->ext_noCEUploadAndCopying) {
1310 // Copy a resource
1311 $copyFile = $this->extractFromResources($this->setup['resources'],$params['value']);
1312 if (!$copyFile) {
1313 if ($params['value']) {
1314 $copyFile=PATH_site.$this->ext_detectAndFixExtensionPrefix($params['value']);
1315 }
1316 } else {
1317 $copyFile='';
1318 }
1319
1320 if ($copyFile && @is_file($copyFile)) {
1321 $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;" />';
1322 }
1323
1324 // Upload?
1325 $p_field.='<br />';
1326 $p_field.='<input id="'.$fN.'" type="file" name="upload_'.$fN.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
1327 }
1328 break;
1329 case 'user':
1330 $userFunction = $typeDat['paramstr'];
1331 $userFunctionParams = array('fieldName' => $fN, 'fieldValue' => $fV);
1332 $p_field = t3lib_div::callUserFunction($userFunction, $userFunctionParams, $this, '');
1333 break;
1334 case 'small':
1335 default:
1336 $fwidth= $typeDat['type']=='small' ? 10 : 46;
1337 $p_field='<input id="'.$fN.'" type="text" name="'.$fN.'" value="'.$fV.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($fwidth).' onChange="uFormUrl('.$aname.')" />';
1338 break;
1339 }
1340
1341 // Define default names and IDs
1342 $userTyposcriptID = 'userTS-'.$params['name'];
1343 $defaultTyposcriptID = 'defaultTS-'.$params['name'];
1344 $checkboxName = 'check['.$params['name'].']';
1345 $checkboxID = $checkboxName;
1346
1347 // Handle type=color specially
1348 if ($typeDat['type']=='color' && substr($params['value'],0,2)!='{$') {
1349 $color = '<div id="colorbox-'.$fN.'" class="typo3-tstemplate-ceditor-colorblock" style="background-color:'.$params['value'].';">&nbsp;</div>';
1350 } else {
1351 $color = '';
1352 }
1353
1354 if (!$this->ext_dontCheckIssetValues) {
1355
1356 /* Set the default styling options */
1357 if(isset($this->objReg[$params['name']])) {
1358 $checkboxValue = 'checked';
1359 $userTyposcriptStyle = '';
1360 $defaultTyposcriptStyle = 'style="display:none;"';
1361 } else {
1362 $checkboxValue = '';
1363 $userTyposcriptStyle = 'style="display:none;"';
1364 $defaultTyposcriptStyle = '';
1365 }
1366
1367
1368 $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']));
1369 $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']));
1370 $constantCheckbox = '<input type="hidden" name="'.$checkboxName.'" id="'.$checkboxID.'" value="'.$checkboxValue.'"/>';
1371
1372 // If there's no default value for the field, use a static label.
1373 if(!$params['default_value']) {
1374 $params['default_value'] = '[Empty]';
1375 }
1376
1377 $constantDefaultRow='<div class="typo3-tstemplate-ceditor-row" id="'.$defaultTyposcriptID.'" '.$defaultTyposcriptStyle.'>'.$editIconHTML.htmlspecialchars($params['default_value']).$color.'</div>';
1378 }
1379
1380 $constantEditRow = '<div class="typo3-tstemplate-ceditor-row" id="'.$userTyposcriptID.'" '.$userTyposcriptStyle.'>'.$deleteIconHTML.$p_field.$color.'</div>';
1381
1382 $constantLabel = '<dt class="typo3-tstemplate-ceditor-label">'.htmlspecialchars($head).'</dt>';
1383 $constantName = '<dt class="typo3-dimmed">['.$params['name'].']</dt>';
1384 $constantDescription = $body ? '<dd>'.htmlspecialchars($body).'</dd>' : '';
1385 $constantData = '<dd>'.$constantCheckbox.$constantEditRow.$constantDefaultRow.'</dd>';
1386
1387 $output.='<a name="'.$raname.'"></a>'.$help['constants'][$params['name']];
1388 $output.='<dl class="typo3-tstemplate-ceditor-constant">'.$constantLabel.$constantName.$constantDescription.$constantData.'</dl>';
1389 } else {
1390 debug('Error. Constant did not exist. Should not happen.');
1391 }
1392 }
1393 }
1394 return $output;
1395 }
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408 /***************************
1409 *
1410 * Processing input values
1411 *
1412 ***************************/
1413
1414 /**
1415 * @param [type] $constants: ...
1416 * @return [type] ...
1417 */
1418 function ext_regObjectPositions($constants) {
1419 // 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
1420 $this->raw = explode(LF,$constants);
1421 $this->rawP=0;
1422
1423 $this->objReg=array(); // resetting the objReg if the divider is found!!
1424 $this->ext_regObjects('');
1425 }
1426
1427 /**
1428 * [Describe function...]
1429 *
1430 * @param [type] $pre: ...
1431 * @return [type] ...
1432 */
1433 function ext_regObjects($pre) {
1434 // works with regObjectPositions. "expands" the names of the TypoScript objects
1435 while (isset($this->raw[$this->rawP])) {
1436 $line = ltrim($this->raw[$this->rawP]);
1437 if (strstr($line,$this->edit_divider)) {
1438 $this->objReg=array(); // resetting the objReg if the divider is found!!
1439 }
1440 $this->rawP++;
1441 if ($line) {
1442 if (substr($line,0,1)=='[') {
1443 // return $line;
1444 } elseif (strcspn($line,'}#/')!=0) {
1445 $varL = strcspn($line,' {=<');
1446 $var=substr($line,0,$varL);
1447 $line = ltrim(substr($line,$varL));
1448 switch(substr($line,0,1)) {
1449 case '=':
1450 $this->objReg[$pre.$var]=$this->rawP-1;
1451 break;
1452 case '{':
1453 $this->ext_inBrace++;
1454 $this->ext_regObjects($pre.$var.'.');
1455 break;
1456 }
1457 $this->lastComment='';
1458 } elseif (substr($line,0,1)=='}') {
1459 $this->lastComment='';
1460 $this->ext_inBrace--;
1461 if ($this->ext_inBrace<0) {
1462 $this->ext_inBrace=0;
1463 } else {
1464 break;
1465 }
1466 }
1467 }
1468 }
1469 }
1470
1471 /**
1472 * [Describe function...]
1473 *
1474 * @param [type] $key: ...
1475 * @param [type] $var: ...
1476 * @return [type] ...
1477 */
1478 function ext_putValueInConf($key, $var) {
1479 // Puts the value $var to the TypoScript value $key in the current lines of the templates.
1480 // If the $key is not found in the template constants field, a new line is inserted in the bottom.
1481 $theValue = ' '.trim($var);
1482 if (isset($this->objReg[$key])) {
1483 $lineNum = $this->objReg[$key];
1484 $parts = explode('=',$this->raw[$lineNum],2);
1485 if (count($parts)==2) {
1486 $parts[1]= $theValue;
1487 }
1488 $this->raw[$lineNum]=implode($parts,'=');
1489 } else {
1490 $this->raw[]=$key.' ='.$theValue;
1491 }
1492 $this->changed=1;
1493 }
1494
1495 /**
1496 * [Describe function...]
1497 *
1498 * @param [type] $key: ...
1499 * @return [type] ...
1500 */
1501 function ext_removeValueInConf($key) {
1502 // Removes the value in the configuration
1503 if (isset($this->objReg[$key])) {
1504 $lineNum = $this->objReg[$key];
1505 unset($this->raw[$lineNum]);
1506 }
1507 $this->changed=1;
1508 }
1509
1510 /**
1511 * [Describe function...]
1512 *
1513 * @param [type] $arr: ...
1514 * @param [type] $settings: ...
1515 * @return [type] ...
1516 */
1517 function ext_depthKeys($arr,$settings) {
1518 $tsbrArray=array();
1519 foreach ($arr as $theK => $theV) {
1520 $theKeyParts = explode('.',$theK);
1521 $depth='';
1522 $c=count($theKeyParts);
1523 $a=0;
1524 foreach ($theKeyParts as $p) {
1525 $a++;
1526 $depth.=($depth?'.':'').$p;
1527 $tsbrArray[$depth]= ($c==$a) ? $theV : 1;
1528 }
1529 }
1530 // Modify settings
1531 foreach ($tsbrArray as $theK => $theV) {
1532 if ($theV) {
1533 $settings[$theK] = 1;
1534 } else {
1535 unset($settings[$theK]);
1536 }
1537 }
1538 return $settings;
1539 }
1540
1541 /**
1542 * [Describe function...]
1543 *
1544 * @param [type] $http_post_vars: ...
1545 * @param [type] $http_post_files: ...
1546 * @param [type] $theConstants: ...
1547 * @param [type] $tplRow: ...
1548 * @return [type] ...
1549 */
1550 function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) {
1551 $data=$http_post_vars['data'];
1552 $check=$http_post_vars['check'];
1553 $copyResource=$http_post_vars['_copyResource'];
1554 $Wdata=$http_post_vars['Wdata'];
1555 $W2data=$http_post_vars['W2data'];
1556 $W3data=$http_post_vars['W3data'];
1557 $W4data=$http_post_vars['W4data'];
1558 $W5data=$http_post_vars['W5data'];
1559
1560 if (is_array($data)) {
1561 foreach ($data as $key => $var) {
1562 if (isset($theConstants[$key])) {
1563 if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // If checkbox is set, update the value
1564 list($var) = explode(LF,$var); // exploding with linebreak, just to make sure that no multiline input is given!
1565 $typeDat=$this->ext_getTypeData($theConstants[$key]['type']);
1566 switch($typeDat['type']) {
1567 case 'int':
1568 if ($typeDat['paramstr']) {
1569 $var=t3lib_div::intInRange($var,$typeDat['params'][0],$typeDat['params'][1]);
1570 } else {
1571 $var=intval($var);
1572 }
1573 break;
1574 case 'int+':
1575 $var = max(0, intval($var));
1576 break;
1577 case 'color':
1578 $col=array();
1579 if($var && !t3lib_div::inList($this->HTMLcolorList,strtolower($var))) {
1580 $var = preg_replace('/[^A-Fa-f0-9]*/','',$var);
1581 $useFullHex = strlen($var) > 3;
1582
1583 $col[]=HexDec(substr($var,0,1));
1584 $col[]=HexDec(substr($var,1,1));
1585 $col[]=HexDec(substr($var,2,1));
1586
1587 if($useFullHex) {
1588 $col[]=HexDec(substr($var,3,1));
1589 $col[]=HexDec(substr($var,4,1));
1590 $col[]=HexDec(substr($var,5,1));
1591 }
1592
1593 $var = substr('0'.DecHex($col[0]),-1).substr('0'.DecHex($col[1]),-1).substr('0'.DecHex($col[2]),-1);
1594 if($useFullHex) {
1595 $var .= substr('0'.DecHex($col[3]),-1).substr('0'.DecHex($col[4]),-1).substr('0'.DecHex($col[5]),-1);
1596 }
1597
1598 $var = '#'.strtoupper($var);
1599 }
1600 break;
1601 case 'comment':
1602 if ($var) {
1603 $var='#';
1604 } else {
1605 $var='';
1606 }
1607 break;
1608 case 'wrap':
1609 if (isset($Wdata[$key])) {
1610 $var.='|'.$Wdata[$key];
1611 }
1612 break;
1613 case 'offset':
1614 if (isset($Wdata[$key])) {
1615 $var=intval($var).','.intval($Wdata[$key]);
1616 if (isset($W2data[$key])) {
1617 $var.=','.intval($W2data[$key]);
1618 if (isset($W3data[$key])) {
1619 $var.=','.intval($W3data[$key]);
1620 if (isset($W4data[$key])) {
1621 $var.=','.intval($W4data[$key]);
1622 if (isset($W5data[$key])) {
1623 $var.=','.intval($W5data[$key]);
1624 }
1625 }
1626 }
1627 }
1628 }
1629 break;
1630 case 'boolean':
1631 if ($var) {
1632 $var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1;
1633 }
1634 break;
1635 case 'file':
1636 if (!$this->ext_noCEUploadAndCopying) {
1637 if ($http_post_files['upload_data']['name'][$key] && $http_post_files['upload_data']['tmp_name'][$key]!='none') {
1638 $var = $this->upload_copy_file(
1639 $typeDat,
1640 $tplRow,
1641 trim($http_post_files['upload_data']['name'][$key]),
1642 $http_post_files['upload_data']['tmp_name'][$key]
1643 );
1644 }
1645 if ($copyResource[$key]) {
1646 $var = $this->upload_copy_file(
1647 $typeDat,
1648 $tplRow,
1649 basename($copyResource[$key]),
1650 $copyResource[$key]
1651 );
1652 }
1653 }
1654 break;
1655 }
1656 if ($this->ext_printAll || strcmp($theConstants[$key]['value'],$var)) {
1657 $this->ext_putValueInConf($key, $var); // Put value in, if changed.
1658 }
1659 unset($check[$key]); // Remove the entry because it has been "used"
1660 } else {
1661 $this->ext_removeValueInConf($key);
1662 }
1663 }
1664 }
1665 }
1666 // 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...
1667 if (!$this->ext_dontCheckIssetValues && is_array($check)) {
1668 foreach ($check as $key => $var) {
1669 if (isset($theConstants[$key])) {
1670 $dValue = $theConstants[$key]['default_value'];
1671 $this->ext_putValueInConf($key, $dValue);
1672 }
1673 }
1674 }
1675 }
1676
1677 /**
1678 * [Describe function...]
1679 *
1680 * @param [type] $typeDat: ...
1681 * @param [type] $tplRow: ...
1682 * @param [type] $theRealFileName: ...
1683 * @param [type] $tmp_name: ...
1684 * @return [type] ...
1685 */
1686 function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
1687
1688 // extensions
1689 $extList = $typeDat['paramstr'];
1690 if ($extList=='IMAGE_EXT') {
1691 $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
1692 }
1693 $fI=t3lib_div::split_fileref($theRealFileName);
1694 if ($theRealFileName && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) {
1695 $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode.
1696
1697 // Saving resource
1698 $alternativeFileName=array();
1699 $alternativeFileName[$tmp_upload_name] = $theRealFileName;
1700 // Making list of resources
1701 $resList = $tplRow['resources'];
1702 $resList = $tmp_upload_name.','.$resList;
1703 $resList=implode(t3lib_div::trimExplode(',',$resList,1),',');
1704 // Making data-array
1705 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
1706
1707 $recData=array();
1708 $recData['sys_template'][$saveId]['resources'] = $resList;
1709 // Saving
1710 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1711 $tce->stripslashes_values=0;
1712 $tce->alternativeFileName = $alternativeFileName;
1713 $tce->start($recData,Array());
1714 $tce->process_datamap();
1715
1716 t3lib_div::unlink_tempfile($tmp_upload_name);
1717
1718 $tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template',$saveId,'resources');
1719
1720 $tplRow['resources'] = $tmpRow['resources'];
1721
1722 // Setting the value
1723 $var = $this->ext_setStar($theRealFileName);
1724 }
1725 return $var;
1726 }
1727
1728 /**
1729 * [Describe function...]
1730 *
1731 * @param [type] $id: ...
1732 * @param [type] $perms_clause: ...
1733 * @return [type] ...
1734 */
1735 function ext_prevPageWithTemplate($id,$perms_clause) {
1736 $rootLine = t3lib_BEfunc::BEgetRootLine($id,$perms_clause?' AND '.$perms_clause:'');
1737 foreach ($rootLine as $p) {
1738 if ($this->ext_getFirstTemplate($p['uid'])) {
1739 return $p;
1740 }
1741 }
1742 }
1743
1744 /**
1745 * [Describe function...]
1746 *
1747 * @param [type] $val: ...
1748 * @return [type] ...
1749 */
1750 function ext_setStar($val) {
1751 $fParts = explode('.',strrev($val),2);
1752 $val=preg_replace('/_[0-9][0-9]$/','',strrev($fParts[1])).'*.'.strrev($fParts[0]);
1753 return $val;
1754 }
1755
1756 /**
1757 * [Describe function...]
1758 *
1759 * @param [type] $value: ...
1760 * @return [type] ...
1761 */
1762 function ext_detectAndFixExtensionPrefix($value) {
1763 if (substr($value,0,4)=='EXT:') {
1764 $parts = explode('/',substr($value,4),2);
1765
1766 $extPath = t3lib_extMgm::siteRelPath($parts[0]);
1767 $value = $extPath.$parts[1];
1768 return $value;
1769 } else {
1770 return $value;
1771 }
1772 }
1773 }
1774
1775
1776 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) {
1777 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);
1778 }
1779
1780 ?>