public function set_htmlspecialchars_mode($mode = ENT_QUOTES) { switch ($mode) { case ENT_COMPAT: case ENT_QUOTES: case ENT_NOQUOTES: case ENT_IGNORE: case ENT_SUBSTITUTE: case ENT_DISALLOWED: case ENT_HTML401: case ENT_XML1: case ENT_XHTML: case ENT_HTML5: self::$_htmlspecialchars_mode = $mode; return; } self::$_htmlspecialchars_mode = ENT_QUOTES; }
public function __construct() { if (self::$_object === null) { self::$_object = \Phpfox_Request::instance(); } }
/** * * Retorna a instância da requisição * * @return Request * */ public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * Break a URL down into its relevant parts. * * This class will break it down into controller and index, and then all of * the GET parameters. If we are using a custom route then there will be no * controller/action in the URL. * * @access public * @param string $url The URL to parse. * @param boolean $setControllerAction Whether we need a controller/action from the URL. * @static */ public static function setUrlFragments($url = null, $setControllerAction = false) { // Breakdown the request the user made into manageable fragments $urlFragments = array_filter(explode('/', $url ?: self::$_url)); // Chunk them into variable => value $url = array(); $urlFragments = array_chunk($urlFragments, 2); // If this is a basic route (not custom) then grab the controller/action if ($setControllerAction) { $url = array('controller' => isset($urlFragments[0][0]) ? ucfirst($urlFragments[0][0]) : 'Index', 'action' => isset($urlFragments[0][1]) ? $urlFragments[0][1] : 'index'); // And remove the first chunk so it is not set in the GET array unset($urlFragments[0]); } // The URL is now comprised of only GET variables, so set them // If a variable has no specified value then it is set to boolean true foreach ($urlFragments as $urlFragment) { $url[$urlFragment[0]] = isset($urlFragment[1]) ? $urlFragment[1] : true; } // Merge the route GETs with the explicitly stated GETs (?var=val) // We give priority to GET variables set via /var/value $_GET = array_merge($_GET, $url); // We want all requests to the GET and POST to be through this class to // .. provide a common interface, so we unset the globals. self::$_get = $_GET; self::$_post = $_POST; self::$_server = $_SERVER; unset($_GET, $_POST, $_SERVER); }