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 = '';
00064 var $modMenu_setDefaultList = '';
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 TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
00130 ';
00131
00132
00133
00134 $CMparts=$this->doc->getContextMenuCode();
00135 $this->doc->bodyTagAdditions = $CMparts[1];
00136 $this->doc->JScode.=$CMparts[0];
00137 $this->doc->postCode.= $CMparts[2];
00138
00139
00140 $headerSection = $this->doc->getHeader("pages",$pageinfo,$pageinfo["_thePath"]).'<br>'.
00141 $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.path").': '.
00142 '<span title="'.htmlspecialchars($pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($pageinfo['_thePath'],-50)).'</span>';
00143
00144
00145 $this->doc->form='<form action="index.php?id='.$this->id.'" method="post" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" name="editForm">';
00146 $this->content.=$this->doc->startPage("Template Tools");
00147 $this->content.=$this->doc->header("Template Tools");
00148 $this->content.=$this->doc->spacer(5);
00149 $this->content.=$this->doc->section('',$this->doc->funcMenu($headerSection,t3lib_BEfunc::getFuncMenu($this->id,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"])));
00150
00151
00152 $this->extObjContent();
00153
00154
00155
00156
00157 if ($BE_USER->mayMakeShortcut()) {
00158 $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"]));
00159 }
00160 $this->content.=$this->doc->spacer(10);
00161 } else {
00162
00163
00164 $this->doc = t3lib_div::makeInstance("mediumDoc");
00165 $this->doc->backPath = $BACK_PATH;
00166
00167 $this->content.=$this->doc->startPage("Template Tools");
00168 $this->content.=$this->doc->header("Template Tools");
00169 $this->content.=$this->doc->spacer(5);
00170
00171
00172
00173 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00174 'pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val',
00175 'pages,sys_template',
00176 'pages.uid=sys_template.pid'.
00177 t3lib_BEfunc::deleteClause('pages').
00178 t3lib_BEfunc::versioningPlaceholderClause('pages').
00179 t3lib_BEfunc::deleteClause('sys_template').
00180 t3lib_BEfunc::versioningPlaceholderClause('sys_template'),
00181 'pages.uid'
00182 );
00183 $templateArray = array();
00184 $pArray = array();
00185 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00186 $this->setInPageArray(
00187 $pArray,
00188 t3lib_BEfunc::BEgetRootLine ($row["uid"],"AND 1=1"),
00189 $row
00190 );
00191 }
00192
00193 $lines = array();
00194 $lines[] = '<tr class="bgColor5">
00195 <td nowrap><strong>Page name</strong></td>
00196 <td nowrap><strong># Templates</strong></td>
00197 <td nowrap><strong>Is Root?</strong></td>
00198 <td nowrap><strong>Is Ext?</strong></td>
00199 </tr>';
00200 $lines = array_merge($lines,$this->renderList($pArray));
00201
00202 $table = '<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
00203 $this->content.= $this->doc->section("",'
00204 <BR>
00205 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.
00206 <BR><BR>
00207 '.$table);
00208
00209
00210
00211
00212
00213
00214
00215
00216 if ($BE_USER->mayMakeShortcut()) {
00217 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("id","",$this->MCONF["name"]));
00218 }
00219
00220 $this->content.=$this->doc->spacer(10);
00221 }
00222 }
00223 function printContent() {
00224
00225 $this->content.=$this->doc->endPage();
00226 echo $this->content;
00227 }
00228
00229
00230
00231
00232 function getCountCacheTables($humanReadable) {
00233 $out=array();
00234
00235 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', '');
00236 list($out["cache_pages"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00237
00238 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pagesection', '');
00239 list($out["cache_pagesection"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00240
00241 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_hash', '');
00242 list($out["cache_hash"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00243
00244 if ($humanReadable) {
00245 $newOut=array();
00246 reset($out);
00247 while(list($k,$v)=each($out)) {
00248 $newOut[]=$k.":".$v;
00249 }
00250 $out=implode($newOut,", ");
00251 }
00252 return $out;
00253 }
00254
00255 function linkWrapTemplateTitle($title,$onlyKey="") {
00256 if ($onlyKey) {
00257 $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e['.$onlyKey.']=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00258 } else {
00259 $title = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&e[constants]=1&e[config]=1&SET[function]=tx_tstemplateinfo">'.htmlspecialchars($title).'</a>';
00260 }
00261 return $title;
00262 }
00263 function noTemplate($newStandardTemplate=0) {
00264 global $SOBE;
00265
00266 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00267 $tmpl->tt_track = 0;
00268 $tmpl->init();
00269
00270 $confirm = ' onClick="return confirm(\'Are you sure you want to do this?\');"';
00271
00272
00273 $theOutput.=$this->doc->spacer(10);
00274 $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);
00275
00276 if ($newStandardTemplate) {
00277 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title,uid', 'static_template', '', '', 'title');
00278 $opt = "";
00279 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00280 if (substr(trim($row["title"]),0,8)=="template") {
00281 $opt.='<option value="'.$row["uid"].'">'.htmlspecialchars($row["title"]).'</option>';
00282 }
00283 }
00284 $selector = '<select name="createStandard"><option></option>'.$opt.'</select>';
00285
00286 $theOutput.=$this->doc->spacer(10);
00287 $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>
00288 <BR>
00289 '.$selector.'<BR>
00290 <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);
00291 }
00292
00293 $theOutput.=$this->doc->spacer(10);
00294 $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);
00295
00296
00297 $first = $tmpl->ext_prevPageWithTemplate($this->id,$this->perms_clause);
00298 if ($first) {
00299 $theOutput.=$this->doc->spacer(10);
00300 $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);
00301 }
00302 return $theOutput;
00303 }
00304 function templateMenu() {
00305 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
00306 $tmpl->tt_track = 0;
00307 $tmpl->init();
00308 $all = $tmpl->ext_getAllTemplates($this->id,$this->perms_clause);
00309 $menu='';
00310 if (count($all)>1) {
00311 $this->MOD_MENU['templatesOnPage']=array();
00312 foreach($all as $d) {
00313 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
00314 }
00315 }
00316
00317 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
00318 $menu = t3lib_BEfunc::getFuncMenu($this->id,'SET[templatesOnPage]',$this->MOD_SETTINGS['templatesOnPage'],$this->MOD_MENU['templatesOnPage']);
00319
00320 return $menu;
00321 }
00322 function createTemplate($id) {
00323 if (t3lib_div::_GP("createExtension")) {
00324 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00325 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00326 $tce->stripslashes_values=0;
00327 $recData=array();
00328 $recData["sys_template"]["NEW"] = array(
00329 "pid" => $id,
00330 "title" => "+ext",
00331 "sorting" => time()
00332 );
00333 $tce->start($recData,Array());
00334 $tce->process_datamap();
00335 } elseif (t3lib_div::_GP("newWebsite")) {
00336 require_once (PATH_t3lib."class.t3lib_tcemain.php");
00337 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
00338 $tce->stripslashes_values=0;
00339 $recData=array();
00340 if (intval(t3lib_div::_GP("createStandard"))) {
00341 $staticT = intval(t3lib_div::_GP("createStandard"));
00342 $recData["sys_template"]["NEW"] = array(
00343 "pid" => $id,
00344 "title" => "NEW SITE, based on standard",
00345 "sorting" => 0,
00346 "root" => 1,
00347 "clear" => 3,
00348 "include_static" => $staticT.",57"
00349 );
00350 } else {
00351 $recData["sys_template"]["NEW"] = array(
00352 "pid" => $id,
00353 "title" => "NEW SITE",
00354 "sorting" => 0,
00355 "root" => 1,
00356 "clear" => 3,
00357 "config" => '
00358 # Default PAGE object:
00359 page = PAGE
00360 page.10 = TEXT
00361 page.10.value = HELLO WORLD!
00362 '
00363 );
00364 }
00365 $tce->start($recData,Array());
00366 $tce->process_datamap();
00367 $tce->clear_cacheCmd("all");
00368 }
00369 }
00370
00371
00372
00373 function setInPageArray(&$pArray,$rlArr,$row) {
00374 ksort($rlArr);
00375 reset($rlArr);
00376 if (!$rlArr[0]["uid"]) array_shift($rlArr);
00377
00378 $cEl = current($rlArr);
00379 $pArray[$cEl["uid"]]=$cEl["title"];
00380 array_shift($rlArr);
00381 if (count($rlArr)) {
00382 if (!isset($pArray[$cEl["uid"]."."])) $pArray[$cEl["uid"]."."]=array();
00383 $this->setInPageArray($pArray[$cEl["uid"]."."],$rlArr,$row);
00384 } else {
00385 $pArray[$cEl["uid"]."_"]=$row;
00386 }
00387 }
00388 function renderList($pArray,$lines=array(),$c=0) {
00389 if (is_array($pArray)) {
00390 reset($pArray);
00391 while(list($k,$v)=each($pArray)) {
00392 if (t3lib_div::testInt($k)) {
00393 if (isset($pArray[$k."_"])) {
00394 $lines[]='<tr class="bgColor4">
00395 <td nowrap><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00396 '<a href="'.t3lib_div::linkThisScript(array("id"=>$k)).'">'.
00397 t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecordWSOL("pages",$k),$GLOBALS["BACK_PATH"],' align="top" title="ID: '.$k.'"').
00398 t3lib_div::fixed_lgd_cs($pArray[$k],30).'</a></td>
00399 <td align=center>'.$pArray[$k."_"]["count"].'</td>
00400 <td align=center>'.($pArray[$k."_"]["root_max_val"]>0?"x":" ").'</td>
00401 <td align=center>'.($pArray[$k."_"]["root_min_val"]==0?"x":" ").'</td>
00402 </tr>';
00403 } else {
00404 $lines[]='<tr>
00405 <td nowrap colspan=3><img src=clear.gif width=1 height=1 hspace='.($c*10).' align=top>'.
00406 t3lib_iconWorks::getIconImage("pages",t3lib_BEfunc::getRecordWSOL("pages",$k),$GLOBALS["BACK_PATH"]," align=top").
00407 t3lib_div::fixed_lgd_cs($pArray[$k],30).'</td>
00408 </tr>';
00409 }
00410 $lines=$this->renderList($pArray[$k."."],$lines,$c+1);
00411 }
00412 }
00413 }
00414 return $lines;
00415 }
00416 }
00417
00418
00419 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"]) {
00420 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tstemplate/ts/index.php"]);
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 $SOBE = t3lib_div::makeInstance("SC_mod_web_ts_index");
00436 $SOBE->init();
00437
00438
00439 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
00440 $SOBE->checkExtObj();
00441
00442 $SOBE->clearCache();
00443 $SOBE->main();
00444 $SOBE->printContent();
00445 ?>