Minahito
minah****@users*****
2006年 1月 14日 (土) 14:27:12 JST
Index: xoops2jp/html/modules/legacyRender/admin/actions/DefaultAction.class.php diff -u xoops2jp/html/modules/legacyRender/admin/actions/DefaultAction.class.php:1.1.2.2 xoops2jp/html/modules/legacyRender/admin/actions/DefaultAction.class.php:1.1.2.3 --- xoops2jp/html/modules/legacyRender/admin/actions/DefaultAction.class.php:1.1.2.2 Sat Jan 14 02:29:28 2006 +++ xoops2jp/html/modules/legacyRender/admin/actions/DefaultAction.class.php Sat Jan 14 14:27:12 2006 @@ -1,6 +1,7 @@ <?php -require_once XOOPS_ROOT_PATH."/modules/legacyRender/admin/class/LegacyTheme.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/class/LegacyTheme.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/ThemeSelectForm.class.php"; /** * This action shows the list of selectable themes to user. @@ -8,77 +9,76 @@ class LegacyRender_DefaultAction extends LegacyRender_Action { var $mConfig; - var $mThemes; + var $mObject = null; + var $mObjectHandler = null; + var $mActionForm=null; + + function _setupObject(&$controller) + { + if ($this->mThemes == null) { + $this->mObjectHandler =& xoops_getmodulehandler('theme'); + $this->mObjectHandler->updateThemeList(); + + $this->mThemes =& $this->mObjectHandler->getObjects(); + } + } + + function _setupActionForm() + { + if ($this->mActionForm == null) { + $this->mActionForm = new ThemeSelectForm(); + $this->mActionForm->prepare(); + } + } function getDefaultView(&$controller, &$xoopsUser) { - $themeHandler =& new LegacyThemeHandler(); - $themes =& $themeHandler->enumAll(); + $this->setupActionForm(); + $this->loadThemes(); - $handler =& xoops_getmodulehandler('theme'); - foreach ($themes as $theme) { - $theme_obj =& $handler->getByName($theme->mDirName); - - if ($theme_obj->isNew()) { - $theme_obj->set('name', $theme->mDirName); - $handler->insert($theme_obj, true); - } - - $theme_obj->loadPackage(); - - if ($theme_obj->isActiveResource()) { - $this->mThemes[] =& $theme_obj; - } - - unset($theme_obj); - } + $this->mActionForm->load($this->mThemes); return LEGACYRENDER_FRAME_VIEW_INDEX; } function execute(&$controller, &$xoopsUser) { - $configHandler =& xoops_gethandler('config'); + $this->setupActionForm(); + $this->loadThemes(); - $criteria =& new CriteriaCompo(); - $criteria->add(new Criteria('conf_name', 'theme_set')); - $criteria->add(new Criteria('conf_catid', XOOPS_CONF)); - - $configs =& $configHandler->getConfigs($criteria); + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + $this->mActionForm->update($this->mThemes); + + if ($this->mActionForm->hasError()) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + // - // selected + // save // - $handler =& xoops_getmodulehandler('theme'); - $themes =& $handler->getObjects(); - foreach ($themes as $theme) { - if (isset($_POST['select'][$theme->get('name')])) { - $theme->set('enable_select', 1); - } - else { - $theme->set('enable_select', 0); - } - $handler->insert($theme); - } - - if (isset($_POST['select']) && is_array($_POST['select'])) { - foreach ($_POST['select'] as $theme_name => $dummy) { - $theme =& $handler->get($theme_name); - - } + foreach ($this->mThemes as $theme) { + $this->mObjectHandler->insert($theme); } + // - // fetch selected theme + // save selected theme. // - if (isset($_POST['choose']) && is_array($_POST['choose'])) { - foreach ($_POST['choose'] as $theme_name => $dummy) { - $configs[0]->setVar('conf_value', $theme_name); - if ($configHandler->insertConfig($configs[0])) { - $controller->mRoot->setThemeName($theme_name); - break; - } - } + + $configHandler =& xoops_gethandler('config'); + + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('conf_name', 'theme_set')); + $criteria->add(new Criteria('conf_catid', XOOPS_CONF)); + + $configs =& $configHandler->getConfigs($criteria); + + $configs[0]->setVar('conf_value', $theme_name); + if ($configHandler->insertConfig($configs[0])) { + $controller->mRoot->setThemeName($this->mActionForm->getChooseTheme()); + break; } return $this->getDefaultView($controller, $xoopsUser); @@ -86,8 +86,13 @@ function executeViewIndex(&$controller, &$xoopsUser, &$render) { + foreach (array_keys($this->mThemes) as $name) { + $this->mThemes[$name]->loadPackage(); + } + $render->setTemplateName("theme_list.html"); $render->setAttribute("themes", $this->mThemes); + $render->setAttribute("actionForm", $this->mActionForm); $render->setAttribute("currentThemeName", $controller->mRoot->getThemeName()); } }