/** * 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; }
/** * 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; }
/** * 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)); }
/** * 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; }
/** * 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')); }
/** * 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'] = ''; } }
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']); }
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; }
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, ); $form['displays']['page']['options']['link_properties']['title'] = array( '#title' => t('Link text'), '#type' => 'textfield', ); // Only offer a feed if we have at least one available feed row style. if ($feed_row_options) { $form['displays']['page']['options']['feed'] = array( '#title' => t('Include an RSS feed'), '#type' => 'checkbox', '#id' => 'edit-page-feed', ); $form['displays']['page']['options']['feed_properties'] = array( '#type' => 'container', '#dependency' => array( 'edit-page-feed' => array(1), ), '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="edit-page-feed-properties-wrapper">', '#suffix' => '</div>', ); $form['displays']['page']['options']['feed_properties']['path'] = array( '#title' => t('Feed path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, ); // This will almost never be visible. $form['displays']['page']['options']['feed_properties']['row_plugin'] = array( '#title' => t('Feed row style'), '#type' => 'select', '#options' => $feed_row_options, '#default_value' => key($feed_row_options), '#access' => (count($feed_row_options) > 1), '#dependency' => array( 'edit-page-feed' => array(1), ), '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="edit-page-feed-properties-row-plugin-wrapper">', '#suffix' => '</div>', ); } $form['displays']['block'] = array( '#type' => 'fieldset', '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),), '#tree' => TRUE, ); $form['displays']['block']['create'] = array( '#title' => t('Create a block'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#id' => 'edit-block-create', ); // All options for the block display are included in this container so they // can be hidden en masse when the "Create a block" checkbox is unchecked. $form['displays']['block']['options'] = array( '#type' => 'container', '#attributes' => array('class' => array('options-set'),), '#dependency' => array( 'edit-block-create' => array(1), ), '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="edit-block-wrapper">', '#suffix' => '</div>', '#parents' => array('block'), ); $form['displays']['block']['options']['title'] = array( '#title' => t('Block title'), '#type' => 'textfield', ); $form['displays']['block']['options']['style'] = array( '#type' => 'fieldset', '#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')), ); // Create the dropdown for choosing the display format. $form['displays']['block']['options']['style']['style_plugin'] = array( '#title' => t('Display format'), '#help_topic' => 'style', '#type' => 'select', '#options' => $style_options, ); $style_form = &$form['displays']['block']['options']['style']; $style_form['style_plugin']['#default_value'] = views_ui_get_selected($form_state, array('block', 'style', 'style_plugin'), 'default', $style_form['style_plugin']); // Changing this dropdown updates $form['displays']['block']['options'] via // AJAX. views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'block', 'options')); $this->build_form_style($form, $form_state, 'block'); $form['displays']['block']['options']['items_per_page'] = array( '#title' => t('Items per page'), '#type' => 'textfield', '#default_value' => '5', '#size' => 5, '#element_validate' => array('_element_validate_integer_positive'), ); return $form; }
/** * 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'] = ''; } }
/** * 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; }
/** * 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); } }
/** * 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); } } } // Return the additional form widgets return $form; }
/** * 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); }
/** * 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; }
/** * 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 gwt_drupal_preprocess_page(&$variables, $hook) { global $base_url; // $variables['path_to_theme'] = $base_url.'/'.path_to_theme(); $js_variables = array('theme_path' => $base_url . '/' . path_to_theme()); drupal_add_js(array('gwt_drupal' => $js_variables), 'setting'); // drupal_add_js(drupal_get_path('theme', 'MYTHEME') .'/mytheme.js', 'file'); // 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'] = ''; } $variables['content_class'] = ''; $variables['sidebar_first_class'] = ' large-3 medium-3'; $variables['sidebar_second_class'] = ' large-3 medium-3'; if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-6 medium-6 large-push-3 medium-push-3'; $variables['sidebar_first_class'] .= ' large-pull-6 medium-push-6'; } elseif (!empty($variables['page']['sidebar_first']) && empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-9 medium-9 large-push-3 medium-push-3'; $variables['sidebar_first_class'] .= ' large-pull-9 medium-pull-9'; } elseif (empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-9 medium-9'; } else { $variables['content_class'] .= ' large-12'; } // create a dynamic column on banner $variables['banner_class'] = ' large-12'; $variables['banner_2_class'] = ''; $variables['banner_3_class'] = ''; $variables['banner_container_class'] = ' has-border'; // TODO: bug! banner slider and container should not show (if no content on other content) if the banner is medium size media if (!empty($variables['page']['banner'])) { if (!empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-6'; $variables['banner_2_class'] = ' large-3'; $variables['banner_3_class'] = ' large-3'; } elseif (!empty($variables['page']['banner_2']) && empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-8'; $variables['banner_2_class'] = ' large-4'; } elseif (empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-9'; $variables['banner_3_class'] = ' large-3'; } } elseif (empty($variables['page']['banner'])) { $variables['banner_class'] = ''; $variables['banner_container_class'] = ''; if (!empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_2_class'] = ' large-6'; $variables['banner_3_class'] = ' large-6'; } elseif (!empty($variables['page']['banner_2']) && empty($variables['page']['banner_3'])) { $variables['banner_2_class'] = ' large-12'; } elseif (empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_3_class'] = ' large-12'; } } // create a dynamic column on banner $variables['name_slogan_class'] = ' large-12'; $variables['ear_content_class'] = ''; $variables['ear_content_2_class'] = ''; // if both banner are available if (!empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-6'; $variables['ear_content_class'] = ' large-3'; $variables['ear_content_2_class'] = ' large-3'; } elseif (!empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-9'; $variables['ear_content_class'] = ' large-3'; //$variables['ear_content_2_class'] = ''; } elseif (empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-9'; //$variables['ear_content_class'] = ''; $variables['ear_content_2_class'] = ' large-3'; } // TODO: make a function that parse multiple region columns // create a dynamic column on agency footer $variables['footer_class'] = ' large-12'; if (!empty($variables['page']['footer_2'])) { $variables['footer_class'] = ' large-6'; $variables['footer_2_class'] = ' large-6'; $variables['footer_3_class'] = ' large-3'; $variables['footer_4_class'] = ' large-3'; if (!empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_class'] = ' large-3'; $variables['footer_2_class'] = ' large-3'; } elseif (empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_2_class'] = ' large-3'; } elseif (!empty($variables['page']['footer_3']) && empty($variables['page']['footer_4'])) { $variables['footer_class'] = ' large-4'; $variables['footer_2_class'] = ' large-4'; $variables['footer_3_class'] = ' large-4'; } } else { $variables['footer_class'] = ' large-6'; $variables['footer_3_class'] = ' large-3'; $variables['footer_4_class'] = ' large-3'; if (empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_4_class'] = ' large-6'; } elseif (!empty($variables['page']['footer_3']) && empty($variables['page']['footer_4'])) { $variables['footer_3_class'] = ' large-6'; } } // create a dynamic column on agency panel_top $variables['panel_top_class'] = ' large-12'; if (!empty($variables['page']['panel_top_2'])) { $variables['panel_top_class'] = ' large-6'; $variables['panel_top_2_class'] = ' large-6'; $variables['panel_top_3_class'] = ' large-3'; $variables['panel_top_4_class'] = ' large-3'; if (!empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_class'] = ' large-3'; $variables['panel_top_2_class'] = ' large-3'; } elseif (empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_2_class'] = ' large-3'; } elseif (!empty($variables['page']['panel_top_3']) && empty($variables['page']['panel_top_4'])) { $variables['panel_top_class'] = ' large-4'; $variables['panel_top_2_class'] = ' large-4'; $variables['panel_top_3_class'] = ' large-4'; } } else { $variables['panel_top_class'] = ' large-12'; $variables['panel_top_3_class'] = ' large-3'; $variables['panel_top_4_class'] = ' large-3'; if (empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_4_class'] = ' large-6'; } elseif (!empty($variables['page']['panel_top_3']) && empty($variables['page']['panel_top_4'])) { $variables['panel_top_3_class'] = ' large-6'; } } // create a dynamic column on agency panel_bottom $variables['panel_bottom_class'] = ' large-12'; if (!empty($variables['page']['panel_bottom_2'])) { $variables['panel_bottom_class'] = ' large-6'; $variables['panel_bottom_2_class'] = ' large-6'; $variables['panel_bottom_3_class'] = ' large-3'; $variables['panel_bottom_4_class'] = ' large-3'; if (!empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_class'] = ' large-3'; $variables['panel_bottom_2_class'] = ' large-3'; } elseif (empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_2_class'] = ' large-3'; } elseif (!empty($variables['page']['panel_bottom_3']) && empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_class'] = ' large-4'; $variables['panel_bottom_2_class'] = ' large-4'; $variables['panel_bottom_3_class'] = ' large-4'; } } else { $variables['panel_bottom_class'] = ' large-6'; $variables['panel_bottom_3_class'] = ' large-3'; $variables['panel_bottom_4_class'] = ' large-3'; if (empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_4_class'] = ' large-6'; } elseif (!empty($variables['page']['panel_bottom_3']) && empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_3_class'] = ' large-6'; } } // load the color used from theme_settings // TODO: use the drupal way of printing attributes $variables['gwt_drupal_masthead_styles'] = 'style=" '; if ($gwt_drupal_masthead_bg_color = theme_get_setting('gwt_drupal_masthead_bg_color')) { $variables['gwt_drupal_masthead_styles'] .= 'background-color: ' . $gwt_drupal_masthead_bg_color . '; '; } $masthead_fid = theme_get_setting('gwt_drupal_masthead_bg_image'); if ($masthead_fid) { $file = file_load($masthead_fid); if (isset($file->uri)) { $variables['gwt_drupal_masthead_styles'] .= 'background-image: url(' . file_create_url($file->uri) . '); '; } } if ($gwt_drupal_masthead_font = theme_get_setting('gwt_drupal_masthead_font_color')) { $variables['gwt_drupal_masthead_styles'] .= 'color: ' . $gwt_drupal_masthead_font . '; '; } $variables['gwt_drupal_masthead_styles'] .= '" '; $variables['gwt_drupal_banner_styles'] = 'style=" '; if ($gwt_drupal_banner_bg_color = theme_get_setting('gwt_drupal_banner_bg_color')) { $variables['gwt_drupal_banner_styles'] .= 'background-color: ' . $gwt_drupal_banner_bg_color . '; '; } $banner_fid = theme_get_setting('gwt_drupal_banner_bg_image'); if ($banner_fid) { $file = file_load($banner_fid); if (isset($file->uri)) { $variables['gwt_drupal_banner_styles'] .= 'background-image: url(' . file_create_url($file->uri) . '); '; } } if ($gwt_drupal_banner_font = theme_get_setting('gwt_drupal_banner_font_color')) { $variables['gwt_drupal_banner_styles'] .= 'color: ' . $gwt_drupal_banner_font . '; '; } $variables['gwt_drupal_banner_styles'] .= '" '; // TODO: check if the auxiliary_menu is available $variables['menu_auxiliary_menu'] = ''; if (menu_load_links('menu-auxiliary-menu')) { $variables['menu_auxiliary_menu'] = menu_load_links('menu-auxiliary-menu'); } $accessibility = array(); /* $gwt_drupal_acc_statement = theme_get_setting('gwt_drupal_acc_statement') ? theme_get_setting('gwt_drupal_acc_statement') : ''; if($gwt_drupal_acc_statement){ $accessibility[] = array( 'url' => $gwt_drupal_acc_statement, 'text' => t('Accessibility Statement'), 'key' => '0', 'class' => array('toggle-statement'), ); } */ $gwt_drupal_acc_home = theme_get_setting('gwt_drupal_acc_home') ? theme_get_setting('gwt_drupal_acc_home') : ''; if ($gwt_drupal_acc_home) { $accessibility[] = array('url' => $gwt_drupal_acc_home, 'text' => t('Home'), 'key' => '1'); } $gwt_drupal_acc_faq = theme_get_setting('gwt_drupal_acc_faq') ? theme_get_setting('gwt_drupal_acc_faq') : ''; if ($gwt_drupal_acc_faq) { $accessibility[] = array('url' => $gwt_drupal_acc_faq, 'text' => t('Faqs'), 'key' => '5'); } $gwt_drupal_acc_contact = theme_get_setting('gwt_drupal_acc_contact') ? theme_get_setting('gwt_drupal_acc_contact') : ''; if ($gwt_drupal_acc_contact) { $accessibility[] = array('url' => $gwt_drupal_acc_contact, 'text' => t('Contact'), 'key' => 'c'); } $gwt_drupal_acc_feedback = theme_get_setting('gwt_drupal_acc_feedback') ? theme_get_setting('gwt_drupal_acc_feedback') : ''; if ($gwt_drupal_acc_feedback) { $accessibility[] = array('url' => $gwt_drupal_acc_feedback, 'text' => t('Feedbacks'), 'key' => 'k'); } $gwt_drupal_acc_search = theme_get_setting('gwt_drupal_acc_search') ? theme_get_setting('gwt_drupal_acc_search') : 'search/node/'; if ($gwt_drupal_acc_search) { $accessibility[] = array('url' => $gwt_drupal_acc_search, 'text' => t('Search'), 'key' => 's'); } // accesibility page that loads all the accesibility theme_settings. $variables['accesibility'] = '<ul>'; $gwt_drupal_acc_maincontent = theme_get_setting('gwt_drupal_acc_maincontent') ? theme_get_setting('gwt_drupal_acc_maincontent') : '#main-content'; if ($gwt_drupal_acc_maincontent) { $variables['accesibility'] .= '<li><a href="' . $gwt_drupal_acc_maincontent . '" accesskey="R">Skip to Main Content</a></li>'; } $gwt_drupal_acc_sitemap = theme_get_setting('gwt_drupal_acc_sitemap') ? theme_get_setting('gwt_drupal_acc_sitemap') : '#footer'; if ($gwt_drupal_acc_sitemap) { $variables['accesibility'] .= '<li><a href="' . $gwt_drupal_acc_sitemap . '" accesskey="M">Sitemap</a></li>'; } $variables['accesibility'] .= '</ul>'; /*$test = l( $accessibility[0]['text'], $accessibility[0]['url'], array( 'attributes' => array( 'accesskey' => 0, 'class' => 'skips', ), )); // drupal_set_message('<pre>'.print_r($data['class'], 1).'</pre>'); drupal_set_message('<pre>'.print_r($test, 1).'</pre>');*/ $variables['accesibility_shortcut'] = '<ul>'; $variables['accesibility_shortcut'] .= '<li><a href="#" class="skips toggle-statement" title="Toggle Accessibility Statement" accesskey="0">Toggle Accessibility Statement</a></li>'; foreach ($accessibility as $access_key => $data) { $data['class'] = isset($data['class']) && is_array($data['class']) ? $data['class'] : array(); $variables['accesibility_shortcut'] .= '<li>'; $variables['accesibility_shortcut'] .= l($data['text'], $data['url'], array('attributes' => array('class' => array_merge(array('skips'), $data['class']), 'accesskey' => $data['key']))); $variables['accesibility_shortcut'] .= '</li>'; } $variables['accesibility_shortcut'] .= '</ul>'; $variables['accessibility_widget'] = theme_get_setting('gwt_drupal_acc_widget'); if (module_exists('gwt_drupal_helper')) { $variables['gwt_mega_menu'] = _gwt_drupal_mega_menu_formatted(); } }
/** * Advanced theme settings. */ function marinelli_form_system_theme_settings_alter(&$form, $form_state) { // fieldgroups $form['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['layout'] = array('#type' => 'fieldset', '#title' => t('Layout Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['menu'] = array('#type' => 'fieldset', '#title' => t('Primary menu settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['accessibility'] = array('#type' => 'fieldset', '#title' => t('Accessibility and code semantics settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['text_vars'] = array('#type' => 'fieldset', '#title' => t('String settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['css3'] = array('#type' => 'fieldset', '#title' => t('css3 settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['banner'] = array('#type' => 'fieldset', '#title' => t('Banner managment'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => FALSE); // Breadcrumb elements $form['breadcrumb']['breadcrumb_title'] = array('#type' => 'select', '#title' => t('Breadcrumb title'), '#description' => t('Do you want to show the title of the page in the breadcrumb?'), '#options' => array(0 => t('No'), 1 => t('Yes')), '#default_value' => theme_get_setting('breadcrumb_title')); $form['breadcrumb']['breadcrumb_title_length'] = array('#type' => 'select', '#title' => t('Title length'), '#description' => t('The title in the breadcrumb will be truncated after this number of character'), '#options' => array(10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70 => 70, 80 => 90, 100 => 100), '#default_value' => theme_get_setting('breadcrumb_title_length')); // Layout elements $form['layout']['layout_width'] = array('#type' => 'select', '#title' => t('Layout width'), '#description' => t('1048px layout could show <strong>horizontal bars </strong> with lower resolutions...but honestly i think we are ready to make a wider web...'), '#options' => array(1 => t('Fixed, 1048px width'), 2 => t('Fixed, 988px width')), '#default_value' => theme_get_setting('layout_width')); $form['layout']['layout_type'] = array('#type' => 'select', '#title' => t('Layout Type'), '#description' => t('Choose a layout type'), '#options' => array(1 => t('Content on the left'), 2 => t('Content in the middle'), 3 => t('Content on the right')), '#default_value' => theme_get_setting('layout_type')); /* TO DO: sidebar width $form['layout']['sidebar_width'] = array( '#type' => 'select', '#title' => t('Sidebar Width'), '#description' => t('Choose a width for the sidebars. The extact size depend on the full layout width (988px or 1048px). The <strong>small size</strong> is 138px or 148px, the <strong>medium size</strong> is 217px or 232px, the <strong>large size</strong> is 296px or 316px'), '#options' => array( 2 => t('Small'), 3 => t('Medium'), 4 => t('Large'), ), '#default_value' => theme_get_setting('sidebar_width'), ); */ $form['layout']['blocks'] = array('#type' => 'select', '#title' => t('Do you want to hide block title for the external blocks?'), '#description' => t('If you choose yes, block title will show only for sidebar blocks. The title will be hidden in all the other blocks (but not removed from source)'), '#options' => array(1 => t('YES'), 2 => t('NO')), '#default_value' => theme_get_setting('blocks')); // Menu elements $form['menu']['menu_type'] = array('#type' => 'select', '#title' => t('Which kind of primary links do you want to use?'), '#description' => t('Classic one-level primary links, or mega drop-down menu'), '#options' => array(1 => t('Classic Primary Links'), 2 => t('Mega Drop Down')), '#default_value' => theme_get_setting('menu_type')); $form['menu']['menu_element'] = array('#type' => 'select', '#title' => t('Megamenu Source'), '#description' => t('Choose a menu to render as megamenu'), '#options' => menu_get_menus(), '#default_value' => theme_get_setting('menu_element')); $form['menu']['menu_alt_class'] = array('#type' => 'select', '#multiple' => TRUE, '#title' => t('Alt class (mega menu only)'), '#description' => t('On which occurency of primary links would you like to put the alt class?'), '#options' => array(0 => t('none'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#suffix' => '<strong>' . t('The alt class will open the mega menu on the left') . '</strong>', '#default_value' => theme_get_setting('menu_alt_class')); // accessibility and code semantics settings $form['accessibility']['outside_tags'] = array('#type' => 'select', '#title' => t('Do you want to use p tag for all the section titles that come before main site content?'), '#description' => t('If you choose yes, the theme will try to comply WCAG2 headings specifications by using the p tag instead of h2 for all the section title tags that come before the main content (for example banner title and top region block titles) '), '#options' => array(0 => t('NO'), 1 => t('YES')), '#default_value' => theme_get_setting('outside_tags')); $form['accessibility']['title_tags'] = array('#type' => 'select', '#title' => t('Do you want to use h1 and h2 tags for site title and site slogan on the front page?'), '#description' => t('If you choose NO, the theme will force the p tag for title and slogan in every page. This might help with WCAG2 headings specification if you front page has the page title'), '#options' => array(0 => t('YES'), 1 => t('NO')), '#default_value' => theme_get_setting('title_tags')); $form['accessibility']['menu_headings'] = array('#type' => 'select', '#title' => t('Which tag do you want to use for menu section titles?'), '#description' => t('Using headings will improve screen-reader based navigation, however you will fail Wcag2 headings order raccomandations'), '#options' => array(1 => t('only <li>'), 2 => t('<h2> for first level and <h3> for megamenu sections')), '#default_value' => theme_get_setting('menu_headings')); // text vars $form['text_vars']['sticky_text'] = array('#type' => 'textfield', '#title' => t('text of the sticky icon'), '#default_value' => theme_get_setting('sticky_text')); $form['text_vars']['bartext'] = array('#type' => 'textfield', '#title' => t('text of the top bar slide button'), '#default_value' => theme_get_setting('bartext')); $form['text_vars']['bartext2'] = array('#type' => 'textfield', '#title' => t('text of opened top bar slide button'), '#default_value' => theme_get_setting('bartext2')); // css3 elements $form['css3']['css'] = array('#type' => 'select', '#title' => t('Do you want to use css3 effects?'), '#description' => t('With css3 you can have some additional css-based styles such as rounded corners and text shadows. This effects work only with some browsers. <strong>With css3 enabled you will probably fail css validation</strong>'), '#options' => array(1 => t('Css3 On'), 2 => t('Css3 Off')), '#default_value' => theme_get_setting('css')); $form['css3']['css_typo'] = array('#type' => 'select', '#title' => t('Do you want to use css3 font face embedding?'), '#description' => t('With this option enabled we can use css3 nice fonts (Loading fonts may slow down page loading) <strong>You need to enable css3 to use this feature</strong>'), '#options' => array(1 => t('Font face OFF'), 2 => t('Font Face ON')), '#default_value' => theme_get_setting('css_typo')); // Banners elements $form['banner']['configuration'] = array('#type' => 'fieldset', '#title' => t('Banner configuration'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE); $form['banner']['configuration']['banner_usage'] = array('#type' => 'select', '#options' => array(1 => t('Marinelli banners'), 0 => t('Drupal region (advertise)')), '#title' => t('Do you want to use Marinelli banners or a classic drupal region?'), '#default_value' => theme_get_setting('banner_usage')); $form['banner']['configuration']['banner_effect'] = array('#type' => 'select', '#options' => array('fade' => t('fade'), 'scrollRight' => t('scrollRight'), 'scrollLeft' => t('scrollLeft'), 'scrollUp' => t('scrollUp'), 'scrollDown' => t('scrollDown'), 'turnLeft' => t('turnLeft'), 'fadeZoom' => t('fadeZoom'), 'curtainX' => t('curtainX'), 'wipe' => t('wipe')), '#title' => t('Choose the effect of your banner'), '#default_value' => theme_get_setting('banner_effect')); $form['banner']['configuration']['banner_speed'] = array('#type' => 'textfield', '#size' => 4, '#title' => t('Choose the rotation speed (milliseconds, default is 1000)'), '#default_value' => theme_get_setting('banner_speed')); $form['banner']['configuration']['banner_delay'] = array('#type' => 'textfield', '#size' => 4, '#title' => t('Choose the banner delay (milliseconds, default is 4000)'), '#default_value' => theme_get_setting('banner_delay')); $form['banner']['configuration']['banner_pause'] = array('#type' => 'select', '#options' => array(0 => t('No'), 1 => t('Yes')), '#title' => t('Pause on hover? default is YES'), '#default_value' => theme_get_setting('banner_pause')); $form['banner']['configuration']['banner_showtext'] = array('#type' => 'radios', '#title' => t('Do you want to show title and description over the banner?'), '#default_value' => theme_get_setting('banner_showtext'), '#options' => array(0 => t('No'), 1 => t('Yes'))); $form['banner']['configuration']['banner_shownavigation'] = array('#type' => 'radios', '#title' => t('Do you want to show the banner navigation over the banner?'), '#default_value' => theme_get_setting('banner_shownavigation'), '#options' => array(0 => t('No'), 1 => t('Yes'))); // Image upload section ====================================================== $banners = marinelli_get_banners(); $form['banner']['images'] = array('#type' => 'vertical_tabs', '#title' => t('Banner images'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE); $i = 0; foreach ($banners as $image_data) { $form['banner']['images'][$i] = array('#type' => 'fieldset', '#title' => t('Image !number: !title', array('!number' => $i + 1, '!title' => $image_data['image_title'])), '#weight' => $i, '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, 'image' => _marinelli_banner_form($image_data)); $i++; } $form['banner']['image_upload'] = array('#type' => 'file', '#title' => t('Upload a new banner'), '#weight' => $i); $form['#submit'][] = 'marinelli_settings_submit'; return $form; }