📄 class.tx_tstemplateobjbrowser.php
字号:
<?php/**************************************************************** Copyright notice** (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)* All rights reserved** This script is part of the TYPO3 project. The TYPO3 project is* free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** The GNU General Public License can be found at* http://www.gnu.org/copyleft/gpl.html.* A copy is found in the textfile GPL.txt and important notices to the license* from the author is found in LICENSE.txt distributed with these scripts.*** This script is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * @author Kasper Sk錼h鴍 <kasperYYYY@typo3.com> */require_once(PATH_t3lib."class.t3lib_extobjbase.php");class tx_tstemplateobjbrowser extends t3lib_extobjbase { function modMenu() { global $LANG; $modMenu = array ( "ts_browser_type" => array( "setup" => "Setup", "const" => "Constants" ), "ts_browser_toplevel_setup" => array( "0" => "ALL" ), "ts_browser_toplevel_const" => array( "0" => "ALL" ), "ts_browser_const" => array( "0" => "Plain substitution (default)", "subst" => "Substituted constants in green", "const" => "UN-substituted constants in green" ), "ts_browser_regexsearch" => "", "ts_browser_fixedLgd" => "1", "ts_browser_linkObjects" => "1", 'ts_browser_alphaSort' => '1', ); foreach(array('setup','const') as $bType) { $addKey = t3lib_div::_GET('addKey'); if (is_array($addKey)) { // If any plus-signs were clicked, it's registred. reset($addKey); if (current($addKey)) { $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_'.$bType][key($addKey)] = key($addKey); } else { unset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_'.$bType][key($addKey)]); } $GLOBALS['BE_USER']->pushModuleData($this->pObj->MCONF['name'],$this->pObj->MOD_SETTINGS); } if (count($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_'.$bType])) { $modMenu['ts_browser_toplevel_'.$bType]['-']='---'; $modMenu['ts_browser_toplevel_'.$bType] = $modMenu['ts_browser_toplevel_'.$bType] + $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_'.$bType]; } } return $modMenu; } /** * [Describe function...] * * @param [type] $propertyArray: ... * @param [type] $parentType: ... * @param [type] $parentValue: ... * @return [type] ... */ function verify_TSobjects($propertyArray,$parentType,$parentValue) { $TSobjTable = array( "PAGE" => array( "prop" => array ( "typeNum" => "int", "1,2,3" => "COBJ", "bodyTag" => "string" ) ), "TEXT" => array( "prop" => array ( "value" => "string" ) ), "HTML" => array( "prop" => array ( "value" => "stdWrap" ) ), "stdWrap" => array( "prop" => array ( "field" => "string", "current" => "boolean" ) ), ); $TSobjDataTypes = array( "COBJ" => "TEXT,CONTENT", "PAGE" => "PAGE", "stdWrap" => "" ); if ($parentType) { if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || t3lib_div::inlist($TSobjDataTypes[$parentType],$parentValue))) { $ObjectKind = $parentValue; } else { $ObjectKind = ""; // Object kind is "" if it should be known. } } else { $ObjectKind = $parentValue; // If parentType is not given, then it can be anything. Free. } if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) { $result=array(); if (is_array($propertyArray)) { reset($propertyArray); while(list($key,$val)=each($propertyArray)) { if (t3lib_div::testInt($key)) { // If num-arrays $result[$key]=$TSobjTable[$ObjectKind]["prop"]["1,2,3"]; } else { // standard $result[$key]=$TSobjTable[$ObjectKind]["prop"][$key]; } } } return $result; } } /** * [Describe function...] * * @param [type] $pageId: ... * @param [type] $template_uid: ... * @return [type] ... */ function initialize_editor($pageId,$template_uid=0) { // Initializes the module. Done in this function because we may need to re-initialize if data is submitted! global $tmpl,$tplRow,$theConstants; $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext"); // Defined global here! $tmpl->tt_track = 0; // Do not log time-performance information $tmpl->init(); // Gets the rootLine $sys_page = t3lib_div::makeInstance("t3lib_pageSelect"); $rootLine = $sys_page->getRootLine($pageId); $tmpl->runThroughTemplates($rootLine,$template_uid); // This generates the constants/config + hierarchy info for the template. $tplRow = $tmpl->ext_getFirstTemplate($pageId,$template_uid); // Get the row of the first VISIBLE template of the page. whereclause like the frontend. if (is_array($tplRow)) { // IF there was a template... return 1; } } /** * [Describe function...] * * @return [type] ... */ function main() { global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; global $tmpl,$tplRow,$theConstants; $POST = t3lib_div::_POST(); // ************************** // Checking for more than one template an if, set a menu... // ************************** $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"]; } // ************************** // Main // ************************** // BUGBUG: Should we check if the uset may at all read and write template-records??? $bType= $this->pObj->MOD_SETTINGS["ts_browser_type"]; $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid); // initialize if ($existTemplate) { $theOutput.=$this->pObj->doc->divider(5); $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); if ($manyTemplatesMenu) { $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu); $theOutput.=$this->pObj->doc->divider(5); } if ($POST["add_property"] || $POST["update_value"] || $POST["clear_object"]) { // add property $line=""; // debug($POST); if (is_array($POST["data"])) { $name = key($POST["data"]); if ($POST['data'][$name]['name']!=='') { // Workaround for this special case: User adds a key and submits by pressing the return key. The form however will use "add_property" which is the name of the first submit button in this form. unset($POST['update_value']); $POST['add_property'] = 'Add'; } if ($POST["add_property"]) { $property = trim($POST["data"][$name]["name"]); if (ereg_replace("[^a-zA-Z0-9_\.]*","",$property)!=$property) { $theOutput.=$this->pObj->doc->spacer(10); $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); } else { $pline= $name.".".$property." = ".trim($POST["data"][$name]["propertyValue"]); $theOutput.=$this->pObj->doc->spacer(10); $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("PROPERTY ADDED"),htmlspecialchars($pline),0,0,0,1); $line.=chr(10).$pline; } } elseif ($POST['update_value']) { $pline= $name." = ".trim($POST["data"][$name]["value"]); $theOutput.=$this->pObj->doc->spacer(10); $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("VALUE UPDATED"),htmlspecialchars($pline),0,0,0,1); $line.=chr(10).$pline; } elseif ($POST['clear_object']) { if ($POST["data"][$name]["clearValue"]) { $pline= $name." >"; $theOutput.=$this->pObj->doc->spacer(10); $theOutput.=$this->pObj->doc->section($GLOBALS["TBE_TEMPLATE"]->rfw("Object cleared"),htmlspecialchars($pline),0,0,0,1); $line.=chr(10).$pline; } } } if ($line) { require_once (PATH_t3lib."class.t3lib_tcemain.php"); $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; // Set the data to be saved $recData=array(); $field =$bType=="setup"?"config":"constants"; $recData["sys_template"][$saveId][$field] = $tplRow[$field].$line; // Create new tce-object $tce = t3lib_div::makeInstance("t3lib_TCEmain"); $tce->stripslashes_values=0; // Initialize $tce->start($recData,Array()); // Saved the stuff $tce->process_datamap(); // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) $tce->clear_cacheCmd("all"); // re-read the template ... $this->initialize_editor($this->pObj->id,$template_uid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -