XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
AdminDashboard.class.php
1<?php
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
22
23
29if (!defined('XC_ADMINDASHBOARD_INFO')) {
30 define('XC_ADMINDASHBOARD_INFO', 1);
31}
32
41
42// Smarty : <{$xoops_lblocks.action_search.content}>
43if (!defined('XC_ADMIN_BLOCK_ACTIONSEARCH')) {
44 define('XC_ADMIN_BLOCK_ACTIONSEARCH', 0);
45}
46// Smarty : <{$xoops_lblocks.block_comments.content}>
47if (!defined('XC_ADMIN_BLOCK_COMMENTS')) {
48 define('XC_ADMIN_BLOCK_COMMENTS', 0);
49}
50// Smarty : <{$xoops_lblocks.block_loginfo.content}>
51if(!defined('XC_ADMIN_BLOCK_LOGINFO')) {
52 define('XC_ADMIN_BLOCK_LOGINFO', 1);
53}
54// Smarty : <{$xoops_lblocks.block_menu.content}>
55if (!defined('XC_ADMIN_BLOCK_MENU')) {
56 define('XC_ADMIN_BLOCK_MENU', 1);
57}
58// Smarty : <{$xoops_lblocks.block_online.content}>
59if (!defined('XC_ADMIN_BLOCK_ONLINE')) {
60 define('XC_ADMIN_BLOCK_ONLINE', 1);
61}
62// Smarty : <{$xoops_lblocks.block_online.content}>
63if (!defined('XC_ADMIN_BLOCK_OVERVIEW')) {
64 define('XC_ADMIN_BLOCK_OVERVIEW', 1);
65}
66// Smarty : <{$xoops_lblocks.block_php.content}>
67if (!defined('XC_ADMIN_BLOCK_PHP')) {
68 define('XC_ADMIN_BLOCK_PHP', 1);
69}
70// Smarty : <{$xoops_lblocks.block_server.content}>
71if (!defined('XC_ADMIN_BLOCK_SERVER')) {
72 define('XC_ADMIN_BLOCK_SERVER', 1);
73}
74// Smarty : <{$xoops_lblocks.block_waiting.content}>
75if (!defined('XC_ADMIN_BLOCK_WAITING')) {
76 define('XC_ADMIN_BLOCK_WAITING', 0);
77}
88if (!defined('XC_ADMINDASHBOARD_PHPINFO')) {
89 define('XC_ADMINDASHBOARD_PHPINFO', 0);
90}
91
92
94{
95 public function preBlockFilter()
96 {
97
98 $root=&XCube_Root::getSingleton();
99
100 // XCUBE_DELEGATE_PRIORITY_2
101 // XCUBE_DELEGATE_PRIORITY_NORMAL+1
102 $root->mDelegateManager->add("Legacypage.Admin.SystemCheck", "Legacy_AdminDashboard::AdminDashboardSystem", XCUBE_DELEGATE_PRIORITY_1);
103
109 if ($root->mController->_mStrategy && get_class($root->mController->_mStrategy) === 'Legacy_AdminControllerStrategy') {
110 //$this->mController->_mStrategy->mSetupBlock->add( [$this, 'AdminSetupBlock'], XCUBE_DELEGATE_PRIORITY_NORMAL );
111 $this->mController->_mStrategy->mSetupBlock->add( [$this, 'AdminSetupBlock'] );
112 }
113
114 }
115
116
117 public static function AdminDashboardSystem()
118 {
119
120 $root =& XCube_Root::getSingleton();
121
122 if(XC_ADMINDASHBOARD_INFO) {
123 /*
124 * Select the Layout Display Option
125 * 0 - output is direct
126 * 1 - output with template "legacy_dummy.html"
127 * 2 - output with template "dashboard.html"
128 */
129 $uitype = 2;
130
131 // 0 -Customize the dashboard of html/admin.php
132 if ( $uitype == 0 ) {
133 $uiadmin = '<b>Welcome to XOOPSCube Admin!</b><br>Have a nice time!';
134 echo $uiadmin;
135 }
136
137 // 1 - Customize the dashboard of html/admin.php with template "legacy_dummy.html"
138 elseif ( $uitype == 1 ) {
139 $uiadminhtml = '<b>Welcome to XOOPSCube !</b>
140 <br>Have a nice and happy time!
141 <br><b>Output with template "legacy_dummy.html"</b>!';
142 $attributes = [];
143 $attributes['dummy_content'] = $uiadminhtml;
144 $template = XOOPS_LEGACY_PATH. '/templates/legacy_dummy.html';
145 self::display_message( false, $attributes, $template );
146 }
147
148 // 2 - Customize the dashboard with template "dashboard.html"
149 elseif ( $uitype == 2 ) {
150
151 if ( file_exists(XOOPS_LEGACY_PATH . '/admin/templates/dashboard.html') ) {
152
153 $title1 = 'XCL Documentation';
154 $content1= 'XCL provides out-of-the-box a search function to find admin features.'
155 . 'And documentation is available from menu Help for each module.';
160 $attributes = [];
161 $attributes['title'] = $title1;
162 $attributes['content'] = $content1;
163
164 $template = XOOPS_LEGACY_PATH. '/admin/templates/dashboard.html';
165
166 self::display_message(false, $attributes, $template, );
167
168 }
169 }
170
171 }
172
173
174 /*
175 * Admin Dashboard PHP Information
176 */
177 if (XC_ADMINDASHBOARD_PHPINFO) {
178
179 ob_start();
180 phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
181 $phpinfo = ob_get_clean();
182
183 preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
184 $output = preg_replace('#<table#', '<table class="outer""', $output[1][0]);
185 $output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
186 $output = preg_replace('#<h2([^>]*)>(.*)</h2>#m','<h3$1>$2</h3>', $output);
187 $output = preg_replace('#<h1([^>]*)>(.*)</h1>#m','<h2$1>$2</h2>', $output);
188 $output = preg_replace('#border="0" width="600"#', '', $output);
189 $output = preg_replace('#<hr>#', '', $output);
190 $output = preg_replace('#class="e"#', 'class="even"', $output);
191 $output = preg_replace('#class="h"#', 'class="odd"', $output);
192 $output = preg_replace('#class="v"#', 'class="even"', $output);
193 $output = preg_replace('#class="p"#', 'class="odd"', $output);
194 $output = str_replace(['<div class="center">', '</div>'], '', $output);
195
196 $attributes = [];
197 $attributes['dummy_content'] = $output;
198
199 $template = XOOPS_LEGACY_PATH. '/templates/legacy_dummy.html';
200
201 self::display_message(false,$attributes, $template, );
202 }
203
204 }
205
206 // If you want to add any new block, please customize this function !
207 // Refer to legacy/admin/blocks!
208 public function AdminSetupBlock() {
209
210 if ( XC_ADMIN_BLOCK_ACTIONSEARCH) {
211 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminActionSearch.class.php';
212 $this->mController->_mBlockChain[] = new Legacy_AdminActionSearch();
213 }
214
215 if (XC_ADMIN_BLOCK_COMMENTS) {
216 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockComments.class.php';
217 $this->mController->_mBlockChain[] = new Legacy_AdminBlockComments();
218 }
219
220 if(XC_ADMIN_BLOCK_LOGINFO && file_exists(XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockLogInfo.class.php')) {
221 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockLogInfo.class.php';
222 $this->mController->_mBlockChain[] = new Legacy_AdminBlockLogInfo();
223 }
224
225 if (XC_ADMIN_BLOCK_MENU && file_exists(XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockMenu.class.php')) {
226 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockMenu.class.php';
227 $this->mController->_mBlockChain[] = new Legacy_AdminBlockMenu();
228 }
229
230 if (XC_ADMIN_BLOCK_ONLINE && file_exists(XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockOnline.class.php')) {
231 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockOnline.class.php';
232 $this->mController->_mBlockChain[] = new Legacy_AdminBlockOnline();
233 }
234 if (XC_ADMIN_BLOCK_OVERVIEW) {
235 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockOverview.class.php';
236 $this->mController->_mBlockChain[] = new Legacy_AdminBlockOverview();
237 }
238 if (XC_ADMIN_BLOCK_PHP) {
239 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockPhp.class.php';
240 $this->mController->_mBlockChain[] = new Legacy_AdminBlockPhp();
241 }
242
243 if (XC_ADMIN_BLOCK_SERVER) {
244 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockServer.class.php';
245 $this->mController->_mBlockChain[] = new Legacy_AdminBlockServer();
246 }
247
248 if (XC_ADMIN_BLOCK_WAITING) {
249 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminBlockWaiting.class.php';
250 $this->mController->_mBlockChain[] = new Legacy_AdminBlockWaiting();
251 }
252
253 //Block admin-theme changer
254/* if(XC_ADMINBLOCK_ADMINTHEME && file_exists(XOOPS_LEGACY_PATH . '/admin/blocks/AdminThemeSelect.class.php') && file_exists(XOOPS_LEGACY_PATH . '/admin/preload/AdminThemeSelectPreload.class.php')) {
255 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminThemeSelect.class.php';
256 $this->mController->_mBlockChain[] = new Legacy_AdminThemeSelect();
257 }*/
258
259 // Add your custom block here!
260
261 }
262
263
271 public static function display_message( bool $return, array $attributes = [], string $template= '')
272 {
273 $root =& XCube_Root::getSingleton();
274
275 $renderSystem =& $root->getRenderSystem($root->mContext->mBaseRenderSystemName);
276
277 //$renderSystem =& $root->getRenderSystemName($root->mContext->mBaseRenderSystemName);
278
279 // Module's templates
280 $renderTarget =& $renderSystem->createRenderTarget('main');
281
282 // Module's templates blocks
283 //$renderTarget =& $renderSystem->createRenderTarget(LEGACY_RENDER_TARGET_TYPE_BLOCK);
284
285 // Module
286 $renderTarget->setAttribute('legacy_module', 'legacy');
287
288 $renderTarget->setTemplateName($template);
289
290 foreach (array_keys($attributes) as $attribute) {
291 $renderTarget->setAttribute($attribute, $attributes[$attribute]);
292 }
293
294 $renderSystem->render($renderTarget);
295 if ($return == true) {
296 return $renderTarget->getResult();
297 }
298
299 print $renderTarget->getResult();
300 }
301
308 private static function getTemplate($file, $prefix = null)
309 {
310 $infoArr = Legacy_get_override_file($file, $prefix);
311 if ($prefix) {
312 $file = $prefix . $file;
313 }
314
315 if ($infoArr['theme'] !== null && $infoArr['dirname'] !== null) {
316 //return XOOPS_THEME_PATH . '/' . $infoArr['theme'] . '/modules/' . $infoArr['dirname'] . '/' . $file;
317 // themes / [theme-name] / templates / [module-name] / [file] .html
318 return XOOPS_THEME_PATH . '/' . $infoArr['theme'] . '/templates/' . $infoArr['dirname'] . '/' . $file;
319
320 }
321
322 if ($infoArr['theme'] !== null) {
323 return XOOPS_THEME_PATH . '/' . $infoArr['theme'] . '/' . $file;
324 }
325
326// if ($infoArr['dirname'] !== null) {
327// return XOOPS_MODULE_PATH . '/' . $infoArr['dirname'] . '/templates/blocks/' . $file;
328// }
329
330 if ($infoArr['dirname'] !== null) {
331 return XOOPS_MODULE_PATH . '/' . $infoArr['dirname'] . '/admin/templates/' . $file;
332 }
333
334 return LEGACY_ADMIN_RENDER_FALLBACK_PATH . '/' . $file;
335 }
336}
337
338
preBlockFilter()
[Abstract] Executes the logic, when the controller executes preBlockFilter().
static display_message(bool $return, array $attributes=[], string $template='')