Passed
Push — master ( 84b92c...f405db )
by Michael
13:24
created

hideButtons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php declare(strict_types=1);
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project (https://xoops.org)
14
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author       XOOPS Development Team
16
 */
17
18
use Xmf\Module\Admin;
19
use Xmf\Request;
20
use XoopsModules\Smartfaq\Common\TestdataButtons;
21
use XoopsModules\Smartfaq\Constants;
22
use XoopsModules\Smartfaq\Helper;
23
use XoopsModules\Smartfaq\Utility;
24
25
/** @var Admin $adminObject */
26
/** @var Helper $helper */
27
/** @var Utility $utility */
28
require_once __DIR__ . '/admin_header.php';
29
30
xoops_cp_header();
31
32
$adminObject = \Xmf\Module\Admin::getInstance();
33
34
//----------------------
35
36
// Creating the category handler object
37
/** @var \XoopsModules\Smartfaq\CategoryHandler $categoryHandler */
38
$categoryHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Category');
39
40
// Creating the FAQ handler object
41
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
42
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq');
43
44
// Total FAQs -- includes everything on the table
45
$totalfaqs = $faqHandler->getFaqsCount();
46
47
// Total categories
48
$totalcategories = $categoryHandler->getCategoriesCount(-1);
49
50
// Total FAQ count by status
51
$totalfaqbystatus = $faqHandler->getFaqsCountByStatus();
52
53
// Total asked FAQs
54
$totalasked = $totalfaqbystatus[Constants::SF_STATUS_ASKED] ?? 0;
55
56
// Total opened FAQs
57
$totalopened = $totalfaqbystatus[Constants::SF_STATUS_OPENED] ?? 0;
58
59
// Total answered FAQs
60
$totalanswered = $totalfaqbystatus[Constants::SF_STATUS_ANSWERED] ?? 0;
61
62
// Total submitted FAQs
63
$totalsubmitted = $totalfaqbystatus[Constants::SF_STATUS_SUBMITTED] ?? 0;
64
65
// Total published FAQs
66
$totalpublished = $totalfaqbystatus[Constants::SF_STATUS_PUBLISHED] ?? 0;
67
68
// Total offline FAQs
69
$totaloffline = $totalfaqbystatus[Constants::SF_STATUS_OFFLINE] ?? 0;
70
71
// Total rejected question
72
$totalrejectedquestion = $totalfaqbystatus[Constants::SF_STATUS_REJECTED_QUESTION] ?? 0;
73
74
// Total rejected smartfaq
75
$totalrejectedsmartfaq = $totalfaqbystatus[Constants::SF_STATUS_REJECTED_SMARTFAQ] ?? 0;
76
77
// Total Q&A with new answers
78
$totalnewanswers = $totalfaqbystatus[Constants::SF_STATUS_NEW_ANSWER] ?? 0;
79
80
//set info block
81
$adminObject->addInfoBox(_AM_SF_INVENTORY);
82
83
if ($totalcategories > 0) {
84
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="category.php">' . _AM_SF_TOTALCAT . '</a><b>' . '</infolabel>', $totalcategories), '', 'Green');
85
} else {
86
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALCAT . '</infolabel>', $totalcategories), '', 'Green');
87
}
88
if ($totalasked > 0) {
89
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="main.php">' . _AM_SF_TOTALASKED . '</a><b>' . '</infolabel>', $totalasked), '', 'Green');
90
} else {
91
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALASKED . '</infolabel>', $totalasked), '', 'Green');
92
}
93
if ($totalopened > 0) {
94
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="question.php">' . _AM_SF_TOTALOPENED . '</a><b>' . '</infolabel>', $totalopened), '', 'Red');
95
} else {
96
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALOPENED . '</infolabel>', $totalopened), '', 'Green');
97
}
98
if ($totalsubmitted > 0) {
99
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="category.php">' . _AM_SF_TOTALSUBMITTED . '</a><b>' . '</infolabel>', $totalsubmitted), '', 'Green');
100
} else {
101
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALSUBMITTED . '</infolabel>', $totalsubmitted), '', 'Green');
102
}
103
if ($totalpublished > 0) {
104
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="faq.php">' . _AM_SF_TOTALPUBLISHED . '</a><b>' . '</infolabel>', $totalpublished), '', 'Green');
105
} else {
106
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALPUBLISHED . '</infolabel>', $totalpublished), '', 'Green');
107
}
108
if ($totalnewanswers > 0) {
109
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . '<a href="main.php">' . _AM_SF_TOTALNEWANSWERS . '</a><b>' . '</infolabel>', $totalnewanswers), '', 'Red');
110
} else {
111
    $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_SF_TOTALNEWANSWERS . '</infolabel>', $totalnewanswers), '', 'Green');
112
}
113
114
//----------------------
115
116
$adminObject->displayNavigation(basename(__FILE__));
117
118
//check for latest release
119
//$newRelease = $utility->checkVerModule($helper);
120
//if (null !== $newRelease) {
121
//    $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
122
//}
123
124
//------------- Test Data Buttons ----------------------------
125
if ($helper->getConfig('displaySampleButton')) {
126
    TestdataButtons::loadButtonConfig($adminObject);
127
    $adminObject->displayButton('left', '');
128
}
129
$op = Request::getString('op', 0, 'GET');
130
switch ($op) {
131
    case 'hide_buttons':
132
        TestdataButtons::hideButtons();
133
        break;
134
    case 'show_buttons':
135
        TestdataButtons::showButtons();
136
        break;
137
}
138
//------------- End Test Data Buttons ----------------------------
139
140
$adminObject->displayIndex();
141
echo $utility::getServerStats();
142
143
//codeDump(__FILE__);
144
require_once __DIR__ . '/admin_footer.php';
145