PluginProbe
GetResponse Forms by Optin Cat / 1.5.4
GetResponse Forms by Optin Cat v1.5.4
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / includes / classes / Mustache / Autoloader.php

Autoloader.php in GetResponse Forms by Optin Cat 1.5.4, at includes/classes/Mustache/Autoloader.php

75 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Mustache.php.
5 *
6 * (c) 2010-2014 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Mustache class autoloader.
14 */
15 class Mustache_Autoloader
16 {
17 private $baseDir;
18
19 /**
20 * Autoloader constructor.
21 *
22 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
23 */
24 public function __construct($baseDir = null)
25 {
26 if ($baseDir === null) {
27 $baseDir = dirname(__FILE__).'/..';
28 }
29
30 // realpath doesn't always work, for example, with stream URIs
31 $realDir = realpath($baseDir);
32 if (is_dir($realDir)) {
33 $this->baseDir = $realDir;
34 } else {
35 $this->baseDir = $baseDir;
36 }
37 }
38
39 /**
40 * Register a new instance as an SPL autoloader.
41 *
42 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
43 *
44 * @return Mustache_Autoloader Registered Autoloader instance
45 */
46 public static function register($baseDir = null)
47 {
48 $loader = new self($baseDir);
49 spl_autoload_register(array($loader, 'autoload'));
50
51 return $loader;
52 }
53
54 /**
55 * Autoload Mustache classes.
56 *
57 * @param string $class
58 */
59 public function autoload($class)
60 {
61 if ($class[0] === '\\') {
62 $class = substr($class, 1);
63 }
64
65 if (strpos($class, 'Mustache') !== 0) {
66 return;
67 }
68
69 $file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class));
70 if (is_file($file)) {
71 require $file;
72 }
73 }
74 }
75