Alpha Framework alpha--controller
[ class tree: alpha--controller ] [ index: alpha--controller ] [ all elements ]

Class: AlphaController

Source Location: /controller/AlphaController.inc

Class AlphaController

Class Overview

The master controller class for the Alpha Framework.

Located in /controller/AlphaController.inc [line 64]



		
				Author(s):
		
  • John Collins <dev@alphaframework.org>
API Tags:
Abstract:  

Information Tags:
Version:  $Id: AlphaController.inc 1453 2011-12-04 15:12:54Z johnc $
Copyright:  

Copyright (c) 2011, John Collins (founder of Alpha Framework). All rights reserved.

 Redistribution and use in source and binary forms, with or
 without modification, are permitted provided that the
 following conditions are met:

 * Redistributions of source code must retain the above
   copyright notice, this list of conditions and the
   following disclaimer.
 * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the
   following disclaimer in the documentation and/or other
   materials provided with the distribution.
 * Neither the name of the Alpha Framework nor the names
   of its contributors may be used to endorse or promote
   products derived from this software without specific
   prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Since:  1.0
License:  The BSD License

Properties

Methods

[ Top ]
Descendants
Child Class Description
CacheManager Controller used to clear out the CMS cache when required
Create Controller used to create a new BO, whose classname must be supplied in GET vars
CreateArticle Controller used to create a new article in the database
Detail Controller used to display the details of a BO, which must be supplied in GET vars
Edit Controller used to edit BO, which must be supplied in GET vars
EditArticle Controller used to edit an existing article
GenSecureQueryStrings Controller used to generate secure URLs from the query strings provided
Install Controller used install the database
ListAll Controller used to list a BO, which must be supplied in GET vars
ListBusinessObjects Controller used to list all of the business objects for the system
Login Login controller that adds the current user object to the session
Logout Logout controller that removes the current user object from the session
PreviewArticle Article for previewing Markdown content in the markItUp TextBox widget
Search Generic tag-based search engine controller
TagManager Controller used to allow an admin to manage tags in the database
ViewArticle Controller used to display a Markdown version of an article
ViewArticlePDF Controller used to display PDF version of an article where the title is provided in GET vars
ViewAttachment Controller used to view (download) an attachment file on an ArticleObject
ViewExcel Controller for viewing Business Objects as Excel spreadsheets
ViewFeed Controller for viewing news feeds
ViewImage Controller for viewing an image rendered with the Image widget.
ViewLog Controller used to display a log file, the path for which must be supplied in GET vars
ViewMetrics Controller used to display the software metrics for the application
ViewRecordSelector Controller for viewing a RecordSelector widget.
ViewTestResults Controller which displays all of the unit test results

[ Top ]
Property Summary
AlphaDAO   $BO   Optionally, a BO may be set for the default validation form handling code to load in the displayPageHead() method. The definition of this BO class will need to be included in the child controller.
string   $description   Meta description for the controller page.
array   $dirtyObjects   An array for storing dirty objects in a session (i.e. persistent business objects that have not been updated in the database yet).
string   $firstJob   The name of the first controller that is used in this unit of work.
string   $keywords   Meta keywords for the controller page, generally populated from tags
string   $lastJob   The name of the last controller that is used in this unit of work.
string   $name   The name of the controller
array   $newObjects   An array for storing new objects in a session (transient business objects that have no OID yet).
string   $nextJob   The name of the next controller that is used in this unit of work.
string   $previousJob   The name of the previous controller that is used in this unit of work.
string   $statusMessage   Used to set status update messages to display to the user (messages stored between requests in _SESSION). Useful for when you want to display a message to a user after POSTing a request, or when moving from one page to the next.
string   $title   The title to be displayed on the controller page
Timestamp.   $unitEndTime   Stores the end time of a unit of work transaction.
Integer   $unitMAXDuration   Stores the maximum allowed time duration (in seconds) of the unit of work.
string   $unitOfWork   Used to determine if the controller is part of a unit of work sequence (either empty or the name of the unit).
Timestamp   $unitStartTime   Stores the start time of a unit of work transaction.
string   $visibility   Used to set access privileages for the controller to the name of the rights group allowed to access it. 'Public' by default.

[ Top ]
Method Summary
static boolean   checkControllerDefExists()   Checks that the definition for the controller classname provided exists. Will also return true if you pass "/" for the root of the web application.
static boolean   checkIfAccessingFromSecureURL()   Static function for determining if the current request URL is a secure one (has a tk string or not)
static boolean   checkSecurityFields()   Method to check the validity of the two hidden form security fields which aim to ensure that a post to the controller is being sent from the same server that is hosting it.
static array   generateSecurityFields()   Generates the two security fields to prevent remote form processing.
static string   getCustomControllerName()   Returns the name of a custom controller if one is found, otherwise returns null.
static void   loadControllerDef()   Loads the definition for the controller classname provided.
AlphaController   __construct()   Constructor for the AlphaController that starts a new session if required, and handles the population of new/dirty objects from the session when available. Accepts the name of the rights group that has access to this controller, 'Public' by default.
void   abort()   Method to clearup a cancelled unit of work.
void   accessError()   Method to display an access error for trespassing users. HTTP response header code will be 403.
boolean   checkRights()   Checks the user rights of the currently logged-in person against the page visibility set for this controller. Will return false if the user has not got the correct rights.
void   commit()   Commits (saves) all of the new and modified (dirty) objects in the unit of work to the database.
mixed   getBO()   Get the BO for this controller (if any).
string   getDescription()   Getter for the page description.
array   getDirtyObjects()   Getter for the dirty objects array.
Timestamp   getEndTime()   Getter for the unit end time.
string   getFirstJob()   Gets the name of the first job in this unit of work.
string   getKeywords()   Getter for the page keywords.
string   getLastJob()   Gets the name of the last job in this unit of work.
Integer   getMAXDuration()   Getter for the unit of work MAX duration.
string   getName()   Get the name of the unit of work job.
array   getNewObjects()   Getter for the new objects array.
string   getNextJob()   Gets the name of the next job in this unit of work
string   getPreviousJob()   Gets the name of the previous job in this unit of work
Timestamp   getStartTime()   Getter for the unit start time.
string   getStatusMessage()   Gets the current status message for this controller. Note that by getting the current status message, you clear out the value stored in _SESSION so this method can only be used to get the status message once for display purposes.
string   getTitle()   Getter for the page title.
integer   getUnitDuration()   Calculates and returns the unit of work current duration in seconds.
string   getVisibility()   Get the name of the rights group that has access to this controller.
void   loadCustomController()   Does a HTTP redirect to a custom controller if one is found.
void   markDirty()   Adds the supplied business object to the dirtyObjects array in the session.
void   markNew()   Adds a newly created business object to the newObjects array in the session.
void   setBO()   Setter for the BO for this controller.
void   setDescription()   Setter for the page description.
void   setKeywords()   Setter for the page keywords, should pass a comma-seperated list as a string.
void   setName()   Setter for the unit of work job name.
void   setStatusMessage()   Set the status message in the _SESSION to the value provided.
void   setTitle()   Setter for the page title.
void   setUnitEndTime()   Setter for the unit end time (value will be stored in the session as key unitEndTime).
void   setUnitMAXDuration()   Setter for the unit MAX duration.
void   setUnitOfWork()   Sets the name of the controller job sequence to the values in the supplied array (and stores the array in the session).
void   setUnitStartTime()   Setter for the unit start time (value will be stored in the session as key unitStartTime).
void   setVisibility()   Setter for the name of the rights group that has access to this controller.

[ Top ]
Properties
AlphaDAO   $BO = null [line 89]

Optionally, a BO may be set for the default validation form handling code to load in the displayPageHead() method. The definition of this BO class will need to be included in the child controller.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
string   $description [line 196]

Meta description for the controller page.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
array   $dirtyObjects = array() [line 163]

An array for storing dirty objects in a session (i.e. persistent business objects that have not been updated in the database yet).

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $firstJob [line 130]

The name of the first controller that is used in this unit of work.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $keywords [line 188]

Meta keywords for the controller page, generally populated from tags

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $lastJob [line 154]

The name of the last controller that is used in this unit of work.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $name [line 71]

The name of the controller

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
array   $newObjects = array() [line 172]

An array for storing new objects in a session (transient business objects that have no OID yet).

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $nextJob [line 138]

The name of the next controller that is used in this unit of work.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $previousJob [line 146]

The name of the previous controller that is used in this unit of work.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $statusMessage [line 206]

Used to set status update messages to display to the user (messages stored between requests in _SESSION). Useful for when you want to display a message to a user after POSTing a request, or when moving from one page to the next.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $title [line 180]

The title to be displayed on the controller page

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
Timestamp.   $unitEndTime [line 114]

Stores the end time of a unit of work transaction.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
Integer   $unitMAXDuration [line 122]

Stores the maximum allowed time duration (in seconds) of the unit of work.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $unitOfWork [line 98]

Used to determine if the controller is part of a unit of work sequence (either empty or the name of the unit).

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
Timestamp   $unitStartTime [line 106]

Stores the start time of a unit of work transaction.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $visibility = 'Public' [line 80]

Used to set access privileages for the controller to the name of the rights group allowed to access it. 'Public' by default.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
Methods
static method checkControllerDefExists  [line 1159]

  static boolean checkControllerDefExists( string $controllerName  )

Checks that the definition for the controller classname provided exists. Will also return true if you pass "/" for the root of the web application.

Parameters:
string   $controllerName: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
static method checkIfAccessingFromSecureURL  [line 1209]

  static boolean checkIfAccessingFromSecureURL( )

Static function for determining if the current request URL is a secure one (has a tk string or not)


API Tags:
Return:  True if the current URL contains a tk value, false otherwise
Access:  public

Information Tags:
Since:  1.0

[ Top ]
static method checkSecurityFields  [line 948]

  static boolean checkSecurityFields( )

Method to check the validity of the two hidden form security fields which aim to ensure that a post to the controller is being sent from the same server that is hosting it.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
static method generateSecurityFields  [line 996]

  static array generateSecurityFields( )

Generates the two security fields to prevent remote form processing.


API Tags:
Return:  An array containing the two fields
Access:  public

Information Tags:
Since:  1.0

[ Top ]
static method getCustomControllerName  [line 1018]

  static string getCustomControllerName( string $BOName, string $mode  )

Returns the name of a custom controller if one is found, otherwise returns null.

Parameters:
string   $BOName:  The classname of the business object
string   $mode:  The mode of the controller (create, view, edit)

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
static method loadControllerDef  [line 1186]

  static void loadControllerDef( string $controllerName  )

Loads the definition for the controller classname provided.

Parameters:
string   $controllerName: 

API Tags:
Access:  public

Information Tags:
Since:  1.0
Throws:  IllegalArguementException

[ Top ]
Constructor __construct  [line 224]

  AlphaController __construct( [string $visibility = 'Public']  )

Constructor for the AlphaController that starts a new session if required, and handles the population of new/dirty objects from the session when available. Accepts the name of the rights group that has access to this controller, 'Public' by default.

Parameters:
string   $visibility:  The name of the rights group that can access this controller.

API Tags:
Access:  public

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
abort  [line 752]

  void abort( )

Method to clearup a cancelled unit of work.


API Tags:
Access:  public

Information Tags:
Throws:  AlphaException
Since:  1.0

[ Top ]
accessError  [line 862]

  void accessError( )

Method to display an access error for trespassing users. HTTP response header code will be 403.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
checkRights  [line 893]

  boolean checkRights( )

Checks the user rights of the currently logged-in person against the page visibility set for this controller. Will return false if the user has not got the correct rights.


API Tags:
Access:  public

Information Tags:
Since:  1.0

Redefined in descendants as:
  • Install::checkRights() : Custom version of the check rights method that only checks for a session for the config admin username/password, when the system database is not set-up

[ Top ]
commit  [line 683]

  void commit( )

Commits (saves) all of the new and modified (dirty) objects in the unit of work to the database.


API Tags:
Access:  public

Information Tags:
Throws:  FailedUnitCommitException
Since:  1.0

[ Top ]
getBO  [line 293]

  mixed getBO( )

Get the BO for this controller (if any).


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getDescription  [line 815]

  string getDescription( )

Getter for the page description.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getDirtyObjects  [line 637]

  array getDirtyObjects( )

Getter for the dirty objects array.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getEndTime  [line 527]

  Timestamp getEndTime( )

Getter for the unit end time.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getFirstJob  [line 380]

  string getFirstJob( )

Gets the name of the first job in this unit of work.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getKeywords  [line 839]

  string getKeywords( )

Getter for the page keywords.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getLastJob  [line 416]

  string getLastJob( )

Gets the name of the last job in this unit of work.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getMAXDuration  [line 560]

  Integer getMAXDuration( )

Getter for the unit of work MAX duration.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getName  [line 332]

  string getName( )

Get the name of the unit of work job.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getNewObjects  [line 671]

  array getNewObjects( )

Getter for the new objects array.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getNextJob  [line 392]

  string getNextJob( )

Gets the name of the next job in this unit of work


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getPreviousJob  [line 404]

  string getPreviousJob( )

Gets the name of the previous job in this unit of work


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getStartTime  [line 494]

  Timestamp getStartTime( )

Getter for the unit start time.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getStatusMessage  [line 1146]

  string getStatusMessage( )

Gets the current status message for this controller. Note that by getting the current status message, you clear out the value stored in _SESSION so this method can only be used to get the status message once for display purposes.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getTitle  [line 791]

  string getTitle( )

Getter for the page title.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getUnitDuration  [line 584]

  integer getUnitDuration( )

Calculates and returns the unit of work current duration in seconds.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
getVisibility  [line 356]

  string getVisibility( )

Get the name of the rights group that has access to this controller.


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
loadCustomController  [line 1054]

  void loadCustomController( string $BOName, string $mode  )

Does a HTTP redirect to a custom controller if one is found.

Parameters:
string   $BOName:  The classname of the business object
string   $mode:  The mode of the controller (create, view, edit)

API Tags:
Access:  protected

Information Tags:
Throws:  FileNotFoundException
Since:  1.0

[ Top ]
markDirty  [line 615]

  void markDirty( AlphaDAO $object  )

Adds the supplied business object to the dirtyObjects array in the session.

Parameters:
AlphaDAO   $object: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
markNew  [line 649]

  void markNew( AlphaDAO $object  )

Adds a newly created business object to the newObjects array in the session.

Parameters:
AlphaDAO   $object: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setBO  [line 305]

  void setBO( AlphaDAO $BO  )

Setter for the BO for this controller.

Parameters:
AlphaDAO   $BO: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setDescription  [line 827]

  void setDescription( string $description  )

Setter for the page description.

Parameters:
string   $description: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setKeywords  [line 851]

  void setKeywords( string $keywords  )

Setter for the page keywords, should pass a comma-seperated list as a string.

Parameters:
string   $keywords: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setName  [line 344]

  void setName( string $name  )

Setter for the unit of work job name.

Parameters:
string   $name: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setStatusMessage  [line 1133]

  void setStatusMessage( string $message  )

Set the status message in the _SESSION to the value provided.

Parameters:
string   $message: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setTitle  [line 803]

  void setTitle( string $title  )

Setter for the page title.

Parameters:
string   $title: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setUnitEndTime  [line 544]

  void setUnitEndTime( integer $year, integer $month, integer $day, integer $hour, integer $minute, integer $second  )

Setter for the unit end time (value will be stored in the session as key unitEndTime).

Parameters:
integer   $year: 
integer   $month: 
integer   $day: 
integer   $hour: 
integer   $minute: 
integer   $second: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setUnitMAXDuration  [line 572]

  void setUnitMAXDuration( integer $duration  )

Setter for the unit MAX duration.

Parameters:
integer   $duration:  The desired duration in seconds.

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setUnitOfWork  [line 430]

  void setUnitOfWork( array $jobs  )

Sets the name of the controller job sequence to the values in the supplied array (and stores the array in the session).

Parameters:
array   $jobs:  The names of the controllers in this unit of work sequence.

API Tags:
Access:  public

Information Tags:
Throws:  IllegalArguementException
Since:  1.0

[ Top ]
setUnitStartTime  [line 511]

  void setUnitStartTime( integer $year, integer $month, integer $day, integer $hour, integer $minute, integer $second  )

Setter for the unit start time (value will be stored in the session as key unitStartTime).

Parameters:
integer   $year: 
integer   $month: 
integer   $day: 
integer   $hour: 
integer   $minute: 
integer   $second: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setVisibility  [line 368]

  void setVisibility( string $visibility  )

Setter for the name of the rights group that has access to this controller.

Parameters:
string   $visibility: 

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]

Documentation generated on Tue, 13 Dec 2011 20:25:36 +0000 by phpDocumentor 1.4.3