📄 class.tx_tstemplateinfo.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_tstemplateinfo extends t3lib_extobjbase { function modMenu() { global $LANG; return Array ( #"ts_template_editor_TArows" => "" ); } function tableRow($label,$data,$field) { $ret='<tr><td class="bgColor4" width="1%">'; $ret.='<a href="index.php?id='.$this->pObj->id.'&e['.$field.']=1"><img '.t3lib_iconWorks::skinImg($GLOBALS["BACK_PATH"],'gfx/edit2.gif').' width=11 height=12 hspace=3 border=0 title="Edit field"></a>'; $ret.='</td><td class="bgColor4" width="1%"><b>'.$label.' </b></td><td class="bgColor4" width="99%">'.$data.' </td></tr>'; return $ret; } function procesResources($resources,$func=0) { $arr = t3lib_div::trimExplode(",",$resources.",,",1); $out=""; if ($func) {$bgcol=' class="bgColor4"';} else {$bgcol="";} while(list($k,$v)=each($arr)) { $path = PATH_site.$GLOBALS["TCA"]["sys_template"]["columns"]["resources"]["config"]["uploadfolder"]."/".$v; $functions=""; if ($func) { $functions='<td bgcolor=red nowrap>Delete: <input type="Checkbox" name="data[remove_resource]['.$k.']" value="'.htmlspecialchars($v).'"></td>'; $functions.='<td'.$bgcol.' nowrap>To top: <input type="Checkbox" name="data[totop_resource]['.$k.']" value="'.htmlspecialchars($v).'"></td>'; $functions.='<td'.$bgcol.' nowrap>'; $fI=t3lib_div::split_fileref($v); if (t3lib_div::inList($this->pObj->textExtensions,$fI["fileext"])) { $functions.='<a href="index.php?id='.$this->pObj->id.'&e[file]='.rawurlencode($v).'"><img '.t3lib_iconWorks::skinImg($GLOBALS["BACK_PATH"],'gfx/edit2.gif').' width=11 height=12 hspace=3 border=0 title="Edit file"></a>'; } $functions.='</td>'; } $thumb=t3lib_BEfunc::thumbCode(array("resources"=>$v),"sys_template","resources",$GLOBALS["BACK_PATH"],""); $out.='<tr><td'.$bgcol.' nowrap>'.$v.' </td><td'.$bgcol.' nowrap> '.t3lib_div::formatSize(@filesize($path)).' </td>'.$functions.'<td'.$bgcol.'>'.trim($thumb).'</td></tr>'; } if ($out) { if ($func) { $out = '<table border=0 cellpadding=1 cellspacing=1 width="100%">'.$out.'</table>'; $out='<table border=0 cellpadding=0 cellspacing=0> <tr><td class="bgColor2">'.$out.'<img src=clear.gif width=465 height=1></td></tr> </table>'; } else { $out = '<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>'; } } return $out; } function resourceListForCopy($id,$template_uid) { global $tmpl; $sys_page = t3lib_div::makeInstance("t3lib_pageSelect"); $rootLine = $sys_page->getRootLine($id); $tmpl->runThroughTemplates($rootLine,$template_uid); // This generates the constants/config + hierarchy info for the template. $theResources = t3lib_div::trimExplode(",",$tmpl->resources,1); reset($theResources); while(list($k,$v)=each($theResources)) { $fI=pathinfo($v); if (t3lib_div::inList($this->pObj->textExtensions,strtolower($fI["extension"]))) { $path = PATH_site.$GLOBALS["TCA"]["sys_template"]["columns"]["resources"]["config"]["uploadfolder"]."/".$v; $thumb=t3lib_BEfunc::thumbCode(array("resources"=>$v),"sys_template","resources",$GLOBALS["BACK_PATH"],""); $out.='<tr><td'.$bgcol.' nowrap>'.$v.' </td><td'.$bgcol.' nowrap> '.t3lib_div::formatSize(@filesize($path)).' </td><td'.$bgcol.'>'.trim($thumb).'</td><td><input type="Checkbox" name="data[makecopy_resource]['.$k.']" value="'.htmlspecialchars($v).'"></td></tr>'; } } $out = $out ? '<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>' : ""; return $out; } 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(); $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)) { return 1; } } function main() { global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; global $tmpl,$tplRow,$theConstants; $edit = $this->pObj->edit; $e = $this->pObj->e; t3lib_div::loadTCA("sys_template"); // ************************** // Create extension template // ************************** $this->pObj->createTemplate($this->pObj->id); // ************************** // 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"]; } // ************************** // Initialize // ************************** $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid); // initialize if ($existTemplate) { $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; // Update template ? $POST = t3lib_div::_POST(); if ($POST["submit"]) { require_once (PATH_t3lib."class.t3lib_tcemain.php"); // Set the data to be saved $recData=array(); $alternativeFileName=array(); $resList = $tplRow["resources"]; $tmp_upload_name = ''; $tmp_newresource_name = ''; // Set this to blank if (is_array($POST["data"])) { while(list($field,$val)=each($POST["data"])) { switch($field) { case "constants": case "config": case "title": case "sitetitle": case "description": $recData["sys_template"][$saveId][$field] = $val; break; case "resources": $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES["resources"]["tmp_name"]); // If there is an uploaded file, move it for the sake of safe_mode. if ($tmp_upload_name) { if ($tmp_upload_name!="none" && $_FILES["resources"]["name"]) { $alternativeFileName[$tmp_upload_name] = trim($_FILES["resources"]["name"]); $resList = $tmp_upload_name.",".$resList; } } break; case "new_resource": $newName = trim(t3lib_div::_GP("new_resource")); if ($newName) { $newName.=".".t3lib_div::_GP("new_resource_ext"); $tmp_newresource_name = t3lib_div::tempnam("new_resource_"); $alternativeFileName[$tmp_newresource_name] = $newName; $resList = $tmp_newresource_name.",".$resList; } break; case "makecopy_resource": if (is_array($val)) { reset($val); $resList=",".$resList.","; while(list($k,$file)=each($val)) { $tmp_name = PATH_site.$TCA["sys_template"]["columns"]["resources"]["config"]["uploadfolder"]."/".$file; // debug($tmp_name); $resList = $tmp_name.",".$resList; } } break; case "remove_resource": if (is_array($val)) { reset($val); $resList=",".$resList.","; while(list($k,$file)=each($val)) { $resList = str_replace(",".$file.",", ",", $resList); } } break; case "totop_resource": if (is_array($val)) { reset($val); $resList=",".$resList.","; while(list($k,$file)=each($val)) { $resList = str_replace(",".$file.",", ",", $resList); $resList = ",".$file.$resList; } } // debug($resList); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -