コード例 #1
0
ファイル: Amslib_Router_URL.php プロジェクト: hakosh/amslib
 /**
  * 	method:	getURL
  *
  *	A method to obtain the url via it's name, group, language and domain
  *
  *	params
  *		$name	-	The name of the route to request
  *		$group	-	The group this route belongs to, allows selecting a route with a similar
  *					name, specifying the group directly
  *		$lang	-	The language for the url to return
  *		$domain	-	The domain of the route, this might be because a router from another URI was
  *					imported, meaning a router contains multiple routers, each segregated by their domain
  *
  *	notes:
  *		-	The $domain parameter is not really the domain, it's the "location", it CAN BE
  *			the domain, but it's not explicitly ONLY THIS, it can be any URI
  */
 public static function getURL($name = NULL, $group = NULL, $lang = "default", $domain = NULL)
 {
     return Amslib_Router::getURL($name, $group, $lang, $domain);
 }
コード例 #2
0
 /**
  * 	method:	__construct
  *
  * 	todo: write documentation
  *
  * 	notes:
  * 		-	The object is basically hard coded to ONLY use $_POST as an input source, but this might not be true
  * 		-	In situations where $_GET is used, you'd need to post some parameters through $_GET, others $_POST
  * 		-	So this should be made more flexible, so the webservice can define the input source and this accomodates
  */
 public function __construct()
 {
     //	Reset the service data and session structures
     $this->data = array();
     $this->session = array(self::HD => array());
     //	FIXME: we are hardcoding a route "home" which might not exist, this could be a bad idea
     $default_url = Amslib_Router::getURL("home");
     $url_return = Amslib_POST::get("url_return", Amslib_POST::get("return_url", $default_url));
     $url_return = Amslib_String::rchop($url_return, "?");
     $url_success = Amslib_POST::get("url_success", Amslib_POST::get("success_url", $url_return));
     $url_success = Amslib_String::rchop($url_success, "?");
     $url_failure = Amslib_POST::get("url_failure", Amslib_POST::get("failure_url", $url_return));
     $url_failure = Amslib_String::rchop($url_failure, "?");
     //	TODO:	I should remove all the url parameters from the source data so it doesn't pass through as data
     //	NOTE:	well then in this case perhaps I should have to namespace them too so they are in a separate
     //			part of the source data and not obvious "url_return" might be a bit generic
     //	NOTE:	but if I namespace them, I don't want to pass that complexity onto the programmer
     //	NOTE:	perhaps this means I need to add functions to build these parameters for the programmer
     //			instead of making them build them personally
     $this->setSuccessURL($url_success);
     $this->setFailureURL($url_failure);
     //	blank the appropriate session key to stop previous sessions overlapping
     //	NOTE:	what if you are using the json output? then there is no key to erase,
     //			so you're just creating session keys and not using them
     Amslib_SESSION::get(self::SR, false, true);
     //	Obtain the old return_ajax parameter, either as json or false
     $return_ajax = Amslib_POST::get("return_ajax", false) ? "json" : false;
     //	Obtain the new output_format parameter, or default to the return_ajax value if not found
     $format = Amslib_POST::get("output_format", $return_ajax);
     //	Sanitise the format to be one of three possible options, or default to false
     //	NOTE: we might want to use redirect, but we cannot store anything useful in the session
     //	NOTE: however this is valid reasoning: to do the job, redirect, but don't bother writing session data cause it cannot be used
     if (!in_array($format, array(false, "json", "session"))) {
         $format = false;
     }
     //	Now it should be safe to set the output format, false will of course reset
     $this->setOutputFormat($format);
     //	Initialise all the terminator groups that can exist
     $this->terminatorList = array_fill_keys(array("common", "success", "failure"), array());
 }