Passed
Push — master ( 169298...1b648e )
by Michael
35s queued 13s
created

my_strrpos()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
nc 3
nop 3
dl 0
loc 13
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Include any constants used for internationalizing templates.
5
 *
6
 * @package      XoopsModules\Pedigree
7
 * @copyright    2004 James Cotton
8
 * @copyright    {@link https://xoops.org/ XOOPS Project}
9
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
10
 * @author       James Cotton {@link http://www.dobermannvereniging.nl James Cotton}
11
 * @author       XOOPS Module Dev Team
12
 */
13
14
use XoopsModules\Pedigree;
15
16
$moduleDirName = basename(__DIR__);
17
$helper = Pedigree\Helper::getInstance();
18
$helper->loadLanguage('main');
19
20
// Include any common code for this module.
21
require_once $helper->path('include/common.php');
22
23
/**
24
 * @return XoopsTpl
25
 */
26
function menu_block()
27
{
28
    /** @var \XoopsModules\Pedigree\Helper $helper */
29
    $helper  = Pedigree\Helper::getInstance();
30
31
    list($actlink, $even, $odd, $text, $hovlink, $head, $body, $title) = Pedigree\Utility::getColourScheme();
32
    /*
33
    $actlink = $colors[0];
34
    $even    = $colors[1];
35
    $odd     = $colors[2];
36
    $text    = $colors[3];
37
    $hovlink = $colors[4];
38
    $head    = $colors[5];
39
    $body    = $colors[6];
40
    $title   = $colors[7];
41
    */
42
    //inline-css
43
    echo '<style>';
44
    //text-colour
45
    echo 'body {margin: 0;padding: 0;background: ' . $body . ';color: ' . $text . ";font-size: 100%; /* <-- Resets 1em to 10px */font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; text-align: left;}";
46
    //link-colour
47
    echo 'a, h2 a:hover, h3 a:hover { color: ' . $actlink . '; text-decoration: none; }';
48
    //link hover colour
49
    echo 'a:hover { color: ' . $hovlink . '; text-decoration: underline; }';
50
    //th
51
    echo 'th {padding: 2px;color: #ffffff;background: ' . $title . ';font-family: Verdana, Arial, Helvetica, sans-serif;vertical-align: middle;}';
52
    echo 'td#centercolumn th { color: #fff; background: ' . $title . '; vertical-align: middle; }';
53
    //head
54
    echo '.head {background-color: ' . $head . '; padding: 3px; font-weight: normal;}';
55
    //even
56
    echo '.even {background-color: ' . $even . '; padding: 3px;}';
57
    echo 'tr.even td {background-color: ' . $even . '; padding: 3px;}';
58
    //odd
59
    echo '.odd {background-color: ' . $odd . '; padding: 3px;}';
60
    echo 'tr.odd td {background-color: ' . $odd . '; padding: 3px;}';
61
    echo '</style>';
62
63
    //is current user a module admin ?
64
    if (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)
65
        && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) {
66
        $isAdmin = true;
67
    } else {
68
        $isAdmin = false;
69
    }
70
71
    $counter   = 1;
72
    $menuwidth = 4;
73
74
    $x       = $_SERVER['SCRIPT_NAME'];
75
    $lastpos = Pedigree\Utility::myStrRpos($x, '/');
76
    $len     = strlen($x);
77
    $curpage = substr($x, $lastpos, $len);
0 ignored issues
show
Bug introduced by
It seems like $lastpos can also be of type false; however, parameter $start of substr() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

77
    $curpage = substr($x, /** @scrutinizer ignore-type */ $lastpos, $len);
Loading history...
78
    if ('1' == $helper->getConfig['showwelcome']) {
0 ignored issues
show
Bug introduced by
The property getConfig does not seem to exist on XoopsModules\Pedigree\Helper.
Loading history...
79
        if ('/welcome.php' === $curpage) {
80
            $title = '<b>' . _MA_PEDIGREE_WELCOME . '</b>';
81
        } else {
82
            $title = _MA_PEDIGREE_WELCOME;
83
        }
84
        $menuarray[] = ['title' => $title, 'link' => 'welcome.php', 'counter' => $counter];
0 ignored issues
show
Comprehensibility Best Practice introduced by
$menuarray was never initialized. Although not strictly required by PHP, it is generally a good practice to add $menuarray = array(); before regardless.
Loading history...
85
        ++$counter;
86
        if ($counter == $menuwidth) {
87
            $counter = 1;
88
        }
89
    }
90
    if ('/index.php' === $curpage || '/result.php' == $curpage) {
91
        $title = '<b>' . _MA_PEDIGREE_VIEWSEARCH . $helper->getConfig['animalTypes'] . '</b>';
92
    } else {
93
        $title = '_MA_PEDIGREE_VIEWSEARCH ' . $helper->getConfig['animalTypes'];
94
    }
95
    $menuarray[] = ['title' => $title, 'link' => 'result.php', 'counter' => $counter];
96
    ++$counter;
97
    if ($counter == $menuwidth) {
98
        $counter = 1;
99
    }
100
    if ('/index.php' === $curpage) {
101
        $title = '<b>' . _MA_PEDIGREE_ADD_A . $helper->getConfig['animalType'] . '</b>';
102
    } else {
103
        $title = 'PED_ADD_A ' . $helper->getConfig['animalType'];
104
    }
105
    $menuarray[] = ['title' => $title, 'link' => 'add_dog.php', 'counter' => $counter];
106
    ++$counter;
107
    if ($counter == $menuwidth) {
108
        $counter = 1;
109
    }
110
    if ('1' == $helper->getConfig['uselitter']) {
111
        if ('/index.php' === $curpage) {
112
            $title = '<b>' . _MA_PEDIGREE_ADD_LITTER . $helper->getConfig['litter'] . '</b>';
113
        } else {
114
            $title = '_MA_PEDIGREE_ADD_LITTER ' . $helper->getConfig['litter'];
115
        }
116
        $menuarray[] = ['title' => $title, 'link' => 'add_litter.php', 'counter' => $counter];
117
        ++$counter;
118
        if ($counter == $menuwidth) {
119
            $counter = 1;
120
        }
121
    }
122
    if ('1' == $helper->getConfig['ownerbreeder']) {
123
        if ('/index.php' === $curpage || '/owner.php' === $curpage) {
124
            $title = '<b>' . _MA_PEDIGREE_VIEW_OWNBREED . '</b>';
125
        } else {
126
            $title = '_MA_PEDIGREE_VIEW_OWNBREED';
127
        }
128
        $menuarray[] = ['title' => $title, 'link' => 'breeder.php', 'counter' => $counter];
129
        ++$counter;
130
        if ($counter == $menuwidth) {
131
            $counter = 1;
132
        }
133
        if ('/index.php' === $curpage || '/add_breeder.php' === $curpage) {
134
            $title = '<b>' . _MA_PEDIGREE_ADD_OWNBREED . '</b>';
135
        } else {
136
            $title = '_MA_PEDIGREE_ADD_OWNBREED';
137
        }
138
        $menuarray[] = ['title' => $title, 'link' => 'add_breeder.php', 'counter' => $counter];
139
        ++$counter;
140
        if ($counter == $menuwidth) {
141
            $counter = 1;
142
        }
143
    }
144
    if ('/index.php' === $curpage || '/advanced.php' === $curpage) {
145
        $title = '<b>' . _MA_PEDIGREE_ADVANCE_INFO . '</b>';
146
    } else {
147
        $title = '_MA_PEDIGREE_ADVANCE_INFO';
148
    }
149
    $menuarray[] = ['title' => $title, 'link' => 'advanced.php', 'counter' => $counter];
150
    ++$counter;
151
    if ($counter == $menuwidth) {
152
        $counter = 1;
153
    }
154
    if ('1' == $helper->getConfig['proversion']) {
155
        if ('/index.php' === $curpage || '/virtual.php' === $curpage) {
156
            $title = '<b>' . _MA_PEDIGREE_VIRUTALTIT . '</b>';
157
        } else {
158
            $title = '_MA_PEDIGREE_VIRUTALTIT';
159
        }
160
        $menuarray[] = ['title' => $title, 'link' => 'virtual.php', 'counter' => $counter];
161
        ++$counter;
162
        if ($counter == $menuwidth) {
163
            $counter = 1;
164
        }
165
    }
166
    if ('/index.php' === $curpage || '/latest.php' === $curpage) {
167
        $title = '<b>' . _MA_PEDIGREE_LATEST_ADD . '</b>';
168
    } else {
169
        $title = '_MA_PEDIGREE_LATEST_ADD';
170
    }
171
    $menuarray[] = ['title' => $title, 'link' => 'latest.php', 'counter' => $counter];
172
    ++$counter;
173
    if ($counter == $menuwidth) {
174
        $counter = 1;
175
    }
176
    if ($isAdmin) {
177
        if ('/index.php' === $curpage || '/tools.php' === $curpage) {
178
            $title = '<b>' . _MA_PEDIGREE_WEB_TOOLS . '</b>';
179
        } else {
180
            $title = '_MA_PEDIGREE_WEB_TOOLS';
181
        }
182
        $menuarray[] = ['title' => $title, 'link' => 'tools.php?op=index', 'counter' => $counter];
183
        ++$counter;
184
        if ($counter == $menuwidth) {
185
            $counter = 1;
186
        }
187
188
        $title       = _MA_PEDIGREE_USER_LOGOUT;
189
        $menuarray[] = ['title' => $title, 'link' => '../../user.php?op=logout', 'counter' => $counter];
190
        ++$counter;
191
        if ($counter == $menuwidth) {
192
            $counter = 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $counter is dead and can be removed.
Loading history...
193
        }
194
    } else {
195
        if ('/user.php' === $curpage) {
196
            $title = '._MA_PEDIGREE_USER_LOGIN.';
197
        } else {
198
            $title = _MA_PEDIGREE_USER_LOGIN;
199
        }
200
        $menuarray[] = ['title' => $title, 'link' => '../../user.php', 'counter' => $counter];
201
        ++$counter;
202
        if ($counter == $menuwidth) {
203
            $counter = 1;
204
        }
205
    }
206
207
    //create path taken
208
    //showpath();
209
    $GLOBALS['xoopsTpl']->assign('menuarray', $menuarray);
210
211
    //return the template contents
212
    return $GLOBALS['xoopsTpl'];
213
}
214