summaryrefslogtreecommitdiff
path: root/plugins/Irc/extlib/phergie/Phergie/Autoload.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Irc/extlib/phergie/Phergie/Autoload.php')
-rwxr-xr-xplugins/Irc/extlib/phergie/Phergie/Autoload.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/Irc/extlib/phergie/Phergie/Autoload.php b/plugins/Irc/extlib/phergie/Phergie/Autoload.php
new file mode 100755
index 000000000..b03fe2ae1
--- /dev/null
+++ b/plugins/Irc/extlib/phergie/Phergie/Autoload.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Phergie
+ *
+ * PHP version 5
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.
+ * It is also available through the world-wide-web at this URL:
+ * http://phergie.org/license
+ *
+ * @category Phergie
+ * @package Phergie
+ * @author Phergie Development Team <team@phergie.org>
+ * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @license http://phergie.org/license New BSD License
+ * @link http://pear.phergie.org/package/Phergie
+ */
+
+/**
+ * Autoloader for Phergie classes.
+ *
+ * @category Phergie
+ * @package Phergie
+ * @author Phergie Development Team <team@phergie.org>
+ * @license http://phergie.org/license New BSD License
+ * @link http://pear.phergie.org/package/Phergie
+ */
+class Phergie_Autoload
+{
+ /**
+ * Constructor to add the base Phergie path to the include_path.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $path = dirname(__FILE__);
+ $includePath = get_include_path();
+ $includePathList = explode(PATH_SEPARATOR, $includePath);
+ if (!in_array($path, $includePathList)) {
+ self::addPath($path);
+ }
+ }
+
+ /**
+ * Autoload callback for loading class files.
+ *
+ * @param string $class Class to load
+ *
+ * @return void
+ */
+ public function load($class)
+ {
+ if (substr($class, 0, 8) == 'Phergie_') {
+ $class = substr($class, 8);
+ }
+ include str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+ }
+
+ /**
+ * Registers an instance of this class as an autoloader.
+ *
+ * @return void
+ */
+ public static function registerAutoloader()
+ {
+ spl_autoload_register(array(new self, 'load'));
+ }
+
+ /**
+ * Add a path to the include path.
+ *
+ * @param string $path Path to add
+ *
+ * @return void
+ */
+ public static function addPath($path)
+ {
+ set_include_path($path . PATH_SEPARATOR . get_include_path());
+ }
+}