45 foreach ($array as $item) {
53 public function add($item)
55 $this->parents[$item[
'pid']][] = $item;
68 foreach ($this->parents[
$pid] as $item) {
71 $this->output[$idx][
'oul'] =
false;
72 $this->output[$idx][
'oli'] =
false;
73 $this->output[$idx][
'close'] =
'';
74 $this->output[$idx][
'cul'] =
false;
75 $this->output[$idx][
'cli'] =
false;
76 $this->output[$idx][
'hassub'] =
false;
77 $this->output[$idx][
'level'] = $level;
80 $this->output[$idx][
'oul'] =
true;
84 $this->output[$idx][
'oli'] =
true;
85 $this->output[$idx] = array_merge($item, $this->output[$idx]);
87 if (isset($this->parents[$item[
'id']])) {
88 $this->output[$idx][
'hassub'] =
true;
91 $this->output[$idx][
'cli'] =
true;
92 $this->output[$idx][
'close'] .=
'</li>';
94 $this->output[$idx][
'cul'] =
true;
95 $this->output[$idx][
'close'] .=
'</ul>';
111 foreach ($this->parents[$pid] as $item) {
114 if ($counter ==
$count) { $down = 0; }
117 $this->output[$idx][
'up_weight'] = $prevWeight;
120 $this->output[$idx][
'down_weight'] = $this->output[$idx][
'weight'] + 2;
123 $prevWeight = $this->output[$idx][
'weight'];
126 if (isset($this->parents[$item[
'id']])) {
136 $query_string =
$_SERVER[
'QUERY_STRING'] ?
'?' .
$_SERVER[
'QUERY_STRING'] :
'';
137 $self =
'http://' .
$_SERVER[
'HTTP_HOST'] .
$_SERVER[
'PHP_SELF'] . $query_string;
143 foreach ($this->output as $idx =>
$menu) {
145 if (!empty(
$menu[
'link'])) {
146 $selected = (
false !== stristr($self,
$menu[
'link'])) ? 1 : $selected;
148 $selected = (
$menu[
'link'] == $self) ? 1 : $selected;
149 $selected = (
$menu[
'link'] == $default) ? 1 : $selected;
159 if (strlen(
$menu[
'link']) > strlen($longlink)) {
161 $longlink =
$menu[
'link'];
169 if (isset($this->output[$longidx])) {
170 $this->output[$longidx][
'selected'] =
true;
171 $this->output[$longidx][
'topselected'] =
true;
183 foreach ($this->output as $idx =>
$menu) {
185 $this->output[$idx][
'selected'] =
true;