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
00031 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00032
00033 class tx_tstemplateobjbrowser extends t3lib_extobjbase {
00034 function modMenu() {
00035 global $LANG;
00036
00037 return Array (
00038 "ts_browser_type" => array(
00039 "setup" => "Setup",
00040 "const" => "Constants"
00041 ),
00042 "ts_browser_toplevel_setup" => array(
00043 "0" => "ALL"
00044 ),
00045 "ts_browser_toplevel_const" => array(
00046 "0" => "ALL"
00047 ),
00048 "ts_browser_const" => array(
00049 "0" => "Plain substitution (default)",
00050 "subst" => "Substituted constants in green",
00051 "const" => "UN-substituted constants in green"
00052 ),
00053 "ts_browser_regexsearch" => "",
00054 "ts_browser_fixedLgd" => "1",
00055 "ts_browser_linkObjects" => "1",
00056 );
00057 }
00058 function verify_TSobjects($propertyArray,$parentType,$parentValue) {
00059 $TSobjTable = array(
00060 "PAGE" => array(
00061 "prop" => array (
00062 "typeNum" => "int",
00063 "1,2,3" => "COBJ",
00064 "bodyTag" => "string"
00065 )
00066 ),
00067 "TEXT" => array(
00068 "prop" => array (
00069 "value" => "string"
00070 )
00071 ),
00072 "HTML" => array(
00073 "prop" => array (
00074 "value" => "stdWrap"
00075 )
00076 ),
00077 "stdWrap" => array(
00078 "prop" => array (
00079 "field" => "string",
00080 "current" => "boolean"
00081 )
00082 ),
00083 );
00084 $TSobjDataTypes = array(
00085 "COBJ" => "TEXT,CONTENT",
00086 "PAGE" => "PAGE",
00087 "stdWrap" => ""
00088 );
00089 debug($propertyArray);
00090
00091 if ($parentType) {
00092 if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || t3lib_div::inlist($TSobjDataTypes[$parentType],$parentValue))) {
00093 $ObjectKind = $parentValue;
00094 } else {
00095 $ObjectKind = "";
00096 }
00097 } else {
00098 $ObjectKind = $parentValue;
00099 }
00100
00101 if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) {
00102 $result=array();
00103 if (is_array($propertyArray)) {
00104 reset($propertyArray);
00105 while(list($key,$val)=each($propertyArray)) {
00106 if (t3lib_div::testInt($key)) {
00107 $result[$key]=$TSobjTable[$ObjectKind]["prop"]["1,2,3"];
00108 } else {
00109 $result[$key]=$TSobjTable[$ObjectKind]["prop"][$key];
00110 }
00111 }
00112 }
00113 return $result;
00114 }
00115 }
00116 function initialize_editor($pageId,$template_uid=0) {
00117
00118 global $tmpl,$tplRow,$theConstants;
00119
00120 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00121 $tmpl->tt_track = 0;
00122 $tmpl->init();
00123
00124
00125 $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
00126 $rootLine = $sys_page->getRootLine($pageId);
00127 $tmpl->runThroughTemplates($rootLine,$template_uid);
00128
00129 $tplRow = $tmpl->ext_getFirstTemplate($pageId,$template_uid);
00130 if (is_array($tplRow)) {
00131 return 1;
00132 }
00133 }
00134 function main() {
00135 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00136 global $tmpl,$tplRow,$theConstants;
00137
00138 $POST = t3lib_div::_POST();
00139
00140
00141
00142
00143 $manyTemplatesMenu = $this->pObj->templateMenu();
00144 $template_uid = 0;
00145 if ($manyTemplatesMenu) {
00146 $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"];
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 $bType= $this->pObj->MOD_SETTINGS["ts_browser_type"];
00159 $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid);
00160 if ($existTemplate) {
00161 $theOutput.=$this->pObj->doc->divider(5);
00162 $theOutput.=$this->pObj->doc->section("Current template:",'<img src="'.$BACK_PATH.t3lib_iconWorks::getIcon("sys_template",$tplRow).'" width=18 height=16 align=top><b>'.$this->pObj->linkWrapTemplateTitle($tplRow["title"], ($bType=="setup"?"config":"constants")).'</b>'.htmlspecialchars(trim($tplRow["sitetitle"])?' - ('.$tplRow["sitetitle"].')':''),0,0);
00163 if ($manyTemplatesMenu) {
00164 $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu);
00165 $theOutput.=$this->pObj->doc->divider(5);
00166 }
00167
00168 if ($POST["add_property"] || $POST["update_value"] || $POST["clear_object"]) {
00169
00170 $line="";
00171
00172 if (is_array($POST["data"])) {
00173 if ($POST["add_property"]) {
00174 reset($POST["data"]);
00175 $name = key($POST["data"]);
00176 $property = trim($POST["data"][$name]["name"]);
00177 if (ereg_replace("[^a-zA-Z0-9_\.]*","",$property)!=$property) {
00178 $theOutput.=$this->pObj->doc->spacer(10);
00179 $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("BAD PROPERTY!"),'You must enter a property with characters a-z, A-Z and 0-9, no spaces!<BR>Nothing was updated!',0,0,0,1);
00180 } else {
00181 $pline= $name.".".$property." = ".trim($POST["data"][$name]["propertyValue"]);
00182 $theOutput.=$this->pObj->doc->spacer(10);
00183 $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("PROPERTY ADDED"),htmlspecialchars($pline),0,0,0,1);
00184 $line.=chr(10).$pline;
00185 }
00186 }
00187 if ($POST["update_value"]) {
00188 reset($POST["data"]);
00189 $name = key($POST["data"]);
00190 $pline= $name." = ".trim($POST["data"][$name]["value"]);
00191 $theOutput.=$this->pObj->doc->spacer(10);
00192 $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("VALUE UPDATED"),htmlspecialchars($pline),0,0,0,1);
00193 $line.=chr(10).$pline;
00194 }
00195 if ($POST["clear_object"]) {
00196 reset($POST["data"]);
00197 $name = key($POST["data"]);
00198 if ($POST["data"][$name]["clearValue"]) {
00199 $pline= $name." >";
00200 $theOutput.=$this->pObj->doc->spacer(10);
00201 $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("Object cleared"),htmlspecialchars($pline),0,0,0,1);
00202 $line.=chr(10).$pline;
00203 }
00204 }
00205 }
00206 if ($line) {
00207 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00208
00209 $recData=array();
00210 $field =$bType=="setup"?"config":"constants";
00211 $recData["sys_template"][$tplRow[uid]][$field] = $tplRow[$field].$line;
00212
00213 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00214 $tce->stripslashes_values=0;
00215
00216 $tce->start($recData,Array());
00217
00218 $tce->process_datamap();
00219
00220 $tce->clear_cacheCmd("all");
00221
00222
00223 $this->initialize_editor($this->pObj->id,$template_uid);
00224 }
00225 }
00226 }
00227
00228 $tsbr = t3lib_div::_GET("tsbr");
00229 $update=0;
00230 if (is_array($tsbr)) {
00231 $this->pObj->MOD_SETTINGS["tsbrowser_depthKeys_".$bType] = $tmpl->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS["tsbrowser_depthKeys_".$bType]);
00232 $update=1;
00233 }
00234
00235 $addKey = t3lib_div::_GET("addKey");
00236 if (is_array($addKey)) {
00237 reset($addKey);
00238 if (current($addKey)) {
00239 $this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType][key($addKey)] = key($addKey);
00240 } else {
00241 unset($this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType][key($addKey)]);
00242 }
00243 $update=1;
00244 }
00245 if ($POST["Submit"]) {
00246 $this->pObj->MOD_SETTINGS["tsbrowser_conditions"] = $POST["conditions"];
00247 $update=1;
00248 }
00249 if ($update){ $GLOBALS["BE_USER"]->pushModuleData($this->pObj->MCONF["name"],$this->pObj->MOD_SETTINGS);}
00250
00251
00252 $tmpl->matchAlternative = $this->pObj->MOD_SETTINGS["tsbrowser_conditions"];
00253 $tmpl->matchAlternative[] = "dummydummydummydummydummydummydummydummydummydummydummy";
00254
00255 $tmpl->constantMode = $this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"] ? "" : $this->pObj->MOD_SETTINGS["ts_browser_const"];
00256 if ($this->pObj->sObj && $tmpl->constantMode) {$tmpl->constantMode = "untouched";}
00257
00258 $tmpl->regexMode = $this->pObj->MOD_SETTINGS["ts_browser_regexsearch"];
00259 $tmpl->fixedLgd=$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"];
00260 # $tmpl->linkObjects=$this->pObj->MOD_SETTINGS["ts_browser_linkObjects"];
00261 $tmpl->linkObjects = TRUE;
00262 $tmpl->ext_regLinenumbers = TRUE;
00263 $tmpl->bType=$bType;
00264 $tmpl->resourceCheck=1;
00265 $tmpl->uplPath = PATH_site.$tmpl->uplPath;
00266 $tmpl->removeFromGetFilePath = PATH_site;
00267
00268
00269 if ($this->pObj->MOD_SETTINGS["ts_browser_type"]=="const") {
00270 $tmpl->ext_constants_BRP=intval(t3lib_div::_GP("breakPointLN"));
00271 } else {
00272 $tmpl->ext_config_BRP=intval(t3lib_div::_GP("breakPointLN"));
00273 }
00274 $tmpl->generateConfig();
00275
00276 if ($bType=="setup") {
00277 $theSetup = $tmpl->setup;
00278 } else {
00279 $theSetup = $tmpl->setup_constants;
00280 }
00281
00282
00283 if ($this->pObj->sObj) {
00284 list($theSetup,$theSetupValue) = $tmpl->ext_getSetup($theSetup, ($this->pObj->sObj?$this->pObj->sObj:""));
00285 $theOutput.=$this->pObj->doc->divider(5);
00286 if ($existTemplate) {
00287
00288 $out="";
00289 $out=$this->pObj->sObj." =<BR>";
00290 $out.='<input type="Text" name="data['.$this->pObj->sObj.'][value]" value="'.htmlspecialchars($theSetupValue).'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(40).'>';
00291 $out.='<input type="Submit" name="update_value" value="Update">';
00292 $theOutput.=$this->pObj->doc->section("Edit object/property value:",$out,0,0);
00293
00294
00295 if (t3lib_extMgm::isLoaded("tsconfig_help")) {
00296 $url=$BACK_PATH."wizard_tsconfig.php?mode=tsref&onlyProperty=1";
00297 $params=array();
00298 $params["formName"]="editForm";
00299 $params["itemName"]="data[".$this->pObj->sObj."][name]";
00300 $TSicon='<a href="#" onClick="vHWin=window.open(\''.$url.t3lib_div::implodeArrayForUrl("",array("P"=>$params)).'\',\'popUp'.$md5ID.'\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;"><img src="'.$BACK_PATH.'gfx/wizard_tsconfig_s.gif" width="22" height="16" border="0" class="absmiddle" hspace=2 title="TSref reference"></a>';
00301 } else $TSicon="";
00302 $out="";
00303 $out="<nobr>".$this->pObj->sObj.".";
00304 $out.='<input type="Text" name="data['.$this->pObj->sObj.'][name]"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'>'.$TSicon.' = </nobr><BR>';
00305 $out.='<input type="Text" name="data['.$this->pObj->sObj.'][propertyValue]"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(40).'>';
00306 $out.='<input type="Submit" name="add_property" value="Add">';
00307
00308
00309
00310 $theOutput.=$this->pObj->doc->spacer(20);
00311 $theOutput.=$this->pObj->doc->section("Add object property:",$out,0,0);
00312
00313
00314 $out="";
00315 $out=$this->pObj->sObj." <b>CLEAR?</b> ";
00316 $out.='<input type="Checkbox" name="data['.$this->pObj->sObj.'][clearValue]" value="1">';
00317 $out.='<input type="Submit" name="clear_object" value="Clear">';
00318 $theOutput.=$this->pObj->doc->spacer(20);
00319 $theOutput.=$this->pObj->doc->section("Clear object:",$out,0,0);
00320
00321 $theOutput.=$this->pObj->doc->spacer(10);
00322 } else {
00323 $theOutput.=$this->pObj->doc->section("EDIT:",$GLOBALS["TBE_TEMPLATE"]->rfw("You cannot edit properties and values, if there's no current template."),0,0,0,1);
00324 }
00325
00326 $out="";
00327 if (!$this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType][$this->pObj->sObj]) {
00328 if (count($theSetup)) {
00329 $out = '<a href="index.php?id='.$this->pObj->id.'&addKey['.$this->pObj->sObj.']=1&SET[ts_browser_toplevel_'.$bType.']='.rawurlencode($this->pObj->sObj).'"><b>Add key</b></a> "'.$this->pObj->sObj.'" to Object List (OL)';
00330 }
00331 } else {
00332 $out = '<a href="index.php?id='.$this->pObj->id.'&addKey['.$this->pObj->sObj.']=0&SET[ts_browser_toplevel_'.$bType.']=0"><b>Remove key</b></a> "'.$this->pObj->sObj.'" from Object List (OL)';
00333 }
00334 if ($out) {
00335 $theOutput.=$this->pObj->doc->divider(5);
00336 $theOutput.=$this->pObj->doc->section("",$out);
00337 }
00338
00339
00340 $out = "< Back";
00341 $out = '<a href="index.php?id='.$this->pObj->id.'"><b>'.$out.'</b></a>';
00342 $theOutput.=$this->pObj->doc->divider(5);
00343 $theOutput.=$this->pObj->doc->section("",$out);
00344
00345 } else {
00346 $tmpl->tsbrowser_depthKeys=$this->pObj->MOD_SETTINGS["tsbrowser_depthKeys_".$bType];
00347
00348
00349 if ($POST["search"] && $POST["search_field"]) {
00350 $tmpl->tsbrowser_depthKeys=$tmpl->ext_getSearchKeys($theSetup, "", $POST["search_field"], array());
00351
00352
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 if (count($this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType])) {
00370
00371 $this->pObj->MOD_MENU["ts_browser_toplevel_".$bType] = $this->pObj->MOD_MENU["ts_browser_toplevel_".$bType] + $this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType];
00372 }
00373
00374
00375
00376 $theOutput.=$this->pObj->doc->spacer(5);
00377 $theOutput.=$this->pObj->doc->section("Object tree:","",0,1);
00378
00379 $menu = "Browse: ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[ts_browser_type]",$bType,$this->pObj->MOD_MENU["ts_browser_type"]);
00380 $menu.= " OL: ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[ts_browser_toplevel_".$bType."]",$this->pObj->MOD_SETTINGS["ts_browser_toplevel_".$bType],$this->pObj->MOD_MENU["ts_browser_toplevel_".$bType]);
00381 $theOutput.=$this->pObj->doc->section("",'<NOBR>'.$menu.'</NOBR>');
00382
00383
00384 $theKey=$this->pObj->MOD_SETTINGS["ts_browser_toplevel_".$bType];
00385 if (!$theKey || !str_replace("-","",$theKey)) {$theKey="";}
00386 list($theSetup,$theSetupValue) = $tmpl->ext_getSetup($theSetup, ($this->pObj->MOD_SETTINGS["ts_browser_toplevel_".$bType]?$this->pObj->MOD_SETTINGS["ts_browser_toplevel_".$bType]:""));
00387 $tree = $tmpl->ext_getObjTree($theSetup, $theKey, "", "", $theSetupValue);
00388 $tree = $tmpl->substituteCMarkers($tree);
00389
00390
00391
00392
00393 $pEkey = ($bType=="setup"?"config":"constants");
00394 if (count($tmpl->parserErrors[$pEkey])) {
00395 reset($tmpl->parserErrors[$pEkey]);
00396 $errMsg=array();
00397 while(list(,$inf)=each($tmpl->parserErrors[$pEkey])) {
00398 $errMsg[]=($inf[1]).": ".$inf[0];
00399 }
00400 $theOutput.=$this->pObj->doc->spacer(10);
00401 $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("Errors and warnings"),implode($errMsg,"<br>"),0,1,0,1);
00402 }
00403
00404
00405
00406 if (isset($this->pObj->MOD_SETTINGS["ts_browser_TLKeys_".$bType][$theKey])) {
00407 $remove='<td width="1%" nowrap><a href="index.php?id='.$this->pObj->id.'&addKey['.$theKey.']=0&SET[ts_browser_toplevel_'.$bType.']=0"><b>Remove key from OL</b></a></td>';
00408 } else {
00409 $remove="";
00410 }
00411 $label = $theKey ? $theKey : ($bType=="setup"?"SETUP ROOT":"CONSTANTS ROOT");
00412 $theOutput.=$this->pObj->doc->spacer(15);
00413 $theOutput.=$this->pObj->doc->sectionEnd();
00414 $theOutput.='<table border=0 cellpadding=1 cellspacing=0 id="typo3-objectBrowser">';
00415 $theOutput.='<tr>
00416 <td><img src=clear.gif width=4 height=1></td>
00417 <td class="bgColor2">
00418 <table border=0 cellpadding=0 cellspacing=0 class="bgColor5" width="100%"><tr><td nowrap width="99%"><b>'.$label.'</b></td>'.$remove.'</tr></table>
00419 </td>
00420 </tr>';
00421 $theOutput.='<tr>
00422 <td><img src=clear.gif width=4 height=1></td>
00423 <td class="bgColor2">
00424 <table border=0 cellpadding=0 cellspacing=0 bgcolor="#D9D5C9" width="100%"><tr><td nowrap>'.$tree.'</td></tr></table><img src=clear.gif width=465 height=1></td>
00425 </tr>
00426 </table>
00427 ';
00428
00429
00430
00431 if (is_array($tmpl->sections)) {
00432 $theOutput.=$this->pObj->doc->divider(15);
00433
00434 $out="";
00435 reset($tmpl->sections);
00436 while(list($key,$val)=each($tmpl->sections)) {
00437 $out.='<tr><td><input type="Checkbox" name="conditions['.$key.']" value="'.htmlspecialchars($val).'"'.($this->pObj->MOD_SETTINGS["tsbrowser_conditions"][$key]?" checked":"").'></td><td nowrap>'.$tmpl->substituteCMarkers(htmlspecialchars($val)).' </td></tr>';
00438 }
00439 $theOutput.='
00440 <table border=0 cellpadding=1 cellspacing=0>
00441 <tr>
00442 <td><img src=clear.gif width=4 height=1></td>
00443 <td class="bgColor2">
00444 <table border=0 cellpadding=0 cellspacing=0 bgcolor="#D9D5C9">'.$out.'
00445 <tr>
00446 <td> </td>
00447 <td><img src=clear.gif height=10 width=240><BR><input type="Submit" name="Submit" value="Set conditions"><BR></td>
00448 </tr>
00449 </table>
00450 </td>
00451 </tr>
00452 </table>
00453
00454 ';
00455 }
00456
00457
00458 $theOutput.='<br>
00459
00460 <table border=0 cellpadding=1 cellspacing=0>
00461 <tr>
00462 <td><img src=clear.gif width=4 height=1></td>
00463 <td class="bgColor2">
00464 <table border=0 cellpadding=0 cellspacing=0 bgcolor="#D9D5C9">
00465 <tr>
00466 <td> Enter search phrase: <input type="Text" name="search_field" value="'.htmlspecialchars($POST["search_field"]).'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'></td>
00467 <td><input type="Submit" name="search" value="Search"></td>
00468 </tr>
00469 <tr>
00470 <td> Use ereg(), not stristr(): '.t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_browser_regexsearch]",$this->pObj->MOD_SETTINGS["ts_browser_regexsearch"]).'</td>
00471 <td> </td>
00472 </tr>
00473 </table>
00474 </td>
00475 </tr>
00476 </table>
00477 <br>
00478 ';
00479
00480
00481 $menu= "Crop lines".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_browser_fixedLgd]",$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"]);
00482 #$menu.= " Enable object links".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_browser_linkObjects]",$this->pObj->MOD_SETTINGS["ts_browser_linkObjects"]);
00483 if ($bType=="setup" && !$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"]) {
00484 $menu.= "<BR>Constants display: ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[ts_browser_const]",$this->pObj->MOD_SETTINGS["ts_browser_const"],$this->pObj->MOD_MENU["ts_browser_const"]);
00485 }
00486 $theOutput.=$this->pObj->doc->section("",'<NOBR>'.$menu.'</NOBR>');
00487
00488 $theOutput.=$this->pObj->doc->spacer(10);
00489 $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);
00490
00491 // Ending section:
00492 $theOutput.=$this->pObj->doc->sectionEnd();
00493 }
00494 return $theOutput;
00495 }
00496 }
00497
00498 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php"]) {
00499 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php"]);
00500 }
00501
00502 ?>