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
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
00083 function init() {
00084
00085 $this->MCONF = $GLOBALS['MCONF'];
00086
00087 $this->isSwap = t3lib_div::_GP('swap');
00088 $this->nextRecordNumber = t3lib_div::_GP('continue_publish');
00089
00090
00091 $this->doc = t3lib_div::makeInstance('mediumDoc');
00092 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00093 $this->doc->docType = 'xhtml_trans';
00094 $this->doc->JScode = '<script type="text/javascript">
00095 function closeAndReload() {
00096
00097 window.location.href = \'index.php\';
00098 }
00099
00100 function nextPortion(val) {
00101 setTimeout(\'window.location.href = "publish.php?continue_publish=\' + val + \'&swap=' . ($this->isSwap ? 1 : 0) . '"\', 750);
00102 }
00103 </script>
00104 ';
00105 $this->doc->inDocStyles = '
00106 #progress-block { width: 450px; margin: 50px auto; text-align: center; }
00107 H3 { margin-bottom: 20px; }
00108 P, IMG { margin-bottom: 20px; }
00109 #progress-block A { text-decoration: underline; }
00110 ';
00111
00112
00113 t3lib_SCbase::init();
00114 }
00115
00121 function main() {
00122 $this->title = $GLOBALS['LANG']->getLL($this->isSwap ? 'swap_title' : 'publish_title');
00123
00124 $content = $this->getContent();
00125
00126 $this->content .= $this->doc->startPage($this->title);
00127 $this->content .= $content;
00128 $this->content .= $this->doc->endPage();
00129 }
00130
00136 function printContent() {
00137 echo $this->content;
00138 }
00139
00145 function getContent() {
00146 $content = '';
00147 if ($this->nextRecordNumber) {
00148
00149 $this->publishData = $GLOBALS['BE_USER']->getSessionData('workspacePublisher');
00150 $this->recordCount = $GLOBALS['BE_USER']->getSessionData('workspacePublisher_count');
00151 $limitedCmd = array(); $numRecs = 0;
00152 foreach ($this->publishData as $table => $recs) {
00153 foreach ($recs as $key => $value) {
00154 $numRecs++;
00155 $limitedCmd[$table][$key] = $value;
00156
00157 if ($numRecs == MAX_RECORDS_TO_PUBLISH) {
00158 break;
00159 }
00160 }
00161 if ($numRecs == MAX_RECORDS_TO_PUBLISH) {
00162 break;
00163 }
00164 }
00165
00166 if ($numRecs == 0) {
00167
00168 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', null);
00169 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher_count', 0);
00170 $content .= '<div id="progress-block"><h3>' . $this->title . '</h3><p>';
00171 $content .= $GLOBALS['LANG']->getLL($this->isSwap ? 'workspace_swapped' : 'workspace_published');
00172 $content .= '</p><p><a href="index.php">' . $GLOBALS['LANG']->getLL('return_to_index') . '</a>';
00173 $content .= '</p></div>';
00174 }
00175 else {
00176
00177 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00178 $tce->stripslashes_values = 0;
00179 $tce->start(array(), $limitedCmd);
00180 $tce->process_cmdmap();
00181
00182 $errors = $tce->errorLog;
00183 if (count($errors) > 0) {
00184 $content .= '<h3>' . $LANG->getLL('label_errors') . '</h3><br/>' . implode('<br/>',$errors);
00185 $content .= '<br /><br /><a href="index.php">' . $GLOBALS['LANG']->getLL('return_to_index') . '</a>';
00186 }
00187 else {
00188
00189
00190 foreach ($limitedCmd as $table => $recs) {
00191 foreach ($recs as $key => $value) {
00192 unset($this->publishData[$table][$key]);
00193 }
00194 }
00195 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', $this->publishData);
00196 $content .= $this->formatProgressBlock($this->isSwap ? 'swap_status' : 'publish_status');
00197 $this->doc->bodyTagAdditions = 'onload="nextPortion(' . ($this->nextRecordNumber + MAX_RECORDS_TO_PUBLISH) . ')"';
00198 }
00199 }
00200 }
00201 else {
00202 $this->getRecords();
00203 if ($this->recordCount > 0) {
00204 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher', $this->publishData);
00205 $GLOBALS['BE_USER']->setAndSaveSessionData('workspacePublisher_count', $this->recordCount);
00206 $content .= $this->formatProgressBlock($this->isSwap ? 'swap_prepare' : 'publish_prepare');
00207 $this->doc->bodyTagAdditions = 'onload="nextPortion(1)"';
00208 }
00209 else {
00210 $this->doc->bodyTagAdditions = 'onload="closeAndReload()"';
00211 }
00212 }
00213 return $content;
00214 }
00215
00221 function getRecords() {
00222 $wslibObj = t3lib_div::makeInstance('wslib');
00223 $this->publishData = $wslibObj->getCmdArrayForPublishWS($GLOBALS['BE_USER']->workspace, $this->isSwap);
00224
00225 $this->recordCount = 0;
00226 foreach ($this->publishData as $table => $recs) {
00227 $this->recordCount += count($recs);
00228 }
00229 }
00230
00237 function formatProgressBlock($messageLabel) {
00238 return '<div id="progress-block"><h3>' . $this->title . '</h3><p>' .
00239 sprintf($GLOBALS['LANG']->getLL($messageLabel),
00240 $this->nextRecordNumber,
00241 min($this->recordCount, $this->nextRecordNumber - 1 + MAX_RECORDS_TO_PUBLISH),
00242 $this->recordCount) . '<br />' .
00243 $GLOBALS['LANG']->getLL('please_wait') .
00244 '</p><img src="progress.gif" width="225" height="20" alt="" />' .
00245 '<p>' .
00246 $GLOBALS['LANG']->getLL('do_not_interrupt_publishing_1') .
00247 '<br />' .
00248 $GLOBALS['LANG']->getLL('do_not_interrupt_publishing_2') .
00249 '</p></div>';
00250 }
00251 }
00252
00253
00254
00255 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/publish.php']) {
00256 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/publish.php']);
00257 }
00258
00259
00260 $SOBE = t3lib_div::makeInstance('SC_mod_user_ws_publish');
00261 $SOBE->init();
00262 $SOBE->main();
00263 $SOBE->printContent();
00264 ?>