1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: 14: 15: 16: 17: 18:
19: class Legacy_ThemeSelect extends XCube_ActionFilter
20: {
21: 22: 23:
24: var $mIsSelectableTheme = null;
25:
26: function Legacy_ThemeSelect(&$controller)
27: {
28:
29:
30:
31: parent::XCube_ActionFilter($controller);
32: $this->mIsSelectableTheme =new XCube_Delegate();
33: $this->mIsSelectableTheme->register('Legacy_ThemeSelect.IsSelectableTheme');
34:
35: $controller->mSetupUser->add(array(&$this, 'doChangeTheme'));
36: }
37:
38: function preBlockFilter()
39: {
40: $this->mController->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array(&$this, "callbackCheckLoginSuccess"));
41: }
42:
43: 44: 45: 46: 47: 48:
49: function doChangeTheme(&$principal, &$controller, &$context)
50: {
51: if (!empty($_POST['xoops_theme_select'])) {
52: $xoops_theme_select = explode('!-!', $_POST['xoops_theme_select']);
53: if ($this->_isSelectableTheme($xoops_theme_select[0])) {
54: $this->mRoot->mContext->setThemeName($xoops_theme_select[0]);
55: $_SESSION['xoopsUserTheme'] = $xoops_theme_select[0];
56: $controller->executeForward($GLOBALS['xoopsRequestUri']);
57: }
58: } elseif (!empty($_SESSION['xoopsUserTheme']) && $this->_isSelectableTheme($_SESSION['xoopsUserTheme'])) {
59: $this->mRoot->mContext->setThemeName($_SESSION['xoopsUserTheme']);
60: }
61: }
62:
63: function callbackCheckLoginSuccess(&$xoopsUser)
64: {
65:
66:
67:
68: $userTheme = $xoopsUser->get('theme');
69: if (in_array($userTheme, $this->mRoot->mContext->getXoopsConfig('theme_set_allowed'))) {
70: $_SESSION['xoopsUserTheme'] = $userTheme;
71: $this->mRoot->mContext->setThemeName($userTheme);
72: }
73: }
74:
75: function _isSelectableTheme($theme_name)
76: {
77: return in_array($theme_name, $this->mRoot->mContext->getXoopsConfig('theme_set_allowed'));
78: }
79: }
80:
81: ?>
82: