1 | <?php namespace XoopsModules\Mymenus; |
||
25 | */ |
||
26 | class Builder |
||
27 | { |
||
28 | public $parents = []; |
||
29 | public $output = []; |
||
30 | |||
31 | /** |
||
32 | * @param $array |
||
33 | */ |
||
34 | public function __construct($array) |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param $array |
||
41 | */ |
||
42 | public function addMenu($array) |
||
43 | { |
||
44 | foreach ($array as $item) { |
||
45 | $this->add($item); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param $item |
||
51 | */ |
||
52 | public function add($item) |
||
53 | { |
||
54 | $this->parents[$item['pid']][] = $item; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param int $pid |
||
59 | */ |
||
60 | public function buildMenus($pid = 0) |
||
61 | { |
||
62 | static $idx = -1; |
||
63 | static $level = -1; |
||
64 | ++$level; |
||
65 | $first = true; |
||
66 | |||
67 | foreach ($this->parents[$pid] as $item) { |
||
68 | ++$idx; |
||
69 | |||
70 | $this->output[$idx]['oul'] = false; |
||
71 | $this->output[$idx]['oli'] = false; |
||
72 | $this->output[$idx]['close'] = ''; |
||
73 | $this->output[$idx]['cul'] = false; |
||
74 | $this->output[$idx]['cli'] = false; |
||
75 | $this->output[$idx]['hassub'] = false; |
||
76 | $this->output[$idx]['level'] = $level; |
||
77 | |||
78 | if ($first) { |
||
79 | $this->output[$idx]['oul'] = true; |
||
80 | $first = false; |
||
81 | } |
||
82 | |||
83 | $this->output[$idx]['oli'] = true; |
||
84 | $this->output[$idx] = array_merge($item, $this->output[$idx]); |
||
85 | |||
86 | if (isset($this->parents[$item['id']])) { |
||
87 | $this->output[$idx]['hassub'] = true; |
||
88 | $this->buildMenus($item['id']); |
||
89 | } |
||
90 | $this->output[$idx]['cli'] = true; |
||
91 | $this->output[$idx]['close'] .= "</li>\n"; |
||
92 | } |
||
93 | $this->output[$idx]['cul'] = true; |
||
94 | $this->output[$idx]['close'] .= "</ul>\n"; |
||
95 | --$level; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param int $pid |
||
100 | */ |
||
101 | public function buildUpDown($pid = 0) |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | |||
133 | public function buildSelected() |
||
134 | { |
||
135 | //get the currentpage |
||
136 | $sel = []; |
||
137 | // $queryString = $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''; |
||
138 | $queryString = Request::getString('QUERY_STRING', '', 'SERVER') ? '?' . Request::getString('QUERY_STRING', '', 'SERVER') : ''; |
||
139 | // $self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $queryString; |
||
140 | $self = 'http://' . Request::getString('HTTP_HOST', '', 'SERVER') . Request::getString('PHP_SELF', '', 'SERVER') . $queryString; |
||
141 | |||
142 | //set a default page in case we don't get matches |
||
143 | $default = XOOPS_URL . '/index.php'; |
||
144 | |||
145 | //get all matching links |
||
146 | foreach ($this->output as $idx => $menu) { |
||
147 | $selected = 0; |
||
148 | if ($menu['link']) { |
||
149 | $selected = (false !== stripos($self, $menu['link'])) ? 1 : $selected; |
||
150 | } |
||
151 | $selected = ($menu['link'] == $self) ? 1 : $selected; |
||
152 | $selected = ($menu['link'] == $default) ? 1 : $selected; |
||
153 | if ($selected) { |
||
154 | $sel[$idx] = $menu; |
||
155 | } |
||
156 | } |
||
157 | |||
158 | //From those links get only the longer one |
||
159 | $longlink = ''; |
||
160 | $longidx = 0; |
||
161 | foreach ($sel as $idx => $menu) { |
||
162 | if (strlen($menu['link']) > strlen($longlink)) { |
||
163 | $longidx = $idx; |
||
164 | $longlink = $menu['link']; |
||
165 | } |
||
166 | } |
||
167 | |||
168 | /* |
||
169 | * When visiting site.com when XOOPS_URL is set to www.site.com |
||
170 | * longidx is not detected, this IF will prevent blank page |
||
171 | */ |
||
172 | if (isset($this->output[$longidx])) { |
||
173 | $this->output[$longidx]['selected'] = true; |
||
174 | $this->output[$longidx]['topselected'] = true; |
||
175 | |||
176 | //Now turn all this menu parents to selected |
||
177 | $this->addSelectedParents($this->output[$longidx]['pid']); |
||
178 | } |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * @param $pid |
||
183 | */ |
||
184 | public function addSelectedParents($pid) |
||
190 | } |
||
191 | } |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * @return array |
||
196 | */ |
||
197 | public function render() |
||
204 | } |
||
205 | } |
||
206 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths