1
|
|
|
<?php |
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
|
|
|
* This program is distributed in the hope that it will be useful, |
7
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
9
|
|
|
* ------------------------------- |
10
|
|
|
* Author: Raul Recio (AKA UNFOR) |
11
|
|
|
* Project: The XOOPS Project |
12
|
|
|
* ------------------------------- |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Module: XoopsPartners - a partner affiliation links module |
17
|
|
|
* |
18
|
|
|
* @package module\Xoopspartners\admin |
19
|
|
|
* @author Raul Recio (aka UNFOR) |
20
|
|
|
* @author XOOPS Module Development Team |
21
|
|
|
* @copyright {@link https://xoops.org 2001-2016 XOOPS Project} |
22
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
23
|
|
|
* @link https://xoops.org XOOPS |
24
|
|
|
* @since 1.11 |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
use Xmf\Module\Admin; |
28
|
|
|
|
29
|
|
|
require_once __DIR__ . '/admin_header.php'; |
30
|
|
|
$moduleAdmin = Admin::getInstance(); |
31
|
|
|
|
32
|
|
|
//----------------------- |
33
|
|
|
$partnersHandler = $helper->getHandler('Partners'); |
34
|
|
|
|
35
|
|
|
$totalPartners = $partnersHandler->getCount(); |
36
|
|
|
$totalNonActivePartners = $partnersHandler->getCount(new \Criteria('status', 0, '=')); |
37
|
|
|
$totalActivePartners = $totalPartners - $totalNonActivePartners; |
38
|
|
|
|
39
|
|
|
$moduleAdmin->addInfoBox(_MD_XOOPSPARTNERS_DASHBOARD); |
40
|
|
|
$moduleAdmin->addInfoBoxLine(sprintf('<infolabel>' . _MD_XOOPSPARTNERS_TOTALACTIVE . '</infolabel>', $totalActivePartners)); |
41
|
|
|
$moduleAdmin->addInfoBoxLine(sprintf('<infolabel>' . _MD_XOOPSPARTNERS_TOTALNONACTIVE . '</infolabel>', $totalNonActivePartners)); |
42
|
|
|
$moduleAdmin->addInfoBoxLine(sprintf('<infolabel>' . _MD_XOOPSPARTNERS_TOTALPARTNERS . '</infolabel><infotext>', $totalPartners . '</infotext>')); |
43
|
|
|
//---------------------------- |
44
|
|
|
|
45
|
|
|
$moduleAdmin->displayNavigation(basename(__FILE__)); |
46
|
|
|
//------------- Test Data ---------------------------- |
47
|
|
|
|
48
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
49
|
|
|
$yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
50
|
|
|
$config = loadAdminConfig($yamlFile); |
51
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
52
|
|
|
|
53
|
|
|
if (1 == $displaySampleButton) { |
54
|
|
|
xoops_loadLanguage('admin/modulesadmin', 'system'); |
55
|
|
|
require_once dirname(__DIR__) . '/testdata/index.php'; |
56
|
|
|
|
57
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
58
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
59
|
|
|
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
60
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
61
|
|
|
} else { |
62
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
63
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
64
|
|
|
} |
65
|
|
|
$adminObject->displayButton('left', ''); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
//------------- End Test Data ---------------------------- |
69
|
|
|
|
70
|
|
|
$adminObject->displayIndex(); |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param $yamlFile |
74
|
|
|
* @return array|bool |
75
|
|
|
*/ |
76
|
|
|
function loadAdminConfig($yamlFile) |
77
|
|
|
{ |
78
|
|
|
$config = \Xmf\Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
79
|
|
|
return $config; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param $yamlFile |
84
|
|
|
*/ |
85
|
|
|
function hideButtons($yamlFile) |
86
|
|
|
{ |
87
|
|
|
$app['displaySampleButton'] = 0; |
|
|
|
|
88
|
|
|
\Xmf\Yaml::save($app, $yamlFile); |
89
|
|
|
redirect_header('index.php', 0, ''); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param $yamlFile |
94
|
|
|
*/ |
95
|
|
|
function showButtons($yamlFile) |
96
|
|
|
{ |
97
|
|
|
$app['displaySampleButton'] = 1; |
|
|
|
|
98
|
|
|
\Xmf\Yaml::save($app, $yamlFile); |
99
|
|
|
redirect_header('index.php', 0, ''); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$op = \Xmf\Request::getString('op', 0, 'GET'); |
103
|
|
|
|
104
|
|
|
switch ($op) { |
105
|
|
|
case 'hide_buttons': |
106
|
|
|
hideButtons($yamlFile); |
107
|
|
|
break; |
108
|
|
|
case 'show_buttons': |
109
|
|
|
showButtons($yamlFile); |
110
|
|
|
break; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
echo $utility::getServerStats(); |
114
|
|
|
|
115
|
|
|
require __DIR__ . '/admin_footer.php'; |
116
|
|
|
|