Beispiel #1
0
 /**
  * The main execute method called from index.php
  */
 public function execute()
 {
     global $argv;
     $func = Request::convertFunctionName('execute', $argv[2]);
     if (method_exists($this, $func)) {
         $this->{$func}();
     } else {
         $this->out('No handler found.');
     }
 }
Beispiel #2
0
    /**
     * Determine which handler in the page to run. This will automatically
     * determine if there is a form based on the submitted action variable.
     * If no action variable, it will call get() or post() or any other
     * rest method.
     */
    public function execute() {
        $request_type = strtolower(Request::type());

        if (!$this->hasAccess()) {
            Output::accessDenied();
        }

        if (!$this->validateToken()) {
            Navigation::redirect('/message?err=invalid_token');
        }

        // If there is a requested action.
        if ($action = Request::get('action')) {
            $method = Request::convertFunctionName($request_type, $action);
            if (method_exists($this, $method)) {
                $this->{$method}();
                $this->output();
            }
            else {
                Output::error('There was an error processing your submission.');
            }
        } else {
            if (method_exists($this, $request_type)) {
                $this->$request_type();
                $this->output();
            } else {
                // TODO: show 302
                Output::error('Method not available');
            }
        }
    }