### Eclipse Workspace Patch 1.0 #P igeworkspace42 Index: typo3/mod/user/ws/class.wsstagelib.php =================================================================== --- typo3/mod/user/ws/class.wsstagelib.php (revision 0) +++ typo3/mod/user/ws/class.wsstagelib.php (revision 0) @@ -0,0 +1,182 @@ + + */ +/** + * [CLASS/FUNCTION INDEX of SCRIPT] + * + * + * + * 68: class wsstagelib + * 81: function getCmdArrayForPublishWS($wsid, $doSwap,$pageId=0) + * 127: function selectVersionsInWorkspace($wsid,$filter=0,$stage=-99,$pageId=-1) + * + * SECTION: CLI functions + * 183: function CLI_main() + * 193: function autoPublishWorkspaces() + * + * TOTAL FUNCTIONS: 4 + * (This index is automatically created/updated by the extension "extdeveval") + * + */ + + + + + + + + + + + + +/** + * Library with Workspace related functionality + * + * @author Sonja Scholz + * @package TYPO3 + * @subpackage core + */ +class wsstagelib { + + /** + * Building an array with all stage ids and titles related to the given workspace + * + * @return array id and title of the stages + */ + function getStagesForWS($wsid) { + $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace',$wsid); + if($workspaceRec['use_custom_staging'] == '1') { + // Get all stage records for this workspace + $workspaceStageRecs = t3lib_BEfunc::getRecordsByField('sys_workspace_stage', 'parentid', $wsid, "AND parenttable='sys_workspace' ", '', $orderBy = 'sorting'); + return $workspaceStageRecs; + } else { + return false; + } + } + + + /** + * Check if given workspace has custom staging activated + * + * @return bool true or false + */ + function checkCustomStagingForWS($wsid) { + $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace',$wsid); + if($workspaceRec['use_custom_staging'] == '1') { + return true; + } else { + return false; + } + } + + + /** + * Get next stage in process for given stage id + * + * @param int workspace id + * @param int stageid + * @return int id + */ + function getNextStage($wsid,$stageid) { + $workspaceStageRecs = $this->getStagesForWS($wsid); + if(is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) { + $nextStage = array(); + + // If current stage is the standart edit stage, next stage is the first custom stage + if($stageid === '0') { + $nextStage = $workspaceStageRecs[0]; + $nextStage['uid'] = $nextStage['uid']+20; + return $nextStage; + } + + while (list($array_key, $workspaceStageRec) = each($workspaceStageRecs)) { + if($workspaceStageRec['uid'] == ($stageid-20)) { + // Get the following value from the result array + list(,$nextStage) = each($workspaceStageRecs); + // check if there is a next stage or if the current stage is the last before publish + if($workspaceStageRecs[$array_key+1]) { + $nextStage = $workspaceStageRecs[$array_key+1]; + $nextStage['uid'] = $nextStage['uid']+20; + } else { + $nextStage['uid'] = '10'; + } + } + } + return $nextStage; + } else { + return false; + } + } + + /** + * Get next stage in process for given stage id + * + * @param int workspace id + * @param int stageid + * @return int id + */ + function getPrevStage($wsid,$stageid) { + $workspaceStageRecs = $this->getStagesForWS($wsid); + if(is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) { + $prevStage = array(); + // If the current stage is 10 then the prev stage is the last of the custom stages + if($stageid == '10') { + $prevStage = end($workspaceStageRecs); + $prevStage['uid'] = $prevStage['uid']+20; + } else { + while (list($array_key, $workspaceStageRec) = each($workspaceStageRecs)) { + if($workspaceStageRec['uid'] == ($stageid-20)) { + // check if there is a prev stage or if the current stage is the first custom stage + if($workspaceStageRecs[$array_key-1]) { + $prevStage = $workspaceStageRecs[$array_key-1]; + $prevStage['uid'] = $prevStage['uid']+20; + } else { + // First stage is always the standart edit stage + $prevStage['uid'] = '0'; + return $prevStage; + } + } + } + } + return $prevStage; + } else { + return false; + } + } +} + + + +if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/class.wsstagelib.php']) { + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/class.wslib.php']); +} +?> \ No newline at end of file Index: typo3/mod/user/ws/index.php =================================================================== --- typo3/mod/user/ws/index.php (revision 270) +++ typo3/mod/user/ws/index.php (working copy) @@ -82,6 +82,7 @@ $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); require_once(PATH_t3lib.'class.t3lib_scbase.php'); require_once(PATH_typo3.'mod/user/ws/class.wslib.php'); +require_once(PATH_typo3.'mod/user/ws/class.wsstagelib.php'); require_once(PATH_typo3.'mod/user/ws/class.wslib_gui.php'); require_once(PATH_t3lib.'class.t3lib_diff.php'); require_once(PATH_t3lib.'class.t3lib_pagetree.php'); @@ -177,6 +178,7 @@ */ function execute() { $post = t3lib_div::_POST(); + $post = array_merge($post, t3lib_div::_GET()); # debug($post); @@ -224,6 +226,15 @@ case "flush": $cmdArray[$table][$uid]['version']['action'] = 'flush'; break; + default: + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); + if($wsstagelibObj->checkCustomStagingForWS($post['wsid'])) { + $cmdArray[$table][$uid]['version']['action'] = 'setStage'; + $cmdArray[$table][$uid]['version']['stageId'] = str_replace('stage_','',$post['_with_selected_do']); + $cmdArray[$table][$uid]['version']['comment'] = $post['comments']; + } + break; } } } @@ -280,7 +291,7 @@ } '); $this->doc->form = '
'; - + // Setting up the context sensitive menu: $this->doc->getContextMenuCode(); Index: typo3/mod/user/ws/class.wslib_gui.php =================================================================== --- typo3/mod/user/ws/class.wslib_gui.php (revision 270) +++ typo3/mod/user/ws/class.wslib_gui.php (working copy) @@ -70,6 +70,7 @@ */ require_once(PATH_typo3 . 'mod/user/ws/class.wslib.php'); +require_once(PATH_typo3 . 'mod/user/ws/class.wsstagelib.php'); $LANG->includeLLFile('EXT:lang/locallang_mod_user_ws.xml'); $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); @@ -137,6 +138,9 @@ // Initialize workspace object and request all pending versions: $wslibObj = t3lib_div::makeInstance('wslib'); + + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); // Selecting ALL versions belonging to the workspace: $versions = $wslibObj->selectVersionsInWorkspace($this->workspaceId, $filter, -99, $pageId); @@ -187,28 +191,39 @@ if ($workspaceOverviewList || $this->alwaysDisplayHeader) { // Make header of overview: $tableRows = array(); - $tableRows[] = ' + $tableHead = ''; + $tableHead = ' ' . $LANG->getLL('label_pagetree') . ' ' . $LANG->getLL('label_live_version') . ' ' . $LANG->getLL('label_draft_versions') . ' ' . $LANG->getLL('label_stage') . ' ' . $LANG->getLL('label_publish') . ' - - - + '; + + // Check if custom staging was choosed in workspace configuration + if($wsstagelibObj->checkCustomStagingForWS($this->workspaceId)) { + $tableHead .= ' + '; + } else { + $tableHead .= ' - - + '; + } + + $tableHead .= ' ' . $LANG->getLL('label_lifecycle') . ' '.($this->showWorkspaceCol ? '' . $LANG->getLL('label_workspace') . '' : '').' '; - + + $tableRows[] = $tableHead; + // Add lines from overview: $tableRows = array_merge($tableRows, $workspaceOverviewList); @@ -341,6 +356,9 @@ // Initialize: $fullColSpan = $this->showWorkspaceCol ? 10 : 9; + + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); // Traverse $pArray if (is_array($pArray)) { @@ -501,22 +519,41 @@ $verElement. $subElements['off']. ''; - - // Compile table row: - $tableRows[] = ' - - '.$mainCell.$verCell.' - '.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).' - '. - $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType). - htmlspecialchars($swapLabel). - ' - - '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).''. // Lifecycle - ($this->showWorkspaceCol ? ' - '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'' : '').' - '; - + + // Check if custom staging is activated in workspace configuration + if($wsstagelibObj->checkCustomStagingForWS($this->workspaceId)) { + // Compile table row: + $tableRows[] = ' + + '.$mainCell.$verCell.' + '.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).' + '. + $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType). + htmlspecialchars($swapLabel). + ' + + + '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).''. // Lifecycle + ($this->showWorkspaceCol ? ' + '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'' : '').' + '; + } else { + // Compile table row: + $tableRows[] = ' + + '.$mainCell.$verCell.' + '.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).' + '. + $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType). + htmlspecialchars($swapLabel). + ' + + '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).''. // Lifecycle + ($this->showWorkspaceCol ? ' + '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'' : '').' + '; + } + // Reset the main cell: $mainCell = ''; } @@ -835,10 +872,21 @@ $text = $LANG->getLL('stage_reset_to_editing'); break; default: - $text = $LANG->getLL('stage_undefined'); - break; + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); + // Check if custom staging is activated in workspace configuration + if($wsstagelibObj->checkCustomStagingForWS($this->workspaceId)) { + $workspaceStageRec = t3lib_BEfunc::getRecord('sys_workspace_stage',$data['stage']-20); + if($workspaceStageRec) { + $text = $LANG->getLL('stage_custom'); + $stagetitle = $workspaceStageRec['title']; + } + } else { + $text = $LANG->getLL('stage_undefined'); + } + break; } - $text = t3lib_BEfunc::datetime($dat['tstamp']).': ' . sprintf($text, $username); + $text = t3lib_BEfunc::datetime($dat['tstamp']).': ' . sprintf($text, $username, $stagetitle); $text.= ($data['comment']?'
' . $LANG->getLL('stage_label_user_comment'). ' '.htmlspecialchars($data['comment']).'':''); $entry[] = $text; @@ -1215,6 +1263,11 @@ */ function displayWorkspaceOverview_stageCmd($table,&$rec_off) { global $LANG; + + $this->workspaceId = (!is_null($wsid) ? $wsid : $GLOBALS['BE_USER']->workspace); + + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); switch((int)$rec_off['t3ver_stage']) { case 0: @@ -1246,6 +1299,20 @@ $sLabel = $LANG->getLL('label_undefined'); $sId = 0; $color = ''; + + // Check if custom staging is activated in workspace configuration + if($wsstagelibObj->checkCustomStagingForWS($this->workspaceId)) { + $workspaceStageRec = t3lib_BEfunc::getRecord('sys_workspace_stage',$rec_off['t3ver_stage']-20); + if($workspaceStageRec) { + $sLabel = $workspaceStageRec['title']; + // Next custom stage + $nextStage = $wsstagelibObj->getNextStage($this->workspaceId,$rec_off['t3ver_stage']); + // ID of next stage + $sId = $nextStage['uid']; + $color = '#999999'; + $titleAttrib = $LANG->getLL('label_sendToNextStage'); + } + } break; } #debug($sId); @@ -1253,12 +1320,21 @@ $raiseOk = !$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off); if ($raiseOk && $rec_off['t3ver_stage']!=-1) { - $onClick = 'var commentTxt=window.prompt("'.$LANG->getLL('explain_reject').'",""); - if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( - '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. - '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]=-1' - ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. - ' return false;'; + // Check if custom staging is activated in workspace configuration + if($wsstagelibObj->checkCustomStagingForWS($rec_off['t3ver_wsid'])) { + // Reject id for custom stage reject is -21 instead of -1 + $onClick = 'var commentTxt=null;window.location.href="'. + $this->doc->backPath.'mod.php?M=user_txversionM2'. + '&items['.$table.':'.$rec_off['uid'].':'.$rec_off['t3ver_stage'].':'.$rec_off['t3ver_wsid'].']=1";'. + ' return false;'; + } else { + $onClick = 'var commentTxt=window.prompt("'.$LANG->getLL('explain_reject').'",""); + if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( + '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. + '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]=-1' + ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. + ' return false;'; + } // Reject: $actionLinks.= ''. @@ -1272,15 +1348,23 @@ // TODO Use CSS? $actionLinks.= ''.$sLabel.''; - + + // Raise if ($raiseOk) { - $onClick = 'var commentTxt=window.prompt("'.$label.'",""); - if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( - '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. - '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]='.$sId - ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. - ' return false;'; + if($wsstagelibObj->checkCustomStagingForWS($rec_off['t3ver_wsid'])) { + $onClick = 'var commentTxt=null;window.location.href="'. + $this->doc->backPath.'mod.php?M=user_txversionM2'. + '&items['.$table.':'.$rec_off['uid'].':'.$rec_off['t3ver_stage'].':'.$rec_off['t3ver_wsid'].']=1";'. + ' return false;'; + } else { + $onClick = 'var commentTxt=window.prompt("'.$label.'",""); + if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( + '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. + '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]='.$sId + ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. + ' return false;'; + } if ($rec_off['t3ver_stage']!=10) { $actionLinks.= ''.