📄 index.php
字号:
<?php/**************************************************************** Copyright notice** (c) 2004-2005 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');require_once (PATH_t3lib.'class.t3lib_scbase.php'); // DEFAULT initialization of a module [END]require_once(PATH_t3lib.'class.t3lib_diff.php');require_once(PATH_typo3.'mod/user/ws/class.wslib.php');require_once(PATH_t3lib.'class.t3lib_pagetree.php');require_once(PATH_t3lib.'class.t3lib_tcemain.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 var $doc; // Document Template Object 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(); /********************************* * * Standard module initialization * *********************************/ /** * Initialize menu configuration * * @return void */ function menuConfig() { // Menu items: $this->MOD_MENU = array( 'filter' => array( 1 => 'Drafts', 2 => 'Archive', 0 => 'All', ), 'display' => array( 0 => '[Live workspace]', -98 => 'Draft Workspaces', -99 => 'All', -1 => '[Default Draft]' ), 'diff' => '' ); // 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; // 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('mediumDoc'); $this->doc->backPath = $BACK_PATH; $this->doc->form='<form action="" method="post">'; // 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: $CMparts = $this->doc->getContextMenuCode(); $this->doc->JScode.= $CMparts[0]; $this->doc->bodyTagAdditions = $CMparts[1]; $this->doc->postCode.= $CMparts[2]; // 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']); } $pidValue = $this->table==='pages' ? $this->uid : $record['pid']; // Checking access etc. if (is_array($record) && $TCA[$this->table]['ctrl']['versioningWS']) { $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); $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); $this->content.=$this->doc->startPage($LANG->getLL('title')); $this->content.=$this->doc->header($LANG->getLL('title')); $this->content.=$this->doc->spacer(5); $this->content.=$this->doc->section('',$headerSection); $this->content.=$this->doc->divider(5); // Render content: if ($this->id) { $this->workspaceMgm(); } else { $this->versioningMgm(); } // ShortCut if ($BE_USER->mayMakeShortcut()) { $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'])); } } $this->content.=$this->doc->spacer(10); } else { // If no access or id value, create empty document: $this->content.=$this->doc->startPage($LANG->getLL('title')); $this->content.=$this->doc->section($LANG->getLL('clickAPage_header'),$LANG->getLL('clickAPage_content'),0,1); } } /** * Outputs accumulated module content to browser. * * @return void */ function printContent() { $this->content.=$this->doc->endPage(); echo $this->content; } /****************************** * * 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>DIFFING:</h3>';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -