From 9b23c3f6d5a76096ee4a93cfad9ee140febeb2d3 Mon Sep 17 00:00:00 2001 From: andrey Date: Tue, 5 Feb 2002 19:05:39 +0000 Subject: [PATCH] Fix up plugin inclusion. --- Smarty.class.php | 5 +++-- Smarty_Compiler.class.php | 13 +++++++------ libs/Smarty.class.php | 5 +++-- libs/Smarty_Compiler.class.php | 13 +++++++------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Smarty.class.php b/Smarty.class.php index 3472ae20..3a892fb2 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -44,7 +44,7 @@ // if not defined, include_path will be used. if (!defined('SMARTY_DIR')) { - define('SMARTY_DIR', ''); + define('SMARTY_DIR', dirname(__FILE__) . '/'); } define('SMARTY_PHP_PASSTHRU', 0); @@ -64,7 +64,8 @@ class Smarty var $template_dir = './templates'; // name of directory for templates var $compile_dir = './templates_c'; // name of directory for compiled templates var $config_dir = './configs'; // directory where config files are located - var $plugins_dir = './plugins'; // directory where plugins are kept + var $plugins_dir = 'plugins'; // directory where plugins are kept + // (relative to Smarty directory) var $debugging = false; // enable debugging console true/false var $debug_tpl = 'file:debug.tpl'; // path to debug console template diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index ff824bd8..ffba5c6d 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -167,11 +167,6 @@ class Smarty_Compiler extends Smarty { $template_compiled, 1); } - // put header at the top of the compiled template - $template_header = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; - $template_header .= " compiled from ".$tpl_file." */ ?>\n"; - $template_compiled = $template_header.$template_compiled; - // remove \n from the end of the file, if any if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) { $template_compiled = substr($template_compiled, 0, -1); @@ -189,6 +184,10 @@ class Smarty_Compiler extends Smarty { } } + // put header at the top of the compiled template + $template_header = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; + $template_header .= " compiled from ".$tpl_file." */ ?>\n"; + /* Emit code to load needed plugins. */ if (count($this->_plugin_info)) { $plugins_code = '_load_plugins(array('; @@ -198,10 +197,12 @@ class Smarty_Compiler extends Smarty { } } $plugins_code .= ")); ?>"; - $template_compiled = $plugins_code . $template_compiled; + $template_header .= $plugins_code; $this->_plugin_info = array(); } + $template_compiled = $template_header . $template_compiled; + return true; } diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 3472ae20..3a892fb2 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -44,7 +44,7 @@ // if not defined, include_path will be used. if (!defined('SMARTY_DIR')) { - define('SMARTY_DIR', ''); + define('SMARTY_DIR', dirname(__FILE__) . '/'); } define('SMARTY_PHP_PASSTHRU', 0); @@ -64,7 +64,8 @@ class Smarty var $template_dir = './templates'; // name of directory for templates var $compile_dir = './templates_c'; // name of directory for compiled templates var $config_dir = './configs'; // directory where config files are located - var $plugins_dir = './plugins'; // directory where plugins are kept + var $plugins_dir = 'plugins'; // directory where plugins are kept + // (relative to Smarty directory) var $debugging = false; // enable debugging console true/false var $debug_tpl = 'file:debug.tpl'; // path to debug console template diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index ff824bd8..ffba5c6d 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -167,11 +167,6 @@ class Smarty_Compiler extends Smarty { $template_compiled, 1); } - // put header at the top of the compiled template - $template_header = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; - $template_header .= " compiled from ".$tpl_file." */ ?>\n"; - $template_compiled = $template_header.$template_compiled; - // remove \n from the end of the file, if any if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) { $template_compiled = substr($template_compiled, 0, -1); @@ -189,6 +184,10 @@ class Smarty_Compiler extends Smarty { } } + // put header at the top of the compiled template + $template_header = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; + $template_header .= " compiled from ".$tpl_file." */ ?>\n"; + /* Emit code to load needed plugins. */ if (count($this->_plugin_info)) { $plugins_code = '_load_plugins(array('; @@ -198,10 +197,12 @@ class Smarty_Compiler extends Smarty { } } $plugins_code .= ")); ?>"; - $template_compiled = $plugins_code . $template_compiled; + $template_header .= $plugins_code; $this->_plugin_info = array(); } + $template_compiled = $template_header . $template_compiled; + return true; }