/** * Returns selected theme name. * * @return OW_Theme */ public function getSelectedTheme() { $selectedTheme = OW::getConfig()->getValue('base', 'selectedTheme'); if (empty($this->themeObjects[$selectedTheme])) { $this->themeObjects[$selectedTheme] = $this->themeService->getThemeObjectByKey(OW::getConfig()->getValue('base', 'selectedTheme')); } return $this->themeObjects[$selectedTheme]; }
/** * Constructor. */ public function __construct() { parent::__construct(); $this->pluginService = BOL_PluginService::getInstance(); $this->storageService = BOL_StorageService::getInstance(); $this->themeService = BOL_ThemeService::getInstance(); }
/** * Constructor. */ public function __construct() { parent::__construct(); if (OW::getApplication()->getContext() != OW_Application::CONTEXT_DESKTOP) { throw new InterceptException(array(OW_RequestHandler::ATTRS_KEY_CTRL => 'BASE_MCTRL_BaseDocument', OW_RequestHandler::ATTRS_KEY_ACTION => 'notAvailable')); } if (!OW::getUser()->isAdmin()) { throw new AuthenticateException(); } if (!OW::getRequest()->isAjax()) { $document = OW::getDocument(); $document->setMasterPage(new ADMIN_CLASS_MasterPage()); $this->setPageTitle(OW::getLanguage()->text('admin', 'page_default_title')); } BOL_PluginService::getInstance()->checkManualUpdates(); BOL_ThemeService::getInstance()->checkManualUpdates(); $plugin = BOL_PluginService::getInstance()->findNextManualUpdatePlugin(); $handlerParams = OW::getRequestHandler()->getHandlerAttributes(); // TODO refactor shortcut below if (!defined('OW_PLUGIN_XP') && $plugin !== null) { if ($handlerParams['controller'] === 'ADMIN_CTRL_Plugins' && $handlerParams['action'] === 'manualUpdateRequest') { //action } else { throw new RedirectException(OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'manualUpdateRequest', array('key' => $plugin->getKey()))); } } // TODO temp admin pge inform event function admin_check_if_admin_page() { return true; } OW::getEventManager()->bind('admin.check_if_admin_page', 'admin_check_if_admin_page'); }
/** * @see OW_MasterPage::init() */ protected function init() { $language = OW::getLanguage(); OW::getThemeManager()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(BOL_ThemeService::DEFAULT_THEME)); $menuTypes = array(BOL_NavigationService::MENU_TYPE_ADMIN, BOL_NavigationService::MENU_TYPE_APPEARANCE, BOL_NavigationService::MENU_TYPE_PAGES, BOL_NavigationService::MENU_TYPE_PLUGINS, BOL_NavigationService::MENU_TYPE_SETTINGS, BOL_NavigationService::MENU_TYPE_USERS, BOL_NavigationService::MENU_TYPE_MOBILE); $menuItems = BOL_NavigationService::getInstance()->findMenuItemsForMenuList($menuTypes); if (defined('OW_PLUGIN_XP')) { foreach ($menuItems as $key1 => $menuType) { foreach ($menuType as $key2 => $menuItem) { if (in_array($menuItem['key'], array('sidebar_menu_plugins_add', 'sidebar_menu_themes_add'))) { unset($menuItems[$key1][$key2]); } } } } $menuDataArray = array('menu_admin' => BOL_NavigationService::MENU_TYPE_ADMIN, 'menu_users' => BOL_NavigationService::MENU_TYPE_USERS, 'menu_settings' => BOL_NavigationService::MENU_TYPE_SETTINGS, 'menu_appearance' => BOL_NavigationService::MENU_TYPE_APPEARANCE, 'menu_pages' => BOL_NavigationService::MENU_TYPE_PAGES, 'menu_plugins' => BOL_NavigationService::MENU_TYPE_PLUGINS, 'menu_mobile' => BOL_NavigationService::MENU_TYPE_MOBILE); foreach ($menuDataArray as $key => $value) { $this->menuCmps[$key] = new ADMIN_CMP_AdminMenu($menuItems[$value]); $this->addMenu($value, $this->menuCmps[$key]); } $event = new ADMIN_CLASS_NotificationCollector('admin.add_admin_notification'); OW::getEventManager()->trigger($event); $this->assign('notifications', $event->getData()); // platform info $event = new OW_Event('admin.get_soft_version_text'); OW_EventManager::getInstance()->trigger($event); $verString = $event->getData(); if (empty($verString)) { $verString = OW::getLanguage()->text('admin', 'soft_version', array('version' => OW::getConfig()->getValue('base', 'soft_version'), 'build' => OW::getConfig()->getValue('base', 'soft_build'))); } $this->assign('version', OW::getConfig()->getValue('base', 'soft_version')); $this->assign('build', OW::getConfig()->getValue('base', 'soft_build')); $this->assign('softVersion', $verString); }
/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_ThemeService */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * @see OW_MasterPage::init() */ protected function init() { $language = OW::getLanguage(); OW::getThemeManager()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(BOL_ThemeService::DEFAULT_THEME)); $menuTypes = array(BOL_NavigationService::MENU_TYPE_ADMIN, BOL_NavigationService::MENU_TYPE_APPEARANCE, BOL_NavigationService::MENU_TYPE_PRIVACY, BOL_NavigationService::MENU_TYPE_PAGES, BOL_NavigationService::MENU_TYPE_PLUGINS, BOL_NavigationService::MENU_TYPE_SETTINGS, BOL_NavigationService::MENU_TYPE_USERS, BOL_NavigationService::MENU_TYPE_MOBILE); $menuItems = BOL_NavigationService::getInstance()->findMenuItemsForMenuList($menuTypes); if (defined('OW_PLUGIN_XP')) { foreach ($menuItems as $key1 => $menuType) { foreach ($menuType as $key2 => $menuItem) { if (in_array($menuItem['key'], array('sidebar_menu_plugins_add', 'sidebar_menu_themes_add'))) { unset($menuItems[$key1][$key2]); } } } } $menuDataArray = array('menu_admin' => BOL_NavigationService::MENU_TYPE_ADMIN, 'menu_users' => BOL_NavigationService::MENU_TYPE_USERS, 'menu_settings' => BOL_NavigationService::MENU_TYPE_SETTINGS, 'menu_privacy' => BOL_NavigationService::MENU_TYPE_PRIVACY, 'menu_appearance' => BOL_NavigationService::MENU_TYPE_APPEARANCE, 'menu_pages' => BOL_NavigationService::MENU_TYPE_PAGES, 'menu_plugins' => BOL_NavigationService::MENU_TYPE_PLUGINS, 'menu_mobile' => BOL_NavigationService::MENU_TYPE_MOBILE); foreach ($menuDataArray as $key => $value) { $this->menuCmps[$key] = new ADMIN_CMP_AdminMenu($menuItems[$value]); $this->addMenu($value, $this->menuCmps[$key]); } // admin notifications $adminNotifications = array(); if (!defined('OW_PLUGIN_XP') && OW::getConfig()->getValue('base', 'update_soft')) { $adminNotifications[] = $language->text('admin', 'notification_soft_update', array('link' => OW::getRouter()->urlForRoute('admin_core_update_request'))); } $pluginsCount = BOL_PluginService::getInstance()->getPluginsToUpdateCount(); if (!defined('OW_PLUGIN_XP') && $pluginsCount > 0) { $adminNotifications[] = $language->text('admin', 'notification_plugins_to_update', array('link' => OW::getRouter()->urlForRoute('admin_plugins_installed'), 'count' => $pluginsCount)); } $themesCount = BOL_ThemeService::getInstance()->getThemesToUpdateCount(); if (!defined('OW_PLUGIN_XP') && $themesCount > 0) { $adminNotifications[] = $language->text('admin', 'notification_themes_to_update', array('link' => OW::getRouter()->urlForRoute('admin_themes_choose'), 'count' => $themesCount)); } $event = new BASE_CLASS_EventCollector('admin.add_admin_notification'); OW::getEventManager()->trigger($event); $adminNotifications = array_merge($adminNotifications, $event->getData()); $this->assign('notifications', $adminNotifications); $adminWarnings = array(); if (!defined('OW_PLUGIN_XP') && OW::getConfig()->configExists('base', 'cron_is_active') && (int) OW::getConfig()->getValue('base', 'cron_is_active') === 0) { $adminWarnings[] = $language->text('admin', 'warning_cron_is_not_active', array('path' => OW_DIR_ROOT . 'ow_cron' . DS . 'run.php')); } if (!defined('OW_PLUGIN_XP') && !ini_get('allow_url_fopen')) { $adminWarnings[] = $language->text('admin', 'warning_url_fopen_disabled'); } $event = new BASE_CLASS_EventCollector('admin.add_admin_warning'); OW::getEventManager()->trigger($event); $adminWarnings = array_merge($adminWarnings, $event->getData()); $this->assign('warnings', $adminWarnings); // platform info $event = new OW_Event('admin.get_soft_version_text'); OW_EventManager::getInstance()->trigger($event); $verString = $event->getData(); if (empty($verString)) { $verString = OW::getLanguage()->text('admin', 'soft_version', array('version' => OW::getConfig()->getValue('base', 'soft_version'), 'build' => OW::getConfig()->getValue('base', 'soft_build'))); } $this->assign('version', OW::getConfig()->getValue('base', 'soft_version')); $this->assign('build', OW::getConfig()->getValue('base', 'soft_build')); $this->assign('softVersion', $verString); }
/** * Updates themes list and regenerates cache of each theme */ public function clearThemeCache() { $this->themeService->updateThemeList(); $this->themeService->processAllThemes(); if (OW::getConfig()->configExists("base", "cachedEntitiesPostfix")) { OW::getConfig()->saveConfig("base", "cachedEntitiesPostfix", UTIL_String::getRandomString()); } }
public function onBeforeRender() { parent::onBeforeRender(); $id = uniqid('filter'); $this->assign('id', $id); $images = BOL_ThemeService::getInstance()->findAllCssImages(); $this->assign('dates', $this->getDates($images)); $jsString = ";\$('#{$id} ul li a').click(function(e){\n e.preventDefault();\n window.browsePhoto.filter({'date': \$(this).data('date')});\n \$(this).parents('.ow_context_action').find('.ow_context_action_value span').html(\$(this).html());\n });\n "; OW::getDocument()->addOnloadScript($jsString); }
private function getThemeDtoByName($params) { if (!empty($params['name'])) { $themeDto = $this->themeService->findThemeByName(trim($params['name'])); } if (!empty($themeDto)) { return $themeDto; } OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_themes_theme_not_found')); $this->redirectToAction('chooseTheme'); }
private function updateItemsLicenseStatus(array $items) { $invalidItems = array(self::URI_VAR_ITEM_TYPE_VAL_PLUGIN => array(), self::URI_VAR_ITEM_TYPE_VAL_THEME => array()); foreach ($items as $item) { $invalidItems[$item[self::URI_VAR_ITEM_TYPE]][$item[self::URI_VAR_KEY]] = $item[self::URI_VAR_DEV_KEY]; } $itemsToCheck = array_merge($this->pluginService->findAllPlugins(), $this->themeService->findAllThemes()); $dataForNotification = array(); /* @var $item BOL_StoreItem */ foreach ($itemsToCheck as $item) { $type = $item instanceof BOL_Plugin ? self::URI_VAR_ITEM_TYPE_VAL_PLUGIN : self::URI_VAR_ITEM_TYPE_VAL_THEME; // if the item is on DB if (isset($invalidItems[$type][$item->getKey()]) && $invalidItems[$type][$item->getKey()] == $item->getDeveloperKey()) { if ((int) $item->getLicenseCheckTimestamp() == 0) { $dataForNotification[] = array("type" => $type, "title" => $item->getTitle()); $item->setLicenseCheckTimestamp(time()); $this->saveStoreItem($item); } else { if ($this->isItemLicenseCheckPeriodExpired($item->getLicenseCheckTimestamp())) { if ($type == self::URI_VAR_ITEM_TYPE_VAL_THEME && $this->themeService->getSelectedThemeName() == $item->getKey()) { $defaultTheme = OW::getEventManager()->call("base.get_default_theme"); if (!$defaultTheme) { $defaultTheme = BOL_ThemeService::DEFAULT_THEME; } $this->themeService->setSelectedThemeName($defaultTheme); } else { if ($type == self::URI_VAR_ITEM_TYPE_VAL_PLUGIN && $item->isActive) { $this->pluginService->deactivate($item->getKey()); } } } } } else { if ($item->getLicenseCheckTimestamp() != null && $item->getLicenseCheckTimestamp() > 0) { $item->setLicenseCheckTimestamp(null); $this->saveStoreItem($item); } } } $this->notifyAdminAboutInvalidItems($dataForNotification); }
public function addAdminNotification(ADMIN_CLASS_NotificationCollector $coll) { // update soft if (OW::getConfig()->getValue('base', 'update_soft')) { $coll->add(OW::getLanguage()->text('admin', 'notification_soft_update', array('link' => OW::getRouter()->urlForRoute('admin_core_update_request'))), ADMIN_CLASS_NotificationCollector::NOTIFICATION_WARNING); } $pluginsCount = BOL_PluginService::getInstance()->getPluginsToUpdateCount(); // plugins update if ($pluginsCount > 0) { $coll->add(OW::getLanguage()->text('admin', 'notification_plugins_to_update', array('link' => OW::getRouter()->urlForRoute('admin_plugins_installed'), 'count' => $pluginsCount)), ADMIN_CLASS_NotificationCollector::NOTIFICATION_UPDATE); } $themesCount = BOL_ThemeService::getInstance()->getThemesToUpdateCount(); // themes update if ($themesCount > 0) { $coll->add(OW::getLanguage()->text('admin', 'notification_themes_to_update', array('link' => OW::getRouter()->urlForRoute('admin_themes_choose'), 'count' => $themesCount)), ADMIN_CLASS_NotificationCollector::NOTIFICATION_UPDATE); } if (OW::getConfig()->configExists('base', 'cron_is_active') && (int) OW::getConfig()->getValue('base', 'cron_is_active') === 0) { $coll->add(OW::getLanguage()->text('admin', 'warning_cron_is_not_active', array('path' => OW_DIR_ROOT . 'ow_cron' . DS . 'run.php')), ADMIN_CLASS_NotificationCollector::NOTIFICATION_WARNING); } if (!ini_get('allow_url_fopen')) { $coll->add(OW::getLanguage()->text('admin', 'warning_url_fopen_disabled'), ADMIN_CLASS_NotificationCollector::NOTIFICATION_WARNING); } }
/** * Cron function. */ public function checkUpdates() { if (defined('OW_PLUGIN_XP')) { return; } $pluginsRequestArray = array(array('key' => 'core', 'developerKey' => 'ow', 'build' => OW::getConfig()->getValue('base', 'soft_build'))); $plugins = $this->pluginDao->findRegularPlugins(); /* @var $plugin BOL_Plugin */ foreach ($plugins as $plugin) { $pluginsRequestArray[] = array('key' => $plugin->getKey(), 'developerKey' => $plugin->getDeveloperKey(), 'build' => $plugin->getBuild()); } $themeService = BOL_ThemeService::getInstance(); //check all manual updates before reading builds in DB $themeService->checkManualUpdates(); $themesRequestArray = array(); $themes = $themeService->findAllThemes(); /* @var $theme BOL_Theme */ foreach ($themes as $theme) { $themesRequestArray[] = array('key' => $theme->getName(), 'developerKey' => $theme->getDeveloperKey(), 'build' => $theme->getBuild()); } $event = new OW_Event('base.on_plugin_info_update'); OW::getEventManager()->trigger($event); $data = $event->getData(); if (empty($data)) { $data = array(); } $requestUrl = OW::getRequest()->buildUrlQueryString(self::UPDATE_SERVER . 'get-items-update-info/'); $data['plugins'] = urlencode(json_encode($pluginsRequestArray)); $data['themes'] = urlencode(json_encode($themesRequestArray)); $postdata = http_build_query($data); $options = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($options); $resultArray = json_decode(file_get_contents($requestUrl, false, $context), true); if (empty($resultArray) || !is_array($resultArray)) { return; } if (!empty($resultArray['plugins']) && is_array($resultArray['plugins'])) { foreach ($plugins as $plugin) { if (in_array($plugin->getKey(), $resultArray['plugins']) && (int) $plugin->getUpdate() === 0) { $plugin->setUpdate(1); $this->pluginDao->save($plugin); } } if (in_array('core', $resultArray['plugins'])) { OW::getConfig()->saveConfig('base', 'update_soft', 1); } } if (!empty($resultArray['themes']) && is_array($resultArray['themes'])) { foreach ($themes as $theme) { if (in_array($theme->getName(), $resultArray['themes']) && (int) $theme->getUpdate() === 0) { $theme->setUpdate(1); $themeService->saveTheme($theme); } } } }
/** * Returns images dir path. * * @return string */ public function getImagesDir($mobile = false) { return $this->themeService->getImagesDir($this->dto->getKey(), $mobile); }
protected function updateCachedEntities($options) { $options = intval($options); if ($options === 1 || $options & 1 << 1) { OW_ViewRenderer::getInstance()->clearCompiledTpl(); } if ($options === 1 || $options & 1 << 2) { BOL_ThemeService::getInstance()->updateThemeList(); BOL_ThemeService::getInstance()->processAllThemes(); if (OW::getConfig()->configExists('base', 'cachedEntitiesPostfix')) { OW::getConfig()->saveConfig('base', 'cachedEntitiesPostfix', uniqid()); } $event = new OW_Event('base.update_cache_entities'); OW::getEventManager()->trigger($event); } if ($options === 1 || $options & 1 << 3) { BOL_LanguageService::getInstance()->generateCacheForAllActiveLanguages(); } if ($options === 1 || $options & 1 << 4) { OW::getCacheManager()->clean(array(), OW_CacheManager::CLEAN_ALL); } if (($options === 1 || $options & 1 << 5) && !defined('OW_PLUGIN_XP')) { $pluginService = BOL_PluginService::getInstance(); $activePlugins = $pluginService->findActivePlugins(); /* @var $pluginDto BOL_Plugin */ foreach ($activePlugins as $pluginDto) { $pluginStaticDir = OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'static' . DS; if (file_exists($pluginStaticDir)) { $staticDir = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule() . DS; if (!file_exists($staticDir)) { mkdir($staticDir); chmod($staticDir, 0777); } UTIL_File::copyDir($pluginStaticDir, $staticDir); } } } }
public function ajaxSubmitPhotos($params) { $userId = OW::getUser()->getId(); $fileTmpService = BOL_FileTemporaryService::getInstance(); $themeService = BOL_ThemeService::getInstance(); if (count($tmpList = $fileTmpService->findUserTemporaryFiles($userId, 'order')) === 0) { $resp = array('result' => false, 'msg' => OW::getLanguage()->text('admin', 'photo_upload_error')); $this->returnResponse($resp); } $form = new BASE_CLASS_AjaxUploadForm('user', $userId); if (!$form->isValid($_POST)) { $resp = array('result' => false); $resp['msg'] = OW::getLanguage()->text('admin', 'photo_upload_error'); $this->returnResponse($resp); } list($entityType, $entityId) = $this->getEntity($params); $files = array(); $tmpList = array_reverse($tmpList); foreach ($tmpList as $tmpFile) { $tmpId = $tmpFile['dto']->id; $file = $themeService->moveTemporaryFile($tmpId, !empty($_POST['desc'][$tmpId]) ? $_POST['desc'][$tmpId] : ''); $fileTmpService->deleteTemporaryFile($tmpId); if ($file) { $files[] = $file; } } $resp = $this->onSubmitComplete($entityType, $entityId, $files); $this->returnResponse($resp); }
public function __construct() { parent::__construct('add-css'); $text = new Textarea('css'); $dto = BOL_ThemeService::getInstance()->findThemeByKey(OW::getConfig()->getValue('base', 'selectedTheme')); $text->setValue($dto->getCustomCss()); $this->addElement($text); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('admin', 'theme_css_edit_submit_label')); $this->addElement($submit); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $this->bindJsFunction(Form::BIND_SUCCESS, 'function(data){OW.info(data.message)}'); }
/** * Returns selected theme name. * * @return OW_Theme */ public function getSelectedTheme() { return $this->themeService->getThemeObjectByName(OW::getConfig()->getValue('base', 'selectedTheme')); }
$hcMessage = "Error! Theme '<b>" . htmlspecialchars($_GET['theme']) . "</b>' not found."; } else { $xmlInfoArray = (array) simplexml_load_file(OW_DIR_ROOT . 'ow_themes' . DS . $result['name'] . DS . 'theme.xml'); if ((int) $xmlInfoArray['build'] > (int) $result['build']) { $db->query("UPDATE `" . OW_DB_PREFIX . "base_config` SET `value` = 1 WHERE `key` = 'base' AND `name` = 'maintenance'"); $entries = UPDATER::getLogger()->getEntries(); if (!empty($entries)) { $query = "INSERT INTO `" . OW_DB_PREFIX . "base_log` (`message`, `type`, `key`, `timeStamp`) VALUES (:message, 'ow_update', :key, :time)"; try { $db->query($query, array('message' => json_encode($entries), 'key' => $result['name'], 'time' => time())); } catch (Exception $e) { } } $query = "UPDATE `" . OW_DB_PREFIX . "base_theme` SET `update` = 0 WHERE `name` = :name"; $db->query($query, array('name' => $result['name'])); BOL_ThemeService::getInstance()->updateThemeInfo($result['name'], true); $mode = 'theme_update_success'; $hcMessage = "Update Complete! Theme '<b>" . $result['title'] . "</b>' successfully updated."; $db->query("UPDATE `" . OW_DB_PREFIX . "base_config` SET `value` = 0 WHERE `key` = 'base' AND `name` = 'maintenance'"); $db->query("UPDATE `" . OW_DB_PREFIX . "base_config` SET `value` = 1 WHERE `key` = 'base' AND `name` = 'dev_mode'"); } else { $db->query("UPDATE `" . OW_DB_PREFIX . "base_theme` SET `update` = 0 WHERE `name` = :name", array('name' => $result['name'])); $mode = 'theme_up_to_date'; $hcMessage = "Error! Theme '<b>" . $result['title'] . "</b>' is up to date."; } } // update result actions if (!empty($_GET['back-uri'])) { $url = build_url_query_string(OW_URL_HOME . urldecode($_GET['back-uri']), array('theme' => $_GET['theme'], 'mode' => $mode)); Header("HTTP/1.1 301 Moved Permanently"); Header("Location: " . $url);
$cssImages = BOL_ThemeService::getInstance()->findAllCssImages(); /* @var $image BOL_ThemeImage */ foreach ($cssImages as $image) { $path = OW_DIR_THEME_USERFILES . $image->getFilename(); $storage->copyFile($path, $path); } $themesList = BOL_ThemeService::getInstance()->findAllThemes(); $newDirUrl = $storage->getFileUrl(OW_DIR_THEME_USERFILES); if (mb_substr($newDirUrl, -1) !== '/') { $newDirUrl .= '/'; } /* @var $theme BOL_Theme */ foreach ($themesList as $theme) { if ($theme->getCustomCss() && mb_strstr($theme->getCustomCss(), OW_URL_USERFILES)) { $theme->setCustomCss(str_replace(OW_URL_THEME_USERFILES, $newDirUrl, $theme->getCustomCss())); BOL_ThemeService::getInstance()->saveTheme($theme); } } } /* end of code to move all custom css graphics to clouds */ //---------- ONLY FOR SERVICE -------- /* try { $sql = " SELECT m.* FROM `".OW_DB_PREFIX."base_media_panel_file` m LEFT JOIN `".OW_DB_PREFIX."base_user` u ON ( m.userId = u.id ) WHERE u.id IS NULL "; $fileList = $db->queryForObjectList($sql, 'BOL_MediaPanelFile'); foreach( $fileList as $image )
public function onAfterRoute(OW_Event $e) { $pluginService = BOL_PluginService::getInstance(); $attrs = OW::getRequestHandler()->getHandlerAttributes(); if (is_subclass_of($attrs[OW_RequestHandler::ATTRS_KEY_CTRL], "ADMIN_CTRL_Abstract")) { $pluginService->checkManualUpdates(); BOL_ThemeService::getInstance()->checkManualUpdates(); if ($pluginService->findNextManualUpdatePlugin() != null) { $params = array(OW_RequestHandler::ATTRS_KEY_CTRL => "ADMIN_CTRL_Plugins", OW_RequestHandler::ATTRS_KEY_ACTION => "manualUpdateRequest", OW_RequestHandler::CATCH_ALL_REQUEST_KEY_REDIRECT => true); OW::getRequestHandler()->setCatchAllRequestsAttributes("admin.manual_update", $params); OW::getRequestHandler()->addCatchAllRequestsExclude("admin.manual_update", "ADMIN_CTRL_Plugins", "manualUpdateAll"); } } }
<?php /** * Copyright (c) 2013, Oxwall CandyStore * All rights reserved. * ATTENTION: This commercial software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ * and is licensed under Oxwall Store Commercial License. * Full text of this license can be found at http://www.oxwall.org/store/oscl */ /** * /activate.php * * @author Oxwall CandyStore <*****@*****.**> * @package ow.ow_plugins.ocs_sitestats * @since 1.5 */ $cmpService = BOL_ComponentAdminService::getInstance(); $widget = $cmpService->addWidget('OCSSITESTATS_CMP_IndexWidget'); $placeWidget = $cmpService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_INDEX); $activeThemeName = OW::getConfig()->getValue('base', 'selectedTheme'); $theme = BOL_ThemeService::getInstance()->getThemeObjectByName($activeThemeName)->getDto(); $sidebarPos = $theme->getSidebarPosition(); if (in_array($sidebarPos, array('left', 'right'))) { $cmpService->addWidgetToPosition($placeWidget, BOL_ComponentAdminService::SECTION_SIDEBAR); }
$queryList = array("CREATE TABLE IF NOT EXISTS `{$tblPrefix}base_attachment` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `userId` int(11) NOT NULL,\n `addStamp` int(11) NOT NULL,\n `status` tinyint(1) NOT NULL DEFAULT '0',\n `fileName` varchar(100) DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci", "ALTER IGNOER TABLE `{$tblPrefix}base_authorization_user_role` ADD UNIQUE `user2role` ( `userId` , `roleId` ) "); foreach ($queryList as $query) { try { $db->query($query); } catch (Exception $e) { if (isset($logArray)) { $logArray[] = $e; } else { $errors[] = $e; } } } $widget = BOL_ComponentAdminService::getInstance()->addWidget('BASE_CMP_QuickLinksWidget', false); $placeWidget = BOL_ComponentAdminService::getInstance()->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_DASHBOARD); BOL_ComponentAdminService::getInstance()->addWidgetToPosition($placeWidget, BOL_ComponentAdminService::SECTION_RIGHT); /* code to move all custom css files to clouds */ if (defined('OW_USE_AMAZON_S3_CLOUDFILES') && OW_USE_AMAZON_S3_CLOUDFILES || defined('OW_USE_CLOUDFILES') && OW_USE_CLOUDFILES) { $storage = Updater::getStorage(); $themesList = BOL_ThemeService::getInstance()->findAllThemes(); /* @var $theme BOL_Theme */ foreach ($themesList as $theme) { if (file_exists(OW_DIR_THEME_USERFILES . $theme->getCustomCssFileName()) && is_file(OW_DIR_THEME_USERFILES . $theme->getCustomCssFileName())) { $storage->copyFile(OW_DIR_THEME_USERFILES . $theme->getCustomCssFileName(), OW_DIR_THEME_USERFILES . $theme->getCustomCssFileName()); } } } Updater::getLanguageService()->deleteLangKey('base', 'questions_question_presentation_select_label'); Updater::getLanguageService()->deleteLangKey('base', 'questions_question_presentation_radio_label'); Updater::getLanguageService()->deleteLangKey('base', 'questions_question_presentation_age_label'); Updater::getLanguageService()->deleteLangKey('base', 'questions_question_presentation_birthdate_label'); Updater::getLanguageService()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'base');
<?php $db = Updater::getDbo(); $logger = Updater::getLogger(); $storage = Updater::getStorage(); $tblPrefix = OW_DB_PREFIX; $queryList = array(); $queryList[] = "ALTER TABLE `{$tblPrefix}base_theme_image`\n ADD `dimensions` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,\n ADD `filesize` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;"; foreach ($queryList as $query) { try { $db->query($query); } catch (Exception $e) { $logger->addEntry(json_encode($e)); } } $themeService = BOL_ThemeService::getInstance(); $images = $themeService->findAllCssImages(); foreach ($images as $image) { try { $path = $themeService->getUserfileImagesDir() . $image->getFilename(); if ($storage->fileExists($path)) { if (get_class($storage) == 'UPDATE_AmazonCloudStorage') { $tempPath = tempnam($themeService->getUserfileImagesDir(), 'themeTmpImage'); $info = $storage->copyFileToLocalFS($path, $tempPath); $dimensions = getimagesize($tempPath); $filesize = UTIL_File::getFileSize($tempPath); unlink($tempPath); } else { $dimensions = getimagesize($path); $filesize = UTIL_File::getFileSize($path); }
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; }
/** * 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(); }
private function importTheme($importDir) { $theme = new BOL_Theme(); $theme->name = $this->configs['currentTheme']['name']; $theme->customCss = $this->configs['currentTheme']['customCss']; $theme->customCssFileName = $this->configs['currentTheme']['customCssFileName']; $theme->description = $this->configs['currentTheme']['description']; $theme->sidebarPosition = $this->configs['currentTheme']['sidebarPosition']; $theme->title = $this->configs['currentTheme']['title']; if (!defined('OW_PLUGIN_XP')) { OW::getStorage()->copyDir($importDir . $theme->name . DS, BOL_ThemeService::getInstance()->getRootDir($theme->name)); } OW::getStorage()->copyDir($importDir . 'themes' . DS, OW_DIR_THEME_USERFILES); BOL_ThemeService::getInstance()->processAllThemes(); $oldTheme = BOL_ThemeService::getInstance()->findThemeByName($theme->name); $theme->id = $oldTheme->id; BOL_ThemeService::getInstance()->saveTheme($theme); $controlValues = array(); $url_pattern = '/http:\\/\\/[^\\s]+\\/([\\w\\.]+)/i'; foreach ($this->configs['controlValue'] as $key => $controlValue) { $value = $controlValue; if (preg_match($url_pattern, $controlValue, $matches)) { $imgFile = BOL_ThemeService::getInstance()->getUserfileImagesDir() . $matches[1]; if (!empty($matches[1]) && file_exists($imgFile) && is_file($imgFile)) { $value = 'url(' . BOL_ThemeService::getInstance()->getUserfileImagesUrl() . $matches[1] . ')'; } } $controlValues[$key] = $value; } BOL_ThemeService::getInstance()->importThemeControls($theme->id, $controlValues); BOL_ThemeService::getInstance()->processAllThemes(); }