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