Commit 83b33429 authored by Mattia Migliorini's avatar Mattia Migliorini

Add meta viewport and charset, remove meta content-type and generator

There should be a better way to add meta tags, but I did not find a working solution
parent 936c6815
...@@ -17,8 +17,56 @@ ...@@ -17,8 +17,56 @@
* @since 1.0.0 * @since 1.0.0
*/ */
error_reporting(E_ALL); /**
ini_set('display_errors',1); * Alter the <head> section contents.
*
* Default contents:
* ```
* array(3) {
* ["system_meta_content_type"]=> array(4) {
* ["#type"]=> string(8) "html_tag"
* ["#tag"]=> string(4) "meta"
* ["#attributes"]=> array(2) {
* ["http-equiv"]=> string(12) "Content-Type"
* ["content"]=> string(24) "text/html; charset=utf-8"
* }
* ["#weight"]=> int(-1000)
* }
* ["system_meta_generator"]=> array(4) {
* ["#type"]=> string(8) "html_tag"
* ["#tag"]=> string(4) "meta"
* ["#attributes"]=> array(2) {
* ["name"]=> string(9) "Generator"
* ["content"]=> string(28) "Drupal 7 (http://drupal.org)"
* }
* ["#attached"]=> array(1) {
* ["drupal_add_http_header"]=> array(1) {
* [0]=> array(2) {
* [0]=> string(11) "X-Generator"
* [1]=> string(28) "Drupal 7 (http://drupal.org)"
* }
* }
* }
* }
* ["drupal_add_html_head_link:shortcut icon:http://uit-test/misc/favicon.ico"]=> array(3) {
* ["#tag"]=> string(4) "link"
* ["#attributes"]=> array(3) {
* ["rel"]=> string(13) "shortcut icon"
* ["href"]=> string(32) "http://uit-test/misc/favicon.ico"
* ["type"]=> string(24) "image/vnd.microsoft.icon"
* }
* ["#type"]=> string(8) "html_tag"
* }
* }
* ```
*
* @since 0.1.1
*
* @param array $elements Head elements. Passed by reference.
*/
function valencia_html_head_alter( &$elements ) {
unset( $elements['system_meta_content_type'], $elements['system_meta_generator'] );
}
/** /**
* Add external scripts and styles. * Add external scripts and styles.
...@@ -31,134 +79,134 @@ ini_set('display_errors',1); ...@@ -31,134 +79,134 @@ ini_set('display_errors',1);
* @uses drupal_add_css() * @uses drupal_add_css()
*/ */
function valencia_preprocess_html( &$variables ) { function valencia_preprocess_html( &$variables ) {
/** /**
* Add a cascading stylesheet to the stylesheet queue. * Add a cascading stylesheet to the stylesheet queue.
* *
* Calling drupal_static_reset('drupal_add_css') will clear all cascading stylesheets added so far. * Calling drupal_static_reset('drupal_add_css') will clear all cascading stylesheets added so far.
* *
* If CSS aggregation/compression is enabled, all cascading stylesheets added with $options['preprocess'] * If CSS aggregation/compression is enabled, all cascading stylesheets added with $options['preprocess']
* set to TRUE will be merged into one aggregate file and compressed. Preprocessed inline stylesheets * set to TRUE will be merged into one aggregate file and compressed. Preprocessed inline stylesheets
* will not be aggregated into this single file; instead, they are just compressed upon output on the page. * will not be aggregated into this single file; instead, they are just compressed upon output on the page.
* Externally hosted stylesheets are never aggregated or compressed. * Externally hosted stylesheets are never aggregated or compressed.
* *
* @see drupal_get_css() * @see drupal_get_css()
* @since 1.0.0 * @since 1.0.0
* *
* @param string $data Optional. Stylesheet data to be added, depending on what is passed through the * @param string $data Optional. Stylesheet data to be added, depending on what is passed through the
* $options['type'] parameter. * $options['type'] parameter.
* @param string|array $options { * @param string|array $options {
* String defining the 'type' of CSS that is being added in the $data parameter or an array which can * String defining the 'type' of CSS that is being added in the $data parameter or an array which can
* have any or all the following keys. Optional. * have any or all the following keys. Optional.
* *
* @type string $type The type of stylesheet being added. Default <file>. Accepts <file>, <inline>, <external>. * @type string $type The type of stylesheet being added. Default <file>. Accepts <file>, <inline>, <external>.
* @type string $basename Force a basename for the file being added. * @type string $basename Force a basename for the file being added.
* @type integer $group Number identifying the group in which to add the stylesheet. CSS within higher * @type integer $group Number identifying the group in which to add the stylesheet. CSS within higher
* number group take precedence over CSS within lower number groups. * number group take precedence over CSS within lower number groups.
* Accepts <CSS_SYSTEM>, <CSS_DEFAULT>, <CSS_THEME>. * Accepts <CSS_SYSTEM>, <CSS_DEFAULT>, <CSS_THEME>.
* @type bool $every_page Should be set to TRUE if the stylesheet is present on every page of the website. * @type bool $every_page Should be set to TRUE if the stylesheet is present on every page of the website.
* Default <FALSE>. * Default <FALSE>.
* @type integer $weight CSS order relative to the same group and $every_page. * @type integer $weight CSS order relative to the same group and $every_page.
* @type string $media Media type for the stylesheet. Default <all>. * @type string $media Media type for the stylesheet. Default <all>.
* @type bool $preprocess If TRUE and CSS aggregation/compression is enabled, the styles * @type bool $preprocess If TRUE and CSS aggregation/compression is enabled, the styles
* will be aggregated and compressed. Default <TRUE>. * will be aggregated and compressed. Default <TRUE>.
* @type array $browsers Info specifying which browsers should load the CSS item. * @type array $browsers Info specifying which browsers should load the CSS item.
* @link https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_pre_render_conditional_comments/7 * @link https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_pre_render_conditional_comments/7
* } * }
* @return array Queued cascading stylesheets. * @return array Queued cascading stylesheets.
*/ */
//drupal_add_css('http://assets.ubuntu.com/sites/guidelines/css/responsive/latest/ubuntu-styles.css', array( //drupal_add_css('http://assets.ubuntu.com/sites/guidelines/css/responsive/latest/ubuntu-styles.css', array(
// 'type' => 'external', // 'type' => 'external',
// 'group' => CSS_DEFAULT, // 'group' => CSS_DEFAULT,
// 'every_page' => true // 'every_page' => true
//)); //));
//drupal_add_css('http://assets.ubuntu.com/sites/ubuntu/1160/u/css/styles.css', array( //drupal_add_css('http://assets.ubuntu.com/sites/ubuntu/1160/u/css/styles.css', array(
// 'type' => 'external', // 'type' => 'external',
// 'group' => CSS_DEFAULT, // 'group' => CSS_DEFAULT,
// 'every_page' => true // 'every_page' => true
//)); //));
drupal_add_css( drupal_get_path( 'theme', 'valencia' ) . '/css/style.css', array( drupal_add_css( drupal_get_path( 'theme', 'valencia' ) . '/css/style.css', array(
'type' => 'file', 'type' => 'file',
'group' => CSS_THEME, 'group' => CSS_THEME,
'every_page' => true 'every_page' => true
)); ));
drupal_add_css( drupal_get_path( 'theme', 'valencia' ) . '/css/footer.css', array( drupal_add_css( drupal_get_path( 'theme', 'valencia' ) . '/css/footer.css', array(
'type' => 'file', 'type' => 'file',
'group' => CSS_THEME, 'group' => CSS_THEME,
'every_page' => true 'every_page' => true
)); ));
/** /**
* Add JavaScript file, setting, or inline code to the page. * Add JavaScript file, setting, or inline code to the page.
* *
* The behaviour of this function depends on the parameters it is called with. * The behaviour of this function depends on the parameters it is called with.
* Generally, it handles the addition of JavaScript to the page, either as reference * Generally, it handles the addition of JavaScript to the page, either as reference
* to an existing file or as inline code. You can: * to an existing file or as inline code. You can:
* - Add a file ('file') * - Add a file ('file')
* - Add inline JavaScript code ('inline'). Make sure to wrap code in `(function($){})(jQuery);` * - Add inline JavaScript code ('inline'). Make sure to wrap code in `(function($){})(jQuery);`
* - Add external JavaScript ('external') * - Add external JavaScript ('external')
* - Add settings ('setting'). Will be accessible at Drupal.settings * - Add settings ('setting'). Will be accessible at Drupal.settings
* *
* If JavaScript aggregation is enabled, all JavaScript files added with $options['preprocess'] * If JavaScript aggregation is enabled, all JavaScript files added with $options['preprocess']
* set to TRUE will be merged into one aggregate file. Preprocessed inline JavaScript will not be * set to TRUE will be merged into one aggregate file. Preprocessed inline JavaScript will not be
* aggregated into this single file. Externally hosted JavaScripts are never aggregated. * aggregated into this single file. Externally hosted JavaScripts are never aggregated.
* *
* @see drupal_get_js() * @see drupal_get_js()
* @since 1.0.0 * @since 1.0.0
* *
* @param string $data Optional. If given, the value depends on the $options or $options['type'] parameter. * @param string $data Optional. If given, the value depends on the $options or $options['type'] parameter.
* @param string|array $options { * @param string|array $options {
* String defining the type of JavaScript that is being added in the $data parameter (<file>, * String defining the type of JavaScript that is being added in the $data parameter (<file>,
* <setting>, <inline>, <external>), or an associative array. JavaScript settings should always * <setting>, <inline>, <external>), or an associative array. JavaScript settings should always
* pass the string 'setting' only. Other types can have the following elements in the array. Optional. * pass the string 'setting' only. Other types can have the following elements in the array. Optional.
* *
* @type string $type Type of JavaScript. Default <file>. Accepts <file>, <inline>, <external>, <setting>. * @type string $type Type of JavaScript. Default <file>. Accepts <file>, <inline>, <external>, <setting>.
* @type string $scope Location of the script. Can use custom regions. Default <header>. Accepts <header>, <footer>. * @type string $scope Location of the script. Can use custom regions. Default <header>. Accepts <header>, <footer>.
* @type integer $group Number of the JS group. Defines priority (higher first). Accepts <JS_LIBRARY>, <JS_DEFAULT>, * @type integer $group Number of the JS group. Defines priority (higher first). Accepts <JS_LIBRARY>, <JS_DEFAULT>,
* <JS_THEME>. * <JS_THEME>.
* @type bool $every_page If present in every page of the website. Default <FALSE>. * @type bool $every_page If present in every page of the website. Default <FALSE>.
* @type integer $weight Priority relative to the scope, group, and every_page. Higher first. * @type integer $weight Priority relative to the scope, group, and every_page. Higher first.
* @type bool $defer If TRUE, defer attribute is set on the script tag. Default <FALSE>. * @type bool $defer If TRUE, defer attribute is set on the script tag. Default <FALSE>.
* @type bool $cache Cache JS file. Used only when $type references a JS file. Default <TRUE>. * @type bool $cache Cache JS file. Used only when $type references a JS file. Default <TRUE>.
* @type bool $preprocess If TRUE and aggregation is enabled, script file will be aggregated. Default <TRUE>. * @type bool $preprocess If TRUE and aggregation is enabled, script file will be aggregated. Default <TRUE>.
* } * }
* @return array JavaScript file, settings, and inline code, including Drupal defaults. * @return array JavaScript file, settings, and inline code, including Drupal defaults.
*/ */
drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/modernizr.2.7.1.js', array( drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/modernizr.2.7.1.js', array(
'type' => 'external', 'type' => 'external',
'group' => JS_LIBRARY, 'group' => JS_LIBRARY,
'every_page' => 'TRUE' 'every_page' => 'TRUE'
)); ));
drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/yui-combined.min.js', array( drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/yui-combined.min.js', array(
'type' => 'external', 'type' => 'external',
'group' => JS_DEFAULT, 'group' => JS_DEFAULT,
'every_page' => 'TRUE', 'every_page' => 'TRUE',
'scope' => 'footer' 'scope' => 'footer'
)); ));
drupal_add_js("if(!core){ var core = {}; } core.globalPrepend = 'body';", array( drupal_add_js("if(!core){ var core = {}; } core.globalPrepend = 'body';", array(
'type' => 'inline', 'type' => 'inline',
'group' => JS_DEFAULT, 'group' => JS_DEFAULT,
'every_page' => 'TRUE', 'every_page' => 'TRUE',
'scope' => 'footer' 'scope' => 'footer'
)); ));
drupal_add_js('http://assets.ubuntu.com/sites/guidelines/js/responsive/core.js', array( drupal_add_js('http://assets.ubuntu.com/sites/guidelines/js/responsive/core.js', array(
'type' => 'external', 'type' => 'external',
'group' => JS_THEME, 'group' => JS_THEME,
'every_page' => 'TRUE', 'every_page' => 'TRUE',
'scope' => 'footer' 'scope' => 'footer'
)); ));
drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/respond.min.js', array( drupal_add_js('http://assets.ubuntu.com/sites/ubuntu/1160/u/js/plugins/respond.min.js', array(
'type' => 'external', 'type' => 'external',
'group' => JS_THEME, 'group' => JS_THEME,
'every_page' => 'TRUE', 'every_page' => 'TRUE',
'scope' => 'footer' 'scope' => 'footer'
)); ));
} }
/** /**
...@@ -166,34 +214,20 @@ function valencia_preprocess_html( &$variables ) { ...@@ -166,34 +214,20 @@ function valencia_preprocess_html( &$variables ) {
* *
*/ */
function valencia_preprocess_page( &$vars ) { function valencia_preprocess_page( &$vars ) {
// Remove the title from all pages but news // Remove the title from all pages but news
if (isset($vars['node'])) { if (isset($vars['node'])) {
if ($vars['node']->type !== 'blog') { if ($vars['node']->type !== 'blog') {
$vars['title'] = ''; $vars['title'] = '';
} }
} }
// Get the entire main menu tree // Get the entire main menu tree
$main_menu_tree = menu_tree_page_data('main-menu'); $main_menu_tree = menu_tree_page_data('main-menu');
// and add the active trail // and add the active trail
menu_tree_add_active_path($main_menu_tree); menu_tree_add_active_path($main_menu_tree);
// Add the rendered output to menu // Add the rendered output to menu
$vars['valencia_menu'] = menu_tree_output($main_menu_tree); $vars['valencia_menu'] = menu_tree_output($main_menu_tree);
/**
* Add meta viewport to page head.
*
* @since 0.1.1
*/
$viewport = array(
'#tag' => 'meta', // The HTML tag - <meta />
'#attributes' => array( // Array of attributes for the tag.
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1.0'
)
);
drupal_add_html_head( $viewport, 'viewport' );
} }
/** /**
...@@ -208,45 +242,45 @@ function valencia_preprocess_page( &$vars ) { ...@@ -208,45 +242,45 @@ function valencia_preprocess_page( &$vars ) {
* http://drupalcontrib.org/api/drupal/contributions!menu_block!menu_block.module/function/menu_tree_add_active_path/7 * http://drupalcontrib.org/api/drupal/contributions!menu_block!menu_block.module/function/menu_tree_add_active_path/7
*/ */
function menu_tree_add_active_path(&$tree) { function menu_tree_add_active_path(&$tree) {
// Grab any menu item to find the menu_name for this tree. // Grab any menu item to find the menu_name for this tree.
$menu_item = current($tree); $menu_item = current($tree);
$tree_with_trail = menu_tree_page_data($menu_item['link']['menu_name']); $tree_with_trail = menu_tree_page_data($menu_item['link']['menu_name']);
// To traverse the original tree down the active trail, we use a pointer. // To traverse the original tree down the active trail, we use a pointer.
$subtree_pointer = &$tree; $subtree_pointer = &$tree;
// Find each key in the active trail. // Find each key in the active trail.
while ($tree_with_trail) { while ($tree_with_trail) {
foreach ($tree_with_trail as $key => &$value) { foreach ($tree_with_trail as $key => &$value) {
if ($tree_with_trail[$key]['link']['in_active_trail']) { if ($tree_with_trail[$key]['link']['in_active_trail']) {
// Set the active trail info in the original tree. // Set the active trail info in the original tree.
$subtree_pointer[$key]['link']['in_active_trail'] = TRUE; $subtree_pointer[$key]['link']['in_active_trail'] = TRUE;
// Continue in the subtree, if it exists. // Continue in the subtree, if it exists.
$tree_with_trail = &$tree_with_trail[$key]['below']; $tree_with_trail = &$tree_with_trail[$key]['below'];
$subtree_pointer = &$subtree_pointer[$key]['below']; $subtree_pointer = &$subtree_pointer[$key]['below'];
break; break;
} }
else { else {
unset($tree_with_trail[$key]); unset($tree_with_trail[$key]);
} }
} }
} }
} }
/** /**
* Choose which menu create basing on the id * Choose which menu create basing on the id
*/ */
function valencia_links__system_main_menu($vars) { function valencia_links__system_main_menu($vars) {
switch ($vars['id']) { switch ($vars['id']) {
case 'header': case 'header':
return valencia_header_menu($vars); return valencia_header_menu($vars);
case 'subheader': case 'subheader':
return valencia_subheader_menu($vars); return valencia_subheader_menu($vars);
case 'breadcrumb': case 'breadcrumb':
return valencia_breadcrumb_menu($vars); return valencia_breadcrumb_menu($vars);
case 'footer': case 'footer':
return valencia_footer_menu($vars); return valencia_footer_menu($vars);
} }
} }
/** /**
...@@ -254,31 +288,31 @@ function valencia_links__system_main_menu($vars) { ...@@ -254,31 +288,31 @@ function valencia_links__system_main_menu($vars) {
* Follows http://design.ubuntu.com/web-style-guide/scaffolding#navigation * Follows http://design.ubuntu.com/web-style-guide/scaffolding#navigation
*/ */
function valencia_header_menu($vars) { function valencia_header_menu($vars) {
// Var with all HTML of the menu // Var with all HTML of the menu
$html = '<ul>'; $html = '<ul>';
foreach ($vars['links'] as $key => $link) { foreach ($vars['links'] as $key => $link) {
// To print every menu voice only one, see Drupal API // To print every menu voice only one, see Drupal API
if (is_numeric($key)) { if (is_numeric($key)) {
$link_title = $link['#title']; $link_title = $link['#title'];
$link_href = $link['#href']; $link_href = $link['#href'];
if ($link['#original_link']['in_active_trail']) { if ($link['#original_link']['in_active_trail']) {
$html .= '<li>' . l($link_title, $link_href, array( $html .= '<li>' . l($link_title, $link_href, array(
'html' => 'true', 'html' => 'true',
'attributes' => array( 'attributes' => array(
'class' => array( 'class' => array(
'active' 'active'
)))) . '</li>'; )))) . '</li>';
} }
else { else {
$html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '</li>'; $html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '</li>';
} }
} }
} }
$html .= '</ul>'; $html .= '</ul>';
return $html; return $html;
} }
/** /**
...@@ -288,27 +322,27 @@ function valencia_header_menu($vars) { ...@@ -288,27 +322,27 @@ function valencia_header_menu($vars) {
* We need to print only the submenu of active menu * We need to print only the submenu of active menu
*/ */
function valencia_subheader_menu($vars) { function valencia_subheader_menu($vars) {
// Var with all HTML of the menu // Var with all HTML of the menu
$html = ''; $html = '';
foreach ($vars['links'] as $key => $link) { foreach ($vars['links'] as $key => $link) {
// To print every menu voice only one, see Drupal API // To print every menu voice only one, see Drupal API
if (is_numeric($key)) { if (is_numeric($key)) {
// Check for submenu, but only if they are of first level and this // Check for submenu, but only if they are of first level and this
// is the active link // is the active link
if (!empty($link['#below']) && $link['#original_link']['depth'] === '1' && $link['#original_link']['in_active_trail']) { if (!empty($link['#below']) && $link['#original_link']['depth'] === '1' && $link['#original_link']['in_active_trail']) {
// If there is a submenu create it using the header function, // If there is a submenu create it using the header function,
// because they have the same struct // because they have the same struct
$sub_menu = theme('links__system_main_menu', array( $sub_menu = theme('links__system_main_menu', array(
'links' => $link['#below'], 'links' => $link['#below'],
'id' => 'header' 'id' => 'header'
)); ));
$html .= $sub_menu; $html .= $sub_menu;
} }
} }
} }
return $html; return $html;
} }
/** /**
...@@ -319,69 +353,69 @@ function valencia_subheader_menu($vars) { ...@@ -319,69 +353,69 @@ function valencia_subheader_menu($vars) {
* Also, if there is, we print third level menu * Also, if there is, we print third level menu
*/ */
function valencia_breadcrumb_menu($vars) { function valencia_breadcrumb_menu($vars) {
// Var with all HTML // Var with all HTML
$html = ''; $html = '';
foreach ($vars['links'] as $key => $link) { foreach ($vars['links'] as $key => $link) {
// See Drupal API, is to print every menu voice only one // See Drupal API, is to print every menu voice only one
if (is_numeric($key)) { if (is_numeric($key)) {
// We need only active links, with children and we // We need only active links, with children and we
// don't want the news page // don't want the news page
if ($link['#original_link']['in_active_trail'] && if ($link['#original_link']['in_active_trail'] &&
!empty($link['#below']) && !empty($link['#below']) &&
$link['#title'] !== 'News') { $link['#title'] !== 'News') {
// If is the first level link and it has children, // If is the first level link and it has children,
// we start to create the breadcrumb // we start to create the breadcrumb
if(!empty($link['#below']) && $link['#original_link']['depth'] === '1') { if(!empty($link['#below']) && $link['#original_link']['depth'] === '1') {
// Now we need to attach second level menu // Now we need to attach second level menu
$sub_menu = theme('links__system_main_menu', array( $sub_menu = theme('links__system_main_menu', array(
'links' => $link['#below'], 'links' => $link['#below'],
'id' => 'breadcrumb' 'id' => 'breadcrumb'
)); ));
$html .= $sub_menu; $html .= $sub_menu;
} }
// Second level link: could be the active one, or only a // Second level link: could be the active one, or only a
// breadcrumb for third level (or both) // breadcrumb for third level (or both)
else if ($link['#original_link']['depth'] === '2') { else if ($link['#original_link']['depth'] === '2') {
$html .= '<ul class="breadcrumb">'; $html .= '<ul class="breadcrumb">';
// If it hasn't child, is the active link // If it hasn't child, is the active link
if (empty($link['#below'])) { if (empty($link['#below'])) {
$link_title = $link['#title']; $link_title = $link['#title'];
$link_href = $link['#href']; $link_href = $link['#href'];
$html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>'; $html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>';
// We close the ul with class breadcrumb, as per design // We close the ul with class breadcrumb, as per design
$html .= '</ul>'; $html .= '</ul>';
} }
else { else {
// If it has children could be active or not. // If it has children could be active or not.
// To check we need to create first the third level // To check we need to create first the third level
// menu, and check if any of the third level menu links // menu, and check if any of the third level menu links
// is active // is active
list ($has_child_active_link, $third_level_menu) = valencia_third_level_menu($link['#below']); list ($has_child_active_link, $third_level_menu) = valencia_third_level_menu($link['#below']);
$link_title = $link['#title']; $link_title = $link['#title'];
$link_href = $link['#href']; $link_href = $link['#href'];
// If a child is active, this one isn't active // If a child is active, this one isn't active
if ($has_child_active_link) { if ($has_child_active_link) {
$html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '&nbsp;&rsaquo;</li>'; $html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '&nbsp;&rsaquo;</li>';
} }
else { else {
$html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>'; $html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>';
} }
// We close the ul with class breadcrumb, as per design // We close the ul with class breadcrumb, as per design
$html .= '</ul>'; $html .= '</ul>';
// Then, third level menu // Then, third level menu
$html .= $third_level_menu; $html .= $third_level_menu;
} }
} }
} }
} }
} }
return $html; return $html;
} }
/** /**
...@@ -394,31 +428,31 @@ function valencia_breadcrumb_menu($vars) { ...@@ -394,31 +428,31 @@ function valencia_breadcrumb_menu($vars) {
* active link, the second element is the html of third level menu * active link, the second element is the html of third level menu
*/ */
function valencia_third_level_menu($vars) { function valencia_third_level_menu($vars) {
// Var with all HTML // Var with all HTML
$html = '<ul class="third-level">'; $html = '<ul class="third-level">';
// This becomes TRUE if there is an active link // This becomes TRUE if there is an active link
$has_active_link = FALSE; $has_active_link = FALSE;
foreach ($vars as $key => $link) { foreach ($vars as $key => $link) {
// See Drupal API, is to print every menu voice only one // See Drupal API, is to print every menu voice only one
if (is_numeric($key)) { if (is_numeric($key)) {
if ($link['#original_link']['in_active_trail']) { if ($link['#original_link']['in_active_trail']) {
$has_active_link = TRUE; $has_active_link = TRUE;
$link_title = $link['#title']; $link_title = $link['#title'];
$link_href = $link['#href']; $link_href = $link['#href'];
$html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>'; $html .= '<li class="active">' . l($link_title, $link_href, array('html' => 'true')) . '</li>';
} }
else { else {
$link_title = $link['#title']; $link_title = $link['#title'];
$link_href = $link['#href']; $link_href = $link['#href'];
$html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '</li>'; $html .= '<li>' . l($link_title, $link_href, array('html' => 'true')) . '</li>';
} }
} }
} }
$html .= '</ul>'; $html .= '</ul>';
return array($has_active_link, $html); return array($has_active_link, $html);
} }
/** /**
...@@ -435,52 +469,52 @@ function valencia_third_level_menu($vars) { ...@@ -435,52 +469,52 @@ function valencia_third_level_menu($vars) {
* https://gitlab.com/ubuntu-it-web/valencia/issues/6 * https://gitlab.com/ubuntu-it-web/valencia/issues/6
*/ */
function valencia_footer_menu($vars) { function valencia_footer_menu($vars) {
// Var with all HTML of the menu // Var with all HTML of the menu
$html = '<ul>'; $html = '<ul>';
// Counter to select first element of every submenu to add class .first // Counter to select first element of every submenu to add class .first
$voice_number = 0; $voice_number = 0;
foreach ($vars['links'] as $key => $link) { foreach ($vars['links'] as $key => $link) {
// To print every menu voice only one, see Drupal API // To print every menu voice only one, see Drupal API
if (is_numeric($key)) { if (is_numeric($key)) {
// Store the submenu links // Store the submenu links
$sub_menu = ''; $sub_menu = '';
$link_title = $link['#title']; $link_title = $link['#title'];
// Check for submenu, but only if they are of first level! // Check for submenu, but only if they are of first level!
if (!empty($link['#below']) && $link['#original_link']['depth'] === '1') { if (!empty($link['#below']) && $link['#original_link']['depth'] === '1') {
// If there is a submenu create it using the same function // If there is a submenu create it using the same function
$sub_menu = theme('links__system_main_menu', array( $sub_menu = theme('links__system_main_menu', array(
'links' => $link['#below'], 'links' => $link['#below'],
'id' => 'footer' 'id' => 'footer'
)); ));
} }
/** /**
* We have 3 types of link: * We have 3 types of link:
* - First level link, they are h2 title, and will be identify for * - First level link, they are h2 title, and will be identify for
* by their depth of 1 * by their depth of 1
* - First link of second level menus, they have class .first, * - First link of second level menus, they have class .first,
* identified by $voice_number * identified by $voice_number
* - Others links of second level menus * - Others links of second level menus
*/ */
if ($link['#original_link']['depth'] === '1') { if ($link['#original_link']['depth'] === '1') {
// First level menu is h2 // First level menu is h2
$html .= '<li><h2>' . l($link_title, $link['#href'], array('html' => 'true')) . '</h2>' . $sub_menu . '</li>'; $html .= '<li><h2>' . l($link_title, $link['#href'], array('html' => 'true')) . '</h2>' . $sub_menu . '</li>';
} }
else if ($voice_number === 0) { else if ($voice_number === 0) {
// The first submenu of every menu has class first // The first submenu of every menu has class first
$html .= '<li class="first">' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>'; $html .= '<li class="first">' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>';
} }
else { else {
// Submenu voice // Submenu voice
$html .= '<li>' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>'; $html .= '<li>' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>';
} }
$voice_number++; $voice_number++;
} }
} }
$html .= '</ul>'; $html .= '</ul>';
return $html; return $html;
} }
if ( !function_exists( 'region_empty' ) ) : if ( !function_exists( 'region_empty' ) ) :
...@@ -494,34 +528,34 @@ if ( !function_exists( 'region_empty' ) ) : ...@@ -494,34 +528,34 @@ if ( !function_exists( 'region_empty' ) ) :
* @return bool. True if empty, false otherwise. * @return bool. True if empty, false otherwise.
*/ */
function region_empty( $region ) { function region_empty( $region ) {
$empty = 1; $empty = 1;
$result = db_query_range( 'SELECT n.pages, n.visibility FROM {blocks} n WHERE n.region="%s" AND n.theme="%s"', $region, $GLOBALS['theme'], 0, 10 ); $result = db_query_range( 'SELECT n.pages, n.visibility FROM {blocks} n WHERE n.region="%s" AND n.theme="%s"', $region, $GLOBALS['theme'], 0, 10 );
if ( count($result) > 0 ) { if ( count($result) > 0 ) {
while ( $node = db_fetch_object($result) ) { while ( $node = db_fetch_object($result) ) {
if ( $node->visibility < 2 ) { if ( $node->visibility < 2 ) {
$path = drupal_get_path_alias($_GET['q']); $path = drupal_get_path_alias($_GET['q']);
// Compare with the internal and path alias (if any) // Compare with the internal and path alias (if any)
$page_match = drupal_match_path($path, $node->pages); $page_match = drupal_match_path($path, $node->pages);
if ( $path != $_GET['q'] ) if ( $path != $_GET['q'] )
$page_match = $page_match || drupal_match_path( $_GET['q'], $node->pages ); $page_match = $page_match || drupal_match_path( $_GET['q'], $node->pages );
/** /**
* When $block->visibility has a value of 0, the block is displayed on * When $block->visibility has a value of 0, the block is displayed on
* all pages except those listed in $block->pages. When set to 1, it * all pages except those listed in $block->pages. When set to 1, it
* is displayed only on those pages listed in $block->pages. * is displayed only on those pages listed in $block->pages.
*/ */
$page_match = !( $node->visibility xor $page_match ); $page_match = !( $node->visibility xor $page_match );
} else { } else {
$page_match = drupal_eval( $block->pages ); $page_match = drupal_eval( $block->pages );
} }
if ( $page_match ) if ( $page_match )
$empty = 0; $empty = 0;
} }
} }
return $empty; return $empty;
} }
endif; endif;
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
<html lang="<?php print $language->language; ?>"> <html lang="<?php print $language->language; ?>">
<head profile="<?php print $grddl_profile; ?>"> <head profile="<?php print $grddl_profile; ?>">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="charset" content="utf-8">
<?php print $head; ?> <?php print $head; ?>
<title><?php print $head_title; ?></title> <title><?php print $head_title; ?></title>
<?php print $styles; ?> <?php print $styles; ?>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment