All pastes #972386 Raw Edit

controller

public text v1 · immutable
·published 2008-04-05 12:00 UTC
rendered paste body
protected static function instance() {
		return self::getInstanceOf(get_class());
	}

	/**
	 * Returns the base URL
	 *
	 * @return string base URL
	 */
	public static function get_base_url() {
		return Controller::instance()->base_url;
	}

	/**
	 * Returns the stub in its entirety
	 *
	 * @return  string  the URL incoming stub
	 */
	public static function get_stub() {
		return Controller::instance()->stub;
	}

	/**
	 * Returns the full requested URL
	 *
	 * @return string The full requested URL
	 */
	public function get_full_url() {
		return self::get_base_url() . self::get_stub();
	}

	/**
	 * Returns the action
	 *
	 * @return  string name of action
	 */
	public static function get_action() {
		return Controller::instance()->action;
	}

	/**
	 * Returns the action handler
	 *
	 * @return  object  handler object
	 */
	public static function get_handler() {
		return Controller::instance()->handler;
	}

	/**
	 * Returns the action handler's variables
	 *
	 * @return  array  variables used by handler
	 */
	public static function get_handler_vars() {
		return Controller::instance()->handler->handler_vars;
	}

	/**
	 * A convenience method for returning a handler variable (handler_var).
	 * This includes parameters set on the url, and fields submitted by POST.
	 * The alternative to this, while possible to write, is just too long.
	 * @param string $name The name of the variable to return.
	 * @return mixed The value of that variable in the handler
	 */
	public static function get_var( $name ) {
		return isset( Controller::instance()->handler->handler_vars[ $name ] ) ? Controller::instance()->handler->handler_vars[ $name ] : NULL;