Passed
Pull Request — master (#11)
by Michael
11:08
created

loadAdminConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
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
 * @package   module\xoopsfaq\admin
17
 * @author    Raul Recio (aka UNFOR)
18
 * @author    XOOPS Module Development Team
19
 * @copyright Copyright (c) 2001-2017 {@link https://xoops.org XOOPS Project}
20
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
21
 *
22
 * @see       Xmf\Module\Admin
23
 */
24
25
use Xmf\Module\Admin;
26
use Xmf\Request;
27
use Xmf\Yaml;
28
use XoopsModules\Xoopsfaq\{
29
    Common,
30
    Constants,
31
    Common\TestdataButtons,
32
    Helper,
33
    Utility
34
};
35
36
/** @var Admin $adminObject */
37
/** @var Helper $helper */
38
/** @var Utility $utility */
39
40
require_once __DIR__ . '/admin_header.php';
41
xoops_cp_header();
42
43
/** @var Xoopsfaq\CategoryHandler $categoryHandler */
44
/** @var Xoopsfaq\ContentsHandler $contentsHandler */
45
46
//-----------------------
47
$moduleDirName      = \basename(\dirname(__DIR__));
48
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
49
50
$contentsHandler = $helper->getHandler('Contents');
51
$totalFaqs       = $contentsHandler->getCount();
52
53
$criteriaPublished = new \CriteriaCompo();
54
$criteriaPublished->add(new \Criteria('contents_publish', Constants::NOT_PUBLISHED, '>'));
55
$criteriaPublished->add(new \Criteria('contents_publish', time(), '<='));
56
57
$criteria = new \CriteriaCompo();
58
$criteria->add(new \Criteria('contents_active', Constants::ACTIVE, '='));
59
$criteria->add($criteriaPublished);
60
$totalPublishedFaqs = $contentsHandler->getCount($criteria);
61
62
$categoryHandler = $helper->getHandler('Category');
63
$totalCats       = $categoryHandler->getCount();
64
65
$totalNonpublishedFaqs = $totalFaqs - $totalPublishedFaqs;
66
67
$adminObject->addInfoBox(_AM_XOOPSFAQ_FAQ_CONF);
68
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_CATEGORIES . '</span>', '<span class="infotext green bold">' . $totalCats . '</span>'));
69
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_PUBLISHED . '</span>', '<span class="infotext green bold">' . $totalPublishedFaqs . '</span>'));
70
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_INACTIVE . '</span>', '<span class="infotext red bold">' . $totalNonpublishedFaqs . '</span>'));
71
$adminObject->addInfoBoxLine(sprintf('<span class="infolabel">' . _AM_XOOPSFAQ_TOTAL_FAQS . '</span>', '<span class="infotext green bold">' . $totalFaqs . '</span>'));
72
73
$adminObject->displayNavigation(basename(__FILE__));
74
75
//check for latest release
76
//$newRelease = $utility->checkVerModule($helper);
77
//if (null !== $newRelease) {
78
//    $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
79
//}
80
81
//------------- Test Data Buttons ----------------------------
82
if ($helper->getConfig('displaySampleButton')) {
83
    TestdataButtons::loadButtonConfig($adminObject);
84
    $adminObject->displayButton('left', '');
85
}
86
$op = Request::getString('op', 0, 'GET');
87
switch ($op) {
88
    case 'hide_buttons':
89
        TestdataButtons::hideButtons();
90
        break;
91
    case 'show_buttons':
92
        TestdataButtons::showButtons();
93
        break;
94
}
95
//------------- End Test Data Buttons ----------------------------
96
97
98
$adminObject->displayIndex();
99
echo $utility::getServerStats();
100
101
//codeDump(__FILE__);
102
require_once __DIR__ . '/admin_footer.php';
103