Class Ismo_Core_State_HTTP

Description

This class represents one state in an Ismo application.

Each state has one or more action methods and the one that will be called depends on the request.

Additional documentation is available in the IsmoWiki at http://ismo.sourceforge.net/wiki/IsmoState

Located in /State/HTTP.php (line 42)


	
			
Direct descendents
Class Description
Ismo_Core_State_HTTP_Pages
Ismo_Core_State_XMLRPC The XML-RPC base state class.
Variable Summary
Method Summary
Ismo_Core_State_HTTP Ismo_Core_State_HTTP ()
void execDefault ()
void execute ()
boolean postExec ()
boolean postShow (string $name)
boolean preExec ()
boolean preShow (string $name)
void setConfiguration (mixed &$config)
void setLogger (mixed &$logInstance)
void setRequest (Ismo_Core_Request &$request)
void setResponse (Ismo_Core_Response &$response)
void setSession (Ismo_Core_Session &$session)
void setStateName (string $stateName)
void setUrlStyle (string $urlStyle)
void _actionMethodMissing (string $name)
boolean _authorize ()
string _createActionMethodName (string $action)
boolean _createNewSession ()
void _createShowMethodName (mixed $result)
void _deduceAction ()
void _deduceLocale ()
Ismo_Core_URL &_getUrl ([string $action = null], [string $state = null])
boolean _hasSession ()
boolean _log (string $message, string $priority)
void _recover (integer $errno, string $errmsg, string $filename, integer $linenum, array $vars)
void _recurseShow (string $res)
void _showMethodMissing (string $name)
Variables
string $_actionName = null (line 49)

The current action being or about to be executed.

  • access: private
string $_locale = '' (line 56)

The clients preferred locale.

  • access: private
mixed $_logger = null (line 66)

This is the class used by the log method to log things. It's set by the Ismo_Core_Application class to be the same as its $_logger attribute when a state instance is created.

  • access: private
mixed $_page (line 74)

The template engine or class or whatever that's used to generate the page.

  • access: private
Ismo_Core_Request $_request (line 81)

The Ismo_Core_Request instance that represents this request.

  • access: private
Ismo_Core_Response $_response (line 89)

The Ismo_Core_Response instance that represents this request's response.

  • access: private
Ismo_Core_Session $_session (line 96)

The Ismo_Core_Session instance that represents the current session.

  • access: private
string $_stateName = null (line 103)

The name of the current state being executed.

  • access: private
integer $_urlStyle = ISMO_CORE_QUERY_STYLE (line 112)

The URL style to use when determining the state and action and also when generating new URLs.

  • access: private
Methods
Constructor Ismo_Core_State_HTTP (line 518)

The constructor.

  • access: public
Ismo_Core_State_HTTP Ismo_Core_State_HTTP ()
execDefault (line 602)

The default action handler method.

This action method will be called if no action was given in the request. The default implementation in the Ismo_Core_State_HTTP class just prints "hello from ismo". You will probably want to override this method in your state classes.

  • access: public
void execDefault ()

Redefined in descendants as:
execute (line 533)

Handles the request.

This is the method that the Ismo_Core_Application class calls. It figures out the action, checks if the request is authorized, expose the default variables and then calls the action method.

This method should never be called manually.

  • access: public
void execute ()

Redefined in descendants as:
postExec (line 640)

Post action method execution hook.

This method is called after the action method is called.

Note If a method named postExecactionName exists it will be called before this method but after the action method (execactionName) is called.

  • return: false to abort execution anything else to continue the execution
  • access: public
boolean postExec ()

Redefined in descendants as:
postShow (line 681)

Post show method execution hook.

This method is called after the show method is called.

Note If a method named postShowshowMethodName exists it will be called before this method but after the show method (showshowMethodName) is called.

  • return: false to abort execution anything else to continue the execution
  • access: public
boolean postShow (string $name)
  • string $name: result value (if any) from the action method call
preExec (line 622)

Pre action method execution hook.

This method is called before the action method is called, so it can e.g. be used for caching or similar things.

Note If a method named preExecactionName exists it will be called after this method but before the action method (execactionName) is called.

  • return: false to abort execution anything else to continue the execution
  • access: public
boolean preExec ()

Redefined in descendants as:
preShow (line 661)

Pre show method execution hook.

This method is called before the show method is called, so it can e.g. be used for caching or similar things.

Note If a method named preShowshowMethodName exists it will be called after this method but before the show method (showshowMethodName) is called.

  • return: false to abort execution anything else to continue the execution
  • access: public
boolean preShow (string $name)
  • string $name: result value (if any) from the action method call
setConfiguration (line 799)

Set the configuration.

This method is used by the Ismo_Core_Application class to set global configuration parameters. You have to override this yourself to do anything usefull.

  • access: public
void setConfiguration (mixed &$config)
  • mixed $config: a configuration container (variable, object or array)
setLogger (line 694)

This sets the log class being used.

The Ismo_Core_Application class uses this method to set the log class used by the state. There is no need to call this method manually.

  • access: public
void setLogger (mixed &$logInstance)
  • mixed $logInstance: the logging class instance to use
setRequest (line 711)

Sets the request instance to use.

This is usually an instance of the Ismo_Core_Request class but it might also be an instance of some other class that implements the same methods.

This is no need to call this method manually.

  • access: public
void setRequest (Ismo_Core_Request &$request)
setResponse (line 728)

Sets the response instance to use.

This is usually an instance of the Ismo_Core_Response class but it might also be an instance of some other class that implements the same methods.

This is no need to call this method manually.

  • access: public
void setResponse (Ismo_Core_Response &$response)
setSession (line 745)

Sets the session used by this class.

This is usually an instance of the Ismo_Core_Session class but it might also be an instance of some other class that implements the same methods.

These is no need to call this method manually.

  • access: public
void setSession (Ismo_Core_Session &$session)
setStateName (line 765)

Sets the state name.

This method is used by the Ismo_Core_Application class to set the name of the state as it has determined. The name is usually the same as the name of the state class but it might differ if the Ismo_Core_Application class has been extended and modified.

There is no need to call this method manually.

  • access: public
void setStateName (string $stateName)
  • string $stateName: the name of the state (as determined by the Ismo_Core_Application class
setUrlStyle (line 781)

Sets the Url style used.

This method is used by the Ismo_Core_Application class to inform the state about the currently used url style.

There is no need to call this method manually.

  • access: public
void setUrlStyle (string $urlStyle)
  • string $urlStyle: the url style to use.
_actionMethodMissing (line 366)

Missing action method saver.

This method is called whenever an action which doesn't have a corresponding exec... method is requested. This implementation just calls the execDefault (i.e. the default action) method.

Override if you want some other behaviour.

  • access: private
void _actionMethodMissing (string $name)
  • string $name: the requested action's name
_authorize (line 145)

Decides if the request is allow to access this action method or not.

This method is automatically called by the execute method before the action method is called.

If true is returned execution is handed onwards to the action method (i.e. exec<action name>). If false is returned execution will be stopped. So if false is returned make sure that an appropriate response has been sent to the client, for example a redirect to a login page.

The default implementation always return true so this method should be overridden in state classes which should have some kind of access checks.

The name of the current action is available in the _actionName property of this object. And the name of the current state name (usually the same as the name of this class but it might be different if the Ismo_Core_Application class has been extended and modified) is available in the _stateName property of this object. The request and session properties are also available.

It is possible to change which action method that will be called after this method has returned by changing the _actionName property of this object.

  • return: true to continue execution false to abort.
  • access: private
boolean _authorize ()
_createActionMethodName (line 408)

Constructs the action method name.

Override this method if you want to change the default execXXX naming scheme.

  • return: the name of the method
  • access: private
string _createActionMethodName (string $action)
  • string $action: the name of the action
_createNewSession (line 160)

Creates a new session.

This method just calls the create method on the Ismo_Core_Session instance.

  • return: indicating whether the session could be created or not.
  • access: private
boolean _createNewSession ()
_createShowMethodName (line 419)

Constructs the show method name.

Override this method if you want to change the default showXXX

void _createShowMethodName (mixed $result)
_deduceAction (line 189)

Figures out which action method that should be called.

If the ISMO_CORE_QUERY_STYLE URL style is used the action is gotten from the action query parameter. If the ISMO_CORE_PATHINFO_STYLE URL style is used the action is gotten from the second path-info parameter. See HowToConfigureURLStyleAndGetURLsToStates in the wiki for more details about the different URL styles.

If no action can be determined the action is set to "default" which means that the execDefault() will later be called.

When the action has been determined $this->_actionName is set accordingly.

Note that only the a-z, A-Z, 0-9 and _ characters are allowed in action names.

You might want to override this method if you want change how the current action is decided.

There is no need to call this method manually.

  • access: private
void _deduceAction ()

Redefined in descendants as:
_deduceLocale (line 214)

Deduces the clients preferred locale.

This method just calls the getLocale() method on the Ismo_Core_Request instance and sets the _locale attribute accordingly.

  • access: private
void _deduceLocale ()
_exposeDefaultVariables (line 233)

Exposes the default variables to the template engine.

This method can be overridden to make sure that certain top-level template variables get exposed to the template engine. This current implemention doesn't expose any.

This method is called by the execute() method before it is calling the action method. So this is a good place to put things that should be exposed to the template engine for every action method. Like maybe a menu or something.

  • access: private
void _exposeDefaultVariables ()
_getUrl (line 251)

Returns a URL to the given action on the given state.

This method honours the URLStyle setting and returns an IsmoURL instance to the given action-state combination. If no state is given the current one is used.

  • return: the URL
  • access: private
Ismo_Core_URL &_getUrl ([string $action = null], [string $state = null])
  • string $action: the action to get a link to, if nons is given the current action is used
  • string $state: the state to get a link to, if none is given the current state is used
_hasSession (line 315)

Convenient wrapper to check if a session is available or not.

This just calls the hasSession() method on the Ismo_Core_Session instance which checks if the current request has a session associated with it or not.

  • return: indicating whether is's available or not
  • access: private
boolean _hasSession ()
_log (line 349)

Logs the given message.

Logs the message with the given priority using the configured logger. The logger class to use is set on the Ismo_Core_Application instance with the setLogger() method.

This method adds the name of the current state to the beginning of the message and then calls the log method on the current active logger.

Example:

  1. // ...
  2. funciton execFoo()
  3. {
  4. $this->_log('Entering execFoo()', PEAR_LOG_DEBUG);
  5. // do stuff
  6. $this->_log('Leaving execFoo()', PEAR_LOG_DEBUG);
  7. }

  • return: true if successful, false if the operation failed.
  • access: public
boolean _log (string $message, string $priority)
  • string $message: the textual message to be logged
  • string $priority: the priority of the message, valid values depend on the used log class.
_recover (line 449)

Handles error conditions that occur during execution of the action method.

Here you can do fancy error recovering if you like.

Please keep in mind that you are responsive for die():ing the script if the execution shouldn't continue. If you don't do anything the execution will continue on the line after which the error happened on.

You should probably override this method in your subclass. The default implementation just calls the system error handler (Ismo_Core_systemErrorHandler). Which just prints a generic error message. If ISMO_CORE_DEBUG is defined it will also print the file, lineno, error messsage and a variable dump, then it will die the script.

  • access: private
void _recover (integer $errno, string $errmsg, string $filename, integer $linenum, array $vars)
  • integer $errno: the error number
  • string $errmsg: the error message
  • string $filename: the name of the file the error occured in
  • integer $linenum: the line number the error is on
  • array $vars: all the defined variables at the time of the error
_recurseShow (line 466)

Handles showMethod calls recursively

This method takes the result value of an execute action method call. If the result is a string value that matches an appropriate show method the show method is called. In turn, each resulting return value is handled recursively to allow a 'layered' view.

  • access: private
void _recurseShow (string $res)
  • string $res: result value (if any) from the action method call
_showMethodMissing (line 506)

Missing show method saver.

This method is called whenever a show method which doesn't exist is requested. The default implementation just prints a message about a show method for show value X is missing.

Override if you want some other behaviour.

  • access: private
void _showMethodMissing (string $name)
  • string $name: the requested show value

Documentation generated on Mon, 14 Jun 2004 11:59:23 +0200 by phpDocumentor 1.3.0RC3