Completed
Push — master ( c8eead...62889a )
by Michael
04:13
created

blocks/menu_block.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
// -------------------------------------------------------------------------
3
//	pedigree
4
//		Copyright 2004, James Cotton
5
// 		http://www.dobermannvereniging.nl
6
7
// Include any constants used for internationalizing templates.
8
if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) {
9
    require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php";
10
} else {
11
    include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english/main.php";
12
}
13
// Include any common code for this module.
14
require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php");
15
require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php");
16
17
/**
18
 * @return XoopsTpl
19
 */
20
function menu_block()
21
{
22
    global $xoopsTpl, $xoopsUser, $apppath;
23
24
    //get module configuration
25
    $module_handler =& xoops_gethandler('module');
26
    $module         =& $module_handler->getByDirname("pedigree");
27
    $config_handler =& xoops_gethandler('config');
28
    $moduleConfig   =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
29
30
    //colour variables
31
    $colors  = explode(";", $moduleConfig['colourscheme']);
32
    $actlink = $colors[0];
33
    $even    = $colors[1];
34
    $odd     = $colors[2];
35
    $text    = $colors[3];
36
    $hovlink = $colors[4];
37
    $head    = $colors[5];
38
    $body    = $colors[6];
39
    $title   = $colors[7];
40
//inline-css
41
    echo "<style>";
42
//text-colour
43
    echo "body {margin: 0;padding: 0;background: " . $body . ";color: " . $text
44
        . ";font-size: 62.5%; /* <-- Resets 1em to 10px */font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; text-align: left;}";
45
//link-colour
46
    echo "a, h2 a:hover, h3 a:hover { color: " . $actlink . "; text-decoration: none; }";
47
//link hover colour
48
    echo "a:hover { color: " . $hovlink . "; text-decoration: underline; }";
49
//th
50
    echo "th {padding: 2px;color: #ffffff;background: " . $title . ";font-family: Verdana, Arial, Helvetica, sans-serif;vertical-align: middle;}";
51
    echo "td#centercolumn th { color: #fff; background: " . $title . "; vertical-align: middle; }";
52
//head
53
    echo ".head {background-color: " . $head . "; padding: 3px; font-weight: normal;}";
54
//even
55
    echo ".even {background-color: " . $even . "; padding: 3px;}";
56
    echo "tr.even td {background-color: " . $even . "; padding: 3px;}";
57
//odd
58
    echo ".odd {background-color: " . $odd . "; padding: 3px;}";
59
    echo "tr.odd td {background-color: " . $odd . "; padding: 3px;}";
60
    echo "</style>";
61
62
    //iscurrent user a module admin ?
63
    $modadmin    = false;
64
    $xoopsModule =& XoopsModule::getByDirname("pedigree");
65
    if (!empty($xoopsUser)) {
66
        if ($xoopsUser->isAdmin($xoopsModule->mid())) {
67
            $modadmin = true;
68
        }
69
    }
70
    $counter   = 1;
71
    $menuwidth = 4;
72
73
    $x       = $_SERVER['PHP_SELF'];
74
    $lastpos = my_strrpos($x, "/");
75
    $len     = strlen($x);
76
    $curpage = substr($x, $lastpos, $len);
77
    if ($moduleConfig['showwelcome'] == '1') {
78
        if ($curpage == "/welcome.php") {
79
            $title = "<b>Welcome</b>";
80
        } else {
81
            $title = "Welcome";
82
        }
83
        $menuarray[] = array('title' => $title, 'link' => "welcome.php", 'counter' => $counter);
84
        ++$counter;
85
        if ($counter == $menuwidth) {
86
            $counter = 1;
87
        }
88
    }
89
    if ($curpage == "/index.php" || $curpage == "/result.php") {
90
        $title = "<b>View/Search " . $moduleConfig['animalTypes'] . "</b>";
91
    } else {
92
        $title = "View/Search " . $moduleConfig['animalTypes'];
93
    }
94
    $menuarray[] = array('title' => $title, 'link' => "index.php", 'counter' => $counter);
95
    ++$counter;
96
    if ($counter == $menuwidth) {
97
        $counter = 1;
98
    }
99
    if ($curpage == "/add_dog.php") {
100
        $title = "<b>Add a " . $moduleConfig['animalType'] . "</b>";
101
    } else {
102
        $title = "Add a " . $moduleConfig['animalType'];
103
    }
104
    $menuarray[] = array('title' => $title, 'link' => "add_dog.php", 'counter' => $counter);
105
    ++$counter;
106
    if ($counter == $menuwidth) {
107
        $counter = 1;
108
    }
109 View Code Duplication
    if ($moduleConfig['uselitter'] == '1') {
110
        if ($curpage == "/add_litter.php") {
111
            $title = "<b>Add a " . $moduleConfig['litter'] . "</b>";
112
        } else {
113
            $title = "Add a " . $moduleConfig['litter'];
114
        }
115
        $menuarray[] = array('title' => $title, 'link' => "add_litter.php", 'counter' => $counter);
116
        ++$counter;
117
        if ($counter == $menuwidth) {
118
            $counter = 1;
119
        }
120
    }
121
    if ($moduleConfig['ownerbreeder'] == '1') {
122
        if ($curpage == "/breeder.php" || $curpage == "/owner.php") {
123
            $title = "<b>View owners/breeders</b>";
124
        } else {
125
            $title = "View owners/breeders";
126
        }
127
        $menuarray[] = array('title' => $title, 'link' => "breeder.php", 'counter' => $counter);
128
        ++$counter;
129
        if ($counter == $menuwidth) {
130
            $counter = 1;
131
        }
132
        if ($curpage == "/add_breeder.php") {
133
            $title = "<b>Add an owner/breeder</b>";
134
        } else {
135
            $title = "Add an owner/breeder";
136
        }
137
        $menuarray[] = array('title' => $title, 'link' => "add_breeder.php", 'counter' => $counter);
138
        ++$counter;
139
        if ($counter == $menuwidth) {
140
            $counter = 1;
141
        }
142
    }
143
    if ($curpage == "/advanced.php") {
144
        $title = "<b>Advanced info</b>";
145
    } else {
146
        $title = "Advanced info";
147
    }
148
    $menuarray[] = array('title' => $title, 'link' => "advanced.php", 'counter' => $counter);
149
    ++$counter;
150
    if ($counter == $menuwidth) {
151
        $counter = 1;
152
    }
153 View Code Duplication
    if ($moduleConfig['proversion'] == '1') {
154
        if ($curpage == "/virtual.php") {
155
            $title = "<b>Virtual mating</b>";
156
        } else {
157
            $title = "Virtual Mating";
158
        }
159
        $menuarray[] = array('title' => $title, 'link' => "virtual.php", 'counter' => $counter);
160
        ++$counter;
161
        if ($counter == $menuwidth) {
162
            $counter = 1;
163
        }
164
    }
165
    if ($curpage == "/latest.php") {
166
        $title = "<b>latest additions</b>";
167
    } else {
168
        $title = "latest additions";
169
    }
170
    $menuarray[] = array('title' => $title, 'link' => "latest.php", 'counter' => $counter);
171
    ++$counter;
172
    if ($counter == $menuwidth) {
173
        $counter = 1;
174
    }
175
    if ($modadmin == true) {
176
        if ($curpage == "/tools.php") {
177
            $title = "<b>Webmaster tools</b>";
178
        } else {
179
            $title = "Webmaster tools";
180
        }
181
        $menuarray[] = array('title' => $title, 'link' => "tools.php?op=index", 'counter' => $counter);
182
        ++$counter;
183
        if ($counter == $menuwidth) {
184
            $counter = 1;
185
        }
186
        $title       = "Logout";
187
        $menuarray[] = array('title' => $title, 'link' => "../../user.php?op=logout", 'counter' => $counter);
188
        ++$counter;
189
        if ($counter == $menuwidth) {
190
            $counter = 1;
191
        }
192 View Code Duplication
    } else {
193
        if ($curpage == "/user.php") {
194
            $title = "<b>User login</b>";
195
        } else {
196
            $title = "User login";
197
        }
198
        $menuarray[] = array('title' => $title, 'link' => "../../user.php", 'counter' => $counter);
199
        ++$counter;
200
        if ($counter == $menuwidth) {
201
            $counter = 1;
202
        }
203
    }
204
205
    //create path taken
206
    //showpath();
207
    $xoopsTpl->assign("menuarray", $menuarray);
208
    //return the template contents
209
    return $xoopsTpl;
210
}
211
212
/**
213
 * @param     $haystack
214
 * @param     $needle
215
 * @param int $offset
216
 *
217
 * @return bool|int
218
 */
219 View Code Duplication
function my_strrpos($haystack, $needle, $offset = 0)
220
{
221
    // same as strrpos, except $needle can be a string
222
    $strrpos = false;
223
    if (is_string($haystack) && is_string($needle) && is_numeric($offset)) {
224
        $strlen = strlen($haystack);
225
        $strpos = strpos(strrev(substr($haystack, $offset)), strrev($needle));
226
        if (is_numeric($strpos)) {
227
            $strrpos = $strlen - $strpos - strlen($needle);
228
        }
229
    }
230
231
    return $strrpos;
232
}
233