showButtons()   A
last analyzed

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
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
### =============================================================
3
### Mastop InfoDigital - Paixão por Internet
4
### =============================================================
5
### Vazio
6
### =============================================================
7
### Developer: Fernando Santos (topet05), [email protected]
8
### Copyright: Mastop InfoDigital © 2003-2007
9
### -------------------------------------------------------------
10
### www.mastop.com.br
11
### =============================================================
12
###
13
### =============================================================
14
15
use XoopsModules\Mastopgo2\Common;
16
17
require_once __DIR__ . '/admin_header.php';
18
xoops_cp_header();
19
20
$adminObject = \Xmf\Module\Admin::getInstance();
21
22
//check or upload folders
23
$configurator = new Common\Configurator();
24
foreach (array_keys($configurator->uploadFolders) as $i) {
25
    $utility::createFolder($configurator->uploadFolders[$i]);
26
    $adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder');
27
}
28
29
$adminObject->displayNavigation(basename(__FILE__));
30
31
/*
32
//check for latest release
33
$newRelease = $utility->checkVerModule($helper);
34
if (!empty($newRelease)) {
35
    $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
36
}
37
*/
38
39
//------------- Test Data ----------------------------
40
41
if ($helper->getConfig('displaySampleButton')) {
42
    $yamlFile            = dirname(__DIR__) . '/config/admin.yml';
43
    $config              = loadAdminConfig($yamlFile);
44
    $displaySampleButton = $config['displaySampleButton'];
45
46
    if (1 == $displaySampleButton) {
47
        xoops_loadLanguage('admin/modulesadmin', 'system');
48
        require __DIR__ . '/../testdata/index.php';
49
50
        $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add');
51
        $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add');
52
        //    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add');
53
        $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
54
    } else {
55
        $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
56
        $displaySampleButton = $config['displaySampleButton'];
57
    }
58
    $adminObject->displayButton('left', '');
59
}
60
61
//------------- End Test Data ----------------------------
62
63
$adminObject->displayIndex();
64
65
/**
66
 * @param $yamlFile
67
 * @return array|bool
68
 */
69
function loadAdminConfig($yamlFile)
70
{
71
    $config = \Xmf\Yaml::loadWrapped($yamlFile); // work with phpmyadmin YAML dumps
72
    return $config;
73
}
74
75
/**
76
 * @param $yamlFile
77
 */
78
function hideButtons($yamlFile)
79
{
80
    $app['displaySampleButton'] = 0;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$app was never initialized. Although not strictly required by PHP, it is generally a good practice to add $app = array(); before regardless.
Loading history...
81
    \Xmf\Yaml::save($app, $yamlFile);
82
    redirect_header('index.php', 0, '');
83
}
84
85
/**
86
 * @param $yamlFile
87
 */
88
function showButtons($yamlFile)
89
{
90
    $app['displaySampleButton'] = 1;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$app was never initialized. Although not strictly required by PHP, it is generally a good practice to add $app = array(); before regardless.
Loading history...
91
    \Xmf\Yaml::save($app, $yamlFile);
92
    redirect_header('index.php', 0, '');
93
}
94
95
$op = \Xmf\Request::getString('op', 0, 'GET');
96
97
switch ($op) {
98
    case 'hide_buttons':
99
        hideButtons($yamlFile);
100
        break;
101
    case 'show_buttons':
102
        showButtons($yamlFile);
103
        break;
104
}
105
106
echo $utility::getServerStats();
107
108
require __DIR__ . '/admin_footer.php';
109