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