Example #1
0
 /**
  * Undocumented method.
  *
  * @todo Method GetImports() needs a description.
  */
 public function GetImports()
 {
     if (!isset($this->Uses) || !is_array($this->Uses)) {
         return;
     }
     // Load any classes in the uses array and make them properties of this class
     foreach ($this->Uses as $Class) {
         if (strlen($Class) >= 4 && substr_compare($Class, 'Gdn_', 0, 4) == 0) {
             $Property = substr($Class, 4);
         } else {
             $Property = $Class;
         }
         // Find the class and instantiate an instance..
         if (Gdn::FactoryExists($Property)) {
             $this->{$Property} = Gdn::Factory($Property);
         }
         if (Gdn::FactoryExists($Class)) {
             // Instantiate from the factory.
             $this->{$Property} = Gdn::Factory($Class);
         } elseif (class_exists($Class)) {
             // Instantiate as an object.
             $ReflectionClass = new ReflectionClass($Class);
             // Is this class a singleton?
             if ($ReflectionClass->implementsInterface("ISingleton")) {
                 eval('$this->' . $Property . ' = ' . $Class . '::GetInstance();');
             } else {
                 $this->{$Property} = new $Class();
             }
         } else {
             trigger_error(ErrorMessage('The "' . $Class . '" class could not be found.', $this->ClassName, '__construct'), E_USER_ERROR);
         }
     }
 }
Example #2
0
Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session', PATH_LIBRARY_CORE . DS . 'class.session.php');
Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth', PATH_LIBRARY_CORE . DS . 'class.auth.php', Gdn::FactorySingleton);
// Dispatcher.
Gdn::FactoryInstall(Gdn::AliasRouter, 'Gdn_Router', PATH_LIBRARY_CORE . DS . 'class.router.php', Gdn::FactorySingleton);
Gdn::FactoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher', PATH_LIBRARY_CORE . DS . 'class.dispatcher.php', Gdn::FactorySingleton);
// Smarty Templating Engine
Gdn::FactoryInstall('Smarty', 'Smarty', PATH_LIBRARY . DS . 'vendors' . DS . 'Smarty-2.6.25' . DS . 'libs' . DS . 'Smarty.class.php', Gdn::FactorySingleton);
Gdn::FactoryInstall('ViewHandler.tpl', 'Gdn_Smarty', PATH_LIBRARY_CORE . DS . 'class.smarty.php', Gdn::FactorySingleton);
// Application manager.
Gdn::FactoryInstall('ApplicationManager', 'Gdn_ApplicationManager', PATH_LIBRARY_CORE . DS . 'class.applicationmanager.php', Gdn::FactorySingleton);
// Theme manager
Gdn::FactoryInstall('ThemeManager', 'Gdn_ThemeManager', PATH_LIBRARY_CORE . DS . 'class.thememanager.php', Gdn::FactoryInstance);
Gdn::FactoryInstall(Gdn::AliasSlice, 'Gdn_Slice', PATH_LIBRARY_CORE . DS . 'class.slice.php', Gdn::FactorySingleton);
// Other objects.
Gdn::FactoryInstall('Dummy', 'Gdn_Dummy', PATH_LIBRARY_CORE . DS . 'class.dummy.php', Gdn::FactorySingleton);
if (!Gdn::FactoryExists(Gdn::AliasLocale)) {
    require_once PATH_LIBRARY_CORE . DS . 'class.locale.php';
    $Codeset = Gdn::Config('Garden.LocaleCodeset', 'UTF8');
    $CurrentLocale = Gdn::Config('Garden.Locale', 'en-CA');
    $SetLocale = str_replace('-', '_', $CurrentLocale) . '.' . $Codeset;
    setlocale(LC_ALL, $SetLocale);
    $Gdn_Locale = new Gdn_Locale($CurrentLocale, Gdn::Config('EnabledApplications'), Gdn::Config('EnabledPlugins'));
    Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', PATH_LIBRARY_CORE . DS . 'class.locale.php', Gdn::FactorySingleton, $Gdn_Locale);
    unset($Gdn_Locale);
}
// Execute other application startup.
foreach ($Gdn_EnabledApplications as $ApplicationName => $ApplicationFolder) {
    // Include the application's bootstrap.
    $Gdn_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'bootstrap.php';
    if (file_exists($Gdn_Path)) {
        include_once $Gdn_Path;