Documentation TYPO3 par Ameos

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


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6