1: <?php
2:
3: /**
4: * Xoops Cpanel class
5: *
6: * You may not change or alter any portion of this comment or credits
7: * of supporting developers from this source code or any supporting source code
8: * which is considered copyrighted (c) material of the original comment or credit authors.
9: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12: *
13: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
14: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
15: * @package system
16: * @subpackage class
17: * @author Taiwen Jiang <phppp@users.sourceforge.net>
18: */
19: class XoopsSystemCpanel
20: {
21: /**
22: * Reference to GUI object
23: */
24: public $gui;
25:
26: /**
27: * Constructer
28: *
29: */
30: public function __construct()
31: {
32: $cpanel = xoops_getConfigOption('cpanel');
33: $this->loadGui($cpanel);
34: }
35:
36: /**
37: * Get an instance of the class
38: *
39: * @return XoopsSystemCpanel
40: */
41: public static function getInstance()
42: {
43: static $instance;
44: if (!isset($instance)) {
45: $class = __CLASS__;
46: $instance = new $class();
47: }
48:
49: return $instance;
50: }
51:
52: /**
53: * Load the Xoops Admin Gui by preference
54: *
55: * @param string $gui
56: */
57: public function loadGui($gui)
58: {
59: if (!empty($gui)) {
60: $class = 'XoopsGui' . ucfirst($gui);
61: if (!class_exists($class)) {
62: include_once XOOPS_ADMINTHEME_PATH . '/' . $gui . '/' . $gui . '.php';
63: }
64: if (class_exists($class)) {
65: if (call_user_func(array($class, 'validate'))) {
66: $this->gui = new $class();
67: $this->gui->foldername = $gui;
68: }
69: }
70: }
71: if (!isset($this->gui)) {
72: if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/transition/transition.php')) {
73: include_once $file;
74: $this->gui = new XoopsGuiTransition();
75: $this->gui->foldername = 'transition';
76: }
77: }
78: }
79:
80: /**
81: * Get a list of Xoops Admin Gui
82: *
83: * @return mixed
84: */
85: public static function getGuis()
86: {
87: $guis = array();
88: xoops_load('XoopsLists');
89: $lists = XoopsLists::getDirListAsArray(XOOPS_ADMINTHEME_PATH);
90: foreach (array_keys($lists) as $gui) {
91: if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/' . $gui . '/' . $gui . '.php')) {
92: include_once $file;
93: if (class_exists($class = 'XoopsGui' . ucfirst($gui))) {
94: if (call_user_func(array($class, 'validate'))) {
95: $guis[$gui] = $gui;
96: }
97: }
98: }
99: }
100:
101: return $guis;
102: }
103:
104: /**
105: * Flush the Xoops Admin Gui
106: *
107: */
108: public static function flush()
109: {
110: $guis = XoopsSystemCpanel::getGuis();
111: foreach ($guis as $gui) {
112: if ($file = XOOPS_ADMINTHEME_PATH . '/' . $gui . '/' . $gui . '.php') {
113: include_once $file;
114: if (class_exists($class = 'XoopsGui' . ucfirst($gui))) {
115: call_user_func(array($class, 'flush'));
116: }
117: }
118: }
119: }
120: }
121: