Index: trunk/sites/all/themes/yui-framework/page.tpl.php
===================================================================
--- trunk/sites/all/themes/yui-framework/page.tpl.php	(revision 9)
+++ trunk/sites/all/themes/yui-framework/page.tpl.php	(working copy)
@@ -1,100 +1,107 @@
 <?php
 // $Id: page.tpl.php,v 1.1 2008/04/11 09:03:30 xavierbriand Exp $
 ?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"	"http://www.w3.org/TR/html4/strict.dtd"> 
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
 <html lang="<?php print $language ?>">
   <head>
-    <title><?php echo $head_title ?></title>
-    <?php echo $head, $styles, $scripts ?>
+    <title><?php print $head_title ?></title>
+    <?php print $head . $styles . $scripts ?>
     <!--[if lt IE 7]>
-    <style type="text/css" media="all">@import "<?php echo base_path() . path_to_theme() ?>/fix-ie.css";</style>
+    <style type="text/css" media="all">@import "<?php print base_path() . path_to_theme() ?>/fix-ie.css";</style>
     <![endif]-->
   </head>
   <body >
-    <div id="<?php phptemplate_page_width() ?>" class="<?php phptemplate_page_template( $sidebar_left, $sidebar_right ) ?>">
+    <div id="<?php phptemplate_page_width() ?>" class="<?php phptemplate_page_template($sidebar_left, $sidebar_right) ?>">
       <div id="hd">
-        <?php
-          echo $header;
-          
-          // Prepare header
-          $site_fields = array();
-          
-          if ($site_name)   $site_fields[] = check_plain( $site_name );
-          if ($site_slogan) $site_fields[] = check_plain( $site_slogan );  
-            
-          $site_title     = implode( ' ', $site_fields );
-          $site_fields[0] = '<span>'. $site_fields[0] .'</span>';
-          $site_html      = implode( ' ', $site_fields );
-
-          if ( $logo || $site_title ) {
-            echo '<h1><a href="'. check_url( $base_path ) .'" title="'. $site_title .'">';
-            if ( $logo ) echo '<img src="'. check_url( $logo ) .'" alt="'. $site_title .'" id="logo" />';
-            echo $site_html .'</a></h1>';
-          }
-        ?>
+        <?php print $header; ?>
+        <?php if ($logo || $site_title) : ?>
+            <h1>
+              <a href="<?php print check_url($base_path) ?>" title="<?php print $site_title ?>">
+                <?php if ($logo): ?>
+                  <img src="<?php print check_url($logo) ?>" alt="<?php print $site_title ?>" id="logo" />
+                <?php endif ?>
+            <?php print $site_html ?></a>
+            </h1>
+        <?php endif; ?>
         </div>
 
       <div id="nav">
-        <?php
-          if ( isset( $primary_links) )   echo theme('links', $primary_links, array('class' => 'links primary-links'));
-          if ( isset( $secondary_links) ) echo theme('links', $secondary_links, array('class' => 'links secondary-links'));
-        ?>
+        <?php print $primary_links_rendered ?>
+        <?php print $secondary_links_rendered ?>
       </div>
 
-      <div id="bd">        
+      <div id="bd">
 
         <div id="yui-main">
           <div class="yui-b">
-            <?php if ( $sidebar_left && $sidebar_right ): ?>
+            <?php if ($sidebar_left && $sidebar_right): ?>
               <div class="yui-g"> 
                 <div id="sidebar-left" class="yui-u first">
-                  <?php
-                    echo $search_box ? $search_box : '';
-                    echo $sidebar_left;
-                  ?>
+                  <?php print $search_box ?>
+                  <?php print $sidebar_left ?>
                 </div>
                 <div class="yui-u">
-            <?php endif ?>        
-          
-            <?php
-              echo $breadcrumb  ? $breadcrumb : '';
-              echo $mission     ? '<div id="mission">'. $mission .'</div>' : '';
-              echo $tabs        ? '<div id="tabs-wrapper" class="clear-block">' : '';
-              echo $title       ? '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>' : '';
-              echo $tabs        ? $tabs .'</div>' : '';
-              echo isset($tabs2)? $tabs2 : '';
-              echo $help        ? $help : '';
-              echo $messages    ? $messages : '';
-  					  echo $content;
-            ?>
-          
-            <?php if ( $sidebar_left && $sidebar_right ): ?>
+            <?php endif ?>
+
+            <?php print $breadcrumb  ?>
+
+            <?php if ($mission) : ?>
+              <div id="mission"><?php print $mission ?></div>
+            <?php endif; ?>
+
+            <?php if ($tabs_wrapper) : //Renders a div around the title and tabs if we have tabs. To display tabs besides title. ?>
+              <div id="tabs-wrapper" class="clear-block">
+            <?php endif; ?>
+
+            <?php if ($title) : ?>
+              <h2 class="title<?php ($tabs_wrapper ?  print ' with-tabs' : '') //add a class to wrap tabs nicely alongside. ?>"><?php print $title ?></h2>
+            <?php endif; ?>
+            <?php if ($tabs_wrapper) : ?>
               </div>
+            <?php endif; ?>
+
+            <?php if ($secondary_tabs): ?>
+              <br class="clear" />
+              <ul class="tabs secondary">
+                <?php print $secondary_tabs ?>
+              </ul>
+            <?php endif; ?>
+
+            <?php print $tabs2 ?>
+
+            <?php print $help ?>
+
+            <?php print $messages ?>
+
+            <?php print $content ?>
+
+            <?php if ($sidebar_left && $sidebar_right): ?>
               </div>
+              </div>
             <?php endif?>
           </div>
         </div>
 
         <?php if ( $sidebar_left && $sidebar_right == ''): ?>
           <div id="sidebar-left" class="yui-b">
-            <?php
-              echo $search_box ? $search_box : '';
-              echo $sidebar_left;
-            ?>
+            <?php print $search_box ?>
+            <?php print $sidebar_left ?>
           </div>
         <?php endif ?>
-        
+
         <?php if ( $sidebar_right ): ?>
           <div id="sidebar-right" class="yui-b">
-            <?php if (!$sidebar_left && $search_box): ?><?php print $search_box ?><?php endif; ?>
+            <?php if (!$sidebar_left && $search_box): ?>
+              <?php print $search_box ?>
+            <?php endif; ?>
             <?php print $sidebar_right ?>
           </div>
         <?php endif; ?>
-        
+
       </div>
-      <div id="ft"><?php echo $footer_message, $feed_icons ?></div>
+      <div id="ft"><?php print $footer_message . $feed_icons ?></div>
     </div>
 
-  <?php echo $closure ?>
+  <?php print $closure ?>
   </body>
 </html>
\ No newline at end of file
Index: trunk/sites/all/themes/yui-framework/template.php
===================================================================
--- trunk/sites/all/themes/yui-framework/template.php	(revision 10)
+++ trunk/sites/all/themes/yui-framework/template.php	(working copy)
@@ -85,17 +85,35 @@
       //After adding, re-create the $styles var.
       $vars['styles'] = drupal_get_css();
 
-      //Add styles around secondary-links
-      if ($secondary = menu_secondary_local_tasks()) {
-        $output = '<br class="clear" />';
-        $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
-        $vars['tabs2'] = $output;
+      //prepare secondary tabs
+      $vars['secondary_tabs'] = menu_secondary_local_tasks();
+
+      if (!empty($vars['tabs'])) {
+        $vars['tabs_wrapper'] = TRUE;
       }
 
       // Hook into color.module
       if (module_exists('color')) {
         _color_page_alter($vars);
       }
+
+      // Prepare header
+      $vars['site_fields'] = array();
+
+      if ($vars['site_name']) {
+        $vars['site_fields'][] = check_plain($vars['site_name']);
+      }
+      if ($vars['site_slogan']) {
+        $vars['site_fields'][] = check_plain($vars['site_slogan']);
+      }
+
+      $vars['site_title'] = implode(' ', $vars['site_fields']);
+      $vars['site_fields'][0] = '<span>'. $vars['site_fields'][0] .'</span>';//@TODO: why is this span here, move it to the page.tpl.php? of remove it entirely?
+      $vars['site_html'] = implode(' ', $vars['site_fields']);
+
+      $vars['primary_links_rendered'] = theme('links', $vars['primary_links'], array('class' => 'links primary-links'));
+      $vars['secondary_links_rendered'] = theme('links', $vars['secondary_links'], array('class' => 'links secondary-links'));
+
     break;
   }
   return $vars;
@@ -111,7 +129,7 @@
   $output = '';
 
   if ($primary = menu_primary_local_tasks()) {
-    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
+    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";//@TODO: move into a theme snippet.
   }
 
   return $output;
