本文整理汇总了PHP中menu_get_menus函数的典型用法代码示例。如果您正苦于以下问题:PHP menu_get_menus函数的具体用法?PHP menu_get_menus怎么用?PHP menu_get_menus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了menu_get_menus函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rootcandy_settings
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
* array An array of saved settings for this theme.
* @return
* array A form array.
*/
function rootcandy_settings($saved_settings, $subtheme_defaults = array())
{
// Get the default values from the .info file.
$themes = list_themes();
$defaults = $themes['rootcandy']->info['settings'];
// Allow a subtheme to override the default values.
$defaults = array_merge($defaults, $subtheme_defaults);
// Merge the saved variables and their default values.
$settings = array_merge($defaults, $saved_settings);
// Create the form widgets using Forms API
$form['header'] = array('#type' => 'fieldset', '#title' => t('Header'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['header']['rootcandy_header_display'] = array('#type' => 'checkbox', '#title' => t('Disable header'), '#default_value' => $settings['rootcandy_header_display']);
$form['dashboard'] = array('#type' => 'fieldset', '#title' => t('Dashboard'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['dashboard']['rootcandy_dashboard_display'] = array('#type' => 'checkbox', '#title' => t('Disable dashboard'), '#default_value' => $settings['rootcandy_dashboard_display']);
$form['dashboard']['rootcandy_dashboard_help'] = array('#type' => 'select', '#options' => array('left' => t('Left'), 'right' => t('Right'), 'content' => t('Content')), '#title' => t('Help box position'), '#default_value' => $settings['rootcandy_dashboard_help']);
$form['dashboard']['rootcandy_dashboard_messages'] = array('#type' => 'select', '#options' => array('left' => t('Left'), 'right' => t('Right'), 'content' => t('Content')), '#title' => t('Messages box position'), '#default_value' => $settings['rootcandy_dashboard_messages']);
$form['dashboard']['rootcandy_dashboard_content_display'] = array('#type' => 'checkbox', '#title' => t('Disable content on a dashboard'), '#default_value' => $settings['rootcandy_dashboard_content_display']);
$form['navigation'] = array('#type' => 'fieldset', '#title' => t('Navigation'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
// Create the form widgets using Forms API
$form['navigation']['rootcandy_navigation_icons'] = array('#type' => 'checkbox', '#title' => t('Disable icons for main navigation'), '#default_value' => $settings['rootcandy_navigation_icons']);
$form['navigation']['rootcandy_navigation_icons_size'] = array('#type' => 'select', '#options' => array(16 => 16, 24 => 24, 32 => 32), '#title' => t('Set icons size for main navigation'), '#default_value' => $settings['rootcandy_navigation_icons_size']);
$form['navigation']['nav-by-role'] = array('#type' => 'fieldset', '#title' => t('Menu source by role'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$primary_options = array(NULL => t('None'), '_rootcandy_default_navigation' => t('default navigation'));
$primary_options = array_merge($primary_options, menu_get_menus());
$roles = user_roles(FALSE);
foreach ($roles as $rid => $role) {
$form['navigation']['nav-by-role']['rootcandy_navigation_source_' . $rid] = array('#type' => 'select', '#title' => t('@role navigation', array('@role' => $role)), '#default_value' => $settings['rootcandy_navigation_source_' . $rid], '#options' => $primary_options, '#tree' => FALSE, '#description' => t('Select what should be displayed as the navigation menu for role @role.', array('@role' => $role)));
}
$form['navigation']['custom-icons'] = array('#type' => 'fieldset', '#title' => t('Custom icons'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['navigation']['custom-icons']['rootcandy_navigation_custom_icons'] = array('#type' => 'textarea', '#title' => t('Custom icons'), '#default_value' => $settings['rootcandy_navigation_custom_icons'], '#description' => t('Format: menu href|icon path (relative to drupal root) - one item per row. eg. admin/build|files/myicons/admin-build.png'), '#required' => FALSE);
// Return the additional form widgets
return $form;
}
示例2: rootcandy_form_system_theme_settings_alter
/**
* Implements hook_form_FORM_ID_alter().
*
* @param $form
* The form.
* @param $form_state
* The form state.
*/
function rootcandy_form_system_theme_settings_alter(&$form, &$form_state)
{
global $custom_theme;
$custom_theme = 'rootcandy';
// Create the form widgets using Forms API
$form['header'] = array('#type' => 'fieldset', '#title' => t('Header'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['header']['rootcandy_header_display'] = array('#type' => 'checkbox', '#title' => t('Disable header'), '#default_value' => theme_get_setting('rootcandy_header_display'));
$form['header']['rootcandy_header_display_overlay'] = array('#type' => 'checkbox', '#title' => t('Disable header in overlay'), '#default_value' => theme_get_setting('rootcandy_header_display_overlay'));
$form['header']['rootcandy_hide_panel'] = array('#type' => 'checkbox', '#title' => t('Disable sliding panel'), '#default_value' => theme_get_setting('rootcandy_hide_panel'));
$form['header']['rootcandy_hide_panel_overlay'] = array('#type' => 'checkbox', '#title' => t('Disable sliding panel in overlay'), '#default_value' => theme_get_setting('rootcandy_hide_panel_overlay'));
$form['navigation'] = array('#type' => 'fieldset', '#title' => t('Navigation'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
// Create the form widgets using Forms API
$form['navigation']['rootcandy_navigation_icons'] = array('#type' => 'checkbox', '#title' => t('Disable icons for main navigation'), '#default_value' => theme_get_setting('rootcandy_navigation_icons'));
$form['navigation']['rootcandy_navigation_icons_size'] = array('#type' => 'select', '#options' => array(16 => 16, 24 => 24, 32 => 32), '#title' => t('Set icons size for main navigation'), '#default_value' => theme_get_setting('rootcandy_navigation_icons_size'));
$menu_options = array_merge(array('_rootcandy_default_navigation' => t('default navigation')), menu_get_menus());
if (!($rootcandy_navigation_source_admin = theme_get_setting('rootcandy_navigation_source_admin'))) {
$rootcandy_navigation_source_admin = '_rootcandy_default_navigation';
}
$form['navigation']['rootcandy_superuser_menu'] = array('#type' => 'fieldset', '#title' => t('Super user (uid 1) menu'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['navigation']['rootcandy_superuser_menu']['rootcandy_navigation_source_admin'] = array('#type' => 'select', '#default_value' => theme_get_setting('rootcandy_navigation_source_admin'), '#options' => $menu_options, '#tree' => FALSE);
$primary_options = array(NULL => t('None'));
$primary_options = array_merge($primary_options, $menu_options);
$form['navigation']['role-weights'] = array('#type' => 'fieldset', '#title' => t('Menu by role and weights'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => TRUE);
// roles setting
$roles = user_roles(FALSE);
$max_weight = 0;
foreach ($roles as $rid => $role) {
$form['navigation']['role-weights']['group-' . $rid] = array('#type' => 'fieldset', '#title' => $role, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['navigation']['role-weights']['group-' . $rid]['rootcandy_navigation_source_' . $rid] = array('#type' => 'select', '#default_value' => theme_get_setting('rootcandy_navigation_source_' . $rid), '#options' => $primary_options, '#tree' => FALSE);
// TODO: calculate defaults - change to select
$form['navigation']['role-weights']['group-' . $rid]['role-weight-' . $rid] = array('#type' => 'textfield', '#title' => t('Weight'), '#default_value' => theme_get_setting('role-weight-' . $rid), '#size' => 4, '#maxlength' => 4);
}
// Return the additional form widgets
return $form;
}
示例3: platon_form_system_theme_settings_alter
/**
* Implements hook_form_FORM_ID_alter() for system_theme_settings().
*/
function platon_form_system_theme_settings_alter(&$form, $form_state)
{
$path = drupal_get_path('theme', 'platon');
// If using a different Admin theme, we get a Fatal Error. Include the
// template.php file.
require_once DRUPAL_ROOT . "/{$path}/template.php";
$form['#attached'] = array('js' => array('//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js' => array('type' => 'file', 'cache' => FALSE), "{$path}/js/platon.theme-settings.js" => array('type' => 'file', 'cache' => FALSE)));
// Deactivate irrelevant settings.
foreach (array('toggle_name', 'toggle_slogan', 'toggle_favicon', 'toggle_main_menu', 'toggle_secondary_menu') as $option) {
$form['theme_settings'][$option]['#access'] = FALSE;
}
if (module_exists('color')) {
// Add some descriptions to clarify what each color is used for.
foreach (array('white' => t("e.g. main menu active menu link background"), 'very_light_gray' => t("e.g. body background color"), 'light_gray' => t('e.g content background color'), 'medium_gray' => t('e.g. title background color, table background color'), 'dark_gray' => t('e.g. forum tools background'), 'light_blue' => t('e.g. link hover color, tabs background, fieldset titles'), 'dark_blue' => t('e.g. link color, tabs active/hover background color'), 'deep_blue' => t('e.g. header background color, footer background color'), 'leaf_green' => t('e.g. form submit buttons, local actions'), 'blood_red' => t('e.g. form delete buttons')) as $color => $description) {
$form['color']['palette'][$color]['#description'] = $description;
}
// Hide the base and link ones. They're just there to prevent Notices.
$form['color']['palette']['base']['#type'] = 'hidden';
$form['color']['palette']['link']['#type'] = 'hidden';
// Make color section collapsible.
$form['color']['#collapsible'] = TRUE;
$form['color']['#collapsed'] = TRUE;
if (isset($form['#submit']) && !in_array('platon_form_system_theme_settings_alter_color_submit', $form['#submit'])) {
$form['#submit'][] = 'platon_form_system_theme_settings_alter_color_submit';
}
}
// Header image settings.
$form['platon_header_settings'] = array('#type' => 'fieldset', '#title' => t("Header background"));
$form['platon_header_settings']['platon_use_header_background'] = array('#type' => 'checkbox', '#title' => t("Use another image for the header background"), '#description' => t("Check here if you want the theme to use a custom image for the header background."), '#default_value' => theme_get_setting('platon_use_header_background'));
$form['platon_header_settings']['platon_header_image_path'] = array('#type' => 'textfield', '#title' => t("The path to the header background image."), '#description' => t("The path to the image file you would like to use as your custom header background (relative to sites/default/files). The suggested size for the header background is 3000x134."), '#default_value' => theme_get_setting('platon_header_image_path'), '#states' => array('invisible' => array('input[name="platon_use_header_background"]' => array('checked' => FALSE))));
$form['platon_header_settings']['platon_header_image_upload'] = array('#type' => 'file', '#title' => t("Upload an image"), '#description' => t("If you don't have direct file access to the server, use this field to upload your header background image."), '#states' => array('invisible' => array('input[name="platon_use_header_background"]' => array('checked' => FALSE))));
// Home page settings.
$form['platon_home_page_settings'] = array('#type' => 'fieldset', '#title' => t("Homepage settings"));
$form['platon_home_page_settings']['platon_use_home_page_markup'] = array('#type' => 'checkbox', '#title' => t("Use a different homepage for anonymous users."), '#description' => t("Check here if you want the theme to use a custom page for users that are not logged in."), '#default_value' => theme_get_setting('platon_use_home_page_markup'));
$settings = theme_get_setting('platon_home_page_markup');
$form['platon_home_page_settings']['platon_home_page_markup_wrapper'] = array('#type' => 'fieldset', '#states' => array('invisible' => array('input[name="platon_use_home_page_markup"]' => array('checked' => FALSE))), 'platon_home_page_markup' => array('#type' => 'text_format', '#base_type' => 'textarea', '#title' => t("Home page content"), '#description' => t("Set the content for the home page. This will be used for users that are not logged in."), '#format' => !empty($settings['format']) ? $settings['format'] : filter_default_format(), '#default_value' => !empty($settings['value']) ? $settings['value'] : ''));
$form['platon_home_page_settings']['platon_use_home_page_background'] = array('#type' => 'checkbox', '#title' => t("Use an image for the home page background"), '#description' => t("Check here if you want the theme to use a custom image for the homepage background."), '#default_value' => theme_get_setting('platon_use_home_page_background'));
$form['platon_home_page_settings']['platon_home_page_image_path'] = array('#type' => 'textfield', '#title' => t("The path to the home page background image."), '#description' => t("The path to the image file you would like to use as your custom home page background (relative to sites/default/files)."), '#default_value' => theme_get_setting('platon_home_page_image_path'), '#states' => array('invisible' => array('input[name="platon_use_home_page_background"]' => array('checked' => FALSE))));
$form['platon_home_page_settings']['platon_home_page_image_upload'] = array('#type' => 'file', '#title' => t("Upload an image"), '#description' => t("If you don't have direct file access to the server, use this field to upload your background image."), '#states' => array('invisible' => array('input[name="platon_use_home_page_background"]' => array('checked' => FALSE))));
// Main menu settings.
if (module_exists('menu')) {
$form['platon_menu_settings'] = array('#type' => 'fieldset', '#title' => t("Menu settings"));
$form['platon_menu_settings']['platon_menu_source'] = array('#type' => 'select', '#title' => t("Main menu source"), '#options' => array(0 => t("None")) + menu_get_menus(), '#description' => t("The menu source to use for the tile navigation. If 'none', Platon will use a default list of tiles."), '#default_value' => theme_get_setting('platon_menu_source'));
$form['platon_menu_settings']['platon_menu_show_for_anonymous'] = array('#type' => 'checkbox', '#title' => t("Show menu for anonymous users"), '#description' => t("Show the main menu for users that are not logged in. Only links that users have access to will show up."), '#default_value' => theme_get_setting('platon_menu_show_for_anonymous'));
}
// CSS overrides.
$form['platon_css_settings'] = array('#type' => 'fieldset', '#title' => t("CSS overrides"), '#collapsible' => TRUE, '#collapsed' => TRUE);
$css_content = _platon_get_css_override_file_content();
$form['platon_css_settings']['platon_css_override_content'] = array('#type' => 'textarea', '#title' => t("CSS overrides"), '#description' => t("You can write CSS rules here. They will be stored in a CSS file in your public files directory. Change it's content to alter the display of your site."), '#default_value' => $css_content);
$form['platon_css_settings']['platon_css_override_fid'] = array('#type' => 'value', '#value' => _platon_get_css_override_file());
if (isset($form['#validate']) && !in_array('platon_form_system_theme_settings_alter_validate', $form['#validate'])) {
$form['#validate'][] = 'platon_form_system_theme_settings_alter_validate';
}
if (isset($form['#submit']) && !in_array('platon_form_system_theme_settings_alter_submit', $form['#submit'])) {
array_unshift($form['#submit'], 'platon_form_system_theme_settings_alter_submit');
}
$form['platon_group_style'] = array('#type' => 'checkbox', '#title' => t("Platon group style"), '#description' => t("Check here if you want the new group style, left block with lessons"), '#default_value' => variable_get('platon_group_style', 1));
}
示例4: settings_form
/**
* Plugin configuration form. Let user choose which menus he wants
* to print in the main topbar.
*/
function settings_form(&$theme_settings_form = array())
{
$form['menu_left'] = array('#type' => 'select', '#title' => 'Left menu', '#options' => array('' => '<none>') + menu_get_menus(), '#default_value' => theme_plugin_get_setting(__CLASS__, 'menu_left', 'main-menu'));
$form['menu_right'] = array('#type' => 'select', '#title' => 'Right menu', '#options' => array('' => '<none>') + menu_get_menus(), '#default_value' => theme_plugin_get_setting(__CLASS__, 'menu_right', 'user-menu'));
$form['sticky'] = array('#type' => 'checkbox', '#title' => 'Make topbar sticky at the top of the page', '#default_value' => theme_plugin_get_setting(__CLASS__, 'sticky'));
$form['contain_to_grid'] = array('#type' => 'checkbox', '#title' => 'Set to grid width instead of full page width', '#default_value' => theme_plugin_get_setting(__CLASS__, 'contain_to_grid'));
$form['hide_site_name'] = array('#type' => 'checkbox', '#title' => 'Hide the site name displaying by default at the left of the topbar', '#default_value' => theme_plugin_get_setting(__CLASS__, 'hide_site_name'));
return $form;
}
示例5: scsmetronic_form_system_theme_settings_alter
/**
* Allow themes to alter the theme-specific settings form.
*
* With this hook, themes can alter the theme-specific settings form in any way
* allowable by Drupal's Form API, such as adding form elements, changing
* default values and removing form elements. See the Form API documentation on
* api.drupal.org for detailed information.
*
* Note that the base theme's form alterations will be run before any sub-theme
* alterations.
*
* @param $form
* Nested array of form elements that comprise the form.
* @param $form_state
* A keyed array containing the current state of the form.
*/
function scsmetronic_form_system_theme_settings_alter(&$form, &$form_state)
{
$form['scsmetronic_theme_settings'] = array('#type' => 'fieldset', '#title' => t('Metronic Theme Settings'));
$form['scsmetronic_theme_settings']['theme_header'] = array('#type' => 'radios', '#title' => t('Header'), '#options' => array('default' => t('Default'), 'fixed' => t('Fixed')), '#default_value' => theme_get_setting('theme_header'), '#description' => t('Specify whether the header will be fixed to the top on scroll of page'));
$form['scsmetronic_theme_settings']['theme_footer'] = array('#type' => 'radios', '#title' => t('Footer'), '#options' => array('default' => t('Default'), 'fixed' => t('Fixed')), '#default_value' => theme_get_setting('theme_footer'), '#description' => t('Specify whether the footer will be fixed to the bottom on scroll of page'));
$form['scsmetronic_theme_settings']['theme_sidebar'] = array('#type' => 'radios', '#title' => t('Sidebar'), '#options' => array('default' => t('Default'), 'fixed' => t('Fixed'), 'closed' => t('Closed')), '#default_value' => theme_get_setting('theme_sidebar'), '#description' => t('Specify whether the sidebar will be fixed, closed to the left on scroll of page'));
$form['scsmetronic_theme_settings']['theme_right_sidebar'] = array('#type' => 'radios', '#title' => t('Right Sidebar'), '#options' => array('default' => t('Default'), 'fixed' => t('Fixed'), 'closed' => t('Closed')), '#default_value' => theme_get_setting('theme_right_sidebar'), '#description' => t('Specify whether the right sidebar will be fixed, closed to the left on scroll of page'));
$menus = menu_get_menus();
$form['scsmetronic_theme_settings']['theme_main_menu'] = array('#type' => 'select', '#options' => $menus, '#title' => t('Select menu to show as Main Menu'), '#default_value' => theme_get_setting('theme_main_menu'), '#description' => t(''), '#empty_option' => t('Select'), '#empty_value' => 0);
$form['scsmetronic_theme_settings']['theme_modal'] = array('#type' => 'textarea', '#title' => t('Launch Modal'), '#description' => t('Enter the one URL per line that needs must be launched in modal frame'), '#default_value' => theme_get_setting('theme_modal'));
}
示例6: lemon_preprocess_page
/**
* Override or insert variables into the page template.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("page" in this case.)
*/
function lemon_preprocess_page(&$variables, $hook)
{
// Find the title of the menu used by the secondary links.
$secondary_links = variable_get('menu_secondary_links_source', 'user-menu');
if ($secondary_links) {
$menus = function_exists('menu_get_menus') ? menu_get_menus() : menu_list_system_menus();
$variables['secondary_menu_heading'] = $menus[$secondary_links];
} else {
$variables['secondary_menu_heading'] = '';
}
}
示例7: micah_preprocess_page
function micah_preprocess_page(&$vars, $hook)
{
//get all menu's
$menus = array();
$menus = menu_get_menus($all = TRUE);
//create var for every menu so we can use it in our page.tpl.php
foreach ($menus as $key => $value) {
$var = str_replace('-', '_', $key);
$vars[$var] = menu_tree($key);
}
// $vars['header_image'] = file_create_url($vars['node']->field_image['und'][0]['uri']);
}
示例8: build
public function build($form, &$form_state)
{
$form['type'] = array('#type' => 'select', '#title' => t('Type'), '#options' => array('wildcard' => t('Wildcard'), 'regex' => t('Regular Expression')), '#default_value' => 'wildcard');
$form['path'] = array('#type' => 'textfield', '#title' => t('Path'), '#description' => t('Depending on the type selected, either a wildcard notation path or a regex statement.'), '#default_value' => '', '#required' => true);
// Generate a list of menus.
// $menus = menu_get_menus();
// $menu_options = array();
// foreach ($menus as $machine_name => $name) {
// $menu_options[$name] = menu_tree_all_data($machine_name);
// }
$form['mlid'] = array('#type' => 'select', '#title' => t('Menu Link'), '#description' => t('The menu link to associate the pattern with.'), '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)), '#required' => true);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Save');
$this->loadExisting($form, $form_state);
return $form;
}
示例9: build_form
function build_form($form, &$form_state) {
$style_options = views_fetch_plugin_names('style', 'normal', array($this->base_table));
$feed_row_options = views_fetch_plugin_names('row', 'feed', array($this->base_table));
$path_prefix = url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=');
// Add filters and sorts which apply to the view as a whole.
$this->build_filters($form, $form_state);
$this->build_sorts($form, $form_state);
$form['displays']['page'] = array(
'#type' => 'fieldset',
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),),
'#tree' => TRUE,
);
$form['displays']['page']['create'] = array(
'#title' => t('Create a page'),
'#type' => 'checkbox',
'#attributes' => array('class' => array('strong')),
'#default_value' => TRUE,
'#id' => 'edit-page-create',
);
// All options for the page display are included in this container so they
// can be hidden en masse when the "Create a page" checkbox is unchecked.
$form['displays']['page']['options'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('options-set'),),
'#dependency' => array(
'edit-page-create' => array(1),
),
'#pre_render' => array('ctools_dependent_pre_render'),
'#prefix' => '<div><div id="edit-page-wrapper">',
'#suffix' => '</div></div>',
'#parents' => array('page'),
);
$form['displays']['page']['options']['title'] = array(
'#title' => t('Page title'),
'#type' => 'textfield',
);
$form['displays']['page']['options']['path'] = array(
'#title' => t('Path'),
'#type' => 'textfield',
'#field_prefix' => $path_prefix,
);
$form['displays']['page']['options']['style'] = array(
'#type' => 'fieldset',
'#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')),
);
// Create the dropdown for choosing the display format.
$form['displays']['page']['options']['style']['style_plugin'] = array(
'#title' => t('Display format'),
'#help_topic' => 'style',
'#type' => 'select',
'#options' => $style_options,
);
$style_form = &$form['displays']['page']['options']['style'];
$style_form['style_plugin']['#default_value'] = views_ui_get_selected($form_state, array('page', 'style', 'style_plugin'), 'default', $style_form['style_plugin']);
// Changing this dropdown updates $form['displays']['page']['options'] via
// AJAX.
views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'page', 'options'));
$this->build_form_style($form, $form_state, 'page');
$form['displays']['page']['options']['items_per_page'] = array(
'#title' => t('Items per page'),
'#type' => 'textfield',
'#default_value' => '10',
'#size' => 5,
'#element_validate' => array('_element_validate_integer_positive'),
);
$form['displays']['page']['options']['link'] = array(
'#title' => t('Create a menu link'),
'#type' => 'checkbox',
'#id' => 'edit-page-link',
);
$form['displays']['page']['options']['link_properties'] = array(
'#type' => 'container',
'#dependency' => array(
'edit-page-link' => array(1),
),
'#pre_render' => array('ctools_dependent_pre_render'),
'#prefix' => '<div id="edit-page-link-properties-wrapper">',
'#suffix' => '</div>',
);
if (module_exists('menu')) {
$menu_options = menu_get_menus();
}
else {
// These are not yet translated.
$menu_options = menu_list_system_menus();
foreach ($menu_options as $name => $title) {
$menu_options[$name] = t($title);
}
}
$form['displays']['page']['options']['link_properties']['menu_name'] = array(
'#title' => t('Menu'),
'#type' => 'select',
'#options' => $menu_options,
);
//.........这里部分代码省略.........
示例10: clf_preprocess_page
/**
* Override or insert variables into the page template.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("page" in this case.)
*/
function clf_preprocess_page(&$variables, $hook)
{
if (isset($variables['node']->type)) {
$nodetype = $variables['node']->type;
$vars['theme_hook_suggestions'][] = 'page__' . $nodetype;
}
$variables['main_menu'] = menu_main_menu();
// Find the title of the menu used by the secondary links.
$secondary_links = variable_get('menu_secondary_links_source', 'user-menu');
if ($secondary_links) {
$menus = function_exists('menu_get_menus') ? menu_get_menus() : menu_list_system_menus();
$variables['secondary_menu_heading'] = $menus[$secondary_links];
} else {
$variables['secondary_menu_heading'] = '';
}
}
示例11: getAllIdentifiers
/**
* Overrides Drupal\configuration\Config\Configuration::getAllIdentifiers().
*/
public static function getAllIdentifiers($component)
{
global $menu_admin;
// Need to set this to TRUE in order to get menu links that the
// current user may not have access to (i.e. user/login)
$menu_admin = TRUE;
// This is intentionally to get always the same number of menus for each
// user that can manage configurations.
global $user;
$current_user = $user;
// Run the next line as administrator.
$user = user_load(1);
$menu_links = menu_parent_options(menu_get_menus(), array('mlid' => 0));
// Back to the previous user.
$user = $current_user;
$options = array();
foreach ($menu_links as $key => $name) {
list($menu_name, $mlid) = explode(':', $key, 2);
if ($mlid != 0) {
$link = menu_link_load($mlid);
$identifier = sha1(str_replace('-', '_', $link['menu_name']) . ':' . $link['link_path']);
$options[$identifier] = "{$menu_name}: {$name}";
}
}
$menu_admin = FALSE;
return $options;
}
示例12: osha_add_menu_position_rules
/**
* Add menu position rules for publication content type.
*/
function osha_add_menu_position_rules()
{
if (module_exists('menu_position') && module_load_include('inc', 'menu_position', 'menu_position.admin')) {
drupal_set_message('Create menu position rules ...');
// Config menu_position contrib module.
variable_set('menu_position_active_link_display', 'parent');
$options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
$publications_menu = array_search('------ Publications', $options);
$form_state = array('values' => array('admin_title' => 'Publications Menu Rule', 'plid' => $publications_menu !== NULL ? $publications_menu : 'main-menu:0', 'content_type' => array('publication' => 'publication'), 'op' => 'Save'));
drupal_form_submit('menu_position_add_rule_form', $form_state);
/* disabled temporarily for release branch
$press_menu_entry = array_search('------ Press room', $options);
$form_state = array(
'values' => array(
'admin_title' => 'Press room Menu Rule',
'plid' => $press_menu_entry !== NULL ? $press_menu_entry : 'main-menu:0',
'content_type' => array('press_release' => 'press_release'),
'op' => 'Save',
),
);
*/
drupal_form_submit('menu_position_add_rule_form', $form_state);
//menu position rule for Directive
$directive_menu_entry = array_search('------ EU directives', $options);
$form_state = array('values' => array('admin_title' => 'Directive Menu Rule', 'plid' => $directive_menu_entry !== NULL ? $directive_menu_entry : 'main-menu:0', 'pages' => 'legislation/directives/*' . PHP_EOL . 'legislation/directive/*', 'op' => 'Save'));
drupal_form_submit('menu_position_add_rule_form', $form_state);
//menu position rule for Guideline
$guideline_menu_entry = array_search('------ EU guidelines', $options);
$form_state = array('values' => array('admin_title' => 'Guideline Menu Rule', 'plid' => $guideline_menu_entry !== NULL ? $guideline_menu_entry : 'main-menu:0', 'pages' => 'legislation/guidelines/*', 'op' => 'Save'));
drupal_form_submit('menu_position_add_rule_form', $form_state);
}
}
示例13: rootcandy_form_system_theme_settings_alter
/**
* Implements hook_form_FORM_ID_alter().
*
* @param $form
* The form.
* @param $form_state
* The form state.
*/
function rootcandy_form_system_theme_settings_alter(&$form, &$form_state) {
// Create the form widgets using Forms API
$form['header'] = array(
'#type' => 'fieldset',
'#title' => t('Header'),
'#weight' => 1,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['header']['rootcandy_header_display'] = array(
'#type' => 'checkbox',
'#title' => t('Disable header'),
'#default_value' => theme_get_setting('rootcandy_header_display'),
);
$form['header']['rootcandy_hide_panel'] = array(
'#type' => 'checkbox',
'#title' => t('Disable sliding panel'),
'#default_value' => theme_get_setting('rootcandy_hide_panel'),
);
$form['navigation'] = array(
'#type' => 'fieldset',
'#title' => t('Navigation'),
'#weight' => 1,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Create the form widgets using Forms API
$form['navigation']['rootcandy_navigation_icons'] = array(
'#type' => 'checkbox',
'#title' => t('Disable icons for main navigation'),
'#default_value' => theme_get_setting('rootcandy_navigation_icons'),
);
$form['navigation']['rootcandy_navigation_icons_size'] = array(
'#type' => 'select',
'#options' => array(16 => 16, 24 => 24, 32 => 32),
'#title' => t('Set icons size for main navigation'),
'#default_value' => theme_get_setting('rootcandy_navigation_icons_size'),
);
$menu_options = array_merge(array('_rootcandy_default_navigation' => t('default navigation')), menu_get_menus());
if (!$rootcandy_navigation_source_admin = theme_get_setting('rootcandy_navigation_source_admin')) {
$rootcandy_navigation_source_admin = '_rootcandy_default_navigation';
}
$form['navigation']['rootcandy_superuser_menu'] = array(
'#type' => 'fieldset',
'#title' => t('Super user (uid 1) menu'),
'#weight' => 1,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['navigation']['rootcandy_superuser_menu']['rootcandy_navigation_source_admin'] = array(
'#type' => 'select',
'#default_value' => theme_get_setting('rootcandy_navigation_source_admin'),
'#options' => $menu_options,
'#tree' => FALSE,
);
$primary_options = array(
NULL => t('None'),
);
$primary_options = array_merge($primary_options, $menu_options);
$form['navigation']['role-weights'] = array(
'#type' => 'fieldset',
'#title' => t('Menu by role and weights'),
'#weight' => 2,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$roles = user_roles(FALSE);
$max_weight = 0;
foreach ($roles as $rid => $role) {
$form['navigation']['nav-by-role']['rootcandy_navigation_source_'. $rid] = array(
'#type' => 'select',
'#default_value' => theme_get_setting('rootcandy_navigation_source_'. $rid),
'#options' => $primary_options,
'#tree' => FALSE,
);
// check the highest weight for later use
if (theme_get_setting('role-weight-'. $rid)) {
if ($max_weight < theme_get_setting('role-weight-'. $rid)) {
$max_weight = theme_get_setting('role-weight-'. $rid);
}
//.........这里部分代码省略.........
示例14: menu_delete
/**
* Delete a custom menu and all contained links.
*
* Note that this function deletes all menu links in a custom menu. While menu
* links derived from router paths may be restored by rebuilding the menu, all
* customized and custom links will be irreversibly gone. Therefore, this
* function should usually be called from a user interface (form submit) handler
* only, which allows the user to confirm the action.
*
* @param $menu
* An array representing a custom menu:
* - menu_name: The unique name of the custom menu.
* - title: The human readable menu title.
* - description: The custom menu description.
*
* Modules should always pass a fully populated $menu when deleting a custom
* menu, so other modules are able to output proper status or watchdog messages.
*
* @see menu_load()
*
* menu_delete_links() will take care of clearing the page cache. Other modules
* should take care of their menu-related data by implementing
* hook_menu_delete().
*/
function menu_delete($menu)
{
// Delete all links from the menu.
menu_delete_links($menu['menu_name']);
// Remove menu from active menus variable.
$active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
foreach ($active_menus as $i => $menu_name) {
if ($menu['menu_name'] == $menu_name) {
unset($active_menus[$i]);
variable_set('menu_default_active_menus', $active_menus);
}
}
// Delete the custom menu.
db_delete('menu_custom')->condition('menu_name', $menu['menu_name'])->execute();
menu_cache_clear_all();
module_invoke_all('menu_delete', $menu);
}
示例15: rootcandy_fixed_settings
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
* array An array of saved settings for this theme.
* @return
* array A form array.
*/
function rootcandy_fixed_settings($saved_settings, $subtheme_defaults = array())
{
// Get the default values from the .info file.
$themes = list_themes();
$defaults = $themes['rootcandy_fixed']->info['settings'];
// Allow a subtheme to override the default values.
$defaults = array_merge($defaults, $subtheme_defaults);
// Merge the saved variables and their default values.
$settings = array_merge($defaults, $saved_settings);
// Create the form widgets using Forms API
$form['header'] = array('#type' => 'fieldset', '#title' => t('Header'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['header']['rootcandy_header_display'] = array('#type' => 'checkbox', '#title' => t('Disable header'), '#default_value' => $settings['rootcandy_header_display']);
$form['header']['rootcandy_hide_panel'] = array('#type' => 'checkbox', '#title' => t('Disable sliding panel'), '#default_value' => $settings['rootcandy_hide_panel']);
$form['dashboard'] = array('#type' => 'fieldset', '#title' => t('Dashboard'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['dashboard']['rootcandy_dashboard_display'] = array('#type' => 'checkbox', '#title' => t('Disable dashboard regions'), '#default_value' => $settings['rootcandy_dashboard_display']);
$form['dashboard']['rootcandy_dashboard_help'] = array('#type' => 'select', '#options' => array('left' => t('Left'), 'right' => t('Right'), 'content' => t('Content')), '#title' => t('Help box position'), '#default_value' => $settings['rootcandy_dashboard_help']);
$form['dashboard']['rootcandy_dashboard_messages'] = array('#type' => 'select', '#options' => array('left' => t('Left'), 'right' => t('Right'), 'content' => t('Content')), '#title' => t('Messages box position'), '#default_value' => $settings['rootcandy_dashboard_messages']);
$form['dashboard']['rootcandy_dashboard_content_display'] = array('#type' => 'checkbox', '#title' => t('Disable content on a dashboard'), '#default_value' => $settings['rootcandy_dashboard_content_display']);
$form['navigation'] = array('#type' => 'fieldset', '#title' => t('Navigation'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
// Create the form widgets using Forms API
$form['navigation']['rootcandy_navigation_icons'] = array('#type' => 'checkbox', '#title' => t('Disable icons for main navigation'), '#default_value' => $settings['rootcandy_navigation_icons']);
$form['navigation']['rootcandy_navigation_icons_size'] = array('#type' => 'select', '#options' => array(16 => 16, 24 => 24, 32 => 32), '#title' => t('Set icons size for main navigation'), '#default_value' => $settings['rootcandy_navigation_icons_size']);
$menu_options = array_merge(array('_rootcandy_default_navigation' => t('default navigation')), menu_get_menus());
if (!isset($settings['rootcandy_navigation_source_admin'])) {
$settings['rootcandy_navigation_source_admin'] = '_rootcandy_default_navigation';
}
$form['navigation']['rootcandy_superuser_menu'] = array('#type' => 'fieldset', '#title' => t('Super user (uid 1) menu'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['navigation']['rootcandy_superuser_menu']['rootcandy_navigation_source_admin'] = array('#type' => 'select', '#default_value' => $settings['rootcandy_navigation_source_admin'], '#options' => $menu_options, '#tree' => FALSE);
$primary_options = array(NULL => t('None'));
$primary_options = array_merge($primary_options, $menu_options);
$form['navigation']['role-weights'] = array('#type' => 'fieldset', '#title' => t('Menu by role and weights'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$roles = user_roles(FALSE);
$max_weight = 0;
foreach ($roles as $rid => $role) {
if (empty($settings['rootcandy_navigation_source_' . $rid])) {
$settings['rootcandy_navigation_source_' . $rid] = '';
}
$form['navigation']['nav-by-role']['rootcandy_navigation_source_' . $rid] = array('#type' => 'select', '#default_value' => $settings['rootcandy_navigation_source_' . $rid], '#options' => $primary_options, '#tree' => FALSE);
// check the highest weight for later use
if (isset($settings['role-weight-' . $rid])) {
if ($max_weight < $settings['role-weight-' . $rid]) {
$max_weight = $settings['role-weight-' . $rid];
}
}
}
$form['navigation']['custom-icons'] = array('#type' => 'fieldset', '#title' => t('Custom icons'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['navigation']['custom-icons']['rootcandy_navigation_custom_icons'] = array('#type' => 'textarea', '#title' => t('Custom icons'), '#default_value' => $settings['rootcandy_navigation_custom_icons'], '#description' => t('Format: menu href|icon path (relative to drupal root) - one item per row. eg. admin/build|files/myicons/admin-build.png'), '#required' => FALSE);
// Create the form widgets using Forms API
$form['Misc'] = array('#type' => 'fieldset', '#title' => t('Misc'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['Misc']['rootcandy_help_display'] = array('#type' => 'checkbox', '#title' => t('Disable help'), '#default_value' => $settings['rootcandy_help_display']);
$form['Misc']['rootcandy_hide_author'] = array('#type' => 'checkbox', '#title' => t('Hide author footer message'), '#default_value' => $settings['rootcandy_hide_author']);
$max_weight = isset($max_weight) ? $max_weight : 100;
foreach ($roles as $rid => $role) {
if (empty($settings['role-weight-' . $rid])) {
$settings['role-weight-' . $rid] = '';
}
if (!($weight = $settings['role-weight-' . $rid])) {
$weight = ++$max_weight;
}
$data = array($role);
$form['rows'][$rid]['data'] = array('#type' => 'value', '#value' => $data);
$form['rows'][$rid]['role-weight-' . $rid] = array('#type' => 'textfield', '#size' => 5, '#default_value' => $weight, '#attributes' => array('class' => 'weight'));
}
// Return the additional form widgets
return $form;
}