Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ApplicationFramework Class Reference

Top-level framework for web applications. More...

List of all members.

## Application Framework
| AddObjectDirectories ($Dirs)
| Add additional directories to be searched for object files when autoloading.
| SetBrowserDetectionFunc ($DetectionFunc)
| Specify function to use to detect the web browser type.
| AddUnbufferedCallback ($Callback, $Parameters=array())
| Add a callback that will not be executed after buffered content has been output and that won't have its output buffered.
| TemplateLocationCacheExpirationInterval ($NewInterval=-1)
| Get/set UI template location cache expiration period in minutes.
| LoadPage ($PageName)
| Load page PHP and HTML/TPL files.
| SetJumpToPage ($Page)
| Set URL of page to autoload after PHP page file is executed.
| JumpToPageIsSet ()
| Report whether a page to autoload has been set.
| HtmlCharset ($NewSetting=NULL)
| Get/set HTTP character encoding value.
| SuppressHTMLOutput ($NewSetting=TRUE)
| Suppress loading of HTML files.
| ActiveUserInterface ($UIName=NULL)
| Get/set name of current active user interface.
| AddPostProcessingCall ($FunctionName, &$Arg1=self::NOVALUE, &$Arg2=self::NOVALUE, &$Arg3=self::NOVALUE, &$Arg4=self::NOVALUE, &$Arg5=self::NOVALUE, &$Arg6=self::NOVALUE, &$Arg7=self::NOVALUE, &$Arg8=self::NOVALUE, &$Arg9=self::NOVALUE)
| Add function to be called after HTML has been loaded.
| AddEnvInclude ($FileName)
| Add file to be included to set up environment.
| GUIFile ($FileName)
| Search UI directories for specified image or CSS file and return name of correct file.
| PUIFile ($FileName)
| Search UI directories for specified image or CSS file and print name of correct file.
| FindCommonTemplate ($PageName)
| Get full path to HTML or CSS file.
| LoadFunction ($Callback)
| Attempt to load code for function or method if not currently available.
| GetElapsedExecutionTime ()
| Get time elapsed since constructor was called.
| GetSecondsBeforeTimeout ()
| Get remaining available (PHP) execution time.
| HtaccessSupport ()
| Determine if .htaccess files are enabled.
## Event Handling
| RegisterEvent ($EventsOrEventName, $EventType=NULL)
| Register one or more events that may be signaled.
| HookEvent ($EventsOrEventName, $Callback=NULL, $Order=self::ORDER_MIDDLE)
| Hook one or more functions to be called when the specified event is signaled.
| SignalEvent ($EventName, $Parameters=NULL)
| Signal that an event has occured.
| IsStaticOnlyEvent ($EventName)
| Report whether specified event only allows static callbacks.
const | EVENTTYPE_DEFAULT = 1
| Default event type.
const | EVENTTYPE_CHAIN = 2
| Result chaining event type.
const | EVENTTYPE_FIRST = 3
| First response event type.
const | EVENTTYPE_NAMED = 4
| Named result event type.
const | ORDER_FIRST = 1
| Run hooked function first (i.e.
const | ORDER_MIDDLE = 2
| Run hooked function after ORDER_FIRST and before ORDER_LAST events.
const | ORDER_LAST = 3
| Run hooked function last (i.e.
## Task Management
| QueueTask ($Callback, $Parameters=NULL, $Priority=self::PRIORITY_MEDIUM, $Description="")
| Add task to queue.
| QueueUniqueTask ($Callback, $Parameters=NULL, $Priority=self::PRIORITY_MEDIUM, $Description="")
| Add task to queue if not already in queue or currently running.
| TaskIsInQueue ($Callback, $Parameters=NULL)
| Check if task is already in queue or currently running.
| GetTaskQueueSize ($Priority=NULL)
| Retrieve current number of tasks in queue.
| GetQueuedTaskList ($Count=100, $Offset=0)
| Retrieve list of tasks currently in queue.
| GetRunningTaskList ($Count=100, $Offset=0)
| Retrieve list of tasks currently in queue.
| GetOrphanedTaskList ($Count=100, $Offset=0)
| Retrieve list of tasks currently in queue.
| ReQueueOrphanedTask ($TaskId)
| Move orphaned task back into queue.
| DeleteTask ($TaskId)
| Remove task from task queues.
| GetTask ($TaskId)
| Retrieve task info from queue (either running or queued tasks).
| MaxTasks ($NewValue=NULL)
| Get/set maximum number of tasks to have running simultaneously.
| MaxExecutionTime ($NewValue=NULL)
| Get/set maximum PHP execution time.
| OnCrash ()
| Called automatically at program termination to ensure output is written out.
const | PRIORITY_HIGH = 1
| Highest priority.
const | PRIORITY_MEDIUM = 2
| Medium (default) priority.
const | PRIORITY_LOW = 3
| Lower priority.
const | PRIORITY_BACKGROUND = 4
| Lowest priority.
const | NOVALUE = ".-+-.NO VALUE PASSED IN FOR ARGUMENT.-+-."

## Detailed Description

Top-level framework for web applications.

Definition at line 15 of file ApplicationFramework.php.

## Member Function Documentation

ApplicationFramework::ActiveUserInterface | ( | $ | UIName = `NULL` | ) |

Get/set name of current active user interface.

Any "SPTUI--" prefix is stripped out for backward compatibility in CWIS.

Parameters:

  | UIName | Name of new active user interface. (OPTIONAL)

Returns:
  Name of currently active user interface.

Definition at line 472 of file ApplicationFramework.php.

ApplicationFramework::AddEnvInclude | ( | $ | FileName | ) |

Add file to be included to set up environment.

This file is loaded right before the PHP file.

Parameters:

  | FileName | Name of file to be included.

Definition at line 518 of file ApplicationFramework.php.

ApplicationFramework::AddObjectDirectories | ( | $ | Dirs | ) |

Add additional directories to be searched for object files when autoloading.

Parameters:

  | Dirs | Array with directories to be searched, with directory paths as indexes and any prefixes to strip (e.g. "Axis--") as values..

Definition at line 84 of file ApplicationFramework.php.

ApplicationFramework::AddPostProcessingCall | ( | $ | FunctionName,
|  | &$ | Arg1 = `self::NOVALUE`,
|  | &$ | Arg2 = `self::NOVALUE`,
|  | &$ | Arg3 = `self::NOVALUE`,
|  | &$ | Arg4 = `self::NOVALUE`,
|  | &$ | Arg5 = `self::NOVALUE`,
|  | &$ | Arg6 = `self::NOVALUE`,
|  | &$ | Arg7 = `self::NOVALUE`,
|  | &$ | Arg8 = `self::NOVALUE`,
|  | &$ | Arg9 = `self::NOVALUE` |
| ) |  |  |

Add function to be called after HTML has been loaded.

The arguments are optional and are saved as references so that any changes to their value that occured while loading the HTML will be recognized.

Parameters:

  | FunctionName | Name of function to be called.
  | Arg1 | First argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg2 | Second argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg3 | Third argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg4 | Fourth argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg5 | FifthFirst argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg6 | Sixth argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg7 | Seventh argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg8 | Eighth argument to be passed to function. (OPTIONAL, REFERENCE)
  | Arg9 | Ninth argument to be passed to function. (OPTIONAL, REFERENCE)

Definition at line 496 of file ApplicationFramework.php.

ApplicationFramework::AddUnbufferedCallback | ( | $ | Callback,
|  | $ | Parameters = `array()` |
| ) |  |  |

Add a callback that will not be executed after buffered content has been output and that won't have its output buffered.

Parameters:

  | $Callback | callback
  | $Parameters | optional callback parameters in an array

Definition at line 112 of file ApplicationFramework.php.

ApplicationFramework::DeleteTask | ( | $ | TaskId | ) |

Remove task from task queues.

Parameters:

  | TaskId | Task ID.

Definition at line 1022 of file ApplicationFramework.php.

ApplicationFramework::FindCommonTemplate | ( | $ | PageName | ) |

Get full path to HTML or CSS file.

Parameters:

  | PageName | File or short page name.

Definition at line 570 of file ApplicationFramework.php.

Referenced by LoadPage().

Here is the caller graph for this function:

ApplicationFramework::GetElapsedExecutionTime | ( |  | ) |

Get time elapsed since constructor was called.

Returns:
  Elapsed execution time in seconds (as a float).

Definition at line 608 of file ApplicationFramework.php.

Referenced by GetSecondsBeforeTimeout().

Here is the caller graph for this function:

ApplicationFramework::GetOrphanedTaskList | ( | $ | Count = `100`,
|  | $ | Offset = `0` |
| ) |  |  |

Retrieve list of tasks currently in queue.

Parameters:

  | Count | Number to retrieve. (OPTIONAL, defaults to 100)
  | Offset | Offset into queue to start retrieval. (OPTIONAL)

Returns:
  Array with task IDs for index and task info for values. Task info is stored as associative array with "Callback" and "Parameter" indices.

Definition at line 995 of file ApplicationFramework.php.

ApplicationFramework::GetQueuedTaskList | ( | $ | Count = `100`,
|  | $ | Offset = `0` |
| ) |  |  |

Retrieve list of tasks currently in queue.

Parameters:

  | Count | Number to retrieve. (OPTIONAL, defaults to 100)
  | Offset | Offset into queue to start retrieval. (OPTIONAL)

Returns:
  Array with task IDs for index and task info for values. Task info is stored as associative array with "Callback" and "Parameter" indices.

Definition at line 967 of file ApplicationFramework.php.

ApplicationFramework::GetRunningTaskList | ( | $ | Count = `100`,
|  | $ | Offset = `0` |
| ) |  |  |

Retrieve list of tasks currently in queue.

Parameters:

  | Count | Number to retrieve. (OPTIONAL, defaults to 100)
  | Offset | Offset into queue to start retrieval. (OPTIONAL)

Returns:
  Array with task IDs for index and task info for values. Task info is stored as associative array with "Callback" and "Parameter" indices.

Definition at line 980 of file ApplicationFramework.php.

ApplicationFramework::GetSecondsBeforeTimeout | ( |  | ) |

Get remaining available (PHP) execution time.

Returns:
  Number of seconds remaining before script times out (as a float).

Definition at line 617 of file ApplicationFramework.php.

References GetElapsedExecutionTime().

ApplicationFramework::GetTask | ( | $ | TaskId | ) |

Retrieve task info from queue (either running or queued tasks).

Parameters:

  | TaskId | Task ID.

Returns:
  Array with task info for values or NULL if task is not found. Task info is stored as associative array with "Callback" and "Parameter" indices.

Definition at line 1035 of file ApplicationFramework.php.

ApplicationFramework::GetTaskQueueSize | ( | $ | Priority = `NULL` | ) |

Retrieve current number of tasks in queue.

Parameters:

  | Priority | of tasks. (OPTIONAL, defaults to all priorities)

Returns:
  Number of tasks currently in queue.

Definition at line 953 of file ApplicationFramework.php.

ApplicationFramework::GUIFile | ( | $ | FileName | ) |

Search UI directories for specified image or CSS file and return name of correct file.

Parameters:

  | FileName | Base file name.

Returns:
  Full relative path name of file or NULL if file not found.

Definition at line 529 of file ApplicationFramework.php.

Referenced by LoadPage(), and PUIFile().

Here is the caller graph for this function:

ApplicationFramework::HookEvent | ( | $ | EventsOrEventName,
|  | $ | Callback = `NULL`,
|  | $ | Order = `self::ORDER_MIDDLE` |
| ) |  |  |

Hook one or more functions to be called when the specified event is signaled.

The callback parameter is of the PHP type "callback", which allows object methods to be passed.

Parameters:

  | EventsOrEventName | Name of the event to hook. To hook multiple events, this may also be an array, with the event names as the index and the callbacks as the values.
  | Callback | Function to be called when event is signaled. (OPTIONAL if EventsOrEventName is an array of events)
  | Order | Preference for when function should be called, primarily for CHAIN and FIRST events. (OPTIONAL, defaults to ORDER_MIDDLE)

Returns:
  TRUE if all callbacks were successfully hooked, otherwise FALSE.

Definition at line 706 of file ApplicationFramework.php.

ApplicationFramework::HtaccessSupport | ( |  | ) |

Determine if .htaccess files are enabled.

Returns:
  TRUE if .htaccess files are enabled or FALSE otherwise

Definition at line 626 of file ApplicationFramework.php.

ApplicationFramework::HtmlCharset | ( | $ | NewSetting = `NULL` | ) |

Get/set HTTP character encoding value.

This is set for the HTTP header and may be queried and set in the HTML header by the active user interface. The default charset is UTF-8. A list of valid character set values can be found at http://www.iana.org/assignments/character-sets

Parameters:

  | NewSetting | New character encoding value string (e.g. "ISO-8859-1").

Returns:
  Current character encoding value.

Definition at line 449 of file ApplicationFramework.php.

Referenced by LoadPage().

Here is the caller graph for this function:

ApplicationFramework::IsStaticOnlyEvent | ( | $ | EventName | ) |

Report whether specified event only allows static callbacks.

Parameters:

  | EventName | Name of event to check.

Returns:
  TRUE if specified event only allows static callbacks, otherwise FALSE.

Definition at line 835 of file ApplicationFramework.php.

ApplicationFramework::JumpToPageIsSet | ( |  | ) |

Report whether a page to autoload has been set.

Returns:
  TRUE if page is set to autoload, otherwise FALSE.

Definition at line 435 of file ApplicationFramework.php.

ApplicationFramework::LoadFunction | ( | $ | Callback | ) |

Attempt to load code for function or method if not currently available.

Function code to be loaded should be located in a file named "F-XXX.php", where "XXX" is the function name. The file may reside in "local/include", any of the interface "include" directories, or any of the object directories.

Parameters:

  | Callback | Function or method info.

Returns:
  TRUE if function/method is now available, else FALSE.

Definition at line 585 of file ApplicationFramework.php.

ApplicationFramework::LoadPage | ( | $ | PageName | ) |

Load page PHP and HTML/TPL files.

Parameters:

  | PageName | Name of page to be loaded (e.g. "BrowseResources").

Definition at line 142 of file ApplicationFramework.php.

References FindCommonTemplate(), GUIFile(), HtmlCharset(), PHP, and SignalEvent().

ApplicationFramework::MaxExecutionTime | ( | $ | NewValue = `NULL` | ) |

Get/set maximum PHP execution time.

Setting a new value is not possible if PHP is running in safe mode.

Parameters:

  | NewValue | New setting for max execution time in seconds. (OPTIONAL, but minimum value is 5 if specified)

Returns:
  Current max execution time in seconds.

Definition at line 1099 of file ApplicationFramework.php.

ApplicationFramework::MaxTasks | ( | $ | NewValue = `NULL` | ) |

Get/set maximum number of tasks to have running simultaneously.

Parameters:

  | NewValue | New setting for max number of tasks. (OPTIONAL)

Returns:
  Current maximum number of tasks to run at once.

Definition at line 1081 of file ApplicationFramework.php.

ApplicationFramework::OnCrash | ( |  | ) |

Called automatically at program termination to ensure output is written out.

(Not intended to be called directly, could not be made private to class because of automatic execution method.)

Definition at line 1578 of file ApplicationFramework.php.

References PHP.

ApplicationFramework::PUIFile | ( | $ | FileName | ) |

Search UI directories for specified image or CSS file and print name of correct file.

If the file is not found, nothing is printed.

This is intended to be called from within interface HTML files to ensure that the correct file is loaded, regardless of which interface it is in.

Parameters:

  | FileName | Base file name.

Definition at line 560 of file ApplicationFramework.php.

References GUIFile().

ApplicationFramework::QueueTask | ( | $ | Callback,
|  | $ | Parameters = `NULL`,
|  | $ | Priority = `self::PRIORITY_MEDIUM`,
|  | $ | Description = `""` |
| ) |  |  |

Add task to queue.

The Callback parameters is the PHP "callback" type. If $Callback refers to a function (rather than an object method) that function must be available in a global scope on all pages or must be loadable by ApplicationFramework::LoadFunction().

Parameters:

  | Callback | Function or method to call to perform task.
  | Parameters | Array containing parameters to pass to function or method. (OPTIONAL, pass NULL for no parameters)
  | Priority | Priority to assign to task. (OPTIONAL, defaults to PRIORITY_MEDIUM)
  | Description | Text description of task. (OPTIONAL)

Definition at line 867 of file ApplicationFramework.php.

Referenced by QueueUniqueTask().

Here is the caller graph for this function:

ApplicationFramework::QueueUniqueTask | ( | $ | Callback,
|  | $ | Parameters = `NULL`,
|  | $ | Priority = `self::PRIORITY_MEDIUM`,
|  | $ | Description = `""` |
| ) |  |  |

Add task to queue if not already in queue or currently running.

If task is already in queue with a lower priority than specified, the task's priority will be increased to the new value. The Callback parameters is the PHP "callback" type. If $Callback refers to a function (rather than an object method) that function must be available in a global scope on all pages or must be loadable by ApplicationFramework::LoadFunction().

Parameters:

  | Callback | Function or method to call to perform task.
  | Parameters | Array containing parameters to pass to function or method. (OPTIONAL, pass NULL for no parameters)
  | Priority | Priority to assign to task. (OPTIONAL, defaults to PRIORITY_MEDIUM)
  | Description | Text description of task. (OPTIONAL)

Returns:
  TRUE if task was added, otherwise FALSE.

See also:
  TaskIsInQueue

Definition at line 896 of file ApplicationFramework.php.

References QueueTask(), and TaskIsInQueue().

ApplicationFramework::RegisterEvent | ( | $ | EventsOrEventName,
|  | $ | EventType = `NULL` |
| ) |  |  |

Register one or more events that may be signaled.

Parameters:

  | EventsOrEventName | Name of event (string). To register multiple events, this may also be an array, with the event names as the index and the event types as the values.
  | EventType | Type of event (constant). (OPTIONAL if EventsOrEventName is an array of events)

Definition at line 678 of file ApplicationFramework.php.

ApplicationFramework::ReQueueOrphanedTask | ( | $ | TaskId | ) |

Move orphaned task back into queue.

Parameters:

  | TaskId | Task ID.

Definition at line 1007 of file ApplicationFramework.php.

ApplicationFramework::SetBrowserDetectionFunc | ( | $ | DetectionFunc | ) |

Specify function to use to detect the web browser type.

Function should return an array of browser names.

Parameters:

  | DetectionFunc | Browser detection function callback.

Definition at line 101 of file ApplicationFramework.php.

ApplicationFramework::SetJumpToPage | ( | $ | Page | ) |

Set URL of page to autoload after PHP page file is executed.

The HTML/TPL file will never be loaded if this is set. Pass in NULL to clear any autoloading.

Parameters:

  | Page | URL of page to jump to (autoload). If the URL does not appear to point to a PHP or HTML file then "index.php?P=" will be prepended to it.

Definition at line 413 of file ApplicationFramework.php.

ApplicationFramework::SignalEvent | ( | $ | EventName,
|  | $ | Parameters = `NULL` |
| ) |  |  |

Signal that an event has occured.

Parameters:

  | EventName | Name of event being signaled.
  | Parameters | Associative array of parameters for event, with CamelCase parameter names as indexes. (OPTIONAL)

Returns:
  Appropriate return value for event type. Returns NULL if no event with specified name was registered and for EVENTTYPE_DEFAULT events.

Definition at line 767 of file ApplicationFramework.php.

Referenced by LoadPage().

Here is the caller graph for this function:

ApplicationFramework::SuppressHTMLOutput | ( | $ | NewSetting = `TRUE` | ) |

Suppress loading of HTML files.

This is useful when the only output from a page is intended to come from the PHP page file.

Parameters:

  | NewSetting | TRUE to suppress HTML output, FALSE to not suppress HTML output. (OPTIONAL, defaults to TRUE)

Definition at line 461 of file ApplicationFramework.php.

ApplicationFramework::TaskIsInQueue | ( | $ | Callback,
|  | $ | Parameters = `NULL` |
| ) |  |  |

Check if task is already in queue or currently running.

When no $Parameters value is specified the task is checked against any other entries with the same $Callback.

Parameters:

  | Callback | Function or method to call to perform task.
  | Parameters | Array containing parameters to pass to function or method. (OPTIONAL)

Returns:
  TRUE if task is already in queue, otherwise FALSE.

Definition at line 933 of file ApplicationFramework.php.

Referenced by QueueUniqueTask().

Here is the caller graph for this function:

ApplicationFramework::TemplateLocationCacheExpirationInterval | ( | $ | NewInterval = `-1` | ) |

Get/set UI template location cache expiration period in minutes.

An expiration period of 0 disables caching.

Parameters:

  | NewInterval | New expiration period in minutes. (OPTIONAL)

Returns:
  Current expiration period in minutes.

Definition at line 126 of file ApplicationFramework.php.

## Member Data Documentation

const ApplicationFramework::EVENTTYPE_CHAIN = 2

Result chaining event type.

For this type the parameter array to each event handler is the return value from the previous handler, and the final return value is sent back to the event signaller.

Definition at line 647 of file ApplicationFramework.php.

const ApplicationFramework::EVENTTYPE_DEFAULT = 1

Default event type.

Any handler return values are ignored.

Definition at line 641 of file ApplicationFramework.php.

const ApplicationFramework::EVENTTYPE_FIRST = 3

First response event type.

For this type event handlers are called until one returns a non-NULL result, at which point no further handlers are called and that last result is passed back to the event signaller.

Definition at line 653 of file ApplicationFramework.php.

const ApplicationFramework::EVENTTYPE_NAMED = 4

Named result event type.

Return values from each handler are placed into an array with the handler (function or class::method) name as the index, and that array is returned to the event signaller. The handler name for class methods is the class name plus "::" plus the method name. are called and that last result is passed back to the event signaller.

Definition at line 661 of file ApplicationFramework.php.

const ApplicationFramework::NOVALUE = ".-+-.NO VALUE PASSED IN FOR ARGUMENT.-+-."

Definition at line 1721 of file ApplicationFramework.php.

const ApplicationFramework::ORDER_FIRST = 1

Run hooked function first (i.e.

before ORDER_MIDDLE events).

Definition at line 664 of file ApplicationFramework.php.

const ApplicationFramework::ORDER_LAST = 3

Run hooked function last (i.e.

after ORDER_MIDDLE events).

Definition at line 668 of file ApplicationFramework.php.

Referenced by PluginManager::__construct().

const ApplicationFramework::ORDER_MIDDLE = 2

Run hooked function after ORDER_FIRST and before ORDER_LAST events.

Definition at line 666 of file ApplicationFramework.php.

const ApplicationFramework::PRIORITY_BACKGROUND = 4

Lowest priority.

Definition at line 853 of file ApplicationFramework.php.

const ApplicationFramework::PRIORITY_HIGH = 1

Highest priority.

Definition at line 847 of file ApplicationFramework.php.

const ApplicationFramework::PRIORITY_LOW = 3

Lower priority.

Definition at line 851 of file ApplicationFramework.php.

const ApplicationFramework::PRIORITY_MEDIUM = 2

Medium (default) priority.

Definition at line 849 of file ApplicationFramework.php.

Referenced by SPTRecommender::RunUpdateForItem().

The documentation for this class was generated from the following file:

- ApplicationFramework.php