ACC SHELL

Path : /var/lib/ntp/proc/self/root/srv/www/vhosts/tsisystem/app/controllers/components/
File Upload :
Current File : //var/lib/ntp/proc/self/root/srv/www/vhosts/tsisystem/app/controllers/components/menu_builder.php

<?php

/* $Id$ */

class MenuBuilderComponent extends Object
{
	var $html;
    var $base;
    var $current;

	/**
	 *
	 */
	function buildMenu($tree, $level = 0)
	{
		$menu = '';

		$len = $pos = count($tree);
		foreach ($tree as $ary) {
			$pos--;
			$first = $pos == $len - 1;
			$last = ! $pos;

            if ($this->current == $ary['data']['name_idx']) {
                $current = ' class="current-1" ';
                $current2 = ' class="current-2" ';
                $current3 = ' class="current-3" ';
            }
            else {
                $current = $current2 = $current3 = ' ';
            }

			switch ($level) {
				case 0:
					if (! $ary['data']['is_cat']) {
						if ($first) {
							$menu .= "  <li><ul class=\"right-menu right-menu-3\">\n";
						}

						$menu .= "    <li><a{$current3}href=\"{$this->base}/produkty/" .
                            "{$ary['data']['name_idx']}\">{$ary['data']['name']}</a></li>\n";

						if ($last) {
							$menu .= "  </ul></li>\n";
						}

					}
					else {
						$menu .= "    <li><a{$current}href=\"{$this->base}/produkty/" .
                            "{$ary['data']['name_idx']}\">{$ary['data']['name']}</a>";

						if (! empty($ary['child'])) {
							$tmp = $this->buildMenu($ary['child'], $level + 1);

                            if (! preg_match('/^\s*<ul/i', $tmp)) {
                                $menu .= "\n" . '  <ul class="right-menu right-menu-2">' . "\n";
                                $menu .= $tmp;
                                $menu .= "  </ul>\n";
                            }
                            else {
                                $menu .= $tmp;
                            }
						}

						$menu .= "    </li>\n";
					}
					break;

				case 1:
					if (! $ary['data']['is_cat']) {
						if ($first) {
							$menu .= "      <ul class=\"right-menu right-menu-3\">\n";
						}
						$menu .= "    <li><a{$current3} href=\"{$this->base}/produkty/" .
                            "{$ary['data']['name_idx']}\">{$ary['data']['name']}</a></li>\n";

						if ($last) {
							$menu .= "  </ul>\n    \n";
						}
					}
					else {
						$menu .= "    <li><a{$current2}href=\"{$this->base}/produkty/" .
                            "{$ary['data']['name_idx']}\">{$ary['data']['name']}</a>\n";

                        if (! empty($ary['child'])) {
                            $tmp = $this->buildMenu($ary['child'], $level + 1);

                            if (! preg_match('/^\s*<ul/i', $tmp)) {
                                $menu .= '  <ul class="right-menu right-menu-3">' . "\n";
                                $menu .= $tmp;
                                $menu .= "  </ul>\n";
                            }
                            else {
                                $menu .= $tmp;
                            }
                        }
                        $menu .= "    </li>\n";
					}
					break;

				case 2:
                    $menu .= "    <li><a{$current3}href=\"{$this->base}/produkty/" .
                        "{$ary['data']['name_idx']}\">{$ary['data']['name']}</a></li>\n";
					break;
			}
		}

		return $menu;
	}
}

?>

ACC SHELL 2018