function __construct($Request) { $this->Request = $Request; if (!$this->Launch()) { jf::run("view/_internal/error/404"); } }
protected function LoadRbac($RbacModule) { try { jf::run($RbacModule); } catch (ImportException $e) { return false; } return true; }
/** * Launches a system (admin interface) controller. Returns what the controller returns. * If it is false, a not found error is displayed. * @return boolean */ function Launch() { $Parts = explode("/", $this->Request); assert($Parts[0] == "sys"); // or $Parts [0] == "app" ); $Parts[0] = "control"; array_unshift($Parts, "jf"); //go system mode for import $RequestedModule = implode("/", $Parts); //load the controller module if (!$this->StartController($RequestedModule)) { //not found! if (!headers_sent()) { # no output done, this check prevents controllers that don't return true to fail jf::run("view/_internal/error/404"); } return false; } return true; }
/** * Outputs a nicely formatted error for web display * @param integer $errno * @param string $errstr * @param string $errfile * @param integer $errline * @param \Exception $exception * @return boolean */ function PresentError($errno, $errstr, $errfile, $errline, $exception = null) { if (!self::$PresentErrors) { return false; } jf::run("jf/view/_internal/error", array("errno" => $errno, "errstr" => $errstr, "errfile" => $errfile, "errline" => $errline, "exception" => $exception)); /* Don't execute PHP internal error handler */ return false; }
/** * Enforce a permission on current user * @param string|integer $Permission path or title or ID of permission */ function Enforce($Permission) { if (jf::CurrentUser() === null) { jf::run("view/_internal/error/401", array("Permission" => $Permission)); exit; } if (!$this->Check($Permission)) { jf::run("view/_internal/error/403", array("Permission" => $Permission)); exit; } }
/** * Outputs test suite run results in a web friendly interface * @param \PHPUnit_Framework_TestResult $Result * @param Profiler $Profiler */ function OutputResult($Result, $Profiler, $Coverage = null) { if (jf::$RunMode->IsCLI()) { $file = "cli"; } else { $file = 'web'; } jf::run("jf/view/_internal/test/result/{$file}", array("result" => $Result, "profiler" => $Profiler, "coverage" => $Coverage)); }
<?php /** * This is the pre-hook. It is run before the request is run, after everything is loaded. */ jf::run("config/transition"); $Stats = new StatsPlugin(); $Stats->Insert();
/** * After loading jFramework and libraries, use this function to run a request type * @param $Request the url request that is supposed to get run */ public function Run($Request = null) { if (!$this->Started) { throw new Exception("You should init jframework before trying to run a request"); return false; } if ($Request === null) { $Request = jf::$BaseRequest; } //fixing request by adding index page $Parts = explode("/", $Request); if ($Parts[count($Parts) - 1] == "") { $Parts[count($Parts) - 1] = self::$IndexPage; } $Request = implode("/", $Parts); jf::run("config/hook/pre"); //pre hook $r = $this->_Run($Request); jf::run("config/hook/post"); //post hook return $r->Result(); }