/** * _makeVC method returns structure video catalogs. * * @param array $menuitems * @param int $id * @return array $menu */ function _makeVC($menuitems, $id = 0) { $menu = array(); foreach ($menuitems as $item) { $vcitem = array(); if ($item->parent_id == $id) { $vcitem['id'] = $item->vcid; $vcitem['text'] = $item->vcname . ' (' . $item->video_counts . ')'; $children = _makeVC($menuitems, $item->vcid); if (count($children) > 0) { $vcitem['state'] = 'open'; $vcitem['children'] = $children; } array_push($menu, $vcitem); } } if (count($menu) <= 0) { return null; } return $menu; }
/** * jsgetVCatalogList method get all video_catalogs in struture. * * Option: Values * -------------- * null * * @param null * @return string json_encode($result) */ public function jsgetVCatalogList() { if (!$this->session->userdata('login')) { return false; } $result = array(); $this->load->model('VideoCatalogs_model'); $data = $this->VideoCatalogs_model->getCatalogs(array()); header('Content-type: text/plain'); $this->load->helper(array('menutool')); $result = _makeVC($data); echo json_encode($result); }