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