summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc154
1 files changed, 126 insertions, 28 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc b/kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc
index 31efaea..e212970 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/admin_menu/admin_menu.inc
@@ -425,6 +425,7 @@ function admin_menu_links_icon() {
$links = array(
'#theme' => 'admin_menu_links',
+ '#wrapper_attributes' => array('id' => 'admin-menu-icon'),
'#weight' => -100,
);
$links['icon'] = array(
@@ -495,52 +496,47 @@ function admin_menu_links_icon() {
),
);
}
+
// Add link to toggle developer modules (performance).
$saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
$links['icon']['toggle-modules'] = array(
'#title' => isset($saved_state) ? t('Enable developer modules') : t('Disable developer modules'),
'#weight' => 88,
- '#access' => user_access('administer site configuration'),
+ '#access' => user_access('administer modules'),
'#href' => 'admin_menu/toggle-modules',
'#options' => array(
'query' => $destination + array('token' => drupal_get_token('admin_menu/toggle-modules')),
),
);
- // Add Devel module links.
+ // Add Devel module menu links.
if (module_exists('devel')) {
- // Add variable editor.
- $links['icon']['devel-variables'] = array(
- '#title' => t('Variable editor'),
- '#weight' => 20,
- '#access' => user_access('access devel information'),
- '#href' => 'devel/variable',
- );
+ $devel_tree = menu_build_tree('devel');
+ $devel_links = admin_menu_links_menu($devel_tree);
+ if (element_get_visible_children($devel_links)) {
+ $links['icon']['devel'] = array(
+ '#title' => t('Development'),
+ '#weight' => 30,
+ ) + $devel_links;
+ }
}
return $links;
}
/**
- * Build user/action links; mostly account information and links.
+ * Builds the account links.
*
* @see theme_admin_menu_links()
*/
-function admin_menu_links_user() {
+function admin_menu_links_account() {
$links = array(
'#theme' => 'admin_menu_links',
+ '#wrapper_attributes' => array('id' => 'admin-menu-account'),
'#weight' => 100,
);
- // Add link to show current authenticated/anonymous users.
- $links['user-counter'] = array(
- '#title' => admin_menu_get_user_count(),
- '#description' => t('Current anonymous / authenticated users'),
- '#weight' => -90,
- '#attributes' => array('class' => array('admin-menu-action', 'admin-menu-users')),
- '#href' => (user_access('administer users') ? 'admin/people/people' : 'user'),
- );
$links['account'] = array(
- '#title' => $GLOBALS['user']->name,
+ '#title' => format_username($GLOBALS['user']),
'#weight' => -99,
'#attributes' => array('class' => array('admin-menu-action', 'admin-menu-account')),
'#href' => 'user/' . $GLOBALS['user']->uid,
@@ -551,7 +547,6 @@ function admin_menu_links_user() {
'#attributes' => array('class' => array('admin-menu-action')),
'#href' => 'user/logout',
);
-
// Add Devel module switch user links.
$switch_links = module_invoke('devel', 'switch_user_list');
if (!empty($switch_links) && count($switch_links) > 1) {
@@ -567,7 +562,51 @@ function admin_menu_links_user() {
);
}
}
+ return $links;
+}
+/**
+ * Builds user counter.
+ *
+ * @see theme_admin_menu_links()
+ */
+function admin_menu_links_users() {
+ $links = array(
+ '#theme' => 'admin_menu_links',
+ '#wrapper_attributes' => array('id' => 'admin-menu-users'),
+ '#weight' => 150,
+ );
+ // Add link to show current authenticated/anonymous users.
+ $links['user-counter'] = array(
+ '#title' => admin_menu_get_user_count(),
+ '#description' => t('Current anonymous / authenticated users'),
+ '#weight' => -90,
+ '#attributes' => array('class' => array('admin-menu-action', 'admin-menu-users')),
+ '#href' => (user_access('administer users') ? 'admin/people/people' : 'user'),
+ );
+ return $links;
+}
+
+/**
+ * Build search widget.
+ *
+ * @see theme_admin_menu_links()
+ */
+function admin_menu_links_search() {
+ $links = array(
+ '#theme' => 'admin_menu_links',
+ '#wrapper_attributes' => array('id' => 'admin-menu-search'),
+ '#weight' => 180,
+ );
+ $links['search'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Search'),
+ '#title_display' => 'attribute',
+ '#attributes' => array(
+ 'placeholder' => t('Search'),
+ 'class' => array('admin-menu-search'),
+ ),
+ );
return $links;
}
@@ -584,20 +623,43 @@ function admin_menu_theme_settings() {
$form['admin_menu_position_fixed'] = array(
'#type' => 'checkbox',
'#title' => t('Keep menu at top of page'),
- '#default_value' => variable_get('admin_menu_position_fixed', 0),
+ '#default_value' => variable_get('admin_menu_position_fixed', 1),
'#description' => t('Displays the administration menu always at the top of the browser viewport (even when scrolling the page).'),
);
// @todo Re-confirm this with latest browser versions.
$form['admin_menu_position_fixed']['#description'] .= '<br /><strong>' . t('In some browsers, this setting may result in a malformed page, an invisible cursor, non-selectable elements in forms, or other issues.') . '</strong>';
- $form['admin_menu_cache_client'] = array(
- '#type' => 'checkbox',
- '#title' => t('Cache menu in client-side browser'),
- '#default_value' => variable_get('admin_menu_cache_client', 1),
+
+ $form['advanced'] = array(
+ '#type' => 'vertical_tabs',
+ '#title' => t('Advanced settings'),
);
+ $form['plugins'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Plugins'),
+ '#group' => 'advanced',
+ );
+ $form['plugins']['admin_menu_components'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Enabled components'),
+ '#options' => array(
+ 'admin_menu.icon' => t('Icon menu'),
+ 'admin_menu.menu' => t('Administration menu'),
+ 'admin_menu.search' => t('Search bar'),
+ 'admin_menu.users' => t('User counts'),
+ 'admin_menu.account' => t('Account links'),
+ ),
+ );
+ $form['plugins']['admin_menu_components']['#default_value'] = array_keys(array_filter(variable_get('admin_menu_components', $form['plugins']['admin_menu_components']['#options'])));
+
+ $process = element_info_property('checkboxes', '#process', array());
+ $form['plugins']['admin_menu_components']['#process'] = array_merge(array('admin_menu_settings_process_components'), $process);
+ $form['#attached']['js'][] = drupal_get_path('module', 'admin_menu') . '/admin_menu.admin.js';
+
$form['tweaks'] = array(
'#type' => 'fieldset',
- '#title' => t('Advanced settings'),
+ '#title' => t('System tweaks'),
+ '#group' => 'advanced',
);
$form['tweaks']['admin_menu_tweak_modules'] = array(
'#type' => 'checkbox',
@@ -625,6 +687,16 @@ function admin_menu_theme_settings() {
'#description' => t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes <code>tabs primary</code> and <code>tabs secondary</code>.'),
);
+ $form['performance'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Performance'),
+ '#group' => 'advanced',
+ );
+ $form['performance']['admin_menu_cache_client'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Cache menu in client-side browser'),
+ '#default_value' => variable_get('admin_menu_cache_client', 1),
+ );
// Fetch all available modules manually, since module_list() only returns
// currently enabled modules, which makes this setting pointless if developer
// modules are currently disabled.
@@ -638,7 +710,7 @@ function admin_menu_theme_settings() {
}
$devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
$devel_modules = array_intersect_key($all_modules, array_flip($devel_modules));
- $form['tweaks']['admin_menu_devel_modules_skip'] = array(
+ $form['performance']['admin_menu_devel_modules_skip'] = array(
'#type' => 'checkboxes',
'#title' => t('Developer modules to keep enabled'),
'#default_value' => variable_get('admin_menu_devel_modules_skip', array()),
@@ -653,6 +725,32 @@ function admin_menu_theme_settings() {
}
/**
+ * #process callback for component plugin form element in admin_menu_theme_settings().
+ */
+function admin_menu_settings_process_components($element) {
+ // Assign 'rel' attributes to all options to achieve a live preview.
+ // Unfortunately, #states relies on wrapping .form-wrapper classes, so it
+ // cannot be used here.
+ foreach ($element['#options'] as $key => $label) {
+ if (!isset($element[$key]['#attributes']['rel'])) {
+ $id = preg_replace('/[^a-z]/', '-', $key);
+ $element[$key]['#attributes']['rel'] = '#' . $id;
+ }
+ }
+ return $element;
+}
+
+/**
+ * Form validation handler for admin_menu_theme_settings().
+ */
+function admin_menu_theme_settings_validate(&$form, &$form_state) {
+ // Change the configured components to Boolean values.
+ foreach ($form_state['values']['admin_menu_components'] as $component => &$enabled) {
+ $enabled = (bool) $enabled;
+ }
+}
+
+/**
* Implementation of hook_form_FORM_ID_alter().
*
* Extends Devel module with Administration menu developer settings.