"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/tstemplate_ceditor/class.tx_tstemplateceditor.php Source File", "datetime" => "Sat Dec 2 19:22:34 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
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 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; 00111 00112 // Update template ? 00113 if (t3lib_div::_POST("submit")) { 00114 require_once (PATH_t3lib."class.t3lib_tcemain.php"); 00115 $tmpl->changed=0; 00116 $tmpl->ext_procesInput(t3lib_div::_POST(),$_FILES,$theConstants,$tplRow); 00117 // debug($tmpl->changed); 00118 // debug($tmpl->raw); 00119 // $tmpl->changed=0; 00120 if ($tmpl->changed) { 00121 // Set the data to be saved 00122 $recData=array(); 00123 $recData["sys_template"][$saveId]["constants"] = implode($tmpl->raw,chr(10)); 00124 // Create new tce-object 00125 $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 00126 $tce->stripslashes_values=0; 00127 // Initialize 00128 $tce->start($recData,Array()); 00129 // Saved the stuff 00130 $tce->process_datamap(); 00131 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) 00132 $tce->clear_cacheCmd("all"); 00133 00134 // re-read the template ... 00135 $this->initialize_editor($this->pObj->id,$template_uid); 00136 } 00137 } 00138 00139 // Output edit form 00140 $tmpl->ext_readDirResources($TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"]); 00141 $tmpl->ext_resourceDims(); 00142 00143 // 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. 00144 $this->pObj->MOD_MENU["constant_editor_cat"] = $tmpl->ext_getCategoryLabelArray(); 00145 00146 $this->pObj->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->pObj->MOD_MENU, t3lib_div::_GP("SET"), $this->pObj->MCONF["name"]); 00147 // Resetting the menu (stop) 00148 00149 $theOutput.=$this->pObj->doc->spacer(5); 00150 $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); 00151 if ($manyTemplatesMenu) { 00152 $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu); 00153 $theOutput.=$this->pObj->doc->divider(5); 00154 } 00155 00156 $theOutput.=$this->pObj->doc->spacer(5); 00157 if (count($this->pObj->MOD_MENU["constant_editor_cat"])) { 00158 $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"]); 00159 $theOutput.=$this->pObj->doc->section("",'<NOBR>'.$menu.'</NOBR>'); 00160 } else { 00161 $theOutput.=$this->pObj->doc->section("No constants available","There are no editable constants available for the Constant Editor.",1,0,1); 00162 } 00163 00164 00165 // Category and constant editor config: 00166 $category = $this->pObj->MOD_SETTINGS["constant_editor_cat"]; 00167 /* $TSCE_tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext"); // Defined global here! 00168 $TSCE_tmpl->tt_track = 0; // Do not log time-performance information 00169 $TSCE_tmpl->init(); 00170 $TSCE_tmpl->constants=array($tplRow["constants"]); 00171 debug($tplRow); 00172 $TSCE_tmpl->generateConfig_constants(); 00173 debug($TSCE_tmpl->setup); 00174 */ 00175 $tmpl->ext_getTSCE_config($category); 00176 00177 # NOT WORKING: 00178 if ($BE_USER_modOptions["properties"]["constantEditor."]["example"]=="top") { 00179 $theOutput=$this->displayExample($theOutput); 00180 } 00181 00182 $printFields = trim($tmpl->ext_printFields($theConstants,$category)); 00183 if ($printFields) { 00184 $theOutput.=$this->pObj->doc->spacer(20); 00185 $theOutput.=$this->pObj->doc->section("",'<input type="Submit" name="submit" value="Update">'); 00186 $theOutput.=$this->pObj->doc->spacer(15); 00187 $theOutput.=$this->pObj->doc->section("",$printFields); 00188 $theOutput.=$this->pObj->doc->spacer(10); 00189 $theOutput.=$this->pObj->doc->section("",'<input type="Submit" name="submit" value="Update">'); 00190 } 00191 00192 if ($BE_USER_modOptions["properties"]["constantEditor."]["example"]!="top") { 00193 $theOutput=$this->displayExample($theOutput); 00194 } 00195 00196 $theOutput.=$this->pObj->doc->spacer(10); 00197 $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); 00198 } else { 00199 $theOutput.=$this->pObj->noTemplate(1); 00200 } 00201 return $theOutput; 00202 } 00203 } 00204 00205 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_ceditor/class.tx_tstemplateceditor.php"]) { 00206 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_ceditor/class.tx_tstemplateceditor.php"]); 00207 } 00208 00209 ?>