コード例 #1
0
ファイル: themes.php プロジェクト: vazahat/dudex
 public function chooseTheme()
 {
     $this->themeService->updateThemeList();
     $this->themeService->updateThemesInfo();
     $themes = $this->themeService->findAllThemes();
     $themesInfo = array();
     $activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getName();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesInfo[$theme->getName()] = (array) json_decode($theme->getDescription());
         $themesInfo[$theme->getName()]['key'] = $theme->getName();
         $themesInfo[$theme->getName()]['title'] = $theme->getTitle();
         $themesInfo[$theme->getName()]['iconUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::ICON_FILE;
         $themesInfo[$theme->getName()]['previewUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::PREVIEW_FILE;
         $themesInfo[$theme->getName()]['active'] = $theme->getName() === $activeTheme;
         $themesInfo[$theme->getName()]['changeUrl'] = OW::getRouter()->urlFor(__CLASS__, 'changeTheme', array('theme' => $theme->getName()));
         $themesInfo[$theme->getName()]['update_url'] = (int) $theme->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Themes', 'updateRequest', array('name' => $theme->getName())) : false;
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('admin')->getStaticJsUrl() . 'theme_select.js');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.sticky.js');
     OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ");\n        \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n    \t\t\twindow.location.href = '" . $themesInfo[$activeTheme]['changeUrl'] . "';\n    \t\t});\n            \$('.selected_theme_info_stick').sticky({topSpacing:60});\n            ");
     $adminTheme = OW::getThemeManager()->getThemeService()->getThemeObjectByName('origin');
     $defaultThemeImgUrl = $adminTheme === null ? '' : $adminTheme->getStaticImagesUrl();
     $this->assign('themeInfo', $themesInfo[$activeTheme]);
     $this->assign('themes', $themesInfo);
     $this->assign('defaultThemeImgDir', $defaultThemeImgUrl);
 }
コード例 #2
0
ファイル: themes.php プロジェクト: hardikamutech/loov
 public function chooseTheme()
 {
     $language = OW::getLanguage();
     $this->themeService->updateThemeList();
     $this->themeService->updateThemesInfo();
     $themes = $this->themeService->findAllThemes();
     $themesInfo = array();
     $activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getName();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesInfo[$theme->getName()] = (array) json_decode($theme->getDescription());
         $themesInfo[$theme->getName()]['key'] = $theme->getName();
         $themesInfo[$theme->getName()]['title'] = $theme->getTitle();
         $themesInfo[$theme->getName()]['iconUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::ICON_FILE;
         $themesInfo[$theme->getName()]['previewUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::PREVIEW_FILE;
         $themesInfo[$theme->getName()]['active'] = $theme->getName() === $activeTheme;
         $themesInfo[$theme->getName()]['changeUrl'] = OW::getRouter()->urlFor(__CLASS__, 'changeTheme', array('theme' => $theme->getName()));
         $themesInfo[$theme->getName()]['update_url'] = (int) $theme->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Themes', 'updateRequest', array('name' => $theme->getName())) : false;
         if (!in_array($theme->getName(), array(BOL_ThemeService::DEFAULT_THEME, $activeTheme))) {
             $themesInfo[$theme->getName()]['delete_url'] = OW::getRouter()->urlFor(__CLASS__, 'deleteTheme', array('name' => $theme->getName()));
         }
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('admin')->getStaticJsUrl() . 'theme_select.js');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.sticky.js');
     $addData = array('deleteConfirmMsg' => $language->text('admin', 'themes_choose_delete_confirm_msg'), 'deleteActiveThemeMsg' => $language->text('admin', 'themes_cant_delete_active_theme'));
     OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ", " . json_encode($addData) . ");\n        \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n    \t\t\twindow.location.href = '" . $themesInfo[$activeTheme]['changeUrl'] . "';\n    \t\t});\n            \$('.selected_theme_info_stick').sticky({topSpacing:60});\n            \$('.admin_themes_select a.theme_icon').click( function(){ \$('.theme_info .theme_control_button').hide(); });");
     $adminTheme = OW::getThemeManager()->getThemeService()->getThemeObjectByName(BOL_ThemeService::DEFAULT_THEME);
     $defaultThemeImgUrl = $adminTheme === null ? "" : $adminTheme->getStaticImagesUrl();
     $this->assign("adminThemes", array(BOL_ThemeService::DEFAULT_THEME => $themesInfo[BOL_ThemeService::DEFAULT_THEME]));
     $this->assign('themeInfo', $themesInfo[$activeTheme]);
     $event = new OW_Event("admin.filter_themes_to_choose", array(), $themesInfo);
     OW::getEventManager()->trigger($event);
     $this->assign('themes', $event->getData());
     $this->assign('defaultThemeImgDir', $defaultThemeImgUrl);
 }
コード例 #3
0
ファイル: themes.php プロジェクト: vBulleteen/oxwall
 public function chooseTheme()
 {
     $language = OW::getLanguage();
     $this->themeService->updateThemeList();
     $this->themeService->updateThemesInfo();
     $themes = $this->themeService->findAllThemes();
     $themesInfo = array();
     $activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getName();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesInfo[$theme->getName()] = (array) json_decode($theme->getDescription());
         $themesInfo[$theme->getName()]['key'] = $theme->getName();
         $themesInfo[$theme->getName()]['title'] = $theme->getTitle();
         $themesInfo[$theme->getName()]['iconUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::ICON_FILE;
         $themesInfo[$theme->getName()]['previewUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::PREVIEW_FILE;
         $themesInfo[$theme->getName()]['active'] = $theme->getName() === $activeTheme;
         $themesInfo[$theme->getName()]['changeUrl'] = OW::getRouter()->urlFor(__CLASS__, 'changeTheme', array('theme' => $theme->getName()));
         $themesInfo[$theme->getName()]['update_url'] = (int) $theme->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Themes', 'updateRequest', array('name' => $theme->getName())) : false;
         if (!in_array($theme->getName(), array(BOL_ThemeService::DEFAULT_THEME, $activeTheme))) {
             $themesInfo[$theme->getName()]['delete_url'] = OW::getRouter()->urlFor(__CLASS__, 'deleteTheme', array('name' => $theme->getName()));
         }
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('admin')->getStaticJsUrl() . 'theme_select.js');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.sticky.js');
     $addData = array('deleteConfirmMsg' => $language->text('admin', 'themes_choose_delete_confirm_msg'), 'deleteActiveThemeMsg' => $language->text('admin', 'themes_cant_delete_active_theme'));
     OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ", " . json_encode($addData) . ");\n        \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n    \t\t\twindow.location.href = '" . $themesInfo[$activeTheme]['changeUrl'] . "';\n    \t\t});\n            \$('.selected_theme_info_stick').sticky({topSpacing:60});\n            \$('.admin_themes_select a.theme_icon').click( function(){ \$('.theme_info .theme_control_button').hide(); });");
     $this->assign("adminThemes", array(BOL_ThemeService::DEFAULT_THEME => $themesInfo[BOL_ThemeService::DEFAULT_THEME]));
     $this->assign('themeInfo', $themesInfo[$activeTheme]);
     $event = new OW_Event("admin.filter_themes_to_choose", array(), $themesInfo);
     OW::getEventManager()->trigger($event);
     $this->assign('themes', $event->getData());
     // add theme
     $form = new Form('theme-add');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField('file');
     $form->addElement($file);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'plugins_manage_add_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $uploadMaxFilesize = (double) ini_get("upload_max_filesize");
             $postMaxSize = (double) ini_get("post_max_size");
             $serverLimit = $uploadMaxFilesize < $postMaxSize ? $uploadMaxFilesize : $postMaxSize;
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK && $_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE || (empty($_FILES['file']) || $_FILES['file']['size'] > $serverLimit * 1024 * 1024)) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_size_error_message', array('limit' => $serverLimit)));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {
                 switch ($_FILES['file']['error']) {
                     case UPLOAD_ERR_INI_SIZE:
                         $error = $language->text('base', 'upload_file_max_upload_filesize_error');
                         break;
                     case UPLOAD_ERR_PARTIAL:
                         $error = $language->text('base', 'upload_file_file_partially_uploaded_error');
                         break;
                     case UPLOAD_ERR_NO_FILE:
                         $error = $language->text('base', 'upload_file_no_file_error');
                         break;
                     case UPLOAD_ERR_NO_TMP_DIR:
                         $error = $language->text('base', 'upload_file_no_tmp_dir_error');
                         break;
                     case UPLOAD_ERR_CANT_WRITE:
                         $error = $language->text('base', 'upload_file_cant_write_file_error');
                         break;
                     case UPLOAD_ERR_EXTENSION:
                         $error = $language->text('base', 'upload_file_invalid_extention_error');
                         break;
                     default:
                         $error = $language->text('base', 'upload_file_fail');
                 }
                 OW::getFeedback()->error($error);
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
                 OW::getFeedback()->error($language->text('admin', 'manage_themes_add_empty_field_error_message'));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             $tempFile = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . '.zip';
             $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . DS;
             copy($_FILES['file']['tmp_name'], $tempFile);
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($tempDir);
                 $zip->close();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_theme_add_extract_error'));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, 'processAdd'), array('dir' => urlencode($tempDir))));
         }
     }
 }