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

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004-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 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00079         // DEFAULT initialization of a module [BEGIN]
00080 unset($MCONF);
00081 require ('conf.php');
00082 require ($BACK_PATH.'init.php');
00083 require ($BACK_PATH.'template.php');
00084 $LANG->includeLLFile('EXT:version/locallang.xml');
00085 require_once (PATH_t3lib.'class.t3lib_scbase.php');
00086         // DEFAULT initialization of a module [END]
00087 
00088 require_once(PATH_t3lib.'class.t3lib_diff.php');
00089 require_once(PATH_typo3.'mod/user/ws/class.wslib.php');
00090 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00091 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
00092 
00093 
00094 
00102 class tx_version_cm1 extends t3lib_SCbase {
00103 
00104                 // Default variables for backend modules
00105         var $MCONF = array();                           // Module configuration
00106         var $MOD_MENU = array();                        // Module menu items
00107         var $MOD_SETTINGS = array();            // Module session settings
00108         var $doc;                                                       // Document Template Object
00109         var $content;                                           // Accumulated content
00110 
00111 
00112                 // Internal:
00113         var $showWorkspaceCol = 0;
00114         var $formatWorkspace_cache = array();
00115         var $formatCount_cache = array();
00116         var $targets = array();         // Accumulation of online targets.
00117         var $pageModule = '';                   // Name of page module
00118         var $publishAccess = FALSE;
00119         var $be_user_Array = array();
00120         var $stageIndex = array();
00121 
00122 
00123 
00124 
00125 
00126 
00127         /*********************************
00128          *
00129          * Standard module initialization
00130          *
00131          *********************************/
00132 
00138         function menuConfig()   {
00139 
00140                         // Menu items:
00141                 $this->MOD_MENU = array(
00142                         'filter' => array(
00143                                 1 => 'Drafts',
00144                                 2 => 'Archive',
00145                                 0 => 'All',
00146                         ),
00147                         'display' => array(
00148                                 0 => '[Live workspace]',
00149                                 -98 => 'Draft Workspaces',
00150                                 -99 => 'All',
00151                                 -1 => '[Default Draft]'
00152                         ),
00153                         'diff' => ''
00154                 );
00155 
00156                         // Add workspaces:
00157                 if ($GLOBALS['BE_USER']->workspace===0) {       // Spend time on this only in online workspace because it might take time:
00158                         $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
00159                         foreach($workspaces as $rec)    {
00160                                 if ($GLOBALS['BE_USER']->checkWorkspace($rec))  {
00161                                         $this->MOD_MENU['display'][$rec['uid']] = '['.$rec['uid'].'] '.$rec['title'];
00162                                 }
00163                         }
00164                 }
00165 
00166                         // CLEANSE SETTINGS
00167                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
00168         }
00169 
00175         function main() {
00176                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00177 
00178                         // Setting module configuration:
00179                 $this->MCONF = $GLOBALS['MCONF'];
00180 
00181                         // Draw the header.
00182                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00183                 $this->doc->backPath = $BACK_PATH;
00184                 $this->doc->form='<form action="" method="post">';
00185 
00186                 // Add styles
00187                 $this->doc->inDocStylesArray[$GLOBALS['MCONF']['name']] = '
00188 .version-diff-1 { background-color: green; }
00189 .version-diff-2 { background-color: red; }
00190 ';
00191 
00192                         // Setting up the context sensitive menu:
00193                 $CMparts = $this->doc->getContextMenuCode();
00194                 $this->doc->JScode.= $CMparts[0];
00195                 $this->doc->bodyTagAdditions = $CMparts[1];
00196                 $this->doc->postCode.= $CMparts[2];
00197 
00198                         // Getting input data:
00199                 $this->id = intval(t3lib_div::_GP('id'));               // Page id. If set, indicates activation from Web>Versioning module
00200                 if (!$this->id) {
00201                         $this->uid = intval(t3lib_div::_GP('uid'));             // Record uid. Goes with table name to indicate specific record
00202                         $this->table = t3lib_div::_GP('table');                 // Record table. Goes with uid to indicate specific record
00203                 } else {
00204                         $this->uid = $this->id;
00205                         $this->table = 'pages';
00206                 }
00207                 $this->details = t3lib_div::_GP('details');             // Page id. If set, indicates activation from Web>Versioning module
00208                 $this->diffOnly = t3lib_div::_GP('diffOnly');           // Flag. If set, shows only the offline version and with diff-view
00209 
00210                         // Force this setting:
00211                 $this->MOD_SETTINGS['expandSubElements'] = TRUE;
00212                 $this->MOD_SETTINGS['diff'] = $this->details || $this->MOD_SETTINGS['diff']?1:0;
00213 
00214                         // Reading the record:
00215                 $record = t3lib_BEfunc::getRecord($this->table,$this->uid);
00216                 if ($record['pid']==-1) {
00217                         $record = t3lib_BEfunc::getRecord($this->table,$record['t3ver_oid']);
00218                 }
00219                 $pidValue = $this->table==='pages' ? $this->uid : $record['pid'];
00220 
00221                         // Checking access etc.
00222                 if (is_array($record) && $TCA[$this->table]['ctrl']['versioningWS'])    {
00223                         $this->uid = $record['uid'];    // Might have changed if new live record was found!
00224 
00225                                 // Access check!
00226                                 // The page will show only if there is a valid page and if this page may be viewed by the user
00227                         $this->pageinfo = t3lib_BEfunc::readPageAccess($pidValue,$this->perms_clause);
00228                         $access = is_array($this->pageinfo) ? 1 : 0;
00229 
00230                         if (($pidValue && $access) || ($BE_USER->user['admin'] && !$pidValue))  {
00231 
00232                                         // JavaScript
00233                                 $this->doc->JScode.= '
00234                                         <script language="javascript" type="text/javascript">
00235                                                 script_ended = 0;
00236                                                 function jumpToUrl(URL) {
00237                                                         window.location.href = URL;
00238                                                 }
00239 
00240                                                 function hlSubelements(origId, verId, over, diffLayer)  {       //
00241                                                         if (over)       {
00242                                                                 document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
00243                                                                 document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
00244                                                                 if (diffLayer)  {
00245                                                                         document.getElementById(\'diff_\'+verId).style.visibility = \'visible\';
00246                                                                 }
00247                                                         } else {
00248                                                                 document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
00249                                                                 document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
00250                                                                 if (diffLayer)  {
00251                                                                         document.getElementById(\'diff_\'+verId).style.visibility = \'hidden\';
00252                                                                 }
00253                                                         }
00254                                                 }
00255                                         </script>
00256                                 ';
00257 
00258                                         // If another page module was specified, replace the default Page module with the new one
00259                                 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00260                                 $this->pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00261 
00262                                         // Setting publish access permission for workspace:
00263                                 $this->publishAccess = $BE_USER->workspacePublishAccess($BE_USER->workspace);
00264 
00265 
00266                                 $headerSection = $this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br/>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path').': '.t3lib_div::fixed_lgd_pre($this->pageinfo['_thePath'],50);
00267 
00268                                 $this->content.=$this->doc->startPage($LANG->getLL('title'));
00269                                 $this->content.=$this->doc->header($LANG->getLL('title'));
00270                                 $this->content.=$this->doc->spacer(5);
00271                                 $this->content.=$this->doc->section('',$headerSection);
00272                                 $this->content.=$this->doc->divider(5);
00273 
00274                                         // Render content:
00275                                 if ($this->id)  {
00276                                         $this->workspaceMgm();
00277                                 } else {
00278                                         $this->versioningMgm();
00279                                 }
00280 
00281                                         // ShortCut
00282                                 if ($BE_USER->mayMakeShortcut())        {
00283                                         $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
00284                                 }
00285                         }
00286 
00287                         $this->content.=$this->doc->spacer(10);
00288                 } else {
00289                                 // If no access or id value, create empty document:
00290                         $this->content.=$this->doc->startPage($LANG->getLL('title'));
00291                         $this->content.=$this->doc->section($LANG->getLL('clickAPage_header'),$LANG->getLL('clickAPage_content'),0,1);
00292                 }
00293         }
00294 
00300         function printContent() {
00301 
00302                 $this->content.=$this->doc->endPage();
00303                 echo $this->content;
00304         }
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 
00314 
00315         /******************************
00316          *
00317          * Versioning management
00318          *
00319          ******************************/
00320 
00326         function versioningMgm()        {
00327                 global $TCA;
00328 
00329                         // Diffing:
00330                 $diff_1 = t3lib_div::_POST('diff_1');
00331                 $diff_2 = t3lib_div::_POST('diff_2');
00332                 if (t3lib_div::_POST('do_diff'))        {
00333                         $content='';
00334                         $content.='<h3>DIFFING:</h3>';
00335                         if ($diff_1 && $diff_2) {
00336                                 $diff_1_record = t3lib_BEfunc::getRecord($this->table, $diff_1);
00337                                 $diff_2_record = t3lib_BEfunc::getRecord($this->table, $diff_2);
00338 
00339                                 if (is_array($diff_1_record) && is_array($diff_2_record))       {
00340                                         t3lib_div::loadTCA($this->table);
00341                                         $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
00342 
00343                                         $tRows=array();
00344                                                                 $tRows[] = '
00345                                                                         <tr class="bgColor5 tableheader">
00346                                                                                 <td>Fieldname:</td>
00347                                                                                 <td width="98%">Colored diff-view:</td>
00348                                                                         </tr>
00349                                                                 ';
00350                                         foreach($diff_1_record as $fN => $fV)   {
00351                                                 if ($TCA[$this->table]['columns'][$fN] && $TCA[$this->table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN)) {
00352                                                         if (strcmp($diff_1_record[$fN],$diff_2_record[$fN]))    {
00353 
00354                                                                 $diffres = $t3lib_diff_Obj->makeDiffDisplay(
00355                                                                         t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_2_record[$fN],0,1),
00356                                                                         t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_1_record[$fN],0,1)
00357                                                                 );
00358 
00359                                                                 $tRows[] = '
00360                                                                         <tr class="bgColor4">
00361                                                                                 <td>'.$fN.'</td>
00362                                                                                 <td width="98%">'.$diffres.'</td>
00363                                                                         </tr>
00364                                                                 ';
00365                                                         }
00366                                                 }
00367                                         }
00368 
00369                                         if (count($tRows)>1)    {
00370                                                 $content.='<table border="0" cellpadding="1" cellspacing="1" width="100%">'.implode('',$tRows).'</table><br/><br/>';
00371                                         } else {
00372                                                 $content.='Records matches completely on all editable fields!';
00373                                         }
00374                                 } else $content.='ERROR: Records could strangely not be found!';
00375                         } else {
00376                                 $content.='ERROR: You didn\'t select two sources for diffing!';
00377                         }
00378                 }
00379 
00380                         // Element:
00381                 $record = t3lib_BEfunc::getRecord($this->table,$this->uid);
00382                 $recordIcon = t3lib_iconWorks::getIconImage($this->table,$record,$this->doc->backPath,'class="absmiddle"');
00383                 $recTitle = t3lib_BEfunc::getRecordTitle($this->table,$record,1);
00384 
00385                         // Display versions:
00386                 $content.='
00387                         '.$recordIcon.$recTitle.'
00388                         <form action="'.t3lib_div::getIndpEnv('REQUEST_URI').'" method="post">
00389                         <table border="0" cellspacing="1" cellpadding="1">';
00390                         $content.='
00391                                 <tr class="bgColor5 tableheader">
00392                                         <td>&nbsp;</td>
00393                                         <td>&nbsp;</td>
00394                                         <td>Title</td>
00395                                         <td>UID</td>
00396                                         <td title="t3ver_oid - Reference to live version UID">oid</td>
00397                                         <td title="t3ver_id - Version number, incremental integer">id</td>
00398                                         <td title="t3ver_wsid - Workspace ID. There can be only one version of an element per ID (except ID zero).">wsid</td>
00399                                         <td title="t3ver_state - Special states of a version: 1=Placeholder for "New". 2=Marked deleted.">state</td>
00400                                         <td title="t3ver_stage - Publishing stage: Editing (0), review (1), publish (10), rejected (-1).">stage</td>
00401                                         <td title="t3ver_count - Life cycle counter. Incremented each time element is unpublished.">count</td>
00402                                         <td>pid</td>
00403                                         <td>t3ver_label</td>
00404                                         <td colspan="2"><input type="submit" name="do_diff" value="Diff" /></td>
00405                                 </tr>';
00406 
00407                 $versions = t3lib_BEfunc::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
00408                 foreach($versions as $row)      {
00409                         $adminLinks = $this->adminLinks($this->table,$row);
00410 
00411                         $content.='
00412                                 <tr class="'.($row['uid']!=$this->uid ? 'bgColor4' : 'bgColor2 tableheader').'">
00413                                         <td>'.($row['uid']!=$this->uid ? '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][action]=swap').'">'.
00414                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert1.gif','width="14" height="14"').' alt="" title="SWAP with current" />'.
00415                                                 '</a>' /* (
00416                                                         $this->table == 'pages' ?
00417                                                         '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][action]=swap&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][swapContent]=1').'">'.
00418                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert2.gif','width="14" height="14"').' alt="" title="Publish page AND content!" />'.
00419                                                 '</a>'.
00420                                                         '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][action]=swap&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][swapContent]=ALL').'">'.
00421                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert4.gif','width="14" height="14"').' alt="" title="Publish page AND content! - AND ALL SUBPAGES!" />'.
00422                                                 '</a>' : '') */ : '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/blinkarrow_left.gif','width="5" height="9"').' alt="" title="CURRENT ONLINE VERSION!"/>').'</td>
00423                                         <td nowrap="nowrap">'.$adminLinks.'</td>
00424                                         <td nowrap="nowrap">'.t3lib_BEfunc::getRecordTitle($this->table,$row,1).'</td>
00425                                         <td>'.$row['uid'].'</td>
00426                                         <td>'.$row['t3ver_oid'].'</td>
00427                                         <td>'.$row['t3ver_id'].'</td>
00428                                         <td>'.$row['t3ver_wsid'].'</td>
00429                                         <td>'.$row['t3ver_state'].'</td>
00430                                         <td>'.$row['t3ver_stage'].'</td>
00431                                         <td>'.$row['t3ver_count'].'</td>
00432                                         <td>'.$row['pid'].'</td>
00433                                         <td nowrap="nowrap"><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$this->table.']['.$row['uid'].']=edit&columnsOnly=t3ver_label',$this->doc->backPath)).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" title="Edit"/></a>'.htmlspecialchars($row['t3ver_label']).'</td>
00434                                         <td class="version-diff-1"><input type="radio" name="diff_1" value="'.$row['uid'].'"'.($diff_1==$row['uid'] ? ' checked="checked"':'').'/></td>
00435                                         <td class="version-diff-2"><input type="radio" name="diff_2" value="'.$row['uid'].'"'.($diff_2==$row['uid'] ? ' checked="checked"':'').'/></td>
00436                                 </tr>';
00437 
00438                                 // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
00439                         if ($this->table == 'pages' && $row['uid']!=$this->uid) {
00440                                 $sub = $this->pageSubContent($row['uid']);
00441 
00442                                 if ($sub)       {
00443                                         $content.='
00444                                                 <tr>
00445                                                         <td></td>
00446                                                         <td></td>
00447                                                         <td colspan="10">'.$sub.'</td>
00448                                                         <td colspan="2"></td>
00449                                                 </tr>';
00450                                 }
00451                         }
00452                 }
00453                 $content.='</table></form>';
00454 
00455                 $this->content.=$this->doc->section('',$content,0,1);
00456 
00457 
00458                         // Create new:
00459                 $content='
00460 
00461                         <form action="'.$this->doc->backPath.'tce_db.php" method="post">
00462                         Label: <input type="text" name="cmd['.$this->table.']['.$this->uid.'][version][label]" /><br/>
00463                         '.($this->table == 'pages' ? '<select name="cmd['.$this->table.']['.$this->uid.'][version][treeLevels]">
00464                                 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0) ? '<option value="0">Page: Page + content</option>' : '').'
00465                                 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(1) ? '<option value="100">Branch: All subpages</option>' : '').'
00466                                 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(-1) ? '<option value="-1">Element: Just record</option>' : '').'
00467                         </select>' : '').'
00468                         <br/><input type="hidden" name="cmd['.$this->table.']['.$this->uid.'][version][action]" value="new" />
00469                         <input type="hidden" name="prErr" value="1" />
00470                         <input type="hidden" name="redirect" value="'.t3lib_div::getIndpEnv('REQUEST_URI').'" />
00471                         <input type="submit" name="_" value="Create new version" />
00472 
00473                         </form>
00474 
00475                 ';
00476 
00477                 $this->content.=$this->doc->spacer(15);
00478                 $this->content.=$this->doc->section('Create new version',$content,0,1);
00479 
00480         }
00481 
00489         function pageSubContent($pid,$c=0)      {
00490                 global $TCA;
00491 
00492                 $tableNames = t3lib_div::removeArrayEntryByValue(array_keys($TCA),'pages');
00493                 $tableNames[] = 'pages';
00494 
00495                 foreach($tableNames as $tN)     {
00496                                 // Basically list ALL tables - not only those being copied might be found!
00497                         #if ($TCA[$tN]['ctrl']['versioning_followPages'] || $tN=='pages')       {
00498                                 $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $tN, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($tN), '', ($TCA[$tN]['ctrl']['sortby'] ? $TCA[$tN]['ctrl']['sortby'] : ''));
00499 
00500                                 if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres))  {
00501                                         $content.='
00502                                                 <tr>
00503                                                         <td colspan="4" class="'.($TCA[$tN]['ctrl']['versioning_followPages'] ? 'bgColor6' : ($tN=='pages' ? 'bgColor5' : 'bgColor-10')).'"'.(!$TCA[$tN]['ctrl']['versioning_followPages'] && $tN!='pages' ? ' style="color: #666666; font-style:italic;"':'').'>'.$tN.'</td>
00504                                                 </tr>';
00505                                         while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))  {
00506                                                 $ownVer = $this->lookForOwnVersions($tN,$subrow['uid']);
00507                                                 $content.='
00508                                                         <tr>
00509                                                                 <td>'.$this->adminLinks($tN,$subrow).'</td>
00510                                                                 <td>'.$subrow['uid'].'</td>
00511                                                                 '.($ownVer>1 ? '<td style="font-weight: bold; background-color: yellow;"><a href="index.php?table='.rawurlencode($tN).'&uid='.$subrow['uid'].'">'.($ownVer-1).'</a></td>' : '<td></td>').'
00512                                                                 <td width="98%">'.t3lib_BEfunc::getRecordTitle($tN,$subrow,1).'</td>
00513                                                         </tr>';
00514 
00515                                                 if ($tN == 'pages' && $c<100)   {
00516                                                         $sub = $this->pageSubContent($subrow['uid'],$c+1);
00517 
00518                                                         if ($sub)       {
00519                                                                 $content.='
00520                                                                         <tr>
00521                                                                                 <td></td>
00522                                                                                 <td></td>
00523                                                                                 <td></td>
00524                                                                                 <td width="98%">'.$sub.'</td>
00525                                                                         </tr>';
00526                                                         }
00527                                                 }
00528                                         }
00529                                 }
00530                         #}
00531                 }
00532 
00533                 return $content ? '<table border="1" cellpadding="1" cellspacing="0" width="100%">'.$content.'</table>' : '';
00534         }
00535 
00543         function lookForOwnVersions($table,$uid)        {
00544                 global $TCA;
00545 
00546                 $versions = t3lib_BEfunc::selectVersionsOfRecord($table, $uid, 'uid');
00547                 if (is_array($versions))        {
00548                         return count($versions);
00549                 }
00550                 return FALSE;
00551         }
00552 
00560         function adminLinks($table,$row)        {
00561                 global $BE_USER;
00562 
00563                         // Edit link:
00564                 $adminLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$table.']['.$row['uid'].']=edit',$this->doc->backPath)).'">'.
00565                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" title="Edit"/>'.
00566                                                 '</a>';
00567 
00568                         // Delete link:
00569                 $adminLink.= '<a href="'.htmlspecialchars($this->doc->issueCommand('&cmd['.$table.']['.$row['uid'].'][delete]=1')).'">'.
00570                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" title="Delete"/>'.
00571                                                 '</a>';
00572 
00573 
00574 
00575                 if ($table == 'pages')  {
00576 
00577                                 // If another page module was specified, replace the default Page module with the new one
00578                         $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00579                         $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00580 
00581                                 // Perform some acccess checks:
00582                         $a_wl = $BE_USER->check('modules','web_list');
00583                         $a_wp = t3lib_extMgm::isLoaded('cms') && $BE_USER->check('modules',$pageModule);
00584 
00585                         $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\''.$pageModule.'\'); return false;">'.
00586                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="" alt="" />'.
00587                                                 '</a>';
00588                         $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\'web_list\'); return false;">'.
00589                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'mod/web/list/list.gif','width="14" height="12"').' title="" alt="" />'.
00590                                                 '</a>';
00591 
00592                                 // "View page" icon is added:
00593                         $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($row['uid'],$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($row['uid']))).'">'.
00594                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
00595                                 '</a>';
00596                 } else {
00597                         if ($row['pid']==-1)    {
00598                                 $getVars = '&ADMCMD_vPrev['.rawurlencode($table.':'.$row['t3ver_oid']).']='.$row['uid'];
00599 
00600                                         // "View page" icon is added:
00601                                 $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($row['_REAL_PID'],$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($row['_REAL_PID']),'','',$getVars)).'">'.
00602                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
00603                                         '</a>';
00604                         }
00605                 }
00606 
00607                 return $adminLink;
00608         }
00609 
00610 
00611 
00612 
00613 
00614 
00615 
00616 
00617 
00618 
00619 
00620         /******************************
00621          *
00622          * Workspace management
00623          *
00624          ******************************/
00625 
00632         function workspaceMgm() {
00633 
00634                 $menu = '';
00635                 if ($GLOBALS['BE_USER']->workspace===0) {
00636                         $menu.= t3lib_BEfunc::getFuncMenu($this->id,'SET[filter]',$this->MOD_SETTINGS['filter'],$this->MOD_MENU['filter']);
00637                         $menu.= t3lib_BEfunc::getFuncMenu($this->id,'SET[display]',$this->MOD_SETTINGS['display'],$this->MOD_MENU['display']);
00638                 }
00639                 if (!$this->details && $GLOBALS['BE_USER']->workspace && !$this->diffOnly)      {
00640                         $menu.= t3lib_BEfunc::getFuncCheck($this->id,'SET[diff]',$this->MOD_SETTINGS['diff']).' Show difference view';
00641                 }
00642 
00643                 if ($menu)      {
00644                         $this->content.=$this->doc->section('',$menu,0,1);
00645                 }
00646 
00647                         // Perform workspace publishing action if buttons are pressed:
00648                 $errors = $this->publishAction();
00649 
00650                         // Generate workspace overview:
00651                 $WSoverview = $this->displayWorkspaceOverview();
00652 
00653                         // Buttons for publish / swap:
00654                 $actionLinks = '<br/>';
00655                 if ($GLOBALS['BE_USER']->workspace!==0) {
00656                         if ($this->publishAccess)       {
00657                                 $actionLinks.= '<input type="submit" name="_publish" value="Publish page" onclick="return confirm(\'Are you sure you want to publish all content '.($GLOBALS['BE_USER']->workspaceRec['publish_access']&1 ? 'in &quot;Publish&quot; stage ':'').'from this page?\');"/>';
00658                                 if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
00659                                         $actionLinks.= '<input type="submit" name="_swap" value="Swap page" onclick="return confirm(\'Are you sure you want to publish (swap) all content '.($GLOBALS['BE_USER']->workspaceRec['publish_access']&1 ? 'in &quot;Publish&quot; stage ':'').'from this page?\');" />';
00660                                 }
00661                         } else {
00662                                 $actionLinks.= $this->doc->icons(1).'You are not permitted to publish from this workspace';
00663                         }
00664                 }
00665                 $actionLinks.= '<input type="submit" name="_" value="Refresh" />';
00666                 $actionLinks.= '<input type="submit" name="_previewLink" value="Preview Link" />';
00667                 $actionLinks.= $this->displayWorkspaceOverview_allStageCmd();
00668 
00669                 if ($actionLinks || count($errors))     {
00670                         $this->content.= $this->doc->section('',$actionLinks.(count($errors) ? '<h3>Errors:</h3><br/>'.implode('<br/>',$errors).'<hr/>' : ''),0,1);
00671                 }
00672 
00673                 if (t3lib_div::_POST('_previewLink'))   {
00674                         $params = 'id='.$this->id.'&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS='.$GLOBALS['BE_USER']->workspace;
00675                         $previewUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL').'?ADMCMD_prev='.t3lib_BEfunc::compilePreviewKeyword($params, $GLOBALS['BE_USER']->user['uid']);
00676 
00677                         $this->content.= $this->doc->section('Preview Url:','You can preview this page from the workspace using this link for the next 48 hours (does not require backend login):<br/><br/><a target="_blank" href="'.htmlspecialchars($previewUrl).'">'.$previewUrl.'</a>',0,1);
00678                 }
00679 
00680                         // Output overview content:
00681                 $this->content.= $this->doc->spacer(15);
00682                 $this->content.= $this->doc->section($this->details ? 'Details for version' : 'Workspace management', $WSoverview,0,1);
00683 
00684         }
00685 
00692         function displayWorkspaceOverview()     {
00693 
00694                         // Initialize variables:
00695                 $this->showWorkspaceCol = $GLOBALS['BE_USER']->workspace===0 && $this->MOD_SETTINGS['display']<=-98;
00696 
00697                         // Get usernames and groupnames
00698                 $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
00699                 $groupArray = array_keys($be_group_Array);
00700                 $this->be_user_Array = t3lib_BEfunc::getUserNames();
00701                 if (!$GLOBALS['BE_USER']->isAdmin())            $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,$groupArray,1);
00702 
00703                         // Initialize Workspace ID and filter-value:
00704                 if ($GLOBALS['BE_USER']->workspace===0) {
00705                         $wsid = $this->details ? -99 : $this->MOD_SETTINGS['display'];          // Set wsid to the value from the menu (displaying content of other workspaces)
00706                         $filter = $this->details ? 0 : $this->MOD_SETTINGS['filter'];
00707                 } else {
00708                         $wsid = $GLOBALS['BE_USER']->workspace;
00709                         $filter = 0;
00710                 }
00711 
00712                         // Initialize workspace object and request all pending versions:
00713                 $wslibObj = t3lib_div::makeInstance('wslib');
00714 
00715                         // Selecting ALL versions belonging to the workspace:
00716                 $versions = $wslibObj->selectVersionsInWorkspace($wsid, $filter, -99, $this->uid);      // $this->uid is the page id of LIVE record.
00717 
00718                         // Traverse versions and build page-display array:
00719                 $pArray = array();
00720                 foreach($versions as $table => $records)        {
00721                         foreach($records as $rec)       {
00722                                 $pageIdField = $table==='pages' ? 't3ver_oid' : 'realpid';
00723                                 $this->displayWorkspaceOverview_setInPageArray(
00724                                         $pArray,
00725                                         $table,
00726                                         $rec
00727                                 );
00728                         }
00729                 }
00730 
00731                         // Make header of overview:
00732                 $tableRows = array();
00733                 if (count($pArray))     {
00734                         $tableRows[] = '
00735                                 <tr class="bgColor5 tableheader">
00736                                         '.($this->diffOnly?'':'<td nowrap="nowrap" colspan="2">Live Version:</td>').'
00737                                         <td nowrap="nowrap" colspan="2">Draft Versions:</td>
00738                                         <td nowrap="nowrap"'.($this->diffOnly?' colspan="2"':' colspan="4"').'>Controls:</td>
00739                                 </tr>';
00740 
00741                                 // Add lines from overview:
00742                         $tableRows = array_merge($tableRows, $this->displayWorkspaceOverview_list($pArray));
00743 
00744                         $table = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding workspace-overview">'.implode('',$tableRows).'</table>';
00745                 } else $table = '';
00746 
00747                 $linkBack = t3lib_div::_GP('returnUrl') ? '<a href="'.htmlspecialchars(t3lib_div::_GP('returnUrl')).'" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />Click here to go back</a><br/><br/>' : '';
00748                 $resetDiffOnly = $this->diffOnly ? '<a href="index.php?id='.intval($this->id).'" class="typo3-goBack">Show all information</a><br/><br/>' : '';
00749 
00750                 $versionSelector = $GLOBALS['BE_USER']->workspace ? $this->doc->getVersionSelector($this->id) : '';
00751 
00752                 return $versionSelector.$linkBack.$resetDiffOnly.$table.$this->markupNewOriginals();
00753         }
00754 
00762         function displayWorkspaceOverview_list($pArray) {
00763                 global $TCA;
00764 
00765                         // If there ARE elements on this level, print them:
00766                 $warnAboutVersions_nonPages = FALSE;
00767                 $warnAboutVersions_page = FALSE;
00768                 if (is_array($pArray))  {
00769                         foreach($pArray as $table => $oidArray) {
00770                                 foreach($oidArray as $oid => $recs)     {
00771 
00772                                                 // Get CURRENT online record and icon based on "t3ver_oid":
00773                                         $rec_on = t3lib_BEfunc::getRecord($table,$oid);
00774                                         $icon = t3lib_iconWorks::getIconImage($table, $rec_on, $this->doc->backPath,' align="top" title="'.t3lib_BEfunc::getRecordIconAltText($rec_on,$table).'"');
00775                                         if ($GLOBALS['BE_USER']->workspace===0) {       // Only edit online records if in ONLINE workspace:
00776                                                 $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $rec_on['uid'], 1, '', '+edit,view,info,delete');
00777                                         }
00778 
00779                                                 // Online version display:
00780                                                 // Create the main cells which will span over the number of versions there is.
00781                                         $verLinkUrl = $TCA[$table]['ctrl']['versioningWS'];
00782                                         $origElement = $icon.
00783                                                 ($verLinkUrl ? '<a href="'.htmlspecialchars('index.php?table='.$table.'&uid='.$rec_on['uid']).'">' : '').
00784                                                 t3lib_BEfunc::getRecordTitle($table,$rec_on,TRUE).
00785                                                 ($verLinkUrl ? '</a>' : '');
00786                                         $mainCell_rowSpan = count($recs)>1 ? ' rowspan="'.count($recs).'"' : '';
00787                                         $mainCell = '
00788                                                                 <td align="center"'.$mainCell_rowSpan.'>'.$this->formatVerId($rec_on['t3ver_id']).'</td>
00789                                                                 <td nowrap="nowrap"'.$mainCell_rowSpan.'>'.
00790                                                                         $origElement.
00791                                                                         '###SUB_ELEMENTS###'.   // For substitution with sub-elements, if any.
00792                                                                 '</td>';
00793 
00794                                                 // Offline versions display:
00795                                                 // Traverse the versions of the element
00796                                         foreach($recs as $rec)  {
00797 
00798                                                         // Get the offline version record and icon:
00799                                                 $rec_off = t3lib_BEfunc::getRecord($table,$rec['uid']);
00800                                                 $icon = t3lib_iconWorks::getIconImage($table, $rec_off, $this->doc->backPath, ' align="top" title="'.t3lib_BEfunc::getRecordIconAltText($rec_off,$table).'"');
00801                                                 $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $rec_off['uid'], 1, '', '+edit,view,info,delete');
00802 
00803                                                         // Prepare diff-code:
00804                                                 if ($this->MOD_SETTINGS['diff'] || $this->diffOnly)     {
00805                                                         $diffCode = '';
00806                                                         list($diffHTML,$diffPct) = $this->createDiffView($table, $rec_off, $rec_on);
00807                                                         if ($rec_on['t3ver_state']==1)  {       // New record:
00808                                                                 $diffCode.= $this->doc->icons(1).'New element<br/>';    // TODO Localize?
00809                                                                 $diffCode.= $diffHTML;
00810                                                         } elseif ($rec_off['t3ver_state']==2)   {
00811                                                                 $diffCode.= $this->doc->icons(2).'Deleted element<br/>';
00812                                                         } else {
00813                                                                 $diffCode.= ($diffPct<0 ? 'N/A' : ($diffPct ? $diffPct.'% change:' : ''));
00814                                                                 $diffCode.= $diffHTML;
00815                                                         }
00816                                                 } else $diffCode = '';
00817 
00818                                                         // Prepare swap-mode values:
00819                                                 if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
00820                                                         if ($rec_off['t3ver_swapmode']>0)       {
00821                                                                 $vType = 'branch';
00822                                                         } else {
00823                                                                 $vType = 'page';
00824                                                         }
00825                                                 } else {
00826                                                         $vType = 'element';
00827                                                 }
00828 
00829                                                 switch($vType) {
00830                                                         case 'element':
00831                                                                 $swapLabel = ' [Element]';
00832                                                                 $swapClass = 'ver-element';
00833                                                                 $warnAboutVersions_nonPages = $warnAboutVersions_page;  // Setting this if sub elements are found with a page+content (must be rendered prior to this of course!)
00834                                                         break;
00835                                                         case 'page':
00836                                                                 $swapLabel = ' [Page]';
00837                                                                 $swapClass = 'ver-page';
00838                                                                 $warnAboutVersions_page = !$this->showWorkspaceCol;             // This value is true only if multiple workspaces are shown and we need the opposite here.
00839                                                         break;
00840                                                         case 'branch':
00841                                                                 $swapLabel = ' [Branch]';
00842                                                                 $swapClass = 'ver-branch';
00843                                                         break;
00844                                                 }
00845 
00846                                                         // Modify main cell based on first version shown:
00847                                                 $subElements = array();
00848                                                 if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1 && $mainCell)    {       // For "Page" and "Branch" swap modes where $mainCell is still carrying content (only first version)
00849                                                         $subElements['on'] = $this->subElements($rec_on['uid'], $rec_off['t3ver_swapmode']);
00850                                                         $subElements['off'] = $this->subElements($rec_off['uid'],$rec_off['t3ver_swapmode'],$rec_on['uid']);
00851                                                 }
00852                                                 $mainCell = str_replace('###SUB_ELEMENTS###', $subElements['on'], $mainCell);
00853 
00854                                                         // Create version element:
00855                                                 $versionsInOtherWS = $this->versionsInOtherWS($table, $rec_on['uid']);
00856                                                 $versionsInOtherWSWarning = $versionsInOtherWS && $GLOBALS['BE_USER']->workspace!==0 ? '<br/>'.$this->doc->icons(2).'Other version(s) in workspace '.$versionsInOtherWS : '';
00857                                                 $multipleWarning = (!$mainCell && $GLOBALS['BE_USER']->workspace!==0? '<br/>'.$this->doc->icons(3).'<b>Multiple versions in same workspace!</b>' : '');
00858                                                 $verWarning = $warnAboutVersions || ($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])? '<br/>'.$this->doc->icons(3).'<b>Version inside version!</b>' : '';
00859                                                 $verElement = $icon.
00860                                                         (!$this->details ? '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table==='pages'?$rec_on['uid']:$rec_on['pid']).'&details='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">' : '').
00861                                                         t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
00862                                                         (!$this->details ? '</a>' : '').
00863                                                         $versionsInOtherWSWarning.
00864                                                         $multipleWarning.
00865                                                         $verWarning;
00866 
00867                                                 $ctrlTable = '
00868                                                                 <td nowrap="nowrap">'.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).'</td>
00869                                                                 <td nowrap="nowrap" class="'.$swapClass.'">'.
00870                                                                         $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType).
00871                                                                         htmlspecialchars($swapLabel).
00872                                                                         '&nbsp;&nbsp;</td>
00873                                                                 '.(!$this->diffOnly?'<td nowrap="nowrap"><b>Lifecycle:</b> '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).'</td>'.             // Lifecycle
00874                                                                         ($this->showWorkspaceCol ? '
00875                                                                 <td nowrap="nowrap">&nbsp;&nbsp;<b>Workspace:</b> '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'</td>' : ''):'');
00876 
00877                                                 if ($diffCode)  {
00878                                                         $verElement = $verElement.'
00879                                                         <br/><b>Difference to live element:</b>
00880                                                         <table border="0" cellpadding="0" cellspacing="0" class="ver-verElement">
00881                                                                 <tr>
00882                                                                         <td class="c-diffCell">'.$diffCode.'</td>
00883                                                                 </tr>
00884                                                         </table>';
00885                                                 }
00886 
00887 
00888                                                         // Create version cell:
00889                                                 $verCell = '
00890                                                                 <td align="center">'.$this->formatVerId($rec_off['t3ver_id']).'</td>
00891                                                                 <td nowrap="nowrap">'.
00892                                                                         $verElement.
00893                                                                         $subElements['off'].
00894                                                                         '</td>
00895                                                                 ';
00896 
00897                                                         // Compile table row:
00898                                                 $tableRows[] = '
00899                                                         <tr class="bgColor4">
00900                                                                 '.
00901                                                                 ($this->diffOnly?'':$mainCell).
00902                                                                 $verCell.
00903                                                                 $ctrlTable.
00904                                                                 '
00905                                                         </tr>';
00906 
00907                                                         // Reset the main cell:
00908                                                 $mainCell = '';
00909 
00910                                         }
00911                                 }
00912                         }
00913                 }
00914 
00915                 return $tableRows;
00916         }
00917 
00927         function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row)  {
00928                 if (!$this->details || $this->details==$table.':'.$row['uid'])  {
00929                         $pArray[$table][$row['t3ver_oid']][] = $row;
00930                 }
00931         }
00932 
00940         function displayWorkspaceOverview_allStageCmd() {
00941 
00942                 if (count($this->stageIndex[1]))        {       // Review:
00943                         $sId = 1;
00944                         $color = '#666666';
00945                         $label = 'Comment for Reviewer:';
00946                         $titleAttrib = 'Send all to Review';
00947                 } elseif(count($this->stageIndex[10]))  {       // Publish:
00948                         $sId = 10;
00949                         $color = '#6666cc';
00950                         $label = 'Comment for Publisher:';
00951                         $titleAttrib = 'Approve all for Publishing';
00952                 } else {
00953                         $sId = 0;
00954                 }
00955 
00956                 if ($sId>0)     {
00957                         $issueCmd = '';
00958                         foreach($this->stageIndex[$sId] as $table => $uidArray) {
00959                                 $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][action]=setStage';
00960                                 $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][stageId]='.$sId;
00961                         }
00962 
00963                         $onClick = 'var commentTxt=window.prompt("'.$label.'","");
00964                                                         if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand($issueCmd).'&generalComment="+escape(commentTxt);}'.
00965                                                         ' return false;';
00966                         $actionLinks.=
00967                                 '<input type="submit" name="_" value="'.htmlspecialchars($titleAttrib).'" onclick="'.htmlspecialchars($onClick).'" />';
00968                 } else $actionLinks = '';
00969 
00970                 return $actionLinks;
00971         }
00972 
00973 
00974 
00975 
00976 
00977 
00978         /**************************************
00979          *
00980          * Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
00981          *
00982          *************************************/
00983 
00990         function formatVerId($verId)    {
00991                 return '1.'.$verId;
00992         }
00993 
01000         function formatWorkspace($wsid) {
01001 
01002                         // Render, if not cached:
01003                 if (!isset($this->formatWorkspace_cache[$wsid]))        {
01004                         switch($wsid)   {
01005                                 case -1:
01006                                         $this->formatWorkspace_cache[$wsid] = '[Offline]';
01007                                 break;
01008                                 case 0:
01009                                         $this->formatWorkspace_cache[$wsid] = '';       // Does not output anything for ONLINE because it might confuse people to think that the elemnet IS online which is not the case - only that it exists as an offline version in the online workspace...
01010                                 break;
01011                                 default:
01012                                         list($titleRec) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title','sys_workspace','uid='.intval($wsid).t3lib_BEfunc::deleteClause('sys_workspace'));
01013                                         $this->formatWorkspace_cache[$wsid] = '['.$wsid.'] '.$titleRec['title'];
01014                                 break;
01015                         }
01016                 }
01017 
01018                 return $this->formatWorkspace_cache[$wsid];
01019         }
01020 
01027         function formatCount($count)    {
01028 
01029                         // Render, if not cached:
01030                 if (!isset($this->formatCount_cache[$count]))   {
01031                         switch($count)  {
01032                                 case 0:
01033                                         $this->formatCount_cache[$count] = 'Draft';
01034                                 break;
01035                                 case 1:
01036                                         $this->formatCount_cache[$count] = 'Archive';
01037                                 break;
01038                                 default:
01039                                         $this->formatCount_cache[$count] = 'Published '.$count.' times';
01040                                 break;
01041                         }
01042                 }
01043 
01044                 return $this->formatCount_cache[$count];
01045         }
01046 
01054         function versionsInOtherWS($table,$uid) {
01055 
01056                         // Check for duplicates:
01057                         // Select all versions of record NOT in this workspace:
01058                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01059                         't3ver_wsid',
01060                         $table,
01061                         'pid=-1
01062                                 AND t3ver_oid='.intval($uid).'
01063                                 AND t3ver_wsid!='.intval($GLOBALS['BE_USER']->workspace).'
01064                                 AND (t3ver_wsid=-1 OR t3ver_wsid>0)'.
01065                                 t3lib_BEfunc::deleteClause($table),
01066                         '',
01067                         't3ver_wsid',
01068                         '',
01069                         't3ver_wsid'
01070                 );
01071                 if (count($rows))       {
01072                         return implode(',',array_keys($rows));
01073                 }
01074         }
01075 
01084         function showStageChangeLog($table,$id,$stageCommands)  {
01085                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01086                         'log_data,tstamp,userid',
01087                         'sys_log',
01088                         'action=6 and details_nr=30
01089                                 AND tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_log').'
01090                                 AND recuid='.intval($id)
01091                 );
01092 
01093                 $entry = array();
01094                 foreach($rows as $dat)  {
01095                         $data = unserialize($dat['log_data']);
01096                         $username = $this->be_user_Array[$dat['userid']] ? $this->be_user_Array[$dat['userid']]['username'] : '['.$dat['userid'].']';
01097 
01098                         switch($data['stage'])  {
01099                                 case 1:
01100                                         $text = 'sent element to "Review"';
01101                                 break;
01102                                 case 10:
01103                                         $text = 'approved for "Publish"';
01104                                 break;
01105                                 case -1:
01106                                         $text = 'rejected element!';
01107                                 break;
01108                                 case 0:
01109                                         $text = 'reset to "Editing"';
01110                                 break;
01111                                 default:
01112                                         $text = '[undefined]';
01113                                 break;
01114                         }
01115                         $text = t3lib_BEfunc::dateTime($dat['tstamp']).': "'.$username.'" '.$text;
01116                         $text.= ($data['comment']?'<br/>User Comment: <em>'.$data['comment'].'</em>':'');
01117 
01118                         $entry[] = $text;
01119                 }
01120 
01121                 return count($entry) ? '<span onmouseover="document.getElementById(\'log_'.$table.$id.'\').style.visibility = \'visible\';" onmouseout="document.getElementById(\'log_'.$table.$id.'\').style.visibility = \'hidden\';">'.$stageCommands.' ('.count($entry).')</span>'.
01122                                 '<div class="logLayer" style="visibility: hidden; position: absolute;" id="log_'.$table.$id.'">'.implode('<hr/>',$entry).'</div>' : $stageCommands;
01123         }
01124 
01133         function subElements($uid,$treeLevel,$origId=0) {
01134                 global $TCA;
01135 
01136                 if (!$this->details && ($GLOBALS['BE_USER']->workspace===0 || !$this->MOD_SETTINGS['expandSubElements']))       {       // In online workspace we have a reduced view because otherwise it will bloat the listing:
01137                         return '<br/>
01138                                         <img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' align="top" alt="" title="" />'.
01139                                         ($origId ?
01140                                                 '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.$uid.'&details='.rawurlencode('pages:'.$uid).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
01141                                                 '<span class="typo3-dimmed"><em>[Sub elements, click for details]</em><span></a>' :
01142                                                 '<span class="typo3-dimmed"><em>[Sub elements]</em><span>');
01143                 } else {        // For an offline workspace, show sub elements:
01144 
01145                         $tCell = array();
01146 
01147                                 // Find records that follow pages when swapping versions:
01148                         $recList = array();
01149                         foreach($TCA as $tN => $tCfg)   {
01150                                 if ($tN!='pages' && ($treeLevel>0 || $TCA[$tN]['ctrl']['versioning_followPages']))      {
01151                                         $this->subElements_getNonPageRecords($tN, $uid, $recList);
01152                                 }
01153                         }
01154 
01155                                 // Render records collected above:
01156                         $elCount = count($recList)-1;
01157                         foreach($recList as $c => $comb)        {
01158                                 list($tN,$rec) = $comb;
01159 
01160                                 $this->subElements_renderItem(
01161                                         $tCell,
01162                                         $tN,
01163                                         $uid,
01164                                         $rec,
01165                                         $origId,
01166                                         $c==$elCount && $treeLevel==0 ? 1 : 0,          // If true, will show bottom-join icon.
01167                                         ''
01168                                 );
01169                         }
01170 
01171                                 // For branch, dive into the subtree:
01172                         if ($treeLevel>0) {
01173 
01174                                         // Drawing tree:
01175                                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
01176                                 $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
01177                                 $tree->makeHTML = 2;            // 2=Also rendering depth-data into the result array
01178                                 $tree->getTree($uid, 99, '');
01179 
01180                                         // Traverse page tree:
01181                                 foreach($tree->tree as $data)   {
01182 
01183                                                 // Render page in table cell:
01184                                         $this->subElements_renderItem(
01185                                                 $tCell,
01186                                                 'pages',
01187                                                 $uid,
01188                                                 t3lib_BEfunc::getRecord('pages',$data['row']['uid']),   // Needs all fields, at least more than what is given in $data['row']...
01189                                                 $origId,
01190                                                 2,              // 2=the join icon and icon for the record is not rendered for pages (where all is in $data['HTML']
01191                                                 $data['HTML']
01192                                         );
01193 
01194                                                 // Find all records from page and collect in $recList:
01195                                         $recList = array();
01196                                         foreach($TCA as $tN => $tCfg)   {
01197                                                 if ($tN!=='pages')      {
01198                                                         $this->subElements_getNonPageRecords($tN, $data['row']['uid'], $recList);
01199                                                 }
01200                                         }
01201 
01202                                                 // Render records collected above:
01203                                         $elCount = count($recList)-1;
01204                                         foreach($recList as $c => $comb)        {
01205                                                 list($tN,$rec) = $comb;
01206 
01207                                                 $this->subElements_renderItem(
01208                                                         $tCell,
01209                                                         $tN,
01210                                                         $uid,
01211                                                         $rec,
01212                                                         $origId,
01213                                                         $c==$elCount?1:0,       // If true, will show bottom-join icon.
01214                                                         $data['HTML_depthData']
01215                                                 );
01216                                         }
01217                                 }
01218                         }
01219 
01220                         return '
01221                                         <!-- Sub-element tree for versions -->
01222                                         <table border="0" cellpadding="0" cellspacing="1" class="ver-subtree">
01223                                                 '.implode('',$tCell).'
01224                                         </table>';
01225                 }
01226         }
01227 
01236         function subElements_getNonPageRecords($tN, $uid, &$recList)    {
01237                 global $TCA;
01238 
01239                 $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01240                         '*',
01241                         $tN,
01242                         'pid='.intval($uid).
01243                                 ($TCA[$tN]['ctrl']['versioningWS'] ? ' AND t3ver_state=0' : '').
01244                                 t3lib_BEfunc::deleteClause($tN),
01245                         '',
01246                         $TCA[$tN]['ctrl']['sortby'] ? $TCA[$tN]['ctrl']['sortby'] : $GLOBALS['TYPO3_DB']->stripOrderBy($TCA[$tN]['ctrl']['default_sortby'])
01247                 );
01248 
01249                 foreach($records as $rec)       {
01250                         $recList[] = array($tN,$rec);
01251                 }
01252         }
01253 
01266         function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata)      {
01267                 global $TCA;
01268 
01269                         // Initialize:
01270                 $origUidFields = $TCA[$tN]['ctrl']['origUid'];
01271                 $diffCode = '';
01272 
01273                 if ($origUidFields)     {       // If there is a field for this table with original uids we will use that to connect records:
01274                         if (!$origId)   {       // In case we are displaying the online originals:
01275                                 $this->targets['orig_'.$uid.'_'.$tN.'_'.$rec['uid']] = $rec;    // Build up target array (important that
01276                                 $tdParams =  ' id="orig_'.$uid.'_'.$tN.'_'.$rec['uid'].'" class="typo3-ver"';           // Setting ID of the table row
01277                         } else {        // Version branch:
01278                                 if ($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]])   {       // If there IS a corresponding original record...:
01279 
01280                                                 // Prepare Table row parameters:
01281                                         $tdParams =  ' onmouseover="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 1, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'.
01282                                                                 ' onmouseout="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 0, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'.
01283                                                                 ' id="ver_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="typo3-ver"';
01284 
01285                                                 // Create diff view:
01286                                         if ($this->MOD_SETTINGS['diff'])        {
01287                                                 list($diffHTML,$diffPct) = $this->createDiffView($tN, $rec, $this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
01288 
01289                                                 if ($this->MOD_SETTINGS['diff']==2)     {
01290                                                         $diffCode =
01291                                                                 ($diffPct ? '<span class="nobr">'.$diffPct.'% change</span>' : '-').
01292                                                                 '<div style="visibility: hidden; position: absolute;" id="diff_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="diffLayer">'.
01293                                                                 $diffHTML.
01294                                                                 '</div>';
01295                                                 } else {
01296                                                         $diffCode =
01297                                                                 ($diffPct<0 ? 'N/A' : ($diffPct ? $diffPct.'% change:' : '')).
01298                                                                 $diffHTML;
01299                                                 }
01300                                         }
01301 
01302                                                 // Unsetting the target fields allows us to mark all originals without a version in the subtree (see ->markupNewOriginals())
01303                                         unset($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
01304                                 } else {        // No original record, so must be new:
01305                                         $tdParams =  ' class="typo3-ver-new"';
01306                                 }
01307                         }
01308                 } else {        // If no original uid column is supported for this table we are forced NOT to display any diff or highlighting.
01309                         $tdParams = ' class="typo3-ver-noComp"';
01310                 }
01311 
01312                         // Compile the cell:
01313                 $tCell[] = '
01314                                                 <tr'.$tdParams.'>
01315                                                         <td class="iconTitle">'.
01316                                                                 $HTMLdata.
01317                                                                 ($iconMode < 2 ?
01318                                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/join'.($iconMode ? 'bottom' : '').'.gif','width="18" height="16"').' alt="" />'.
01319                                                                         t3lib_iconWorks::getIconImage($tN, $rec, $this->doc->backPath,'') : '').
01320                                                                 t3lib_BEfunc::getRecordTitle($tN, $rec, TRUE).
01321                                                         '</td>
01322                                                         <td class="cmdCell">'.
01323                                                                 $this->displayWorkspaceOverview_commandLinksSub($tN,$rec,$origId).
01324                                                         '</td>'.($origId ? '<td class="diffCell">'.
01325                                                                 $diffCode.
01326                                                         '</td>':'').'
01327                                                 </tr>';
01328         }
01329 
01335         function markupNewOriginals()   {
01336 
01337                 if (count($this->targets))      {
01338                         $scriptCode = '';
01339                         foreach($this->targets as $key => $rec) {
01340                                 $scriptCode.='
01341                                         document.getElementById(\''.$key.'\').attributes.getNamedItem("class").nodeValue = \'typo3-ver-new\';
01342                                 ';
01343                         }
01344 
01345                         return $this->doc->wrapScriptTags($scriptCode);
01346                 }
01347         }
01348 
01357         function createDiffView($table, $diff_1_record, $diff_2_record) {
01358                 global $TCA;
01359 
01360                         // Initialize:
01361                 $pctChange = 'N/A';
01362 
01363                         // Check that records are arrays:
01364                 if (is_array($diff_1_record) && is_array($diff_2_record))       {
01365 
01366                                 // Load full table description and initialize diff-object:
01367                         t3lib_div::loadTCA($table);
01368                         $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
01369 
01370                                 // Add header row:
01371                         $tRows = array();
01372                         $tRows[] = '
01373                                 <tr class="bgColor5 tableheader">
01374                                         <td>Fieldname:</td>
01375                                         <td width="98%" nowrap="nowrap">Colored diff-view:</td>
01376                                 </tr>
01377                         ';
01378 
01379                                 // Initialize variables to pick up string lengths in:
01380                         $allStrLen = 0;
01381                         $diffStrLen = 0;
01382 
01383                                 // Traversing the first record and process all fields which are editable:
01384                         foreach($diff_1_record as $fN => $fV)   {
01385                                 if ($TCA[$table]['columns'][$fN] && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN))     {
01386 
01387                                                 // Check if it is files:
01388                                         $isFiles = FALSE;
01389                                         if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])) &&
01390                                                         $TCA[$table]['columns'][$fN]['config']['type']=='group' &&
01391                                                         $TCA[$table]['columns'][$fN]['config']['internal_type']=='file')        {
01392 
01393                                                         // Initialize:
01394                                                 $uploadFolder = $TCA[$table]['columns'][$fN]['config']['uploadfolder'];
01395                                                 $files1 = array_flip(t3lib_div::trimExplode(',', $diff_1_record[$fN],1));
01396                                                 $files2 = array_flip(t3lib_div::trimExplode(',', $diff_2_record[$fN],1));
01397 
01398                                                         // Traverse filenames and read their md5 sum:
01399                                                 foreach($files1 as $filename => $tmp)   {
01400                                                         $files1[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
01401                                                 }
01402                                                 foreach($files2 as $filename => $tmp)   {
01403                                                         $files2[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
01404                                                 }
01405 
01406                                                         // Implode MD5 sums and set flag:
01407                                                 $diff_1_record[$fN] = implode(' ',$files1);
01408                                                 $diff_2_record[$fN] = implode(' ',$files2);
01409                                                 $isFiles = TRUE;
01410                                         }
01411 
01412                                                 // If there is a change of value:
01413                                         if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])))        {
01414 
01415 
01416                                                         // Get the best visual presentation of the value and present that:
01417                                                 $val1 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_2_record[$fN],0,1);
01418                                                 $val2 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_1_record[$fN],0,1);
01419 
01420                                                         // Make diff result and record string lenghts:
01421                                                 $diffres = $t3lib_diff_Obj->makeDiffDisplay($val1,$val2,$isFiles?'div':'span');
01422                                                 $diffStrLen+= $t3lib_diff_Obj->differenceLgd;
01423                                                 $allStrLen+= strlen($val1.$val2);
01424 
01425                                                         // If the compared values were files, substituted MD5 hashes:
01426                                                 if ($isFiles)   {
01427                                                         $allFiles = array_merge($files1,$files2);
01428                                                         foreach($allFiles as $filename => $token)       {
01429                                                                 if (strlen($token)==32 && strstr($diffres,$token))      {
01430                                                                         $filename =
01431                                                                                 t3lib_BEfunc::thumbCode(array($fN=>$filename),$table,$fN,$this->doc->backPath).
01432                                                                                 $filename;
01433                                                                         $diffres = str_replace($token,$filename,$diffres);
01434                                                                 }
01435                                                         }
01436                                                 }
01437 
01438                                                         // Add table row with result:
01439                                                 $tRows[] = '
01440                                                         <tr class="bgColor4">
01441                                                                 <td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table,$fN))).'</td>
01442                                                                 <td width="98%">'.$diffres.'</td>
01443                                                         </tr>
01444                                                 ';
01445                                         } else {
01446                                                         // Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed:
01447                                                 $allStrLen+=strlen($diff_1_record[$fN].$diff_2_record[$fN]);
01448                                         }
01449                                 }
01450                         }
01451 
01452                                 // Calculate final change percentage:
01453                         $pctChange = $allStrLen ? ceil($diffStrLen*100/$allStrLen) : -1;
01454 
01455                                 // Create visual representation of result:
01456                         if (count($tRows)>1)    {
01457                                 $content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>';
01458                         } else {
01459                                 $content.= '<span class="nobr">'.$this->doc->icons(1).'Complete match on editable fields.</span>';
01460                         }
01461                 } else $content.= $this->doc->icons(3).'ERROR: Records could strangely not be found!';
01462 
01463                         // Return value:
01464                 return array($content,$pctChange);
01465         }
01466 
01474         function displayWorkspaceOverview_stageCmd($table,&$rec_off)    {
01475 #debug($rec_off['t3ver_stage']);
01476                 switch((int)$rec_off['t3ver_stage'])    {
01477                         case 0:
01478                                 $sId = 1;
01479                                 $sLabel = 'Editing';
01480                                 $color = '#666666';
01481                                 $label = 'Comment for Reviewer:';
01482                                 $titleAttrib = 'Send to Review';
01483                         break;
01484                         case 1:
01485                                 $sId = 10;
01486                                 $sLabel = 'Review';
01487                                 $color = '#6666cc';
01488                                 $label = 'Comment for Publisher:';
01489                                 $titleAttrib = 'Approve for Publishing';
01490                         break;
01491                         case 10:
01492                                 $sLabel = 'Publish';
01493                                 $color = '#66cc66';
01494                         break;
01495                         case -1:
01496                                 $sLabel = $this->doc->icons(2).'Rejected';
01497                                 $sId = 0;
01498                                 $color = '#ff0000';
01499                                 $label = 'Comment:';
01500                                 $titleAttrib = 'Reset stage';
01501                         break;
01502                         default:
01503                                 $sLabel = 'Undefined';
01504                                 $sId = 0;
01505                                 $color = '';
01506                         break;
01507                 }
01508 #debug($sId);
01509 
01510                 $raiseOk = !$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off);
01511 
01512                 if ($raiseOk && $rec_off['t3ver_stage']!=-1)    {
01513                         $onClick = 'var commentTxt=window.prompt("Please explain why you reject:","");
01514                                                         if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand(
01515                                                         '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'.
01516                                                         '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]=-1'
01517                                                         ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'.
01518                                                         ' return false;';
01519                                 // Reject:
01520                         $actionLinks.=
01521                                 '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
01522                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/down.gif','width="14" height="14"').' alt="" align="top" title="Reject" />'.
01523                                 '</a>';
01524                 } else {
01525                                 // Reject:
01526                         $actionLinks.=
01527                                 '<img src="'.$this->doc->backPath.'gfx/clear.gif" width="14" height="14" alt="" align="top" title="" />';
01528                 }
01529 
01530                 $actionLinks.= '<span style="background-color: '.$color.'; color: white;">'.$sLabel.'</span>';
01531 
01532                         // Raise
01533                 if ($raiseOk)   {
01534                         $onClick = 'var commentTxt=window.prompt("'.$label.'","");
01535                                                         if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand(
01536                                                         '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'.
01537                                                         '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]='.$sId
01538                                                         ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'.
01539                                                         ' return false;';
01540                         if ($rec_off['t3ver_stage']!=10)        {
01541                                 $actionLinks.=
01542                                         '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
01543                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/up.gif','width="14" height="14"').' alt="" align="top" title="'.htmlspecialchars($titleAttrib).'" />'.
01544                                         '</a>';
01545 
01546                                 $this->stageIndex[$sId][$table][] = $rec_off['uid'];
01547                         }
01548                 }
01549                 return $actionLinks;
01550         }
01551 
01561         function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType)        {
01562                 if ($this->publishAccess && (!($GLOBALS['BE_USER']->workspaceRec['publish_access']&1) || (int)$rec_off['t3ver_stage']===10))    {
01563                         $actionLinks =
01564                                 '<a href="'.htmlspecialchars($this->doc->issueCommand(
01565                                                 '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'.
01566                                                 '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid']
01567                                                 )).'">'.
01568                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert1.gif','width="14" height="14"').' alt="" align="top" title="Publish" />'.
01569                                 '</a>';
01570                         if ($GLOBALS['BE_USER']->workspaceSwapAccess() && (int)$rec_on['t3ver_state']!==1 && (int)$rec_off['t3ver_state']!==2)  {
01571                                 $actionLinks.=
01572                                         '<a href="'.htmlspecialchars($this->doc->issueCommand(
01573                                                         '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'.
01574                                                         '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid'].
01575                                                         '&cmd['.$table.']['.$rec_on['uid'].'][version][swapIntoWS]=1'
01576                                                         )).'">'.
01577                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/swap.png','width="14" height="14"').' alt="" align="top" title="Swap" />'.
01578                                         '</a>';
01579                         }
01580                 }
01581 
01582                 if (!$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off))   {
01583                                 // Release
01584                         $actionLinks.=
01585                                 '<a href="'.htmlspecialchars($this->doc->issueCommand('&cmd['.$table.']['.$rec_off['uid'].'][version][action]=clearWSID')).'" onclick="return confirm(\'Remove from workspace?\');">'.
01586                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/group_clear.gif','width="14" height="14"').' alt="" align="top" title="Remove from workspace" />'.
01587                                 '</a>';
01588 
01589                                 // Edit
01590                         if ($table==='pages' && $vType!=='element')     {
01591                                 $tempUid = ($vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']);
01592                                 $actionLinks.=
01593                                         '<a href="#" onclick="top.loadEditId('.$tempUid.');top.goToModule(\''.$this->pageModule.'\'); return false;">'.
01594                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="Edit page" alt="" />'.
01595                                         '</a>';
01596                         } else {
01597                                 $params = '&edit['.$table.']['.$rec_off['uid'].']=edit';
01598                                 $actionLinks.=
01599                                         '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->doc->backPath)).'">'.
01600                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="12" height="12"').' title="Edit element" alt="" />'.
01601                                         '</a>';
01602                         }
01603                 }
01604 
01605                         // History/Log
01606                 $actionLinks.=
01607                         '<a href="'.htmlspecialchars($this->doc->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
01608                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' title="Show Log" alt="" />'.
01609                         '</a>';
01610 
01611                         // View
01612                 if ($table==='pages')   {
01613                         $tempUid = ($vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']);
01614                         $actionLinks.=
01615                                 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($tempUid,$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($tempUid))).'">'.
01616                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
01617                                 '</a>';
01618                 }
01619 
01620                 return $actionLinks;
01621         }
01622 
01631         function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId)  {
01632                 $uid = $rec['uid'];
01633                 if ($origId || $GLOBALS['BE_USER']->workspace===0)      {
01634                         if (!$GLOBALS['BE_USER']->workspaceCannotEditRecord($table,$rec))       {
01635                                         // Edit
01636                                 if ($table==='pages')   {
01637                                         $actionLinks.=
01638                                                 '<a href="#" onclick="top.loadEditId('.$uid.');top.goToModule(\''.$this->pageModule.'\'); return false;">'.
01639                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="Edit page" alt="" />'.
01640                                                 '</a>';
01641                                 } else {
01642                                         $params = '&edit['.$table.']['.$uid.']=edit';
01643                                         $actionLinks.=
01644                                                 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->doc->backPath)).'">'.
01645                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="12" height="12"').' title="Edit element" alt="" />'.
01646                                                 '</a>';
01647                                 }
01648                         }
01649 
01650                                 // History/Log
01651                         $actionLinks.=
01652                                 '<a href="'.htmlspecialchars($this->doc->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$uid).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
01653                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' title="Show Log" alt="" />'.
01654                                 '</a>';
01655                 }
01656 
01657                         // View
01658                 if ($table==='pages')   {
01659                         $actionLinks.=
01660                                 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($uid,$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($uid))).'">'.
01661                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
01662                                 '</a>';
01663                 }
01664 
01665                 return $actionLinks;
01666         }
01667 
01668 
01669 
01670 
01671 
01672 
01673 
01674 
01675 
01676         /**********************************
01677          *
01678          * Processing
01679          *
01680          **********************************/
01681 
01687         function publishAction()        {
01688 
01689                         // If "Publish" or "Swap" buttons are pressed:
01690                 if (t3lib_div::_POST('_publish') || t3lib_div::_POST('_swap'))  {
01691 
01692                         if ($this->table==='pages')     {       // Making sure ->uid is a page ID!
01693                                         // Initialize workspace object and request all pending versions:
01694                                 $wslibObj = t3lib_div::makeInstance('wslib');
01695                                 $cmd = $wslibObj->getCmdArrayForPublishWS($GLOBALS['BE_USER']->workspace, t3lib_div::_POST('_swap'),$this->uid);
01696 
01697                                         // Execute the commands:
01698                                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
01699                                 $tce->stripslashes_values = 0;
01700                                 $tce->start(array(), $cmd);
01701                                 $tce->process_cmdmap();
01702 
01703                                 return $tce->errorLog;
01704                         }
01705                 }
01706         }
01707 }
01708 
01709 
01710 
01711 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/cm1/index.php'])       {
01712         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/cm1/index.php']);
01713 }
01714 
01715 
01716 
01717 
01718 // Make instance:
01719 $SOBE = t3lib_div::makeInstance('tx_version_cm1');
01720 $SOBE->init();
01721 
01722 
01723 $SOBE->main();
01724 $SOBE->printContent();
01725 
01726 ?>