TestdataButtons   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 25
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadButtonConfig() 0 18 2
A showButtons() 0 7 1
A hideButtons() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Wgsitenotice\Common;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
 
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*/
16
17
/**
18
 *
19
 * @category        Module
20
 * @author          XOOPS Development Team <https://xoops.org>
21
 * @copyright       {@link https://xoops.org/ XOOPS Project}
22
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
23
 */
24
25
use Xmf\Request;
0 ignored issues
show
Bug introduced by
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
use Xmf\Yaml;
0 ignored issues
show
Bug introduced by
The type Xmf\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
use XoopsModules\Wgsitenotice\Helper;
28
/** @var Helper $helper */
29
30
/**
31
 * Class SysUtility
32
 */
33
class TestdataButtons
34
{
35
36
    //functions for import buttons
37
    public static function loadButtonConfig($adminObject)
38
    {
39
        $moduleDirName      = \basename(\dirname(__DIR__, 2));
40
        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
41
        $yamlFile           = \dirname(__DIR__, 2) . '/config/admin.yml';
42
        $config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
43
        $displaySampleButton = $config['displaySampleButton'];
44
        $helper = Helper::getInstance();
45
46
        if (1 == $displaySampleButton) {
47
            \xoops_loadLanguage('admin/modulesadmin', 'system');
0 ignored issues
show
Bug introduced by
The function xoops_loadLanguage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
            /** @scrutinizer ignore-call */ 
48
            \xoops_loadLanguage('admin/modulesadmin', 'system');
Loading history...
48
            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
49
            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
50
            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
51
            //    $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
52
            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
53
        } else {
54
            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
55
            // $displaySampleButton = $config['displaySampleButton'];
56
        }
57
    }
58
59
    public static function hideButtons()
60
    {
61
        $yamlFile            = \dirname(__DIR__, 2) . '/config/admin.yml';
62
        $app                        = [];
63
        $app['displaySampleButton'] = 0;
64
        Yaml::save($app, $yamlFile);
65
        \redirect_header('index.php', 0);
0 ignored issues
show
Bug introduced by
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        /** @scrutinizer ignore-call */ 
66
        \redirect_header('index.php', 0);
Loading history...
66
    }
67
68
    public static function showButtons()
69
    {
70
        $yamlFile            = \dirname(__DIR__, 2) . '/config/admin.yml';
71
        $app                        = [];
72
        $app['displaySampleButton'] = 1;
73
        Yaml::save($app, $yamlFile);
74
        \redirect_header('index.php', 0);
0 ignored issues
show
Bug introduced by
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
        /** @scrutinizer ignore-call */ 
75
        \redirect_header('index.php', 0);
Loading history...
75
    }
76
}
77