Advertisement
Guest User

Untitled

a guest
Jun 12th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. <?php if (!defined('APPLICATION')) exit();
  2.  
  3. /**
  4. * Bootstrap Before
  5. *
  6. * This file gives developers the opportunity to hook into Garden before any
  7. * real work has been done. Nothing has been included yet, aside from this file.
  8. * No Garden features are available yet.
  9. */
  10. if (file_exists(PATH_ROOT.'/conf/bootstrap.before.php'))
  11. require_once(PATH_ROOT.'/conf/bootstrap.before.php');
  12.  
  13. /**
  14. * Define Core Constants
  15. *
  16. * Garden depends on the presence of a certain base set of defines that allow it
  17. * to be aware of its own place within the system. These are conditionally
  18. * defined here, in case they've already been set by a zealous bootstrap.before.
  19. */
  20.  
  21. // Path to the primary configuration file
  22. if (!defined('PATH_CONF')) define('PATH_CONF', PATH_ROOT.'/conf');
  23.  
  24. // Include default constants if none were defined elsewhere
  25. if (!defined('VANILLA_CONSTANTS'))
  26. include(PATH_CONF.'/constants.php');
  27.  
  28. // Make sure a default time zone is set
  29. date_default_timezone_set('UTC')+0530;
  30. //date_default_timezone_set('Asia/Kolkata');
  31.  
  32. // Include the core function definitions
  33. require_once(PATH_LIBRARY_CORE.'/functions.error.php');
  34. require_once(PATH_LIBRARY_CORE.'/functions.general.php');
  35. require_once(PATH_LIBRARY_CORE.'/functions.compatibility.php');
  36.  
  37. // Include and initialize the autoloader
  38. require_once(PATH_LIBRARY_CORE.'/class.autoloader.php');
  39. Gdn_Autoloader::Start();
  40.  
  41. // Cache Layer
  42. Gdn::FactoryInstall(Gdn::AliasCache, 'Gdn_Cache', NULL, Gdn::FactoryRealSingleton, 'Initialize');
  43.  
  44. // Install the configuration handler
  45. Gdn::FactoryInstall(Gdn::AliasConfig, 'Gdn_Configuration');
  46.  
  47. // Load default baseline Garden configurations
  48. Gdn::Config()->Load(PATH_CONF.'/config-defaults.php');
  49.  
  50. // Load installation-specific configuration so that we know what apps are enabled
  51. Gdn::Config()->Load(PATH_CONF.'/config.php', 'Configuration', TRUE);
  52.  
  53. Gdn::Config()->Caching(TRUE);
  54.  
  55. /**
  56. * Bootstrap Early
  57. *
  58. * A lot of the framework is loaded now, most importantly the autoloader,
  59. * default config and the general and error functions. More control is possible
  60. * here, but some things have already been loaded and are immutable.
  61. */
  62. if (file_exists(PATH_CONF.'/bootstrap.early.php'))
  63. require_once(PATH_CONF.'/bootstrap.early.php');
  64.  
  65. Debug(C('Debug', FALSE));
  66.  
  67. // Default request object
  68. Gdn::FactoryInstall(Gdn::AliasRequest, 'Gdn_Request', NULL, Gdn::FactoryRealSingleton, 'Create');
  69. Gdn::Request()->FromEnvironment();
  70.  
  71. /**
  72. * Extension Managers
  73. *
  74. * Now load the Application, Theme and Plugin managers into the Factory, and
  75. * process the Application-specific configuration defaults.
  76. */
  77.  
  78. // ApplicationManager
  79. Gdn::FactoryInstall(Gdn::AliasApplicationManager, 'Gdn_ApplicationManager');
  80. Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_APPLICATION);
  81.  
  82. // ThemeManager
  83. Gdn::FactoryInstall(Gdn::AliasThemeManager, 'Gdn_ThemeManager');
  84.  
  85. // PluginManager
  86. Gdn::FactoryInstall(Gdn::AliasPluginManager, 'Gdn_PluginManager');
  87.  
  88. // Load the configurations for enabled Applications
  89. foreach (Gdn::ApplicationManager()->EnabledApplicationFolders() as $ApplicationName => $ApplicationFolder)
  90. Gdn::Config()->Load(PATH_APPLICATIONS."/{$ApplicationFolder}/settings/configuration.php");
  91.  
  92. /**
  93. * Installer Redirect
  94. *
  95. * If Garden is not yet installed, force the request to /dashboard/setup and
  96. * begin installation.
  97. */
  98. if (Gdn::Config('Garden.Installed', FALSE) === FALSE && strpos(Gdn_Url::Request(), 'setup') === FALSE) {
  99. header('Location: '.Gdn::Request()->Url('dashboard/setup', TRUE));
  100. exit();
  101. }
  102.  
  103. // Re-apply loaded user settings
  104. Gdn::Config()->OverlayDynamic();
  105.  
  106. /**
  107. * Bootstrap Late
  108. *
  109. * All configurations are loaded, as well as the Application, Plugin and Theme
  110. * managers.
  111. */
  112. if (file_exists(PATH_CONF.'/bootstrap.late.php'))
  113. require_once(PATH_CONF.'/bootstrap.late.php');
  114.  
  115. if (C('Debug'))
  116. Debug(TRUE);
  117.  
  118. Gdn_Cache::Trace(Debug());
  119.  
  120. /**
  121. * Factory Services
  122. *
  123. * These are the helper classes that facilitate Garden's operation. They can be
  124. * overwritten using FactoryOverwrite, but their defaults are installed here.
  125. */
  126.  
  127. // Default database.
  128. Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', NULL, Gdn::FactorySingleton, array('Database'));
  129. // Database drivers.
  130. Gdn::FactoryInstall('MySQLDriver', 'Gdn_MySQLDriver', NULL, Gdn::FactoryInstance);
  131. Gdn::FactoryInstall('MySQLStructure', 'Gdn_MySQLStructure', NULL, Gdn::FactoryInstance);
  132. // Form class
  133. Gdn::FactoryInstall('Form', 'Gdn_Form', NULL, Gdn::FactoryInstance);
  134.  
  135. // Identity, Authenticator & Session.
  136. Gdn::FactoryInstall('Identity', 'Gdn_CookieIdentity');
  137. Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session');
  138. Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth');
  139.  
  140. // Dispatcher.
  141. Gdn::FactoryInstall(Gdn::AliasRouter, 'Gdn_Router');
  142. Gdn::FactoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher');
  143.  
  144. // Smarty Templating Engine
  145. Gdn::FactoryInstall('Smarty', 'Smarty', PATH_LIBRARY.'/vendors/Smarty-2.6.25/libs/Smarty.class.php');
  146. Gdn::FactoryInstall('ViewHandler.tpl', 'Gdn_Smarty');
  147.  
  148. // Slice handler
  149. Gdn::FactoryInstall(Gdn::AliasSlice, 'Gdn_Slice');
  150.  
  151. // Remote Statistics
  152. Gdn::FactoryInstall('Statistics', 'Gdn_Statistics', NULL, Gdn::FactorySingleton);
  153. Gdn::Statistics();
  154.  
  155. // Regarding
  156. Gdn::FactoryInstall('Regarding', 'Gdn_Regarding', NULL, Gdn::FactorySingleton);
  157. Gdn::Regarding();
  158.  
  159. // Other objects.
  160. Gdn::FactoryInstall('Dummy', 'Gdn_Dummy');
  161.  
  162. /**
  163. * Extension Startup
  164. *
  165. * Allow installed Extensions (Applications, Themes, Plugins) to execute startup
  166. * and bootstrap procedures that they may have, here.
  167. */
  168.  
  169. // Applications startup
  170. foreach (Gdn::ApplicationManager()->EnabledApplicationFolders() as $ApplicationName => $ApplicationFolder) {
  171. // Include the application's bootstrap.
  172. $Gdn_Path = PATH_APPLICATIONS."/{$ApplicationFolder}/settings/bootstrap.php";
  173. if (file_exists($Gdn_Path))
  174. include_once($Gdn_Path);
  175.  
  176. // Include the application's hooks.
  177. $Hooks_Path = PATH_APPLICATIONS."/{$ApplicationFolder}/settings/class.hooks.php";
  178. if (file_exists($Hooks_Path))
  179. include_once($Hooks_Path);
  180. }
  181.  
  182. unset($Gdn_Path);
  183. unset($Hooks_Path);
  184.  
  185. // Themes startup
  186. Gdn::ThemeManager()->Start();
  187. Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_THEME);
  188.  
  189. // Plugins startup
  190. Gdn::PluginManager()->Start();
  191. Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_PLUGIN);
  192.  
  193. /**
  194. * Locales
  195. *
  196. * Install any custom locales provided by applications and plugins, and set up
  197. * the locale management system.
  198. */
  199.  
  200. // Load the Garden locale system
  201. $Gdn_Locale = new Gdn_Locale(C('Garden.Locale', 'en-CA'), Gdn::ApplicationManager()->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders());
  202. Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', NULL, Gdn::FactorySingleton, $Gdn_Locale);
  203. unset($Gdn_Locale);
  204.  
  205. require_once(PATH_LIBRARY_CORE.'/functions.validation.php');
  206.  
  207. // Start Authenticators
  208. Gdn::Authenticator()->StartAuthenticator();
  209.  
  210. /**
  211. * Bootstrap After
  212. *
  213. * After the bootstrap has finished loading, this hook allows developers a last
  214. * chance to customize Garden's runtime environment before the actual request
  215. * is handled.
  216. */
  217. if (file_exists(PATH_ROOT.'/conf/bootstrap.after.php'))
  218. require_once(PATH_ROOT.'/conf/bootstrap.after.php');
  219.  
  220. // Include "Render" functions now - this way pluggables and custom confs can override them.
  221. require_once(PATH_LIBRARY_CORE.'/functions.render.php');
  222.  
  223. if (!defined('CLIENT_NAME'))
  224. define('CLIENT_NAME', 'vanilla');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement