Exemplo n.º 1
0
 /**
  * @author giorgio 19/ago/2014
  * 
  * recursively gets all the children of a given menu item
  * 
  * @param number $tree_id the id of the menu tree to load
  * @param number $parent_id the id of the parent to get children for
  * @param AMA_DataHandler $dbToUse the data handler to be used, either Common or Tester
  * @param boolean $get_all set it to true to get also disabled elements.
  * 
  * @return array of found children or null if no children found
  * 
  * @access private
  */
 private function get_menu_children_recursive($tree_id = 0, $parent_id, $dbToUse, $get_all)
 {
     $sql = 'SELECT MI.*, MT.extraClass AS menuExtraClass FROM `menu_items` AS MI JOIN `menu_tree` AS MT ON ' . 'MI.item_id=MT.item_id WHERE MT.tree_id=? AND MT.parent_id=?';
     if (!$get_all) {
         $sql .= ' AND MI.enabledON!="' . Menu::NEVER_ENABLED . '"';
     }
     $sql .= ' ORDER BY MI.order ASC';
     $res = $dbToUse->getAllPrepared($sql, array($tree_id, $parent_id), AMA_FETCH_ASSOC);
     if (AMA_DB::isError($res) || count($res) <= 0 || $res === false) {
         return null;
     } else {
         foreach ($res as $count => $element) {
             $res[$count]['children'] = $this->get_menu_children_recursive($tree_id, $element['item_id'], $dbToUse, $get_all);
         }
         return $res;
     }
 }