libs/Autoloader.php Quellcode

Autoloader.php
gehe zur Dokumentation dieser Datei
1 <?php
21 {
27  public static $SMARTY_DIR = '';
33  public static $SMARTY_SYSPLUGINS_DIR = '';
39  public static $unknown = array();
45  public static $rootClasses = array('Smarty' => 'Smarty.class.php',
46  'SmartyBC' => 'SmartyBC.class.php',
47  );
48 
49  private static $syspluginsClasses = array(
50  'smarty_config_source' => true,
51  'smarty_security' => true,
52  'smarty_cacheresource' => true,
53  'smarty_compiledresource' => true,
54  'smarty_cacheresource_custom' => true,
55  'smarty_cacheresource_keyvaluestore' => true,
56  'smarty_resource' => true,
57  'smarty_resource_custom' => true,
58  'smarty_resource_uncompiled' => true,
59  'smarty_resource_recompiled' => true,
60  'smarty_template_source' => true,
61  'smarty_template_compiled' => true,
62  'smarty_template_cached' => true,
63  'smarty_template_config' => true,
64  'smarty_data' => true,
65  'smarty_variable' => true,
66  'smarty_undefined_variable' => true,
67  'smartyexception' => true,
68  'smartycompilerexception' => true,
69  'smarty_internal_data' => true,
70  'smarty_internal_template' => true,
71  'smarty_internal_templatebase' => true,
72  'smarty_internal_resource_file' => true,
73  'smarty_internal_resource_extends' => true,
74  'smarty_internal_resource_eval' => true,
75  'smarty_internal_resource_string' => true,
76  'smarty_internal_resource_registered' => true,
77  'smarty_internal_extension_codeframe' => true,
78  'smarty_internal_extension_config' => true,
79  'smarty_internal_filter_handler' => true,
80  'smarty_internal_function_call_handler' => true,
81  'smarty_internal_cacheresource_file' => true,
82  'smarty_internal_write_file' => true,
83  );
84 
90  public static function registerBC($prepend = false)
91  {
95  if (!defined('SMARTY_SPL_AUTOLOAD')) {
96  define('SMARTY_SPL_AUTOLOAD', 0);
97  }
98  if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
99  $registeredAutoLoadFunctions = spl_autoload_functions();
100  if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
101  spl_autoload_register();
102  }
103  } else {
104  self::register($prepend);
105  }
106  }
107 
113  public static function register($prepend = false)
114  {
115  self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . '/';
116  self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins/';
117  if (version_compare(phpversion(), '5.3.0', '>=')) {
118  spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
119  } else {
120  spl_autoload_register(array(__CLASS__, 'autoload'));
121  }
122  }
123 
129  public static function autoload($class)
130  {
131  // Request for Smarty or already unknown class
132  if (isset(self::$unknown[$class])) {
133  return;
134  }
135  $_class = strtolower($class);
136  if (isset(self::$syspluginsClasses[$_class])) {
137  $_class = (self::$syspluginsClasses[$_class] === true) ? $_class : self::$syspluginsClasses[$_class];
138  $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
139  require_once $file;
140  return;
141  } elseif (0 !== strpos($_class, 'smarty_internal_')) {
142  if (isset(self::$rootClasses[$class])) {
143  $file = self::$SMARTY_DIR . self::$rootClasses[$class];
144  require_once $file;
145  return;
146  }
147  self::$unknown[$class] = true;
148  return;
149  }
150  $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
151  if (is_file($file)) {
152  require_once $file;
153  return;
154  }
155  self::$unknown[$class] = true;
156  return;
157  }
158 }




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.