1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19: class XoopsSystemCpanel
20: {
21: 22: 23:
24: public $gui;
25:
26: 27: 28: 29:
30: public function __construct()
31: {
32: $cpanel = xoops_getConfigOption('cpanel');
33: $this->loadGui($cpanel);
34: }
35:
36: 37: 38: 39: 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: 54: 55: 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: 82: 83: 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: 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: