34 public $mThemes =
null;
35 public $mObjectHandler =
null;
36 public $mActionForm =
null;
37 public $mMainTheme =
null;
39 public function prepare(&$controller, &$xoopsUser)
41 $this->_setupObject();
42 $this->_setupActionForm();
44 $handler =& xoops_gethandler(
'config');
47 $criteria->add(
new Criteria(
'conf_name',
'theme_set'));
48 $criteria->add(
new Criteria(
'conf_catid', XOOPS_CONF));
50 $configs =& $handler->getConfigs($criteria);
51 $this->mMainTheme = $configs[0]->get(
'conf_value');
54 public function _setupObject()
56 $handler =& xoops_getmodulehandler(
'theme');
57 $this->mThemes =& $handler->getObjects();
60 public function _setupActionForm()
63 $this->mActionForm->prepare();
66 public function getDefaultView(&$controller, &$xoopsUser)
68 $configHandler =& xoops_gethandler(
'config');
71 $criteria->add(
new Criteria(
'conf_name',
'theme_set_allowed'));
72 $criteria->add(
new Criteria(
'conf_catid', XOOPS_CONF));
74 $configs =& $configHandler->getConfigs($criteria);
75 $selectedThemeArr = unserialize($configs[0]->
get(
'conf_value'));
77 $this->mActionForm->load($selectedThemeArr);
79 return LEGACY_FRAME_VIEW_INDEX;
82 public function execute(&$controller, &$xoopsUser)
84 $this->mActionForm->fetch();
85 $this->mActionForm->validate();
87 if ($this->mActionForm->hasError()) {
88 return $this->getDefaultView($controller, $xoopsUser);
94 $configHandler =& xoops_gethandler(
'config');
97 $criteria->add(
new Criteria(
'conf_name',
'theme_set_allowed'));
98 $criteria->add(
new Criteria(
'conf_catid', XOOPS_CONF));
100 $configs =& $configHandler->getConfigs($criteria);
101 $t_themeArr = $this->mActionForm->getSelectableTheme();
102 $configs[0]->set(
'conf_value', serialize($t_themeArr));
103 if (!$configHandler->insertConfig($configs[0])) {
110 $themeName = $this->mActionForm->getChooseTheme();
112 if (
null !== $themeName) {
114 $criteria->add(
new Criteria(
'conf_name',
'theme_set'));
115 $criteria->add(
new Criteria(
'conf_catid', XOOPS_CONF));
117 $configs =& $configHandler->getConfigs($criteria);
119 $configs[0]->set(
'conf_value', $themeName);
120 if ($configHandler->insertConfig($configs[0])) {
121 $controller->mRoot->mContext->setThemeName($themeName);
122 $this->mMainTheme = $themeName;
126 XCube_DelegateUtils::call(
'Legacy.Event.ThemeSettingChanged', $this->mMainTheme, $t_themeArr);
128 return $this->getDefaultView($controller, $xoopsUser);
131 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
133 $render->setTemplateName(
'theme_list.html');
134 $render->setAttribute(
'themes', $this->mThemes);
135 $render->setAttribute(
'actionForm', $this->mActionForm);
136 $render->setAttribute(
'currentThemeName', $this->mMainTheme);