XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
BlockInstallListAction.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_MODULE_PATH . '/legacy/class/AbstractListAction.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/admin/forms/BlockInstallFilterForm.class.php';
18
20{
21
22 public $mpageArr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 0];
23
24 public function &_getHandler()
25 {
26 $handler =& xoops_getmodulehandler('newblocks');
27 return $handler;
28 }
29
30 public function &_getPageNavi()
31 {
32 $navi =new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE);
33
34 $root =& XCube_Root::getSingleton();
35 $perpage = $root->mContext->mRequest->getRequest($navi->mPrefix.'perpage');
36
37 if (isset($perpage) && 0 == (int)$perpage) {
38 $navi->setPerpage(0);
39 }
40 return $navi;
41 }
42
43 public function &_getFilterForm()
44 {
45 $filter =new Legacy_BlockInstallFilterForm($this->_getPageNavi(), $this->_getHandler());
46 return $filter;
47 }
48
49 public function _getBaseUrl()
50 {
51 return './index.php?action=BlockInstallList';
52 }
53
54 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
55 {
56 $render->setTemplateName('blockinstall_list.html');
57
58 //
59 // Lazy load
60 //
61 foreach (array_keys($this->mObjects) as $key) {
62 $this->mObjects[$key]->loadModule();
63 }
64
65 $mods = [];
66
67 foreach ($mods as $mod) {
68
69 $rtn = [];
70 $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
71 if ($sadmin && ($mod->getVar('hasnotification') || is_array($mod->getInfo('config')) || is_array($mod->getInfo('comments')))) {
72 $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
73 $rtn['title'] = htmlspecialchars($mod->name(), ENT_QUOTES);
74 $rtn['absolute'] = 1;
75 $rtn['icon'] = XOOPS_ADMINTHEME_URL . '/icons/prefs_small.png'; // TODO
76 $menu[] = $rtn;
77 }
78 }
79 $render->setAttribute('objects', $this->mObjects);
80 $render->setAttribute('pageNavi', $this->mFilter->mNavi);
81 $moduleHandler =& xoops_gethandler('module');
82 $modules =& $moduleHandler->getObjects(new Criteria('isactive', 1));
83 $render->setAttribute('modules', $modules);
84 $render->setAttribute('filterForm', $this->mFilter);
85 $render->setAttribute('pageArr', $this->mpageArr);
86
87 $block_handler =& $this->_getHandler();
88 $block_total = $block_handler->getCount();
89 $inactive_block_total = $block_handler->getCount(new Criteria('isactive', 0));
90 $active_block_total = $block_total-$inactive_block_total;
91 $render->setAttribute('BlockTotal', $block_total);
92 $render->setAttribute('ActiveBlockTotal', $active_block_total);
93 $render->setAttribute('InactiveBlockTotal', $inactive_block_total);
94
95 $active_installed_criteria = new CriteriaCompo(new Criteria('visible', 1));
96 $active_installed_criteria->add(new Criteria('isactive', 1));
97 $active_installed_block_total = $block_handler->getCount($active_installed_criteria);
98 $render->setAttribute('ActiveInstalledBlockTotal', $active_installed_block_total);
99 $render->setAttribute('ActiveUninstalledBlockTotal', $active_block_total - $active_installed_block_total);
100
101 $inactive_installed_criteria = new CriteriaCompo(new Criteria('visible', 1));
102 $inactive_installed_criteria->add(new Criteria('isactive', 0));
103 $inactive_installed_block_total = $block_handler->getCount($inactive_installed_criteria);
104 $render->setAttribute('InactiveInstalledBlockTotal', $inactive_installed_block_total);
105 $render->setAttribute('InactiveUninstalledBlockTotal', $inactive_block_total - $inactive_installed_block_total);
106 }
107}