public function langFromBrowser() { $browser_langs = explode(",", Ac::request()->languages()); foreach ($browser_langs as $i => $lang) { if (in_array($lang, $this->config("available_languages"))) { return $lang; } } return $this->config("default_language", 'en'); }
public function __construct() { parent::__construct(); $this->contentType("text/html"); $this->title = Ac::request()->directory(); $this->meta_description = ""; $this->meta_keywords = ""; $this->meta_robots = "INDEX,FOLLOW"; $this->link_canonical = Ac::router()->directoryUrl(); }
/** * Request validation function */ public function __validate($action = null) { $method = Ac::request()->method(); if (!isset($this->supports[$method])) { $this->status(405); return false; } elseif ($this->supports[$method] != '*' && !in_array(Ac::request()->format(), $this->supports[$method])) { $this->status(415); return false; } return true; }
/** * Get / Set the request * @param Ac_Http_Request $request The new request * @return Ac_Http_Request */ public static function &request(Ac_Http_Request &$request = null) { if (!empty($request)) { self::$request = $request; } return self::$request; }
public function resolve() { //Yet initialized if ($this->controller != null) { return true; } $request = Ac::trigger(__CLASS__ . "_before_" . __FUNCTION__, array('directoryUrl' => Ac::request()->directoryUrl(), 'resource' => Ac::request()->resource())); $this->directoryUrl = trim($request["directoryUrl"], ' /') . "/"; $this->resource = $rs = empty($request["resource"]) ? array() : explode("/", trim($request["resource"], " /")); // Prevent? to access duplicated content when accessing '/', '/index' and '/index/index' $r = strtolower(implode("/", $this->resource)); if ($r == "index" || $r == "index/index") { $this->resource = Ac::config("router.on_index") ? array(Ac::config("router.on_index")) : $this->resource; } $this->findController(); $this->findAction(); //die(print_r($this, true)); Ac::trigger(__CLASS__ . "_on_" . __FUNCTION__, $this); }