[TASK] CGL OpeningFunctionBraceKernighanRitchieSpaceBeforeBrace in version
[Packages/TYPO3.CMS.git] / typo3 / sysext / version / class.tx_version_cm1.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
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.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * Addition of the versioning item to the clickmenu
26 *
27 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
28 */
29
30
31
32
33
34 /**
35 * "Versioning" item added to click menu of elements.
36 *
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * @package TYPO3
39 * @subpackage core
40 */
41 class tx_version_cm1 {
42
43 /**
44 * Main function, adding the item to input menuItems array
45 *
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
51 */
52 function main(&$backRef, $menuItems, $table, $uid) {
53 $localItems = Array();
54 if (!$backRef->cmLevel && $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) {
55
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']) {
58 return $menuItems;
59 }
60
61 // Adds the regular item
62 $LL = $this->includeLL();
63
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),
70 1
71 );
72
73 // "Send to review" element added:
74 /*
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),
80 1
81 );
82 */
83
84 // Find position of "delete" element:
85 $c=0;
86 foreach ($menuItems as $k => $value) {
87 $c++;
88 if (!strcmp($k, 'delete')) {
89 break;
90 }
91 }
92 // .. subtract two (delete item + divider line)
93 $c-=2;
94 // ... and insert the items just before the delete element.
95 array_splice(
96 $menuItems,
97 $c,
98 0,
99 $localItems
100 );
101 }
102 return $menuItems;
103 }
104
105 /**
106 * Includes the [extDir]/locallang.php and returns the $LOCAL_LANG array found in that file.
107 *
108 * @return array Local lang array
109 */
110 function includeLL() {
111 return $GLOBALS['LANG']->includeLLFile('EXT:version/locallang.xml', FALSE);
112 }
113 }
114
115
116
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']);
119 }
120 ?>