X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/c559ba094d7d3fc9d93c7d0dd834c400779aa154..fb892d17a5e85860cf1f452d01da3c3fab909119:/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php diff --git a/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php b/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php index b4ec7ad0392..764620d8aa2 100644 --- a/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php +++ b/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * -* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) +* (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -25,49 +25,81 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** - * @author Kasper Skårhøj + * [CLASS/FUNCTION INDEX of SCRIPT] + * + * + * + * 49: class tx_tstemplateinfo extends t3lib_extobjbase + * 63: function tableRow($label, $data, $field) + * 77: function procesResources($resources, $func=false) + * 117: function resourceListForCopy($id, $template_uid) + * 143: function initialize_editor($pageId, $template_uid=0) + * 160: function main() + * + * TOTAL FUNCTIONS: 5 + * (This index is automatically created/updated by the extension "extdeveval") + * */ -require_once(PATH_t3lib."class.t3lib_extobjbase.php"); +$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_info/locallang.xml'); +/** + * This class displays the Info/Modify screen of the Web > Template module + * + * @author Kasper Skaarhoj + * + * $Id$ + */ class tx_tstemplateinfo extends t3lib_extobjbase { - function modMenu() { - global $LANG; - return Array ( - #"ts_template_editor_TArows" => "" - ); - } - function tableRow($label,$data,$field) { - $ret=''; - $ret.=''; - $ret.=''.$label.'  '.$data.' '; + public $tce_processed = false; // indicator for t3editor, whether data is stored + + /** + * Creates a row for a HTML table + * + * @param string $label: The label to be shown (e.g. 'Title:', 'Sitetitle:') + * @param string $data: The data/information to be shown (e.g. 'Template for my site') + * @param string $field: The field/variable to be sent on clicking the edit icon (e.g. 'title', 'sitetitle') + * @return string A row for a HTML table + */ + function tableRow($label, $data, $field) { + $ret = ''; + $ret.= ''; + $ret.= ''.$label.'  '.$data.' '; 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=""; + + /** + * Renders HTML table with available template resources/files + * + * @param string $resources: List of resources/files to be shown (e.g. 'file_01.txt,file.txt') + * @param boolean $func: Whether to render functions like 'to top' or 'delete' for each resource (default: false) + * @return string HTML table with available template resources/files + */ + function procesResources($resources, $func=false) { + $arr = t3lib_div::trimExplode(',', $resources.',,', 1); + $out = ''; + $bgcol = ($func ? ' class="bgColor4"' : ''); + foreach ($arr as $k => $v) { + $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v; + $functions = ''; if ($func) { - $functions='Delete: '; - $functions.='To top: '; - $functions.=''; - $fI=t3lib_div::split_fileref($v); - if (t3lib_div::inList($this->pObj->textExtensions,$fI["fileext"])) { - $functions.=''; + $functions = '' . $GLOBALS['LANG']->getLL('delete') . ' '; + $functions.= '' . $GLOBALS['LANG']->getLL('toTop') . ' '; + $functions.= ''; + $fI = t3lib_div::split_fileref($v); + if (t3lib_div::inList($this->pObj->textExtensions,$fI['fileext'])) { + $functions.= ''; } - $functions.=''; + $functions.= ''; } - $thumb=t3lib_BEfunc::thumbCode(array("resources"=>$v),"sys_template","resources",$GLOBALS["BACK_PATH"],""); - $out.=''.$v.'   '.t3lib_div::formatSize(@filesize($path)).' '.$functions.''.trim($thumb).''; + $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], ''); + $out.= ''.$v.'   '.t3lib_div::formatSize(@filesize($path)).' '.$functions.''.trim($thumb).''; } if ($out) { if ($func) { $out = ''.$out.'
'; - $out=' + $out = '
'.$out.'
'; } else { @@ -76,37 +108,57 @@ class tx_tstemplateinfo extends t3lib_extobjbase { } return $out; } - function resourceListForCopy($id,$template_uid) { + + /** + * Renders HTML table with all available template resources/files in the current rootline that could be copied + * + * @param integer $id: The uid of the current page + * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page) + * @return string HTML table with all available template resources/files in the current rootline that could be copied + */ + function resourceListForCopy($id, $template_uid) { global $tmpl; - $sys_page = t3lib_div::makeInstance("t3lib_pageSelect"); + $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.=''.$v.'   '.t3lib_div::formatSize(@filesize($path)).' '.trim($thumb).''; + $tmpl->runThroughTemplates($rootLine, $template_uid); // This generates the constants/config + hierarchy info for the template. + $theResources = t3lib_div::trimExplode(',', $tmpl->resources, 1); + foreach ($theResources as $k => $v) { + $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.= ''.$v.'   '.t3lib_div::formatSize(@filesize($path)).' '.trim($thumb).''; } } - $out = $out ? ''.$out.'
' : ""; + $out = ($out ? ''.$out.'
' : ''); return $out; } - function initialize_editor($pageId,$template_uid=0) { + + /** + * Create an instance of t3lib_tsparser_ext in $GLOBALS['tmpl'] and looks for the first (visible) template + * record. If $template_uid was given and greater than zero, this record will be checked. + * + * @param integer $id: The uid of the current page + * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page) + * @return boolean Returns true if a template record was found, otherwise false + */ + 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 = 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; - } + $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid); // Get the row of the first VISIBLE template of the page. whereclause like the frontend. + return (is_array($tplRow) ? true : false); } + + /** + * The main processing method if this class + * + * @return string Information of the template status or the taken actions as HTML string + */ function main() { global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; global $tmpl,$tplRow,$theConstants; @@ -114,12 +166,9 @@ class tx_tstemplateinfo extends t3lib_extobjbase { $edit = $this->pObj->edit; $e = $this->pObj->e; - t3lib_div::loadTCA("sys_template"); + t3lib_div::loadTCA('sys_template'); + - // ************************** - // Create extension template - // ************************** - $this->pObj->createTemplate($this->pObj->id); // ************************** @@ -128,114 +177,118 @@ class tx_tstemplateinfo extends t3lib_extobjbase { $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { - $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"]; + $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } - - - // ************************** // Initialize // ************************** - $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid); // initialize + $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize + if ($existTemplate) { - $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; + $saveId = ($tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']); + } + // ************************** + // Create extension template + // ************************** + $newId = $this->pObj->createTemplate($this->pObj->id, $saveId); + if($newId) { + // switch to new template + header('location: index.php?id=' . $this->pObj->id. '&SET[templatesOnPage]=' . $newId); + } + if ($existTemplate) { // Update template ? $POST = t3lib_div::_POST(); - if ($POST["submit"]) { - require_once (PATH_t3lib."class.t3lib_tcemain.php"); + if ($POST['submit'] || (t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y'])) + || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) { // Set the data to be saved - $recData=array(); - $alternativeFileName=array(); - $resList = $tplRow["resources"]; + $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 (is_array($POST['data'])) { + foreach ($POST['data'] as $field => $val) { + 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; + 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")); + 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_"); + $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; + $resList = $tmp_newresource_name.','.$resList; } - break; - case "makecopy_resource": + 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; + $resList = ','.$resList.','; + foreach ($val as $k => $file) { + $tmp_name = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$file; + $resList = $tmp_name.','.$resList; } } - break; - case "remove_resource": + break; + case 'remove_resource': if (is_array($val)) { - reset($val); - $resList=",".$resList.","; - while(list($k,$file)=each($val)) { - $resList = str_replace(",".$file.",", ",", $resList); + $resList = ','.$resList.','; + foreach ($val as $k => $file) { + $resList = str_replace(','.$file.',', ',', $resList); } } - break; - case "totop_resource": + 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; + $resList = ','.$resList.','; + foreach ($val as $k => $file) { + $resList = str_replace(','.$file.',', ',', $resList); + $resList = ','.$file.$resList; } } - // debug($resList); - break; + break; } } } - $resList=implode(t3lib_div::trimExplode(",",$resList,1),","); - if (strcmp($resList,$tplRow["resources"])) { - $recData["sys_template"][$saveId]["resources"] = $resList; - // debug("update resource - ".$resList); + $resList=implode(',', t3lib_div::trimExplode(',', $resList, 1)); + if (strcmp($resList, $tplRow['resources'])) { + $recData['sys_template'][$saveId]['resources'] = $resList; } if (count($recData)) { // Create new tce-object - $tce = t3lib_div::makeInstance("t3lib_TCEmain"); + $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values=0; $tce->alternativeFileName = $alternativeFileName; // Initialize - // debug($recData); - $tce->start($recData,Array()); + $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"); + $tce->clear_cacheCmd('all'); + + // tce were processed successfully + $this->tce_processed = true; // re-read the template ... - $this->initialize_editor($this->pObj->id,$template_uid); + $this->initialize_editor($this->pObj->id, $template_uid); } // Unlink any uploaded/new temp files there was: @@ -244,186 +297,242 @@ class tx_tstemplateinfo extends t3lib_extobjbase { // If files has been edited: if (is_array($edit)) { - if ($edit["filename"] && $tplRow["resources"] && t3lib_div::inList($tplRow["resources"], $edit["filename"])) { // Check if there are resources, and that the file is in the resourcelist. - $path = PATH_site.$TCA["sys_template"]["columns"]["resources"]["config"]["uploadfolder"]."/".$edit["filename"]; - $fI=t3lib_div::split_fileref($edit["filename"]); - if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions,$fI["fileext"])) { // checks that have already been done.. Just to make sure - if (filesize($path)<(30*1024)) { // checks that have already been done.. Just to make sure - t3lib_div::writeFile($path,$edit['file']); - - $theOutput.=$this->pObj->doc->spacer(10); - $theOutput.=$this->pObj->doc->section("FILE CHANGED","Resource '".$edit["filename"]."' has been updated.",0,0,0,1); + if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) { // Check if there are resources, and that the file is in the resourcelist. + $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$edit['filename']; + $fI = t3lib_div::split_fileref($edit['filename']); + if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) { // checks that have already been done.. Just to make sure + // @TODO: Check if the hardcorded value already has a config member, otherwise create one + if (filesize($path) < 30720) { // checks that have already been done.. Just to make sure + t3lib_div::writeFile($path, $edit['file']); + + $theOutput.= $this->pObj->doc->spacer(10); + $theOutput.= $this->pObj->doc->section( + '' . $GLOBALS['LANG']->getLL('fileChanged') . '', + sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), + 0, 0, 0, 1 + ); // Clear cache - the file has probably affected the template setup - $tce = t3lib_div::makeInstance("t3lib_TCEmain"); - $tce->stripslashes_values=0; - $tce->start(Array(),Array()); - $tce->clear_cacheCmd("all"); + // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible! + $tce = t3lib_div::makeInstance('t3lib_TCEmain'); + $tce->stripslashes_values = 0; + $tce->start(array(), array()); + $tce->clear_cacheCmd('all'); } } } } } - $theOutput.=$this->pObj->doc->spacer(5); - $theOutput.=$this->pObj->doc->section("Template information:",''.htmlspecialchars($tplRow["title"]).''.htmlspecialchars(trim($tplRow["sitetitle"])?' - ('.$tplRow["sitetitle"].')':''),0,1); + // hook Post updating template/TCE processing + if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) { + $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook']; + if (is_array($postTCEProcessingHook)) { + $hookParameters = array( + 'POST' => $POST, + 'tce' => $tce, + ); + foreach ($postTCEProcessingHook as $hookFunction) { + t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); + } + } + } + + $theOutput.= $this->pObj->doc->spacer(5); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), ' '.htmlspecialchars($tplRow['title']).''.htmlspecialchars(trim($tplRow['sitetitle'])?' - ('.$tplRow['sitetitle'].')':''), 0, 1); if ($manyTemplatesMenu) { - $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu); - $theOutput.=$this->pObj->doc->divider(5); + $theOutput.= $this->pObj->doc->section('', $manyTemplatesMenu); + $theOutput.= $this->pObj->doc->divider(5); } - /* $e[constants]=1; - $e[config]=1; - $e[title]=1; - $e[sitetitle]=1; - */ #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150); #if (!$numberOfRows) $numberOfRows = 35; - if (t3lib_div::_POST('abort')) {unset($e);} // If abort pressed, nothing should be edited. - - if (is_array($e)) { - $theOutput.=$this->pObj->doc->section("",'
'); + // If abort pressed, nothing should be edited: + if ($POST['abort'] || (t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y'])) + || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) { + unset($e); } - if ($e["title"]) { - $outCode='pObj->doc->formWidth().'>'; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Title:",$outCode); + + if ($e['title']) { + $outCode = 'pObj->doc->formWidth().'>'; + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode); } - if ($e["sitetitle"]) { - $outCode='pObj->doc->formWidth().'>'; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Sitetitle:",$outCode); + if ($e['sitetitle']) { + $outCode = 'pObj->doc->formWidth().'>'; + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode); } - if ($e["description"]) { - $outCode=''; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Description:",$outCode); + if ($e['description']) { + $outCode = ''; + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode); } - if ($e["resources"]) { + if ($e['resources']) { // Upload - $outCode='pObj->doc->formWidth().' size="50">'; - $outCode.=''; - $outCode.=''; - $outCode.='
Allowed extensions: '.$TCA["sys_template"]["columns"]["resources"]["config"]["allowed"].''; - $outCode.='
Max file size: '.t3lib_div::formatSize($TCA["sys_template"]["columns"]["resources"]["config"]["max_size"]*1024).''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Upload resource:",$outCode); + $outCode = 'pObj->doc->formWidth().' size="50">'; + $outCode.= ''; + $outCode.= ''; + $outCode.= '
' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' ' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . ''; + $outCode.= '
' . $GLOBALS['LANG']->getLL('maxFilesize') . ' ' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size']*1024) . ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode); // New - $opt=explode(",",$this->pObj->textExtensions); - $optTags=""; - while(list(,$extVal)=each($opt)) { - $optTags.=''; + $opt = explode(',', $this->pObj->textExtensions); + $optTags = ''; + foreach ($opt as $extVal) { + $optTags.= ''; } - $outCode='pObj->doc->formWidth(20).'> + $outCode = 'pObj->doc->formWidth(20).'> '; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("New text resource (enter name):",$outCode); + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode); // Make copy - $rL = $this->resourceListForCopy($this->pObj->id,$template_uid); + $rL = $this->resourceListForCopy($this->pObj->id, $template_uid); if ($rL) { - $theOutput.=$this->pObj->doc->spacer(20); - $theOutput.=$this->pObj->doc->section("Make a copy of resource:",$rL); + $theOutput.= $this->pObj->doc->spacer(20); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL); } // Update resource list - $rL = $this->procesResources($tplRow["resources"],1); + $rL = $this->procesResources($tplRow['resources'], 1); if ($rL) { - $theOutput.=$this->pObj->doc->spacer(20); - $theOutput.=$this->pObj->doc->section("Update resource list:",$rL); + $theOutput.= $this->pObj->doc->spacer(20); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL); } } - if ($e["constants"]) { - $outCode=''; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Constants:",""); - $theOutput.=$this->pObj->doc->sectionEnd().$outCode; + if ($e['constants']) { + $outCode = ''; + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), ''); + $theOutput.= $this->pObj->doc->sectionEnd().$outCode; } - if ($e["file"]) { - $path = PATH_site.$TCA["sys_template"]["columns"]["resources"]["config"]["uploadfolder"]."/".$e[file]; + if ($e['file']) { + $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$e[file]; - $fI=t3lib_div::split_fileref($e[file]); - if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions,$fI["fileext"])) { - if (filesize($path)<($TCA['sys_template']['columns']['resources']['config']['max_size']*1024)) { + $fI = t3lib_div::split_fileref($e[file]); + if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) { + if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size']*1024) { $fileContent = t3lib_div::getUrl($path); - $outCode='File: '.$e[file].'
'; - $outCode.=''; - $outCode.=''; - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Edit Resource:",""); - $theOutput.=$this->pObj->doc->sectionEnd().$outCode; + $outCode = $GLOBALS['LANG']->getLL('file'). ' ' . $e[file] . '
'; + $outCode.= ''; + $outCode.= ''; + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), ''); + $theOutput.= $this->pObj->doc->sectionEnd().$outCode; } else { - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section('Filesize exceeded '.$TCA['sys_template']['columns']['resources']['config']['max_size'].' Kbytes','Files larger than '.$TCA['sys_template']['columns']['resources']['config']['max_size'].' KByes are not allowed to be edited.',0,0,0,1); + $theOutput.= $this->pObj->doc->spacer(15); + $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']); + $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']); + $theOutput.= $this->pObj->doc->section( + '' . $fileToBig . '', + $filesizeNotAllowed, + 0, 0, 0, 1 + ); } } } - if ($e["config"]) { + if ($e['config']) { $outCode=''; - if (t3lib_extMgm::isLoaded("tsconfig_help")) { - $url=$BACK_PATH."wizard_tsconfig.php?mode=tsref"; - $params=array(); - $params["formName"]="editForm"; - $params["itemName"]="data[config]"; - $outCode.='$params)).'\',\'popUp'.$md5ID.'\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">'; + if (t3lib_extMgm::isLoaded('tsconfig_help')) { + $url = $BACK_PATH.'wizard_tsconfig.php?mode=tsref'; + $params = array( + 'formName' => 'editForm', + 'itemName' => 'data[config]', + ); + $outCode.= ''; } - $outCode.=''; - $theOutput.=$this->pObj->doc->spacer(15); - $theOutput.=$this->pObj->doc->section("Setup:",""); - $theOutput.=$this->pObj->doc->sectionEnd().$outCode; - } - if (is_array($e)) { - $theOutput.=$this->pObj->doc->section("",'
'); + $outCode.= ''; + $theOutput.= $this->pObj->doc->spacer(15); + $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), ''); + $theOutput.= $this->pObj->doc->sectionEnd().$outCode; } - // Processing: - // debug($tplRow); - $outCode=""; - $outCode.=$this->tableRow("Title:",htmlspecialchars($tplRow["title"]),"title"); - $outCode.=$this->tableRow("Sitetitle:",htmlspecialchars($tplRow["sitetitle"]),"sitetitle"); - $outCode.=$this->tableRow("Description:",nl2br(htmlspecialchars($tplRow["description"])),"description"); - $outCode.=$this->tableRow("Resources:",$this->procesResources($tplRow["resources"]),"resources"); - $outCode.=$this->tableRow("Constants:","(edit to view, ".(trim($tplRow[constants]) ? count(explode(chr(10), $tplRow[constants])):0)." lines)","constants"); - $outCode.=$this->tableRow("Setup:","(edit to view, ".(trim($tplRow[config]) ? count(explode(chr(10), $tplRow[config])):0)." lines)","config"); - $outCode=''.$outCode.'
'; - - $outCode=' + // Processing: + $outCode = ''; + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('title'), + htmlspecialchars($tplRow['title']), + 'title' + ); + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('sitetitle'), + htmlspecialchars($tplRow['sitetitle']), + 'sitetitle' + ); + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('description'), + nl2br(htmlspecialchars($tplRow['description'])), + 'description' + ); + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('resources'), + $this->procesResources($tplRow['resources']), + 'resources' + ); + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('constants'), + sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[constants]) ? count(explode(chr(10), $tplRow[constants])) : 0)), + 'constants' + ); + $outCode.= $this->tableRow( + $GLOBALS['LANG']->getLL('setup'), + sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[config]) ? count(explode(chr(10), $tplRow[config])) : 0)), + 'config' + ); + $outCode = '
'.$outCode.'
'; + + $outCode = '
'.$outCode.'
'; // Edit all icon: - $outCode.='
Click here to edit whole template record'; - - $theOutput.=$this->pObj->doc->spacer(25); - $theOutput.=$this->pObj->doc->section("",$outCode); - - $theOutput.=$this->pObj->doc->spacer(10); - $theOutput.=$this->pObj->doc->section("Cache",'Click here to clear all cache.

- Status: '.$this->pObj->getCountCacheTables(1),0,1); + $outCode.= '
' . $GLOBALS['LANG']->getLL('editTemplateRecord') . ''; + + $theOutput.= $this->pObj->doc->spacer(25); + $theOutput.= $this->pObj->doc->section('', $outCode); + + + // hook after compiling the output + if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) { + $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook']; + if (is_array($postOutputProcessingHook)) { + $hookParameters = array( + 'theOutput' => &$theOutput, + 'POST' => $POST, + 'e' => $e, + 'tplRow' => $tplRow, + 'numberOfRows' => $numberOfRows + ); + foreach ($postOutputProcessingHook as $hookFunction) { + t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); + } + } + } - // $theOutput.=$this->pObj->doc->divider(5); -# $menu = htmlspecialchars("Rows in