myglob()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 5
eloc 12
c 1
b 1
f 0
nc 5
nop 2
dl 0
loc 20
rs 9.5555
1
<?php declare(strict_types=1);
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (https://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 (https://www.herve-thouzard.com)
15
 * @license           GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author            Hervé Thouzard (https://www.herve-thouzard.com)
17
 *
18
 * Version :
19
 * ****************************************************************************
20
 *
21
 * @param int    $currentoption
22
 * @param string $breadcrumb
23
 */
24
function marquee_adminmenu($currentoption = 0, $breadcrumb = ''): void
0 ignored issues
show
Unused Code introduced by
The parameter $currentoption is not used and could be removed. ( Ignorable by Annotation )

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

24
function marquee_adminmenu(/** @scrutinizer ignore-unused */ $currentoption = 0, $breadcrumb = ''): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $breadcrumb is not used and could be removed. ( Ignorable by Annotation )

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

24
function marquee_adminmenu($currentoption = 0, /** @scrutinizer ignore-unused */ $breadcrumb = ''): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
{
26
    ///*    require_once XOOPS_ROOT_PATH.'/modules/marquee/class/Utility.php';
27
    //
28
    //  /* Nice buttons styles */
29
    //  echo "
30
    //      <style type='text/css'>
31
    //      #buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }
32
    //      #buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/marquee/assets/images/bg.png') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; }
33
    //      #buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; }
34
    //      #buttonbar li { display:inline; margin:0; padding:0; }
35
    //      #buttonbar a { float:left; background:url('" . XOOPS_URL . "/modules/marquee/assets/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; }
36
    //      #buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/marquee/assets/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
37
    //      /* Commented Backslash Hack hides rule from IE5-Mac \*/
38
    //      #buttonbar a span {float:none;}
39
    //      /* End IE5-Mac hack */
40
    //      #buttonbar a:hover span { color:#333; }
41
    //      #buttonbar #current a { background-position:0 -150px; border-width:0; }
42
    //      #buttonbar #current a span { background-position:100% -150px; padding-bottom:5px; color:#333; }
43
    //      #buttonbar a:hover { background-position:0% -150px; }
44
    //      #buttonbar a:hover span { background-position:100% -150px; }
45
    //      </style>
46
    //    ";
47
    //  global $xoopsModule, $xoopsConfig;
48
    //
49
    //  $tblColors = array('','','','','');
50
    //  if ($currentoption >= 0) {
51
    //      $tblColors[$currentoption] = 'current';
52
    //  }
53
    //
54
    //  if (file_exists(XOOPS_ROOT_PATH . '/modules/marquee/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
55
    //      require_once XOOPS_ROOT_PATH. '/modules/marquee/language/' . $xoopsConfig['language'] . '/modinfo.php';
56
    //  } else {
57
    //      require_once XOOPS_ROOT_PATH . '/modules/marquee/language/english/modinfo.php';
58
    //  }
59
    //
60
    //  echo "<div id='buttontop'>";
61
    //  echo "<table style=\"width: 100%; padding: 0; \" cellspacing=\"0\"><tr>";
62
    //  echo "<td style=\"width: 60%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;\"><a class=\"nobutton\" href=\"../../system/admin.php?fct=preferences&amp;op=showmod&amp;mod=".$xoopsModule->getVar('mid')."\">" . _AM_MARQUEE_GENERALSET . "</a></td>";
63
    //  echo "<td style=\"width: 40%; font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;\"><b>" . $xoopsModule->name() . "  " . _AM_MARQUEE_MODULEADMIN . "</b> " . $breadcrumb . "</td>";
64
    //  echo "</tr></table>";
65
    //  echo "</div>";
66
    //
67
    //  echo "<div id='buttonbar'>";
68
    //  echo "<ul>";
69
    //  echo "<li id='" . $tblColors[0] . "'><a href=\"index.php\"\"><span>"._MI_MARQUEE_MENU_01 ."</span></a></li>\n";
70
    //  echo "</ul></div>";
71
    //  echo "<br><br><pre>&nbsp;</pre><pre>&nbsp;</pre><br>";*/
72
}
73
74
/**
75
 * Returns the files in a folder according to a pattern
76
 *
77
 * Some hosts have disabled the Php glob() function, that's why this function exists
78
 *
79
 * @param string $folder  Folder where you want to grab files from (terminated with a slash)
80
 * @param string $pattern Pattern used to filter files
81
 *
82
 * @return array Files that match the pattern in the selected folder
83
 * @throws \Exception
84
 * @author           Hervé Thouzard (https://www.herve-thouzard.com)
85
 * @copyright    (c) Hervé Thouzard
86
 */
87
function myglob($folder = '', $pattern = 'php')
88
{
89
    $result = [];
90
91
    if (!($dir = opendir($folder))) {
92
        throw new \RuntimeException('Error, impossible to open the folder ' . $folder);
93
    }
94
    while (false !== ($file = readdir($dir))) {
95
        if (!is_dir($file)) {
96
            $ext       = basename($file);
97
            $ext       = explode('.', $ext);
98
            $extension = \mb_strtolower($ext[count($ext) - 1]);
99
            if ($extension === $pattern) {
100
                $result[] = $file;
101
            }
102
        }
103
    }
104
    closedir($dir);
105
106
    return $result;
107
}
108