Welcome, Guest Log In

Class Krai_Module_Action

Class Overview

Action base class

This class is the basis for every module action in an application. It provides filtering functionality, as well as redirection, rendering, and error handling.

Located in /Krai/Module/Action.php [line 23]

Krai
   |
   --Krai_Module_Action
Author(s):
API Tags:
Abstract:  

Properties

Methods

[ Top ]
Descendants
Child Class Description
PageModule_EditAction Page editing action
PageModule_DeniedAction The access denied action
PageModule_ViewAction View action for arbitrary pages
PageModule_ListAction A page directory
PageModule_SetrevAction Processes a revision setting
PageModule_RevisionsAction Gets the revisions for a page over AJAX
PageModule_IndexAction Pages index action - displays some certain page with a menu
ApplicationModule_IndexAction The index action for the application module
UserModule_LoginAction User login action
UserModule_EditAction User profile editing
UserModule_ProfileAction Displays user profile pages
UserModule_DirectoryAction The user directory
UserModule_ChangepassAction Change password action
UserModule_LostpassAction Action to recover lost password
UserModule_LogoutAction User logout action
UserModule_ConfirmAction User confirmation for both email changes and for registrations

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Krai

Krai::$APPDIR
Krai::$DB
Krai::$DB_DEFAULT
Krai::$FRAMEWORK
Krai::$GET
Krai::$INCLUDES
Krai::$INFLECTOR
Krai::$LAYOUTS
Krai::$MODULES
Krai::$PARAMS
Krai::$POST
Krai::$REQUEST
Krai::$ROUTER
Krai::$STARTTIME
Krai::$_BACKLOGS
Krai::$_CONFIG
Krai::$_LOGGING
Krai::$_MESSAGES
Krai::$_MIMESET
Krai::$_NAKOR_CORE
Krai::$_SETUP
Krai::$_STARTED

Inherited From Krai

Krai::AssocImplode()
A function to implode an associative array preserving keys
Krai::AutoLoad()
Loads the file for a module or action name
Krai::DetermineRequest()
Determines the request to be used from server variables.
Krai::EndRun()
Ends the application run after cleaning up
Krai::Error()
Save an error message
Krai::GetConfig()
Gets information from the configuration array Krai::$_CONFIG.
Krai::GetErrors()
Returns the logged errors
Krai::GetNotices()
Returns the logged notices
Krai::IsErrors()
Determine whether there are errors or not
Krai::IsNotices()
Determine whether there are notices or not
Krai::LoadActionFile()
Tries to load the file for an action
Krai::LoadModuleFile()
Tries to load the file for a module
Krai::Notice()
Save a notice message
Krai::ReloadMessages()
Reloads messages from session if available
Krai::Run()
Makes everything start up and work
Krai::SaveMessages()
Saves messages to the session
Krai::SetMime()
Sets the mime-type header for the response
Krai::Setup()
This is the configuration function for the framework.
Krai::Uses()
A wrapper for including files and logging such. Uses http://www.php.net/func_get_args() for variable argument number.
Krai::WriteBackLogs()
Writes the back logs to the logger
Krai::WriteLog()
Provides an interface to the loghandler, whatever that might be.

Inherited From Krai

Krai::LOG_ALERT
Krai::LOG_CRITICAL
Krai::LOG_DEBUG
Krai::LOG_EMERG
Krai::LOG_ERROR
Krai::LOG_INFO
Krai::LOG_NOTICE
Krai::LOG_WARNING

[ Top ]
Property Summary
static boolean   $_RENDER_STARTED   Whether or not any rendering has been done yet.
Krai_Module   $_parent   Holds a reference to the parent module
string   $_RequestMethod   The request method for the current action

[ Top ]
Method Summary
Krai_Module_Action   __construct()   Constructor
void   AfterFilters()   Filters to apply after the Display call
void   AfterRender()   Filters to apply after any rendering takes place. If no render call is made, this is not executed.
void   BeforeFilters()   Filters to apply before the validate call
void   BeforeRender()   Filters to apply before any rendering takes place. If no render call is made, this is not executed.
void   Display()   Display something
void   HandleError()   Handle an error being thrown
void   Process()   Process data
void   RedirectSilent()   Execute a redirect behind the scenes
void   RedirectTo()   Execute a redirect
void   Render()   Render a file with or without a template
void   RenderPartial()   Renders a partial file
void   RenderText()   Renders some text with or without a template
void   Validate()   Validate some data

[ Top ]
Properties
static boolean   $_RENDER_STARTED = false [line 56]

Whether or not any rendering has been done yet.

This variable is a flag for whether or not rendering has been started by any action. This allows for errors to be thrown when attempting to render a layout more than once.

API Tags:
Access:  private


[ Top ]
Krai_Module   $_parent [line 35]

Holds a reference to the parent module

This variable holds a reference to the parent module of the action. This allows actions to be tied to a heirarchy of module classes instead of just one from which it inherits. It also allows for data separation between the module and the action.

API Tags:
Access:  protected


[ Top ]
string   $_RequestMethod [line 45]

The request method for the current action

This variable holds the request method which generated the call to the current action. It should be one of "GET" or "POST", as supplied by Krai_Module::DoAction().

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 68]

  Krai_Module_Action __construct( Krai_Module &$_parent, string $_rm, Krai_Module $_parent  )

Constructor

This function initializes the action parameters. It does not control execution other than that. Execution is managed within Krai_Module::DoAction().

Parameters:
Krai_Module   $_parent:  The parent module of the action
string   $_rm:  The request method
Krai_Module   &$_parent: 

API Tags:
Access:  public

Information Tags:
Throws:  Krai_Module_Exception

[ Top ]
AfterFilters  [line 371]

  void AfterFilters( )

Filters to apply after the Display call

This function provides the ability for things to happen after the call to Krai_Module_Action::Display(). It should always call

  1.  parent::AfterFilters();
in order to allow stacking.


API Tags:
Access:  public


[ Top ]
AfterRender  [line 357]

  void AfterRender( )

Filters to apply after any rendering takes place. If no render call is made, this is not executed.

This function provides the ability for things to happen after a rendering takes place via either Krai_Module_Action::Render() or Krai_Module_Action::RenderText() It should always call

  1.  parent::AfterRender();
in order to allow stacking.


API Tags:
Access:  public


[ Top ]
BeforeFilters  [line 325]

  void BeforeFilters( )

Filters to apply before the validate call

This function provides the ability for things to happen before the call to Krai_Module_Action::Validate(). It should always call

  1.  parent::BeforeFilters();
in order to allow stacking.


API Tags:
Access:  public


Redefined in descendants as:

[ Top ]
BeforeRender  [line 341]

  void BeforeRender( )

Filters to apply before any rendering takes place. If no render call is made, this is not executed.

This function provides the ability for things to happen before a rendering takes place via either Krai_Module_Action::Render() or Krai_Module_Action::RenderText() It should always call

  1.  parent::BeforeRender();
in order to allow stacking.


API Tags:
Access:  public


[ Top ]
HandleError  [line 132]

  void HandleError( integer $_ErrorCode, string $_ErrorMsg  )

Handle an error being thrown

This function handles the Krai_Module_Exceptions thrown by the Krai_Module_Action::Validate() and Krai_Module_Action::Process() methods. By default it is implemented to call Krai::Error() with the $_ErrorMsg parameter.

Parameters:
integer   $_ErrorCode: 
string   $_ErrorMsg: 

API Tags:
Access:  public


Redefined in descendants as:

[ Top ]
Process  [line 106]

  void Process( )

Process data

This is the third function of an action called, after Krai_Module_Action::BeforeFilters() and Krai_Module_Action::Validate() in a standard application flow. The intention is to process validated input within this method and record any messages or errors to be used later in the Krai_Module_Action::Display() method. If an error is found, a Krai_Module_Exception should be thrown.


API Tags:
Access:  public

Information Tags:
Throws:  Krai_Module_Exception

Redefined in descendants as:

[ Top ]
RedirectSilent  [line 401]

  void RedirectSilent( $_module, $_action, [ $_params = array()], string $module, string $action, array $params  )

Execute a redirect behind the scenes

This function executes a redirect by means of the Krai_Module::RedirectSilent() function. See that function for details.

Parameters:
string   $module:  The name of the module
string   $action:  The name of the action
array   $params:  The array of parameters
   $_module: 
   $_action: 
array   $_params: 

API Tags:
See:  Krai_Module::RedirectSilent()
Access:  protected


[ Top ]
RedirectTo  [line 385]

  void RedirectTo( string $module, [string $action = null], [ $params = array()]  )

Execute a redirect

This function executes a redirect by means of the Krai_Module::RedirectTo() function. See that function for details.

Parameters:
string   $module:  The name of the module or the url
string   $action:  The name of the action or null to use a url
array   $params:  The array of parameters

API Tags:
See:  Krai_Module::RedirectTo()
Access:  protected


[ Top ]
Render  [line 158]

  void Render( string $_file, [boolean $_templated = true]  )

Render a file with or without a template

This function is responsible for rendering a view file, optionally with a template. It should only be called if neither it nor Krai_Module_Action::RenderText() was previously called in the application flow. Before rendering the file, it passes off to Krai_Module_Action::BeforeRender(). It throws a Krai_Module_Exception_Adone, so it generally will not return to the action application flow.

The filename passed with be prefixed with Krai::$MODULES and verified to be within the Krai::$APPDIR directory. Additionally, the name of the layout file (whether passed or default) will be prefixed with Krai::$LAYOUTS and also verified to live within the application root Krai::$APPDIR.

Parameters:
string   $_file:  The name of the file to be rendered
boolean   $_templated:  The name of the layout to use or true to use the default layout or false to use no layout

API Tags:
Access:  protected

Information Tags:
Throws:  Krai_Module_Exception
Throws:  Krai_Module_Exception_Adone

[ Top ]
RenderPartial  [line 222]

  void RenderPartial( string $_file, [mixed $_collection = array()], [ $_locals = array()]  )

Renders a partial file

This function provides the ability to render a "partial" within another render. It accepts some data and assigns that to a local variable based on the name of the partial file that will be available within the scope of the partial file. If an array of data is passed, it will include the partial file once for each element of the array.

The filename passed with be prefixed with Krai::$MODULES and verified to be within the Krai::$APPDIR directory.

Parameters:
string   $_file:  The name of the partial file
mixed   $_collection:  The data for the partial file
array   $_locals:  Some other local variables that will be available to the partial file in the form of varname => value pairs

API Tags:
Access:  protected


[ Top ]
RenderText  [line 275]

  void RenderText( string $_text, [boolean $_templated = true]  )

Renders some text with or without a template

This function is responsible for rendering some text (e.g. JSON), optionally with a template. It should only be called if neither it nor Krai_Module_Action::Render() was previously called in the application flow. Before rendering the file, it passes off to Krai_Module_Action::BeforeRender(). It throws a Krai_Module_Exception_Adone, so it generally will not return to the action application flow.

The name of the layout file (whether passed or default) will be prefixed with Krai::$LAYOUTS and verified to live within the application root Krai::$APPDIR.

Parameters:
string   $_text:  The text to be rendered
boolean   $_templated:  The name of the layout or true to use the default layout or false to use no layout

API Tags:
Access:  protected

Information Tags:
Throws:  Krai_Module_Exception
Throws:  Krai_Module_Exception_Adone

[ Top ]
Validate  [line 92]

  void Validate( )

Validate some data

This is the second function of an action called, after the Krai_Module_Action::BeforeFilters() in a standard application flow. The intention is to validate input within this method and save it to instance variables to be used later in the Krai_Module_Action::Process() and Krai_Module_Action::Display() methods. If an error is found, a Krai_Module_Exception should be thrown.


API Tags:
Access:  public

Information Tags:
Throws:  Krai_Module_Exception

Redefined in descendants as:

[ Top ]

Documentation generated on Fri, 25 Jul 2008 15:19:02 -0400 by phpDocumentor 1.4.2
Krai Framework site admin credits sitemap valid xhtml?