/** * This sets up our "action models", determined by the requested object. * @param Request $request * @param Model $model * @return mixed */ public static function doAction(Request $request, Model $model) { $class = ucfirst($request->method) . ucfirst($request->getObject()); $directory = $request->getObject(); if (file_exists(__DIR__ . '/models/' . $directory . '/' . $class . '.php')) { require_once __DIR__ . '/models/' . $directory . '/' . $class . '.php'; } $nameSpace = "models\\" . $directory . "\\"; $fqcn = $nameSpace . $class; if (class_exists($fqcn)) { return new $fqcn($request, $model); } else { $request->setObject('error'); $request->refreshPage(); } }
/** * Default entry point */ public function route() { $method = Request::getObject()->get(0); // This checks whether there is a public method with the specified name if (in_array($method, get_class_methods($this))) { $this->{$method}(); } else { $this->main(); } }
public static function route() { $class = Request::getObject()->getRequestedClass(); $module = Core::constructObject($class); if ($module !== null) { $module->route(); } else { self::throwError("Could not instantiate object of type '{$class}' for this route."); } }
public function loginWithCookies() { // Try to login with user data from cookie $udata = Request::getObject()->getCookie('udata'); if ($udata != null && strpos($udata, '|') !== false) { list($email, $pw) = explode('|', $udata, 2); return $this->login($email, $pw, true); } return $this->loginAsGuest(); }
public static function build($uri, $host = false) { $uri = Request::getObject()->normalizeURI($uri); if (strpos($uri, '://') === false) { $root = Config::get("general.url"); if ($host == false) { $root = parse_url($root, PHP_URL_PATH); } return $root . $uri; } else { return $uri; } }
private function loadSID() { // Get Session ID from Cookie / Query-String $cookie = Request::getObject()->getCookie('sid'); if (strlen($cookie) == 32) { return $cookie; } $query = Request::get('s'); if (strlen($query) == 32) { return $query; } return null; }
/** * This sets up our main models, determined by the object requested. * @param Request $request * @param null $secondaryObject * @return mixed */ public static function build(Request $request, $secondaryObject = null) { if (null !== $secondaryObject) { $directory = $secondaryObject; $class = ucfirst($secondaryObject); } else { $directory = $request->getObject(); $class = ucfirst($request->getObject()); } if (file_exists(__DIR__ . '/../app/models/' . $directory . '/' . $class . '.php')) { require_once __DIR__ . '/../app/models/' . $directory . '/' . $class . '.php'; } $nameSpace = "models\\" . $directory . "\\"; $fqcn = $nameSpace . $class; if (class_exists($fqcn)) { return new $fqcn($request); } else { $request->setObject('error'); //Not working yet! //$request->parameters['errorCode'] = 404; $request->refreshPage(); } }
/** * Returns a value from the $_REQUEST array. * * You have to specify the index of the $_REQUEST-array. The second parameter * is the type of the variable. Default is VAR_NONE. You can specify thw * following constants: VAR_NONE, VAR_DB, VAR_INT, VAR_ALNUM, VAR_ARR_NONE, * VAR_ARR_STR, VAR_ARR_INT, VAR_ARR_ALNUM, VAR_HTML, VAR_ARR_HTML. * With the third parameter you can specify a default value, which will be set * when the $_REQUEST-array does not contain an entry with the specified index. * * @param string Index * @param int Type of variable * @param mixed Default value * @return mixed Value for specified index * @static **/ public static function get($index, $type = VAR_NONE, $standard = null) { $value = null; if (is_int($index)) { $value = Request::getObject()->getArg($index); } else { if (isset($_REQUEST[$index])) { $value = $_REQUEST[$index]; } } return Sanitize::save($value, $type, $standard); }