public function create() { $this->load->helper('recursive'); $this->menu->as_array(); $recursive = data_recursive($this->menu->get_all(), 'menu_id', 'menu_parent'); $this->data['menu'] = datagrid_recursive($recursive, 'menu_name'); $this->action->as_array(); $this->data['action'] = $this->action->get_all(); $this->view = 'sso/role/create'; }
public function index() { $udata = data_recursive($this->mn->fmn(), 'mid', 'mpar'); $recursive = datagrid_recursive($udata, 'mnme'); /* $this->header['breadcrumb'] = array(anchor('/', '<i class="fa fa-home"></i> Home'), $this->page['mnme']); */ $this->header['breadcrumb'] = array(anchor('/', '<i class="fa fa-home"></i> Home'), ''); $page = $this->uri->segment(4) ? $this->uri->segment(4) : 0; $config['base_url'] = base_url('sso/menus/index/'); $config['per_page'] = $this->perpage; $config['uri_segment'] = 4; $config['total_rows'] = count($recursive); $this->pagination->initialize($config); $data = array_slice($recursive, $page, $config['per_page']); $this->load->view('header', $this->header); $this->load->view('sso/test/indexlish', array('data' => $data, 'row' => count($recursive), 'links' => $this->pagination->create_links())); $this->load->view('footer', $this->footer); }
public function index() { if (!empty($this->input->get('search'))) { $this->_attr['data'] = $this->mn->fmn($this->input->get('search')); $this->_attr['row'] = count($this->_attr['data']); } else { $udata = data_recursive($this->mn->fmn(), 'mid', 'mpar'); $recursive = datagrid_recursive($udata, 'mnme'); $page = !empty($this->input->get('page')) ? $this->cfg->perpage * ($this->input->get('page') - 1) : 0; $config['base_url'] = base_url('sso/menus/'); $config['per_page'] = $this->cfg->perpage; $config['uri_segment'] = $this->cfg->segment; $config['total_rows'] = count($recursive); $this->pagination->initialize($config); $this->_attr['data'] = array_slice($recursive, $page, $config['per_page']); $this->_attr['row'] = count($recursive); } $this->_attr['breadcrumb'] = [anchor('/', '<i class="fa fa-home"></i> Home'), $this->cfg->page['mnme']]; $this->_attr['pagination'] = $this->pagination->create_links(); $this->template->load($this->cfg->template . '/default', 'sso/menu', $this->_attr); }
function datagrid_recursive($data = [], $name = NULL, $divider = '___', $tmpdata = [], $depth = 0) { $separator = NULL; for ($i = 0; $i < $depth; $i++) { $separator .= $divider; } if (!empty($data)) { foreach ($data as $val) { $d = $val['data']; if (!empty($name)) { $d[$name] = $separator . $d[$name]; } $d['_divider'] = $separator; $d['_depth'] = $depth; $tmpdata[] = $d; if (!empty($val['sub'])) { $newdepth = $depth + 1; $tmpdata = datagrid_recursive($val['sub'], $name, $divider, $tmpdata, $newdepth); } } } return $tmpdata; }
<th class="text-center">#</th> <th class="text-center">Menu name</th> <?php foreach ($acc_key as $v) { ?> <th class="text-center"><?php echo $v; ?> </th> <?php } ?> </tr> <?php $mdata = data_recursive($mdata, 'mid', 'mpar'); $recursive = datagrid_recursive($mdata, 'mnme'); if (!empty($recursive)) { foreach ($recursive as $v) { if ($v['mpar'] == FALSE) { continue; } ?> <tr> <th class="text-center"> <div class="checkbox all"><?php echo form_label(form_checkbox('mid_' . $v['mid'], '', '', 'data-mid="' . $v['mid'] . '"')); ?> </div> </th> <td><?php echo $v['mnme'];
protected function index() { $this->load->library(['pagination', 'table']); $page = !empty($this->uri->segment(4)) ? $this->_perpage * ($this->uri->segment(4) - 1) : 0; $config['base_url'] = base_url($this->_base . '/index/'); $config['total_rows'] = $this->{$this->router->fetch_class()}->count_all(); $this->_set_datagrid_header(isset($this->data['recursive']) ? $this->data['recursive'][1] : NULL); $unshift = [$this->_primary_key => 'Primary Key'] + $this->data['datagrid_header']; $items = $this->_get_items(); if (!empty($this->data['recursive'])) { $this->load->helper('recursive'); $recursive = data_recursive($this->{$this->router->fetch_class()}->as_array()->get_all(), $this->data['recursive'][0], $this->data['recursive'][1]); foreach (datagrid_recursive($recursive, $this->data['recursive'][2]) as $index => $row) { foreach ($row as $k => $v) { if (!empty($items) && array_key_exists($k, $items)) { $row[$k] = empty($v) ? $v : $items[$k][$v]; } } $this->data['datagrid'][$index] = array_intersect_key($row, $unshift); } $this->data['datagrid'] = array_slice($this->data['datagrid'], $page, $this->_perpage); $this->data['datagrid'] = array_to_object($this->data['datagrid']); } else { $this->{$this->router->fetch_class()}->order_by($this->_primary_key, 'ASC'); $this->{$this->router->fetch_class()}->limit($this->_perpage, $page); foreach ($this->{$this->router->fetch_class()}->get_all() as $index => $row) { $row = object_to_array($row); foreach ($row as $k => $v) { if (!empty($items) && array_key_exists($k, $items)) { $row[$k] = empty($v) ? $v : $items[$k][$v]; } } $row = array_intersect_key($row, $unshift); $this->data['datagrid'][$index] = array_to_object($row); } } $this->pagination->initialize($config); $this->data['links'] = $this->pagination->create_links(); }