4a71f81adcfd15d6b303353ea3418b477bf2fcff
2 /***************************************************************
5 * (c) 2004-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
27 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
30 * [CLASS/FUNCTION INDEX of SCRIPT]
34 * 102: class tx_version_cm1 extends t3lib_SCbase
36 * SECTION: Standard module initialization
37 * 138: function menuConfig()
38 * 175: function main()
39 * 236: function jumpToUrl(URL)
40 * 296: function printContent()
42 * SECTION: Versioning management
43 * 322: function versioningMgm()
44 * 485: function pageSubContent($pid,$c=0)
45 * 539: function lookForOwnVersions($table,$uid)
46 * 556: function adminLinks($table,$row)
48 * SECTION: Workspace management
49 * 628: function workspaceMgm()
50 * 688: function displayWorkspaceOverview()
51 * 758: function displayWorkspaceOverview_list($pArray)
52 * 923: function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row)
53 * 936: function displayWorkspaceOverview_allStageCmd()
55 * SECTION: Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
56 * 986: function formatVerId($verId)
57 * 996: function formatWorkspace($wsid)
58 * 1023: function formatCount($count)
59 * 1050: function versionsInOtherWS($table,$uid)
60 * 1080: function showStageChangeLog($table,$id,$stageCommands)
61 * 1129: function subElements($uid,$treeLevel,$origId=0)
62 * 1232: function subElements_getNonPageRecords($tN, $uid, &$recList)
63 * 1262: function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata)
64 * 1331: function markupNewOriginals()
65 * 1353: function createDiffView($table, $diff_1_record, $diff_2_record)
66 * 1470: function displayWorkspaceOverview_stageCmd($table,&$rec_off)
67 * 1557: function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType)
68 * 1627: function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId)
71 * 1683: function publishAction()
74 * (This index is automatically created/updated by the extension "extdeveval")
79 // DEFAULT initialization of a module [BEGIN]
82 require ($BACK_PATH.'init.php');
83 require ($BACK_PATH.'template.php');
84 $LANG->includeLLFile('EXT:version/locallang.xml');
85 require_once (PATH_t3lib
.'class.t3lib_scbase.php');
86 // DEFAULT initialization of a module [END]
88 require_once(PATH_t3lib
.'class.t3lib_diff.php');
89 require_once(PATH_typo3
.'mod/user/ws/class.wslib.php');
90 require_once(PATH_t3lib
.'class.t3lib_pagetree.php');
91 require_once(PATH_t3lib
.'class.t3lib_tcemain.php');
96 * Versioning module, including workspace management
98 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
102 class tx_version_cm1
extends t3lib_SCbase
{
104 // Default variables for backend modules
105 var $MCONF = array(); // Module configuration
106 var $MOD_MENU = array(); // Module menu items
107 var $MOD_SETTINGS = array(); // Module session settings
108 var $doc; // Document Template Object
109 var $content; // Accumulated content
113 var $showWorkspaceCol = 0;
114 var $formatWorkspace_cache = array();
115 var $formatCount_cache = array();
116 var $targets = array(); // Accumulation of online targets.
117 var $pageModule = ''; // Name of page module
118 var $publishAccess = FALSE;
119 var $be_user_Array = array();
120 var $stageIndex = array();
121 var $recIndex = array();
128 /*********************************
130 * Standard module initialization
132 *********************************/
135 * Initialize menu configuration
139 function menuConfig() {
142 $this->MOD_MENU
= array(
149 0 => '[Live workspace]',
150 -98 => 'Draft Workspaces',
152 -1 => '[Default Draft]'
158 if ($GLOBALS['BE_USER']->workspace
===0) { // Spend time on this only in online workspace because it might take time:
159 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc
::deleteClause('sys_workspace'),'','title');
160 foreach($workspaces as $rec) {
161 if ($GLOBALS['BE_USER']->checkWorkspace($rec)) {
162 $this->MOD_MENU
['display'][$rec['uid']] = '['.$rec['uid'].'] '.$rec['title'];
168 $this->MOD_SETTINGS
= t3lib_BEfunc
::getModuleData($this->MOD_MENU
, t3lib_div
::_GP('SET'), $this->MCONF
['name'], 'ses');
172 * Main function of the module. Write the content to $this->content
177 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
179 // Setting module configuration:
180 $this->MCONF
= $GLOBALS['MCONF'];
182 $this->REQUEST_URI
= str_replace('&sendToReview=1','',t3lib_div
::getIndpEnv('REQUEST_URI'));
185 $this->doc
= t3lib_div
::makeInstance('mediumDoc');
186 $this->doc
->backPath
= $BACK_PATH;
187 $this->doc
->form
='<form action="" method="post">';
190 $this->doc
->inDocStylesArray
[$GLOBALS['MCONF']['name']] = '
191 .version-diff-1 { background-color: green; }
192 .version-diff-2 { background-color: red; }
195 // Setting up the context sensitive menu:
196 $CMparts = $this->doc
->getContextMenuCode();
197 $this->doc
->JScode
.= $CMparts[0];
198 $this->doc
->bodyTagAdditions
= $CMparts[1];
199 $this->doc
->postCode
.= $CMparts[2];
201 // Getting input data:
202 $this->id
= intval(t3lib_div
::_GP('id')); // Page id. If set, indicates activation from Web>Versioning module
204 $this->uid
= intval(t3lib_div
::_GP('uid')); // Record uid. Goes with table name to indicate specific record
205 $this->table
= t3lib_div
::_GP('table'); // Record table. Goes with uid to indicate specific record
207 $this->uid
= $this->id
;
208 $this->table
= 'pages';
210 $this->details
= t3lib_div
::_GP('details'); // Page id. If set, indicates activation from Web>Versioning module
211 $this->diffOnly
= t3lib_div
::_GP('diffOnly'); // Flag. If set, shows only the offline version and with diff-view
213 // Force this setting:
214 $this->MOD_SETTINGS
['expandSubElements'] = TRUE;
215 $this->MOD_SETTINGS
['diff'] = $this->details ||
$this->MOD_SETTINGS
['diff']?
1:0;
217 // Reading the record:
218 $record = t3lib_BEfunc
::getRecord($this->table
,$this->uid
);
219 if ($record['pid']==-1) {
220 $record = t3lib_BEfunc
::getRecord($this->table
,$record['t3ver_oid']);
222 $pidValue = $this->table
==='pages' ?
$this->uid
: $record['pid'];
224 // Checking access etc.
225 if (is_array($record) && $TCA[$this->table
]['ctrl']['versioningWS']) {
226 $this->uid
= $record['uid']; // Might have changed if new live record was found!
229 // The page will show only if there is a valid page and if this page may be viewed by the user
230 $this->pageinfo
= t3lib_BEfunc
::readPageAccess($pidValue,$this->perms_clause
);
231 $access = is_array($this->pageinfo
) ?
1 : 0;
233 if (($pidValue && $access) ||
($BE_USER->user
['admin'] && !$pidValue)) {
236 $this->doc
->JScode
.= '
237 <script language="javascript" type="text/javascript">
239 function jumpToUrl(URL) {
240 window.location.href = URL;
243 function hlSubelements(origId, verId, over, diffLayer) { //
245 document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
246 document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
248 document.getElementById(\'diff_\'+verId).style.visibility = \'visible\';
251 document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
252 document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
254 document.getElementById(\'diff_\'+verId).style.visibility = \'hidden\';
261 // If another page module was specified, replace the default Page module with the new one
262 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
263 $this->pageModule
= t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
265 // Setting publish access permission for workspace:
266 $this->publishAccess
= $BE_USER->workspacePublishAccess($BE_USER->workspace
);
269 $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);
271 $this->content
.=$this->doc
->startPage($LANG->getLL('title'));
272 $this->content
.=$this->doc
->header($LANG->getLL('title'));
273 $this->content
.=$this->doc
->spacer(5);
274 $this->content
.=$this->doc
->section('',$headerSection);
275 $this->content
.=$this->doc
->divider(5);
279 $this->workspaceMgm();
281 $this->versioningMgm();
285 if ($BE_USER->mayMakeShortcut()) {
286 $this->content
.=$this->doc
->spacer(20).$this->doc
->section('',$this->doc
->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU
)),$this->MCONF
['name']));
290 $this->content
.=$this->doc
->spacer(10);
292 // If no access or id value, create empty document:
293 $this->content
.=$this->doc
->startPage($LANG->getLL('title'));
294 $this->content
.=$this->doc
->section($LANG->getLL('clickAPage_header'),$LANG->getLL('clickAPage_content'),0,1);
299 * Outputs accumulated module content to browser.
303 function printContent() {
305 $this->content
.=$this->doc
->endPage();
318 /******************************
320 * Versioning management
322 ******************************/
325 * Management of versions for record
329 function versioningMgm() {
333 $diff_1 = t3lib_div
::_POST('diff_1');
334 $diff_2 = t3lib_div
::_POST('diff_2');
335 if (t3lib_div
::_POST('do_diff')) {
337 $content.='<h3>DIFFING:</h3>';
338 if ($diff_1 && $diff_2) {
339 $diff_1_record = t3lib_BEfunc
::getRecord($this->table
, $diff_1);
340 $diff_2_record = t3lib_BEfunc
::getRecord($this->table
, $diff_2);
342 if (is_array($diff_1_record) && is_array($diff_2_record)) {
343 t3lib_div
::loadTCA($this->table
);
344 $t3lib_diff_Obj = t3lib_div
::makeInstance('t3lib_diff');
348 <tr class="bgColor5 tableheader">
350 <td width="98%">Colored diff-view:</td>
353 foreach($diff_1_record as $fN => $fV) {
354 if ($TCA[$this->table
]['columns'][$fN] && $TCA[$this->table
]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div
::inList('t3ver_label',$fN)) {
355 if (strcmp($diff_1_record[$fN],$diff_2_record[$fN])) {
357 $diffres = $t3lib_diff_Obj->makeDiffDisplay(
358 t3lib_BEfunc
::getProcessedValue($this->table
,$fN,$diff_2_record[$fN],0,1),
359 t3lib_BEfunc
::getProcessedValue($this->table
,$fN,$diff_1_record[$fN],0,1)
363 <tr class="bgColor4">
365 <td width="98%">'.$diffres.'</td>
372 if (count($tRows)>1) {
373 $content.='<table border="0" cellpadding="1" cellspacing="1" width="100%">'.implode('',$tRows).'</table><br/><br/>';
375 $content.='Records matches completely on all editable fields!';
377 } else $content.='ERROR: Records could strangely not be found!';
379 $content.='ERROR: You didn\'t select two sources for diffing!';
384 $record = t3lib_BEfunc
::getRecord($this->table
,$this->uid
);
385 $recordIcon = t3lib_iconWorks
::getIconImage($this->table
,$record,$this->doc
->backPath
,'class="absmiddle"');
386 $recTitle = t3lib_BEfunc
::getRecordTitle($this->table
,$record,TRUE);
390 '.$recordIcon.$recTitle.'
391 <form name="theform" action="'.str_replace('&sendToReview=1','',$this->REQUEST_URI
).'" method="post">
392 <table border="0" cellspacing="1" cellpadding="1">';
394 <tr class="bgColor5 tableheader">
399 <td title="t3ver_oid - Reference to live version UID">oid</td>
400 <td title="t3ver_id - Version number, incremental integer">id</td>
401 <td title="t3ver_wsid - Workspace ID. There can be only one version of an element per ID (except ID zero).">wsid</td>
402 <td title="t3ver_state - Special states of a version: 1=Placeholder for "New". 2=Marked deleted.">state</td>
403 <td title="t3ver_stage - Publishing stage: Editing (0), review (1), publish (10), rejected (-1).">stage</td>
404 <td title="t3ver_count - Life cycle counter. Incremented each time element is unpublished.">count</td>
407 <td colspan="2"><input type="submit" name="do_diff" value="Diff" /></td>
410 $versions = t3lib_BEfunc
::selectVersionsOfRecord($this->table
, $this->uid
, '*', $GLOBALS['BE_USER']->workspace
);
411 foreach($versions as $row) {
412 $adminLinks = $this->adminLinks($this->table
,$row);
415 <tr class="'.($row['uid']!=$this->uid ?
'bgColor4' : 'bgColor2 tableheader').'">
416 <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').'">'.
417 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/insert1.gif','width="14" height="14"').' alt="" title="SWAP with current" />'.
419 $this->table == 'pages' ?
420 '<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').'">'.
421 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert2.gif','width="14" height="14"').' alt="" title="Publish page AND content!" />'.
423 '<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').'">'.
424 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert4.gif','width="14" height="14"').' alt="" title="Publish page AND content! - AND ALL SUBPAGES!" />'.
425 '</a>' : '') */ : '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/blinkarrow_left.gif','width="5" height="9"').' alt="" title="CURRENT ONLINE VERSION!"/>').'</td>
426 <td nowrap="nowrap">'.$adminLinks.'</td>
427 <td nowrap="nowrap">'.t3lib_BEfunc
::getRecordTitle($this->table
,$row,TRUE).'</td>
428 <td>'.$row['uid'].'</td>
429 <td>'.$row['t3ver_oid'].'</td>
430 <td>'.$row['t3ver_id'].'</td>
431 <td>'.$row['t3ver_wsid'].'</td>
432 <td>'.$row['t3ver_state'].'</td>
433 <td>'.$row['t3ver_stage'].'</td>
434 <td>'.$row['t3ver_count'].'</td>
435 <td>'.$row['pid'].'</td>
436 <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>
437 <td class="version-diff-1"><input type="radio" name="diff_1" value="'.$row['uid'].'"'.($diff_1==$row['uid'] ?
' checked="checked"':'').'/></td>
438 <td class="version-diff-2"><input type="radio" name="diff_2" value="'.$row['uid'].'"'.($diff_2==$row['uid'] ?
' checked="checked"':'').'/></td>
441 // 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;)
442 if ($this->table
== 'pages' && $row['uid']!=$this->uid
) {
443 $sub = $this->pageSubContent($row['uid']);
450 <td colspan="10">'.$sub.'</td>
451 <td colspan="2"></td>
456 $content.='</table></form>';
458 $this->content
.=$this->doc
->section('',$content,0,1);
464 <form action="'.$this->doc
->backPath
.'tce_db.php" method="post">
465 Label: <input type="text" name="cmd['.$this->table
.']['.$this->uid
.'][version][label]" /><br/>
466 '.($this->table
== 'pages' ?
'<select name="cmd['.$this->table
.']['.$this->uid
.'][version][treeLevels]">
467 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0) ?
'<option value="0">Page: Page + content</option>' : '').'
468 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(1) ?
'<option value="100">Branch: All subpages</option>' : '').'
469 '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(-1) ?
'<option value="-1">Element: Just record</option>' : '').'
471 <br/><input type="hidden" name="cmd['.$this->table
.']['.$this->uid
.'][version][action]" value="new" />
472 <input type="hidden" name="prErr" value="1" />
473 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->REQUEST_URI
).'" />
474 <input type="submit" name="_" value="Create new version" />
480 $this->content
.=$this->doc
->spacer(15);
481 $this->content
.=$this->doc
->section('Create new version',$content,0,1);
486 * Recursively look for children for page version with $pid
488 * @param integer UID of page record for which to look up sub-elements following that version
489 * @param integer Counter, do not set (limits to 100 levels)
490 * @return string Table with content if any
492 function pageSubContent($pid,$c=0) {
495 $tableNames = t3lib_div
::removeArrayEntryByValue(array_keys($TCA),'pages');
496 $tableNames[] = 'pages';
498 foreach($tableNames as $tN) {
499 // Basically list ALL tables - not only those being copied might be found!
500 #if ($TCA[$tN]['ctrl']['versioning_followPages'] || $tN=='pages') {
501 $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $tN, 'pid='.intval($pid).t3lib_BEfunc
::deleteClause($tN), '', ($TCA[$tN]['ctrl']['sortby'] ?
$TCA[$tN]['ctrl']['sortby'] : ''));
503 if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres)) {
506 <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>
508 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
509 $ownVer = $this->lookForOwnVersions($tN,$subrow['uid']);
512 <td>'.$this->adminLinks($tN,$subrow).'</td>
513 <td>'.$subrow['uid'].'</td>
514 '.($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>').'
515 <td width="98%">'.t3lib_BEfunc
::getRecordTitle($tN,$subrow,TRUE).'</td>
518 if ($tN == 'pages' && $c<100) {
519 $sub = $this->pageSubContent($subrow['uid'],$c+
1);
527 <td width="98%">'.$sub.'</td>
536 return $content ?
'<table border="1" cellpadding="1" cellspacing="0" width="100%">'.$content.'</table>' : '';
540 * Look for number of versions of a record
542 * @param string Table name
543 * @param integer Record uid
544 * @return integer Number of versions for record, false if none.
546 function lookForOwnVersions($table,$uid) {
549 $versions = t3lib_BEfunc
::selectVersionsOfRecord($table, $uid, 'uid');
550 if (is_array($versions)) {
551 return count($versions);
557 * Administrative links for a table / record
559 * @param string Table name
560 * @param array Record for which administrative links are generated.
561 * @return string HTML link tags.
563 function adminLinks($table,$row) {
567 $adminLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick('&edit['.$table.']['.$row['uid'].']=edit',$this->doc
->backPath
)).'">'.
568 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" title="Edit"/>'.
572 $adminLink.= '<a href="'.htmlspecialchars($this->doc
->issueCommand('&cmd['.$table.']['.$row['uid'].'][delete]=1')).'">'.
573 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" title="Delete"/>'.
578 if ($table == 'pages') {
580 // If another page module was specified, replace the default Page module with the new one
581 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
582 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
584 // Perform some acccess checks:
585 $a_wl = $BE_USER->check('modules','web_list');
586 $a_wp = t3lib_extMgm
::isLoaded('cms') && $BE_USER->check('modules',$pageModule);
588 $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\''.$pageModule.'\'); return false;">'.
589 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,t3lib_extMgm
::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="" alt="" />'.
591 $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\'web_list\'); return false;">'.
592 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'mod/web/list/list.gif','width="14" height="12"').' title="" alt="" />'.
595 // "View page" icon is added:
596 $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($row['uid'],$this->doc
->backPath
,t3lib_BEfunc
::BEgetRootLine($row['uid']))).'">'.
597 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
600 if ($row['pid']==-1) {
601 $getVars = '&ADMCMD_vPrev['.rawurlencode($table.':'.$row['t3ver_oid']).']='.$row['uid'];
603 // "View page" icon is added:
604 $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($row['_REAL_PID'],$this->doc
->backPath
,t3lib_BEfunc
::BEgetRootLine($row['_REAL_PID']),'','',$getVars)).'">'.
605 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
623 /******************************
625 * Workspace management
627 ******************************/
630 * Management of workspace for page ID
631 * Called when $this->id is set.
635 function workspaceMgm() {
638 if ($GLOBALS['BE_USER']->workspace
===0) {
639 $menu.= t3lib_BEfunc
::getFuncMenu($this->id
,'SET[filter]',$this->MOD_SETTINGS
['filter'],$this->MOD_MENU
['filter']);
640 $menu.= t3lib_BEfunc
::getFuncMenu($this->id
,'SET[display]',$this->MOD_SETTINGS
['display'],$this->MOD_MENU
['display']);
642 if (!$this->details
&& $GLOBALS['BE_USER']->workspace
&& !$this->diffOnly
) {
643 $menu.= t3lib_BEfunc
::getFuncCheck($this->id
,'SET[diff]',$this->MOD_SETTINGS
['diff'],'','','id="checkDiff"').' <label for="checkDiff">Show difference view</label>';
647 $this->content
.=$this->doc
->section('',$menu,0,1);
650 // Perform workspace publishing action if buttons are pressed:
651 $errors = $this->publishAction();
653 // Generate workspace overview:
654 $WSoverview = $this->displayWorkspaceOverview();
656 // Buttons for publish / swap:
657 $actionLinks = '<br/>';
658 if ($GLOBALS['BE_USER']->workspace
!==0) {
659 if ($this->publishAccess
) {
660 $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 "Publish" stage ':'').'from this page?\');"/>';
661 if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
662 $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 "Publish" stage ':'').'from this page?\');" />';
665 $actionLinks.= $this->doc
->icons(1).'You are not permitted to publish from this workspace';
668 $actionLinks.= '<input type="submit" name="_" value="Refresh" />';
669 $actionLinks.= '<input type="submit" name="_previewLink" value="Preview Link" />';
670 $actionLinks.= $this->displayWorkspaceOverview_allStageCmd();
672 if ($actionLinks ||
count($errors)) {
673 $this->content
.= $this->doc
->section('',$actionLinks.(count($errors) ?
'<h3>Errors:</h3><br/>'.implode('<br/>',$errors).'<hr/>' : ''),0,1);
676 if (t3lib_div
::_POST('_previewLink')) {
677 $params = 'id='.$this->id
.'&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS='.$GLOBALS['BE_USER']->workspace
;
678 $previewUrl = t3lib_div
::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.t3lib_BEfunc
::compilePreviewKeyword($params, $GLOBALS['BE_USER']->user
['uid']);
680 $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);
683 // Output overview content:
684 $this->content
.= $this->doc
->spacer(15);
685 $this->content
.= $this->doc
->section($this->details ?
'Details for version' : 'Workspace management', $WSoverview,0,1);
690 * Rendering the overview of versions in the current workspace
692 * @return string HTML (table)
693 * @see typo3/mod/user/ws/index.php for sister function!
695 function displayWorkspaceOverview() {
697 // Initialize variables:
698 $this->showWorkspaceCol
= $GLOBALS['BE_USER']->workspace
===0 && $this->MOD_SETTINGS
['display']<=-98;
700 // Get usernames and groupnames
701 $be_group_Array = t3lib_BEfunc
::getListGroupNames('title,uid');
702 $groupArray = array_keys($be_group_Array);
703 $this->be_user_Array
= t3lib_BEfunc
::getUserNames();
704 if (!$GLOBALS['BE_USER']->isAdmin()) $this->be_user_Array
= t3lib_BEfunc
::blindUserNames($this->be_user_Array
,$groupArray,1);
706 // Initialize Workspace ID and filter-value:
707 if ($GLOBALS['BE_USER']->workspace
===0) {
708 $wsid = $this->details ?
-99 : $this->MOD_SETTINGS
['display']; // Set wsid to the value from the menu (displaying content of other workspaces)
709 $filter = $this->details ?
0 : $this->MOD_SETTINGS
['filter'];
711 $wsid = $GLOBALS['BE_USER']->workspace
;
715 // Initialize workspace object and request all pending versions:
716 $wslibObj = t3lib_div
::makeInstance('wslib');
718 // Selecting ALL versions belonging to the workspace:
719 $versions = $wslibObj->selectVersionsInWorkspace($wsid, $filter, -99, $this->uid
); // $this->uid is the page id of LIVE record.
721 // Traverse versions and build page-display array:
723 foreach($versions as $table => $records) {
724 foreach($records as $rec) {
725 $pageIdField = $table==='pages' ?
't3ver_oid' : 'realpid';
726 $this->displayWorkspaceOverview_setInPageArray(
734 // Make header of overview:
735 $tableRows = array();
736 if (count($pArray)) {
738 <tr class="bgColor5 tableheader">
739 '.($this->diffOnly?
'':'<td nowrap="nowrap" colspan="2">Live Version:</td>').'
740 <td nowrap="nowrap" colspan="2">Draft Versions:</td>
741 <td nowrap="nowrap"'.($this->diffOnly?
' colspan="2"':' colspan="4"').'>Controls:</td>
744 // Add lines from overview:
745 $tableRows = array_merge($tableRows, $this->displayWorkspaceOverview_list($pArray));
747 $table = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding workspace-overview">'.implode('',$tableRows).'</table>';
750 $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/>' : '';
751 $resetDiffOnly = $this->diffOnly ?
'<a href="index.php?id='.intval($this->id
).'" class="typo3-goBack">Show all information</a><br/><br/>' : '';
753 $versionSelector = $GLOBALS['BE_USER']->workspace ?
$this->doc
->getVersionSelector($this->id
) : '';
755 return $versionSelector.$linkBack.$resetDiffOnly.$table.$this->markupNewOriginals();
759 * Rendering the content for the publish / review overview:
760 * (Made for internal recursive calling)
762 * @param array Storage of the elements to display (see displayWorkspaceOverview() / displayWorkspaceOverview_setInPageArray())
763 * @return array Table rows, see displayWorkspaceOverview()
765 function displayWorkspaceOverview_list($pArray) {
768 // If there ARE elements on this level, print them:
769 $warnAboutVersions_nonPages = FALSE;
770 $warnAboutVersions_page = FALSE;
771 if (is_array($pArray)) {
772 foreach($pArray as $table => $oidArray) {
773 foreach($oidArray as $oid => $recs) {
775 // Get CURRENT online record and icon based on "t3ver_oid":
776 $rec_on = t3lib_BEfunc
::getRecord($table,$oid);
777 $icon = t3lib_iconWorks
::getIconImage($table, $rec_on, $this->doc
->backPath
,' align="top" title="'.t3lib_BEfunc
::getRecordIconAltText($rec_on,$table).'"');
778 if ($GLOBALS['BE_USER']->workspace
===0) { // Only edit online records if in ONLINE workspace:
779 $icon = $this->doc
->wrapClickMenuOnIcon($icon, $table, $rec_on['uid'], 1, '', '+edit,view,info,delete');
782 // Online version display:
783 // Create the main cells which will span over the number of versions there is.
784 $verLinkUrl = $TCA[$table]['ctrl']['versioningWS'];
785 $origElement = $icon.
786 ($verLinkUrl ?
'<a href="'.htmlspecialchars('index.php?table='.$table.'&uid='.$rec_on['uid']).'">' : '').
787 t3lib_BEfunc
::getRecordTitle($table,$rec_on,TRUE).
788 ($verLinkUrl ?
'</a>' : '');
789 $mainCell_rowSpan = count($recs)>1 ?
' rowspan="'.count($recs).'"' : '';
791 <td align="center"'.$mainCell_rowSpan.'>'.$this->formatVerId($rec_on['t3ver_id']).'</td>
792 <td nowrap="nowrap"'.$mainCell_rowSpan.'>'.
794 '###SUB_ELEMENTS###'. // For substitution with sub-elements, if any.
797 // Offline versions display:
798 // Traverse the versions of the element
799 foreach($recs as $rec) {
801 // Get the offline version record and icon:
802 $rec_off = t3lib_BEfunc
::getRecord($table,$rec['uid']);
804 // Prepare swap-mode values:
805 if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
806 if ($rec_off['t3ver_swapmode']>0) {
816 $icon = t3lib_iconWorks
::getIconImage($table, $rec_off, $this->doc
->backPath
, ' align="top" title="'.t3lib_BEfunc
::getRecordIconAltText($rec_off,$table).'"');
817 $tempUid = ($table != 'pages' ||
$vType==='branch' ||
$GLOBALS['BE_USER']->workspace
===0 ?
$rec_off['uid'] : $rec_on['uid']);
818 $icon = $this->doc
->wrapClickMenuOnIcon($icon, $table, $tempUid, 1, '', '+edit,' . ($table == 'pages' ?
'view,info,' : '') . 'delete');
820 // Prepare diff-code:
821 if ($this->MOD_SETTINGS
['diff'] ||
$this->diffOnly
) {
823 list($diffHTML,$diffPct) = $this->createDiffView($table, $rec_off, $rec_on);
824 if ($rec_on['t3ver_state']==1) { // New record:
825 $diffCode.= $this->doc
->icons(1).'New element<br/>'; // TODO Localize?
826 $diffCode.= $diffHTML;
827 } elseif ($rec_off['t3ver_state']==2) {
828 $diffCode.= $this->doc
->icons(2).'Deleted element<br/>';
830 $diffCode.= ($diffPct<0 ?
'N/A' : ($diffPct ?
$diffPct.'% change:' : ''));
831 $diffCode.= $diffHTML;
833 } else $diffCode = '';
837 $swapLabel = ' [Element]';
838 $swapClass = 'ver-element';
839 $warnAboutVersions_nonPages = $warnAboutVersions_page; // Setting this if sub elements are found with a page+content (must be rendered prior to this of course!)
842 $swapLabel = ' [Page]';
843 $swapClass = 'ver-page';
844 $warnAboutVersions_page = !$this->showWorkspaceCol
; // This value is true only if multiple workspaces are shown and we need the opposite here.
847 $swapLabel = ' [Branch]';
848 $swapClass = 'ver-branch';
852 // Modify main cell based on first version shown:
853 $subElements = array();
854 if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1 && $mainCell) { // For "Page" and "Branch" swap modes where $mainCell is still carrying content (only first version)
855 $subElements['on'] = $this->subElements($rec_on['uid'], $rec_off['t3ver_swapmode']);
856 $subElements['off'] = $this->subElements($rec_off['uid'],$rec_off['t3ver_swapmode'],$rec_on['uid']);
858 $mainCell = str_replace('###SUB_ELEMENTS###', $subElements['on'], $mainCell);
860 // Create version element:
861 $versionsInOtherWS = $this->versionsInOtherWS($table, $rec_on['uid']);
862 $versionsInOtherWSWarning = $versionsInOtherWS && $GLOBALS['BE_USER']->workspace
!==0 ?
'<br/>'.$this->doc
->icons(2).'Other version(s) in workspace '.$versionsInOtherWS : '';
863 $multipleWarning = (!$mainCell && $GLOBALS['BE_USER']->workspace
!==0?
'<br/>'.$this->doc
->icons(3).'<b>Multiple versions in same workspace!</b>' : '');
864 $verWarning = $warnAboutVersions ||
($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])?
'<br/>'.$this->doc
->icons(3).'<b>Version inside version!</b>' : '';
866 (!$this->details ?
'<a href="'.htmlspecialchars($this->doc
->backPath
.t3lib_extMgm
::extRelPath('version').'cm1/index.php?id='.($table==='pages'?
$rec_on['uid']:$rec_on['pid']).'&details='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode($this->REQUEST_URI
)).'">' : '').
867 t3lib_BEfunc
::getRecordTitle($table,$rec_off,TRUE).
868 (!$this->details ?
'</a>' : '').
869 $versionsInOtherWSWarning.
874 <td nowrap="nowrap">'.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).'</td>
875 <td nowrap="nowrap" class="'.$swapClass.'">'.
876 $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType).
877 htmlspecialchars($swapLabel).
879 '.(!$this->diffOnly?
'<td nowrap="nowrap"><b>Lifecycle:</b> '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).'</td>'. // Lifecycle
880 ($this->showWorkspaceCol ?
'
881 <td nowrap="nowrap"> <b>Workspace:</b> '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'</td>' : ''):'');
884 $verElement = $verElement.'
885 <br/><b>Difference to live element:</b>
886 <table border="0" cellpadding="0" cellspacing="0" class="ver-verElement">
888 <td class="c-diffCell">'.$diffCode.'</td>
894 // Create version cell:
896 <td align="center">'.$this->formatVerId($rec_off['t3ver_id']).'</td>
897 <td nowrap="nowrap">'.
903 // Compile table row:
905 <tr class="bgColor4">
907 ($this->diffOnly?
'':$mainCell).
913 // Reset the main cell:
925 * Building up of the $pArray
928 * @param array Array that is built up with the page tree structure
929 * @param string Table name
930 * @param array Table row
931 * @return void $pArray is passed by reference and modified internally
933 function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row) {
934 if (!$this->details ||
$this->details
==$table.':'.$row['uid']) {
935 $pArray[$table][$row['t3ver_oid']][] = $row;
940 * Links to stage change of a version
942 * @param string Table name
943 * @param array Offline record (version)
944 * @return string HTML content, mainly link tags and images.
946 function displayWorkspaceOverview_allStageCmd() {
948 $table = t3lib_div
::_GP('table');
949 if ($table && $table!='pages') {
950 $uid = t3lib_div
::_GP('uid');
951 if ($rec_off = t3lib_BEfunc
::getRecordWSOL($table,$uid)) {
952 $uid = $rec_off['_ORIG_uid'];
957 if ($uid && $this->recIndex
[$table][$uid]) {
958 $sId = $this->recIndex
[$table][$uid];
961 $label = 'Comment for Reviewer:';
964 $label = 'Comment for Publisher:';
969 if (count($this->stageIndex
[1])) { // Review:
972 $label = 'Sending %s item(s) to review. Comment for Reviewer:';
973 $titleAttrib = 'Send all to Review';
974 } elseif(count($this->stageIndex
[10])) { // Publish:
977 $label = 'Approving %s item(s) to publishing. Comment for Publisher:';
978 $titleAttrib = 'Approve all for Publishing';
988 if ($table && $uid && $this->recIndex
[$table][$uid]) {
989 $issueCmd.='&cmd['.$table.']['.$uid.'][version][action]=setStage';
990 $issueCmd.='&cmd['.$table.']['.$uid.'][version][stageId]='.$this->recIndex
[$table][$uid];
992 foreach($this->stageIndex
[$sId] as $table => $uidArray) {
993 $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][action]=setStage';
994 $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][stageId]='.$sId;
995 $itemCount+
=count($uidArray);
999 $onClick = 'var commentTxt=window.prompt("'.sprintf($label,$itemCount).'","");
1000 if (commentTxt!=null) {window.location.href="'.$this->doc
->issueCommand($issueCmd,$this->REQUEST_URI
).'&generalComment="+escape(commentTxt);}';
1002 if (t3lib_div
::_GP('sendToReview')) {
1003 $onClick.= ' else {window.location.href = "'.$this->REQUEST_URI
.'"}';
1005 $this->doc
->wrapScriptTags($onClick);
1007 $onClick.= ' return false;';
1009 '<input type="submit" name="_" value="'.htmlspecialchars($titleAttrib).'" onclick="'.htmlspecialchars($onClick).'" />';
1011 } elseif (t3lib_div
::_GP('sendToReview')) {
1012 $onClick = 'window.location.href = "'.$this->REQUEST_URI
.'";';
1014 $this->doc
->wrapScriptTags($onClick);
1015 } else $actionLinks = '';
1017 return $actionLinks;
1025 /**************************************
1027 * Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
1029 *************************************/
1032 * Formatting the version number for HTML output
1034 * @param integer Version number
1035 * @return string Version number for output
1037 function formatVerId($verId) {
1042 * Formatting workspace ID into a visual label
1044 * @param integer Workspace ID
1045 * @return string Workspace title
1047 function formatWorkspace($wsid) {
1049 // Render, if not cached:
1050 if (!isset($this->formatWorkspace_cache
[$wsid])) {
1053 $this->formatWorkspace_cache
[$wsid] = '[Offline]';
1056 $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...
1059 list($titleRec) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title','sys_workspace','uid='.intval($wsid).t3lib_BEfunc
::deleteClause('sys_workspace'));
1060 $this->formatWorkspace_cache
[$wsid] = '['.$wsid.'] '.$titleRec['title'];
1065 return $this->formatWorkspace_cache
[$wsid];
1069 * Format publishing count for version (lifecycle state)
1071 * @param integer t3ver_count value (number of times it has been online)
1072 * @return string String translation of count.
1074 function formatCount($count) {
1076 // Render, if not cached:
1077 if (!isset($this->formatCount_cache
[$count])) {
1080 $this->formatCount_cache
[$count] = 'Draft';
1083 $this->formatCount_cache
[$count] = 'Archive';
1086 $this->formatCount_cache
[$count] = 'Published '.$count.' times';
1091 return $this->formatCount_cache
[$count];
1095 * Looking for versions of a record in other workspaces than the current
1097 * @param string Table name
1098 * @param integer Record uid
1099 * @return string List of other workspace IDs
1101 function versionsInOtherWS($table,$uid) {
1103 // Check for duplicates:
1104 // Select all versions of record NOT in this workspace:
1105 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1109 AND t3ver_oid='.intval($uid).'
1110 AND t3ver_wsid!='.intval($GLOBALS['BE_USER']->workspace
).'
1111 AND (t3ver_wsid=-1 OR t3ver_wsid>0)'.
1112 t3lib_BEfunc
::deleteClause($table),
1119 return implode(',',array_keys($rows));
1124 * Looks up stage changes for version and displays a formatted view on mouseover.
1126 * @param string Table name
1127 * @param integer Record ID
1128 * @param string HTML string to wrap the mouseover around (should be stage change links)
1129 * @return string HTML code.
1131 function showStageChangeLog($table,$id,$stageCommands) {
1132 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1133 'log_data,tstamp,userid',
1135 'action=6 and details_nr=30
1136 AND tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_log').'
1137 AND recuid='.intval($id)
1141 foreach($rows as $dat) {
1142 $data = unserialize($dat['log_data']);
1143 $username = $this->be_user_Array
[$dat['userid']] ?
$this->be_user_Array
[$dat['userid']]['username'] : '['.$dat['userid'].']';
1145 switch($data['stage']) {
1147 $text = 'sent element to "Review"';
1150 $text = 'approved for "Publish"';
1153 $text = 'rejected element!';
1156 $text = 'reset to "Editing"';
1159 $text = '[undefined]';
1162 $text = t3lib_BEfunc
::dateTime($dat['tstamp']).': "'.$username.'" '.$text;
1163 $text.= ($data['comment']?
'<br/>User Comment: <em>'.$data['comment'].'</em>':'');
1168 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>'.
1169 '<div class="logLayer" style="visibility: hidden; position: absolute;" id="log_'.$table.$id.'">'.implode('<hr/>',array_reverse($entry)).'</div>' : $stageCommands;
1173 * Creates display of sub elements of a page when the swap mode is either "Page" or "Branch" (0 / ALL)
1175 * @param integer Page uid (for either online or offline version, but it MUST have swapmode/treeLevel set to >0 (not -1 indicating element versioning)
1176 * @param integer The treeLevel value, >0 indicates "branch" while 0 means page+content. (-1 would have meant element versioning, but that should never happen for a call to this function!)
1177 * @param integer For offline versions; This is t3ver_oid, the original ID of the online page.
1178 * @return string HTML content.
1180 function subElements($uid,$treeLevel,$origId=0) {
1183 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:
1185 <img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/joinbottom.gif','width="18" height="16"').' align="top" alt="" title="" />'.
1187 '<a href="'.htmlspecialchars($this->doc
->backPath
.t3lib_extMgm
::extRelPath('version').'cm1/index.php?id='.$uid.'&details='.rawurlencode('pages:'.$uid).'&returnUrl='.rawurlencode($this->REQUEST_URI
)).'">'.
1188 '<span class="typo3-dimmed"><em>[Sub elements, click for details]</em><span></a>' :
1189 '<span class="typo3-dimmed"><em>[Sub elements]</em><span>');
1190 } else { // For an offline workspace, show sub elements:
1194 // Find records that follow pages when swapping versions:
1196 foreach($TCA as $tN => $tCfg) {
1197 if ($tN!='pages' && ($treeLevel>0 ||
$TCA[$tN]['ctrl']['versioning_followPages'])) {
1198 $this->subElements_getNonPageRecords($tN, $uid, $recList);
1202 // Render records collected above:
1203 $elCount = count($recList)-1;
1204 foreach($recList as $c => $comb) {
1205 list($tN,$rec) = $comb;
1207 $this->subElements_renderItem(
1213 $c==$elCount && $treeLevel==0 ?
1 : 0, // If true, will show bottom-join icon.
1218 // For branch, dive into the subtree:
1222 $tree = t3lib_div
::makeInstance('t3lib_pageTree');
1223 $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
1224 $tree->makeHTML
= 2; // 2=Also rendering depth-data into the result array
1225 $tree->getTree($uid, 99, '');
1227 // Traverse page tree:
1228 foreach($tree->tree
as $data) {
1230 // Render page in table cell:
1231 $this->subElements_renderItem(
1235 t3lib_BEfunc
::getRecord('pages',$data['row']['uid']), // Needs all fields, at least more than what is given in $data['row']...
1237 2, // 2=the join icon and icon for the record is not rendered for pages (where all is in $data['HTML']
1241 // Find all records from page and collect in $recList:
1243 foreach($TCA as $tN => $tCfg) {
1244 if ($tN!=='pages') {
1245 $this->subElements_getNonPageRecords($tN, $data['row']['uid'], $recList);
1249 // Render records collected above:
1250 $elCount = count($recList)-1;
1251 foreach($recList as $c => $comb) {
1252 list($tN,$rec) = $comb;
1254 $this->subElements_renderItem(
1260 $c==$elCount?
1:0, // If true, will show bottom-join icon.
1261 $data['HTML_depthData']
1268 <!-- Sub-element tree for versions -->
1269 <table border="0" cellpadding="0" cellspacing="1" class="ver-subtree">
1270 '.implode('',$tCell).'
1276 * Select records from a table and add them to recList
1278 * @param string Table name (from TCA)
1279 * @param integer PID to select records from
1280 * @param array Array where records are accumulated, passed by reference
1283 function subElements_getNonPageRecords($tN, $uid, &$recList) {
1286 $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1289 'pid='.intval($uid).
1290 ($TCA[$tN]['ctrl']['versioningWS'] ?
' AND t3ver_state=0' : '').
1291 t3lib_BEfunc
::deleteClause($tN),
1293 $TCA[$tN]['ctrl']['sortby'] ?
$TCA[$tN]['ctrl']['sortby'] : $GLOBALS['TYPO3_DB']->stripOrderBy($TCA[$tN]['ctrl']['default_sortby'])
1296 foreach($records as $rec) {
1297 $recList[] = array($tN,$rec);
1302 * Render a single item in a subelement list into a table row:
1304 * @param array Table rows, passed by reference
1305 * @param string Table name
1306 * @param integer Page uid for which the subelements are selected/shown
1307 * @param array Row of element in list
1308 * @param integer The uid of the online version of $uid. If zero it means we are drawing a row for the online version itself while a value means we are drawing display for an offline version.
1309 * @param integer Mode of icon display: 0=not the last, 1= is the last in list (make joinbottom icon then), 2=do not shown icons are all (for pages from the page tree already rendered)
1310 * @param string Prefix HTML data (icons for tree rendering)
1311 * @return void (Content accumulated in $tCell!)
1313 function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata) {
1317 $origUidFields = $TCA[$tN]['ctrl']['origUid'];
1320 if ($origUidFields) { // If there is a field for this table with original uids we will use that to connect records:
1321 if (!$origId) { // In case we are displaying the online originals:
1322 $this->targets
['orig_'.$uid.'_'.$tN.'_'.$rec['uid']] = $rec; // Build up target array (important that
1323 $tdParams = ' id="orig_'.$uid.'_'.$tN.'_'.$rec['uid'].'" class="typo3-ver"'; // Setting ID of the table row
1324 } else { // Version branch:
1325 if ($this->targets
['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]) { // If there IS a corresponding original record...:
1327 // Prepare Table row parameters:
1328 $tdParams = ' onmouseover="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 1, '.($this->MOD_SETTINGS
['diff']==2?
1:0).');"'.
1329 ' onmouseout="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 0, '.($this->MOD_SETTINGS
['diff']==2?
1:0).');"'.
1330 ' id="ver_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="typo3-ver"';
1332 // Create diff view:
1333 if ($this->MOD_SETTINGS
['diff']) {
1334 list($diffHTML,$diffPct) = $this->createDiffView($tN, $rec, $this->targets
['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
1336 if ($this->MOD_SETTINGS
['diff']==2) {
1338 ($diffPct ?
'<span class="nobr">'.$diffPct.'% change</span>' : '-').
1339 '<div style="visibility: hidden; position: absolute;" id="diff_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="diffLayer">'.
1344 ($diffPct<0 ?
'N/A' : ($diffPct ?
$diffPct.'% change:' : '')).
1349 // Unsetting the target fields allows us to mark all originals without a version in the subtree (see ->markupNewOriginals())
1350 unset($this->targets
['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
1351 } else { // No original record, so must be new:
1352 $tdParams = ' class="typo3-ver-new"';
1355 } else { // If no original uid column is supported for this table we are forced NOT to display any diff or highlighting.
1356 $tdParams = ' class="typo3-ver-noComp"';
1359 // Compile the cell:
1362 <td class="iconTitle">'.
1365 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/join'.($iconMode ?
'bottom' : '').'.gif','width="18" height="16"').' alt="" />'.
1366 t3lib_iconWorks
::getIconImage($tN, $rec, $this->doc
->backPath
,'') : '').
1367 t3lib_BEfunc
::getRecordTitle($tN, $rec, TRUE).
1369 <td class="cmdCell">'.
1370 $this->displayWorkspaceOverview_commandLinksSub($tN,$rec,$origId).
1371 '</td>'.($origId ?
'<td class="diffCell">'.
1378 * JavaScript code to mark up new records that are online (in sub element lists)
1380 * @return string HTML javascript section
1382 function markupNewOriginals() {
1384 if (count($this->targets
)) {
1386 foreach($this->targets
as $key => $rec) {
1388 document.getElementById(\''.$key.'\').attributes.getNamedItem("class").nodeValue = \'typo3-ver-new\';
1392 return $this->doc
->wrapScriptTags($scriptCode);
1397 * Create visual difference view of two records. Using t3lib_diff library
1399 * @param string Table name
1400 * @param array New version record (green)
1401 * @param array Old version record (red)
1402 * @return array Array with two keys (0/1) with HTML content / percentage integer (if -1, then it means N/A) indicating amount of change
1404 function createDiffView($table, $diff_1_record, $diff_2_record) {
1410 // Check that records are arrays:
1411 if (is_array($diff_1_record) && is_array($diff_2_record)) {
1413 // Load full table description and initialize diff-object:
1414 t3lib_div
::loadTCA($table);
1415 $t3lib_diff_Obj = t3lib_div
::makeInstance('t3lib_diff');
1420 <tr class="bgColor5 tableheader">
1422 <td width="98%" nowrap="nowrap">Colored diff-view:</td>
1426 // Initialize variables to pick up string lengths in:
1430 // Traversing the first record and process all fields which are editable:
1431 foreach($diff_1_record as $fN => $fV) {
1432 if ($TCA[$table]['columns'][$fN] && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div
::inList('t3ver_label',$fN)) {
1434 // Check if it is files:
1436 if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])) &&
1437 $TCA[$table]['columns'][$fN]['config']['type']=='group' &&
1438 $TCA[$table]['columns'][$fN]['config']['internal_type']=='file') {
1441 $uploadFolder = $TCA[$table]['columns'][$fN]['config']['uploadfolder'];
1442 $files1 = array_flip(t3lib_div
::trimExplode(',', $diff_1_record[$fN],1));
1443 $files2 = array_flip(t3lib_div
::trimExplode(',', $diff_2_record[$fN],1));
1445 // Traverse filenames and read their md5 sum:
1446 foreach($files1 as $filename => $tmp) {
1447 $files1[$filename] = @is_file
(PATH_site
.$uploadFolder.'/'.$filename) ?
md5(t3lib_div
::getUrl(PATH_site
.$uploadFolder.'/'.$filename)) : $filename;
1449 foreach($files2 as $filename => $tmp) {
1450 $files2[$filename] = @is_file
(PATH_site
.$uploadFolder.'/'.$filename) ?
md5(t3lib_div
::getUrl(PATH_site
.$uploadFolder.'/'.$filename)) : $filename;
1453 // Implode MD5 sums and set flag:
1454 $diff_1_record[$fN] = implode(' ',$files1);
1455 $diff_2_record[$fN] = implode(' ',$files2);
1459 // If there is a change of value:
1460 if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN]))) {
1463 // Get the best visual presentation of the value and present that:
1464 $val1 = t3lib_BEfunc
::getProcessedValue($table,$fN,$diff_2_record[$fN],0,1);
1465 $val2 = t3lib_BEfunc
::getProcessedValue($table,$fN,$diff_1_record[$fN],0,1);
1467 // Make diff result and record string lenghts:
1468 $diffres = $t3lib_diff_Obj->makeDiffDisplay($val1,$val2,$isFiles?
'div':'span');
1469 $diffStrLen+
= $t3lib_diff_Obj->differenceLgd
;
1470 $allStrLen+
= strlen($val1.$val2);
1472 // If the compared values were files, substituted MD5 hashes:
1474 $allFiles = array_merge($files1,$files2);
1475 foreach($allFiles as $filename => $token) {
1476 if (strlen($token)==32 && strstr($diffres,$token)) {
1478 t3lib_BEfunc
::thumbCode(array($fN=>$filename),$table,$fN,$this->doc
->backPath
).
1480 $diffres = str_replace($token,$filename,$diffres);
1485 // Add table row with result:
1487 <tr class="bgColor4">
1488 <td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel($table,$fN))).'</td>
1489 <td width="98%">'.$diffres.'</td>
1493 // Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed:
1494 $allStrLen+
=strlen($diff_1_record[$fN].$diff_2_record[$fN]);
1499 // Calculate final change percentage:
1500 $pctChange = $allStrLen ?
ceil($diffStrLen*100/$allStrLen) : -1;
1502 // Create visual representation of result:
1503 if (count($tRows)>1) {
1504 $content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>';
1506 $content.= '<span class="nobr">'.$this->doc
->icons(1).'Complete match on editable fields.</span>';
1508 } else $content.= $this->doc
->icons(3).'ERROR: Records could strangely not be found!';
1511 return array($content,$pctChange);
1515 * Links to stage change of a version
1517 * @param string Table name
1518 * @param array Offline record (version)
1519 * @return string HTML content, mainly link tags and images.
1521 function displayWorkspaceOverview_stageCmd($table,&$rec_off) {
1522 #debug($rec_off['t3ver_stage']);
1523 switch((int)$rec_off['t3ver_stage']) {
1526 $sLabel = 'Editing';
1528 $label = 'Comment for Reviewer:';
1529 $titleAttrib = 'Send to Review';
1535 $label = 'Comment for Publisher:';
1536 $titleAttrib = 'Approve for Publishing';
1539 $sLabel = 'Publish';
1543 $sLabel = $this->doc
->icons(2).'Rejected';
1546 $label = 'Comment:';
1547 $titleAttrib = 'Reset stage';
1550 $sLabel = 'Undefined';
1557 $raiseOk = !$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off);
1559 if ($raiseOk && $rec_off['t3ver_stage']!=-1) {
1560 $onClick = 'var commentTxt=window.prompt("Please explain why you reject:","");
1561 if (commentTxt!=null) {window.location.href="'.$this->doc
->issueCommand(
1562 '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'.
1563 '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]=-1'
1564 ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'.
1568 '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1569 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/down.gif','width="14" height="14"').' alt="" align="top" title="Reject" />'.
1574 '<img src="'.$this->doc
->backPath
.'gfx/clear.gif" width="14" height="14" alt="" align="top" title="" />';
1577 $actionLinks.= '<span style="background-color: '.$color.'; color: white;">'.$sLabel.'</span>';
1581 $onClick = 'var commentTxt=window.prompt("'.$label.'","");
1582 if (commentTxt!=null) {window.location.href="'.$this->doc
->issueCommand(
1583 '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'.
1584 '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]='.$sId
1585 ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'.
1587 if ($rec_off['t3ver_stage']!=10) {
1589 '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1590 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/up.gif','width="14" height="14"').' alt="" align="top" title="'.htmlspecialchars($titleAttrib).'" />'.
1593 $this->stageIndex
[$sId][$table][] = $rec_off['uid'];
1594 $this->recIndex
[$table][$rec_off['uid']] = $sId;
1597 return $actionLinks;
1601 * Links to publishing etc of a version
1603 * @param string Table name
1604 * @param array Online record
1605 * @param array Offline record (version)
1606 * @param string Swap type, "branch", "page" or "element"
1607 * @return string HTML content, mainly link tags and images.
1609 function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType) {
1610 if ($this->publishAccess
&& (!($GLOBALS['BE_USER']->workspaceRec
['publish_access']&1) ||
(int)$rec_off['t3ver_stage']===10)) {
1612 '<a href="'.htmlspecialchars($this->doc
->issueCommand(
1613 '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'.
1614 '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid']
1616 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/insert1.gif','width="14" height="14"').' alt="" align="top" title="Publish" />'.
1618 if ($GLOBALS['BE_USER']->workspaceSwapAccess() && (int)$rec_on['t3ver_state']!==1 && (int)$rec_off['t3ver_state']!==2) {
1620 '<a href="'.htmlspecialchars($this->doc
->issueCommand(
1621 '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'.
1622 '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid'].
1623 '&cmd['.$table.']['.$rec_on['uid'].'][version][swapIntoWS]=1'
1625 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/swap.png','width="14" height="14"').' alt="" align="top" title="Swap" />'.
1630 if (!$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off)) {
1633 '<a href="'.htmlspecialchars($this->doc
->issueCommand('&cmd['.$table.']['.$rec_off['uid'].'][version][action]=clearWSID')).'" onclick="return confirm(\'Remove from workspace?\');">'.
1634 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/group_clear.gif','width="14" height="14"').' alt="" align="top" title="Remove from workspace" />'.
1638 if ($table==='pages' && $vType!=='element') {
1639 $tempUid = ($vType==='branch' ||
$GLOBALS['BE_USER']->workspace
===0 ?
$rec_off['uid'] : $rec_on['uid']);
1641 '<a href="#" onclick="top.loadEditId('.$tempUid.');top.goToModule(\''.$this->pageModule
.'\'); return false;">'.
1642 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,t3lib_extMgm
::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="Edit page" alt="" />'.
1645 $params = '&edit['.$table.']['.$rec_off['uid'].']=edit';
1647 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->doc
->backPath
)).'">'.
1648 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/edit2.gif','width="12" height="12"').' title="Edit element" alt="" />'.
1655 '<a href="'.htmlspecialchars($this->doc
->backPath
.'show_rechis.php?element='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode($this->REQUEST_URI
)).'">'.
1656 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/history2.gif','width="13" height="12"').' title="Show Log" alt="" />'.
1660 if ($table==='pages') {
1661 $tempUid = ($vType==='branch' ||
$GLOBALS['BE_USER']->workspace
===0 ?
$rec_off['uid'] : $rec_on['uid']);
1663 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($tempUid,$this->doc
->backPath
,t3lib_BEfunc
::BEgetRootLine($tempUid))).'">'.
1664 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
1668 return $actionLinks;
1672 * Links to publishing etc of a version
1674 * @param string Table name
1675 * @param array Record
1676 * @param integer The uid of the online version of $uid. If zero it means we are drawing a row for the online version itself while a value means we are drawing display for an offline version.
1677 * @return string HTML content, mainly link tags and images.
1679 function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId) {
1681 if ($origId ||
$GLOBALS['BE_USER']->workspace
===0) {
1682 if (!$GLOBALS['BE_USER']->workspaceCannotEditRecord($table,$rec)) {
1684 if ($table==='pages') {
1686 '<a href="#" onclick="top.loadEditId('.$uid.');top.goToModule(\''.$this->pageModule
.'\'); return false;">'.
1687 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,t3lib_extMgm
::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="Edit page" alt="" />'.
1690 $params = '&edit['.$table.']['.$uid.']=edit';
1692 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->doc
->backPath
)).'">'.
1693 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/edit2.gif','width="12" height="12"').' title="Edit element" alt="" />'.
1700 '<a href="'.htmlspecialchars($this->doc
->backPath
.'show_rechis.php?element='.rawurlencode($table.':'.$uid).'&returnUrl='.rawurlencode($this->REQUEST_URI
)).'">'.
1701 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/history2.gif','width="13" height="12"').' title="Show Log" alt="" />'.
1706 if ($table==='pages') {
1708 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($uid,$this->doc
->backPath
,t3lib_BEfunc
::BEgetRootLine($uid))).'">'.
1709 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
1713 return $actionLinks;
1724 /**********************************
1728 **********************************/
1731 * Will publish workspace if buttons are pressed
1735 function publishAction() {
1737 // If "Publish" or "Swap" buttons are pressed:
1738 if (t3lib_div
::_POST('_publish') || t3lib_div
::_POST('_swap')) {
1740 if ($this->table
==='pages') { // Making sure ->uid is a page ID!
1741 // Initialize workspace object and request all pending versions:
1742 $wslibObj = t3lib_div
::makeInstance('wslib');
1743 $cmd = $wslibObj->getCmdArrayForPublishWS($GLOBALS['BE_USER']->workspace
, t3lib_div
::_POST('_swap'),$this->uid
);
1745 // Execute the commands:
1746 $tce = t3lib_div
::makeInstance('t3lib_TCEmain');
1747 $tce->stripslashes_values
= 0;
1748 $tce->start(array(), $cmd);
1749 $tce->process_cmdmap();
1751 t3lib_BEfunc
::getSetUpdateSignal('updatePageTree');
1753 return $tce->errorLog
;
1761 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/version/cm1/index.php']) {
1762 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/version/cm1/index.php']);
1769 $SOBE = t3lib_div
::makeInstance('tx_version_cm1');
1774 $SOBE->printContent();