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