1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_MODULE_PATH . "/legacy/admin/forms/ThemeSelectForm.class.php";
14:
15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30: class Legacy_ThemeListAction extends Legacy_Action
31: {
32: var $mThemes = null;
33: var $mObjectHandler = null;
34: var $mActionForm = null;
35: var $mMainTheme = null;
36:
37: function prepare(&$controller, &$xoopsUser)
38: {
39: $this->_setupObject();
40: $this->_setupActionForm();
41:
42: $handler =& xoops_gethandler('config');
43:
44: $criteria =new CriteriaCompo();
45: $criteria->add(new Criteria('conf_name', 'theme_set'));
46: $criteria->add(new Criteria('conf_catid', XOOPS_CONF));
47:
48: $configs =& $handler->getConfigs($criteria);
49: $this->mMainTheme = $configs[0]->get('conf_value');
50: }
51:
52: function _setupObject()
53: {
54: $handler =& xoops_getmodulehandler('theme');
55: $this->mThemes =& $handler->getObjects();
56: }
57:
58: function _setupActionForm()
59: {
60: $this->mActionForm =new Legacy_ThemeSelectForm();
61: $this->mActionForm->prepare();
62: }
63:
64: function getDefaultView(&$controller, &$xoopsUser)
65: {
66: $configHandler =& xoops_gethandler('config');
67:
68: $criteria =new CriteriaCompo();
69: $criteria->add(new Criteria('conf_name', 'theme_set_allowed'));
70: $criteria->add(new Criteria('conf_catid', XOOPS_CONF));
71:
72: $configs =& $configHandler->getConfigs($criteria);
73: $selectedThemeArr = unserialize($configs[0]->get('conf_value'));
74:
75: $this->mActionForm->load($selectedThemeArr);
76:
77: return LEGACY_FRAME_VIEW_INDEX;
78: }
79:
80: function execute(&$controller, &$xoopsUser)
81: {
82: $this->mActionForm->fetch();
83: $this->mActionForm->validate();
84:
85: if ($this->mActionForm->hasError()) {
86: return $this->getDefaultView($controller, $xoopsUser);
87: }
88:
89:
90:
91:
92: $configHandler =& xoops_gethandler('config');
93:
94: $criteria =new CriteriaCompo();
95: $criteria->add(new Criteria('conf_name', 'theme_set_allowed'));
96: $criteria->add(new Criteria('conf_catid', XOOPS_CONF));
97:
98: $configs =& $configHandler->getConfigs($criteria);
99: $t_themeArr = $this->mActionForm->getSelectableTheme();
100: $configs[0]->set('conf_value', serialize($t_themeArr));
101: if (!$configHandler->insertConfig($configs[0])) {
102: die();
103: }
104:
105:
106:
107:
108: $themeName = $this->mActionForm->getChooseTheme();
109:
110: if ($themeName != null) {
111: $criteria =new CriteriaCompo();
112: $criteria->add(new Criteria('conf_name', 'theme_set'));
113: $criteria->add(new Criteria('conf_catid', XOOPS_CONF));
114:
115: $configs =& $configHandler->getConfigs($criteria);
116:
117: $configs[0]->set('conf_value', $themeName);
118: if ($configHandler->insertConfig($configs[0])) {
119: $controller->mRoot->mContext->setThemeName($themeName);
120: $this->mMainTheme = $themeName;
121: }
122: }
123:
124: XCube_DelegateUtils::call('Legacy.Event.ThemeSettingChanged', $this->mMainTheme, $t_themeArr);
125:
126: return $this->getDefaultView($controller, $xoopsUser);
127: }
128:
129: function executeViewIndex(&$controller, &$xoopsUser, &$render)
130: {
131: $render->setTemplateName("theme_list.html");
132: $render->setAttribute("themes", $this->mThemes);
133: $render->setAttribute("actionForm", $this->mActionForm);
134: $render->setAttribute("currentThemeName", $this->mMainTheme);
135: }
136: }
137:
138: ?>
139: