Documentation TYPO3 par Ameos

index.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 ***************************************************************/
00039 unset($MCONF);
00040 require ("conf.php");
00041 require ($BACK_PATH."init.php");
00042 require ($BACK_PATH."template.php");
00043 require_once (PATH_t3lib."class.t3lib_page.php");
00044 require_once (PATH_t3lib."class.t3lib_tstemplate.php");
00045 require_once (PATH_t3lib."class.t3lib_tsparser_ext.php");
00046 
00047 require_once (PATH_t3lib."class.t3lib_scbase.php");
00048 
00049 $BE_USER->modAccess($MCONF,1);
00050 
00051 
00052 // ***************************
00053 // Script Classes
00054 // ***************************
00055 class SC_mod_web_ts_index extends t3lib_SCbase {
00056         var $perms_clause;
00057         var $e;
00058         var $sObj;
00059         var $edit;
00060         var $textExtensions = "html,htm,txt,css,tmpl,inc";
00061 
00062         var $modMenu_type = "";
00063         var $modMenu_dontValidateList = "ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const";
00064         var $modMenu_setDefaultList = "ts_browser_linkObjects,ts_browser_fixedLgd";
00065 
00066         function init() {
00067                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00068 
00069                 parent::init();
00070 
00071                 $this->id = intval(t3lib_div::_GP("id"));
00072                 $this->e = t3lib_div::_GP("e");
00073                 $this->sObj = t3lib_div::_GP("sObj");
00074                 $this->edit = t3lib_div::_GP("edit");
00075 
00076                 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00077 
00078                 if (t3lib_div::_GP("clear_all_cache"))  {
00079                         $this->include_once[]=PATH_t3lib."class.t3lib_tcemain.php";
00080                 }
00081         }
00082         function clearCache()   {
00083                 if (t3lib_div::_GP("clear_all_cache"))  {
00084                         $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00085                         $tce->stripslashes_values=0;
00086                         $tce->start(Array(),Array());
00087                         $tce->clear_cacheCmd("all");
00088                 }
00089         }
00090         function main() {
00091                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00092 
00093                 // Access check...
00094                 // The page will show only if there is a valid page and if this page may be viewed by the user
00095                 $pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00096                 $access = is_array($pageinfo) ? 1 : 0;
00097 
00098                 if ($this->id && $access)       {
00099                         $this->doc = t3lib_div::makeInstance("template");
00100                         $this->doc->backPath = $BACK_PATH;
00101 
00102 
00103                                 // JavaScript
00104                         $this->doc->JScode = '
00105                 <script language="javascript" type="text/javascript">
00106                         script_ended = 0;
00107                         function jumpToUrl(URL) {
00108                                 document.location = URL;
00109                         }
00110                         function uFormUrl(aname)        {
00111                                 document.forms[0].action = "index.php?id='.$this->id.'#"+aname;
00112                         }
00113                         function brPoint(lnumber,t)     {
00114                                 document.location = "index.php?id='.$this->id.'&SET[function]=tx_tstemplateobjbrowser&SET[ts_browser_type]="+(t?"setup":"const")+"&breakPointLN="+lnumber;
00115                                 return false;
00116                         }
00117                 </script>
00118                 ';
00119 
00120                         $this->doc->postCode='
00121                 <script language="javascript" type="text/javascript">
00122                         script_ended = 1;
00123                         if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
00124                 </script>
00125                 ';
00126 
00127                         $this->doc->inDocStylesArray[] = '
00128                                 TABLE#typo3-objectBrowser A { text-decoration: none; }
00129                         ';
00130 
00131 
00132                                 // Setting up the context sensitive menu:
00133                         $CMparts=$this->doc->getContextMenuCode();
00134                         $this->doc->bodyTagAdditions = $CMparts[1];
00135                         $this->doc->JScode.=$CMparts[0];
00136                         $this->doc->postCode.= $CMparts[2];
00137 
00138 
00139                         $headerSection = $this->doc->getHeader("pages",$pageinfo,$pageinfo["_thePath"]).'<br>'.
00140                                 $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.path").': '.
00141                                 '<span title="'.htmlspecialchars($pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($pageinfo['_thePath'],-50)).'</span>';
00142 
00143                                 // Draw the header.
00144                         $this->doc->form='<form action="index.php?id='.$this->id.'" method="post" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" name="editForm">';
00145                         $this->content.=$this->doc->startPage("Template Tools");
00146                         $this->content.=$this->doc->header("Template Tools");
00147                         $this->content.=$this->doc->spacer(5);
00148                         $this->content.=$this->doc->section('',$this->doc->funcMenu($headerSection,t3lib_BEfunc::getFuncMenu($this->id,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"])));
00149 
00150 
00151                         $this->extObjContent();
00152 
00153 
00154 
00155                         // ShortCut
00156                         if ($BE_USER->mayMakeShortcut())        {
00157                                 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("id,e,sObj,template","function,ts_browser_type,constant_editor_cat",$this->MCONF["name"]));
00158                         }
00159                         $this->content.=$this->doc->spacer(10);
00160                 } else {
00161                                 // If no access or if ID == zero
00162 
00163                         $this->doc = t3lib_div::makeInstance("mediumDoc");
00164                         $this->doc->backPath = $BACK_PATH;
00165 
00166                         $this->content.=$this->doc->startPage("Template Tools");
00167                         $this->content.=$this->doc->header("Template Tools");
00168                         $this->content.=$this->doc->spacer(5);
00169 
00170 
00171                                 // Template pages:
00172                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00173                                                 'pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val',
00174                                                 'pages,sys_template',
00175                                                 'pages.uid=sys_template.pid'.
00176                                                         t3lib_BEfunc::deleteClause('pages').
00177                                                         t3lib_BEfunc::deleteClause('sys_template'),
00178                                                 'pages.uid'
00179                                         );
00180                         $templateArray = array();
00181                         $pArray = array();
00182                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00183                                 $this->setInPageArray(
00184                                         $pArray,
00185                                         t3lib_BEfunc::BEgetRootLine ($row["uid"],"AND 1=1"),
00186                                         $row
00187                                 );
00188                         }
00189 
00190                         $lines = array();
00191                         $lines[] = '<tr class="bgColor5">
00192                                 <td nowrap><strong>Page name</strong></td>
00193                                 <td nowrap><strong># Templates</strong></td>
00194                                 <td nowrap><strong>Is Root?</strong></td>
00195                                 <td nowrap><strong>Is Ext?</strong></td>
00196                                 </tr>';
00197                         $lines = array_merge($lines,$this->renderList($pArray));
00198 
00199                         $table = '<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
00200                         $this->content.= $this->doc->section("",'
00201                         <BR>
00202                         This is an overview of the pages in the database containing one or more template records. Click a page title to go to the page.
00203                         <BR><BR>
00204                         '.$table);
00205                 //      debug($pArray);
00206                         // ********************************************
00207                         // RENDER LIST of pages with templates, END
00208                         // ********************************************
00209 
00210 
00211 
00212                         // ShortCut
00213                         if ($BE_USER->mayMakeShortcut())        {
00214                                 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("id","",$this->MCONF["name"]));
00215                         }
00216 
00217                         $this->content.=$this->doc->spacer(10);
00218                 }
00219         }
00220         function printContent() {
00221 
00222                 $this->content.=$this->doc->endPage();
00223                 echo $this->content;
00224         }
00225 
00226         // ***************************
00227         // OTHER FUNCTIONS:
00228         // ***************************
00229         function getCountCacheTables($humanReadable)    {
00230                 $out=array();
00231 
00232                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', '');
00233                 list($out["cache_pages"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00234 
00235                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pagesection', '');
00236                 list($out["cache_pagesection"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00237 
00238                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_hash', '');
00239                 list($out["cache_hash"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00240 
00241                 if ($humanReadable)     {
00242                         $newOut=array();
00243                         reset($out);
00244                         while(list($k,$v)=each($out))   {
00245                                 $newOut[]=$k.":".$v;
00246                         }
00247                         $out=implode($newOut,", ");
00248                 }
00249                 return $out;
00250         }
00251 
00252         function linkWrapTemplateTitle($title,$onlyKey="")      {
00253                 if ($onlyKey)   {
00254                         $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e['.$onlyKey.']=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00255                 } else {
00256                         $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e[constants]=1&e[config]=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00257                 }
00258                 return $title;
00259         }
00260         function noTemplate($newStandardTemplate=0)     {
00261                 global $SOBE;
00262 
00263                 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");  // Defined global here!
00264                 $tmpl->tt_track = 0;    // Do not log time-performance information
00265                 $tmpl->init();
00266 
00267                 $confirm = ' onClick="return confirm(\'Are you sure you want to do this?\');"';
00268 
00269                         // No template
00270                 $theOutput.=$this->doc->spacer(10);
00271                 $theOutput.=$this->doc->section('<span class="typo3-red">No template</span>',"There was no template on this page!<BR>Create a template record first in order to edit constants!",0,0,0,1);
00272                         // New standard?
00273                 if ($newStandardTemplate)       {
00274                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title,uid', 'static_template', '', '', 'title');
00275                         $opt = "";
00276                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00277                                 if (substr(trim($row["title"]),0,8)=="template")        {
00278                                         $opt.='<option value="'.$row["uid"].'">'.htmlspecialchars($row["title"]).'</option>';
00279                                 }
00280                         }
00281                         $selector = '<select name="createStandard"><option></option>'.$opt.'</select>';
00282                                 // Extension?
00283                         $theOutput.=$this->doc->spacer(10);
00284                         $theOutput.=$this->doc->section("Create new website",'If you want this page to be the root of a new website, optionally based on one of the standard templates, then press the button below:<BR>
00285                         <BR>
00286                         '.$selector.'<BR>
00287                         <img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/icon_warning.gif" width=18 height=16 hspace=5 align=top><input type="Submit" name="newWebsite" value="Create template for a new site"'.$confirm.'>',0,1);
00288                 }
00289                         // Extension?
00290                 $theOutput.=$this->doc->spacer(10);
00291                 $theOutput.=$this->doc->section("Create extension template",sprintf('An extension template allows you to enter TypoScript values that will affect only this page and subpages.<BR><BR><img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/icon_warning.gif" width=18 height=16 hspace=5 align=top>%s<strong>Click here to create an extension template.</strong>%s','<a href="index.php?id='.$this->id.'&createExtension=1"'.$confirm.'>','</a>'),0,1);
00292 
00293                         // Go to first appearing...
00294                 $first = $tmpl->ext_prevPageWithTemplate($this->id,$this->perms_clause);
00295                 if ($first)     {
00296                         $theOutput.=$this->doc->spacer(10);
00297                         $theOutput.=$this->doc->section("Go to closest page with template",sprintf("Closest template is on page '%s' (uid %s).<BR><BR>%s<strong>Click here to go.</strong>%s",$first["title"],$first["uid"],'<a href="index.php?id='.$first["uid"].'">','</a>'),0,1);
00298                 }
00299                 return $theOutput;
00300         }
00301         function templateMenu() {
00302                 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");  // Defined global here!
00303                 $tmpl->tt_track = 0;    // Do not log time-performance information
00304                 $tmpl->init();
00305                 $all = $tmpl->ext_getAllTemplates($this->id,$this->perms_clause);
00306                 $menu="";
00307                 if (count($all)>1)      {
00308                         reset($all);
00309                         $this->MOD_MENU["templatesOnPage"]=array();
00310                         while(list(,$d)=each($all))     {
00311                                 $this->MOD_MENU["templatesOnPage"][$d["uid"]] = $d["title"];
00312                         }
00313                         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"]);
00314                         $menu = t3lib_BEfunc::getFuncMenu($this->id,"SET[templatesOnPage]",$this->MOD_SETTINGS["templatesOnPage"],$this->MOD_MENU["templatesOnPage"]);
00315                 }
00316                 return $menu;
00317         }
00318         function createTemplate($id)    {
00319                 if (t3lib_div::_GP("createExtension"))  {
00320                         require_once (PATH_t3lib."class.t3lib_tcemain.php");
00321                         $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00322                         $tce->stripslashes_values=0;
00323                         $recData=array();
00324                         $recData["sys_template"]["NEW"] = array(
00325                                 "pid" => $id,
00326                                 "title" => "+ext",
00327                                 "sorting" => time()
00328                         );
00329                         $tce->start($recData,Array());
00330                         $tce->process_datamap();
00331                 } elseif (t3lib_div::_GP("newWebsite")) {
00332                         require_once (PATH_t3lib."class.t3lib_tcemain.php");
00333                         $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00334                         $tce->stripslashes_values=0;
00335                         $recData=array();
00336                         if (intval(t3lib_div::_GP("createStandard")))   {
00337                                 $staticT = intval(t3lib_div::_GP("createStandard"));
00338                                 $recData["sys_template"]["NEW"] = array(
00339                                         "pid" => $id,
00340                                         "title" => "NEW SITE, based on standard",
00341                                         "sorting" => 0,
00342                                         "root" => 1,
00343                                         "clear" => 3,
00344                                         "include_static" => $staticT.",57"      // 57 is cSet
00345                                 );
00346                         } else {
00347                                 $recData["sys_template"]["NEW"] = array(
00348                                         "pid" => $id,
00349                                         "title" => "NEW SITE",
00350                                         "sorting" => 0,
00351                                         "root" => 1,
00352                                         "clear" => 3,
00353                                         "config" => '
00354 # Default PAGE object:
00355 page = PAGE
00356 page.10 = TEXT
00357 page.10.value = HELLO WORLD!
00358 '
00359                                 );
00360                         }
00361                         $tce->start($recData,Array());
00362                         $tce->process_datamap();
00363                         $tce->clear_cacheCmd("all");
00364                 }
00365         }
00366         // ********************************************
00367         // RENDER LIST of pages with templates, BEGIN
00368         // ********************************************
00369         function setInPageArray(&$pArray,$rlArr,$row)   {
00370                 ksort($rlArr);
00371                 reset($rlArr);
00372                 if (!$rlArr[0]["uid"])          array_shift($rlArr);
00373 
00374                 $cEl = current($rlArr);
00375                 $pArray[$cEl["uid"]]=$cEl["title"];
00376                 array_shift($rlArr);
00377                 if (count($rlArr))      {
00378                         if (!isset($pArray[$cEl["uid"]."."]))   $pArray[$cEl["uid"]."."]=array();
00379                         $this->setInPageArray($pArray[$cEl["uid"]."."],$rlArr,$row);
00380                 } else {
00381                         $pArray[$cEl["uid"]."_"]=$row;
00382                 }
00383         }
00384         function renderList($pArray,$lines=array(),$c=0)        {
00385                 if (is_array($pArray))  {
00386                         reset($pArray);
00387                         while(list($k,$v)=each($pArray))        {
00388                                 if (t3lib_div::testInt($k))     {
00389                                         if (isset($pArray[$k."_"]))     {
00390                                                 $lines[]='<tr class="bgColor4">
00391                                                         <td nowrap><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00392                                                         '<a href="'.t3lib_div::linkThisScript(array("id"=>$k)).'">'.
00393                                                         t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecord("pages",$k),$GLOBALS["BACK_PATH"],' align="top" title="ID: '.$k.'"').
00394                                                         t3lib_div::fixed_lgd_cs($pArray[$k],30).'</a></td>
00395                                                         <td align=center>'.$pArray[$k."_"]["count"].'</td>
00396                                                         <td align=center>'.($pArray[$k."_"]["root_max_val"]>0?"x":"&nbsp;").'</td>
00397                                                         <td align=center>'.($pArray[$k."_"]["root_min_val"]==0?"x":"&nbsp;").'</td>
00398                                                         </tr>';
00399                                         } else {
00400                                                 $lines[]='<tr>
00401                                                         <td nowrap colspan=3><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00402                                                         t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecord("pages",$k),$GLOBALS["BACK_PATH"]," align=top").
00403                                                         t3lib_div::fixed_lgd_cs($pArray[$k],30).'</td>
00404                                                         </tr>';
00405                                         }
00406                                         $lines=$this->renderList($pArray[$k."."],$lines,$c+1);
00407                                 }
00408                         }
00409                 }
00410                 return $lines;
00411         }
00412 }
00413 
00414 // Include extension?
00415 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"])     {
00416         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"]);
00417 }
00418 
00419 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 // Make instance:
00431 $SOBE = t3lib_div::makeInstance("SC_mod_web_ts_index");
00432 $SOBE->init();
00433 
00434 // Include files?
00435 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
00436 $SOBE->checkExtObj();   // Checking for first level external objects
00437 
00438 $SOBE->clearCache();
00439 $SOBE->main();
00440 $SOBE->printContent();
00441 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6