Class Controller

Description

A default controller class to be extended

Located in /class.controller.php (line 24)


                
			
Variable Summary
mixed $aData
mixed $b404Error
mixed $sView
Method Summary
Controller __construct ()
void AjaxError (string $sError, [int $iResponseCode = 400])
string GetFlash ()
void index ()
bool Is404Error ()
boolean IsAjaxRequest ()
bool RedirectTo (string $sURL, [bool $bPermanentRedirect = true])
void Set404Error ([bool $bIs404Error = true])
void SetData (string $sName, mixed $sValue)
void SetFlash (string $sMessage)
bool SetHTTPStatus (int $iCode)
void SetView (string $sView)
Variables
mixed $aData = array() (line 29)

Stores view data that is passed from the Controller to the View

  • access: public
mixed $b404Error = false (line 39)

Stores whether the current request will result in a 404 error

  • access: public
mixed $sView = "" (line 34)

Stores the name of the file file that will be loaded at the end of the request

  • access: public
Methods
Constructor __construct (line 45)

Constructor. Currently does not do anything.

  • access: public
Controller __construct ()
AjaxError (line 131)

This specialized method does two things: it attempts to set the HTTP status code, 400 by default, to inform the web browser that there was an error, and second, echoes the supplied error message to the browser, which could be a simple string or a JSON object.

  • access: public
void AjaxError (string $sError, [int $iResponseCode = 400])
  • string $sError: The error message to output
  • int $iResponseCode: Optional; The response code to send to the browser. Default: 400
GetFlash (line 220)

Retrieves any flash message stored in the flash session variable, if any. See the SetFlash() method.

  • return: The flash message, if any, stored in the session
  • access: public
string GetFlash ()
index (line 56)

Every controller must have an index() method defined for default requests to the controller that do not define a method. Since it is a requirement for this method to exist, it is defined in the parent controller class.

  • access: public
void index ()
Is404Error (line 68)

Returns the internal 404 status to determine if a 404 error flag was triggered

  • return: True if a 404 error was encountered, false otherwise
  • access: public
bool Is404Error ()
IsAjaxRequest (line 93)

Determines whether or not the current HTTP request came via AJAX.

  • return: True of the request is via AJAX, false otherwise
  • access: public
boolean IsAjaxRequest ()
RedirectTo (line 154)

This method redirects the browser to the specified URL. The second argument controls whether or not the 301 HTTP response code is used to signal a permanent redirect. Using this response code enable the user to hit refresh afterwards without resubmitting any form data from the original request.

If headers have already been sent to the browser, this method will return false and will not call the redirect. Otherwise this method will always return true.

  • return: True if the redirect was sucessfull, false otherwise
  • access: public
bool RedirectTo (string $sURL, [bool $bPermanentRedirect = true])
  • string $sURL: The URL to redirect to
  • bool $bPermanentRedirect: Optional; True to signal a permanent redirect, false to not set the HTTP response code. Default: true
Set404Error (line 81)

Sets or clears the internal 404 error status flag.

  • access: public
void Set404Error ([bool $bIs404Error = true])
  • bool $bIs404Error: True to trigger a 404 error, false to clear the 404 flag. Default: true
SetData (line 192)

Sets a data variable that can be used by the view file. Supplying the name and value of the variable, before loading the view file, these variables will be extracted and available in the view file for processing and/or display.

If the supplied variable already exists, it will be overwritten.

  • access: public
void SetData (string $sName, mixed $sValue)
  • string $sName: The name of the variable to set
  • mixed $sValue: The value of the variable to set
SetFlash (line 207)

Sets a session variable called flash with the supplied message. This can be used on a redirect to display a success message (in conjunction with the RedirectTo() method).

If a flash message is already set, it will be overwritten on subsequent calls.

  • access: public
void SetFlash (string $sMessage)
  • string $sMessage: The message to set in the flash session variable
SetHTTPStatus (line 107)

Sets the HTTP status code header. This method will only work if no output or headers have already been sent.

  • return: True if the operation was successful, false on failure
  • access: public
bool SetHTTPStatus (int $iCode)
  • int $iCode: The HTTP status code
SetView (line 175)

Sets the view file that should be loaded at the end of the request. This method does not check to ensure that the file specified actually exists. It is up to the code that loads the view file to do this (normally the Dispatcher class).

  • access: public
void SetView (string $sView)
  • string $sView: The file name of the view file that should be loaded.

Documentation generated on Thu, 25 Feb 2010 15:59:39 -0500 by phpDocumentor 1.4.3