[geeklog-hg] geeklog: Removed php procesing and setting of default template v...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Jul 11 19:34:35 EDT 2013


changeset 9175:cdb07fa252a5
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/cdb07fa252a5
user: Tom <websitemaster at cogeco.net>
date: Thu Jul 11 14:57:09 2013 -0400
description:
Removed php procesing and setting of default template variables for templates from lib-common since template class now does this automatically

diffstat:

 public_html/lib-common.php        |  56 ++++----------------------------------
 system/classes/template.class.php |   7 ++++-
 2 files changed, 13 insertions(+), 50 deletions(-)

diffs (127 lines):

diff -r f41a437f370c -r cdb07fa252a5 public_html/lib-common.php
--- a/public_html/lib-common.php	Tue Jul 09 15:23:48 2013 -0400
+++ b/public_html/lib-common.php	Thu Jul 11 14:57:09 2013 -0400
@@ -323,7 +323,7 @@
         }
     }
 }
-
+// Set template class default template variables option
 $TEMPLATE_OPTIONS['default_vars']['layout_url'] = $_CONF['layout_url'];
 
 /**
@@ -388,6 +388,8 @@
         break;
     }
 }
+// Set template class default template variables option
+$TEMPLATE_OPTIONS['default_vars']['xhtml'] = XHTML;
 
 // Set language
 
@@ -1365,28 +1367,8 @@
 
     $header->set_var( 'layout_columns', 'js_off' );
 
-    // The following lines allow users to embed PHP in their templates.  This
-    // is almost a contradition to the reasons for using templates but this may
-    // prove useful at times ...
-    // Don't use PHP in templates if you can live without it!
-
-    $tmp = $header->finish($header->parse('index_header', 'header'));
-
-    $xml_declaration = '';
-    if ( get_cfg_var('short_open_tag') == '1' )
-    {
-        if ( preg_match( '/(<\?xml[^>]*>)(.*)/s', $tmp, $match ) )
-        {
-            $xml_declaration = $match[1] . LB;
-            $tmp = $match[2];
-        }
-    }
-
-    ob_start();
-    eval( '?>' . $tmp );
-    $retval = $xml_declaration . ob_get_contents();
-    ob_end_clean();
-
+    $retval = $header->finish($header->parse('index_header', 'header'));
+    
     return $retval;
 }
 
@@ -2257,27 +2239,7 @@
     }
     $header->set_var( 'layout_columns', $layout_columns );
 
-    // The following lines allow users to embed PHP in their templates.  This
-    // is almost a contradition to the reasons for using templates but this may
-    // prove useful at times ...
-    // Don't use PHP in templates if you can live without it!
-
-    $tmp = $header->finish($header->parse('index_header', 'header'));
-
-    $xml_declaration = '';
-    if ( get_cfg_var('short_open_tag') == '1' )
-    {
-        if ( preg_match( '/(<\?xml[^>]*>)(.*)/s', $tmp, $match ) )
-        {
-            $xml_declaration = $match[1] . LB;
-            $tmp = $match[2];
-        }
-    }
-
-    ob_start();
-    eval( '?>' . $tmp );
-    $retval_header = $xml_declaration . ob_get_contents();
-    ob_end_clean();
+    $retval_header = $header->finish($header->parse('index_header', 'header'));
 
     // Call to plugins to set template variables in the footer
     PLG_templateSetVars( 'footer', $footer );
@@ -4580,7 +4542,6 @@
         // The only time cache_time would not be set if for dynamic blocks (they can handle their own caching if needed)
         // Don't Cache default blocks either
         if (isset($A['cache_time']) AND $A['cache_time'] > 0) {
-    
             $cacheInstance = 'block__' . $A['bid'] . '__' . CACHE_security_hash() . '__' . $_CONF['theme'];
             $retval = CACHE_check_instance($cacheInstance, 0);
             if ($retval) {
@@ -8672,10 +8633,7 @@
         else $options = 'remove';
         $T = new Template($root, $options);
     }
-    $T->set_var('xhtml', XHTML);
-    $T->set_var('site_url', $_CONF['site_url']);
-    $T->set_var('site_admin_url', $_CONF['site_admin_url']);
-    $T->set_var('layout_url', $_CONF['layout_url']);
+    
     return $T;
 }
 
diff -r f41a437f370c -r cdb07fa252a5 system/classes/template.class.php
--- a/system/classes/template.class.php	Tue Jul 09 15:23:48 2013 -0400
+++ b/system/classes/template.class.php	Thu Jul 11 14:57:09 2013 -0400
@@ -56,6 +56,10 @@
 /* This should be the only Geeklog-isms in the file. Didn't want to "infect" the class but it was necessary.
  * These options are global to all templates.
  */
+$xhtml = '';
+if (defined('XHTML')) { // usually not defined yet but will be later
+    $xhtml = XHTML;
+}
 $TEMPLATE_OPTIONS = array(
     'path_cache'    => $_CONF['path_data'].'layout_cache/',   // location of template cache
     'path_prefixes' => array(                               // used to strip directories off file names. Order is important here.
@@ -66,9 +70,10 @@
     'incl_phpself_header' => true,          // set this to true if your template cache exists within your web server's docroot.
     'cache_by_language' => true,            // create cache directories for each language. Takes extra space but moves all $LANG variable text directly into the cached file
     'default_vars' => array(                                // list of vars found in all templates.
+                        'xhtml' => $xhtml, // Will be reset by lib-common       
                         'site_url' => $_CONF['site_url'],
                         'site_admin_url' => $_CONF['site_admin_url'],
-                        'layout_url' => $_CONF['layout_url'],
+                        'layout_url' => $_CONF['layout_url'], // Can be set by lib-common on theme change
                       ),
     'hook' => array(),
 );



More information about the geeklog-cvs mailing list