Documentation TYPO3 par Ameos

class.tx_tstemplateceditor.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 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 ***************************************************************/
00038 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00039 
00040 class tx_tstemplateceditor extends t3lib_extobjbase {
00041         function initialize_editor($pageId,$template_uid=0)     {
00042                         // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00043                 global $tmpl,$tplRow,$theConstants;
00044 
00045                 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");  // Defined global here!
00046                 $tmpl->tt_track = 0;    // Do not log time-performance information
00047                 $tmpl->init();
00048 
00049                 $tmpl->ext_localGfxPrefix=t3lib_extMgm::extPath("tstemplate_ceditor");
00050                 $tmpl->ext_localWebGfxPrefix=$GLOBALS["BACK_PATH"].t3lib_extMgm::extRelPath("tstemplate_ceditor");
00051 
00052                 $tplRow = $tmpl->ext_getFirstTemplate($pageId,$template_uid);   // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
00053                 if (is_array($tplRow))  {       // IF there was a template...
00054                                 // Gets the rootLine
00055                         $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
00056                         $rootLine = $sys_page->getRootLine($pageId);
00057                         $tmpl->runThroughTemplates($rootLine,$template_uid);    // This generates the constants/config + hierarchy info for the template.
00058                         $theConstants = $tmpl->generateConfig_constants();      // The editable constants are returned in an array.
00059                         $tmpl->ext_categorizeEditableConstants($theConstants);  // The returned constants are sorted in categories, that goes into the $tmpl->categories array
00060                         $tmpl->ext_regObjectPositions($tplRow["constants"]);            // This array will contain key=[expanded constantname], value=linenumber in template. (after edit_divider, if any)
00061                         return 1;
00062                 }
00063         }
00064         function displayExample($theOutput)     {
00065                 global $SOBE,$tmpl;
00066                 if ($tmpl->helpConfig["imagetag"] || $tmpl->helpConfig["description"] || $tmpl->helpConfig["header"])   {
00067         //              $theOutput.=$this->pObj->doc->divider(20);
00068                         $theOutput.=$this->pObj->doc->spacer(30);
00069                         $theOutput.=$this->pObj->doc->section($tmpl->helpConfig["header"],
00070                                 '<div align="center">'.$tmpl->helpConfig["imagetag"].'</div><BR>'.
00071                                 ($tmpl->helpConfig["description"] ? implode(explode("//",$tmpl->helpConfig["description"]),"<BR>")."<BR>" : "").
00072                                 ($tmpl->helpConfig["bulletlist"] ? "<ul><li>".implode(explode("//",$tmpl->helpConfig["bulletlist"]),"<li>")."</ul>" : "<BR>")
00073                                 );
00074                 }
00075                 return $theOutput;
00076         }
00077 
00078         function main() {
00079                 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00080                 global $tmpl,$tplRow,$theConstants;
00081 
00082 
00083                 // **************************
00084                 // Create extension template
00085                 // **************************
00086                 $this->pObj->createTemplate($this->pObj->id);
00087 
00088 
00089 
00090 
00091                 // **************************
00092                 // Checking for more than one template an if, set a menu...
00093                 // **************************
00094                 $manyTemplatesMenu = $this->pObj->templateMenu();
00095                 $template_uid = 0;
00096                 if ($manyTemplatesMenu) {
00097                         $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"];
00098                 }
00099 
00100 
00101 
00102                 // **************************
00103                 // Main
00104                 // **************************
00105 
00106                 // BUGBUG: Should we check if the uset may at all read and write template-records???
00107                 $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid);               // initialize
00108 
00109                 if ($existTemplate)     {
00110                                 // Update template ?
00111                         if (t3lib_div::_POST("submit")) {
00112                                 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00113                                 $tmpl->changed=0;
00114                                 $tmpl->ext_procesInput(t3lib_div::_POST(),$_FILES,$theConstants,$tplRow);
00115                 //              debug($tmpl->changed);
00116                 //              debug($tmpl->raw);
00117                 //              $tmpl->changed=0;
00118                                 if ($tmpl->changed)     {
00119                                                 // Set the data to be saved
00120                                         $recData=array();
00121                                         $recData["sys_template"][$tplRow[uid]]["constants"] = implode($tmpl->raw,chr(10));
00122                                                 // Create new  tce-object
00123                                         $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00124                                         $tce->stripslashes_values=0;
00125                                                 // Initialize
00126                                         $tce->start($recData,Array());
00127                                                 // Saved the stuff
00128                                         $tce->process_datamap();
00129                                                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
00130                                         $tce->clear_cacheCmd("all");
00131 
00132                                                 // re-read the template ...
00133                                         $this->initialize_editor($this->pObj->id,$template_uid);
00134                                 }
00135                         }
00136 
00137                         // Output edit form
00138                         $tmpl->ext_readDirResources($TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"]);
00139                         $tmpl->ext_resourceDims();
00140 
00141                                 // Resetting the menu (start). I wonder if this in any way is a violation of the menu-system. Haven't checked. But need to do it here, because the menu is dependent on the categories available.
00142                         $this->pObj->MOD_MENU["constant_editor_cat"] = $tmpl->ext_getCategoryLabelArray();
00143 
00144                         $this->pObj->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->pObj->MOD_MENU, t3lib_div::_GP("SET"), $this->pObj->MCONF["name"]);
00145                                 // Resetting the menu (stop)
00146 
00147                         $theOutput.=$this->pObj->doc->spacer(5);
00148                         $theOutput.=$this->pObj->doc->section("Edit constants for template:",'<img src="'.$BACK_PATH.t3lib_iconWorks::getIcon("sys_template",$tplRow).'" width=18 height=16 align=top><b>'.$this->pObj->linkWrapTemplateTitle($tplRow["title"],"constants").'</b>'.htmlspecialchars(trim($tplRow["sitetitle"])?' - ('.$tplRow["sitetitle"].')':''),0,1);
00149                         if ($manyTemplatesMenu) {
00150                                 $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu);
00151                                 $theOutput.=$this->pObj->doc->divider(5);
00152                         }
00153 
00154                         $theOutput.=$this->pObj->doc->spacer(5);
00155                         if (count($this->pObj->MOD_MENU["constant_editor_cat"]))        {
00156                                 $menu = "Category: ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[constant_editor_cat]",$this->pObj->MOD_SETTINGS["constant_editor_cat"],$this->pObj->MOD_MENU["constant_editor_cat"]);
00157                                 $theOutput.=$this->pObj->doc->section("",'<NOBR>'.$menu.'</NOBR>');
00158                         } else {
00159                                 $theOutput.=$this->pObj->doc->section("No constants available","There are no editable constants available for the Constant Editor.",1,0,1);
00160                         }
00161 
00162 
00163                                         // Category and constant editor config:
00164                         $category = $this->pObj->MOD_SETTINGS["constant_editor_cat"];
00165                 /*      $TSCE_tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");     // Defined global here!
00166                         $TSCE_tmpl->tt_track = 0;       // Do not log time-performance information
00167                         $TSCE_tmpl->init();
00168                         $TSCE_tmpl->constants=array($tplRow["constants"]);
00169                         debug($tplRow);
00170                         $TSCE_tmpl->generateConfig_constants();
00171                         debug($TSCE_tmpl->setup);
00172                         */
00173                         $tmpl->ext_getTSCE_config($category);
00174 
00175 # NOT WORKING:
00176                         if ($BE_USER_modOptions["properties"]["constantEditor."]["example"]=="top")     {
00177                                 $theOutput=$this->displayExample($theOutput);
00178                         }
00179 
00180                         $printFields = trim($tmpl->ext_printFields($theConstants,$category));
00181                         if ($printFields)       {
00182                                 $theOutput.=$this->pObj->doc->spacer(20);
00183                                 $theOutput.=$this->pObj->doc->section("",'<input type="Submit" name="submit" value="Update">');
00184                                 $theOutput.=$this->pObj->doc->spacer(15);
00185                                 $theOutput.=$this->pObj->doc->section("",$printFields);
00186                                 $theOutput.=$this->pObj->doc->spacer(10);
00187                                 $theOutput.=$this->pObj->doc->section("",'<input type="Submit" name="submit" value="Update">');
00188                         }
00189 
00190                         if ($BE_USER_modOptions["properties"]["constantEditor."]["example"]!="top")     {
00191                                 $theOutput=$this->displayExample($theOutput);
00192                         }
00193 
00194                         $theOutput.=$this->pObj->doc->spacer(10);
00195                         $theOutput.=$this->pObj->doc->section("Cache",'Click here to <a href="index.php?id='.$this->pObj->id.'&clear_all_cache=1"><strong>clear all cache</strong></a>',0,1);
00196                 } else {
00197                         $theOutput.=$this->pObj->noTemplate(1);
00198                 }
00199                 return $theOutput;
00200         }
00201 }
00202 
00203 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_ceditor/class.tx_tstemplateceditor.php"])   {
00204         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_ceditor/class.tx_tstemplateceditor.php"]);
00205 }
00206 
00207 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6