function classmap($classname)
{
    //Lowercase all part in classname to prevent some weird case name
    $classname = strtolower($classname);
    $classmapList = classmapList();
    $shortclassname = substr($classname, strlen('controller\\'));
    if (isset($classmapList[$shortclassname])) {
        return 'Controller' . DIRECTORY_SEPARATOR . $classmapList[$shortclassname];
    } else {
        return '';
    }
}
function classmap($classname)
{
    //Lowercase all part in classname to prevent some weird case name
    $classname = strtolower($classname);
    $classmapList = classmapList();
    $shortclassname = str_replace(array('\\controller\\', 'controller\\'), '', $classname);
    if (isset($classmapList[$shortclassname])) {
        return 'Controller' . DIRECTORY_SEPARATOR . $classmapList[$shortclassname];
    } else {
        return '';
    }
}
Exemple #3
0
 public function delegate()
 {
     // Analyze route
     $this->getController($module, $controller, $action, $args);
     //assign args
     $this->extractArgs($args);
     $me = new \Model\User();
     $me->updateFromSession($this->registry);
     if ($me->checkPerm($this->registry, $notfound, $notlogin)) {
         $this->registry->me = $me;
     } elseif ($notfound) {
         $classmapList = classmapList();
         if (isset($classmapList[$module . '\\notfound'])) {
             $controller = 'notfound';
         } else {
             $module = 'site';
             $controller = 'notfound';
         }
     } elseif ($notlogin) {
         $returnUrl = base64_encode(Helper::curPageURL());
         $classmapList = classmapList();
         if (isset($classmapList[$module . '\\login'])) {
             $controller = 'login';
             $redirectUrl = $this->registry->conf['rooturl_' . $module] . 'login?redirect=' . $returnUrl;
         } else {
             $module = 'site';
             $controller = 'login';
             $redirectUrl = $this->registry->conf['rooturl'] . 'login?redirect=' . $returnUrl;
         }
         $this->registry->response->setStatusCode(302);
         $this->registry->response->headers->set('location', $redirectUrl);
     }
     if (!$notlogin) {
         //reassign module, controller and action because it can be change on the conditions above
         $this->registry->module = $module;
         $this->registry->controller = $controller;
         $this->registry->action = $action;
         // Initiate the class
         $class = '\\controller\\' . $module . '\\' . $controller;
         $controller = new $class($this->registry);
         //refine action string : append Action
         $action .= 'Action';
         // Run action
         $controller->{$action}();
     }
 }