[BUGFIX] Fix PHP warning in EXT:beuser
[Packages/TYPO3.CMS.git] / typo3 / sysext / extra_page_cm_options / class.tx_extrapagecmoptions.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-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 * 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 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34
35 /**
36 * Class, adding extra context menu options
37 *
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 * @package TYPO3
40 * @subpackage tx_extrapagecmoptions
41 */
42 class tx_extrapagecmoptions {
43
44 /**
45 * Adding various standard options to the context menu.
46 * This includes both first and second level.
47 *
48 * @param object $backRef The calling object. Value by reference.
49 * @param array $menuItems Array with the currently collected menu items to show.
50 * @param string $table Table name of clicked item.
51 * @param integer $uid UID of clicked item.
52 * @return array Modified $menuItems array
53 */
54 function main(&$backRef, $menuItems, $table, $uid) {
55 // Accumulation of local items.
56 $localItems = array();
57 $subname = t3lib_div::_GP('subname');
58
59 // Detecting menu level
60 // LEVEL: Primary menu.
61 if (!in_array('moreoptions', $backRef->disabledItems) && !$backRef->cmLevel) {
62 // Creating menu items here:
63 if ($backRef->editOK) {
64 $LL = $this->includeLL();
65
66 $localItems[]='spacer';
67 $localItems['moreoptions']=$backRef->linkItem(
68 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('label', $LL)),
69 $backRef->excludeIcon(''),
70 "top.loadTopMenu('".t3lib_div::linkThisScript()."&cmLevel=1&subname=moreoptions');return false;",
71 0,
72 1
73 );
74
75 if (!in_array('hide', $backRef->disabledItems) && is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) && $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']) {
76 $localItems['hide'] = $backRef->DB_hideUnhide($table, $backRef->rec, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']);
77 }
78
79 if (!in_array('edit_access', $backRef->disabledItems) && is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
80 $localItems['edit_access'] = $backRef->DB_editAccess($table, $uid);
81 }
82
83 if (!in_array('edit_pageproperties', $backRef->disabledItems) && $table == 'pages' && $backRef->editPageIconSet) {
84 $localItems['edit_pageproperties'] = $backRef->DB_editPageProperties($uid);
85 }
86
87 }
88
89 // Find delete element among the input menu items and insert the local items just before that:
90 $c = 0;
91 $deleteFound = FALSE;
92 foreach ($menuItems as $k => $value) {
93 $c++;
94 if (!strcmp($k, 'delete')) {
95 $deleteFound = TRUE;
96 break;
97 }
98 }
99
100 if ($deleteFound) {
101 // .. subtract two... (delete item + its spacer element...)
102 $c -= 2;
103 // and insert the items just before the delete element.
104 array_splice(
105 $menuItems,
106 $c,
107 0,
108 $localItems
109 );
110 // If no delete item was found, then just merge in the items:
111 } else {
112 $menuItems = array_merge($menuItems, $localItems);
113 }
114 // LEVEL: Secondary level of menus (activated by an item on the first level).
115 } elseif ($subname === 'moreoptions') {
116 // If the page can be edited, then show this:
117 if ($backRef->editOK) {
118 if (!in_array('move_wizard', $backRef->disabledItems) && ($table == 'pages' || $table == 'tt_content')) {
119 $localItems['move_wizard']=$backRef->DB_moveWizard($table, $uid, $backRef->rec);
120 }
121 if (!in_array('new_wizard', $backRef->disabledItems) && ($table == 'pages' || $table == 'tt_content')) {
122 $localItems['new_wizard']=$backRef->DB_newWizard($table, $uid, $backRef->rec);
123 }
124 if (!in_array('perms', $backRef->disabledItems) && $table == 'pages' && $GLOBALS['BE_USER']->check('modules', 'web_perm')) {
125 $localItems['perms']=$backRef->DB_perms($table, $uid, $backRef->rec);
126 }
127 if (!in_array('db_list', $backRef->disabledItems) && $GLOBALS['BE_USER']->check('modules', 'web_list')) {
128 $localItems['db_list']=$backRef->DB_db_list($table, $uid, $backRef->rec);
129 }
130 }
131
132 // Temporary mount point item:
133 if ($table == 'pages') {
134 $localItems['temp_mount_point'] = $backRef->DB_tempMountPoint($uid);
135 }
136
137 // Merge the locally made items into the current menu items passed to this function.
138 $menuItems = array_merge($menuItems, $localItems);
139 }
140 return $menuItems;
141 }
142
143 /**
144 * Include local lang file.
145 *
146 * @return array Local lang array.
147 */
148 function includeLL() {
149 $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile('EXT:extra_page_cm_options/locallang.php', FALSE);
150 return $LOCAL_LANG;
151 }
152 }
153 ?>