Documentation TYPO3 par Ameos

class.tx_kickstarter_compilefiles.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2001-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00034 class tx_kickstarter_compilefiles {
00035 
00036                 // Internal:
00037         var $fileArray=array();
00038         var $ext_tables=array();
00039         var $ext_tca=array();
00040         var $ext_tables_sql=array();
00041         var $ext_localconf=array();
00042         var $ext_locallang=array();
00043         var $ext_locallang_db=array();
00044 
00045         var $extKey="";
00046 
00047         var $charMaxLng = 2;    // Varchars are created instead of chars when over this length.
00048 
00049 
00050         function makeFilesArray($extKey)        {
00051 
00052                 $this->ext_localconf=array();
00053                 $this->ext_tables=array();
00054                 $this->fileArray=array();
00055 
00056                         // TSconfig?
00057                 if (is_array($this->wizArray["TSconfig"]))      {
00058                         $content = current($this->wizArray["TSconfig"]);
00059                                 // Page TSconfig:
00060                         if (trim($content["page_TSconfig"]))    {
00061                                 $this->ext_localconf[]=trim($this->wrapBody("
00062                                         t3lib_extMgm::addPageTSConfig('
00063                                         ",trim($this->slashValueForSingleDashes($content["page_TSconfig"])),"
00064                                         ');
00065                                 "));
00066                         }
00067                                 // User TSconfig:
00068                         if (trim($content["user_TSconfig"]))    {
00069                                 $this->ext_localconf[]=trim($this->wrapBody("
00070                                         t3lib_extMgm::addUserTSConfig('
00071                                         ",trim($this->slashValueForSingleDashes($content["user_TSconfig"])),"
00072                                         ');
00073                                 "));
00074                         }
00075                 }
00076 
00077                         // TypoScript
00078                 if (is_array($this->wizArray["ts"]))    {
00079                         $content = current($this->wizArray["ts"]);
00080                                 // Page TSconfig:
00081                         if (trim($content["constants"]))        {
00082                                 $this->addFileToFileArray("ext_typoscript_constants.txt",$content["constants"],1);
00083                                 $this->EM_CONF_presets["clearCacheOnLoad"]=1;
00084                         }
00085                                 // User TSconfig:
00086                         if (trim($content["setup"]))    {
00087                                 $this->addFileToFileArray("ext_typoscript_setup.txt",$content["setup"],1);
00088                                 $this->EM_CONF_presets["clearCacheOnLoad"]=1;
00089 #debug(array($this->fileArray["ext_typoscript_setup.txt"]));
00090                         }
00091                 }
00092 
00093                 if (is_array($this->wizArray["module"]))        {
00094                         reset($this->wizArray["module"]);
00095                         while(list($k,$config)=each($this->wizArray["module"])) {
00096                                 $this->renderExtPart_module($k,$config,$extKey);
00097                         }
00098                 }
00099 
00100                 if (is_array($this->wizArray["moduleFunction"]))        {
00101                         reset($this->wizArray["moduleFunction"]);
00102                         while(list($k,$config)=each($this->wizArray["moduleFunction"])) {
00103                                 $this->renderExtPart_moduleFunction($k,$config,$extKey);
00104                         }
00105                 }
00106 
00107                 if (is_array($this->wizArray["cm"]))    {
00108                         reset($this->wizArray["cm"]);
00109                         while(list($k,$config)=each($this->wizArray["cm"]))     {
00110                                 $this->renderExtPart_cm($k,$config,$extKey);
00111                         }
00112                 }
00113 
00114                 // This should be BEFORE PI.
00115                 if (is_array($this->wizArray["fields"]))        {
00116                         reset($this->wizArray["fields"]);
00117                         while(list($k,$config)=each($this->wizArray["fields"])) {
00118                                 $this->renderExtPart_fields($k,$config,$extKey);
00119                                 $this->EM_CONF_presets["modify_tables"][]=$config["which_table"];
00120                         }
00121                 }
00122 
00123                 if (is_array($this->wizArray["tables"]))        {
00124                         reset($this->wizArray["tables"]);
00125                         while(list($k,$config)=each($this->wizArray["tables"])) {
00126                                 $this->renderExtPart_tables($k,$config,$extKey);
00127                         }
00128                 }
00129 
00130                 if (is_array($this->wizArray["pi"]))    {
00131                         reset($this->wizArray["pi"]);
00132                         while(list($k,$config)=each($this->wizArray["pi"]))     {
00133                                 $this->renderExtPart_PI($k,$config,$extKey);
00134                                 $this->EM_CONF_presets["clearCacheOnLoad"]=1;
00135                         }
00136                         $this->EM_CONF_presets["dependencies"][]="cms";
00137                 }
00138 
00139                 if (is_array($this->wizArray["sv"]))    {
00140                         reset($this->wizArray["sv"]);
00141                         while(list($k,$config)=each($this->wizArray["sv"]))     {
00142                                 $this->renderExtPart_SV($k,$config,$extKey);
00143                                 $this->EM_CONF_presets["clearCacheOnLoad"]=1;
00144                         }
00145                 }
00146 
00147                 // Write the ext_localconf.php file:
00148                 if (count($this->ext_localconf))        {
00149                         $this->addFileToFileArray("ext_localconf.php",trim($this->wrapBody('
00150                                 <?php
00151                                 if (!defined ("TYPO3_MODE"))    die ("Access denied.");
00152                                         ',
00153                                 implode(chr(10),$this->ext_localconf),
00154                                 '?>
00155                         ',0)));
00156                 }
00157                 // Write the ext_tables.php file:
00158                 if (count($this->ext_tables))   {
00159                         $this->addFileToFileArray("ext_tables.php",trim($this->wrapBody('
00160                                 <?php
00161                                 if (!defined ("TYPO3_MODE"))    die ("Access denied.");
00162 
00163                                 ',implode(chr(10),$this->ext_tables),'
00164                                 ?>
00165                         ',0)));
00166                 }
00167                 // Write the tca.php file:
00168                 if (count($this->ext_tca))      {
00169                         $this->addFileToFileArray("tca.php",trim($this->wrapBody('
00170                                 <?php
00171                                 if (!defined ("TYPO3_MODE"))    die ("Access denied.");
00172 
00173                                 ',implode(chr(10),$this->ext_tca),'
00174                                 ?>
00175                         ',0)));
00176                 }
00177                 // Write the ext_tables.sql file:
00178                 if (count($this->ext_tables_sql))       {
00179                         $this->addFileToFileArray("ext_tables.sql",trim($this->sPS(implode(chr(10),$this->ext_tables_sql))));
00180                 }
00181                 // Local lang file:
00182                 if (count($this->ext_locallang))        {
00183                         $this->addLocalLangFile($this->ext_locallang,"locallang.php",'Language labels for extension "'.$extKey.'"');
00184                 }
00185                 // Local lang DB file:
00186                 if (count($this->ext_locallang_db))     {
00187                         $this->addLocalLangFile($this->ext_locallang_db,"locallang_db.php",'Language labels for database tables/fields belonging to extension "'.$extKey.'"');
00188                 }
00189 
00190                 // The form used to generate the extension:
00191                 $this->dontPrintImages = 1;
00192                 $this->addFileToFileArray("doc/wizard_form.html",trim($this->sPS('
00193                         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00194 
00195                         <html>
00196                         <head>
00197                                 <title>Untitled</title>
00198                         </head>
00199 
00200                         <body>
00201 
00202                                 '.$this->totalForm().'
00203                         </body>
00204                         </html>
00205                 ')));
00206                 $this->addFileToFileArray("doc/wizard_form.dat",serialize($this->wizArray));
00207 
00208                         // icon:
00209                 $this->addFileToFileArray("ext_icon.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/notfound.gif"));
00210 
00211 
00212 #               debug($this->wizArray);
00213 #               debug ($this->fileArray);
00214 #               return $dataArr;
00215         }
00216 
00217 
00218         function addLocalLangFile($arr,$filename,$description)  {
00219                 $lines=array();
00220                 reset($arr);
00221                 $lines[]='<?php';
00222                 $lines[]=trim($this->sPS('
00228                 '));
00229                 $lines[]='';
00230                 $lines[]='$LOCAL_LANG = Array (';
00231                 while(list($lK,$labels)=each($arr))     {
00232                         if (is_array($labels))  {
00233                                 $lines[]='      "'.$lK.'" => Array (';
00234                                 while(list($l,$v)=each($labels))        {
00235                                         if (strcmp($v[0],""))   $lines[]='              "'.$l.'" => "'.addslashes($v[0]).'",    '.$this->WOPcomment($v[1]);
00236                                 }
00237                                 $lines[]='      ),';
00238                         }
00239                 }
00240                 $lines[]=');';
00241                 $lines[]='?>';
00242                 $this->addFileToFileArray($filename,implode(chr(10),$lines));
00243         }
00244 
00248         function renderExtPart_fields($k,$config,$extKey)       {
00249                 $WOP="[fields][".$k."]";
00250                 $tableName=$config["which_table"];
00251         #       $tableName = $this->returnName($extKey,"fields",$tableName);
00252 #               $prefix = "tx_".str_replace("_","",$extKey)."_";
00253                 $prefix = $this->returnName($extKey,"fields")."_";
00254 
00255                 $DBfields=array();
00256                 $columns=array();
00257                 $ctrl=array();
00258                 $enFields=array();
00259 
00260                 if (is_array($config["fields"]))        {
00261                         reset($config["fields"]);
00262                         while(list($i,$fConf)=each($config["fields"]))  {
00263                                 $fConf["fieldname"] = $prefix.$fConf["fieldname"];
00264                                 $this->makeFieldTCA($DBfields,$columns,$fConf,$WOP."[fields][".$i."]",$tableName,$extKey);
00265                         }
00266                 }
00267 
00268                 if ($tableName=="tt_address")   $this->EM_CONF_presets["dependencies"][]="tt_address";
00269                 if ($tableName=="tt_news")      $this->EM_CONF_presets["dependencies"][]="tt_news";
00270                 if (t3lib_div::inList("tt_content,fe_users,fe_groups",$tableName))      $this->EM_CONF_presets["dependencies"][]="cms";
00271 
00272                 $createTable = $this->wrapBody('
00273                         #
00274                         # Table structure for table \''.$tableName.'\'
00275                         #
00276                         CREATE TABLE '.$tableName.' (
00277                 ', ereg_replace(",[[:space:]]*$","",implode(chr(10),$DBfields)), '
00278 
00279                         );
00280                 ');
00281                 $this->ext_tables_sql[]=chr(10).$createTable.chr(10);
00282 
00283 
00284                         // Finalize ext_tables.php:
00285                 $this->ext_tables[]=$this->wrapBody('
00286                         $tempColumns = Array (
00287                                 ', implode(chr(10),$columns)    ,'
00288                         );
00289                 ');
00290 
00291 
00292                 list($typeList) = $this->implodeColumns($columns);
00293                 $applyToAll=1;
00294                 if (is_array($this->wizArray["pi"]))    {
00295                         reset($this->wizArray["pi"]);
00296                         while(list(,$fC)=each($this->wizArray["pi"]))   {
00297                                 if ($fC["apply_extended"]==$k)  {
00298                                         $applyToAll=0;
00299                                         $this->_apply_extended_types[$k]=$typeList;
00300                                 }
00301                         }
00302                 }
00303                 $this->ext_tables[]=$this->sPS('
00304                         t3lib_div::loadTCA("'.$tableName.'");
00305                         t3lib_extMgm::addTCAcolumns("'.$tableName.'",$tempColumns,1);
00306                         '.($applyToAll?'t3lib_extMgm::addToAllTCAtypes("'.$tableName.'","'.$typeList.'");':'').'
00307                 ');
00308         }
00309 
00313         function renderExtPart_tables($k,$config,$extKey)       {
00314                 $WOP="[tables][".$k."]";
00315                 $tableName=$config["tablename"];
00316                 $tableName = $this->returnName($extKey,"tables",$tableName);
00317 
00318                 $DBfields=array();
00319                 $columns=array();
00320                 $ctrl=array();
00321                 $enFields=array();
00322 
00323 //str_replace("\\'","'",addslashes($this->getSplitLabels($config,"title")))
00324                 $ctrl[] = trim($this->sPS('
00325                         "title" => "'.$this->getSplitLabels_reference($config,"title",$tableName).'",           '.$this->WOPcomment('WOP:'.$WOP.'[title]').'
00326                         "label" => "'.($config["header_field"]?$config["header_field"]:"uid").'",       '.$this->WOPcomment('WOP:'.$WOP.'[header_field]').'
00327                         "tstamp" => "tstamp",
00328                         "crdate" => "crdate",
00329                         "cruser_id" => "cruser_id",
00330                 ',0));
00331                 $DBfields[] = trim($this->sPS("
00332                         uid int(11) DEFAULT '0' NOT NULL auto_increment,
00333                         pid int(11) DEFAULT '0' NOT NULL,
00334                         tstamp int(11) unsigned DEFAULT '0' NOT NULL,
00335                         crdate int(11) unsigned DEFAULT '0' NOT NULL,
00336                         cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
00337                 ",0));
00338 
00339                 if ($config["type_field"])      {
00340                         $ctrl[] = '"type" => "'.$config["type_field"].'",       '.$this->WOPcomment('WOP:'.$WOP.'[type_field]');
00341                 }
00342                 if ($config["versioning"])      {
00343                         $ctrl[] = '"versioning" => "1", '.$this->WOPcomment('WOP:'.$WOP.'[versioning]');
00344                         $DBfields[] = "t3ver_oid int(11) unsigned DEFAULT '0' NOT NULL,";
00345                         $DBfields[] = "t3ver_id int(11) unsigned DEFAULT '0' NOT NULL,";
00346                         $DBfields[] = "t3ver_label varchar(30) DEFAULT '' NOT NULL,";
00347                 }
00348                 if ($config["localization"])    {
00349                         $ctrl[] = '"languageField" => "sys_language_uid",       '.$this->WOPcomment('WOP:'.$WOP.'[localization]');
00350                         $ctrl[] = '"transOrigPointerField" => "l18n_parent",    '.$this->WOPcomment('WOP:'.$WOP.'[localization]');
00351                         $ctrl[] = '"transOrigDiffSourceField" => "l18n_diffsource",     '.$this->WOPcomment('WOP:'.$WOP.'[localization]');
00352 
00353                         $DBfields[] = "sys_language_uid int(11) DEFAULT '0' NOT NULL,";
00354                         $DBfields[] = "l18n_parent int(11) DEFAULT '0' NOT NULL,";
00355                         $DBfields[] = "l18n_diffsource mediumblob NOT NULL,";
00356 
00357                         $columns["sys_language_uid"] = trim($this->sPS("
00358                                 'sys_language_uid' => Array (           ".$this->WOPcomment('WOP:'.$WOP.'[localization]')."
00359                                         'exclude' => 1,
00360                                         'label' => 'LLL:EXT:lang/locallang_general.php:LGL.language',
00361                                         'config' => Array (
00362                                                 'type' => 'select',
00363                                                 'foreign_table' => 'sys_language',
00364                                                 'foreign_table_where' => 'ORDER BY sys_language.title',
00365                                                 'items' => Array(
00366                                                         Array('LLL:EXT:lang/locallang_general.php:LGL.allLanguages',-1),
00367                                                         Array('LLL:EXT:lang/locallang_general.php:LGL.default_value',0)
00368                                                 )
00369                                         )
00370                                 ),
00371                         "));
00372 
00373                         $columns["l18n_parent"] = trim($this->sPS("
00374                                 'l18n_parent' => Array (                ".$this->WOPcomment('WOP:'.$WOP.'[localization]')."
00375                                         'displayCond' => 'FIELD:sys_language_uid:>:0',
00376                                         'exclude' => 1,
00377                                         'label' => 'LLL:EXT:lang/locallang_general.php:LGL.l18n_parent',
00378                                         'config' => Array (
00379                                                 'type' => 'select',
00380                                                 'items' => Array (
00381                                                         Array('', 0),
00382                                                 ),
00383                                                 'foreign_table' => '".$tableName."',
00384                                                 'foreign_table_where' => 'AND ".$tableName.".pid=###CURRENT_PID### AND ".$tableName.".sys_language_uid IN (-1,0)',
00385                                         )
00386                                 ),
00387                         "));
00388 
00389                         $columns["l18n_diffsource"] = trim($this->sPS("
00390                                 'l18n_diffsource' => Array (            ".$this->WOPcomment('WOP:'.$WOP.'[localization]')."
00391                                         'config' => Array (
00392                                                 'type' => 'passthrough'
00393                                         )
00394                                 ),
00395                         "));
00396                 }
00397                 if ($config["sorting"]) {
00398                         $ctrl[] = '"sortby" => "sorting",       '.$this->WOPcomment('WOP:'.$WOP.'[sorting]');
00399                         $DBfields[] = "sorting int(10) unsigned DEFAULT '0' NOT NULL,";
00400                 } else {
00401                         $ctrl[] = '"default_sortby" => "ORDER BY '.trim($config["sorting_field"].' '.($config["sorting_desc"]?"DESC":"")).'",   '.$this->WOPcomment('WOP:'.$WOP.'[sorting] / '.$WOP.'[sorting_field] / '.$WOP.'[sorting_desc]');
00402                 }
00403                 if ($config["add_deleted"])     {
00404                         $ctrl[] = '"delete" => "deleted",       '.$this->WOPcomment('WOP:'.$WOP.'[add_deleted]');
00405                         $DBfields[] = "deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,";
00406                 }
00407                 if ($config["add_hidden"])      {
00408                         $enFields[] = '"disabled" => "hidden",  '.$this->WOPcomment('WOP:'.$WOP.'[add_hidden]');
00409                         $DBfields[] = "hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,";
00410                         $columns["hidden"] = trim($this->sPS('
00411                                 "hidden" => Array (             '.$this->WOPcomment('WOP:'.$WOP.'[add_hidden]').'
00412                                         "exclude" => 1,
00413                                         "label" => "LLL:EXT:lang/locallang_general.php:LGL.hidden",
00414                                         "config" => Array (
00415                                                 "type" => "check",
00416                                                 "default" => "0"
00417                                         )
00418                                 ),
00419                         '));
00420                 }
00421                 if ($config["add_starttime"])   {
00422                         $enFields[] = '"starttime" => "starttime",      '.$this->WOPcomment('WOP:'.$WOP.'[add_starttime]');
00423                         $DBfields[] = "starttime int(11) unsigned DEFAULT '0' NOT NULL,";
00424                         $columns["starttime"] = trim($this->sPS('
00425                                 "starttime" => Array (          '.$this->WOPcomment('WOP:'.$WOP.'[add_starttime]').'
00426                                         "exclude" => 1,
00427                                         "label" => "LLL:EXT:lang/locallang_general.php:LGL.starttime",
00428                                         "config" => Array (
00429                                                 "type" => "input",
00430                                                 "size" => "8",
00431                                                 "max" => "20",
00432                                                 "eval" => "date",
00433                                                 "default" => "0",
00434                                                 "checkbox" => "0"
00435                                         )
00436                                 ),
00437                         '));
00438                 }
00439                 if ($config["add_endtime"])     {
00440                         $enFields[] = '"endtime" => "endtime",  '.$this->WOPcomment('WOP:'.$WOP.'[add_endtime]');
00441                         $DBfields[] = "endtime int(11) unsigned DEFAULT '0' NOT NULL,";
00442                         $columns["endtime"] = trim($this->sPS('
00443                                 "endtime" => Array (            '.$this->WOPcomment('WOP:'.$WOP.'[add_endtime]').'
00444                                         "exclude" => 1,
00445                                         "label" => "LLL:EXT:lang/locallang_general.php:LGL.endtime",
00446                                         "config" => Array (
00447                                                 "type" => "input",
00448                                                 "size" => "8",
00449                                                 "max" => "20",
00450                                                 "eval" => "date",
00451                                                 "checkbox" => "0",
00452                                                 "default" => "0",
00453                                                 "range" => Array (
00454                                                         "upper" => mktime(0,0,0,12,31,2020),
00455                                                         "lower" => mktime(0,0,0,date("m")-1,date("d"),date("Y"))
00456                                                 )
00457                                         )
00458                                 ),
00459                         '));
00460                 }
00461                 if ($config["add_access"])      {
00462                         $enFields[] = '"fe_group" => "fe_group",        '.$this->WOPcomment('WOP:'.$WOP.'[add_access]');
00463                         $DBfields[] = "fe_group int(11) DEFAULT '0' NOT NULL,";
00464                         $columns["fe_group"] = trim($this->sPS('
00465                                 "fe_group" => Array (           '.$this->WOPcomment('WOP:'.$WOP.'[add_access]').'
00466                                         "exclude" => 1,
00467                                         "label" => "LLL:EXT:lang/locallang_general.php:LGL.fe_group",
00468                                         "config" => Array (
00469                                                 "type" => "select",
00470                                                 "items" => Array (
00471                                                         Array("", 0),
00472                                                         Array("LLL:EXT:lang/locallang_general.php:LGL.hide_at_login", -1),
00473                                                         Array("LLL:EXT:lang/locallang_general.php:LGL.any_login", -2),
00474                                                         Array("LLL:EXT:lang/locallang_general.php:LGL.usergroups", "--div--")
00475                                                 ),
00476                                                 "foreign_table" => "fe_groups"
00477                                         )
00478                                 ),
00479                         '));
00480                 }
00481                         // Add enable fields in header:
00482                 if (is_array($enFields) && count($enFields))    {
00483                         $ctrl[]=trim($this->wrapBody('
00484                                 "enablecolumns" => Array (              '.$this->WOPcomment('WOP:'.$WOP.'[add_hidden] / '.$WOP.'[add_starttime] / '.$WOP.'[add_endtime] / '.$WOP.'[add_access]').'
00485                                 ',implode(chr(10),$enFields),'
00486                                 ),
00487                         '));
00488                 }
00489                         // Add dynamic config file.
00490                 $ctrl[]= '"dynamicConfigFile" => t3lib_extMgm::extPath($_EXTKEY)."tca.php",';
00491                 $ctrl[]= '"iconfile" => t3lib_extMgm::extRelPath($_EXTKEY)."icon_'.$tableName.'.gif",';
00492 
00493                 if ($config["allow_on_pages"])  {
00494                         $this->ext_tables[]=$this->sPS('
00495                                 '.$this->WOPcomment('WOP:'.$WOP.'[allow_on_pages]').'
00496                                 t3lib_extMgm::allowTableOnStandardPages("'.$tableName.'");
00497                         ');
00498                 }
00499                 if ($config["allow_ce_insert_records"]) {
00500                         $this->ext_tables[]=$this->sPS('
00501                                 '.$this->WOPcomment('WOP:'.$WOP.'[allow_ce_insert_records]').'
00502                                 t3lib_extMgm::addToInsertRecords("'.$tableName.'");
00503                         ');
00504                 }
00505                 if ($config["save_and_new"])    {
00506                         $this->ext_localconf[]=trim($this->wrapBody("
00507                                 t3lib_extMgm::addUserTSConfig('
00508                                         ","options.saveDocNew.".$tableName."=1","
00509                                 ');
00510                         "));
00511                 }
00512 
00513                 if (is_array($config["fields"]))        {
00514                         reset($config["fields"]);
00515                         while(list($i,$fConf)=each($config["fields"]))  {
00516                                 $this->makeFieldTCA($DBfields,$columns,$fConf,$WOP."[fields][".$i."]",$tableName,$extKey);
00517                         }
00518                 }
00519 
00520 
00521 
00522                         // Finalize tables.sql:
00523                 $DBfields[]=$this->sPS('
00524                         PRIMARY KEY (uid),
00525                         KEY parent (pid)
00526                 ');
00527                 $createTable = $this->wrapBody('
00528                         #
00529                         # Table structure for table \''.$tableName.'\'
00530                         #
00531                         CREATE TABLE '.$tableName.' (
00532                 ', implode(chr(10),$DBfields), '
00533                         );
00534                 ');
00535                 $this->ext_tables_sql[]=chr(10).$createTable.chr(10);
00536 
00537                         // Finalize tca.php:
00538                 $tca_file="";
00539                 list($typeList,$palList) = $this->implodeColumns($columns);
00540                 $tca_file.=$this->wrapBody('
00541                         $TCA["'.$tableName.'"] = Array (
00542                                 "ctrl" => $TCA["'.$tableName.'"]["ctrl"],
00543                                 "interface" => Array (
00544                                         "showRecordFieldList" => "'.implode(",",array_keys($columns)).'"
00545                                 ),
00546                                 "feInterface" => $TCA["'.$tableName.'"]["feInterface"],
00547                                 "columns" => Array (
00548                         ', trim(implode(chr(10),$columns))      ,'
00549                                 ),
00550                                 "types" => Array (
00551                                         "0" => Array("showitem" => "'.$typeList.'")
00552                                 ),
00553                                 "palettes" => Array (
00554                                         "1" => Array("showitem" => "'.$palList.'")
00555                                 )
00556                         );
00557                 ',2);
00558                 $this->ext_tca[]=chr(10).$tca_file.chr(10);
00559 
00560                         // Finalize ext_tables.php:
00561                 $this->ext_tables[]=$this->wrapBody('
00562                         $TCA["'.$tableName.'"] = Array (
00563                                 "ctrl" => Array (
00564                         ', implode(chr(10),$ctrl)       ,'
00565                                 ),
00566                                 "feInterface" => Array (
00567                                         "fe_admin_fieldList" => "'.implode(", ",array_keys($columns)).'",
00568                                 )
00569                         );
00570                 ',2);
00571 
00572 
00573                                 // Add wizard icon
00574                         $this->addFileToFileArray($pathSuffix."icon_".$tableName.".gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/".$config["defIcon"]));
00575 
00576         }
00577 
00578         function implodeColumns($columns)       {
00579                 reset($columns);
00580                 $outems=array();
00581                 $paltems=array();
00582                 $c=0;
00583                 $hiddenFlag=0;
00584                 $titleDivFlag=0;
00585                 while(list($fN)=each($columns)) {
00586                         if (!$hiddenFlag || !t3lib_div::inList("starttime,endtime,fe_group",$fN))       {
00587                                 $outTem = array($fN,"","","","");
00588                                 $outTem[3] = $this->_typeP[$fN];
00589                                 if ($c==0)      $outTem[4]="1-1-1";
00590                                 if ($fN=="title")       {
00591                                         $outTem[4]="2-2-2";
00592                                         $titleDivFlag=1;
00593                                 } elseif ($titleDivFlag)        {
00594                                         $outTem[4]="3-3-3";
00595                                         $titleDivFlag=0;
00596                                 }
00597                                 if ($fN=="hidden")      {
00598                                         $outTem[2]="1";
00599                                         $hiddenFlag=1;
00600                                 }
00601                                 $outems[] = str_replace(",","",str_replace(chr(9),";",trim(str_replace(";","",implode(chr(9),$outTem)))));
00602                                 $c++;
00603                         } else {
00604                                 $paltems[]=$fN;
00605                         }
00606                 }
00607                 return array(implode(", ",$outems),implode(", ",$paltems));
00608         }
00609         function makeFieldTCA(&$DBfields,&$columns,$fConf,$WOP,$table,$extKey)  {
00610                 if (!(string)$fConf["type"])    return;
00611                 $id = $table."_".$fConf["fieldname"];
00612 #debug($fConf);
00613 
00614                 $configL=array();
00615                 $t = (string)$fConf["type"];
00616                 switch($t)      {
00617                         case "input":
00618                         case "input+":
00619                                 $isString =1;
00620                                 $configL[]='"type" => "input",  '.$this->WOPcomment('WOP:'.$WOP.'[type]');
00621                                 $configL[]='"size" => "'.t3lib_div::intInRange($fConf["conf_size"],5,48,30).'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_size]');
00622                                 if (intval($fConf["conf_max"])) $configL[]='"max" => "'.t3lib_div::intInRange($fConf["conf_max"],1,255).'",     '.$this->WOPcomment('WOP:'.$WOP.'[conf_max]');
00623 
00624                                 $evalItems=array();
00625                                 if ($fConf["conf_required"])    {$evalItems[0][] = "required";                  $evalItems[1][] = $WOP.'[conf_required]';}
00626 
00627                                 if ($t=="input+")       {
00628                                         $isString = !$fConf["conf_eval"] || t3lib_div::inList("alphanum,upper,lower",$fConf["conf_eval"]);
00629                                         if ($fConf["conf_varchar"] && $isString)                {$evalItems[0][] = "trim";                      $evalItems[1][] = $WOP.'[conf_varchar]';}
00630                                         if ($fConf["conf_eval"]=="int+")        {
00631                                                 $configL[]='"range" => Array ("lower"=>0,"upper"=>1000),        '.$this->WOPcomment('WOP:'.$WOP.'[conf_eval] = int+ results in a range setting');
00632                                                 $fConf["conf_eval"]="int";
00633                                         }
00634                                         if ($fConf["conf_eval"])                {$evalItems[0][] = $fConf["conf_eval"];                 $evalItems[1][] = $WOP.'[conf_eval]';}
00635                                         if ($fConf["conf_check"])       $configL[]='"checkbox" => "'.($isString?"":"0").'",     '.$this->WOPcomment('WOP:'.$WOP.'[conf_check]');
00636 
00637                                         if ($fConf["conf_stripspace"])          {$evalItems[0][] = "nospace";                   $evalItems[1][] = $WOP.'[conf_stripspace]';}
00638                                         if ($fConf["conf_pass"])                {$evalItems[0][] = "password";                  $evalItems[1][] = $WOP.'[conf_pass]';}
00639                                         if ($fConf["conf_unique"])      {
00640                                                 if ($fConf["conf_unique"]=="L")         {$evalItems[0][] = "uniqueInPid";                       $evalItems[1][] = $WOP.'[conf_unique] = Local (unique in this page (PID))';}
00641                                                 if ($fConf["conf_unique"]=="G")         {$evalItems[0][] = "unique";                    $evalItems[1][] = $WOP.'[conf_unique] = Global (unique in whole database)';}
00642                                         }
00643 
00644                                         $wizards =array();
00645                                         if ($fConf["conf_wiz_color"])   {
00646                                                 $wizards[] = trim($this->sPS('
00647                                                         '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_color]').'
00648                                                         "color" => Array(
00649                                                                 "title" => "Color:",
00650                                                                 "type" => "colorbox",
00651                                                                 "dim" => "12x12",
00652                                                                 "tableStyle" => "border:solid 1px black;",
00653                                                                 "script" => "wizard_colorpicker.php",
00654                                                                 "JSopenParams" => "height=300,width=250,status=0,menubar=0,scrollbars=1",
00655                                                         ),
00656                                                 '));
00657                                         }
00658                                         if ($fConf["conf_wiz_link"])    {
00659                                                 $wizards[] = trim($this->sPS('
00660                                                         '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_link]').'
00661                                                         "link" => Array(
00662                                                                 "type" => "popup",
00663                                                                 "title" => "Link",
00664                                                                 "icon" => "link_popup.gif",
00665                                                                 "script" => "browse_links.php?mode=wizard",
00666                                                                 "JSopenParams" => "height=300,width=500,status=0,menubar=0,scrollbars=1"
00667                                                         ),
00668                                                 '));
00669                                         }
00670                                         if (count($wizards))    {
00671                                                 $configL[]=trim($this->wrapBody('
00672                                                         "wizards" => Array(
00673                                                                 "_PADDING" => 2,
00674                                                                 ',implode(chr(10),$wizards),'
00675                                                         ),
00676                                                 '));
00677                                         }
00678                                 } else {
00679                                         if ($fConf["conf_varchar"])             {$evalItems[0][] = "trim";                      $evalItems[1][] = $WOP.'[conf_varchar]';}
00680                                 }
00681 
00682                                 if (count($evalItems))  $configL[]='"eval" => "'.implode(",",$evalItems[0]).'", '.$this->WOPcomment('WOP:'.implode(" / ",$evalItems[1]));
00683 
00684                                 if (!$isString) {
00685                                         $DBfields[] = $fConf["fieldname"]." int(11) DEFAULT '0' NOT NULL,";
00686                                 } elseif (!$fConf["conf_varchar"])              {
00687                                         $DBfields[] = $fConf["fieldname"]." tinytext NOT NULL,";
00688                                 } else {
00689                                         $varCharLn = (intval($fConf["conf_max"])?t3lib_div::intInRange($fConf["conf_max"],1,255):255);
00690                                         $DBfields[] = $fConf["fieldname"]." ".($varCharLn>$this->charMaxLng?'var':'')."char(".$varCharLn.") DEFAULT '' NOT NULL,";
00691                                 }
00692                         break;
00693                         case "link":
00694                                 $DBfields[] = $fConf["fieldname"]." tinytext NOT NULL,";
00695                                 $configL[]=trim($this->sPS('
00696                                         "type" => "input",
00697                                         "size" => "15",
00698                                         "max" => "255",
00699                                         "checkbox" => "",
00700                                         "eval" => "trim",
00701                                         "wizards" => Array(
00702                                                 "_PADDING" => 2,
00703                                                 "link" => Array(
00704                                                         "type" => "popup",
00705                                                         "title" => "Link",
00706                                                         "icon" => "link_popup.gif",
00707                                                         "script" => "browse_links.php?mode=wizard",
00708                                                         "JSopenParams" => "height=300,width=500,status=0,menubar=0,scrollbars=1"
00709                                                 )
00710                                         )
00711                                 '));
00712                         break;
00713                         case "datetime":
00714                         case "date":
00715                                 $DBfields[] = $fConf["fieldname"]." int(11) DEFAULT '0' NOT NULL,";
00716                                 $configL[]=trim($this->sPS('
00717                                         "type" => "input",
00718                                         "size" => "'.($t=="datetime"?12:8).'",
00719                                         "max" => "20",
00720                                         "eval" => "'.$t.'",
00721                                         "checkbox" => "0",
00722                                         "default" => "0"
00723                                 '));
00724                         break;
00725                         case "integer":
00726                                 $DBfields[] = $fConf["fieldname"]." int(11) DEFAULT '0' NOT NULL,";
00727                                 $configL[]=trim($this->sPS('
00728                                         "type" => "input",
00729                                         "size" => "4",
00730                                         "max" => "4",
00731                                         "eval" => "int",
00732                                         "checkbox" => "0",
00733                                         "range" => Array (
00734                                                 "upper" => "1000",
00735                                                 "lower" => "10"
00736                                         ),
00737                                         "default" => 0
00738                                 '));
00739                         break;
00740                         case "textarea":
00741                         case "textarea_nowrap":
00742                                 $DBfields[] = $fConf["fieldname"]." text NOT NULL,";
00743                                 $configL[]='"type" => "text",';
00744                                 if ($t=="textarea_nowrap")      {
00745                                         $configL[]='"wrap" => "OFF",';
00746                                 }
00747                                 $configL[]='"cols" => "'.t3lib_div::intInRange($fConf["conf_cols"],5,48,30).'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_cols]');
00748                                 $configL[]='"rows" => "'.t3lib_div::intInRange($fConf["conf_rows"],1,20,5).'",  '.$this->WOPcomment('WOP:'.$WOP.'[conf_rows]');
00749                                 if ($fConf["conf_wiz_example"]) {
00750                                         $wizards =array();
00751                                         $wizards[] = trim($this->sPS('
00752                                                 '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_example]').'
00753                                                 "example" => Array(
00754                                                         "title" => "Example Wizard:",
00755                                                         "type" => "script",
00756                                                         "notNewRecords" => 1,
00757                                                         "icon" => t3lib_extMgm::extRelPath("'.$extKey.'")."'.$id.'/wizard_icon.gif",
00758                                                         "script" => t3lib_extMgm::extRelPath("'.$extKey.'")."'.$id.'/index.php",
00759                                                 ),
00760                                         '));
00761 
00762                                         $cN = $this->returnName($extKey,"class",$id."wiz");
00763                                         $this->writeStandardBE_xMod(
00764                                                 $extKey,
00765                                                 array("title"=>"Example Wizard title..."),
00766                                                 $id.'/',
00767                                                 $cN,
00768                                                 0,
00769                                                 $id."wiz"
00770                                         );
00771                                         $this->addFileToFileArray($id."/wizard_icon.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/notfound.gif"));
00772 
00773                                         $configL[]=trim($this->wrapBody('
00774                                                 "wizards" => Array(
00775                                                         "_PADDING" => 2,
00776                                                         ',implode(chr(10),$wizards),'
00777                                                 ),
00778                                         '));
00779                                 }
00780                         break;
00781                         case "textarea_rte":
00782                                 $DBfields[] = $fConf["fieldname"]." text NOT NULL,";
00783                                 $configL[]='"type" => "text",';
00784                                 $configL[]='"cols" => "30",';
00785                                 $configL[]='"rows" => "5",';
00786                                 if ($fConf["conf_rte_fullscreen"])      {
00787                                         $wizards =array();
00788                                         $wizards[] = trim($this->sPS('
00789                                                 '.$this->WOPcomment('WOP:'.$WOP.'[conf_rte_fullscreen]').'
00790                                                 "RTE" => Array(
00791                                                         "notNewRecords" => 1,
00792                                                         "RTEonly" => 1,
00793                                                         "type" => "script",
00794                                                         "title" => "Full screen Rich Text Editing|Formatteret redigering i hele vinduet",
00795                                                         "icon" => "wizard_rte2.gif",
00796                                                         "script" => "wizard_rte.php",
00797                                                 ),
00798                                         '));
00799                                         $configL[]=trim($this->wrapBody('
00800                                                 "wizards" => Array(
00801                                                         "_PADDING" => 2,
00802                                                         ',implode(chr(10),$wizards),'
00803                                                 ),
00804                                         '));
00805                                 }
00806 
00807                                 $rteImageDir = "";
00808                                 if ($fConf["conf_rte_separateStorageForImages"] && t3lib_div::inList("moderate,basic,custom",$fConf["conf_rte"]))       {
00809                                         $this->EM_CONF_presets["createDirs"][]=$this->ulFolder($extKey)."rte/";
00810                                         $rteImageDir = "|imgpath=".$this->ulFolder($extKey)."rte/";
00811                                 }
00812 
00813                                 $transformation="ts_images-ts_reglinks";
00814                                 if ($fConf["conf_mode_cssOrNot"] && t3lib_div::inList("moderate,custom",$fConf["conf_rte"]))    {
00815                                         $transformation="ts_css";
00816                                 }
00817 
00818 
00819                                 switch($fConf["conf_rte"])      {
00820                                         case "tt_content":
00821                                                 $typeP = 'richtext[paste|bold|italic|underline|formatblock|class|left|center|right|orderedlist|unorderedlist|outdent|indent|link|image]:rte_transform[mode=ts]';
00822                                         break;
00823                                         case "moderate":
00824                                                 $typeP = 'richtext[*]:rte_transform[mode='.$transformation.''.$rteImageDir.']';
00825                                         break;
00826                                         case "basic":
00827                                                 $typeP = 'richtext[cut|copy|paste|formatblock|textcolor|bold|italic|underline|left|center|right|orderedlist|unorderedlist|outdent|indent|link|table|image|line|chMode]:rte_transform[mode=ts_css'.$rteImageDir.']';
00828                                                 $this->ext_localconf[]=trim($this->wrapBody("
00829                                                                 t3lib_extMgm::addPageTSConfig('
00830 
00831                                                                         # ***************************************************************************************
00832                                                                         # CONFIGURATION of RTE in table \"".$table."\", field \"".$fConf["fieldname"]."\"
00833                                                                         # ***************************************************************************************
00834 
00835                                                                         ",trim($this->slashValueForSingleDashes(str_replace(chr(9),"  ",$this->sPS("
00836                                                                                 RTE.config.".$table.".".$fConf["fieldname"]." {
00837                                                                                         hidePStyleItems = H1, H4, H5, H6
00838                                                                                         proc.exitHTMLparser_db=1
00839                                                                                         proc.exitHTMLparser_db {
00840                                                                                                 keepNonMatchedTags=1
00841                                                                                                 tags.font.allowedAttribs= color
00842                                                                                                 tags.font.rmTagIfNoAttrib = 1
00843                                                                                                 tags.font.nesting = global
00844                                                                                         }
00845                                                                                 }
00846                                                                         ")))),"
00847                                                                 ');
00848                                                 ",0));
00849                                         break;
00850                                         case "none":
00851                                                 $typeP = 'richtext[*]';
00852                                         break;
00853                                         case "custom":
00854                                                 $enabledButtons=array();
00855                                                 $traverseList = explode(",","cut,copy,paste,formatblock,class,fontstyle,fontsize,textcolor,bold,italic,underline,left,center,right,orderedlist,unorderedlist,outdent,indent,link,table,image,line,user,chMode");
00856                                                 $HTMLparser=array();
00857                                                 $fontAllowedAttrib=array();
00858                                                 $allowedTags_WOP = array();
00859                                                 $allowedTags=array();
00860                                                 while(list(,$lI)=each($traverseList))   {
00861                                                         $nothingDone=0;
00862                                                         if ($fConf["conf_rte_b_".$lI])  {
00863                                                                 $enabledButtons[]=$lI;
00864                                                                 switch($lI)     {
00865                                                                         case "formatblock":
00866                                                                         case "left":
00867                                                                         case "center":
00868                                                                         case "right":
00869                                                                                 $allowedTags[]="div";
00870                                                                                 $allowedTags[]="p";
00871                                                                         break;
00872                                                                         case "class":
00873                                                                                 $allowedTags[]="span";
00874                                                                         break;
00875                                                                         case "fontstyle":
00876                                                                                 $allowedTags[]="font";
00877                                                                                 $fontAllowedAttrib[]="face";
00878                                                                         break;
00879                                                                         case "fontsize":
00880                                                                                 $allowedTags[]="font";
00881                                                                                 $fontAllowedAttrib[]="size";
00882                                                                         break;
00883                                                                         case "textcolor":
00884                                                                                 $allowedTags[]="font";
00885                                                                                 $fontAllowedAttrib[]="color";
00886                                                                         break;
00887                                                                         case "bold":
00888                                                                                 $allowedTags[]="b";
00889                                                                                 $allowedTags[]="strong";
00890                                                                         break;
00891                                                                         case "italic":
00892                                                                                 $allowedTags[]="i";
00893                                                                                 $allowedTags[]="em";
00894                                                                         break;
00895                                                                         case "underline":
00896                                                                                 $allowedTags[]="u";
00897                                                                         break;
00898                                                                         case "orderedlist":
00899                                                                                 $allowedTags[]="ol";
00900                                                                                 $allowedTags[]="li";
00901                                                                         break;
00902                                                                         case "unorderedlist":
00903                                                                                 $allowedTags[]="ul";
00904                                                                                 $allowedTags[]="li";
00905                                                                         break;
00906                                                                         case "outdent":
00907                                                                         case "indent":
00908                                                                                 $allowedTags[]="blockquote";
00909                                                                         break;
00910                                                                         case "link":
00911                                                                                 $allowedTags[]="a";
00912                                                                         break;
00913                                                                         case "table":
00914                                                                                 $allowedTags[]="table";
00915                                                                                 $allowedTags[]="tr";
00916                                                                                 $allowedTags[]="td";
00917                                                                         break;
00918                                                                         case "image":
00919                                                                                 $allowedTags[]="img";
00920                                                                         break;
00921                                                                         case "line":
00922                                                                                 $allowedTags[]="hr";
00923                                                                         break;
00924                                                                         default:
00925                                                                                 $nothingDone=1;
00926                                                                         break;
00927                                                                 }
00928                                                                 if (!$nothingDone)      $allowedTags_WOP[] = $WOP.'[conf_rte_b_'.$lI.']';
00929                                                         }
00930                                                 }
00931                                                 if (count($fontAllowedAttrib))  {
00932                                                         $HTMLparser[]="tags.font.allowedAttribs = ".implode(",",$fontAllowedAttrib);
00933                                                         $HTMLparser[]="tags.font.rmTagIfNoAttrib = 1";
00934                                                         $HTMLparser[]="tags.font.nesting = global";
00935                                                 }
00936                                                 if (count($enabledButtons))     {
00937                                                         $typeP = 'richtext['.implode("|",$enabledButtons).']:rte_transform[mode='.$transformation.''.$rteImageDir.']';
00938                                                 }
00939 
00940                                                 $rte_colors=array();
00941                                                 $setupUpColors=array();
00942                                                 for ($a=1;$a<=3;$a++)   {
00943                                                         if ($fConf["conf_rte_color".$a])        {
00944                                                                 $rte_colors[$id.'_color'.$a]=trim($this->sPS('
00945                                                                         '.$this->WOPcomment('WOP:'.$WOP.'[conf_rte_color'.$a.']').'
00946                                                                         '.$id.'_color'.$a.' {
00947                                                                                 name = Color '.$a.'
00948                                                                                 value = '.$fConf["conf_rte_color".$a].'
00949                                                                         }
00950                                                                 '));
00951                                                                 $setupUpColors[]=trim($fConf["conf_rte_color".$a]);
00952                                                         }
00953                                                 }
00954 
00955                                                 $rte_classes=array();
00956                                                 for ($a=1;$a<=6;$a++)   {
00957                                                         if ($fConf["conf_rte_class".$a])        {
00958                                                                 $rte_classes[$id.'_class'.$a]=trim($this->sPS('
00959                                                                         '.$this->WOPcomment('WOP:'.$WOP.'[conf_rte_class'.$a.']').'
00960                                                                         '.$id.'_class'.$a.' {
00961                                                                                 name = '.$fConf["conf_rte_class".$a].'
00962                                                                                 value = '.$fConf["conf_rte_class".$a."_style"].'
00963                                                                         }
00964                                                                 '));
00965                                                         }
00966                                                 }
00967 
00968                                                 $PageTSconfig= Array();
00969                                                 if ($fConf["conf_rte_removecolorpicker"])       {
00970                                                         $PageTSconfig[]="       ".$this->WOPcomment('WOP:'.$WOP.'[conf_rte_removecolorpicker]');
00971                                                         $PageTSconfig[]="disableColorPicker = 1";
00972                                                 }
00973                                                 if (count($rte_classes))        {
00974                                                         $PageTSconfig[]="       ".$this->WOPcomment('WOP:'.$WOP.'[conf_rte_class*]');
00975                                                         $PageTSconfig[]="classesParagraph = ".implode(", ",array_keys($rte_classes));