Beispiel #1
0
/**
 * 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'] = '';
    }
}
 public function settingsForm(array $form, array &$form_state)
 {
     $menu_enabled = \Drupal::moduleHandler()->moduleExists('menu_ui');
     if ($menu_enabled) {
         $menus = array('__new-menu__' => t('Create new menu(s)')) + menu_ui_get_menus();
     } else {
         $menus = menu_list_system_menus();
     }
     $form['existing_menus'] = array('#type' => 'checkboxes', '#title' => t('Generate links for these menus'), '#options' => $menus, '#default_value' => array('__new-menu__'), '#required' => TRUE);
     if ($menu_enabled) {
         $form['num_menus'] = array('#type' => 'textfield', '#title' => t('Number of new menus to create'), '#default_value' => $this->getSetting('num_menus'), '#size' => 10, '#states' => array('visible' => array(':input[name=existing_menus[__new-menu__]]' => array('checked' => TRUE))));
     }
     $form['num_links'] = array('#type' => 'textfield', '#title' => t('Number of links to generate'), '#default_value' => $this->getSetting('num_links'), '#size' => 10, '#required' => TRUE);
     $form['title_length'] = array('#type' => 'textfield', '#title' => t('Maximum number of characters in menu and menu link names'), '#description' => t("The minimum length is 2."), '#default_value' => $this->getSetting('title_length'), '#size' => 10, '#required' => TRUE);
     $form['link_types'] = array('#type' => 'checkboxes', '#title' => t('Types of links to generate'), '#options' => array('node' => t('Nodes'), 'front' => t('Front page'), 'external' => t('External')), '#default_value' => array('node', 'front', 'external'), '#required' => TRUE);
     $form['max_depth'] = array('#type' => 'select', '#title' => t('Maximum link depth'), '#options' => range(0, MENU_MAX_DEPTH), '#default_value' => floor(MENU_MAX_DEPTH / 2), '#required' => TRUE);
     unset($form['max_depth']['#options'][0]);
     $form['max_width'] = array('#type' => 'textfield', '#title' => t('Maximum menu width'), '#default_value' => $this->getSetting('max_width'), '#size' => 10, '#description' => t("Limit the width of the generated menu's first level of links to a certain number of items."), '#required' => TRUE);
     $form['kill'] = array('#type' => 'checkbox', '#title' => t('Delete existing custom generated menus and menu links before generating new ones.'), '#default_value' => $this->getSetting('kill'));
     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'] = '';
    }
}
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $style_options = Views::fetchPluginNames('style', 'normal', array($this->base_table));
     $feed_row_options = Views::fetchPluginNames('row', 'feed', array($this->base_table));
     $path_prefix = $this->url('<none>', [], ['absolute' => TRUE]);
     // Add filters and sorts which apply to the view as a whole.
     $this->buildFilters($form, $form_state);
     $this->buildSorts($form, $form_state);
     $form['displays']['page'] = array('#type' => 'fieldset', '#title' => $this->t('Page settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
     $form['displays']['page']['create'] = array('#title' => $this->t('Create a page'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#default_value' => FALSE, '#id' => 'edit-page-create');
     // All options for the page display are included in this container so they
     // can be hidden as a group when the "Create a page" checkbox is unchecked.
     $form['displays']['page']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="page[create]"]' => array('checked' => TRUE))), '#prefix' => '<div><div id="edit-page-wrapper">', '#suffix' => '</div></div>', '#parents' => array('page'));
     $form['displays']['page']['options']['title'] = array('#title' => $this->t('Page title'), '#type' => 'textfield', '#maxlength' => 255);
     $form['displays']['page']['options']['path'] = array('#title' => $this->t('Path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
     $form['displays']['page']['options']['style'] = array('#type' => 'fieldset', '#title' => $this->t('Page display settings'), '#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' => $this->t('Display format'), '#type' => 'select', '#options' => $style_options);
     $style_form =& $form['displays']['page']['options']['style'];
     $style_form['style_plugin']['#default_value'] = static::getSelected($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->buildFormStyle($form, $form_state, 'page');
     $form['displays']['page']['options']['items_per_page'] = array('#title' => $this->t('Items to display'), '#type' => 'number', '#default_value' => 10, '#min' => 0);
     $form['displays']['page']['options']['pager'] = array('#title' => $this->t('Use a pager'), '#type' => 'checkbox', '#default_value' => TRUE);
     $form['displays']['page']['options']['link'] = array('#title' => $this->t('Create a menu link'), '#type' => 'checkbox', '#id' => 'edit-page-link');
     $form['displays']['page']['options']['link_properties'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="page[link]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-link-properties-wrapper">', '#suffix' => '</div>');
     if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
         $menu_options = menu_ui_get_menus();
     } else {
         // These are not yet translated.
         $menu_options = menu_list_system_menus();
         foreach ($menu_options as $name => $title) {
             $menu_options[$name] = $this->t($title);
         }
     }
     $form['displays']['page']['options']['link_properties']['menu_name'] = array('#title' => $this->t('Menu'), '#type' => 'select', '#options' => $menu_options);
     $form['displays']['page']['options']['link_properties']['title'] = array('#title' => $this->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' => $this->t('Include an RSS feed'), '#type' => 'checkbox', '#id' => 'edit-page-feed');
         $form['displays']['page']['options']['feed_properties'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="page[feed]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-feed-properties-wrapper">', '#suffix' => '</div>');
         $form['displays']['page']['options']['feed_properties']['path'] = array('#title' => $this->t('Feed path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
         // This will almost never be visible.
         $form['displays']['page']['options']['feed_properties']['row_plugin'] = array('#title' => $this->t('Feed row style'), '#type' => 'select', '#options' => $feed_row_options, '#default_value' => key($feed_row_options), '#access' => count($feed_row_options) > 1, '#states' => array('visible' => array(':input[name="page[feed]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-feed-properties-row-plugin-wrapper">', '#suffix' => '</div>');
     }
     // Only offer the block settings if the module is enabled.
     if (\Drupal::moduleHandler()->moduleExists('block')) {
         $form['displays']['block'] = array('#type' => 'fieldset', '#title' => $this->t('Block settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
         $form['displays']['block']['create'] = array('#title' => $this->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 as a group when the "Create a block" checkbox is
         // unchecked.
         $form['displays']['block']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="block[create]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-block-wrapper">', '#suffix' => '</div>', '#parents' => array('block'));
         $form['displays']['block']['options']['title'] = array('#title' => $this->t('Block title'), '#type' => 'textfield', '#maxlength' => 255);
         $form['displays']['block']['options']['style'] = array('#type' => 'fieldset', '#title' => $this->t('Block display settings'), '#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' => $this->t('Display format'), '#type' => 'select', '#options' => $style_options);
         $style_form =& $form['displays']['block']['options']['style'];
         $style_form['style_plugin']['#default_value'] = static::getSelected($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->buildFormStyle($form, $form_state, 'block');
         $form['displays']['block']['options']['items_per_page'] = array('#title' => $this->t('Items per block'), '#type' => 'number', '#default_value' => 5, '#min' => 0);
         $form['displays']['block']['options']['pager'] = array('#title' => $this->t('Use a pager'), '#type' => 'checkbox', '#default_value' => FALSE);
     }
     // Only offer the REST export settings if the module is enabled.
     if (\Drupal::moduleHandler()->moduleExists('rest')) {
         $form['displays']['rest_export'] = array('#type' => 'fieldset', '#title' => $this->t('REST export settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
         $form['displays']['rest_export']['create'] = array('#title' => $this->t('Provide a REST export'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#id' => 'edit-rest-export-create');
         // All options for the REST export display are included in this container
         // so they can be hidden as a group when the "Provide a REST export"
         // checkbox is unchecked.
         $form['displays']['rest_export']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="rest_export[create]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-rest-export-wrapper">', '#suffix' => '</div>', '#parents' => array('rest_export'));
         $form['displays']['rest_export']['options']['path'] = array('#title' => $this->t('REST export path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
     }
     return $form;
 }
Beispiel #6
0
/**
 * 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();
    }
}
/**
 * Return an associative array of the custom menus names.
 *
 * @param $all
 *   If FALSE return only user-added menus, or if TRUE also include
 *   the menus defined by the system.
 * @return
 *   An array with the machine-readable names as the keys, and human-readable
 *   titles as the values.
 */
function menu_get_menus($all = TRUE)
{
    if ($custom_menus = menu_load_all()) {
        if (!$all) {
            $custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
        }
        foreach ($custom_menus as $menu_name => $menu) {
            $custom_menus[$menu_name] = t($menu['title']);
        }
        asort($custom_menus);
    }
    return $custom_menus;
}
Beispiel #8
0
 /**
  * Tests menu link bundles.
  */
 public function testMenuBundles()
 {
     $this->drupalLogin($this->admin_user);
     $menu = $this->addCustomMenu();
     // Clear the entity cache to ensure the static caches are rebuilt.
     \Drupal::entityManager()->clearCachedBundles();
     $bundles = entity_get_bundles('menu_link');
     $this->assertTrue(isset($bundles[$menu->id()]));
     $menus = menu_list_system_menus();
     $menus[$menu->id()] = $menu->label();
     ksort($menus);
     $this->assertIdentical(array_keys($bundles), array_keys($menus));
     // Test if moving a menu link between menus changes the bundle.
     $node = $this->drupalCreateNode(array('type' => 'article'));
     $item = $this->addMenuLink(0, 'node/' . $node->id(), 'tools');
     $this->moveMenuLink($item, 0, $menu->id());
     $this->assertEqual($item->bundle(), 'tools', 'Menu link bundle matches the menu');
     $moved_item = entity_load('menu_link', $item->id(), TRUE);
     $this->assertNotEqual($moved_item->bundle(), $item->bundle(), 'Menu link bundle was changed');
     $this->assertEqual($moved_item->bundle(), $menu->id(), 'Menu link bundle matches the menu');
     $unsaved_item = entity_create('menu_link', array('menu_name' => $menu->id(), 'link_title' => $this->randomName(16), 'link_path' => '<front>'));
     $this->assertEqual($unsaved_item->bundle(), $menu->id(), 'Unsaved menu link bundle matches the menu');
     $this->assertEqual($unsaved_item->menu_name, $menu->id(), 'Unsaved menu link menu name matches the menu');
 }
Beispiel #9
0
function constellation_preprocess_block(&$vars)
{
    //dpm($vars);
    if (theme_get_setting('extra_block_classes')) {
        $vars['classes_array'][] = 'block-' . $vars['block_zebra'];
        $vars['classes_array'][] = 'block-count-' . $vars['id'];
        $vars['classes_array'][] = drupal_html_class('block-region-' . $vars['block']->region);
    }
    if (theme_get_setting('horizontal_login_block') && $vars['block']->module == 'user' && $vars['block']->delta == 'login') {
        $vars['classes_array'][] = 'lb-h';
    }
    if (theme_get_setting('slider_login_block') && $vars['block']->module == 'user' && $vars['block']->delta == 'login') {
        $vars['classes_array'][] = 'lb-s';
    }
    $vars['title_attributes_array']['class'][] = 'block-title';
    $vars['content_attributes_array']['class'][] = 'block-content';
    $vars['content_attributes_array']['class'][] = 'content';
    $nav_blocks = array('navigation', 'main-menu', 'management', 'user-menu');
    if (in_array($vars['block']->delta, $nav_blocks)) {
        $vars['theme_hook_suggestions'][] = 'block__menu';
    }
    $nav_modules = array('superfish', 'nice_menus');
    if (in_array($vars['block']->module, $nav_modules)) {
        $vars['theme_hook_suggestions'][] = 'block__menu';
    }
    if ($vars['block']->region == 'menu_bar') {
        $vars['theme_hook_suggestions'][] = 'block__menu_bar';
        $vars['title_attributes_array']['class'][] = 'element-invisible';
    }
    // Provide template suggestions such as block--header--search, or block--menu-bar--menu
    $vars['theme_hook_suggestions'][] = 'block__' . $vars['block']->region . '__' . $vars['block']->module;
    // Add ARIA Roles to blocks, thank-you to Jacine http://drupal.org/user/88931 for cleaning up this code :)
    $roles = array('complementary' => array('aggregator', 'help', 'locale', 'poll', 'profile', 'node' => array('syndicate'), 'system' => array('powered-by', 'help'), 'user' => array('new', 'online')), 'navigation' => array('blog', 'book', 'comment', 'forum', 'menu', 'menu_block', 'node' => array('recent'), 'shortcut', 'statistics', 'system' => array_keys(menu_list_system_menus()), 'superfish', 'nice_menus'), 'search' => array('search'), 'form' => array('user' => array('login')));
    foreach ($roles as $role => $module) {
        if (!is_array($role) && in_array($vars['block']->module, $module)) {
            $vars['attributes_array']['role'] = "{$role}";
        } elseif (is_array($role)) {
            foreach ($role as $module => $delta) {
                if ($vars['block']->module == $module && in_array($vars['block']->delta, $delta)) {
                    $vars['attributes_array']['role'] = "{$role}";
                }
            }
        }
    }
}