[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_tsparser_ext.php (source)

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


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics