Added feature #3687: Disable versioning and moreoptions-menuitem via contextMenu...
[Packages/TYPO3.CMS.git] / typo3 / sysext / extra_page_cm_options / class.tx_extrapagecmoptions.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 Kasper Skaarhoj (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 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Class, adding extra context menu options
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 67: class tx_extrapagecmoptions
41 * 79: function main(&$backRef,$menuItems,$table,$uid)
42 * 158: function includeLL()
43 *
44 * TOTAL FUNCTIONS: 2
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49
50
51
52
53
54
55
56
57
58
59
60 /**
61 * Class, adding extra context menu options
62 *
63 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
64 * @package TYPO3
65 * @subpackage tx_extrapagecmoptions
66 */
67 class tx_extrapagecmoptions {
68
69 /**
70 * Adding various standard options to the context menu.
71 * This includes both first and second level.
72 *
73 * @param object The calling object. Value by reference.
74 * @param array Array with the currently collected menu items to show.
75 * @param string Table name of clicked item.
76 * @param integer UID of clicked item.
77 * @return array Modified $menuItems array
78 */
79 function main(&$backRef,$menuItems,$table,$uid) {
80 global $BE_USER,$TCA,$LANG;
81
82 $localItems = array(); // Accumulation of local items.
83 $subname = t3lib_div::_GP('subname');
84
85 // Detecting menu level
86 // LEVEL: Primary menu.
87 if (!in_array('moreoptions', $backRef->disabledItems) && !$backRef->cmLevel) {
88 // Creating menu items here:
89 if ($backRef->editOK) {
90 $LL = $this->includeLL();
91
92 $localItems[]='spacer';
93 $localItems['moreoptions']=$backRef->linkItem(
94 $GLOBALS['LANG']->makeEntities($LANG->getLLL('label',$LL)),
95 $backRef->excludeIcon(''),
96 "top.loadTopMenu('".t3lib_div::linkThisScript()."&cmLevel=1&subname=moreoptions');return false;",
97 0,
98 1
99 );
100
101 if (!in_array('hide',$backRef->disabledItems) && is_array($TCA[$table]['ctrl']['enablecolumns']) && $TCA[$table]['ctrl']['enablecolumns']['disabled'])
102 $localItems['hide'] = $backRef->DB_hideUnhide($table,$backRef->rec,$TCA[$table]['ctrl']['enablecolumns']['disabled']);
103 if (!in_array('edit_access',$backRef->disabledItems) && is_array($TCA[$table]['ctrl']['enablecolumns']))
104 $localItems['edit_access'] = $backRef->DB_editAccess($table,$uid);
105 if (!in_array('edit_pageproperties',$backRef->disabledItems) && $table=='pages' && $backRef->editPageIconSet)
106 $localItems['edit_pageproperties'] = $backRef->DB_editPageProperties($uid);
107 }
108
109 // Find delete element among the input menu items and insert the local items just before that:
110 reset($menuItems);
111 $c=0;
112 $deleteFound = FALSE;
113 while(list($k)=each($menuItems)) {
114 $c++;
115 if (!strcmp($k,'delete')) {
116 $deleteFound = TRUE;
117 break;
118 }
119 }
120
121 if ($deleteFound) {
122 // .. subtract two... (delete item + its spacer element...)
123 $c-=2;
124 // and insert the items just before the delete element.
125 array_splice(
126 $menuItems,
127 $c,
128 0,
129 $localItems
130 );
131 } else { // If no delete item was found, then just merge in the items:
132 $menuItems=array_merge($menuItems,$localItems);
133 }
134 } elseif ($subname==='moreoptions') { // LEVEL: Secondary level of menus (activated by an item on the first level).
135 if ($backRef->editOK) { // If the page can be edited, then show this:
136 if (!in_array('move_wizard',$backRef->disabledItems) && ($table=='pages' || $table=='tt_content')) $localItems['move_wizard']=$backRef->DB_moveWizard($table,$uid,$backRef->rec);
137 if (!in_array('new_wizard',$backRef->disabledItems) && ($table=='pages' || $table=='tt_content')) $localItems['new_wizard']=$backRef->DB_newWizard($table,$uid,$backRef->rec);
138 if (!in_array('perms',$backRef->disabledItems) && $table=='pages' && $BE_USER->check('modules','web_perm')) $localItems['perms']=$backRef->DB_perms($table,$uid,$backRef->rec);
139 if (!in_array('db_list',$backRef->disabledItems) && $BE_USER->check('modules','web_list')) $localItems['db_list']=$backRef->DB_db_list($table,$uid,$backRef->rec);
140 }
141
142 // Temporary mount point item:
143 if ($table=='pages') {
144 $localItems['temp_mount_point'] = $backRef->DB_tempMountPoint($uid);
145 }
146
147 // Merge the locally made items into the current menu items passed to this function.
148 $menuItems = array_merge($menuItems,$localItems);
149 }
150 return $menuItems;
151 }
152
153 /**
154 * Include local lang file.
155 *
156 * @return array Local lang array.
157 */
158 function includeLL() {
159 global $LANG;
160
161 $LOCAL_LANG = $LANG->includeLLFile('EXT:extra_page_cm_options/locallang.php',FALSE);
162 return $LOCAL_LANG;
163 }
164 }
165
166 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/extra_page_cm_options/class.tx_extrapagecmoptions.php']) {
167 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/extra_page_cm_options/class.tx_extrapagecmoptions.php']);
168 }
169 ?>