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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 unset($MCONF);
00057 require('conf.php');
00058 require($BACK_PATH . 'init.php');
00059 require($BACK_PATH . 'template.php');
00060 $BE_USER->modAccess($MCONF, 1);
00061
00062
00063 $LANG->includeLLFile('EXT:lang/locallang_mod_user_ws.xml');
00064 require_once(PATH_t3lib . 'class.t3lib_scbase.php');
00065 require_once(PATH_typo3 . 'mod/user/ws/class.wslib.php');
00066 require_once(PATH_t3lib . 'class.t3lib_tcemain.php');
00067
00068 define('MAX_RECORDS_TO_PUBLISH', 30);
00069
00070 class SC_mod_user_ws_publish extends t3lib_SCbase {
00071
00072 var $isSwap;
00073 var $title;
00074 var $nextRecordNumber;
00075 var $publishData;
00076 var $recordCount;
00077
00078
00079
00080
00081
00082
00083 var $doc;
00084
00085
00086
00087
00088
00089
00090 function init() {
00091
00092 $this->MCONF = $GLOBALS['MCONF'];
00093
00094 $this->isSwap = t3lib_div::_GP('swap');
00095 $this->nextRecordNumber = t3lib_div::_GP('continue_publish');
00096
00097
00098 $this->doc = t3lib_div::makeInstance('mediumDoc');
00099 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00100 $this->doc->JScode = '<script type="text/javascript">
00101 function closeAndReload() {
00102
00103 window.location.href = \'index.php\';
00104 }
00105
00106 function nextPortion(val) {
00107 setTimeout(\'window.location.href = "publish.php?continue_publish=\' + val + \'&swap=' . ($this->isSwap ? 1 : 0) . '"\', 750);
00108 }
00109 </script>
00110 ';
00111 $this->doc->inDocStyles = '
00112 #progress-block { width: 450px; margin: 50px auto; text-align: center; }
00113 H3 { margin-bottom: 20px; }
00114 P, IMG { margin-bottom: 20px; }
00115 #progress-block A { text-decoration: underline; }
00116 ';
00117
00118
00119 t3lib_SCbase::init();
00120 }
00121
00122
00123
00124
00125
00126
00127 function main() {
00128 $this->title = $GLOBALS['LANG']->getLL($this->isSwap ? 'swap_title' : 'publish_title');
00129
00130 $content = $this->getContent();
00131
00132 $this->content .= $this->doc->startPage($this->title);
00133 $this->content .= $content;
00134 $this->content .= $this->doc->endPage();
00135 }
00136
00137
00138
00139
00140
00141
00142 function printContent() {
00143 echo $this->content;
00144 }
00145
00146
00147
00148
00149
00150
00151 function getContent() {
00152 $content = '';
00153 if ($this->nextRecordNumber) {
00154
00155 $this->publishData = $GLOBALS['BE_USER']->getSessionData('workspacePublisher');
00156 $this->recordCount = $GLOBALS['BE_USER']->getSessionData('workspacePublisher_count');
00157 $limitedCmd = array(); $numRecs = 0;
00158 foreach ($this->publishData as $table => $recs) {
00159 foreach ($recs as $key => $value) {
00160 $numRecs++;
00161 $limitedCmd[$table][$key] = $value;
00162
00163 if ($numRecs == MAX_RECORDS_TO_PUBLISH) {
00164 break;
00165 }
00166 }
00167 if ($numRecs == MAX_RECORDS_TO_PUBLISH) {
00168 break;
00169 }
00170 }
00171
00172 if ($numRecs == 0) {
00173
00174 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', null);
00175 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher_count', 0);
00176 $content .= '<div id="progress-block"><h3>' . $this->title . '</h3><p>';
00177 $content .= $GLOBALS['LANG']->getLL($this->isSwap ? 'workspace_swapped' : 'workspace_published');
00178 $content .= '</p><p><a href="index.php">' . $GLOBALS['LANG']->getLL('return_to_index') . '</a>';
00179 $content .= '</p></div>';
00180 }
00181 else {
00182
00183 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00184 $tce->stripslashes_values = 0;
00185 $tce->start(array(), $limitedCmd);
00186 $tce->process_cmdmap();
00187
00188 $errors = $tce->errorLog;
00189 if (count($errors) > 0) {
00190 $content .= '<h3>' . $GLOBALS['LANG']->getLL('label_errors') . '</h3><br/>' . implode('<br/>',$errors);
00191 $content .= '<br /><br /><a href="index.php">' . $GLOBALS['LANG']->getLL('return_to_index') . '</a>';
00192 }
00193 else {
00194
00195
00196 foreach ($limitedCmd as $table => $recs) {
00197 foreach ($recs as $key => $value) {
00198 unset($this->publishData[$table][$key]);
00199 }
00200 }
00201 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', $this->publishData);
00202 $content .= $this->formatProgressBlock($this->isSwap ? 'swap_status' : 'publish_status');
00203 $this->doc->bodyTagAdditions = 'onload="nextPortion(' . ($this->nextRecordNumber + MAX_RECORDS_TO_PUBLISH) . ')"';
00204 }
00205 }
00206 }
00207 else {
00208 $this->getRecords();
00209 if ($this->recordCount > 0) {
00210 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', $this->publishData);
00211 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher_count', $this->recordCount);
00212 $content .= $this->formatProgressBlock($this->isSwap ? 'swap_prepare' : 'publish_prepare');
00213 $this->doc->bodyTagAdditions = 'onload="nextPortion(1)"';
00214 }
00215 else {
00216 $this->doc->bodyTagAdditions = 'onload="closeAndReload()"';
00217 }
00218 }
00219 return $content;
00220 }
00221
00222
00223
00224
00225
00226
00227 function getRecords() {
00228 $wslibObj = t3lib_div::makeInstance('wslib');
00229 $this->publishData = $wslibObj->getCmdArrayForPublishWS($GLOBALS['BE_USER']->workspace, $this->isSwap);
00230
00231 $this->recordCount = 0;
00232 foreach ($this->publishData as $table => $recs) {
00233 $this->recordCount += count($recs);
00234 }
00235 }
00236
00237
00238
00239
00240
00241
00242
00243 function formatProgressBlock($messageLabel) {
00244 return '<div id="progress-block"><h3>' . $this->title . '</h3><p>' .
00245 sprintf($GLOBALS['LANG']->getLL($messageLabel),
00246 $this->nextRecordNumber,
00247 min($this->recordCount, $this->nextRecordNumber - 1 + MAX_RECORDS_TO_PUBLISH),
00248 $this->recordCount) . '<br />' .
00249 $GLOBALS['LANG']->getLL('please_wait') .
00250 '</p><img src="progress.gif" width="225" height="20" alt="" />' .
00251 '<p>' .
00252 $GLOBALS['LANG']->getLL('do_not_interrupt_publishing_1') .
00253 '<br />' .
00254 $GLOBALS['LANG']->getLL('do_not_interrupt_publishing_2') .
00255 '</p></div>';
00256 }
00257 }
00258
00259
00260 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/publish.php']) {
00261 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/publish.php']);
00262 }
00263
00264
00265 $SOBE = t3lib_div::makeInstance('SC_mod_user_ws_publish');
00266 $SOBE->init();
00267 $SOBE->main();
00268 $SOBE->printContent();
00269
00270 ?>