diff --git html5_foundation/html5_foundation.info html5_foundation/html5_foundation.info new file mode 100644 index 0000000..c66b6ab --- /dev/null +++ html5_foundation/html5_foundation.info @@ -0,0 +1,21 @@ +; $Id +name = HTML5 Foundation +description = A base theme built on HTML5 Base theme.
This theme includes settings and features not suitable for inclusion in Drupal Core. This theme requires the HTML5 Tools module. http://drupal.org/project/html5_tools. +screenshot = images/screenshot.png +core = 7.x +base theme = html5_base + + +; SETTINGS +; ------------------------------ + +settings[html5_foundation_modernizr] = 0 +settings[html5_foundation_use_mobile_viewport] = 0 +settings[html5_foundation_mobile_viewport] = 'width=device-width; initial-scale=1.0; maximum-scale=1.0;' +settings[html5_foundation_include_chrome_frame] = 1 +settings[html5_foundation_breadcrumb] = yes +settings[html5_foundation_breadcrumb_separator] = ' » ' +settings[html5_foundation_breadcrumb_home] = 1 +settings[html5_foundation_breadcrumb_trailing] = 0 +settings[html5_foundation_breadcrumb_title] = 0 + diff --git html5_foundation/template.php html5_foundation/template.php new file mode 100644 index 0000000..a4662c1 --- /dev/null +++ html5_foundation/template.php @@ -0,0 +1,80 @@ + 'meta', + '#attributes' => array( + 'http-equiv' => 'X-UA-Compatible', + 'content' => 'IE=edge,chrome=1', + ), + ); + drupal_add_html_head($element,'chrome_array'); + } + + // Mobile Viewport Fix + if (theme_get_setting('html5_foundation_use_mobile_viewport') && strlen(theme_get_setting('html5_base_mobile_viewport')) > 1) { + $element = array( + '#tag' => 'meta', + '#attributes' => array( + 'name' => 'viewport', + 'content' => theme_get_setting('html5_foundation_mobile_viewport'), + ), + ); + drupal_add_html_head($element,'mobile_viewport'); + } +} + +/** +* Return a themed breadcrumb trail. +* +* @param $variables +* An array containing the breadcrumb links. +* @return +* A string containing the breadcrumb output. +*/ +function html5_foundation_breadcrumb($variables) { + $breadcrumb = $variables['breadcrumb']; + + // Determine if we are to display the breadcrumb. + $show_breadcrumb = theme_get_setting('html5_foundation_breadcrumb'); + if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') { + + // Optionally get rid of the homepage link. + $show_breadcrumb_home = theme_get_setting('html5_foundation_breadcrumb_home'); + if (!$show_breadcrumb_home) { + array_shift($breadcrumb); + } + + // Return the breadcrumb with separators. + if (!empty($breadcrumb)) { + $breadcrumb_separator = theme_get_setting('html5_foundation_breadcrumb_separator'); + $trailing_separator = $title = ''; + if (theme_get_setting('html5_foundation_breadcrumb_title')) { + if ($title = drupal_get_title()) { + $trailing_separator = $breadcrumb_separator; + } + } + elseif (theme_get_setting('html5_foundation_breadcrumb_trailing')) { + $trailing_separator = $breadcrumb_separator; + } + return '"; + } + } + // Otherwise, return an empty string. + return ''; +} diff --git html5_foundation/theme-settings.php html5_foundation/theme-settings.php new file mode 100644 index 0000000..074be22 --- /dev/null +++ html5_foundation/theme-settings.php @@ -0,0 +1,96 @@ + 'fieldset', + '#title' => t('Activate JavaScript Libraries'), + '#attributes' => array('id' => 'html5_foundation-js-libraries'), + ); + $form['javascript_libraries']['html5_foundation_modernizr'] = array( + '#type' => 'checkbox', + '#title' => t('Include Modernizr'), + '#default_value' => theme_get_setting('html5_foundation_modernizr'), + '#description' => t('Include a reference the the Modernizr JS library. (!url)
+ Requires manual download. Place in /sites/all/themes/html5_foundation/js/ directory.', array('!url' => l('Modernizr', 'http://www.modernizr.com'))), + '#prefix' => '' . t('Modernizr') . ':', + ); + + $form['mobile_viewport'] = array( + '#type' => 'fieldset', + '#title' => t('Meta tags for mobile devices'), + '#attributes' => array('id' => 'html5_foundation-mobile-view-port'), + ); + $form['mobile_viewport']['html5_foundation_use_mobile_viewport'] = array( + '#type' => 'checkbox', + '#title' => t('Use a mobile viewport meta tag'), + '#default_value' => theme_get_setting('html5_foundation_use_mobile_viewport'), + '#prefix' => '' . t('Mobile Viewport Fix') . ':', + ); + $form['mobile_viewport']['html5_foundation_mobile_viewport'] = array( + '#type' => 'textfield', + '#title' => t('Mobile viewport meta tag value'), + '#default_value' => theme_get_setting('html5_foundation_mobile_viewport'), + '#description' => t('device-width : Occupy full width of the screen in its current orientation
+ initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
+ maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width
+ suggested default: width=device-width; initial-scale=1.0; maximum-scale=1.0;
+ More info + '), + ); + $form['html5_foundation_include_chrome_frame'] = array( + '#type' => 'checkbox', + '#title' => t('Include Chrome Frame for IE users with Chrome Frame installed'), + '#default_value' => theme_get_setting('html5_foundation_include_chrome_frame'), + '#description' => t('Include a meta tag to initialize Chrome Frame. Only affects IE users who already have Chrome Frame installed.'), + '#prefix' => '' . t('Chrome Frame') . ':', + ); + + $form['html5_foundation_breadcrumb'] = array( + '#type' => 'fieldset', + '#title' => t('Breadcrumb settings'), + '#attributes' => array('id' => 'html5_foundation-breadcrumb'), + ); + $form['html5_foundation_breadcrumb']['html5_foundation_breadcrumb'] = array( + '#type' => 'select', + '#title' => t('Display breadcrumb'), + '#default_value' => theme_get_setting('html5_foundation_breadcrumb'), + '#options' => array( + 'yes' => t('Yes'), + 'admin' => t('Only in admin section'), + 'no' => t('No'), + ), + ); + $form['html5_foundation_breadcrumb']['html5_foundation_breadcrumb_separator'] = array( + '#type' => 'textfield', + '#title' => t('Breadcrumb separator'), + '#description' => t('Text only. Don’t forget to include spaces.'), + '#default_value' => theme_get_setting('html5_foundation_breadcrumb_separator'), + '#size' => 5, + '#maxlength' => 10, + '#prefix' => '
', // jquery hook to show/hide optional widgets + ); + $form['html5_foundation_breadcrumb']['html5_foundation_breadcrumb_home'] = array( + '#type' => 'checkbox', + '#title' => t('Show home page link in breadcrumb'), + '#default_value' => theme_get_setting('html5_foundation_breadcrumb_home'), + ); + $form['html5_foundation_breadcrumb']['html5_foundation_breadcrumb_trailing'] = array( + '#type' => 'checkbox', + '#title' => t('Append a separator to the end of the breadcrumb'), + '#default_value' => theme_get_setting('html5_foundation_breadcrumb_trailing'), + '#description' => t('Useful when the breadcrumb is placed just before the title.'), + ); + $form['html5_foundation_breadcrumb']['html5_foundation_breadcrumb_title'] = array( + '#type' => 'checkbox', + '#title' => t('Append the content title to the end of the breadcrumb'), + '#default_value' => theme_get_setting('html5_foundation_breadcrumb_title'), + '#description' => t('Useful when the breadcrumb is not placed just before the title.'), + '#suffix' => '
', // #div-zen-breadcrumb + ); + +} + diff --git theme-settings.php theme-settings.php deleted file mode 100644 index e155392..0000000 --- theme-settings.php +++ /dev/null @@ -1,204 +0,0 @@ - 'fieldset', - '#title' => t('Activate JavaScript Libraries'), - '#attributes' => array('id' => 'html5_base-js-libraries'), - ); - $form['javascript_libraries']['html5_base_modernizr'] = array( - '#type' => 'checkbox', - '#title' => t('Include Modernizr'), - '#default_value' => $settings['html5_base_modernizr'], - '#description' => t('Include a reference the the Modernizr JS library. (!url)
- Requires manual download. Place in /sites/all/themes/html5_base/js/ directory.', array('!url' => l('Modernizr', 'http://www.modernizr.com'))), - '#prefix' => '' . t('Modernizr') . ':', - ); - - $form['mobile_viewport'] = array( - '#type' => 'fieldset', - '#title' => t('Meta tags for mobile devices'), - '#attributes' => array('id' => 'html5_base-mobile-view-port'), - ); - $form['mobile_viewport']['html5_base_use_mobile_viewport'] = array( - '#type' => 'checkbox', - '#title' => t('Use a mobile viewport meta tag'), - '#default_value' => $settings['html5_base_use_mobile_viewport'], - '#prefix' => '' . t('Mobile Viewport Fix') . ':', - ); - $form['mobile_viewport']['html5_base_mobile_viewport'] = array( - '#type' => 'textfield', - '#title' => t('Mobile viewport meta tag value'), - '#default_value' => $settings['html5_base_mobile_viewport'], - '#description' => t('device-width : Occupy full width of the screen in its current orientation
- initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
- maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width
- suggested default: width=device-width; initial-scale=1.0; maximum-scale=1.0;
- More info - '), - ); - $form['html5_base_include_chrome_frame'] = array( - '#type' => 'checkbox', - '#title' => t('Include Chrome Frame for IE users with Chrome Frame installed'), - '#default_value' => $settings['html5_base_include_chrome_frame'], - '#description' => t('Include a meta tag to initialize Chrome Frame. Only affects IE users who already have Chrome Frame installed.'), - '#prefix' => '' . t('Chrome Frame') . ':', - ); - - $form['html5_base_zen_tabs'] = array( - '#type' => 'checkbox', - '#title' => t('Use Zen Tabs'), - '#default_value' => $settings['html5_base_zen_tabs'], - '#description' => t('Replace the default tabs by the Zen Tabs.'), - '#prefix' => '' . t('Zen Tabs') . ':', - ); - - $form['html5_base_breadcrumb'] = array( - '#type' => 'fieldset', - '#title' => t('Breadcrumb settings'), - '#attributes' => array('id' => 'html5_base-breadcrumb'), - ); - $form['html5_base_breadcrumb']['html5_base_breadcrumb'] = array( - '#type' => 'select', - '#title' => t('Display breadcrumb'), - '#default_value' => $settings['html5_base_breadcrumb'], - '#options' => array( - 'yes' => t('Yes'), - 'admin' => t('Only in admin section'), - 'no' => t('No'), - ), - ); - $form['html5_base_breadcrumb']['html5_base_breadcrumb_separator'] = array( - '#type' => 'textfield', - '#title' => t('Breadcrumb separator'), - '#description' => t('Text only. Don’t forget to include spaces.'), - '#default_value' => $settings['html5_base_breadcrumb_separator'], - '#size' => 5, - '#maxlength' => 10, - '#prefix' => '
', // jquery hook to show/hide optional widgets - ); - $form['html5_base_breadcrumb']['html5_base_breadcrumb_home'] = array( - '#type' => 'checkbox', - '#title' => t('Show home page link in breadcrumb'), - '#default_value' => $settings['html5_base_breadcrumb_home'], - ); - $form['html5_base_breadcrumb']['html5_base_breadcrumb_trailing'] = array( - '#type' => 'checkbox', - '#title' => t('Append a separator to the end of the breadcrumb'), - '#default_value' => $settings['html5_base_breadcrumb_trailing'], - '#description' => t('Useful when the breadcrumb is placed just before the title.'), - ); - $form['html5_base_breadcrumb']['html5_base_breadcrumb_title'] = array( - '#type' => 'checkbox', - '#title' => t('Append the content title to the end of the breadcrumb'), - '#default_value' => $settings['html5_base_breadcrumb_title'], - '#description' => t('Useful when the breadcrumb is not placed just before the title.'), - '#suffix' => '
', // #div-zen-breadcrumb - ); - - $form['html5_base_wireframe'] = array( - '#type' => 'checkbox', - '#title' => t('Display borders around main layout elements'), - '#default_value' => $settings['html5_base_wireframe'], - '#description' => t('Wireframes are useful when prototyping a website.', array('!link' => 'http://www.boxesandarrows.com/view/html_wireframes_and_prototypes_all_gain_and_no_pain')), - '#prefix' => '' . t('Wireframes') . ':', - ); - - $form['html5_base_block_editing'] = array( - '#type' => 'checkbox', - '#title' => t('Show block editing on hover'), - '#description' => t('When hovering over a block, privileged users will see block editing links.'), - '#default_value' => $settings['html5_base_block_editing'], - '#prefix' => '' . t('Block Edit Links') . ':', - ); - - $form['themedev']['html5_base_rebuild_registry'] = array( - '#type' => 'checkbox', - '#title' => t('Rebuild theme registry on every page.'), - '#default_value' => $settings['html5_base_rebuild_registry'], - '#description' => t('During theme development, it can be very useful to continuously rebuild the theme registry. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')), - '#prefix' => '
' . t('Theme registry') . ':', - '#suffix' => '
', - ); - - // Return the form - return $form; -} - - -function _html5_base_theme(&$existing, $type, $theme, $path) { - // Each theme has two possible preprocess functions that can act on a hook. - // This function applies to every hook. - $functions[0] = $theme . '_preprocess'; - // Inspect the preprocess functions for every hook in the theme registry. - // @TODO: When PHP 5 becomes required (Zen 7.x), use the following faster - // implementation: foreach ($existing AS $hook => &$value) {} - foreach (array_keys($existing) AS $hook) { - // Each theme has two possible preprocess functions that can act on a hook. - // This function only applies to this hook. - $functions[1] = $theme . '_preprocess_' . $hook; - foreach ($functions AS $key => $function) { - // Add any functions that are not already in the registry. - if (function_exists($function) && !in_array($function, $existing[$hook]['preprocess functions'])) { - // We add the preprocess function to the end of the existing list. - $existing[$hook]['preprocess functions'][] = $function; - } - } - } - - // Since we are rebuilding the theme registry and the theme settings' default - // values may have changed, make sure they are saved in the database properly. - html5_base_theme_get_default_settings($theme); - - // If we are auto-rebuilding the theme registry, warn about feature. - if (theme_get_setting('html5_base_rebuild_registry')) { - drupal_set_message(t('The theme registry has been rebuilt. Turn off this feature on production websites.', array('!link' => base_path() . 'admin/build/themes/settings/' . $GLOBALS['theme'])), 'warning'); - } - - // Since we modify the $existing cache directly, return nothing. - return array(); -} - - -function html5_base_theme_get_default_settings($theme) { - $themes = list_themes(); - - // Get the default values from the .info file. - $defaults = !empty($themes[$theme]->info['settings']) ? $themes[$theme]->info['settings'] : array(); - - if (!empty($defaults)) { - // Get the theme settings saved in the database. - $settings = theme_get_settings($theme); - // Don't save the toggle_node_info_ variables. - if (module_exists('node')) { - foreach (node_get_types() as $type => $name) { - unset($settings['toggle_node_info_' . $type]); - } - } - // Save default theme settings. - variable_set( - str_replace('/', '_', 'theme_' . $theme . '_settings'), - array_merge($defaults, $settings) - ); - // If the active theme has been loaded, force refresh of Drupal internals. - if (!empty($GLOBALS['theme_key'])) { - theme_get_setting('', TRUE); - } - } - - // Return the default settings. - return $defaults; -}