6.X/traits/menus.php
/**
     * Scan a menu for selected items
     *
     * Iterate through a menu, including sub-menus, and mark menu items that match the current URLs.
     *
     * @param $menu array Menu array
     */
Scan a menu for selected items
Iterate through a menu, including sub-menus, and mark menu items that match the current URLs.

@param $menu array Menu array
Scan a menu for selected items Iterate through a menu including sub - menus and mark menu items that match the current URLs . @param $menu array Menu array
public function scan_selected(&$menu)
    {
        $mr = 0;
        foreach ($menu as $n => $v) {
            $obtained_spath = [];
            if ($v['sub']) {
                $reserve_spath = $this->spath;
                $this->spath = [];
                $res = $this->scan_selected($v['sub']);
                $obtained_spath = $this->spath;
                $this->spath = $reserve_spath;
                $menu[$n]['sub'] = $v['sub'];
                if ($res > 0) {
                    $menu[$n]['ssel'] = $res;
                    $menu[$n]['sel'] = $v['sel'] = 1;
                }
                if ($res > 0) $mr = 1;
            }
            if ($v['sel'] > 0) {
                if(!$this->no_spath[$v['grp']]){
                    $this->add_to_spath($v);
                    foreach ($obtained_spath as $spv) {
                        $this->add_to_spath($spv);
                    }
                }
                $mr = 1;
            }
        }
        return $mr;
    }
public function scan_selected ( & $ menu ) { $ mr = 0 ; foreach ( $ menu as $ n => $ v ) { $ obtained_spath = [ ] ; if ( $ v [ 'sub' ] ) { $ reserve_spath = $ this -> spath ; $ this -> spath = [ ] ; $ res = $ this -> scan_selected ( $ v [ 'sub' ] ) ; $ obtained_spath = $ this -> spath ; $ this -> spath = $ reserve_spath ; $ menu [ $ n ] [ 'sub' ] = $ v [ 'sub' ] ; if ( $ res > 0 ) { $ menu [ $ n ] [ 'ssel' ] = $ res ; $ menu [ $ n ] [ 'sel' ] = $ v [ 'sel' ] = 1 ; } if ( $ res > 0 ) $ mr = 1 ; } if ( $ v [ 'sel' ] > 0 ) { if ( ! $ this -> no_spath [ $ v [ 'grp' ] ] ) { $ this -> add_to_spath ( $ v ) ; foreach ( $ obtained_spath as $ spv ) { $ this -> add_to_spath ( $ spv ) ; } } $ mr = 1 ; } } return $ mr ; }
Scan a menu for selected items
 Iterate through a menu, including sub-menus, and mark menu items that match the current URLs.
Scan a menu for selected items Iterate through a menu including sub - menus and mark menu items that match the current URLs .