|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* **************************************************************************** |
|
4
|
|
|
* marquee - MODULE FOR XOOPS |
|
5
|
|
|
* Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com) |
|
6
|
|
|
* |
|
7
|
|
|
* You may not change or alter any portion of this comment or credits |
|
8
|
|
|
* of supporting developers from this source code or any supporting source code |
|
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright Hervé Thouzard (http://www.herve-thouzard.com) |
|
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
16
|
|
|
* @package marquee |
|
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
18
|
|
|
* |
|
19
|
|
|
* Version : |
|
20
|
|
|
* **************************************************************************** |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use Xmf\Module\Admin; |
|
24
|
|
|
use Xmf\Request; |
|
25
|
|
|
use Xmf\Yaml; |
|
26
|
|
|
use XoopsModules\Marquee\{Common, |
|
27
|
|
|
Helper, |
|
28
|
|
|
Utility |
|
29
|
|
|
}; |
|
30
|
|
|
|
|
31
|
|
|
/** @var Admin $adminObject */ |
|
32
|
|
|
/** @var Helper $helper */ |
|
33
|
|
|
/** @var Utility $utility */ |
|
34
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
35
|
|
|
// Display Admin header |
|
36
|
|
|
xoops_cp_header(); |
|
37
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
38
|
|
|
//check for latest release |
|
39
|
|
|
//$newRelease = $utility->checkVerModule($helper); |
|
40
|
|
|
//if (!empty($newRelease)) { |
|
41
|
|
|
// $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); |
|
42
|
|
|
//} |
|
43
|
|
|
//------------- Test Data ---------------------------- |
|
44
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
|
45
|
|
|
$yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
|
46
|
|
|
$config = loadAdminConfig($yamlFile); |
|
47
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
|
48
|
|
|
if (1 == $displaySampleButton) { |
|
49
|
|
|
xoops_loadLanguage('admin/modulesadmin', 'system'); |
|
50
|
|
|
require_once dirname(__DIR__) . '/testdata/index.php'; |
|
51
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
|
52
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
|
53
|
|
|
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
|
54
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
55
|
|
|
} else { |
|
56
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
57
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
|
58
|
|
|
} |
|
59
|
|
|
$adminObject->displayButton('left', ''); |
|
60
|
|
|
} |
|
61
|
|
|
//------------- End Test Data ---------------------------- |
|
62
|
|
|
$adminObject->displayIndex(); |
|
63
|
|
|
/** |
|
64
|
|
|
* @param $yamlFile |
|
65
|
|
|
* @return array|bool |
|
66
|
|
|
*/ |
|
67
|
|
|
function loadAdminConfig($yamlFile) |
|
68
|
|
|
{ |
|
69
|
|
|
$config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
|
70
|
|
|
return $config; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param $yamlFile |
|
75
|
|
|
*/ |
|
76
|
|
|
function hideButtons($yamlFile) |
|
77
|
|
|
{ |
|
78
|
|
|
$app['displaySampleButton'] = 0; |
|
|
|
|
|
|
79
|
|
|
Yaml::save($app, $yamlFile); |
|
80
|
|
|
redirect_header('index.php', 0, ''); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param $yamlFile |
|
85
|
|
|
*/ |
|
86
|
|
|
function showButtons($yamlFile) |
|
87
|
|
|
{ |
|
88
|
|
|
$app['displaySampleButton'] = 1; |
|
|
|
|
|
|
89
|
|
|
Yaml::save($app, $yamlFile); |
|
90
|
|
|
redirect_header('index.php', 0, ''); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$op = Request::getString('op', 0, 'GET'); |
|
94
|
|
|
switch ($op) { |
|
95
|
|
|
case 'hide_buttons': |
|
96
|
|
|
hideButtons($yamlFile); |
|
97
|
|
|
break; |
|
98
|
|
|
case 'show_buttons': |
|
99
|
|
|
showButtons($yamlFile); |
|
100
|
|
|
break; |
|
101
|
|
|
} |
|
102
|
|
|
echo $utility::getServerStats(); |
|
103
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
104
|
|
|
|