|
| 1 | +<?php |
| 2 | + |
| 3 | +///////////////////////////////////////////////////////////////////// |
| 4 | +// This is a stub PSR-4 loading script that gets all the pieces of // |
| 5 | +// Smarty 5.x loaded without requiring the use of composer. It's // |
| 6 | +// not really a 'class' file, but the name is used so we're // |
| 7 | +// backwards compatible with previous versions of Smarty. // |
| 8 | +// // |
| 9 | +// Example: // |
| 10 | +// require_once("/path/to/smarty/libs/Smarty.class.php"); // |
| 11 | +// // |
| 12 | +// $smarty = new Smarty\Smarty; // |
| 13 | +// $smarty->testInstall(); // |
| 14 | +///////////////////////////////////////////////////////////////////// |
| 15 | + |
| 16 | +define('__SMARTY_DIR', __DIR__ . '/../src/'); |
| 17 | + |
| 18 | +// Global function declarations |
| 19 | +require_once(__SMARTY_DIR . "/functions.php"); |
| 20 | + |
| 21 | +spl_autoload_register(function ($class) { |
| 22 | + // Class prefix |
| 23 | + $prefix = 'Smarty\\'; |
| 24 | + |
| 25 | + // Does the class use the namespace prefix? |
| 26 | + $len = strlen($prefix); |
| 27 | + if (strncmp($prefix, $class, $len) !== 0) { |
| 28 | + // If not, move to the next registered autoloader |
| 29 | + return; |
| 30 | + } |
| 31 | + |
| 32 | + // Hack off the prefix part |
| 33 | + $relative_class = substr($class, $len); |
| 34 | + |
| 35 | + // Build a path to the include file |
| 36 | + $file = __SMARTY_DIR . str_replace('\\', '/', $relative_class) . '.php'; |
| 37 | + |
| 38 | + // If the file exists, require it |
| 39 | + if (file_exists($file)) { |
| 40 | + require_once($file); |
| 41 | + } |
| 42 | +}); |
0 commit comments