00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00043 global $tmpl,$tplRow,$theConstants;
00044
00045 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00046 $tmpl->tt_track = 0;
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);
00053 if (is_array($tplRow)) {
00054
00055 $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
00056 $rootLine = $sys_page->getRootLine($pageId);
00057 $tmpl->runThroughTemplates($rootLine,$template_uid);
00058 $theConstants = $tmpl->generateConfig_constants();
00059 $tmpl->ext_categorizeEditableConstants($theConstants);
00060 $tmpl->ext_regObjectPositions($tplRow["constants"]);
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
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
00085
00086 $this->pObj->createTemplate($this->pObj->id);
00087
00088
00089
00090
00091
00092
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
00104
00105
00106
00107 $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid);
00108
00109 if ($existTemplate) {
00110
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
00116
00117
00118 if ($tmpl->changed) {
00119
00120 $recData=array();
00121 $recData["sys_template"][$tplRow[uid]]["constants"] = implode($tmpl->raw,chr(10));
00122
00123 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00124 $tce->stripslashes_values=0;
00125
00126 $tce->start($recData,Array());
00127
00128 $tce->process_datamap();
00129
00130 $tce->clear_cacheCmd("all");
00131
00132
00133 $this->initialize_editor($this->pObj->id,$template_uid);
00134 }
00135 }
00136
00137
00138 $tmpl->ext_readDirResources($TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"]);
00139 $tmpl->ext_resourceDims();
00140
00141
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
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
00164 $category = $this->pObj->MOD_SETTINGS["constant_editor_cat"];
00165
00166
00167
00168
00169
00170
00171
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 ?>