commit 1dc9554f934715f96350a830c8e90cda971ba761
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Mon Nov 26 15:10:34 2012 +0000

    theme customization improved - layout adapts to image sizes

diff --git a/7.x/themes/zen_dataportal/.sass-cache/b7ec75a973b6ef8187af26f68d839cc5b2c81e58/navigation.scssc b/7.x/themes/zen_dataportal/.sass-cache/b7ec75a973b6ef8187af26f68d839cc5b2c81e58/navigation.scssc
index 9f1be259..0b8c02e0 100644
Binary files a/7.x/themes/zen_dataportal/.sass-cache/b7ec75a973b6ef8187af26f68d839cc5b2c81e58/navigation.scssc and b/7.x/themes/zen_dataportal/.sass-cache/b7ec75a973b6ef8187af26f68d839cc5b2c81e58/navigation.scssc differ
diff --git a/7.x/themes/zen_dataportal/css/navigation.css b/7.x/themes/zen_dataportal/css/navigation.css
index e550eeb4..3055d6dc 100644
--- a/7.x/themes/zen_dataportal/css/navigation.css
+++ b/7.x/themes/zen_dataportal/css/navigation.css
@@ -59,10 +59,12 @@ li a.active {
   /* Menu block links */
   margin: 0;
   padding: 0;
+  margin-left: -20px;
   text-align: left;
   /* LTR */
+  display: block;
 }
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000366}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000368}}
 #navigation ul.links li,
 #navigation ul.menu li {
   /* A simple method to get navigation links to appear in one line. */
@@ -77,12 +79,12 @@ li a.active {
   margin-left: -1px;
   /* collapse borders */
 }
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000376}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000378}}
 #navigation ul.links li.first,
 #navigation ul.menu li.first {
   border-left: 0;
 }
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000380}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000382}}
 #navigation ul.links li.last,
 #navigation ul.menu li.last {
   border-right: 0;
@@ -91,27 +93,27 @@ li a.active {
 /*
  * Main menu and Secondary menu links
  */
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000393}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\0000395}}
 #main-menu {
-  padding-top: 5px;
-  height: 20px;
+  padding: 2.5px 0;
   padding-left: 73px;
   background-color: #dedede;
+  display: block;
   font-size: 14.4px;
 }
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003100}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003102}}
 #main-menu a:link,
 #main-menu a:visited {
   color: black;
   text-decoration: none;
 }
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003106}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003108}}
 #main-menu a:hover,
 #main-menu a:focus {
   text-decoration: underline;
 }
 
-@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003111}}
+@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/andreas\/workspaces\/www\/drupal-7\.16\/sites\/all\/themes\/zen_dataportal\/sass\/navigation\.scss}line{font-family:\00003113}}
 #secondary-menu {
   float: right;
   /* LTR */
diff --git a/7.x/themes/zen_dataportal/sass/navigation.scss b/7.x/themes/zen_dataportal/sass/navigation.scss
index 75749398..728c2db7 100644
--- a/7.x/themes/zen_dataportal/sass/navigation.scss
+++ b/7.x/themes/zen_dataportal/sass/navigation.scss
@@ -61,7 +61,9 @@ li a.active {
   ul.menu { /* Menu block links */
     margin: 0;
     padding: 0;
+    margin-left: -$zen-gutter-width; 
     text-align: left; /* LTR */
+    display: block;
 
     li { /* A simple method to get navigation links to appear in one line. */
       float: left; /* LTR */
@@ -91,10 +93,10 @@ li a.active {
  */
 
 #main-menu {
-    padding-top: $zen-gutter-width / 4; 
-    height: $menu-bar-line-height;
+    padding: ($zen-gutter-width / 8) 0; 
     padding-left: 93px - $zen-gutter-width; // width of logo image
     background-color: $menu-bar-background-color;
+    display: block;
     font-size: $menu-bar-font-size;
     a:link,
     a:visited {
diff --git a/7.x/themes/zen_dataportal/template.php b/7.x/themes/zen_dataportal/template.php
index b2b9f711..00dd9719 100644
--- a/7.x/themes/zen_dataportal/template.php
+++ b/7.x/themes/zen_dataportal/template.php
@@ -106,17 +106,15 @@
  *   name of the image, see _zen_dataportal_imagenames() for possible values
  * @param $variables
  *   An array of variables to pass to the theme template.
- * @param $attributes_key
- *
+ * @param $css_selector
+ *   The dom element to apply the image as background image
  * @param $background_style
+ *   Addtional css setting for the background css attribute, default is  'scroll repeat'
  *
  * @see _zen_dataportal_imagenames() for possible values
  */
-function _set_image_url($which_image, &$variables, $attributes_key = NULL, $background_style = 'scroll repeat') {
+function _set_image_url($which_image, &$variables, $css_selector = NULL, $background_style = 'scroll repeat') {
 
-  if($attributes_key) {
-    $variables[$attributes_key] = '';
-  }
 
   if (!theme_get_setting('default_' . $which_image)) {
     $path = theme_get_setting($which_image . '_path');
@@ -126,9 +124,13 @@ function _set_image_url($which_image, &$variables, $attributes_key = NULL, $back
       }
       if(isset($url)) {
         $variables[$which_image . '_url'] = $url;
-        if($attributes_key) {
+
+        if($css_selector) {
+          if(!isset($variables['inline_styles'])) {
+            $variables['inline_styles'] = array();
+          }
           // FIXME is not save only works if no other style given e.g. html.php $attributes
-          $variables[$attributes_key] = ' style="background: white url(' . $url .')  ' . $background_style . ';"';
+          $variables['inline_styles'][] = $css_selector . ' {background: white url(' . $url .')  ' . $background_style . ';}';
         }
       }
 
@@ -141,14 +143,19 @@ function _set_image_url($which_image, &$variables, $attributes_key = NULL, $back
 function _add_inline_styles(&$variables) {
 
   $css = array();
-  $variables['inline_styles'] = '';
+  if(!isset($variables['inline_styles'])) {
+    $variables['inline_styles'] = array();
+  }
 
   // site_name
   if(theme_get_setting('site_name_color')) {
-      $css[] = "#site-name a span {color:" . theme_get_setting('site_name_color') . ';}';
+      $variables['inline_styles'][] = "#site-name a span {color:" . theme_get_setting('site_name_color') . ';}';
+  }
+  if(theme_get_setting('logo_size')) {
+    $logo_size = theme_get_setting('logo_size');
+    $variables['inline_styles'][] = '#header {background-position:' . $logo_size['width'] . 'px 0;}';
+    $variables['inline_styles'][] = '#main-menu {padding-left:' . $logo_size['width'] . 'px;}';
   }
-
-  $variables['inline_styles'] = '<style type="text/css">'. "\n" . implode("\n", $css) . '</style>';
 }
 
 
@@ -179,7 +186,9 @@ function STARTERKIT_preprocess_maintenance_page(&$variables, $hook) {
  *   The name of the template being rendered ("html" in this case.)
  */
 function zen_dataportal_preprocess_html(&$variables, $hook) {
-  _set_image_url('body_background', $variables, 'attributes');
+  _set_image_url('body_background', $variables, 'body');
+  _set_image_url('page_background', $variables, '#page');
+  _set_image_url('banner', $variables, '#header', 'scroll no-repeat content-box');
   _add_inline_styles($variables);
 }
 
@@ -192,8 +201,6 @@ function zen_dataportal_preprocess_html(&$variables, $hook) {
  *   The name of the template being rendered ("page" in this case.)
  */
 function zen_dataportal_preprocess_page(&$variables, $hook) {
-  _set_image_url('banner', $variables, 'banner_attributes', 'scroll no-repeat content-box');
-  _set_image_url('page_background', $variables, 'page_attributes');
 }
 
 /**
diff --git a/7.x/themes/zen_dataportal/templates/html.tpl.php b/7.x/themes/zen_dataportal/templates/html.tpl.php
index 262c0bb9..fd3801f7 100644
--- a/7.x/themes/zen_dataportal/templates/html.tpl.php
+++ b/7.x/themes/zen_dataportal/templates/html.tpl.php
@@ -63,7 +63,7 @@
  *     - one-sidebar and sidebar-first or sidebar-second: A combination of the
  *       two classes when only one of the two sidebars have content.
  * - $body_background_url: from zen_dataportal theme-settings.php
- * - $inline_styles: custom styles for specific elements from zen_dataportal
+ * - $inline_styles: an array of custom styles for specific elements from zen_dataportal
  *    theme-settings.php
  *
  * @see template_preprocess()
@@ -90,7 +90,7 @@
   <meta http-equiv="cleartype" content="on">
 
   <?php print $styles; ?>
-  <?php print $inline_styles; ?>
+  <?php print '<style type="text/css">'. "\n" . implode("\n", $inline_styles) . "\n</style>;" ?>
   <?php print $scripts; ?>
   <?php if ($add_respond_js): ?>
     <!--[if lt IE 9]>
@@ -102,12 +102,6 @@
     <![endif]-->
   <?php endif; ?>
 </head>
-<?php
-  // FIXME is not save only works if no other style given
-//    if (isset($body_background_url)){
-//      $attributes .= ' style="background: white url(' . $body_background_url .')  fixed repeat;"';
-//    }
-?>
 <body class="<?php print $classes; ?>" <?php print $attributes;?>>
   <?php if ($skip_link_text && $skip_link_anchor): ?>
     <p id="skip-link">
diff --git a/7.x/themes/zen_dataportal/templates/page.tpl.php b/7.x/themes/zen_dataportal/templates/page.tpl.php
index da07305c..aed75e48 100644
--- a/7.x/themes/zen_dataportal/templates/page.tpl.php
+++ b/7.x/themes/zen_dataportal/templates/page.tpl.php
@@ -53,8 +53,6 @@
  *   comment/reply/12345).
  * - $banner_url: from zen_dataportal theme-settings.php
  * - $page_background_url: from zen_dataportal theme-settings.php
- * - $page_attributes: will contain style with $page_background_url
- * - $header_attributes: will contain style with $page_background_url
  *
  * Regions:
  * - $page['header']: Items for the header region.
@@ -74,9 +72,9 @@
  */
 ?>
 
-<div id="page" <?php print $page_attributes; ?> >
+<div id="page">
 
-  <header id="header" role="banner" <?php print $banner_attributes; ?>>
+  <header id="header" role="banner">
     <?php if ($logo): ?>
       <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"><img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /></a>
     <?php endif; ?>
diff --git a/7.x/themes/zen_dataportal/theme-settings.php b/7.x/themes/zen_dataportal/theme-settings.php
index 41b40405..77479ddc 100644
--- a/7.x/themes/zen_dataportal/theme-settings.php
+++ b/7.x/themes/zen_dataportal/theme-settings.php
@@ -43,62 +43,12 @@ function zen_dataportal_form_system_theme_settings_alter(&$form, &$form_state, $
   // custom images for banner, body and page backgrounds
   //
   foreach(_zen_dataportal_imagenames() as $which_image) {
-    $image_label = str_replace('_', ' ', $which_image);
-    $form['zen_dataportal_' .  $which_image] = array(
-        '#type' => 'fieldset',
-        '#title' => ucfirst(t($image_label)) . ' ' . t('image settings'),
-        '#description' => t('If toggled on, the following image will be displayed.'),
-        '#attributes' => array('class' => array('theme-settings-bottom')),
-      );
-      $form['zen_dataportal_' .  $which_image]['default_' . $which_image] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Use the default') . t($which_image),
-        '#default_value' => theme_get_setting('default_' . $which_image),
-        '#tree' => FALSE,
-        '#description' => t('Check here if you want the theme to use the image supplied with it.')
-      );
-      $form['zen_dataportal_' .  $which_image]['settings'] = array(
-        '#type' => 'container',
-        '#states' => array(
-          // Hide the logo settings when using the default logo.
-          'invisible' => array(
-            'input[name="default_' . $which_image . '"]' => array('checked' => TRUE),
-          ),
-        ),
-      );
-
-      // If $path is a public:// URI, display the path relative to the files
-      // directory; stream wrappers are not end-user friendly.
-      $path = theme_get_setting($which_image . '_path');
-      $image = '';
-      if (file_uri_scheme($path) == 'public') {
-        $url = file_create_url($path);
-        $path = file_uri_target($path);
-        $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_preview'] = array(
-        	'#type' => 'item',
-          '#title' => t('Preview'),
-          '#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
-        );
-      }
-      $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_path'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Path to custom') . ' ' . t($image_label),
-        '#description' => t('The path to the file you would like to use as your') . ' ' . t($image_label),
-        '#default_value' => $path,
-      );
-      $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_upload'] = array(
-        '#type' => 'file',
-        '#title' => t('Upload') . ' ' . t($image_label) . t(' image'),
-        '#maxlength' => 40,
-        '#description' => t("If you don't have direct file access to the server, use this field to upload your image.")
-      );
-  } // END of loop over image names
+    zen_dataportal_form_widget_image($form, $which_image);
+  }
 
 
   $form['#validate'][] = 'zen_dataportal_theme_settings_validate';
   $form['#submit'][] = 'zen_dataportal_theme_settings_submit';
-
-
   // We are editing the $form in place, so we don't need to return anything.
 }
 
@@ -111,30 +61,31 @@ function zen_dataportal_form_system_theme_settings_alter(&$form, &$form_state, $
  */
 function zen_dataportal_theme_settings_submit($form, &$form_state) {
 
-  $values = &$form_state['values'];
 
   foreach(_zen_dataportal_imagenames() as $which_image) {
-    // If the user uploaded a new image, save it to a permanent location
-    // and use it in place of the default theme-provided file.
-    if ($file = $values[$which_image . '_upload']) {
-      unset($values[$which_image . '_upload']);
-      $filename = file_unmanaged_copy($file->uri);
-      $values['default_' .$which_image ] = 0;
-      $values[$which_image . '_path'] = $filename;
-      $values['toggle_' . $which_image] = 1;
-    }
-    if (!empty($values[$which_image . '_path'])) {
-      $values[$which_image . '_path'] = _system_theme_settings_validate_path($values[$which_image . '_path']);
-    }
+    zen_dataportal_form_widget_image_submit($form_state, $which_image);
+  }
+
+  // update logo information like wich one to use and size, this is needed to
+  // offset the banner and menu bar
+  $values = &$form_state['values'];
+  if(!theme_get_setting('default_logo')) {
+    $logo_file = path_to_theme() . '/logo.png';
+  } else {
+    $logo_file = theme_get_setting('logo_path');
+  }
+  $logo_file_info = image_get_info($logo_file);
+  if(isset($logo_file_info['width'])) {
+   $values['logo_size'] = array('width' => $logo_file_info['width'], 'height' => $logo_file_info['height']);
+  }
+
 
-  } // END of loop over image names
 
   /*
    * Ok, we are done here the $values will be saved in the theme
    * variable by system_theme_settings_submit($form, &$form_state)
    * in modules/system/system.admin.inc
    */
-
 }
 
 /**
@@ -146,21 +97,117 @@ function zen_dataportal_theme_settings_submit($form, &$form_state) {
  */
 function zen_dataportal_theme_settings_validate($form, &$form_state) {
 
-  $validators = array('file_validate_is_image' => array());
-
   foreach(_zen_dataportal_imagenames() as $which_image) {
-    // Check for a new uploaded logo.
-    $file = file_save_upload($which_image . '_upload', $validators);
-    if (isset($file)) {
-      // File upload was attempted.
-      if ($file) {
-        // Put the temporary file in form_values so we can save it on submit.
-        $form_state['values'][$which_image . '_upload'] = $file;
-      }
-      else {
-        // File upload failed.
-        form_set_error($which_image . '_upload', t('The image could not be uploaded.'));
-      }
+    zen_dataportal_form_widget_image_validate($form_state, $which_image);
+  }
+}
+
+/*******************************************************************
+ *                    form widget functions
+ *******************************************************************/
+
+/**
+ *
+ * Enter description here ...
+ *  @param $form
+ *   Nested array of form elements that comprise the form.
+ * @param unknown_type $which_image
+ */
+function zen_dataportal_form_widget_image(&$form, $which_image){
+  $image_label = str_replace('_', ' ', $which_image);
+  $form['zen_dataportal_' .  $which_image] = array(
+          '#type' => 'fieldset',
+          '#title' => ucfirst(t($image_label)) . ' ' . t('image settings'),
+          '#description' => t('If toggled on, the following image will be displayed.'),
+          '#attributes' => array('class' => array('theme-settings-bottom')),
+  );
+  $form['zen_dataportal_' .  $which_image]['default_' . $which_image] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Use the default') . t($which_image),
+          '#default_value' => theme_get_setting('default_' . $which_image),
+          '#tree' => FALSE,
+          '#description' => t('Check here if you want the theme to use the image supplied with it.')
+  );
+  $form['zen_dataportal_' .  $which_image]['settings'] = array(
+          '#type' => 'container',
+          '#states' => array(
+            // Hide the logo settings when using the default logo.
+            'invisible' => array(
+              'input[name="default_' . $which_image . '"]' => array('checked' => TRUE),
+            ),
+          ),
+  );
+
+  // If $path is a public:// URI, display the path relative to the files
+  // directory; stream wrappers are not end-user friendly.
+  $path = theme_get_setting($which_image . '_path');
+  $image = '';
+  if (file_uri_scheme($path) == 'public') {
+    $url = file_create_url($path);
+    $path = file_uri_target($path);
+    $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_preview'] = array(
+          	'#type' => 'item',
+            '#title' => t('Preview'),
+            '#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
+    );
+  } // FIXME manully entered files without scheme public: are omitted here
+  $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_path'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Path to custom') . ' ' . t($image_label),
+          '#description' => t('The path to the file you would like to use as your') . ' ' . t($image_label),
+          '#default_value' => $path,
+  );
+  $form['zen_dataportal_' .  $which_image]['settings'][$which_image . '_upload'] = array(
+          '#type' => 'file',
+          '#title' => t('Upload') . ' ' . t($image_label) . t(' image'),
+          '#maxlength' => 40,
+          '#description' => t("If you don't have direct file access to the server, use this field to upload your image.")
+  );
+}
+
+/**
+ *
+ * Enter description here ...
+ * @param $form_state
+ *   A keyed array containing the current state of the form.
+ * @param unknown_type $which_image
+ */
+function zen_dataportal_form_widget_image_submit(&$form_state, $which_image){
+  // If the user uploaded a new image, save it to a permanent location
+  // and use it in place of the default theme-provided file.
+  $values = &$form_state['values'];
+  if ($file = $values[$which_image . '_upload']) {
+    unset($values[$which_image . '_upload']);
+    $filename = file_unmanaged_copy($file->uri);
+    $values['default_' .$which_image ] = 0;
+    $values[$which_image . '_path'] = $filename;
+    $values['toggle_' . $which_image] = 1;
+  }
+  if (!empty($values[$which_image . '_path'])) {
+    $values[$which_image . '_path'] = _system_theme_settings_validate_path($values[$which_image . '_path']);
+  }
+}
+
+/**
+*
+* Enter description here ...
+ * @param $form_state
+ *   A keyed array containing the current state of the form.
+* @param unknown_type $which_image
+*/
+function zen_dataportal_form_widget_image_validate(&$form_state, $which_image){
+  $validators = array('file_validate_is_image' => array('gif', 'jpg', 'png'));
+  // Check for a new uploaded logo.
+  $file = file_save_upload($which_image . '_upload', $validators);
+  if (isset($file)) {
+    // File upload was attempted.
+    if ($file) {
+      // Put the temporary file in form_values so we can save it on submit.
+      $form_state['values'][$which_image . '_upload'] = $file;
+    }
+    else {
+      // File upload failed.
+      form_set_error($which_image . '_upload', t('The image could not be uploaded.'));
     }
-  } // END of loop over image names
+  }
 }
\ No newline at end of file
