<?php
if (!defined('_GNUBOARD_'))
  exit;

class Menu
{
  public $mid;
  public $name;
  public $order;
  public $target;
  public $icon;
  public $gnb_grp_div;

  public function __construct($mid, $name, $target, $order = 0, $icon = "", $gnb_grp_div = 0)
  {
    $this->mid = $mid;
    $this->name = $name;
    $this->order = $order;
    $this->target = $target;
    $this->icon = $icon;
    $this->gnb_grp_div = $gnb_grp_div;
  }
}

class MenuCategory extends Menu
{
  public $key;
  public $childmenu;

  public function __construct($key, $mid, $name, $target, $order = 0, $icon = '', $gnb_grp_div = 0)
  {
    $this->key = $key;
    $this->childmenu = [];
    parent::__construct($mid, $name, $target, $order, $icon, $gnb_grp_div);
  }

  public function addChildMenu($mid, $name, $target, $order = 0, $icon = '', $gnb_grp_div = 0)
  {
    $this->childmenu[] = new Menu($mid, $name, $target, $order, $icon, $gnb_grp_div);
    usort($this->childmenu, function($a, $b) {
      return $a->order - $b->order;
    });
  }

  public function buildHtml()
  {
    global $g5, $is_admin, $auth, $menu, $auth_menu, $sub_menu;
  }
}
