Преглед изворни кода

Do not use ob_end_flush because the fetch method returns the content of the
buffer. If we do not clear the buffer the to display template will be
displayed twice (paginator.tpl in this case)

stekkel пре 19 година
родитељ
комит
a0e99d40e5
1 измењених фајлова са 17 додато и 20 уклоњено
  1. 17 20
      class/template/template.class.php

+ 17 - 20
class/template/template.class.php

@@ -44,35 +44,35 @@ class Template
 
 
   /**
   /**
    * Template files provided by this template set
    * Template files provided by this template set
-   * 
+   *
    * @var array
    * @var array
    */
    */
   var $templates_provided = array();
   var $templates_provided = array();
-  
+
   /**
   /**
    * Javascript files required by the template
    * Javascript files required by the template
-   * 
+   *
    * @var array
    * @var array
    */
    */
   var $required_js_files = array();
   var $required_js_files = array();
-  
+
   /**
   /**
    * Javascript files provided by the template.  If a JS file is required, but
    * Javascript files provided by the template.  If a JS file is required, but
-   * not provided, the js file by the same name will be included from the 
+   * not provided, the js file by the same name will be included from the
    * default template directory.
    * default template directory.
-   * 
+   *
    * @var array
    * @var array
    */
    */
   var $provided_js_files = array();
   var $provided_js_files = array();
-  
+
   /**
   /**
    * Additional stylesheets provided by the template.  This allows template
    * Additional stylesheets provided by the template.  This allows template
    * authors (namely me to begin with :p) to provide additional CSS sheets
    * authors (namely me to begin with :p) to provide additional CSS sheets
    * to templates while using the default template set stylesheet for other
    * to templates while using the default template set stylesheet for other
    * definitions.
    * definitions.
    */
    */
-  var $additional_css_sheets = array(); 
-  
+  var $additional_css_sheets = array();
+
     /**
     /**
      * Constructor
      * Constructor
      *
      *
@@ -80,7 +80,7 @@ class Template
      */
      */
     function Template($sTplDir) {
     function Template($sTplDir) {
         $this->template_dir = $sTplDir;
         $this->template_dir = $sTplDir;
-       
+
         // Pull in the tempalte config file
         // Pull in the tempalte config file
         if (!file_exists($this->template_dir . 'template.php')) {
         if (!file_exists($this->template_dir . 'template.php')) {
              trigger_error('No template.php could be found in the requested template directory ("'.$this->template_dir.'")', E_USER_ERROR);
              trigger_error('No template.php could be found in the requested template directory ("'.$this->template_dir.'")', E_USER_ERROR);
@@ -205,7 +205,7 @@ class Template
   {
   {
     // Pull in our config file
     // Pull in our config file
     $t = &$this->values; // place values array directly in scope
     $t = &$this->values; // place values array directly in scope
-    
+
     $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file;
     $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file;
     if (!file_exists($template)) {
     if (!file_exists($template)) {
         trigger_error('The template "'.htmlspecialchars($file).'" could not be displayed!', E_USER_ERROR);
         trigger_error('The template "'.htmlspecialchars($file).'" could not be displayed!', E_USER_ERROR);
@@ -222,9 +222,7 @@ class Template
    * @param string $file The template file to use
    * @param string $file The template file to use
    * @return string A string of the results
    * @return string A string of the results
    */
    */
-  function fetch($file)
-  {
-    ob_start();
+  function fetch($file) {
     $t = &$this->values; // place values array directly in scope
     $t = &$this->values; // place values array directly in scope
 
 
     $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file;
     $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file;
@@ -234,16 +232,15 @@ class Template
         ob_start();
         ob_start();
         include($template);
         include($template);
         $contents = ob_get_contents();
         $contents = ob_get_contents();
-        ob_end_flush();
+        ob_end_clean();
         return $contents;
         return $contents;
     }
     }
-
   }
   }
 
 
   /**
   /**
-   * Return paths to the required javascript files.  Used when generating page 
+   * Return paths to the required javascript files.  Used when generating page
    * header.
    * header.
-   * 
+   *
    * @return array $paths
    * @return array $paths
    */
    */
   function getJavascriptIncludes () {
   function getJavascriptIncludes () {
@@ -253,14 +250,14 @@ class Template
             $paths[] = './'.$this->template_dir.'js/'.basename($file);
             $paths[] = './'.$this->template_dir.'js/'.basename($file);
         else $paths[] = SM_PATH .'templates/default/js/'.basename($file);
         else $paths[] = SM_PATH .'templates/default/js/'.basename($file);
     }
     }
-    
+
     return $paths;
     return $paths;
   }
   }
 
 
   /**
   /**
    * Return any additional stylsheets provided by the template.  Used when
    * Return any additional stylsheets provided by the template.  Used when
    * generating page headers.
    * generating page headers.
-   * 
+   *
    * @return array $paths
    * @return array $paths
    */
    */
   function getAdditionalStyleSheets () {
   function getAdditionalStyleSheets () {