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