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


Généré par L'expert TYPO3 avec  doxygen 1.4.6