/** * Reading the top navigation from the database first, if can't find any, using the * configuration file to retrieve all the first level navigations */ public function getNavigations() { if ($this->CI->input->get('clear_navi')) { $this->clear(); } if (isset($this->current_navigations)) { return $this->current_navigations; } $main = $this->getMainNavigations(); // Get current action $action = $this->action_model->getCurrentAction(); if (!$action) { // Testing for current navigation $controller = get_controller_class(); $method = 'index'; if (get_breadscrums()) { $last = array_pop(get_breadscrums()); $last = explode('/', $last); $controller = $last[0]; if (count($last) > 1) { $method = $last[1]; } } $action = $this->action_model->getActionByController($controller, $method); } if ($action) { $action->subnavi = $this->_getSubNavigations($action->name); while ($action->group != 'main_navigation') { $action_siblings = $this->_getSubNavigations($action->group); $arr = array(); foreach ($action_siblings as $n) { if ($n->name == $action->name) { $n->current = true; if (isset($action->subnavi)) { $n->subnavi = $action->subnavi; } } $arr[] = $n; } $action = $this->action_model->getActionByName($action->group); $action->subnavi = $arr; } foreach ($main as $navi) { if ($navi->name == $action->name) { $navi->current = true; if (isset($action->subnavi)) { $navi->subnavi = $action->subnavi; } } } } $this->current_navigations = $main; return $main; }
/** * Need to use transaction to fix the problem that the datatable and listview can't use together */ public function index($type = '') { ci_log('breadscrums', get_breadscrums()); $this->session->unset_userdata('need_to_redirect_url'); $data = array(); $this->stickup(); if ($type == 'test') { $this->log('Navigations is ', $this->navigation->getNavigations()); $this->less('home/welcome_css'); $this->render('welcome_message', $data); } else { $this->less('home/index_css'); $this->render('index', $data); } }
function smarty_block_cancel_button($params, $content = '', $template, &$repeat) { if ($repeat) { return; } $breadscrums = get_breadscrums(); if (count($breadscrums) > 1) { array_pop($breadscrums); } $url = array_pop($breadscrums); $params['tag'] = 'a'; $params['href'] = site_url($url); $params['title'] = $url; return pinet_smarty_create_button($params, $content); }
function set_breadscrum() { $CI =& get_instance(); if ($CI->input->is_cli_request()) { // Skip the breadscrum for cli request return; } if (isset($CI->action_model) && !$CI->action_model->getCurrentAction()) { return; } $CI->load->library('session'); $scrums = get_breadscrums(); if (count($scrums) && get_request_url() == $scrums[count($scrums) - 1]) { return; } $scrums[] = get_request_url(); if (count($scrums) > get_ci_config('breadscrum_depth', 5)) { array_shift($scrums); } $CI->session->set_userdata('bread_scrums', $scrums); }