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 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
00111
00112
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
00118
00119
00120 if ($tmpl->changed) {
00121
00122 $recData=array();
00123 $recData["sys_template"][$saveId]["constants"] = implode($tmpl->raw,chr(10));
00124
00125 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00126 $tce->stripslashes_values=0;
00127
00128 $tce->start($recData,Array());
00129
00130 $tce->process_datamap();
00131
00132 $tce->clear_cacheCmd("all");
00133
00134
00135 $this->initialize_editor($this->pObj->id,$template_uid);
00136 }
00137 }
00138
00139
00140 $tmpl->ext_readDirResources($TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"]);
00141 $tmpl->ext_resourceDims();
00142
00143
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
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
00166 $category = $this->pObj->MOD_SETTINGS["constant_editor_cat"];
00167
00168
00169
00170
00171
00172
00173
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 ?>