/** * Returns an instance of class (singleton pattern implementation). * * @return OW_ThemeManager */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Application init actions. */ public function init() { // router init - need to set current page uri and base url $router = OW::getRouter(); $router->setBaseUrl(OW_URL_HOME); $this->urlHostRedirect(); OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator()); $this->userAutoLogin(); // setting default time zone date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone')); // synchronize the db's time zone OW::getDbo()->setTimezone(); // OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel'); OW::getRequestHandler()->setStaticPageAttributes('BASE_MCTRL_BaseDocument', 'staticDocument'); $uri = OW::getRequest()->getRequestUri(); // before setting in router need to remove get params if (strstr($uri, '?')) { $uri = substr($uri, 0, strpos($uri, '?')); } $router->setUri($uri); $defaultRoute = new OW_DefaultRoute(); //$defaultRoute->setControllerNamePrefix('MCTRL'); $router->setDefaultRoute($defaultRoute); $navService = BOL_NavigationService::getInstance(); // // // try to find static document with current uri // $document = $navService->findStaticDocument($uri); // // if ( $document !== null ) // { // $this->documentKey = $document->getKey(); // } OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); $beckend = OW::getEventManager()->call('base.cache_backend_init'); if ($beckend !== null) { OW::getCacheManager()->setCacheBackend($beckend); OW::getCacheManager()->setLifetime(3600); OW::getDbo()->setUseCashe(true); } $this->devActions(); OW::getThemeManager()->initDefaultTheme(true); // setting current theme $activeThemeName = OW::getEventManager()->call('base.get_active_theme_name'); $activeThemeName = $activeThemeName ? $activeThemeName : OW::getConfig()->getValue('base', 'selectedTheme'); if ($activeThemeName !== BOL_ThemeService::DEFAULT_THEME && OW::getThemeManager()->getThemeService()->themeExists($activeThemeName)) { OW_ThemeManager::getInstance()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(trim($activeThemeName), true)); } // adding static document routes $staticDocs = $navService->findAllMobileStaticDocuments(); $staticPageDispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes(); /* @var $value BOL_Document */ foreach ($staticDocs as $value) { OW::getRouter()->addRoute(new OW_Route($value->getKey(), $value->getUri(), $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $value->getKey())))); // TODO refactor - hotfix for TOS page if (UTIL_String::removeFirstAndLastSlashes($value->getUri()) == 'terms-of-use') { OW::getRequestHandler()->addCatchAllRequestsExclude('base.members_only', $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => $value->getKey())); } } //adding index page route $item = BOL_NavigationService::getInstance()->findFirstLocal(OW::getUser()->isAuthenticated() ? BOL_NavigationService::VISIBLE_FOR_MEMBER : BOL_NavigationService::VISIBLE_FOR_GUEST, OW_Navigation::MOBILE_TOP); if ($item !== null) { if ($item->getRoutePath()) { $route = OW::getRouter()->getRoute($item->getRoutePath()); $ddispatchAttrs = $route->getDispatchAttrs(); } else { $ddispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes(); } $router->addRoute(new OW_Route('base_default_index', '/', $ddispatchAttrs['controller'], $ddispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $item->getDocumentKey())))); $this->indexMenuItem = $item; OW::getEventManager()->bind(OW_EventManager::ON_AFTER_REQUEST_HANDLE, array($this, 'activateMenuItem')); } else { $router->addRoute(new OW_Route('base_default_index', '/', 'BASE_MCTRL_WidgetPanel', 'index')); } if (!OW::getRequest()->isAjax()) { OW::getResponse()->setDocument($this->newDocument()); OW::getDocument()->setMasterPage(new OW_MobileMasterPage()); OW::getResponse()->setHeader(OW_Response::HD_CNT_TYPE, OW::getDocument()->getMime() . '; charset=' . OW::getDocument()->getCharset()); } else { OW::getResponse()->setDocument(new OW_AjaxDocument()); } /* additional actions */ if (OW::getUser()->isAuthenticated()) { BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext()); } // adding global template vars $currentThemeImagesDir = OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl(); $viewRenderer = OW_ViewRenderer::getInstance(); $viewRenderer->assignVar('themeImagesUrl', $currentThemeImagesDir); $viewRenderer->assignVar('siteName', OW::getConfig()->getValue('base', 'site_name')); $viewRenderer->assignVar('siteTagline', OW::getConfig()->getValue('base', 'site_tagline')); $viewRenderer->assignVar('siteUrl', OW_URL_HOME); $viewRenderer->assignVar('isAuthenticated', OW::getUser()->isAuthenticated()); $viewRenderer->assignVar('bottomPoweredByLink', '<a href="http://www.oxwall.org/" target="_blank" title="Powered by Oxwall Community Software"><img src="' . $currentThemeImagesDir . 'powered-by-oxwall.png" alt="Oxwall Community Software" /></a>'); $viewRenderer->assignVar('adminDashboardIframeUrl', "http://static.oxwall.org/spotlight/?platform=oxwall&platform-version=" . OW::getConfig()->getValue('base', 'soft_version') . "&platform-build=" . OW::getConfig()->getValue('base', 'soft_build')); if (function_exists('ow_service_actions')) { call_user_func('ow_service_actions'); } $this->handleHttps(); }
OW::getRouter()->setBaseUrl(OW_URL_HOME); OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); //init cache manager $beckend = OW::getEventManager()->call('base.cache_backend_init'); if ($beckend !== null) { OW::getCacheManager()->setCacheBackend($beckend); OW::getCacheManager()->setLifetime(3600); OW::getDbo()->setUseCashe(true); } OW::getThemeManager()->initDefaultTheme(); // setting current theme $activeThemeName = OW::getConfig()->getValue('base', 'selectedTheme'); if ($activeThemeName !== BOL_ThemeService::DEFAULT_THEME && OW::getThemeManager()->getThemeService()->themeExists($activeThemeName)) { OW_ThemeManager::getInstance()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(trim($activeThemeName))); } $plugins = BOL_PluginService::getInstance()->findActivePlugins(); foreach ($plugins as $plugin) { /* @var $plugin BOL_Plugin */ $pluginRootDir = OW::getPluginManager()->getPlugin($plugin->getKey())->getRootDir(); if (file_exists($pluginRootDir . DS . 'cron.php')) { include $pluginRootDir . DS . 'cron.php'; $className = strtoupper($plugin->getKey()) . '_Cron'; $cron = new $className(); $runJobs = array(); $newRunJobDtos = array(); foreach (BOL_CronService::getInstance()->findJobList() as $runJob) { /* @var $runJob BOL_CronJob */ $runJobs[$runJob->methodName] = $runJob->runStamp; }
/** * Returns system theme manager object. * * @return OW_ThemeManager */ public static function getThemeManager() { return OW_ThemeManager::getInstance(); }