Passed
Pull Request — master (#11)
by Michael
23:53 queued 11:52
created

showButtons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php declare(strict_types=1);
2
/*
3
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * Admin index file
15
 *
16
 * @author    Raul Recio (aka UNFOR)
17
 * @author    XOOPS Module Development Team
18
 * @copyright Copyright (c) 2001-2017 {@link https://xoops.org XOOPS Project}
19
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20
 *
21
 * @see       Xmf\Module\Admin
22
 */
23
24
use Xmf\Module\Admin;
25
use Xmf\Request;
26
use XoopsModules\Xoopsfaq\{
27
    CategoryHandler,
28
    Common,
29
    Common\TestdataButtons,
30
    ContentsHandler,
31
    Constants,
32
    Helper,
33
    Utility
34
};
35
36
/** @var Admin $adminObject */
37
/** @var Helper $helper */
38
/** @var Utility $utility */
39
require_once __DIR__ . '/admin_header.php';
40
xoops_cp_header();
41
42
/** @var CategoryHandler $categoryHandler */
43
/** @var ContentsHandler $contentsHandler */
44
45
//-----------------------
46
$moduleDirName      = \basename(\dirname(__DIR__));
47
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
48
49
$contentsHandler = $helper->getHandler('Contents');
50
$totalFaqs       = $contentsHandler->getCount();
51
52
$criteriaPublished = new \CriteriaCompo();
53
$criteriaPublished->add(new \Criteria('contents_publish', Constants::NOT_PUBLISHED, '>'));
54
$criteriaPublished->add(new \Criteria('contents_publish', time(), '<='));
55
56
$criteria = new \CriteriaCompo();
57
$criteria->add(new \Criteria('contents_active', Constants::ACTIVE, '='));
58
$criteria->add($criteriaPublished);
59
$totalPublishedFaqs = $contentsHandler->getCount($criteria);
60
61
$categoryHandler = $helper->getHandler('Category');
62
$totalCats       = $categoryHandler->getCount();
63
64
$totalNonpublishedFaqs = $totalFaqs - $totalPublishedFaqs;
65
66
$adminObject->addInfoBox(_AM_XOOPSFAQ_FAQ_CONF);
67
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_CATEGORIES . '</span>', '<span class="infotext green bold">' . $totalCats . '</span>'));
68
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_PUBLISHED . '</span>', '<span class="infotext green bold">' . $totalPublishedFaqs . '</span>'));
69
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_INACTIVE . '</span>', '<span class="infotext red bold">' . $totalNonpublishedFaqs . '</span>'));
70
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_FAQS . '</span>', '<span class="infotext green bold">' . $totalFaqs . '</span>'));
71
72
$adminObject->displayNavigation(basename(__FILE__));
73
74
//check for latest release
75
//$newRelease = $utility->checkVerModule($helper);
76
//if (null !== $newRelease) {
77
//    $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
78
//}
79
80
//------------- Test Data Buttons ----------------------------
81
if ($helper->getConfig('displaySampleButton')) {
82
    TestdataButtons::loadButtonConfig($adminObject);
83
    $adminObject->displayButton('left', '');
84
}
85
$op = Request::getString('op', 0, 'GET');
86
switch ($op) {
87
    case 'hide_buttons':
88
        TestdataButtons::hideButtons();
89
        break;
90
    case 'show_buttons':
91
        TestdataButtons::showButtons();
92
        break;
93
}
94
//------------- End Test Data Buttons ----------------------------
95
96
$adminObject->displayIndex();
97
echo $utility::getServerStats();
98
99
//codeDump(__FILE__);
100
require_once __DIR__ . '/admin_footer.php';
101