Elgg  Version 2.3
Namespaces | Functions | Variables
pagehandler.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Activate a plugin or plugins.
 

Functions

 elgg_register_page_handler ($identifier, $function)
 Registers a page handler for a particular identifier. More...
 
 elgg_unregister_page_handler ($identifier)
 Unregister a page handler for an identifier. More...
 
 elgg_gatekeeper ()
 Used at the top of a page to mark it as logged in users only. More...
 
 gatekeeper ()
 Alias of elgg_gatekeeper() More...
 
 elgg_admin_gatekeeper ()
 Used at the top of a page to mark it as admin only. More...
 
 admin_gatekeeper ()
 Alias of elgg_admin_gatekeeper() More...
 
 elgg_group_gatekeeper ($forward=true, $group_guid=null)
 May the current user access item(s) on this page? If the page owner is a group, membership, visibility, and logged in status are taken into account. More...
 
 group_gatekeeper ($forward=true, $page_owner_guid=null)
 May the current user access item(s) on this page? If the page owner is a group, membership, visibility, and logged in status are taken into account. More...
 
 elgg_entity_gatekeeper ($guid, $type=null, $subtype=null, $forward=true)
 Can the viewer see this entity? More...
 
 elgg_ajax_gatekeeper ()
 Require that the current request be an XHR. More...
 
 elgg_front_page_handler ()
 Front page handler. More...
 
 elgg_error_page_handler ($hook, $type, $result, $params)
 Serve an error page. More...
 
 elgg_ok_response ($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
 Prepares a successful response to be returned by a page or an action handler. More...
 
 elgg_error_response ($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
 Prepare an error response to be returned by a page or an action handler. More...
 
 elgg_redirect_response ($forward_url=REFERRER, $status_code=ELGG_HTTP_FOUND)
 Prepare a silent redirect response to be returned by a page or an action handler. More...
 
 _elgg_page_handler_init ()
 Initializes the page handler/routing system. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_page_handler_init ( )

Initializes the page handler/routing system.

Returns
void private

Definition at line 363 of file pagehandler.php.

admin_gatekeeper ( )

Alias of elgg_admin_gatekeeper()

Used at the top of a page to mark it as logged in admin or siteadmin only.

Returns
void

Definition at line 100 of file pagehandler.php.

elgg_admin_gatekeeper ( )

Used at the top of a page to mark it as admin only.

Returns
void
Since
1.9.0

Definition at line 83 of file pagehandler.php.

elgg_ajax_gatekeeper ( )

Require that the current request be an XHR.

If not, execution of the current function will end and a 400 response page will be sent.

Returns
void
Since
1.12.0

Definition at line 237 of file pagehandler.php.

elgg_entity_gatekeeper (   $guid,
  $type = null,
  $subtype = null,
  $forward = true 
)

Can the viewer see this entity?

Tests if the entity exists and whether the viewer has access to the entity if it does. If the viewer cannot view this entity, it forwards to an appropriate page.

Parameters
int$guidEntity GUID
string$typeOptional required entity type
string$subtypeOptional required entity subtype
bool$forwardIf set to true (default), will forward the page; if set to false, will return true or false.
Returns
bool Will return if $forward is set to false.
Since
1.9.0

Definition at line 187 of file pagehandler.php.

elgg_error_page_handler (   $hook,
  $type,
  $result,
  $params 
)

Serve an error page.

This is registered by Elgg for the 'forward', '404' plugin hook. It can registered for other hooks by plugins or called directly to display an error page.

Parameters
string$hookThe name of the hook
string$typeHttp error code
bool$resultThe current value of the hook
array$paramsParameters related to the hook
Returns
void

Definition at line 267 of file pagehandler.php.

elgg_error_response (   $error = '',
  $forward_url = REFERRER,
  $status_code = ELGG_HTTP_OK 
)

Prepare an error response to be returned by a page or an action handler.

Parameters
string$errorError message Can be used by handlers to display an error message For certain requests this error message will also be used as the response body
string$forward_urlURL to redirect the client to Can be used by handlers to redirect the client on non-ajax requests
int$status_codeHTTP status code Status code of the HTTP response For BC reasons and due to the logic in the client-side AJAX API, this defaults to 200. Note that the Router and AJAX API will treat these responses as error in spite of the HTTP code assigned
Returns

Definition at line 333 of file pagehandler.php.

elgg_front_page_handler ( )

Front page handler.

Returns
bool

Definition at line 249 of file pagehandler.php.

elgg_gatekeeper ( )

Used at the top of a page to mark it as logged in users only.

Returns
void
Since
1.9.0

Definition at line 58 of file pagehandler.php.

elgg_group_gatekeeper (   $forward = true,
  $group_guid = null 
)

May the current user access item(s) on this page? If the page owner is a group, membership, visibility, and logged in status are taken into account.

Parameters
bool$forwardIf set to true (default), will forward the page; if set to false, will return true or false.
int$group_guidThe group that owns the page. If not set, this will be pulled from elgg_get_page_owner_guid().
Returns
bool Will return if $forward is set to false.
Since
1.9.0

Definition at line 117 of file pagehandler.php.

elgg_ok_response (   $content = '',
  $message = '',
  $forward_url = null,
  $status_code = ELGG_HTTP_OK 
)

Prepares a successful response to be returned by a page or an action handler.

Parameters
mixed$contentResponse content In page handlers, response content should contain an HTML string In action handlers, response content can contain either a JSON string or an array of data
string$messageSystem message visible to the client Can be used by handlers to display a system message
string$forward_urlForward URL Can be used by handlers to redirect the client on non-ajax requests
int$status_codeHTTP status code Status code of the HTTP response (defaults to 200)
Returns

Definition at line 310 of file pagehandler.php.

elgg_redirect_response (   $forward_url = REFERRER,
  $status_code = ELGG_HTTP_FOUND 
)

Prepare a silent redirect response to be returned by a page or an action handler.

Parameters
string$forward_urlRedirection URL Relative or absolute URL to redirect the client to
int$status_codeHTTP status code Status code of the HTTP response Note that the Router and AJAX API will treat these responses as redirection in spite of the HTTP code assigned Note that non-redirection HTTP codes will throw an exception
Returns
Exceptions

Definition at line 353 of file pagehandler.php.

elgg_register_page_handler (   $identifier,
  $function 
)

Registers a page handler for a particular identifier.

For example, you can register a function called 'blog_page_handler' for the identifier 'blog' For all URLs http://yoururl/blog/*, the blog_page_handler() function will be called. The part of the URL marked with * above will be exploded on '/' characters and passed as an array to that function. For example, the URL http://yoururl/blog/username/friends/ would result in the call: blog_page_handler(array('username','friends'), blog);

A request to register a page handler with the same identifier as previously registered handler will replace the previous one.

The context is set to the identifier before the registered page handler function is called. For the above example, the context is set to 'blog'.

Page handlers should return true to indicate that they handled the request. Requests not handled are forwarded to the front page with a reason of 404. Plugins can register for the 'forward', '404' plugin hook.

See also
forward()
Parameters
string$identifierThe page type identifier
string$functionYour function name
Returns
bool Depending on success

Definition at line 34 of file pagehandler.php.

elgg_unregister_page_handler (   $identifier)

Unregister a page handler for an identifier.

Note: to replace a page handler, call elgg_register_page_handler()

Parameters
string$identifierThe page type identifier
Since
1.7.2
Returns
void

Definition at line 48 of file pagehandler.php.

gatekeeper ( )

Alias of elgg_gatekeeper()

Used at the top of a page to mark it as logged in users only.

Returns
void

Definition at line 73 of file pagehandler.php.

group_gatekeeper (   $forward = true,
  $page_owner_guid = null 
)

May the current user access item(s) on this page? If the page owner is a group, membership, visibility, and logged in status are taken into account.

Parameters
bool$forwardIf set to true (default), will forward the page; if set to false, will return true or false.
int$page_owner_guidThe current page owner guid. If not set, this will be pulled from elgg_get_page_owner_guid().
Returns
bool Will return if $forward is set to false.

Definition at line 168 of file pagehandler.php.

Variable Documentation

Definition at line 367 of file pagehandler.php.