public function accept($method = 'index')
 {
     if (isset($this->controller)) {
         $cls = get_controller_class();
         if (is_array($this->controller)) {
             foreach ($this->controller as $p) {
                 if (preg_match($p, $cls)) {
                     return true;
                 }
             }
             return false;
         }
         if (!preg_match($this->controller, $cls)) {
             return false;
         }
     }
     if (is_array($this->pattern)) {
         foreach ($this->pattern as $p) {
             if (preg_match($p, $method)) {
                 return true;
             }
         }
         return false;
     }
     return preg_match($this->pattern, $method);
 }
Esempio n. 2
0
 public function getCurrentAction()
 {
     $controller = get_controller_class();
     $method = get_controller_method();
     $action = $this->getActionByController($controller, $method);
     if ($this->validAction($action)) {
         return $action;
     }
     return null;
 }
 /**
  * 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;
 }
Esempio n. 4
0
function get_controller_meta()
{
    $action = new Action();
    $action->controller = get_controller_class();
    $action->method = get_controller_method();
    $action->args = get_controller_args();
    return $action;
}
Esempio n. 5
0
/**
 * Find and include specific controller based on controller name
 *
 * @param string $controller_name
 * @param string $module_name
 * @return boolean
 * @throws FileDnxError if controller file does not exists
 */
function use_controller($controller_name, $module_name = DEFAULT_MODULE)
{
    $controller_class = get_controller_class($controller_name);
    if (class_exists($controller_class)) {
        return true;
    }
    // if
    $controller_file = APPLICATION_PATH . "/modules/{$module_name}/controllers/{$controller_class}.class.php";
    if (is_file($controller_file)) {
        include_once $controller_file;
        return true;
    } else {
        return new FileDnxError($controller_file, "Controller {$module_name}::{$controller_name} does not exists (expected location '{$controller_file}')");
    }
    // if
}