PEEL Shopping
Open source ecommerce : PEEL Shopping
Smarty.class.php
Go to the documentation of this file.
1 <?php
37 if (!defined('DS')) {
38  define('DS', DIRECTORY_SEPARATOR);
39 }
40 
45 if (!defined('SMARTY_DIR')) {
46  define('SMARTY_DIR', dirname(__FILE__) . DS);
47 }
48 
53 if (!defined('SMARTY_SYSPLUGINS_DIR')) {
54  define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
55 }
56 if (!defined('SMARTY_PLUGINS_DIR')) {
57  define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
58 }
59 if (!defined('SMARTY_MBSTRING')) {
60  define('SMARTY_MBSTRING', function_exists('mb_split'));
61 }
62 if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
63  // UTF-8 can only be done properly when mbstring is available!
67  define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
68 }
69 if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
73  define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
74 }
75 
79 if (!defined('SMARTY_SPL_AUTOLOAD')) {
80  define('SMARTY_SPL_AUTOLOAD', 0);
81 }
82 
83 if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
84  $registeredAutoLoadFunctions = spl_autoload_functions();
85  if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
86  spl_autoload_register();
87  }
88 } else {
89  spl_autoload_register('smartyAutoload');
90 }
91 
95 include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php';
96 include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php';
97 include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php';
98 include_once SMARTY_SYSPLUGINS_DIR.'smarty_resource.php';
99 include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php';
100 include_once SMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php';
101 include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php';
102 
108 
116  const SMARTY_VERSION = 'Smarty-3.1.14';
117 
121  const SCOPE_LOCAL = 0;
122  const SCOPE_PARENT = 1;
123  const SCOPE_ROOT = 2;
124  const SCOPE_GLOBAL = 3;
128  const CACHING_OFF = 0;
134  const CLEAR_EXPIRED = -1;
135 
139  const COMPILECHECK_OFF = 0;
140  const COMPILECHECK_ON = 1;
145  const PHP_PASSTHRU = 0; //-> print tags as plain text
146  const PHP_QUOTE = 1; //-> escape tags as entities
147  const PHP_REMOVE = 2; //-> escape tags as entities
148  const PHP_ALLOW = 3; //-> escape tags as entities
152  const FILTER_POST = 'post';
153  const FILTER_PRE = 'pre';
154  const FILTER_OUTPUT = 'output';
155  const FILTER_VARIABLE = 'variable';
159  const PLUGIN_FUNCTION = 'function';
160  const PLUGIN_BLOCK = 'block';
161  const PLUGIN_COMPILER = 'compiler';
162  const PLUGIN_MODIFIER = 'modifier';
163  const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
164 
170  public static $global_tpl_vars = array();
171 
175  public static $_previous_error_handler = null;
179  public static $_muted_directories = array();
183  public static $_MBSTRING = SMARTY_MBSTRING;
187  public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
192  public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
196  public static $_UTF8_MODIFIER = 'u';
197 
201  public static $_IS_WINDOWS = false;
202 
211  public $auto_literal = true;
216  public $error_unassigned = false;
221  public $use_include_path = false;
226  private $template_dir = array();
231  public $joined_template_dir = null;
236  public $joined_config_dir = null;
256  private $compile_dir = null;
261  private $plugins_dir = array();
266  private $cache_dir = null;
271  private $config_dir = array();
276  public $force_compile = false;
281  public $compile_check = true;
286  public $use_sub_dirs = false;
296  public $caching = false;
301  public $merge_compiled_includes = false;
306  public $cache_lifetime = 3600;
311  public $force_cache = false;
318  public $cache_id = null;
325  public $compile_id = null;
330  public $left_delimiter = "{";
335  public $right_delimiter = "}";
347  public $security_class = 'Smarty_Security';
353  public $security_policy = null;
359  public $php_handling = self::PHP_PASSTHRU;
365  public $allow_php_templates = false;
375  public $direct_access_security = true;
384  public $debugging = false;
393  public $debugging_ctrl = 'NONE';
402  public $smarty_debug_id = 'SMARTY_DEBUG';
407  public $debug_tpl = null;
412  public $error_reporting = null;
417  public $get_used_tags = false;
418 
427  public $config_overwrite = true;
432  public $config_booleanize = true;
437  public $config_read_hidden = false;
438 
449  public $compile_locking = true;
454  public $cache_locking = false;
459  public $locking_timeout = 10;
460 
467  public $template_functions = array();
474  public $default_resource_type = 'file';
482  public $caching_type = 'file';
487  public $properties = array();
492  public $default_config_type = 'file';
497  public $template_objects = array();
502  public $cache_modified_check = false;
507  public $registered_plugins = array();
512  public $plugin_search_order = array('function', 'block', 'compiler', 'class');
517  public $registered_objects = array();
522  public $registered_classes = array();
527  public $registered_filters = array();
532  public $registered_resources = array();
537  public $_resource_handlers = array();
542  public $registered_cache_resources = array();
547  public $_cacheresource_handlers = array();
552  public $autoload_filters = array();
557  public $default_modifiers = array();
562  public $escape_html = false;
567  public static $_smarty_vars = array();
572  public $start_time = 0;
577  public $_file_perms = 0644;
582  public $_dir_perms = 0771;
587  public $_tag_stack = array();
592  public $smarty;
597  public $_current_file = null;
602  public $_parserdebug = false;
608  public $merged_templates_func = array();
615  public function __construct()
616  {
617  // selfpointer needed by some other class methods
618  $this->smarty = $this;
619  if (is_callable('mb_internal_encoding')) {
620  mb_internal_encoding(Smarty::$_CHARSET);
621  }
622  $this->start_time = microtime(true);
623  // set default dirs
624  $this->setTemplateDir('.' . DS . 'templates' . DS)
625  ->setCompileDir('.' . DS . 'templates_c' . DS)
626  ->setPluginsDir(SMARTY_PLUGINS_DIR)
627  ->setCacheDir('.' . DS . 'cache' . DS)
628  ->setConfigDir('.' . DS . 'configs' . DS);
629 
630  $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl';
631  if (isset($_SERVER['SCRIPT_NAME'])) {
632  $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
633  }
634  }
635 
636 
640  public function __destruct()
641  {
642  // intentionally left blank
643  }
644 
648  public function __clone()
649  {
650  $this->smarty = $this;
651  }
652 
653 
663  public function __get($name)
664  {
665  $allowed = array(
666  'template_dir' => 'getTemplateDir',
667  'config_dir' => 'getConfigDir',
668  'plugins_dir' => 'getPluginsDir',
669  'compile_dir' => 'getCompileDir',
670  'cache_dir' => 'getCacheDir',
671  );
672 
673  if (isset($allowed[$name])) {
674  return $this->{$allowed[$name]}();
675  } else {
676  trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE);
677  }
678  }
679 
689  public function __set($name, $value)
690  {
691  $allowed = array(
692  'template_dir' => 'setTemplateDir',
693  'config_dir' => 'setConfigDir',
694  'plugins_dir' => 'setPluginsDir',
695  'compile_dir' => 'setCompileDir',
696  'cache_dir' => 'setCacheDir',
697  );
698 
699  if (isset($allowed[$name])) {
700  $this->{$allowed[$name]}($value);
701  } else {
702  trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
703  }
704  }
705 
712  public function templateExists($resource_name)
713  {
714  // create template object
715  $save = $this->template_objects;
716  $tpl = new $this->template_class($resource_name, $this);
717  // check if it does exists
718  $result = $tpl->source->exists;
719  $this->template_objects = $save;
720  return $result;
721  }
722 
730  public function getGlobal($varname = null)
731  {
732  if (isset($varname)) {
733  if (isset(self::$global_tpl_vars[$varname])) {
734  return self::$global_tpl_vars[$varname]->value;
735  } else {
736  return '';
737  }
738  } else {
739  $_result = array();
740  foreach (self::$global_tpl_vars AS $key => $var) {
741  $_result[$key] = $var->value;
742  }
743  return $_result;
744  }
745  }
746 
754  function clearAllCache($exp_time = null, $type = null)
755  {
756  // load cache resource and call clearAll
757  $_cache_resource = Smarty_CacheResource::load($this, $type);
759  return $_cache_resource->clearAll($this, $exp_time);
760  }
761 
772  public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
773  {
774  // load cache resource and call clear
775  $_cache_resource = Smarty_CacheResource::load($this, $type);
777  return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time);
778  }
779 
787  public function enableSecurity($security_class = null)
788  {
789  if ($security_class instanceof Smarty_Security) {
790  $this->security_policy = $security_class;
791  return $this;
792  } elseif (is_object($security_class)) {
793  throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
794  }
795  if ($security_class == null) {
797  }
798  if (!class_exists($security_class)) {
799  throw new SmartyException("Security class '$security_class' is not defined");
800  } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
801  throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
802  } else {
803  $this->security_policy = new $security_class($this);
804  }
805 
806  return $this;
807  }
808 
813  public function disableSecurity()
814  {
815  $this->security_policy = null;
816 
817  return $this;
818  }
819 
826  public function setTemplateDir($template_dir)
827  {
828  $this->template_dir = array();
829  foreach ((array) $template_dir as $k => $v) {
830  $this->template_dir[$k] = rtrim($v, '/\\') . DS;
831  }
832 
833  $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
834  return $this;
835  }
836 
845  public function addTemplateDir($template_dir, $key=null)
846  {
847  // make sure we're dealing with an array
848  $this->template_dir = (array) $this->template_dir;
849 
850  if (is_array($template_dir)) {
851  foreach ($template_dir as $k => $v) {
852  if (is_int($k)) {
853  // indexes are not merged but appended
854  $this->template_dir[] = rtrim($v, '/\\') . DS;
855  } else {
856  // string indexes are overridden
857  $this->template_dir[$k] = rtrim($v, '/\\') . DS;
858  }
859  }
860  } elseif ($key !== null) {
861  // override directory at specified index
862  $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS;
863  } else {
864  // append new directory
865  $this->template_dir[] = rtrim($template_dir, '/\\') . DS;
866  }
867  $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
868  return $this;
869  }
870 
877  public function getTemplateDir($index=null)
878  {
879  if ($index !== null) {
880  return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null;
881  }
882 
883  return (array)$this->template_dir;
884  }
885 
892  public function setConfigDir($config_dir)
893  {
894  $this->config_dir = array();
895  foreach ((array) $config_dir as $k => $v) {
896  $this->config_dir[$k] = rtrim($v, '/\\') . DS;
897  }
898 
899  $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
900  return $this;
901  }
902 
910  public function addConfigDir($config_dir, $key=null)
911  {
912  // make sure we're dealing with an array
913  $this->config_dir = (array) $this->config_dir;
914 
915  if (is_array($config_dir)) {
916  foreach ($config_dir as $k => $v) {
917  if (is_int($k)) {
918  // indexes are not merged but appended
919  $this->config_dir[] = rtrim($v, '/\\') . DS;
920  } else {
921  // string indexes are overridden
922  $this->config_dir[$k] = rtrim($v, '/\\') . DS;
923  }
924  }
925  } elseif( $key !== null ) {
926  // override directory at specified index
927  $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS;
928  } else {
929  // append new directory
930  $this->config_dir[] = rtrim($config_dir, '/\\') . DS;
931  }
932 
933  $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
934  return $this;
935  }
936 
943  public function getConfigDir($index=null)
944  {
945  if ($index !== null) {
946  return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null;
947  }
948 
949  return (array)$this->config_dir;
950  }
951 
958  public function setPluginsDir($plugins_dir)
959  {
960  $this->plugins_dir = array();
961  foreach ((array)$plugins_dir as $k => $v) {
962  $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
963  }
964 
965  return $this;
966  }
967 
975  public function addPluginsDir($plugins_dir)
976  {
977  // make sure we're dealing with an array
978  $this->plugins_dir = (array) $this->plugins_dir;
979 
980  if (is_array($plugins_dir)) {
981  foreach ($plugins_dir as $k => $v) {
982  if (is_int($k)) {
983  // indexes are not merged but appended
984  $this->plugins_dir[] = rtrim($v, '/\\') . DS;
985  } else {
986  // string indexes are overridden
987  $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
988  }
989  }
990  } else {
991  // append new directory
992  $this->plugins_dir[] = rtrim($plugins_dir, '/\\') . DS;
993  }
994 
995  $this->plugins_dir = array_unique($this->plugins_dir);
996  return $this;
997  }
998 
1004  public function getPluginsDir()
1005  {
1006  return (array)$this->plugins_dir;
1007  }
1008 
1015  public function setCompileDir($compile_dir)
1016  {
1017  $this->compile_dir = rtrim($compile_dir, '/\\') . DS;
1018  if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
1019  Smarty::$_muted_directories[$this->compile_dir] = null;
1020  }
1021  return $this;
1022  }
1023 
1029  public function getCompileDir()
1030  {
1031  return $this->compile_dir;
1032  }
1033 
1040  public function setCacheDir($cache_dir)
1041  {
1042  $this->cache_dir = rtrim($cache_dir, '/\\') . DS;
1043  if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
1044  Smarty::$_muted_directories[$this->cache_dir] = null;
1045  }
1046  return $this;
1047  }
1048 
1054  public function getCacheDir()
1055  {
1056  return $this->cache_dir;
1057  }
1058 
1065  public function setDefaultModifiers($modifiers)
1066  {
1067  $this->default_modifiers = (array) $modifiers;
1068  return $this;
1069  }
1070 
1077  public function addDefaultModifiers($modifiers)
1078  {
1079  if (is_array($modifiers)) {
1080  $this->default_modifiers = array_merge($this->default_modifiers, $modifiers);
1081  } else {
1082  $this->default_modifiers[] = $modifiers;
1083  }
1084 
1085  return $this;
1086  }
1087 
1093  public function getDefaultModifiers()
1094  {
1095  return $this->default_modifiers;
1096  }
1097 
1098 
1106  public function setAutoloadFilters($filters, $type=null)
1107  {
1108  if ($type !== null) {
1109  $this->autoload_filters[$type] = (array) $filters;
1110  } else {
1111  $this->autoload_filters = (array) $filters;
1112  }
1113 
1114  return $this;
1115  }
1116 
1124  public function addAutoloadFilters($filters, $type=null)
1125  {
1126  if ($type !== null) {
1127  if (!empty($this->autoload_filters[$type])) {
1128  $this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters);
1129  } else {
1130  $this->autoload_filters[$type] = (array) $filters;
1131  }
1132  } else {
1133  foreach ((array) $filters as $key => $value) {
1134  if (!empty($this->autoload_filters[$key])) {
1135  $this->autoload_filters[$key] = array_merge($this->autoload_filters[$key], (array) $value);
1136  } else {
1137  $this->autoload_filters[$key] = (array) $value;
1138  }
1139  }
1140  }
1141 
1142  return $this;
1143  }
1144 
1151  public function getAutoloadFilters($type=null)
1152  {
1153  if ($type !== null) {
1154  return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array();
1155  }
1156 
1157  return $this->autoload_filters;
1158  }
1159 
1165  public function getDebugTemplate()
1166  {
1167  return $this->debug_tpl;
1168  }
1169 
1177  public function setDebugTemplate($tpl_name)
1178  {
1179  if (!is_readable($tpl_name)) {
1180  throw new SmartyException("Unknown file '{$tpl_name}'");
1181  }
1182  $this->debug_tpl = $tpl_name;
1183 
1184  return $this;
1185  }
1186 
1197  public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
1198  {
1199  if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
1200  $parent = $cache_id;
1201  $cache_id = null;
1202  }
1203  if (!empty($parent) && is_array($parent)) {
1204  $data = $parent;
1205  $parent = null;
1206  } else {
1207  $data = null;
1208  }
1209  // default to cache_id and compile_id of Smarty object
1210  $cache_id = $cache_id === null ? $this->cache_id : $cache_id;
1211  $compile_id = $compile_id === null ? $this->compile_id : $compile_id;
1212  // already in template cache?
1213  if ($this->allow_ambiguous_resources) {
1214  $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
1215  } else {
1216  $_templateId = $this->joined_template_dir . '#' . $template . $cache_id . $compile_id;
1217  }
1218  if (isset($_templateId[150])) {
1219  $_templateId = sha1($_templateId);
1220  }
1221  if ($do_clone) {
1222  if (isset($this->template_objects[$_templateId])) {
1223  // return cached template object
1224  $tpl = clone $this->template_objects[$_templateId];
1225  $tpl->smarty = clone $tpl->smarty;
1226  $tpl->parent = $parent;
1227  $tpl->tpl_vars = array();
1228  $tpl->config_vars = array();
1229  } else {
1230  $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id);
1231  }
1232  } else {
1233  if (isset($this->template_objects[$_templateId])) {
1234  // return cached template object
1235  $tpl = $this->template_objects[$_templateId];
1236  $tpl->parent = $parent;
1237  $tpl->tpl_vars = array();
1238  $tpl->config_vars = array();
1239  } else {
1240  $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
1241  }
1242  }
1243  // fill data if present
1244  if (!empty($data) && is_array($data)) {
1245  // set up variable values
1246  foreach ($data as $_key => $_val) {
1247  $tpl->tpl_vars[$_key] = new Smarty_variable($_val);
1248  }
1249  }
1250  return $tpl;
1251  }
1252 
1253 
1263  public function loadPlugin($plugin_name, $check = true)
1264  {
1265  // if function or class exists, exit silently (already loaded)
1266  if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
1267  return true;
1268  }
1269  // Plugin name is expected to be: Smarty_[Type]_[Name]
1270  $_name_parts = explode('_', $plugin_name, 3);
1271  // class name must have three parts to be valid plugin
1272  // count($_name_parts) < 3 === !isset($_name_parts[2])
1273  if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
1274  throw new SmartyException("plugin {$plugin_name} is not a valid name format");
1275  return false;
1276  }
1277  // if type is "internal", get plugin from sysplugins
1278  if (strtolower($_name_parts[1]) == 'internal') {
1279  $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
1280  if (file_exists($file)) {
1281  require_once($file);
1282  return $file;
1283  } else {
1284  return false;
1285  }
1286  }
1287  // plugin filename is expected to be: [type].[name].php
1288  $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
1289 
1290  $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
1291 
1292  // loop through plugin dirs and find the plugin
1293  foreach($this->getPluginsDir() as $_plugin_dir) {
1294  $names = array(
1295  $_plugin_dir . $_plugin_filename,
1296  $_plugin_dir . strtolower($_plugin_filename),
1297  );
1298  foreach ($names as $file) {
1299  if (file_exists($file)) {
1300  require_once($file);
1301  return $file;
1302  }
1303  if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
1304  // try PHP include_path
1305  if ($_stream_resolve_include_path) {
1306  $file = stream_resolve_include_path($file);
1307  } else {
1309  }
1310 
1311  if ($file !== false) {
1312  require_once($file);
1313  return $file;
1314  }
1315  }
1316  }
1317  }
1318  // no plugin loaded
1319  return false;
1320  }
1321 
1331  public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
1332  {
1333  return Smarty_Internal_Utility::compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, $this);
1334  }
1335 
1345  public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
1346  {
1347  return Smarty_Internal_Utility::compileAllConfig($extension, $force_compile, $time_limit, $max_errors, $this);
1348  }
1349 
1358  public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
1359  {
1360  return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this);
1361  }
1362 
1363 
1370  public function getTags(Smarty_Internal_Template $template)
1371  {
1372  return Smarty_Internal_Utility::getTags($template);
1373  }
1374 
1381  public function testInstall(&$errors=null)
1382  {
1383  return Smarty_Internal_Utility::testInstall($this, $errors);
1384  }
1385 
1393  public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
1394  {
1395  $_is_muted_directory = false;
1396 
1397  // add the SMARTY_DIR to the list of muted directories
1398  if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
1399  $smarty_dir = realpath(SMARTY_DIR);
1400  if ($smarty_dir !== false) {
1401  Smarty::$_muted_directories[SMARTY_DIR] = array(
1402  'file' => $smarty_dir,
1403  'length' => strlen($smarty_dir),
1404  );
1405  }
1406  }
1407 
1408  // walk the muted directories and test against $errfile
1409  foreach (Smarty::$_muted_directories as $key => &$dir) {
1410  if (!$dir) {
1411  // resolve directory and length for speedy comparisons
1412  $file = realpath($key);
1413  if ($file === false) {
1414  // this directory does not exist, remove and skip it
1415  unset(Smarty::$_muted_directories[$key]);
1416  continue;
1417  }
1418  $dir = array(
1419  'file' => $file,
1420  'length' => strlen($file),
1421  );
1422  }
1423  if (!strncmp($errfile, $dir['file'], $dir['length'])) {
1424  $_is_muted_directory = true;
1425  break;
1426  }
1427  }
1428 
1429  // pass to next error handler if this error did not occur inside SMARTY_DIR
1430  // or the error was within smarty but masked to be ignored
1431  if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
1433  return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, $errcontext);
1434  } else {
1435  return false;
1436  }
1437  }
1438  }
1439 
1445  public static function muteExpectedErrors()
1446  {
1447  /*
1448  error muting is done because some people implemented custom error_handlers using
1449  http://php.net/set_error_handler and for some reason did not understand the following paragraph:
1450 
1451  It is important to remember that the standard PHP error handler is completely bypassed for the
1452  error types specified by error_types unless the callback function returns FALSE.
1453  error_reporting() settings will have no effect and your error handler will be called regardless -
1454  however you are still able to read the current value of error_reporting and act appropriately.
1455  Of particular note is that this value will be 0 if the statement that caused the error was
1456  prepended by the @ error-control operator.
1457 
1458  Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include
1459  - @filemtime() is almost twice as fast as using an additional file_exists()
1460  - between file_exists() and filemtime() a possible race condition is opened,
1461  which does not exist using the simple @filemtime() approach.
1462  */
1463  $error_handler = array('Smarty', 'mutingErrorHandler');
1464  $previous = set_error_handler($error_handler);
1465 
1466  // avoid dead loops
1467  if ($previous !== $error_handler) {
1469  }
1470  }
1471 
1477  public static function unmuteExpectedErrors()
1478  {
1479  restore_error_handler();
1480  }
1481 }
1482 
1483 // Check if we're running on windows
1484 Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
1485 
1486 // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8
1487 if (Smarty::$_CHARSET !== 'UTF-8') {
1489 }
1490 
1495 class SmartyException extends Exception {
1496  public static $escape = true;
1497  public function __construct($message) {
1498  $this->message = self::$escape ? htmlentities($message) : $message;
1499  }
1500 }
1501 
1507 }
1508 
1513 {
1514  $_class = strtolower($class);
1515  $_classes = array(
1516  'smarty_config_source' => true,
1517  'smarty_config_compiled' => true,
1518  'smarty_security' => true,
1519  'smarty_cacheresource' => true,
1520  'smarty_cacheresource_custom' => true,
1521  'smarty_cacheresource_keyvaluestore' => true,
1522  'smarty_resource' => true,
1523  'smarty_resource_custom' => true,
1524  'smarty_resource_uncompiled' => true,
1525  'smarty_resource_recompiled' => true,
1526  );
1527 
1528  if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) {
1529  include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
1530  }
1531 }
1532 
1533 ?>
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
Definition: chart-data.php:29
static $_UTF8_MODIFIER
Flag denoting if PCRE should run in UTF-8 mode.
$allow_ambiguous_resources
const SCOPE_ROOT
__destruct()
Class destructor.
$merged_templates_func
$template_functions
$result
static testInstall(Smarty $smarty, &$errors=null)
diagnose Smarty setup
addTemplateDir($template_dir, $key=null)
Add template directory(s)
createTemplate($template, $cache_id=null, $compile_id=null, $parent=null, $do_clone=true)
creates a template object
$plugin_search_order
$cache_modified_check
setTemplateDir($template_dir)
Set template directory.
__clone()
<> set selfpointer on cloned object
$registered_classes
static load(Smarty $smarty, $type=null)
Load Cache Resource Handler.
static $_MBSTRING
Flag denoting if Multibyte String functions are available.
if($rub=fetch_assoc($rub_query)) if(check_if_module_active('url_rewriting')) $class
Definition: index.php:68
loadPlugin($plugin_name, $check=true)
Takes unknown classes and loads plugin files for them class name format: Smarty_PluginType_PluginName...
addConfigDir($config_dir, $key=null)
Add config directory(s)
static compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
Compile all template files.
static unmuteExpectedErrors()
Disable error handler muting expected messages.
$default_resource_type
static invalidLoadedCache(Smarty $smarty)
Invalid Loaded Cache Files.
static getIncludePath($filepath)
Return full file path from PHP include_path.
$registered_resources
static getTags(Smarty_Internal_Template $template)
Return array of tag/attributes of all tags used by an template.
$extension
clearCompiledTemplate($resource_name=null, $compile_id=null, $exp_time=null)
Delete compiled template file.
setAutoloadFilters($filters, $type=null)
Set autoload filters.
compileAllConfig($extension= '.conf', $force_compile=false, $time_limit=0, $max_errors=null)
Compile all config files.
static $_DATE_FORMAT
The date format to be used internally (accepts date() and strftime())
const FILTER_OUTPUT
assignGlobal($varname, $value=null, $nocache=false)
assigns a global Smarty variable
getConfigDir($index=null)
Get config directory.
$registered_plugins
enableSecurity($security_class=null)
Loads security class and enables security.
setDefaultModifiers($modifiers)
Set default modifiers.
__construct($message)
const CACHING_OFF
define caching modes
const PLUGIN_FUNCTION
plugin types
const SCOPE_GLOBAL
disableSecurity()
Disable security.
static $global_tpl_vars
#@-
const SCOPE_PARENT
$_resource_handlers
const PLUGIN_COMPILER
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
static clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
Delete compiled template file.
$default_modifiers
setDebugTemplate($tpl_name)
set the debug template
static compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
Compile all config files.
clearCache($template_name, $cache_id=null, $compile_id=null, $exp_time=null, $type=null)
Empty cache for a specific template.
getPluginsDir()
Get plugin directories.
const CACHING_LIFETIME_CURRENT
Smarty plugin to format text blocks.
const COMPILECHECK_OFF
define compile check modes
templateExists($resource_name)
Check if a template resource exists.
const PLUGIN_MODIFIER
const PHP_QUOTE
$default_config_handler_func
$direct_access_security
Should compiled-templates be prevented from being called directly?
const FILTER_POST
filter types
static getUniqueTemplateName($smarty, $template_resource)
modify resource_name according to resource handlers specifications
$registered_objects
const FILTER_VARIABLE
const CACHING_LIFETIME_SAVED
static $_previous_error_handler
error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
static $_muted_directories
contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() ...
const COMPILECHECK_CACHEMISS
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
const PHP_PASSTHRU
modes for handling of "" tags in templates.
const CLEAR_EXPIRED
define constant for clearing cache files be saved expiration datees
static mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
Error Handler to mute expected messages.
getTemplateDir($index=null)
Get template directories.
getGlobal($varname=null)
Returns a single or all global variables.
compileAllTemplates($extension= '.tpl', $force_compile=false, $time_limit=0, $max_errors=null)
Compile all template files.
smartyAutoload($class)
Autoloader.
$joined_template_dir
testInstall(&$errors=null)
Run installation test.
clearAllCache($exp_time=null, $type=null)
Empty cache folder.
static $_IS_WINDOWS
Flag denoting if operating system is windows.
setCompileDir($compile_dir)
Set compile directory.
static $_smarty_vars
$registered_cache_resources
addPluginsDir($plugins_dir)
Adds directory of plugin files.
getDefaultModifiers()
Get default modifiers.
const SCOPE_LOCAL
define variable scopes
$joined_config_dir
__set($name, $value)
<> Generic setter.
const PLUGIN_BLOCK
getAutoloadFilters($type=null)
Get autoload filters.
$default_config_type
$allow_php_templates
setConfigDir($config_dir)
Set config directory.
static $_CHARSET
The character set to adhere to (e.g.
const PLUGIN_MODIFIERCOMPILER
getCompileDir()
Get compiled directory.
This class does contain the security settings.
static muteExpectedErrors()
Enable error handler to mute expected messages.
$config_read_hidden
const FILTER_PRE
__construct()
#@-
getDebugTemplate()
return name of debugging template
const SMARTY_VERSION
#@+ constant definitions
$default_plugin_handler_func
setPluginsDir($plugins_dir)
Set plugins directory.
getTags(Smarty_Internal_Template $template)
Return array of tag/attributes of all tags used by an template.
$merge_compiled_includes
$default_template_handler_func
addAutoloadFilters($filters, $type=null)
Add autoload filters.
getCacheDir()
Get cache directory.
setCacheDir($cache_dir)
Set cache directory.
addDefaultModifiers($modifiers)
Add default modifiers.
const PHP_ALLOW
const PHP_REMOVE
$registered_filters
$_cacheresource_handlers
const COMPILECHECK_ON
$config_booleanize
__get($name)
<> Generic getter.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:16 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.