2 /***************************************************************
5 * (c) 2004-2011 Kasper Skårhøj (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 ***************************************************************/
25 * Addition of the versioning item to the clickmenu
27 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 * "Versioning" item added to click menu of elements.
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 class tx_version_cm1
{
44 * Main function, adding the item to input menuItems array
46 * @param object References to parent clickmenu objects.
47 * @param array Array of existing menu items accumulated. New element added to this.
48 * @param string Table name of the element
49 * @param integer Record UID of the element
50 * @return array Modified menuItems array
52 function main(&$backRef, $menuItems, $table, $uid) {
53 $localItems = Array();
54 if (!$backRef->cmLevel
&& $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) {
56 // Returns directly, because the clicked item was not from the pages table
57 if (in_array('versioning', $backRef->disabledItems
) ||
!$GLOBALS['TCA'][$table] ||
!$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
61 // Adds the regular item
62 $LL = $this->includeLL();
64 // "Versioning" element added:
65 $url = t3lib_extMgm
::extRelPath('version').'cm1/index.php?table='.rawurlencode($table).'&uid='.$uid;
66 $localItems[] = $backRef->linkItem(
67 $GLOBALS['LANG']->getLLL('title', $LL),
68 $backRef->excludeIcon('<img src="'.$backRef->backPath
.t3lib_extMgm
::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
69 $backRef->urlRefForCM($url),
73 // "Send to review" element added:
75 $url = t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table=='pages'?$uid:$backRef->rec['pid']).'&table='.rawurlencode($table).'&uid='.$uid.'&sendToReview=1';
76 $localItems[] = $backRef->linkItem(
77 $GLOBALS['LANG']->getLLL('title_review', $LL),
78 $backRef->excludeIcon('<img src="'.$backRef->backPath.t3lib_extMgm::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
79 $backRef->urlRefForCM($url),
84 // Find position of "delete" element:
86 foreach ($menuItems as $k => $value) {
88 if (!strcmp($k, 'delete')) {
92 // .. subtract two (delete item + divider line)
94 // ... and insert the items just before the delete element.
106 * Includes the [extDir]/locallang.php and returns the $LOCAL_LANG array found in that file.
108 * @return array Local lang array
110 function includeLL() {
111 return $GLOBALS['LANG']->includeLLFile('EXT:version/locallang.xml', FALSE);
117 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/version/class.tx_version_cm1.php'])) {
118 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/version/class.tx_version_cm1.php']);