"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/cms/tslib/publish.php Source File", "datetime" => "Sat Dec 2 19:22:30 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

publish.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  /*
00040 
00041  TODO:
00042 
00043 - Show publish-dir in interface
00044 - enabled checkboxes to select pages / frames
00045 - which-frames selecteble by TS
00046 - disable publishing of hidden/starttime/endtime/fe_group pages.
00047 - remove published files option
00048 - enable writing of images
00049 - Policy: HTML-files overridden always, mediafiles are only overwritten if mtime is different.
00050 
00051  */
00052 
00053 
00054 
00055 if (!is_object($TSFE))  {die('You cannot execute this file directly. It\'s meant to be included from index_ts.php');}
00056 
00057 
00058         // Storing the TSFE object
00059 $temp_publish_TSFE = $TSFE;
00060 $TT->push('Publishing','');
00061 $temp_publish_pages = explode(',',$BE_USER->extPublishList);
00062 $temp_publish_imagesTotal = array();
00063 $temp_publish_array = array();  // Collects the rendered pages.
00064 
00065 while(list(,$temp_publish_id)=each($temp_publish_pages))        {
00066         $TT->push('Page '.$temp_publish_id,'');
00067 //debug($temp_publish_id,1);
00068                 $temp_TSFEclassName=t3lib_div::makeInstanceClassName('tslib_fe');
00069                 $TSFE = new $temp_TSFEclassName($TYPO3_CONF_VARS,$temp_publish_id,0);
00070 
00071                 $TSFE->initFEuser();
00072                 $TSFE->clear_preview();
00073                 $TSFE->determineId();
00074                 $TSFE->initTemplate();
00075                 $TSFE->getFromCache();
00076 
00077                 $TSFE->getConfigArray();
00078                 $TSFE->setUrlIdToken();
00079                 if ($TSFE->isGeneratePage())    {
00080                                 $TSFE->generatePage_preProcessing();
00081                                 $temp_theScript=$TSFE->generatePage_whichScript();
00082                                 if ($temp_theScript)    {
00083                                         include($temp_theScript);
00084                                 } else {
00085                                         require_once (PATH_tslib.'class.tslib_pagegen.php');            // Just formal, this is already included from index_ts.php
00086                                         include(PATH_tslib.'pagegen.php');
00087                                 }
00088                                 $TSFE->generatePage_postProcessing();
00089                 } elseif ($TSFE->isINTincScript())      {
00090                         require_once (PATH_tslib.'class.tslib_pagegen.php');    // Just formal, this is already included from index_ts.php
00091                         include(PATH_tslib.'pagegen.php');
00092                 }
00093 
00094                 // ********************************
00095                 // $GLOBALS['TSFE']->config['INTincScript']
00096                 // *******************************
00097                 if ($TSFE->isINTincScript())            {
00098                         $TT->push('Internal PHP-scripts','');
00099                                 $INTiS_config = $GLOBALS['TSFE']->config['INTincScript'];
00100 
00101                                         // Special feature: Include libraries
00102                                 $TT->push('Include libraries');
00103                                 reset($INTiS_config);
00104                                 while(list(,$INTiS_cPart)=each($INTiS_config))  {
00105                                         if ($INTiS_cPart['conf']['includeLibs'])        {
00106                                                 $INTiS_resourceList = t3lib_div::trimExplode(',',$INTiS_cPart['conf']['includeLibs'],1);
00107                                                 reset($INTiS_resourceList);
00108                                                 while(list(,$INTiS_theLib)=each($INTiS_resourceList))   {
00109                                                         $INTiS_incFile=$GLOBALS['TSFE']->tmpl->getFileName($INTiS_theLib);
00110                                                         if ($INTiS_incFile)     {
00111                                                                 include_once('./'.$INTiS_incFile);
00112                                                         }
00113                                                 }
00114                                         }
00115                                 }
00116                                 $TT->pull();
00117                                 $TSFE->INTincScript();
00118                         $TT->pull();
00119                 }
00120 
00121                         // Get filename
00122                 $temp_fileName = $TSFE->getSimulFileName();
00123 
00124                 if (!isset($temp_publish_array[$temp_fileName]))        {       // If the page is not rendered allready, which will happen if a hidden page is 'published'
00125                                 // Images file
00126 //                      $temp_publish_row = $TSFE->getSearchCache();
00127 //                      $temp_publish_imagesOnPage= unserialize($temp_publish_row['tempFile_data']);
00128 //                      $temp_publish_imagesTotal = array_merge($temp_publish_imagesTotal, $temp_publish_imagesOnPage);
00129                                 // Store the data for this page:
00130                         $temp_publish_array[$temp_fileName]= array($temp_publish_id, $temp_publish_imagesOnPage, $TSFE->content);
00131                 }
00132         $TT->pull();
00133 }
00134 //debug($temp_publish_imagesTotal);
00135 //debug(array_unique($temp_publish_imagesTotal));
00136 
00137 
00138 // ***************************
00139 // Publishing, writing files
00140 // ***************************
00141 $publishDir = $TYPO3_CONF_VARS['FE']['publish_dir'];
00142 if ($publishDir && @is_dir($publishDir))        {
00143         $publishDir = ereg_replace('/*$','',$publishDir).'/';
00144         debug('Publishing in: '.$publishDir,1);
00145         reset($temp_publish_array);
00146         while(list($key,$val)=each($temp_publish_array))        {
00147                 $file = $publishDir.$key;
00148                 t3lib_div::writeFile($file,$val[2]);
00149                 debug('Writing: '.$file,1);
00150         }
00151 //      debug($temp_publish_array);
00152 } else {
00153         debug('No publish_dir specified...');
00154 }
00155 
00156 
00157 $TT->pull();
00158         // Restoring the TSFE object
00159 $TSFE = $temp_publish_TSFE;
00160 
00161 ?>