Пример #1
0
<?php

// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    // start tree class
    $tree = new NestedTree($this->registry->core . 'menu_items', $this->registry->params['id'], 'item');
    $rows = $tree->numDecendants(true);
    $menuBar = array('menus' => '/menu/overview', 'new_link' => '/menu/view/id-' . $this->registry->params['id'] . '/action-new');
    $this->content .= $this->makeToolbar($menuBar, 24);
    if ($rows > 0) {
        $items = $tree->getDecendants(true);
        $c = 0;
        $data = array();
        foreach ($items as $row) {
            if ($row['depth'] > 0) {
                if ($row['depth'] > 1) {
                    $r = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $row['depth'] - 1);
                    $r .= "&bull;&nbsp;" . $row['item'];
                    $data[$c][] = $r;
                } else {
                    $data[$c][] = $row['item'];
                }
                $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-edit/item-' . $row['item_id'] . '"><img src="/images/24x24/Edit3.png" class="Tips" title="Edit Item" rel="Click to edit the ' . $row['item'] . ' menu" /></a>';
                $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-delete/item-' . $row['item_id'] . '" ><img src="/images/24x24/DeleteRed.png" class="Tips" title="Delete item" rel="Click to delete the ' . $row['category'] . ' item" /></a>';
                $c++;
            }
        }
        $header = array('Menu Item', '', '');
        $table = $this->dataTable($data, $header);
    } else {
Пример #2
0
 protected function queryMenu($menu_id)
 {
     $menu = array();
     if ($this->status == "LI") {
         $status = "LO";
     } else {
         $status = "LI";
     }
     $tree = new NestedTree($this->db_table . 'menu_items', $menu_id, 'item');
     $decendants = $tree->getDecendants(true);
     $search_categories = null;
     if ($decendants) {
         foreach ($decendants as $key => $value) {
             $search_categories .= $decendants[$key]['item_id'] . ',';
         }
         $search_categories = substr($search_categories, 0, -1);
         $fields = 'item_id, item, status, url, enssl, page_id';
         $join = array($this->registry->core . 'menu_link_status', $this->db_table . 'menu_urls');
         $result = $this->registry->db->getResult($fields, 'menu_items', $join, array('WHERE' => "status != '" . $status . "'", 'AND' => 'item_id IN (' . $search_categories . ')', 'ORDER BY' => 'lft ASC'));
     } else {
         $result = false;
     }
     if ($result) {
         foreach ($result as $row) {
             $menu[] = Uthando::objectToArray($row);
         }
         foreach ($menu as $key => $value) {
             $return_menu[$key] = $value;
             if (is_numeric($value['page_id'])) {
                 $page = $this->registry->db->getResult('page', $this->db_table . 'pages', null, array('WHERE' => 'page_id=' . $value['page_id']), false);
                 $return_menu[$key]['page'] = $page->page;
             }
             $return_menu[$key]['lft'] = $decendants[$key]['lft'];
             $return_menu[$key]['rgt'] = $decendants[$key]['rgt'];
             $return_menu[$key]['depth'] = $decendants[$key]['depth'] - 1;
         }
         if ($return_menu) {
             foreach ($return_menu as $key => $value) {
                 $category[$key] = $value['lft'];
             }
             array_multisort($category, SORT_ASC, $return_menu);
         }
         return $return_menu;
     } else {
         return false;
     }
 }