From ad6d3a0f73582444ca23e5e23a3a2db2220f0ae8 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 12 Apr 2012 20:05:10 +0000
Subject: [PATCH] Update WdnTemplate view helper to support version 3.1 of the
 templates and make it the default.

---
 library/Unl/View/Helper/WdnTemplate.php | 31 ++++++++++++++++++-------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/library/Unl/View/Helper/WdnTemplate.php b/library/Unl/View/Helper/WdnTemplate.php
index 05c25bd..e6b510c 100644
--- a/library/Unl/View/Helper/WdnTemplate.php
+++ b/library/Unl/View/Helper/WdnTemplate.php
@@ -39,10 +39,6 @@ class Unl_View_Helper_WdnTemplate extends Zend_View_Helper_Abstract
         $staticBaseUrl .= $_SERVER['HTTP_HOST']
                         . $baseUrl . '/';
         
-        if (!$layout->template) {
-        	$layout->template = 'Fixed';
-        }
-	
         if (!$layout->siteTitle) {
             $layout->siteTitle = 'Site';
         }
@@ -56,17 +52,32 @@ class Unl_View_Helper_WdnTemplate extends Zend_View_Helper_Abstract
                                     'title' => $layout->siteTitle));
         
         require_once 'UNL/Templates.php';
-        Unl_Templates::$options['version'] = UNL_Templates::VERSION3;
+        require_once 'UNL/Templates/CachingService/Null.php';
+        UNL_Templates::setCachingService(new UNL_Templates_CachingService_Null());
+        UNL_Templates::$options['version'] = UNL_Templates::VERSION3x1;
         
         $config = Unl_Application::getOptions();
         if (isset($config['unl']['templates']['options']) && is_array($config['unl']['templates']['options'])) {
             UNL_Templates::$options = array_merge(UNL_Templates::$options, $config['unl']['templates']['options']);
         }
+
+        if (!$layout->template) {
+            if (UNL_Templates::$options['version'] == UNL_Templates::VERSION3x1) {
+                $layout->template = 'Local';
+            } else {
+                $layout->template = 'Fixed';
+            }
+        }
         
         $template = UNL_Templates::factory($layout->template, array('sharedcodepath' => 'sharedcode'));
         
-        $template->titlegraphic = '<h1>' . $layout->siteTitle . '</h1>';
-        $template->pagetitle = '<h2>' . $layout->pageTitle . '</h2>';
+        if (in_array(UNL_Templates::$options['version'], array(UNL_Templates::VERSION3x1, '3x1'))) {
+            $template->titlegraphic = $layout->siteTitle;
+            $template->pagetitle = '<h1>' . $layout->pageTitle . '</h1>';
+        } else {
+            $template->titlegraphic = '<h1>' . $layout->siteTitle . '</h1>';
+            $template->pagetitle = '<h2>' . $layout->pageTitle . '</h2>';
+        }
         
         $template->navlinks = $this->_processLinks($layout->navLinks); 
         $template->maincontentarea = $layout->content . "\n";
@@ -112,7 +123,11 @@ class Unl_View_Helper_WdnTemplate extends Zend_View_Helper_Abstract
         
         $template->breadcrumbs = $this->_processLinks($breadcrumbs);
         
-        $template->doctitle = '<title>' . implode(' | ', $htmlTitle) . '</title>';
+        if (in_array(UNL_Templates::$options['version'], array(UNL_Templates::VERSION3x1, '3x1'))) {
+            $template->doctitle = '<title>' . implode(' | ', array_reverse($htmlTitle)) . '</title>';
+        } else {
+            $template->doctitle = '<title>' . implode(' | ', $htmlTitle) . '</title>';
+        }
         
         if (!$layout->leftColLinks) {
             $layout->leftColLinks = array();
-- 
GitLab