TYPO3 CMS  TYPO3_6-2
ExtraPageContextMenuOptions.php
Go to the documentation of this file.
1 <?php
3 
23 
34  public function main(&$backRef, $menuItems, $table, $uid) {
35  // Accumulation of local items.
36  $localItems = array();
37  $subname = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname');
38  // Detecting menu level
39  // LEVEL: Primary menu.
40  if (!in_array('moreoptions', $backRef->disabledItems) && !$backRef->cmLevel) {
41  // Creating menu items here:
42  if ($backRef->editOK) {
43  $localLanguage = $GLOBALS['LANG']->includeLLFile('EXT:extra_page_cm_options/locallang.xlf', FALSE);
44  $localItems[] = 'spacer';
45  $localItems['moreoptions'] = $backRef->linkItem(
46  $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('label', $localLanguage)),
47  $backRef->excludeIcon(''),
48  'top.loadTopMenu(\'' . \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript() . '&cmLevel=1&subname=moreoptions\');return false;',
49  0,
50  1
51  );
52  $menuItemHideUnhideAllowed = FALSE;
53  $hiddenField = '';
54  // Check if column for disabled is defined
55  if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) && isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) {
56  $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
57  if (
58  $hiddenField !== '' && !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
59  && (!empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
60  && $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $hiddenField))
61  ) {
62  $menuItemHideUnhideAllowed = TRUE;
63  }
64  }
65  if ($menuItemHideUnhideAllowed && !in_array('hide', $backRef->disabledItems)) {
66  $localItems['hide'] = $backRef->DB_hideUnhide($table, $backRef->rec, $hiddenField);
67  }
68  $anyEnableColumnsFieldAllowed = FALSE;
69  // Check if columns are defined
70  if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
71  $columnsToCheck = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
72  if ($table === 'pages' && !empty($columnsToCheck)) {
73  $columnsToCheck[] = 'extendToSubpages';
74  }
75  foreach ($columnsToCheck as $currentColumn) {
76  if (
77  isset($GLOBALS['TCA'][$table]['columns'][$currentColumn])
78  && (!empty($GLOBALS['TCA'][$table]['columns'][$currentColumn]['exclude'])
79  && $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $currentColumn))
80  ) {
81  $anyEnableColumnsFieldAllowed = TRUE;
82  }
83  }
84  }
85  if ($anyEnableColumnsFieldAllowed && !in_array('edit_access', $backRef->disabledItems)) {
86  $localItems['edit_access'] = $backRef->DB_editAccess($table, $uid);
87  }
88  if ($table === 'pages' && $backRef->editPageIconSet && !in_array('edit_pageproperties', $backRef->disabledItems)) {
89  $localItems['edit_pageproperties'] = $backRef->DB_editPageProperties($uid);
90  }
91  }
92  // Find delete element among the input menu items and insert the local items just before that:
93  $c = 0;
94  $deleteFound = FALSE;
95  foreach ($menuItems as $key => $value) {
96  $c++;
97  if ($key === 'delete') {
98  $deleteFound = TRUE;
99  break;
100  }
101  }
102  if ($deleteFound) {
103  // .. subtract two... (delete item + its spacer element...)
104  $c -= 2;
105  // and insert the items just before the delete element.
106  array_splice($menuItems, $c, 0, $localItems);
107  } else {
108  $menuItems = array_merge($menuItems, $localItems);
109  }
110  } elseif ($subname === 'moreoptions') {
111  // If the page can be edited, then show this:
112  if ($backRef->editOK) {
113  if (($table === 'pages' || $table === 'tt_content') && !in_array('move_wizard', $backRef->disabledItems)) {
114  $localItems['move_wizard'] = $backRef->DB_moveWizard($table, $uid, $backRef->rec);
115  }
116  if (($table === 'pages' || $table === 'tt_content') && !in_array('new_wizard', $backRef->disabledItems)) {
117  $localItems['new_wizard'] = $backRef->DB_newWizard($table, $uid, $backRef->rec);
118  }
119  if ($table === 'pages' && !in_array('perms', $backRef->disabledItems) && $GLOBALS['BE_USER']->check('modules', 'web_perm')) {
120  $localItems['perms'] = $backRef->DB_perms($table, $uid, $backRef->rec);
121  }
122  if (!in_array('db_list', $backRef->disabledItems) && $GLOBALS['BE_USER']->check('modules', 'web_list')) {
123  $localItems['db_list'] = $backRef->DB_db_list($table, $uid, $backRef->rec);
124  }
125  }
126  // Temporary mount point item:
127  if ($table === 'pages') {
128  $localItems['temp_mount_point'] = $backRef->DB_tempMountPoint($uid);
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 }
$uid
Definition: server.php:36
static linkThisScript(array $getParams=array())
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]