Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Loader)
- *
- * @ Version : 2.0.0.3
- * @ Author : DeZender
- * @ Release on : 06.05.2013
- * @ Official site : http://DeZender.Net
- *
- */
- namespace {
- require_once "Loader.php";
- }
- namespace Core\Loader {
- class Autoloader {
- /**
- *
- * @var \Core\Loader\Autoloader Singleton instance
- */
- protected static $_instance = null;
- /**
- *
- * @var array Concrete autoloader callback implementations
- */
- protected static $_autoloaders = array();
- /**
- *
- * @var array Default autoloader callback
- */
- protected static $_defaultAutoloader = array(0 => "\\Core\\Loader\\Loader", 1 => "loadClass");
- /**
- *
- * @var bool Whether or not to act as a fallback autoloader
- */
- protected static $_fallbackAutoloader = false;
- /**
- *
- * @var array Callback for internal autoloader implementation
- */
- protected static $_internalAutoloader = null;
- /**
- *
- * @var array Supported namespaces 'Core' by default.
- */
- protected static $_namespaces = array();
- /**
- *
- * @var array Namespace-specific autoloaders
- */
- protected static $_namespaceAutoloaders = array();
- /**
- *
- * @var bool Whether or not to suppress file not found warnings
- */
- protected static $_suppressNotFoundWarnings = false;
- public static function getInstance() {
- if (null === self::$_instance) {
- self::$_instance = new self();
- }
- return self::$_instance;
- }
- public static function resetInstance() {
- self::$_instance = null;
- }
- public static function autoload($class) {
- $self = self::getInstance();
- foreach ($self->getClassAutoloaders($class) as $autoloader) {
- if ($autoloader instanceof Autoloader) {
- if ($autoloader->autoload($class)) {
- return true;
- }
- }
- else {
- if (is_string($autoloader)) {
- if ($autoloader($class)) {
- return true;
- }
- }
- else {
- if (is_array($autoloader)) {
- $object = array_shift($autoloader);
- $method = array_shift($autoloader);
- if (call_user_func(array($object, $method), $class)) {
- return true;
- }
- }
- }
- }
- continue;
- }
- return false;
- }
- public function setDefaultAutoloader($callback) {
- if (!is_callable($callback)) {
- throw new Exception("Invalid callback specified for default autoloader");
- }
- $this->_defaultAutoloader = $callback;
- return $this;
- }
- public function getDefaultAutoloader() {
- return $this->_defaultAutoloader;
- }
- public function setAutoloaders(array $autoloaders) {
- $this->_autoloaders = $autoloaders;
- return $this;
- }
- public function getAutoloaders() {
- return $this->_autoloaders;
- }
- public function getNamespaceAutoloaders($namespace) {
- $namespace = (string)$namespace;
- if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
- return array();
- }
- return $this->_namespaceAutoloaders[$namespace];
- }
- public function registerNamespace($namespace, $path = null) {
- if (is_array($namespace)) {
- return $this->registerNamespaces($namespace);
- }
- else {
- if (!$path || is_array($path)) {
- throw new Exception("Invalid namespace provided");
- }
- }
- $namespace = rtrim($namespace, "\\") . "\\";
- if (!isset($this->_namespaces[$namespace])) {
- $this->_namespaces[$namespace] = $path;
- }
- return $this;
- }
- public function registerNamespaces($namespace) {
- if (!is_array($namespace)) {
- throw new Exception("Invalid namespace provided");
- }
- foreach ($namespace as $ns => $path) {
- $this->registerNamespace($ns, $path);
- continue;
- }
- return $this;
- }
- public function unregisterNamespace($namespace) {
- if (is_string($namespace)) {
- $namespace = (array)$namespace;
- }
- else {
- if (!is_array($namespace)) {
- throw new Exception("Invalid namespace provided");
- }
- }
- foreach ($namespace as $ns) {
- if (isset($this->_namespaces[$ns])) {
- unset($this->_namespaces[$ns]);
- }
- continue;
- }
- return $this;
- }
- public function getRegisteredNamespaces() {
- return $this->_namespaces;
- }
- public function suppressNotFoundWarnings($flag = null) {
- if (null === $flag) {
- return $this->_suppressNotFoundWarnings;
- }
- $this->_suppressNotFoundWarnings = (bool)$flag;
- return $this;
- }
- public function setFallbackAutoloader($flag) {
- $this->_fallbackAutoloader = (bool)$flag;
- return $this;
- }
- public function isFallbackAutoloader() {
- return $this->_fallbackAutoloader;
- }
- public function getClassAutoloaders($class) {
- $namespace = false;
- $autoloaders = (array());
- foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
- if ("" == $ns) {
- continue;
- }
- if (0 === strpos($class, $ns)) {
- $namespace = $ns;
- $autoloaders = $autoloaders + $this->getNamespaceAutoloaders($ns);
- break;
- }
- continue;
- }
- foreach ($this->getRegisteredNamespaces() as $ns => $path) {
- if (0 === strpos($class, $ns)) {
- $namespace = $ns;
- $autoloaders[] = $this->_internalAutoloader;
- break;
- }
- continue;
- }
- $autoloaders = $autoloaders + $this->getNamespaceAutoloaders("");
- if (!$namespace && $this->isFallbackAutoloader()) {
- $autoloaders[] = $this->_internalAutoloader;
- }
- return $autoloaders;
- }
- public function unshiftAutoloader($callback, $namespace = "") {
- $autoloaders = $this->getAutoloaders();
- array_unshift($autoloaders, $callback);
- $this->setAutoloaders($autoloaders);
- $namespace = (array)$namespace;
- foreach ($namespace as $ns) {
- .........................................................................
- ....................................
- ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement