public function execute()
 {
     // get the controller
     $controllerClass = $this->getControllerClass();
     if (class_exists($controllerClass)) {
         // namespaced?
         $module = new $controllerClass();
     } else {
         if (($str = substr($controllerClass, 1)) && class_exists($str)) {
             // non namespaced?
             $module = new $str();
         } else {
             throw new ActionEnforcingException('Controller "' . $controllerClass . '" could not be loaded.', $this->context->getModuleName(), $this->context->getActionName());
         }
     }
     // get the action, module, extension of the action
     $extensionId = $this->context->getExtensionName();
     $moduleName = $this->context->getModuleName() ? Camelizer::firstToUpper($this->context->getModuleName()) : DEFAULT_MODULE_NAME;
     $action = $this->context->getActionName() ? Camelizer::firstToLower($this->context->getActionName()) : DEFAULT_ACTION_NAME;
     // Are we authorized to execute this action?
     $requestParameters = $this->context->getRequest()->getParameters();
     if (!tao_models_classes_accessControl_AclProxy::hasAccess($action, $moduleName, $extensionId, $requestParameters)) {
         $userUri = common_session_SessionManager::getSession()->getUserUri();
         throw new tao_models_classes_AccessDeniedException($userUri, $action, $moduleName, $extensionId);
     }
     // if the method related to the specified action exists, call it
     if (method_exists($module, $action)) {
         $this->context->setActionName($action);
         // search parameters method
         $reflect = new ReflectionMethod($module, $action);
         $parameters = $reflect->getParameters();
         $tabParam = array();
         foreach ($parameters as $param) {
             $tabParam[$param->getName()] = $this->context->getRequest()->getParameter($param->getName());
         }
         // Action method is invoked, passing request parameters as
         // method parameters.
         common_Logger::d('Invoking ' . get_class($module) . '::' . $action, array('GENERIS', 'CLEARRFW'));
         call_user_func_array(array($module, $action), $tabParam);
         // Render the view if selected.
         if ($module->hasView()) {
             $renderer = $module->getRenderer();
             echo $renderer->render();
         }
     } else {
         throw new ActionEnforcingException("Unable to find the action '" . $action . "' in '" . get_class($module) . "'.", $this->context->getModuleName(), $this->context->getActionName());
     }
 }
 /**
  * Constructor. Please use only getInstance to retrieve the single instance.
  * 
  * @see Context#getInstance
  */
 private function __construct()
 {
     $this->request = new Request();
     $this->response = new Response();
     $this->viewData = array();
     $this->behaviors = array();
     if (PHP_SAPI != 'cli') {
         try {
             $resolver = new Resolver();
             $this->extensionName = $resolver->getExtensionFromURL();
             $this->moduleName = Camelizer::firstToUpper($resolver->getModule());
             $this->actionName = Camelizer::firstToLower($resolver->getAction());
         } catch (ResolverException $re) {
             $this->extensionName = 'tao';
         }
     }
 }
Example #3
0
 public function __construct()
 {
     if (PHP_SAPI != 'cli') {
         try {
             $resolver = new Resolver();
             $this->extension = $resolver->getExtensionFromURL();
             $this->module = Camelizer::firstToUpper($resolver->getModule());
             $this->action = Camelizer::firstToLower($resolver->getAction());
         } catch (ResolverException $re) {
             $this->extension = 'tao';
         }
     }
     $this->epoch = time();
     $this->user = common_session_SessionManager::getSession()->getUserUri();
     $this->script = $_SERVER['PHP_SELF'];
     $this->system = new common_profiler_System();
 }