00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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,js';
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
00094
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
00104 $this->doc->JScode = '
00105 <script language="javascript" type="text/javascript">
00106 script_ended = 0;
00107 function jumpToUrl(URL) {
00108 window.location.href = URL;
00109 }
00110 function uFormUrl(aname) {
00111 document.forms[0].action = "index.php?id='.$this->id.'#"+aname;
00112 }
00113 function brPoint(lnumber,t) {
00114 window.location.href = "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
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
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
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
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
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::versioningPlaceholderClause('pages').
00178 t3lib_BEfunc::deleteClause('sys_template').
00179 t3lib_BEfunc::versioningPlaceholderClause('sys_template'),
00180 'pages.uid'
00181 );
00182 $templateArray = array();
00183 $pArray = array();
00184 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00185 $this->setInPageArray(
00186 $pArray,
00187 t3lib_BEfunc::BEgetRootLine ($row["uid"],"AND 1=1"),
00188 $row
00189 );
00190 }
00191
00192 $lines = array();
00193 $lines[] = '<tr class="bgColor5">
00194 <td nowrap><strong>Page name</strong></td>
00195 <td nowrap><strong># Templates</strong></td>
00196 <td nowrap><strong>Is Root?</strong></td>
00197 <td nowrap><strong>Is Ext?</strong></td>
00198 </tr>';
00199 $lines = array_merge($lines,$this->renderList($pArray));
00200
00201 $table = '<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
00202 $this->content.= $this->doc->section("",'
00203 <BR>
00204 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.
00205 <BR><BR>
00206 '.$table);
00207
00208
00209
00210
00211
00212
00213
00214
00215 if ($BE_USER->mayMakeShortcut()) {
00216 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("id","",$this->MCONF["name"]));
00217 }
00218
00219 $this->content.=$this->doc->spacer(10);
00220 }
00221 }
00222 function printContent() {
00223
00224 $this->content.=$this->doc->endPage();
00225 echo $this->content;
00226 }
00227
00228
00229
00230
00231 function getCountCacheTables($humanReadable) {
00232 $out=array();
00233
00234 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', '');
00235 list($out["cache_pages"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00236
00237 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pagesection', '');
00238 list($out["cache_pagesection"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00239
00240 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_hash', '');
00241 list($out["cache_hash"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00242
00243 if ($humanReadable) {
00244 $newOut=array();
00245 reset($out);
00246 while(list($k,$v)=each($out)) {
00247 $newOut[]=$k.":".$v;
00248 }
00249 $out=implode($newOut,", ");
00250 }
00251 return $out;
00252 }
00253
00254 function linkWrapTemplateTitle($title,$onlyKey="") {
00255 if ($onlyKey) {
00256 $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e['.$onlyKey.']=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00257 } else {
00258 $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e[constants]=1&e[config]=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00259 }
00260 return $title;
00261 }
00262 function noTemplate($newStandardTemplate=0) {
00263 global $SOBE;
00264
00265 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00266 $tmpl->tt_track = 0;
00267 $tmpl->init();
00268
00269 $confirm = ' onClick="return confirm(\'Are you sure you want to do this?\');"';
00270
00271
00272 $theOutput.=$this->doc->spacer(10);
00273 $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);
00274
00275 if ($newStandardTemplate) {
00276 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title,uid', 'static_template', '', '', 'title');
00277 $opt = "";
00278 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00279 if (substr(trim($row["title"]),0,8)=="template") {
00280 $opt.='<option value="'.$row["uid"].'">'.htmlspecialchars($row["title"]).'</option>';
00281 }
00282 }
00283 $selector = '<select name="createStandard"><option></option>'.$opt.'</select>';
00284
00285 $theOutput.=$this->doc->spacer(10);
00286 $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>
00287 <BR>
00288 '.$selector.'<BR>
00289 <img src="'.$GLOBALS["BACK_PATH"].'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);
00290 }
00291
00292 $theOutput.=$this->doc->spacer(10);
00293 $theOutput.=$this->doc->section("Create extension template",'An extension template allows you to enter TypoScript values that will affect only this page and subpages.<BR><BR><img src="'.$GLOBALS["BACK_PATH"].'gfx/icon_warning.gif" width=18 height=16 hspace=5 align=top><input type="submit" name="createExtension" value="Click here to create an extension template."'.$confirm.'>',0,1);
00294
00295
00296 $first = $tmpl->ext_prevPageWithTemplate($this->id,$this->perms_clause);
00297 if ($first) {
00298 $theOutput.=$this->doc->spacer(10);
00299 $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);
00300 }
00301 return $theOutput;
00302 }
00303 function templateMenu() {
00304 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00305 $tmpl->tt_track = 0;
00306 $tmpl->init();
00307 $all = $tmpl->ext_getAllTemplates($this->id,$this->perms_clause);
00308 $menu='';
00309 if (count($all)>1) {
00310 $this->MOD_MENU['templatesOnPage']=array();
00311 foreach($all as $d) {
00312 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
00313 }
00314 }
00315
00316 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00317 $menu = t3lib_BEfunc::getFuncMenu($this->id,'SET[templatesOnPage]',$this->MOD_SETTINGS['templatesOnPage'],$this->MOD_MENU['templatesOnPage']);
00318
00319 return $menu;
00320 }
00321 function createTemplate($id) {
00322 if (t3lib_div::_GP("createExtension")) {
00323 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00324 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00325 $tce->stripslashes_values=0;
00326 $recData=array();
00327 $recData["sys_template"]["NEW"] = array(
00328 "pid" => $id,
00329 "title" => "+ext",
00330 "sorting" => time()
00331 );
00332 $tce->start($recData,Array());
00333 $tce->process_datamap();
00334 } elseif (t3lib_div::_GP("newWebsite")) {
00335 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00336 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00337 $tce->stripslashes_values=0;
00338 $recData=array();
00339 if (intval(t3lib_div::_GP("createStandard"))) {
00340 $staticT = intval(t3lib_div::_GP("createStandard"));
00341 $recData["sys_template"]["NEW"] = array(
00342 "pid" => $id,
00343 "title" => "NEW SITE, based on standard",
00344 "sorting" => 0,
00345 "root" => 1,
00346 "clear" => 3,
00347 "include_static" => $staticT.",57"
00348 );
00349 } else {
00350 $recData["sys_template"]["NEW"] = array(
00351 "pid" => $id,
00352 "title" => "NEW SITE",
00353 "sorting" => 0,
00354 "root" => 1,
00355 "clear" => 3,
00356 "config" => '
00357 # Default PAGE object:
00358 page = PAGE
00359 page.10 = TEXT
00360 page.10.value = HELLO WORLD!
00361 '
00362 );
00363 }
00364 $tce->start($recData,Array());
00365 $tce->process_datamap();
00366 $tce->clear_cacheCmd("all");
00367 }
00368 }
00369
00370
00371
00372 function setInPageArray(&$pArray,$rlArr,$row) {
00373 ksort($rlArr);
00374 reset($rlArr);
00375 if (!$rlArr[0]["uid"]) array_shift($rlArr);
00376
00377 $cEl = current($rlArr);
00378 $pArray[$cEl["uid"]]=$cEl["title"];
00379 array_shift($rlArr);
00380 if (count($rlArr)) {
00381 if (!isset($pArray[$cEl["uid"]."."])) $pArray[$cEl["uid"]."."]=array();
00382 $this->setInPageArray($pArray[$cEl["uid"]."."],$rlArr,$row);
00383 } else {
00384 $pArray[$cEl["uid"]."_"]=$row;
00385 }
00386 }
00387 function renderList($pArray,$lines=array(),$c=0) {
00388 if (is_array($pArray)) {
00389 reset($pArray);
00390 while(list($k,$v)=each($pArray)) {
00391 if (t3lib_div::testInt($k)) {
00392 if (isset($pArray[$k."_"])) {
00393 $lines[]='<tr class="bgColor4">
00394 <td nowrap><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00395 '<a href="'.t3lib_div::linkThisScript(array("id"=>$k)).'">'.
00396 t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecordWSOL("pages",$k),$GLOBALS["BACK_PATH"],' align="top" title="ID: '.$k.'"').
00397 t3lib_div::fixed_lgd_cs($pArray[$k],30).'</a></td>
00398 <td align=center>'.$pArray[$k."_"]["count"].'</td>
00399 <td align=center>'.($pArray[$k."_"]["root_max_val"]>0?"x":" ").'</td>
00400 <td align=center>'.($pArray[$k."_"]["root_min_val"]==0?"x":" ").'</td>
00401 </tr>';
00402 } else {
00403 $lines[]='<tr>
00404 <td nowrap colspan=3><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00405 t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecordWSOL("pages",$k),$GLOBALS["BACK_PATH"]," align=top").
00406 t3lib_div::fixed_lgd_cs($pArray[$k],30).'</td>
00407 </tr>';
00408 }
00409 $lines=$this->renderList($pArray[$k."."],$lines,$c+1);
00410 }
00411 }
00412 }
00413 return $lines;
00414 }
00415 }
00416
00417
00418 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"]) {
00419 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"]);
00420 }
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 $SOBE = t3lib_div::makeInstance("SC_mod_web_ts_index");
00435 $SOBE->init();
00436
00437
00438 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
00439 $SOBE->checkExtObj();
00440
00441 $SOBE->clearCache();
00442 $SOBE->main();
00443 $SOBE->printContent();
00444 ?>