Fixed bug #15580: Add calls to logDeprecatedFunction() for more deprecated functions...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / publish.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Publishing pages to static
29 *
30 * Is included from index_ts.php
31 * $Id$
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @package TYPO3
35 * @subpackage tslib
36 */
37
38
39 /*
40
41 TODO:
42
43 - Show publish-dir in interface
44 - enabled checkboxes to select pages / frames
45 - which-frames selecteble by TS
46 - disable publishing of hidden/starttime/endtime/fe_group pages.
47 - remove published files option
48 - enable writing of images
49 - Policy: HTML-files overridden always, mediafiles are only overwritten if mtime is different.
50
51 */
52
53
54
55 if (!is_object($TSFE)) {die('You cannot execute this file directly. It\'s meant to be included from index_ts.php');}
56
57
58 // Storing the TSFE object
59 $temp_publish_TSFE = $TSFE;
60 $TT->push('Publishing','');
61 $temp_publish_pages = explode(',', $BE_USER->adminPanel->getExtPublishList());
62 $temp_publish_imagesTotal = array();
63 $temp_publish_array = array(); // Collects the rendered pages.
64
65 foreach ($temp_publish_pages as $temp_publish_id) {
66 $TT->push('Page '.$temp_publish_id,'');
67 //debug($temp_publish_id);
68 $TSFE = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, $temp_publish_id, 0);
69
70 $TSFE->initFEuser();
71 $TSFE->clear_preview();
72 $TSFE->determineId();
73 $TSFE->initTemplate();
74 $TSFE->getFromCache();
75
76 $TSFE->getConfigArray();
77 $TSFE->setUrlIdToken();
78 if ($TSFE->isGeneratePage()) {
79 $TSFE->generatePage_preProcessing();
80 $temp_theScript=$TSFE->generatePage_whichScript();
81 if ($temp_theScript) {
82 include($temp_theScript);
83 } else {
84 include(PATH_tslib.'pagegen.php');
85 }
86 $TSFE->generatePage_postProcessing();
87 } elseif ($TSFE->isINTincScript()) {
88 include(PATH_tslib.'pagegen.php');
89 }
90
91 // ********************************
92 // $GLOBALS['TSFE']->config['INTincScript']
93 // *******************************
94 if ($TSFE->isINTincScript()) {
95 $TT->push('Internal PHP-scripts','');
96 $TSFE->INTincScript();
97 $TT->pull();
98 }
99
100 // Get filename
101 $temp_fileName = $TSFE->getSimulFileName();
102
103 if (!isset($temp_publish_array[$temp_fileName])) { // If the page is not rendered allready, which will happen if a hidden page is 'published'
104 // Images file
105 // $temp_publish_row = $TSFE->getSearchCache();
106 // $temp_publish_imagesOnPage= unserialize($temp_publish_row['tempFile_data']);
107 // $temp_publish_imagesTotal = array_merge($temp_publish_imagesTotal, $temp_publish_imagesOnPage);
108 // Store the data for this page:
109 $temp_publish_array[$temp_fileName]= array($temp_publish_id, $temp_publish_imagesOnPage, $TSFE->content);
110 }
111 $TT->pull();
112 }
113 //debug($temp_publish_imagesTotal);
114 //debug(array_unique($temp_publish_imagesTotal));
115
116
117 // ***************************
118 // Publishing, writing files
119 // ***************************
120 $publishDir = $TYPO3_CONF_VARS['FE']['publish_dir'];
121 if ($publishDir && @is_dir($publishDir)) {
122 $publishDir = rtrim($publishDir, '/').'/';
123 debug('Publishing in: '.$publishDir, 'Publish');
124 foreach ($temp_publish_array as $key => $val) {
125 $file = $publishDir.$key;
126 t3lib_div::writeFile($file,$val[2]);
127 debug('Writing: '.$file, 'Publish');
128 }
129 // debug($temp_publish_array);
130 } else {
131 debug('No publish_dir specified...');
132 }
133
134
135 $TT->pull();
136 // Restoring the TSFE object
137 $TSFE = $temp_publish_TSFE;
138
139 ?>