Class GP_Route

Description

Base controller class

Located in /gp-includes/route.php (line 5)


	
			
Direct descendents
Class Description
GP_Route_Main Holds common functionality for routes.
Variable Summary
Method Summary
GP_Route __construct ()
void after_request ()
void before_request ()
void can ( $action, [ $object_type = null], [ $object_id = null])
void cannot_and_redirect (string $action, [ $object_type = null], [string $object_id = null], [string $url = null])
void can_or_forbidden ( $action, [ $object_type = null], [ $object_id = null], [ $message = 'You are not allowed to do that!'])
void die_with_error ( $message, [ $status = 500])
void exit_ ([ $message = 0])
void header ( $string)
void headers_for_download ( $filename)
bool invalid_and_redirect (object $thing, [string $url = null])
void redirect ([ $url = null])
void redirect_with_error ( $message, [ $url = null])
void status_header ( $status)
void tmpl (string $template, [array $args = array()], [bool|string $honor_api = true])
void tmpl_404 ( $args)
bool validate (object $thing)
Variables
mixed $api = false (line 7)
mixed $errors = array() (line 9)
mixed $exited = false (line 15)
mixed $exit_message (line 16)
mixed $fake_request = false (line 14)
mixed $headers = array() (line 22)
mixed $loaded_template = null (line 20)
mixed $notices = array() (line 10)
mixed $redirected = false (line 17)
mixed $redirected_to = null (line 18)
mixed $rendered_template = false (line 19)
mixed $request_running = false (line 11)
mixed $template_output = null (line 21)
mixed $template_path = null (line 12)
Methods
Constructor __construct (line 24)
GP_Route __construct ()
after_request (line 37)
void after_request ()
before_request (line 33)
void before_request ()
can (line 79)
void can ( $action, [ $object_type = null], [ $object_id = null])
  • $action
  • $object_type
  • $object_id
cannot_and_redirect (line 91)

If the current user isn't allowed to do an action, redirect and exit the current request

void cannot_and_redirect (string $action, [ $object_type = null], [string $object_id = null], [string $url = null])
  • string $action
  • string $object_id
  • string $url: The URL to redirect. Default value: referrer or index page, if referrer is missing
  • $object_type
can_or_forbidden (line 100)
void can_or_forbidden ( $action, [ $object_type = null], [ $object_id = null], [ $message = 'You are not allowed to do that!'])
  • $action
  • $object_type
  • $object_id
  • $message
die_with_error (line 28)
void die_with_error ( $message, [ $status = 500])
  • $message
  • $status
exit_ (line 190)
void exit_ ([ $message = 0])
  • $message
header (line 198)
void header ( $string)
  • $string
headers_for_download (line 134)
void headers_for_download ( $filename)
  • $filename
invalid_and_redirect (line 70)

Same as validate(), but redirects to $url if the thing isn't valid.

Note: this method calls $this->exit_() after the redirect and the code after it won't be executed.

  • return: whether the thing is valid
bool invalid_and_redirect (object $thing, [string $url = null])
  • object $thing: a GP_Thing instance to validate
  • string $url: where to redirect if the thing doesn't validate
logged_in_or_forbidden (line 108)
void logged_in_or_forbidden ()
redirect (line 119)
void redirect ([ $url = null])
  • $url
redirect_with_error (line 114)
void redirect_with_error ( $message, [ $url = null])
  • $message
  • $url
set_notices_and_errors (line 144)
void set_notices_and_errors ()
status_header (line 207)
void status_header ( $status)
  • $status
tmpl (line 166)

Loads a template.

void tmpl (string $template, [array $args = array()], [bool|string $honor_api = true])
  • string $template: template name to load
  • array $args: Associative array with arguements, which will be exported in the template PHP file
  • bool|string $honor_api: If this is true or 'api' and the route is processing an API request the template name will be suffixed with .api. The actual file loaded will be template.api.php
tmpl_404 (line 186)
void tmpl_404 ( $args)
  • $args
validate (line 54)

Validates a thing and add its errors to the route's errors.

  • return: whether the thing is valid
bool validate (object $thing)
  • object $thing: a GP_Thing instance to validate

Documentation generated on Fri, 18 May 2012 01:46:05 +0100 by phpDocumentor 1.4.3