TYPO3 API  SVNRelease
class.tx_tstemplateinfo.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * [CLASS/FUNCTION INDEX of SCRIPT]
00029  *
00030  *
00031  *
00032  *   49: class tx_tstemplateinfo extends t3lib_extobjbase
00033  *   63:     function tableRow($label, $data, $field)
00034  *   77:     function procesResources($resources, $func=false)
00035  *  117:     function resourceListForCopy($id, $template_uid)
00036  *  143:     function initialize_editor($pageId, $template_uid=0)
00037  *  160:     function main()
00038  *
00039  * TOTAL FUNCTIONS: 5
00040  * (This index is automatically created/updated by the extension "extdeveval")
00041  *
00042  */
00043 
00044 $GLOBALS['LANG']->includeLLFile('EXT:tstemplate_info/locallang.xml');
00045 
00046 /**
00047  * This class displays the Info/Modify screen of the Web > Template module
00048  *
00049  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00050  *
00051  * $Id: class.tx_tstemplateinfo.php 10120 2011-01-18 20:03:36Z ohader $
00052  */
00053 class tx_tstemplateinfo extends t3lib_extobjbase {
00054 
00055     public $tce_processed = false;  // indicator for t3editor, whether data is stored
00056     
00057     /**
00058      * Creates a row for a HTML table
00059      *
00060      * @param   string      $label: The label to be shown (e.g. 'Title:', 'Sitetitle:')
00061      * @param   string      $data: The data/information to be shown (e.g. 'Template for my site')
00062      * @param   string      $field: The field/variable to be sent on clicking the edit icon (e.g. 'title', 'sitetitle')
00063      * @return  string      A row for a HTML table
00064      */
00065     function tableRow($label, $data, $field)    {
00066         $ret = '<tr><td>';
00067         $ret.= '<a href="index.php?id=' . $this->pObj->id . '&e[' . $field . ']=1">' .
00068             t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:editField', true))) . '<strong>' . $label . '&nbsp;&nbsp;</strong></a>';
00069         $ret .= '</td><td width="80%" class="bgColor4">' . $data . '&nbsp;</td></tr>';
00070         return $ret;
00071     }
00072 
00073     /**
00074      * Renders HTML table with available template resources/files
00075      *
00076      * @param   string      $resources: List of  resources/files to be shown (e.g. 'file_01.txt,file.txt')
00077      * @param   boolean     $func: Whether to render functions like 'to top' or 'delete' for each resource (default: false)
00078      * @return  string      HTML table with available template resources/files
00079      */
00080     function procesResources($resources, $func=false)   {
00081         $arr = t3lib_div::trimExplode(',', $resources.',,', 1);
00082         $out = '';
00083         $bgcol = ($func ? ' class="bgColor4"' : '');
00084         foreach ($arr as $k => $v) {
00085             $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
00086             $functions = '';
00087             if ($func)  {
00088                 $functions = '<td bgcolor="red" nowrap="nowrap">' . $GLOBALS['LANG']->getLL('delete') . ' <input type="checkbox" name="data[remove_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
00089                 $functions .= '<td' . $bgcol . ' nowrap="nowrap">' . $GLOBALS['LANG']->getLL('toTop') . ' <input type="checkbox" name="data[totop_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
00090                 $functions .= '<td' . $bgcol . ' nowrap="nowrap">';
00091                 $fI = t3lib_div::split_fileref($v);
00092                 if (t3lib_div::inList($this->pObj->textExtensions,$fI['fileext']))  {
00093                     $functions.= '<a href="index.php?id='.$this->pObj->id.'&e[file]='.rawurlencode($v).'">'.t3lib_iconWorks::getSpriteIcon('actions-document-open',array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:editFile', true))) . '</a>';
00094                 }
00095                 $functions.= '</td>';
00096             }
00097             $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
00098             $out .= '<tr><td' . $bgcol . ' nowrap="nowrap">' . $v . '&nbsp;&nbsp;</td><td' . $bgcol . ' nowrap="nowrap">&nbsp;' . t3lib_div::formatSize(@filesize($path)) . '&nbsp;</td>' . $functions . '<td' . $bgcol . '>' . trim($thumb) . '</td></tr>';
00099         }
00100         if ($out)   {
00101             if ($func)  {
00102                 $out = '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . $out . '</table>';
00103                 $out = '<table border="0" cellpadding="0" cellspacing="0">
00104                     <tr><td class="bgColor2">' . $out . '<img src="clear.gif" width="465px" height="1px"></td></tr>
00105                 </table>';
00106             } else {
00107                 $out = '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>';
00108             }
00109         }
00110         return $out;
00111     }
00112 
00113     /**
00114      * Renders HTML table with all available template resources/files in the current rootline that could be copied
00115      *
00116      * @param   integer     $id: The uid of the current page
00117      * @param   integer     $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
00118      * @return  string      HTML table with all available template resources/files in the current rootline that could be copied
00119      */
00120     function resourceListForCopy($id, $template_uid)    {
00121         global $tmpl;
00122         $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
00123         $rootLine = $sys_page->getRootLine($id);
00124         $tmpl->runThroughTemplates($rootLine, $template_uid);   // This generates the constants/config + hierarchy info for the template.
00125         $theResources = t3lib_div::trimExplode(',', $tmpl->resources, 1);
00126         foreach ($theResources as $k => $v) {
00127             $fI = pathinfo($v);
00128             if (t3lib_div::inList($this->pObj->textExtensions,strtolower($fI['extension'])))    {
00129                 $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
00130                 $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
00131                 $out .= '<tr><td' . $bgcol . ' nowrap="nowrap">' . $v . '&nbsp;&nbsp;</td><td' . $bgcol . ' nowrap="nowrap">&nbsp;' . t3lib_div::formatSize(@filesize($path)) . '&nbsp;</td><td' . $bgcol . '>' . trim($thumb) . '</td><td><input type="Checkbox" name="data[makecopy_resource][' . $k . ']" value="' . htmlspecialchars($v) . '"></td></tr>';
00132             }
00133         }
00134         $out = ($out ? '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>' : '');
00135         return $out;
00136     }
00137 
00138     /**
00139      * Create an instance of t3lib_tsparser_ext in $GLOBALS['tmpl'] and looks for the first (visible) template
00140      * record. If $template_uid was given and greater than zero, this record will be checked.
00141      *
00142      * @param   integer     $id: The uid of the current page
00143      * @param   integer     $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
00144      * @return  boolean     Returns true if a template record was found, otherwise false
00145      */
00146     function initialize_editor($pageId, $template_uid=0)    {
00147             // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00148         global $tmpl,$tplRow,$theConstants;
00149 
00150         $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');  // Defined global here!
00151         $tmpl->tt_track = 0;    // Do not log time-performance information
00152         $tmpl->init();
00153 
00154             // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
00155         $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid);
00156         if (is_array($tplRow)) {
00157             $tplRow = $this->processTemplateRowAfterLoading($tplRow);
00158             return TRUE;
00159         }
00160         return FALSE;
00161     }
00162     
00163     /**
00164      * Process template row after loading
00165      * 
00166      * @param   array   $tplRow: template row
00167      * @return  array   preprocessed template row
00168      * @author  Fabrizio Branca <typo3@fabrizio-branca.de>
00169      */
00170     function processTemplateRowAfterLoading(array $tplRow) {
00171         if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
00172                 // Let the recursion detection counter start at 91, so that only 10 recursive calls will be resolved
00173                 // Otherwise the editor will be bloated with way to many lines making it hard the break the cyclic recursion.
00174             $tplRow['config'] = t3lib_TSparser::checkIncludeLines($tplRow['config'], 91);
00175             $tplRow['constants'] = t3lib_TSparser::checkIncludeLines($tplRow['constants'], 91);
00176         }
00177         return $tplRow;
00178     }
00179     
00180     /**
00181      * Process template row before saving
00182      * 
00183      * @param   array   $tplRow: template row
00184      * @return  array   preprocessed template row
00185      * @author  Fabrizio Branca <typo3@fabrizio-branca.de>
00186      */
00187     function processTemplateRowBeforeSaving(array $tplRow) {
00188         if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
00189             $tplRow = t3lib_TSparser::extractIncludes_array($tplRow);
00190         }
00191         return $tplRow;
00192     }
00193 
00194     /**
00195      * The main processing method if this class
00196      *
00197      * @return  string      Information of the template status or the taken actions as HTML string
00198      */
00199     function main() {
00200         global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00201         global $tmpl,$tplRow,$theConstants;
00202         
00203         $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = true;
00204 
00205         $edit = $this->pObj->edit;
00206         $e = $this->pObj->e;
00207 
00208         t3lib_div::loadTCA('sys_template');
00209 
00210 
00211 
00212 
00213         // **************************
00214         // Checking for more than one template an if, set a menu...
00215         // **************************
00216         $manyTemplatesMenu = $this->pObj->templateMenu();
00217         $template_uid = 0;
00218         if ($manyTemplatesMenu) {
00219             $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
00220         }
00221 
00222 
00223         // **************************
00224         // Initialize
00225         // **************************
00226         $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);      // initialize
00227 
00228         if ($existTemplate) {
00229             $saveId = ($tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']);
00230         }
00231         // **************************
00232         // Create extension template
00233         // **************************
00234         $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
00235         if($newId) {
00236             // switch to new template
00237             t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id. '&SET[templatesOnPage]=' . $newId);
00238         }
00239 
00240         if ($existTemplate) {
00241                 // Update template ?
00242             $POST = t3lib_div::_POST();
00243             if ($POST['submit'] || (t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']))
00244                 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
00245                     // Set the data to be saved
00246                 $recData = array();
00247                 $alternativeFileName = array();
00248                 $resList = $tplRow['resources'];
00249 
00250                 $tmp_upload_name = '';
00251                 $tmp_newresource_name = ''; // Set this to blank
00252 
00253                 if (is_array($POST['data']))    {
00254                     foreach ($POST['data'] as $field => $val) {
00255                         switch ($field) {
00256                             case 'constants':
00257                             case 'config':
00258                             case 'title':
00259                             case 'sitetitle':
00260                             case 'description':
00261                                 $recData['sys_template'][$saveId][$field] = $val;
00262                                 break;
00263                             case 'resources':
00264                                 $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.
00265                                 if ($tmp_upload_name)   {
00266                                     if ($tmp_upload_name!='none' && $_FILES['resources']['name'])   {
00267                                         $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
00268                                         $resList = $tmp_upload_name.','.$resList;
00269                                     }
00270                                 }
00271                                 break;
00272                             case 'new_resource':
00273                                 $newName = trim(t3lib_div::_GP('new_resource'));
00274                                 if ($newName)   {
00275                                     $newName.= '.'.t3lib_div::_GP('new_resource_ext');
00276                                     $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
00277                                     $alternativeFileName[$tmp_newresource_name] = $newName;
00278                                     $resList = $tmp_newresource_name.','.$resList;
00279                                 }
00280                                 break;
00281                             case 'makecopy_resource':
00282                                 if (is_array($val)) {
00283                                     $resList = ','.$resList.',';
00284                                     foreach ($val as $k => $file) {
00285                                         $tmp_name = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$file;
00286                                         $resList = $tmp_name.','.$resList;
00287                                     }
00288                                 }
00289                                 break;
00290                             case 'remove_resource':
00291                                 if (is_array($val)) {
00292                                     $resList = ','.$resList.',';
00293                                     foreach ($val as $k => $file) {
00294                                         $resList = str_replace(','.$file.',', ',', $resList);
00295                                     }
00296                                 }
00297                                 break;
00298                             case 'totop_resource':
00299                                 if (is_array($val)) {
00300                                     $resList = ','.$resList.',';
00301                                     foreach ($val as $k => $file) {
00302                                         $resList = str_replace(','.$file.',', ',', $resList);
00303                                         $resList = ','.$file.$resList;
00304                                     }
00305                                 }
00306                                 break;
00307                         }
00308                     }
00309                 }
00310                 $resList=implode(',', t3lib_div::trimExplode(',', $resList, 1));
00311                 if (strcmp($resList, $tplRow['resources'])) {
00312                     $recData['sys_template'][$saveId]['resources'] = $resList;
00313                 }
00314                 if (count($recData))    {
00315                     
00316                     $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
00317                     
00318                         // Create new  tce-object
00319                     $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00320                     $tce->stripslashes_values=0;
00321                     $tce->alternativeFileName = $alternativeFileName;
00322                         // Initialize
00323                     $tce->start($recData, array());
00324                         // Saved the stuff
00325                     $tce->process_datamap();
00326                         // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
00327                     $tce->clear_cacheCmd('all');
00328 
00329                         // tce were processed successfully
00330                     $this->tce_processed = true;
00331 
00332                         // re-read the template ...
00333                     $this->initialize_editor($this->pObj->id, $template_uid);
00334                 }
00335 
00336                     // Unlink any uploaded/new temp files there was:
00337                 t3lib_div::unlink_tempfile($tmp_upload_name);
00338                 t3lib_div::unlink_tempfile($tmp_newresource_name);
00339 
00340                     // If files has been edited:
00341                 if (is_array($edit))        {
00342                     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.
00343                         $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$edit['filename'];
00344                         $fI = t3lib_div::split_fileref($edit['filename']);
00345                         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
00346                                 // @TODO: Check if the hardcorded value already has a config member, otherwise create one
00347                             if (filesize($path) < 30720)    {   // checks that have already been done.. Just to make sure
00348                                 t3lib_div::writeFile($path, $edit['file']);
00349 
00350                                 $theOutput.= $this->pObj->doc->spacer(10);
00351                                 $theOutput.= $this->pObj->doc->section(
00352                                     '<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>',
00353                                     sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']),
00354                                     0, 0, 0, 1
00355                                 );
00356 
00357                                     // Clear cache - the file has probably affected the template setup
00358                                     // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
00359                                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00360                                 $tce->stripslashes_values = 0;
00361                                 $tce->start(array(), array());
00362                                 $tce->clear_cacheCmd('all');
00363                             }
00364                         }
00365                     }
00366                 }
00367             }
00368 
00369                 // hook Post updating template/TCE processing
00370             if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook']))   {
00371                 $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
00372                 if (is_array($postTCEProcessingHook)) {
00373                     $hookParameters = array(
00374                         'POST'  => $POST,
00375                         'tce'   => $tce,
00376                     );
00377                     foreach ($postTCEProcessingHook as $hookFunction)   {
00378                         t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
00379                     }
00380                 }
00381             }
00382 
00383             $theOutput.= $this->pObj->doc->spacer(5);
00384             $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow).'<strong>'.htmlspecialchars($tplRow['title']).'</strong>'.htmlspecialchars(trim($tplRow['sitetitle'])?' - ('.$tplRow['sitetitle'].')':''), 0, 1);
00385             if ($manyTemplatesMenu) {
00386                 $theOutput.= $this->pObj->doc->section('', $manyTemplatesMenu);
00387                 $theOutput.= $this->pObj->doc->divider(5);
00388             }
00389 
00390             #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
00391             #if (!$numberOfRows)
00392             $numberOfRows = 35;
00393 
00394                 // If abort pressed, nothing should be edited:
00395             if ($POST['abort'] || (t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']))
00396                 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
00397                 unset($e);
00398             }
00399 
00400             if ($e['title'])    {
00401                 $outCode = '<input type="Text" name="data[title]" value="'.htmlspecialchars($tplRow['title']).'"'.$this->pObj->doc->formWidth().'>';
00402                 $outCode.= '<input type="Hidden" name="e[title]" value="1">';
00403                 $theOutput.= $this->pObj->doc->spacer(15);
00404                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
00405             }
00406             if ($e['sitetitle'])    {
00407                 $outCode = '<input type="Text" name="data[sitetitle]" value="'.htmlspecialchars($tplRow['sitetitle']).'"'.$this->pObj->doc->formWidth().'>';
00408                 $outCode.= '<input type="Hidden" name="e[sitetitle]" value="1">';
00409                 $theOutput.= $this->pObj->doc->spacer(15);
00410                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
00411             }
00412             if ($e['description'])  {
00413                 $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, '', '').'>'.t3lib_div::formatForTextarea($tplRow['description']).'</textarea>';
00414                 $outCode.= '<input type="Hidden" name="e[description]" value="1">';
00415                 $theOutput.= $this->pObj->doc->spacer(15);
00416                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
00417             }
00418             if ($e['resources'])    {
00419                     // Upload
00420                 $outCode = '<input type="File" name="resources"'.$this->pObj->doc->formWidth().' size="50">';
00421                 $outCode.= '<input type="Hidden" name="data[resources]" value="1">';
00422                 $outCode.= '<input type="Hidden" name="e[resources]" value="1">';
00423                 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
00424                 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size']*1024) . '</strong>';
00425                 $theOutput.= $this->pObj->doc->spacer(15);
00426                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
00427 
00428                     // New
00429                 $opt = explode(',', $this->pObj->textExtensions);
00430                 $optTags = '';
00431                 foreach ($opt as $extVal) {
00432                     $optTags.= '<option value="'.$extVal.'">.'.$extVal.'</option>';
00433                 }
00434                 $outCode = '<input type="text" name="new_resource"'.$this->pObj->doc->formWidth(20).'>
00435                     <select name="new_resource_ext">'.$optTags.'</select>';
00436                 $outCode.= '<input type="Hidden" name="data[new_resource]" value="1">';
00437                 $theOutput.= $this->pObj->doc->spacer(15);
00438                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
00439 
00440                     // Make copy
00441                 $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
00442                 if ($rL)    {
00443                     $theOutput.= $this->pObj->doc->spacer(20);
00444                     $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
00445                 }
00446 
00447                     // Update resource list
00448                 $rL = $this->procesResources($tplRow['resources'], 1);
00449                 if ($rL)    {
00450                     $theOutput.= $this->pObj->doc->spacer(20);
00451                     $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
00452                 }
00453             }
00454             if ($e['constants'])    {
00455                 $outCode = '<textarea name="data[constants]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off').' class="fixed-font">'.t3lib_div::formatForTextarea($tplRow['constants']).'</textarea>';
00456                 $outCode.= '<input type="Hidden" name="e[constants]" value="1">';
00457                 
00458                     // Display "Include TypoScript file content?" checkbox
00459                 $outCode .= t3lib_BEfunc::getFuncCheck(
00460                     $this->pObj->id, 
00461                     'SET[includeTypoScriptFileContent]', 
00462                     $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], 
00463                     'index.php', 
00464                     '&e[constants]=1', 
00465                     'id="checkIncludeTypoScriptFileContent"'
00466                 );
00467                 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
00468                 
00469                 
00470                 $theOutput.= $this->pObj->doc->spacer(15);
00471                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
00472                 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
00473             }
00474             if ($e['file']) {
00475                 $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$e[file];
00476 
00477                 $fI = t3lib_div::split_fileref($e[file]);
00478                 if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext']))  {
00479                     if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size']*1024)  {
00480                         $fileContent = t3lib_div::getUrl($path);
00481                         $outCode = $GLOBALS['LANG']->getLL('file'). ' <strong>' . $e[file] . '</strong><BR>';
00482                         $outCode.= '<textarea name="edit[file]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off').' class="fixed-font">'.t3lib_div::formatForTextarea($fileContent).'</textarea>';
00483                         $outCode.= '<input type="Hidden" name="edit[filename]" value="'.$e[file].'">';
00484                         $outCode.= '<input type="Hidden" name="e[file]" value="'.htmlspecialchars($e[file]).'">';
00485                         $theOutput.= $this->pObj->doc->spacer(15);
00486                         $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
00487                         $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
00488                     } else {
00489                         $theOutput.= $this->pObj->doc->spacer(15);
00490                         $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
00491                         $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
00492                         $theOutput.= $this->pObj->doc->section(
00493                             '<font color=red>' . $fileToBig . '</font>',
00494                             $filesizeNotAllowed,
00495                             0, 0, 0, 1
00496                         );
00497                     }
00498                 }
00499             }
00500             if ($e['config'])   {
00501                 $outCode='<textarea name="data[config]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48,"width:98%;height:70%","off").' class="fixed-font">'.t3lib_div::formatForTextarea($tplRow["config"]).'</textarea>';
00502                 $outCode.= '<input type="Hidden" name="e[config]" value="1">';
00503                 
00504                     // Display "Include TypoScript file content?" checkbox
00505                 $outCode .= t3lib_BEfunc::getFuncCheck(
00506                     $this->pObj->id, 
00507                     'SET[includeTypoScriptFileContent]', 
00508                     $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], 
00509                     'index.php', 
00510                     '&e[config]=1', 
00511                     'id="checkIncludeTypoScriptFileContent"'
00512                 );
00513                 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
00514 
00515                 if (t3lib_extMgm::isLoaded('tsconfig_help'))    {
00516                     $url = $BACK_PATH.'wizard_tsconfig.php?mode=tsref';
00517                     $params = array(
00518                         'formName' => 'editForm',
00519                         'itemName' => 'data[config]',
00520                     );
00521                     $outCode.= '<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;">'.t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
00522                 }
00523 
00524                 $theOutput.= $this->pObj->doc->spacer(15);
00525                 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
00526                 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
00527             }
00528             
00529                 // Processing:
00530             $outCode = '';
00531             $outCode.= $this->tableRow(
00532                 $GLOBALS['LANG']->getLL('title'),
00533                 htmlspecialchars($tplRow['title']),
00534                 'title'
00535             );
00536             $outCode.= $this->tableRow(
00537                 $GLOBALS['LANG']->getLL('sitetitle'),
00538                 htmlspecialchars($tplRow['sitetitle']),
00539                 'sitetitle'
00540             );
00541             $outCode.= $this->tableRow(
00542                 $GLOBALS['LANG']->getLL('description'),
00543                 nl2br(htmlspecialchars($tplRow['description'])),
00544                 'description'
00545             );
00546             $outCode.= $this->tableRow(
00547                 $GLOBALS['LANG']->getLL('resources'),
00548                 $this->procesResources($tplRow['resources']),
00549                 'resources'
00550             );
00551             $outCode.= $this->tableRow(
00552                 $GLOBALS['LANG']->getLL('constants'),
00553                 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0)),
00554                 'constants'
00555             );
00556             $outCode.= $this->tableRow(
00557                 $GLOBALS['LANG']->getLL('setup'),
00558                 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0)),
00559                 'config'
00560             );
00561             $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
00562 
00563                 // Edit all icon:
00564             $outCode.= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') .
00565                 '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' .
00566                 t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title'=>
00567                 $GLOBALS['LANG']->getLL('editTemplateRecord') ))  . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
00568             $theOutput.= $this->pObj->doc->section('', $outCode);
00569 
00570 
00571                 // hook after compiling the output
00572             if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook']))    {
00573                 $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
00574                 if (is_array($postOutputProcessingHook)) {
00575                     $hookParameters = array(
00576                         'theOutput' => &$theOutput,
00577                         'POST'      => $POST,
00578                         'e'         => $e,
00579                         'tplRow'        => $tplRow,
00580                         'numberOfRows'      => $numberOfRows
00581                     );
00582                     foreach ($postOutputProcessingHook as $hookFunction)    {
00583                         t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
00584                     }
00585                 }
00586             }
00587 
00588         } else {
00589             $theOutput.= $this->pObj->noTemplate(1);
00590         }
00591 
00592 
00593         return $theOutput;
00594     }
00595 }
00596 
00597 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php'])) {
00598     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']);
00599 }
00600 
00601 ?>