/**
  * Register hooks and load options.
  *
  * @since 1.0.0
  */
 public static function setup()
 {
     // Setup the registry
     Registry::load();
     // Register the hooks of the subsystems
     Frontend::register_hooks();
     Backend::register_hooks();
 }
 /**
  * Register hooks and load options.
  *
  * @since 1.0.0
  *
  * @uses Registry::load() to load the options.
  * @uses Loader::register_hooks() to setup plugin management.
  * @uses System::register_hooks() to setup global functionality.
  * @uses Backend::register_hooks() to setup backend functionality.
  * @uses AJAX::register_hooks() to setup AJAX functionality.
  * @uses Manager::register_hooks() to setup admin screens.
  * @uses Documenter::register_hooks() to setup admin documentation.
  */
 public static function setup()
 {
     // Setup the registry
     Registry::load();
     // Register the Installer stuff
     Installer::register_hooks();
     // Register global hooks
     self::register_hooks();
     // Register the hooks of the subsystems
     Backend::register_hooks();
     AJAX::register_hooks();
     Manager::register_hooks();
     Documenter::register_hooks();
 }
Ejemplo n.º 3
0
function load_class($className, $type = 'Core', $surpress = FALSE)
{
    // Now we need to make sure the user supplied some sort of path
    if (strpos($className, $type) === FALSE) {
        $className = $type . '\\' . $className;
    }
    // Make a lowercase version, and a storage name
    $class = strtolower($className);
    $store_name = str_replace('\\', '_', $class);
    // Check the registry for the class, If its there, then return the class
    $loaded = \Registry::load($store_name);
    if ($loaded !== NULL) {
        return $loaded;
    }
    // ---------------------------------------------------------
    // Class not in Registry, So we load it manually and then  |
    // store it in the registry for future static use          |
    // ---------------------------------------------------------
    // We need to find the file the class is stored in. Good thing the
    // Namespaces are pretty much paths to the class ;)
    $parts = explode('\\', $class);
    $last = count($parts) - 1;
    $parts[$last] = ucfirst($parts[$last]);
    // Build our filepath
    $file = implode(DS, $parts);
    $file = SYSTEM_PATH . DS . $file . '.php';
    // Include our file. If it doesnt exists, class is un-obtainable.
    require_once $file;
    //  Initiate the new class into a variable
    try {
        $Obj = new $className();
    } catch (\Exception $e) {
        $message = $e->getMessage();
        $Obj = FALSE;
    }
    // Display error?
    if (!is_object($Obj) && !$surpress) {
        show_error('class_init_failed', array($className, $message), E_ERROR);
    }
    // Store this new object in the registery
    \Registry::store($store_name, $Obj);
    // return the object.
    return $Obj;
}
Ejemplo n.º 4
0
 public function realm($instance = TRUE)
 {
     // Get our emulator from the Config File
     $emulator = ucfirst(config('emulator'));
     $class_name = "Emulator_" . $emulator;
     // Make sure we havent loaded the lib already
     $realm = \Registry::load($class_name);
     if ($realm !== NULL) {
         goto Instance;
     }
     // Init the class if it doesnt exist
     if (!class_exists('Wowlib', false)) {
         $this->_initWowlib();
     }
     // Add debug tracer
     \Debug::trace('Loading Realm from Wowlib', __FILE__, __LINE__);
     // Fetch the emulator class
     try {
         $realm = \Wowlib::getRealm(0, 'RDB');
     } catch (\Exception $e) {
         \Debug::silent_mode(false);
         $message = 'Wowlib Error: ' . $e->getMessage();
         // Add debug tracer
         \Debug::trace($message, __FILE__, __LINE__);
         show_error($message, false, E_ERROR);
     }
     // Store the class statically and return the class
     \Registry::store($class_name, $realm);
     // Instance
     Instance:
     if ($instance == TRUE) {
         $FB = get_instance();
         if (is_object($FB)) {
             $FB->realm = $realm;
         }
     }
     // We need to make sure the realm loaded ok, or thrown an error
     if (!is_object($realm)) {
         // Add debug tracer
         $message = 'Wowlib failed to fetch realm. Assuming the realm database is offline.';
         \Debug::trace($message, __FILE__, __LINE__);
         show_error($message, false, E_ERROR);
     } else {
         \Debug::trace('Successfully fetched the realm connection from the Wowlib', __FILE__, __LINE__);
     }
     return $realm;
 }