Commit 8c765c5b authored by Thomas Maroschik's avatar Thomas Maroschik
Browse files

[TASK] Merge submodule version into core

parents ca1c3ea4 95b15a41
[submodule "typo3/sysext/version"]
path = typo3/sysext/version
url = git://git.typo3.org/TYPO3v4/CoreProjects/workspaces/version.git
version @ 314d0e61
Subproject commit 314d0e610fe3dfa5479f19bf0cb2302e8413204d
<?php
/***************************************************************
* Copyright notice
*
* (c) 2004-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Addition of the versioning item to the clickmenu
*
* @author Kasper Skrhj <kasperYYYY@typo3.com>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 54: class tx_version_cm1
* 65: function main(&$backRef,$menuItems,$table,$uid)
* 111: function includeLL()
*
* TOTAL FUNCTIONS: 2
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
/**
* "Versioning" item added to click menu of elements.
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
* @package TYPO3
* @subpackage core
*/
class tx_version_cm1 {
/**
* Main function, adding the item to input menuItems array
*
* @param object References to parent clickmenu objects.
* @param array Array of existing menu items accumulated. New element added to this.
* @param string Table name of the element
* @param integer Record UID of the element
* @return array Modified menuItems array
*/
function main(&$backRef,$menuItems,$table,$uid) {
global $BE_USER,$TCA,$LANG;
$localItems = Array();
if (!$backRef->cmLevel && $uid>0 && $BE_USER->check('modules','web_txversionM1')) {
// Returns directly, because the clicked item was not from the pages table
if (in_array('versioning', $backRef->disabledItems) || !$TCA[$table] || !$TCA[$table]['ctrl']['versioningWS']) {
return $menuItems;
}
// Adds the regular item
$LL = $this->includeLL();
// "Versioning" element added:
$url = t3lib_extMgm::extRelPath('version').'cm1/index.php?table='.rawurlencode($table).'&uid='.$uid;
$localItems[] = $backRef->linkItem(
$GLOBALS['LANG']->getLLL('title',$LL),
$backRef->excludeIcon('<img src="'.$backRef->backPath.t3lib_extMgm::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
$backRef->urlRefForCM($url),
1
);
// "Send to review" element added:
$url = t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table=='pages'?$uid:$backRef->rec['pid']).'&table='.rawurlencode($table).'&uid='.$uid.'&sendToReview=1';
$localItems[] = $backRef->linkItem(
$GLOBALS['LANG']->getLLL('title_review',$LL),
$backRef->excludeIcon('<img src="'.$backRef->backPath.t3lib_extMgm::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
$backRef->urlRefForCM($url),
1
);
// Find position of "delete" element:
$c=0;
foreach ($menuItems as $k => $value) {
$c++;
if (!strcmp($k,'delete')) break;
}
// .. subtract two (delete item + divider line)
$c-=2;
// ... and insert the items just before the delete element.
array_splice(
$menuItems,
$c,
0,
$localItems
);
}
return $menuItems;
}
/**
* Includes the [extDir]/locallang.php and returns the $LOCAL_LANG array found in that file.
*
* @return array Local lang array
*/
function includeLL() {
global $LANG;
return $LANG->includeLLFile('EXT:version/locallang.xml',FALSE);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_cm1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_cm1.php']);
}
?>
\ No newline at end of file
<?php
// DO NOT REMOVE OR CHANGE THESE 3 LINES:
define('TYPO3_MOD_PATH', 'sysext/version/cm1/');
$BACK_PATH = '../../../';
$MCONF['name'] = 'web_txversionM1';
$MLANG['default']['tabs_images']['tab'] = 'cm_icon.gif';
$MLANG['default']['ll_ref'] = 'LLL:EXT:version/locallang.xml';
$MCONF['script'] = 'index.php';
$MCONF['access'] = 'user,group';
?>
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
* (c) 2004-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Versioning module
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 102: class tx_version_cm1 extends t3lib_SCbase
*
* SECTION: Standard module initialization
* 138: function menuConfig()
* 175: function main()
* 236: function jumpToUrl(URL)
* 296: function printContent()
*
* SECTION: Versioning management
* 322: function versioningMgm()
* 485: function pageSubContent($pid,$c=0)
* 539: function lookForOwnVersions($table,$uid)
* 556: function adminLinks($table,$row)
*
* SECTION: Workspace management
* 628: function workspaceMgm()
* 688: function displayWorkspaceOverview()
* 758: function displayWorkspaceOverview_list($pArray)
* 923: function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row)
* 936: function displayWorkspaceOverview_allStageCmd()
*
* SECTION: Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
* 986: function formatVerId($verId)
* 996: function formatWorkspace($wsid)
* 1023: function formatCount($count)
* 1050: function versionsInOtherWS($table,$uid)
* 1080: function showStageChangeLog($table,$id,$stageCommands)
* 1129: function subElements($uid,$treeLevel,$origId=0)
* 1232: function subElements_getNonPageRecords($tN, $uid, &$recList)
* 1262: function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata)
* 1331: function markupNewOriginals()
* 1353: function createDiffView($table, $diff_1_record, $diff_2_record)
* 1470: function displayWorkspaceOverview_stageCmd($table,&$rec_off)
* 1557: function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType)
* 1627: function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId)
*
* SECTION: Processing
* 1683: function publishAction()
*
* TOTAL FUNCTIONS: 27
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
// DEFAULT initialization of a module [BEGIN]
unset($MCONF);
require ('conf.php');
require ($BACK_PATH.'init.php');
require ($BACK_PATH.'template.php');
$LANG->includeLLFile('EXT:version/locallang.xml');
// DEFAULT initialization of a module [END]
require_once(PATH_typo3.'mod/user/ws/class.wslib.php');
/**
* Versioning module, including workspace management
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
* @package TYPO3
* @subpackage core
*/
class tx_version_cm1 extends t3lib_SCbase {
// Default variables for backend modules
var $MCONF = array(); // Module configuration
var $MOD_MENU = array(); // Module menu items
var $MOD_SETTINGS = array(); // Module session settings
/**
* document template object
*
* @var mediumDoc
*/
var $doc;
var $content; // Accumulated content
// Internal:
var $showWorkspaceCol = 0;
var $formatWorkspace_cache = array();
var $formatCount_cache = array();
var $targets = array(); // Accumulation of online targets.
var $pageModule = ''; // Name of page module
var $publishAccess = FALSE;
var $be_user_Array = array();
var $stageIndex = array();
var $recIndex = array();
protected $showDraftWorkspace = FALSE; // Determines whether to show the dummy draft workspace
/*********************************
*
* Standard module initialization
*
*********************************/
/**
* Initialize menu configuration
*
* @return void
*/
function menuConfig() {
// fetches the configuration of the version extension
$versionExtconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['version']);
// show draft workspace only if enabled in the version extensions config
if($versionExtconf['showDraftWorkspace']) {
$this->showDraftWorkspace = TRUE;
}
// Menu items:
$this->MOD_MENU = array(
'filter' => array(
1 => $GLOBALS['LANG']->getLL('filter_drafts'),
2 => $GLOBALS['LANG']->getLL('filter_archive'),
0 => $GLOBALS['LANG']->getLL('filter_all'),
),
'display' => array(
0 => $GLOBALS['LANG']->getLL('liveWorkspace'),
-98 => $GLOBALS['LANG']->getLL('draftWorkspaces'),
-99 => $GLOBALS['LANG']->getLL('filter_all'),
),
'diff' => ''
);
if($this->showDraftWorkspace === TRUE) {
$this->MOD_MENU['display'][-1] = $GLOBALS['LANG']->getLL('defaultDraft');
}
// Add workspaces:
if ($GLOBALS['BE_USER']->workspace===0) { // Spend time on this only in online workspace because it might take time:
$workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
foreach($workspaces as $rec) {
if ($GLOBALS['BE_USER']->checkWorkspace($rec)) {
$this->MOD_MENU['display'][$rec['uid']] = '['.$rec['uid'].'] '.$rec['title'];
}
}
}
// CLEANSE SETTINGS
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
}
/**
* Main function of the module. Write the content to $this->content
*
* @return void
*/
function main() {
global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
// Template markers
$markers = array(
'CSH' => '',
'FUNC_MENU' => '',
'WS_MENU' => '',
'CONTENT' => ''
);
// Setting module configuration:
$this->MCONF = $GLOBALS['MCONF'];
$this->REQUEST_URI = str_replace('&sendToReview=1','',t3lib_div::getIndpEnv('REQUEST_URI'));
// Draw the header.
$this->doc = t3lib_div::makeInstance('template');
$this->doc->backPath = $BACK_PATH;
$this->doc->setModuleTemplate('templates/version.html');
// Add styles
$this->doc->inDocStylesArray[$GLOBALS['MCONF']['name']] = '
.version-diff-1 { background-color: green; }
.version-diff-2 { background-color: red; }
';
// Setting up the context sensitive menu:
$this->doc->getContextMenuCode();
// Getting input data:
$this->id = intval(t3lib_div::_GP('id')); // Page id. If set, indicates activation from Web>Versioning module
if (!$this->id) {
$this->uid = intval(t3lib_div::_GP('uid')); // Record uid. Goes with table name to indicate specific record
$this->table = t3lib_div::_GP('table'); // Record table. Goes with uid to indicate specific record
} else {
$this->uid = $this->id;
$this->table = 'pages';
}
$this->details = t3lib_div::_GP('details'); // Page id. If set, indicates activation from Web>Versioning module
$this->diffOnly = t3lib_div::_GP('diffOnly'); // Flag. If set, shows only the offline version and with diff-view
// Force this setting:
$this->MOD_SETTINGS['expandSubElements'] = TRUE;
$this->MOD_SETTINGS['diff'] = $this->details || $this->MOD_SETTINGS['diff']?1:0;
// Reading the record:
$record = t3lib_BEfunc::getRecord($this->table,$this->uid);
if ($record['pid']==-1) {
$record = t3lib_BEfunc::getRecord($this->table,$record['t3ver_oid']);
}
$this->recordFound = is_array($record);
$pidValue = $this->table==='pages' ? $this->uid : $record['pid'];
// Checking access etc.
if ($this->recordFound && $TCA[$this->table]['ctrl']['versioningWS']) {
$this->doc->form='<form action="" method="post">';
$this->uid = $record['uid']; // Might have changed if new live record was found!
// Access check!
// The page will show only if there is a valid page and if this page may be viewed by the user
$this->pageinfo = t3lib_BEfunc::readPageAccess($pidValue,$this->perms_clause);
$access = is_array($this->pageinfo) ? 1 : 0;
if (($pidValue && $access) || ($BE_USER->user['admin'] && !$pidValue)) {
// JavaScript
$this->doc->JScode.= '
<script language="javascript" type="text/javascript">
script_ended = 0;
function jumpToUrl(URL) {
window.location.href = URL;
}
function hlSubelements(origId, verId, over, diffLayer) { //
if (over) {
document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
if (diffLayer) {
document.getElementById(\'diff_\'+verId).style.visibility = \'visible\';
}
} else {
document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
if (diffLayer) {
document.getElementById(\'diff_\'+verId).style.visibility = \'hidden\';
}
}
}
</script>
';
// If another page module was specified, replace the default Page module with the new one
$newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
$this->pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
// Setting publish access permission for workspace:
$this->publishAccess = $BE_USER->workspacePublishAccess($BE_USER->workspace);
// Render content:
if ($this->id) {
$this->workspaceMgm();
} else {
$this->versioningMgm();
}
}
$this->content.=$this->doc->spacer(10);
// Setting up the buttons and markers for docheader
$docHeaderButtons = $this->getButtons();
$markers['CSH'] = $docHeaderButtons['csh'];
$markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
$markers['WS_MENU'] = $this->workspaceMenu();
$markers['CONTENT'] = $this->content;
} else {
// If no access or id value, create empty document
$this->content = $this->doc->section($LANG->getLL('clickAPage_header'), $LANG->getLL('clickAPage_content'), 0, 1);
// Setting up the buttons and markers for docheader
$docHeaderButtons = $this->getButtons();
$markers['CONTENT'] = $this->content;
}
// Build the <body> for the module
$this->content = $this->doc->startPage($LANG->getLL('title'));
$this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
$this->content.= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
}
/**
* Outputs accumulated module content to browser.
*
* @return void
*/
function printContent() {
echo $this->content;
}
/**
* Create the panel of buttons for submitting the form or otherwise perform operations.
*
* @return array all available buttons as an assoc. array
*/
protected function getButtons() {
global $TCA, $LANG, $BACK_PATH, $BE_USER;
$buttons = array(
'csh' => '',
'view' => '',
'record_list' => '',
'shortcut' => '',
);
// CSH
//$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_txversionM1', '', $GLOBALS['BACK_PATH']);
if ($this->recordFound && $TCA[$this->table]['ctrl']['versioningWS']) {
// View page
$buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
t3lib_iconWorks::getSpriteIcon('actions-document-view') .
'</a>';
// Shortcut
if ($BE_USER->mayMakeShortcut()) {
$buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
}
// If access to Web>List for user, then link to that module.
if ($BE_USER->check('modules','web_list')) {
$href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
$buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE) . '">' .
t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
'</a>';
}
}
return $buttons;
}
/******************************
*
* Versioning management
*
******************************/
/**
* Management of versions for record
*
* @return void
*/
function versioningMgm() {
global $TCA;
// Diffing:
$diff_1 = t3lib_div::_POST('diff_1');
$diff_2 = t3lib_div::_POST('diff_2');
if (t3lib_div::_POST('do_diff')) {
$content='';
$content.='<h3>' . $GLOBALS['LANG']->getLL('diffing') . ':</h3>';
if ($diff_1 && $diff_2) {
$diff_1_record = t3lib_BEfunc::getRecord($this->table, $diff_1);
$diff_2_record = t3lib_BEfunc::getRecord($this->table, $diff_2);
if (is_array($diff_1_record) && is_array($diff_2_record)) {
t3lib_div::loadTCA($this->table);
$t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
$tRows=array();
$tRows[] = '
<tr class="bgColor5 tableheader">
<td>' . $GLOBALS['LANG']->getLL('fieldname') . '</td>
<td width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</td>
</tr>
';
foreach($diff_1_record as $fN => $fV) {
if ($TCA[$this->table]['columns'][$fN] && $TCA[$this->table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN)) {
if (strcmp($diff_1_record[$fN],$diff_2_record[$fN])) {
$diffres = $t3lib_diff_Obj->makeDiffDisplay(
t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_2_record[$fN],0,1),
t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_1_record[$fN],0,1)
);
$tRows[] = '
<tr class="bgColor4">
<td>'.$fN.'</td>
<td width="98%">'.$diffres.'</td>
</tr>
';
}
}
}
if (count($tRows)>1) {
$content .= '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . implode('', $tRows) . '</table><br /><br />';
} else {
$content .= $GLOBALS['LANG']->getLL('recordsMatchesCompletely');
}
} else $content .= $GLOBALS['LANG']->getLL('errorRecordsNotFound');
} else {
$content .= $GLOBALS['LANG']->getLL('errorDiffSources');
}
}
// Element:
$record = t3lib_BEfunc::getRecord($this->table,$this->uid);
$recordIcon = t3lib_iconWorks::getSpriteIconForRecord($this->table, $record);
$recTitle = t3lib_BEfunc::getRecordTitle($this->table,$record,TRUE);
// Display versions:
$content.='
'.$recordIcon.$recTitle.'
<form name="theform" action="'.str_replace('&sendToReview=1','',$this->REQUEST_URI).'" method="post">
<table border="0" cellspacing="1" cellpadding="1">';