00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00045 define('TYPO3_PROCEED_IF_NO_USER', '1');
00046
00047 unset($MCONF);
00048 require('conf.php');
00049 require($BACK_PATH.'init.php');
00050 require_once('class.wslib.php');
00051
00052
00053
00062 class wsol_preview {
00063
00064 var $workspace = 0;
00065
00071 function main() {
00072
00073 if ($this->isBeLogin()) {
00074 $this->workspace = $GLOBALS['BE_USER']->workspace;
00075 }
00076
00077 if ($header = t3lib_div::_GP('header')) {
00078 if ($header!=='live') {
00079 $headerText = 'Workspace Version ('.$this->workspace.'):';
00080 $color = 'green';
00081 } else {
00082 $headerText = 'Live Version:';
00083 $color = 'red';
00084 }
00085
00086 $output = '
00087 <html>
00088 <head>
00089 <title>Header</title>
00090 </head>
00091 <body bgcolor="'.$color.'">
00092 <font face="verdana,arial" size="2" color="white"><b>'.$headerText.'</b></font>
00093 </body>
00094 </html>';
00095 } elseif ($msg = t3lib_div::_GP('msg')) {
00096 switch($msg) {
00097 case 'branchpoint':
00098 $message = '<b>No live page available!</b><br/><br/>
00099 The previewed page was inside a "Branch" type version and has no traceable counterpart in the live workspace.';
00100 break;
00101 case 'newpage':
00102 $message = '<b>New page!</b><br/><br/>
00103 The previewed page is created in the workspace and has no counterpart in the live workspace.';
00104 break;
00105 default:
00106 $message = 'Unknown message code "'.$msg.'"';
00107 break;
00108 }
00109
00110 $output = '
00111 <html>
00112 <head>
00113 <title>Message</title>
00114 </head>
00115 <body bgcolor="#eeeeee">
00116 <div width="100%" height="100%" style="text-align: center; align: center;"><br/><br/><br/><br/><font face="verdana,arial" size="2" color="#666666">'.$message.'</font></div>
00117 </body>
00118 </html>';
00119
00120 } else {
00121 $this->generateUrls();
00122 $output = $this->printFrameset();
00123 }
00124
00125 echo $output;
00126 }
00127
00133 function generateUrls() {
00134
00135 $pageId = intval(t3lib_div::_GP('id'));
00136 $language = intval(t3lib_div::_GP('L'));
00137
00138 $this->URL = array(
00139 'liveHeader' => 'wsol_preview.php?header=live',
00140 'draftHeader' => 'wsol_preview.php?header=draft',
00141 'live' => t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?id='.$pageId.'&L='.$language.'&ADMCMD_noBeUser=1',
00142 'draft' => t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?id='.$pageId.'&L='.$language.'&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS='.$this->workspace,
00143 'versionMod' => '../../../sysext/version/cm1/index.php?id='.intval(t3lib_div::_GP('id')).'&diffOnly=1'
00144 );
00145
00146 if ($this->isBeLogin()) {
00147
00148 if (t3lib_BEfunc::isPidInVersionizedBranch($pageId)=='branchpoint') {
00149 $this->URL['live'] = 'wsol_preview.php?msg=branchpoint';
00150 }
00151
00152 $rec = t3lib_BEfunc::getRecord('pages',$pageId,'t3ver_state');
00153 if ((int)$rec['t3ver_state']===1) {
00154 $this->URL['live'] = 'wsol_preview.php?msg=newpage';
00155 }
00156 }
00157 }
00158
00164 function printFrameset() {
00165 if ($this->isBeLogin()) {
00166 return '
00167 <html>
00168 <head>
00169 <title>Preview and compare workspace version with live version</title>
00170 </head>
00171 <frameset cols="60%,40%" framespacing="3" frameborder="3" border="3">
00172 <frameset rows="20,*,20,*" framespacing="3" frameborder="3" border="3">
00173 <frame name="frame_liveh" src="'.htmlspecialchars($this->URL['liveHeader']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00174 <frame name="frame_live" src="'.htmlspecialchars($this->URL['live']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00175 <frame name="frame_drafth" src="'.htmlspecialchars($this->URL['draftHeader']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00176 <frame name="frame_draft" src="'.htmlspecialchars($this->URL['draft']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00177 </frameset>
00178 <frame name="be" src="'.htmlspecialchars($this->URL['versionMod']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00179 </frameset>
00180 </html>';
00181 } else {
00182 return '
00183 <html>
00184 <head>
00185 <title>Preview and compare workspace version with live version</title>
00186 </head>
00187 <frameset cols="*,*" framespacing="3" frameborder="3" border="3">
00188 <frameset rows="20,*" framespacing="3" frameborder="3" border="3">
00189 <frame name="frame_liveh" src="'.htmlspecialchars($this->URL['liveHeader']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00190 <frame name="frame_live" src="'.htmlspecialchars($this->URL['live']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00191 </frameset>
00192 <frameset rows="20,*" framespacing="3" frameborder="3" border="3">
00193 <frame name="frame_drafth" src="'.htmlspecialchars($this->URL['draftHeader']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00194 <frame name="frame_draft" src="'.htmlspecialchars($this->URL['draft']).'" marginwidth="0" marginheight="0" frameborder="1" scrolling="auto">
00195 </frameset>
00196 </frameset>
00197 </html>';
00198 }
00199 }
00200
00206 function isBeLogin() {
00207 return is_array($GLOBALS['BE_USER']->user);
00208 }
00209 }
00210
00211
00212
00213 $previewObject = t3lib_div::makeInstance('wsol_preview');
00214 $previewObject->main();
00215 ?>