public
|
|
public static
|
#
history( pagesBack $pagesBack = 1 )
Return a URL from this user's navigation history.
Return a URL from this user's navigation history.
Parameters
- $pagesBack
- pagesBack The number of pages back to go. The default, 1, returns the previous
page.
|
public static
|
#
addRules( mixed $priority, mixed $rules )
Add URL matching rules to the Director.
Add URL matching rules to the Director.
The director is responsible for turning URLs into Controller objects. It does
thi
Parameters
- $priority
- $priority The priority of the rules; higher values will get your rule checked
first. We recommend priority 100 for your site's rules. The built-in rules are
priority 10, standard modules are priority 50.
- $rules
|
public static
|
#
direct( mixed $url )
Process the given URL, creating the appropriate controller and executing
it.
Process the given URL, creating the appropriate controller and executing
it.
Request processing is handled as folows: - Director::direct() creates a new
SS_HTTPResponse object and passes this to Director::handleRequest(). -
Director::handleRequest($request) checks each of the Director rules and
identifies a controller to handle this request. -
Controller::handleRequest($request) is then called. This will find a rule to
handle the URL, and call the rule handling method. -
RequestHandler::handleRequest($request) is recursively called whenever a rule
handling method returns a RequestHandler object.
In addition to request processing, Director will manage the session, and
perform the output of the actual response to the browser.
Parameters
- $url
- $url String, the URL the user is visiting, without the querystring.
Uses
Director::handleRequest()rule-lookup logic is handled by this.
Controller::run() Controller::run() handles the page logic for a
Director::direct() call.
|
public static
SS_HTTPResponse
|
#
test( string $url, array $postVars = null, Session $session = null, string $httpMethod = null, string $body = null, array $headers = null, array $cookies = null )
Test a URL request, returning a response object.
Test a URL request, returning a response object.
This method is the counterpart of Director::direct() that is used in
functional testing. It will execute the URL given,
Parameters
- $url
- string $url The URL to visit
- $postVars
- array $postVars The $_POST & $_FILES variables
- $session
- Session $session The
Session object representing the current session. By
passing the same object to multiple calls of Director::test(), you can simulate
a peristed session.
- $httpMethod
- string $httpMethod The HTTP method, such as GET or POST. It will default to POST
if postVars is set, GET otherwise. Overwritten by $postVars['_method'] if
present.
- $body
- string $body The HTTP body
- $headers
- array $headers HTTP headers with key-value pairs
- $cookies
- array $cookies to populate $_COOKIE
Returns
Uses
getControllerForURL() The rule-lookup logic is handled by this.
Controller::run() Controller::run() handles the page logic for a
Director::direct() call.
Used by
|
protected static
SS_HTTPResponse|string
|
#
handleRequest( SS_HTTPRequest $request, Session $session )
Handle an HTTP request, defined with a SS_HTTPRequest object.
Handle an HTTP request, defined with a SS_HTTPRequest object.
Returns
Used by
|
public static
|
#
urlParam( mixed $name )
Returns the urlParam with the given name
Returns the urlParam with the given name
|
public static
|
#
urlParams( )
Returns an array of urlParams
Returns an array of urlParams
|
public static
SiteTree
|
#
get_current_page( )
Return the SiteTree object that is currently being viewed. If there
is no sitetree object to return, then this will return the current
controller.
Return the SiteTree object that is currently being viewed. If there
is no sitetree object to return, then this will return the current
controller.
Returns
|
public static
|
#
set_current_page( SiteTree $page )
Set the currently active SiteTree object that is being used to
respond to the request.
Set the currently active SiteTree object that is being used to
respond to the request.
Parameters
|
public static
|
|
public static
|
#
absoluteURL( mixed $url, mixed $relativeToSiteBase = false )
Turns the given URL into an absolute URL.
Turns the given URL into an absolute URL.
|
public static
boolean|string
|
#
protocolAndHost( )
Returns the part of the URL, 'http://www.mysite.com'.
Returns the part of the URL, 'http://www.mysite.com'.
Returns
boolean|string The domain from the PHP environment. Returns FALSE is this environment variable
isn't set.
|
public static
|
#
redirect( mixed $url, mixed $code = 302 )
Redirect to another page.
- $url can be an absolute URL
- or it can be a URL relative to the "site base"
- if it is just a word without an slashes, then it redirects to another action
on the current controller.
Redirect to another page. - $url can be an absolute URL - or it can be a URL
relative to the "site base" - if it is just a word without an slashes, then it
redirects to another action on the current controller.
|
public static
string
|
#
redirected_to( )
Tests whether a redirection has been requested.
Tests whether a redirection has been requested.
Returns
string If redirect() has been called, it will return the URL redirected to. Otherwise,
it will return null;
|
public static
|
#
set_status_code( mixed $code )
Sets the HTTP status code
Sets the HTTP status code
|
public static
|
#
get_status_code( )
Returns the current HTTP status code
Returns the current HTTP status code
|
public static
|
|
public static
|
#
baseURL( )
Returns the root URL for the site. It will be automatically calculated unless
it is overridden with Director::setBaseURL().
Returns the root URL for the site. It will be automatically calculated unless
it is overridden with Director::setBaseURL().
Used by
|
public static
|
#
setBaseURL( mixed $baseURL )
Sets the root URL for the website. If the site isn't accessible from the URL
you provide, weird things will happen.
Sets the root URL for the website. If the site isn't accessible from the URL
you provide, weird things will happen.
|
public static
|
#
baseFolder( )
Returns the root filesystem folder for the site. It will be automatically
calculated unless it is overridden with Director::setBaseFolder().
Returns the root filesystem folder for the site. It will be automatically
calculated unless it is overridden with Director::setBaseFolder().
Used by
|
public static
|
#
setBaseFolder( mixed $baseFolder )
Sets the root folder for the website. If the site isn't accessible from the
folder you provide, weird things will happen.
Sets the root folder for the website. If the site isn't accessible from the
folder you provide, weird things will happen.
|
public static
string
|
#
makeRelative( string $url )
Turns an absolute URL or folder into one that's relative to the root of the
site. This is useful when turning a URL into a filesystem reference, or vice
versa.
Turns an absolute URL or folder into one that's relative to the root of the
site. This is useful when turning a URL into a filesystem reference, or vice
versa.
Parameters
- $url
- string $url Accepts both a URL or a filesystem path
Returns
string Either a relative URL if the checks succeeded, or the original (possibly
absolute) URL.
|
public static
boolean
|
#
is_absolute( string $path )
Returns true if a given path is absolute. Works under both *nix and windows
systems
Returns true if a given path is absolute. Works under both *nix and windows
systems
Parameters
Returns
boolean bool
|
public static
boolean
|
#
is_absolute_url( string $url )
Checks if a given URL is absolute (e.g. starts with 'http://' etc.).
Checks if a given URL is absolute (e.g. starts with 'http://' etc.).
Parameters
Returns
boolean boolean
|
public static
boolean
|
|
public static
boolean
|
#
is_site_url( string $url )
Checks if the given URL is belonging to this "site", as defined by Director::makeRelative() and absoluteBaseUrl(). Useful to check before
redirecting based on a URL from user submissions through $_GET or $_POST, and
avoid phishing attacks by redirecting to an attackers server.
Checks if the given URL is belonging to this "site", as defined by Director::makeRelative() and absoluteBaseUrl(). Useful to check before
redirecting based on a URL from user submissions through $_GET or $_POST, and
avoid phishing attacks by redirecting to an attackers server.
Parameters
Returns
boolean boolean
|
public static
string
|
#
getAbsFile( string $file )
Given a filesystem reference relative to the site root, return the full
file-system path.
Given a filesystem reference relative to the site root, return the full
file-system path.
Parameters
Returns
string string
|
public static
|
#
fileExists( mixed $file )
Returns true if the given file exists.
Returns true if the given file exists.
Parameters
- $file
- $file Filename specified relative to the site root
|
public static
|
#
absoluteBaseURL( )
Returns the Absolute URL of the site root.
Returns the Absolute URL of the site root.
Used by
|
public static
|
#
absoluteBaseURLWithAuth( )
Returns the Absolute URL of the site root, embedding the current basic-auth
credentials into the URL.
Returns the Absolute URL of the site root, embedding the current basic-auth
credentials into the URL.
|
public static
|
#
forceSSL( )
Force the site to run on SSL. To use, call from _config.php.
Force the site to run on SSL. To use, call from _config.php.
For example:
if(Director::isLive()) Director::forceSSL();
|
public static
|
#
forceWWW( )
Force a redirect to a domain starting with "www."
Force a redirect to a domain starting with "www."
|
public static
boolean
|
#
is_ajax( )
Checks if the current HTTP-Request is an "Ajax-Request" by checking for a
custom header set by prototype.js or wether a manually set request-parameter
'ajax' is present.
Checks if the current HTTP-Request is an "Ajax-Request" by checking for a
custom header set by prototype.js or wether a manually set request-parameter
'ajax' is present.
Returns
boolean boolean
|
public static
boolean
|
#
is_cli( )
Returns true if this script is being run from the command line rather than
the webserver.
Returns true if this script is being run from the command line rather than
the webserver.
Returns
boolean boolean
|
public static
|
|
public static
|
|
public static
|
#
add_callback( mixed $function, mixed $mode = 'site' )
Deprecated
2.4 Use a custom extension on your controller.
|
public static
|
#
set_environment_type( mixed $et )
Set the environment type of the current site.
Set the environment type of the current site.
Typically, a SilverStripe site have a number of environments: - development
environments, such a copy on your local machine. - test sites, such as the one
you show the client before going live. - the live site itself.
The behaviour of these environments often varies slightly. For example,
development sites may have errors dumped to the screen, and order confirmation
emails might be sent to the developer instead of the client.
To help with this, Sapphire support the notion of an environment type. The
environment type can be dev, test, or live.
You can set it explicitly with Director::set_environment_tpye(). Or you can
use Director::set_dev_servers() and Director::set_test_servers()
to set it implicitly, based on the value of $_SERVER['HTTP_HOST']. If the
HTTP_HOST value is one of the servers listed, then the environment type will be
test or dev. Otherwise, the environment type will be live.
Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask
you to log in and then push the site into dev mode for the remainder of the
session. Putting ?isDev=0 onto the URL can turn it back.
Test mode can also be forced by putting ?isTest=1 in your URL, which will ask
you to log in and then push the site into test mode for the remainder of the
session. Putting ?isTest=0 onto the URL can turn it back.
Generally speaking, these methods will be called from your _config.php
file.
Once the environment type is set, it can be checked with Director::isDev(), Director::isTest(), and Director::isLive().
Parameters
- $et
- $et string The environment type: dev, test, or live.
|
public static
string
|
|
public static
|
#
set_dev_servers( mixed $servers )
Specify HTTP_HOST values that are development environments. For information
about environment types, see Director::set_environment_type().
Parameters
- $servers
- $servers array An array of HTTP_HOST values that should be treated as
development environments.
|
public static
|
#
set_test_servers( mixed $servers )
Specify HTTP_HOST values that are test environments. For information about
environment types, see Director::set_environment_type().
Parameters
- $servers
- $servers array An array of HTTP_HOST values that should be treated as test
environments.
|
public static
|
|
public static
|
|
public static
|
|