Documentation TYPO3 par Ameos

class.tx_tstemplateanalyzer.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (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 ***************************************************************/
00031 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00032 
00033 class tx_tstemplateanalyzer extends t3lib_extobjbase {
00034         function modMenu()      {
00035                 global $LANG;
00036 
00037                 return Array (
00038                         "ts_analyzer_checkSetup" => "",
00039                         "ts_analyzer_checkConst" => "",
00040                         "ts_analyzer_checkLinenum" => "",
00041                         "ts_analyzer_checkComments" => "",
00042                         "ts_analyzer_checkCrop" => "",
00043                         "ts_analyzer_checkSyntax" => "",
00044                         "ts_analyzer_checkSyntaxBlockmode" => "",
00045                 );
00046         }
00047 
00048         function initialize_editor($pageId,$template_uid=0)     {
00049                         // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00050                 global $tmpl,$tplRow,$theConstants,$rootLine;
00051 
00052                 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");  // Defined global here!
00053                 $tmpl->tt_track = 0;    // Do not log time-performance information
00054                 $tmpl->init();
00055 
00056                         // Gets the rootLine
00057                 $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
00058                 $rootLine = $sys_page->getRootLine($pageId);
00059                 $tmpl->runThroughTemplates($rootLine,$template_uid);    // This generates the constants/config + hierarchy info for the template.
00060 
00061                 $tplRow = $tmpl->ext_getFirstTemplate($pageId,$template_uid);   // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
00062                 if (is_array($tplRow))  {       // IF there was a template...
00063                         return 1;
00064                 }
00065         }
00066         function main() {
00067                         // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00068                 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00069                 global $tmpl,$tplRow,$theConstants,$rootLine;
00070 
00071                 // **************************
00072                 // Checking for more than one template an if, set a menu...
00073                 // **************************
00074                 $manyTemplatesMenu = $this->pObj->templateMenu();
00075                 $template_uid = 0;
00076                 if ($manyTemplatesMenu) {
00077                         $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"];
00078                 }
00079 
00080                 // **************************
00081                 // Main
00082                 // **************************
00083 
00084                 // BUGBUG: Should we check if the uset may at all read and write template-records???
00085                 $existTemplate = $this->initialize_editor($this->pObj->id,$template_uid);               // initialize
00086                 if ($existTemplate)     {
00087                         $theOutput.=$this->pObj->doc->divider(5);
00088                         $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"]).'</b>'.htmlspecialchars(trim($tplRow["sitetitle"])?' - ('.$tplRow["sitetitle"].')':''));
00089                 }
00090                 if ($manyTemplatesMenu) {
00091                         $theOutput.=$this->pObj->doc->section("",$manyTemplatesMenu);
00092                 }
00093 
00094                 //      debug($tmpl->hierarchyInfo);
00095 
00096                 $tmpl->clearList_const_temp = array_flip($tmpl->clearList_const);
00097                 $tmpl->clearList_setup_temp = array_flip($tmpl->clearList_setup);
00098 
00099                 $pointer = count($tmpl->hierarchyInfo);
00100                 $tmpl->hierarchyInfoArr = $tmpl->ext_process_hierarchyInfo(array(), $pointer);
00101                 $tmpl->procesIncludes();
00102 
00103                 $hierarArr = array();
00104                 $head= '<tr>';
00105                 $head.= '<td class="bgColor2"><b>Title&nbsp;&nbsp;</b></td>';
00106                 $head.= '<td class="bgColor2"><b>Rootlevel&nbsp;&nbsp;</b></td>';
00107                 $head.= '<td class="bgColor2"><b>C. Setup&nbsp;&nbsp;</b></td>';
00108                 $head.= '<td class="bgColor2"><b>C. Const&nbsp;&nbsp;</b></td>';
00109                 $head.= '<td class="bgColor2"><b>PID/RL&nbsp;&nbsp;</b></td>';
00110                 $head.= '<td class="bgColor2"><b>NL&nbsp;&nbsp;</b></td>';
00111                 $head.= '</tr>';
00112                 $hierar = implode(array_reverse($tmpl->ext_getTemplateHierarchyArr($tmpl->hierarchyInfoArr, "",array(),1)),"");
00113                 $hierar= '<table border=0 cellpadding=0 cellspacing=0>'.$head.$hierar.'</table>';
00114 
00115                 $theOutput.=$this->pObj->doc->spacer(5);
00116                 $theOutput.=$this->pObj->doc->section("Template hierarchy:",$hierar,0,1);
00117 
00118 
00119                         // Output constants
00120                 $theOutput.=$this->pObj->doc->spacer(25);
00121                 $theOutput.=$this->pObj->doc->divider(0);
00122                 $theOutput.=$this->pObj->doc->section("",
00123                         "Linenumbers".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkLinenum]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkLinenum"]).
00124                         "&nbsp;&nbsp;&nbsp;Syntax HL".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkSyntax]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"]).
00125                         (!$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"] ?
00126                                 "&nbsp;&nbsp;&nbsp;Comments".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkComments]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkComments"]).
00127                                 "&nbsp;&nbsp;&nbsp;Crop lines".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkCrop]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkCrop"])
00128                                 :
00129                                 "&nbsp;&nbsp;&nbsp;Block mode".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkSyntaxBlockmode]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntaxBlockmode"])
00130                         )
00131                 );
00132                 $theOutput.=$this->pObj->doc->divider(2);
00133                 //$theOutput.=$this->pObj->doc->section("Constants:",t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkConst]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkConst"]).fw("Enable"));
00134                 $theOutput.=$this->pObj->doc->section("Constants:","",0,1);
00135                 $theOutput.=$this->pObj->doc->sectionEnd();
00136                 if (1==1 || $this->pObj->MOD_SETTINGS["ts_analyzer_checkConst"])        {
00137                         $theOutput.='
00138                                 <table border=0 cellpadding=1 cellspacing=0>
00139                         ';
00140                         $tmpl->ext_lineNumberOffset=-2; // Don't know why -2 and not 0... :-) But works.
00141                         $tmpl->ext_lineNumberOffset_mode="const";
00142                         $tmpl->ext_lineNumberOffset+=count(explode(chr(10),t3lib_TSparser::checkIncludeLines("".$GLOBALS["TYPO3_CONF_VARS"]["FE"]["defaultTypoScript_constants"])))+1;
00143 
00144                         reset($tmpl->constants);
00145                         reset($tmpl->clearList_const);
00146                         while(list($key,$val)=each($tmpl->constants))   {
00147                                 $cVal = current($tmpl->clearList_const);
00148                                 if ($cVal==t3lib_div::_GET('template') || t3lib_div::_GET('template')=="all")   {
00149                                         $theOutput.='
00150                                                 <tr>
00151                                                         <td><img src=clear.gif width=3 height=1></td><td class="bgColor2"><b>'.$tmpl->templateTitles[$cVal].'</b></td></tr>
00152                                                 <tr>
00153                                                         <td><img src=clear.gif width=3 height=1></td>
00154                                                         <td class="bgColor2"><table border=0 cellpadding=0 cellspacing=0 bgcolor="#D9D5C9" width="100%"><tr><td nowrap>'.$tmpl->ext_outputTS(array($val),$this->pObj->MOD_SETTINGS["ts_analyzer_checkLinenum"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkComments"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkCrop"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntaxBlockmode"]).'</td></tr></table>
00155                                                         </td>
00156                                                 </tr>
00157                                         ';
00158                                         if (t3lib_div::_GET('template')!="all")         break;
00159                                 }
00160                                 $tmpl->ext_lineNumberOffset+=count(explode(chr(10),$val))+1;
00161                                 next($tmpl->clearList_const);
00162                         }
00163                         $theOutput.='
00164                                 </table>
00165                         ';
00166                 }
00167 
00168                         // Output setup
00169                 $theOutput.=$this->pObj->doc->spacer(15);
00170                 //$theOutput.=$this->pObj->doc->section("SETUP:",t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_analyzer_checkSetup]",$this->pObj->MOD_SETTINGS["ts_analyzer_checkSetup"]).fw("Enable"));
00171                 $theOutput.=$this->pObj->doc->section("SETUP:","",0,1);
00172                 $theOutput.=$this->pObj->doc->sectionEnd();
00173                 if (1==1 || $this->pObj->MOD_SETTINGS["ts_analyzer_checkSetup"])        {
00174                         $theOutput.='
00175                                 <table border=0 cellpadding=1 cellspacing=0>
00176                         ';
00177                         $tmpl->ext_lineNumberOffset=0;
00178                         $tmpl->ext_lineNumberOffset_mode="setup";
00179                         $tmpl->ext_lineNumberOffset+=count(explode(chr(10),t3lib_TSparser::checkIncludeLines("".$GLOBALS["TYPO3_CONF_VARS"]["FE"]["defaultTypoScript_setup"])))+1;
00180 
00181                         reset($tmpl->config);
00182                         reset($tmpl->clearList_setup);
00183                         while(list($key,$val)=each($tmpl->config))      {
00184                                 if (current($tmpl->clearList_setup)==t3lib_div::_GET('template') || t3lib_div::_GET('template')=="all") {
00185                                         $theOutput.='
00186                                                 <tr>
00187                                                         <td><img src=clear.gif width=3 height=1></td><td class="bgColor2"><b>'.$tmpl->templateTitles[current($tmpl->clearList_setup)].'</b></td></tr>
00188                                                 <tr>
00189                                                         <td><img src=clear.gif width=3 height=1></td>
00190                                                         <td class="bgColor2"><table border=0 cellpadding=0 cellspacing=0 bgcolor="#D9D5C9" width="100%"><tr><td nowrap>'.$tmpl->ext_outputTS(array($val),$this->pObj->MOD_SETTINGS["ts_analyzer_checkLinenum"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkComments"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkCrop"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"],$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntaxBlockmode"]).'</td></tr></table>
00191                                                         </td>
00192                                                 </tr>
00193                                         ';
00194                                         if (t3lib_div::_GET('template')!="all")         break;
00195                                 }
00196                                 $tmpl->ext_lineNumberOffset+=count(explode(chr(10),$val))+1;
00197                                 next($tmpl->clearList_setup);
00198                         }
00199                         $theOutput.='
00200                                 </table>
00201                         ';
00202                 }
00203                 return $theOutput;
00204         }
00205 }
00206 
00207 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php"]) {
00208         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php"]);
00209 }
00210 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6