Xataface 2.0
Xataface Application Framework
Data Fields
Dataface_Application Class Reference

The main Application object that handles requests and response. More...

Public Member Functions

Request Context

Methods and Structures for getting information about the current request context.

getQuery ()
 Returns a reference to the current query object. This is very similar to the $_GET and $_REQUEST globals except this array has been filled in with missing values.
getQueryParam ($key)
 Returns a query parameter.
getResultSet ()
 Loads the current result set.
getRecord ()
 Gets the current record based on the current query.
 recordLoaded ()
 Checks is the current record has been loaded yet.
getAction ()
 Gets the settings array for the current action as specified by the -action parameter of the current query.
Event Handling

Methods for dealing with the dispatch of events.

 fireEvent ($name, $params=null)
 Fires an event to all event listeners.
 registerEventListener ($name, $callback)
 Registers an event listener to respond to events of a certain type.
 unregisterEventListener ($name, $callback)
 Unregisters an event listener.
 getEventListeners ($name=null)
 Gets a list of the callbacks that are registered for a given event.
Delegate Class

Methods for obtaining and working with the delegate class.

getDelegate ()
 Returns a reference to the delegate object for this application. The delegate object can be used to define custom functionality for the application.
Permissions

Method wrappers for working with permissions.

 getPermissions ($params=array())
 Returns the permissions that are currently available to the user in the current context. If we are in browse mode then permissions are checked against the current record. Otherwise, permissions are checked against the table.
 checkPermission ($perm)
 Checks if a permission is granted in the current context.
Custom Pages

Methods for working with custom pages. These are seldom used and are not the recommended way to make actions in Xataface.

getCustomPages ()
 PHP files located in the 'pages' directory of the site are considered to be custom pages. Passing the GET parameter -action=custom_<pagename> will cause the Application controller to display the page <pagename>.php from the pages directory. This method just returns an array of full paths to the custom pages that are available in the 'pages' directory.
 getCustomPagePath ($name)
 Obtains the full path (read for inclusion) of the custom page with name $name.
 getCustomPageLabel ($name)
 Obtains the label for a custom page. The label is the same as the name except with capitalization of words and replacement of underscores with spaces.

Data Fields

const EX_FAILED_TO_CREATE_SESSION_DIR = 5500
 $redirectHandler = null
 An object that implements a method named 'redirect' that is supposed to handle requests to redirect to a new page. This gives an opportunity to suppress redirects or handle them differently inline. This is helpful if you're loading Xataface from a cron script or another application and need to prevent redirects.
 $rawQuery
 $prefs
 User preferences matrix.

Languages

Methods for dealing with multiple languages.

 getLanguage ($langCode)
 Returns the language associated with a given language code.
 getLanguageCode ($locale)
 Returns the Xataface language code for a particular locale. E.g. zh_CN would return zh, while zh_TW would return zt.
 getAvailableLanguages ()
 Returns an array of all available languages in the application. This is derived from all languages listed in the [languages] section of the conf.ini file.

Configuration & Initialization

Methods and Data Structures for Storing and Accessing Configuration.

 $_conf
 A configuration array to store configuration information.
 db ()
 Returns MySQL connection resource.
 Dataface_Application ($conf=null)
 Constructor. Do not use this. getInstance() instead.
conf ()
 Returns the config array as loaded from the conf.ini file, except that it opens up the opportunity for the delegate class to load values into the config using its own conf() method.
 getMySQLMajorVersion ()
 Get the mysql major version number of MySQL. returns int.
 getSiteTitle ()
 Gets the site title.
static & getInstance ($conf=null)
 Returns reference to the singleton instance of this class.

Session Handling

Methods and data structures for dealing with Session Handling and authentication.

 saveMessage ($str)
 Sets a message to be displayed as an info/alert the next time a page is rendered. This is handy if your action is performing some funcitons and then redirecting to a new page on complete - and you want the message to be displayed on the other page.
 enableSessions ()
 Sets the cookie that causes sessions to be enabled by default. In order to maximize performance Xataface will try not to start a session until it absolutely has to . This allows public sites to not rack up huge amounts of Session files unnecessarily.
 disableSessions ()
 Unsets the cookie that causes sessions to be enabled by default. Despite the name, this doesn't actually disable sessions. Sessions will still be enabled when they are needed, eg for login. This will just enable them always by default.
 sessionEnabled ()
 Checks if sessions are enabled by default.
 startSession ($conf=null)
 Starts a session if one does not already exist. If you are writing code that needs to use session data it is a good idea to explicitly call this before doing anything with the $_SESSION array. It is safe to call this multiple times.
getAuthenticationTool ()
 Obtains reference to the authentication tool.

Template & UI Interaction

Methods for customizing the output. This includes error messages, and inclusion of content in the head of the document.

 addHeadContent ($content)
 Adds some content meant to be inserted in the head of the application.
 getNavItem ($key, $label=null)
 Returns the nav item info for a key. This is a wrapper around the nav items defined in the [_tables] section of the conf.ini file.
 isNavItemSelected ($key)
 Checks whether the specified nav item is currently selected. This is used by the default implementation of getNavItem() and it an be used also in custom implementations. It can also be overridden by the application delegate class method of the same name.
 addError ($err)
 Adds an error to be displayed in the UI in the messages block.
 numErrors ()
 Returns the number of errors that are to be displayed to the user in the messages block.
 getErrors ()
 Returns an array of the errors that are set to be displayed to the user in the messages block.
 addMessage ($msg)
 Adds a message to be displayed in the messages block.
 getMessages ()
 Gets the messages that are to be displayed in the messages block. This will look in multiple sources for possible messages to display. It will include the following:
 clearMessages ()
 Clears all of the message to be displayed.
 numMessages ()
 Returns the number of messages to be displayed to the user.
static & getResponse ()
 Returns the response array used for compiling response. The response may include messages that need to be displayed to the screen as an alert. Currently the response array only includes a single key: --msg.

Request Handling

Methods for handling the main requests. These methods are responsible for doing the heaving lifting of displaying a page.

 handleRequest ($disableCache=false)
 Handle a request. This method is the starting point for all Dataface application requests. It will delegate the request to the appropriate handler. The order of delegation is as follows:
 display ($main_content_only=false, $disableCache=false)
 Displays the Dataface application.

Utility Functions

Useful functions that are informed by the current context to provide useful functionality to the application as a whole.

 $_parseStringContext = array()
 parseString ($expression, $context=null)
 Evaluates a string expression replacing PHP variables with appropriate values in the current record.
 testCondition ($condition, $context=null)
 Tests an expression for a boolean result. This is primarly used by the condition directive of actions to be able to evaluate boolean expressions to determine if an action should be visible or not.
 url ($query, $useContext=true, $forceContext=false)
 Builds a link to somewhere in the application. This will maintain the existing query information.
 registerUrlFilter ($filter)
 Registers a filter that acts on URLs that are build with link builder. This allows modules to affect URLs as they are built to add, remove, or change parameters.
 filterUrl ($url)
 Filters a URL to add the current table and apply any filters that have been registered using registerUrlFilter()
 redirect ($url)
 Redirects the browser to a particular URL. Using this method rather than using a Location HTTP header directly is preferred as it allows modules to hook in to provide their own redirect handler to override the redirect.

Detailed Description

The main Application object that handles requests and response.

This is the one object that is presumed to always exist in a Dataface request.

 <?php
 require_once 'xataface/public-api.php';
 df_init(__FILE__, '/dataface')->display();
Author:
Steve Hannah (shannah@sfu.ca)
Since:
0.6

Definition at line 87 of file Application.php.


Member Function Documentation

addError ( err)

Adds an error to be displayed in the UI in the messages block.

Parameters:
PEAR_Error$errThe error that is being added.
Returns:
void
See also:
numErrors()
getErrors()
addMessage() To add string messages instead of Error objects.

Definition at line 1606 of file Application.php.

addHeadContent ( content)

Adds some content meant to be inserted in the head of the application.

Parameters:
string$content
Returns:
void
Example
Adding A CSS stylesheet in the <head> of the page
 $app->addHeadContent('<link rel="stylesheet" type="text/css" href="styles.css"/>');
Attention:
If possible, you should try to use the Dataface_JavascriptTool class for adding javascripts and CSS stylesheets to your application's output.
Since:
1.0
See also:
Dataface_JavascriptTool
Dataface_CSSTool

Definition at line 1524 of file Application.php.

addMessage ( msg)

Adds a message to be displayed in the messages block.

Parameters:
string$msgThe messag to be displayed.
Returns:
void
See also:
addError()

Definition at line 1639 of file Application.php.

checkPermission ( perm)

Checks if a permission is granted in the current context.

This is essentially a wrapper around the getPermissions() method that goes on to check for the existence of a permission.

Parameters:
string$permThe name of a permission to check.
Returns:
boolean True if the permission is granted.
See also:
getPermissions()

Definition at line 2741 of file Application.php.

clearMessages ( )

Clears all of the message to be displayed.

Returns:
void

Definition at line 1672 of file Application.php.

& conf ( )

Returns the config array as loaded from the conf.ini file, except that it opens up the opportunity for the delegate class to load values into the config using its own conf() method.

This is useful if an application wants to store config information in the database and still make it available to the application.

Returns:
array

Definition at line 995 of file Application.php.

Dataface_Application ( conf = null)

Constructor. Do not use this. getInstance() instead.

The garbage collector threshold is the number of seconds that "garbage" can exist for before it is deleted. Examples of "garbage" include import tables (ie: temporary tables created as an intermediate point to importing data).

Definition at line 469 of file Application.php.

db ( )

Returns MySQL connection resource.

Definition at line 459 of file Application.php.

disableSessions ( )

Unsets the cookie that causes sessions to be enabled by default. Despite the name, this doesn't actually disable sessions. Sessions will still be enabled when they are needed, eg for login. This will just enable them always by default.

See also:
enableSessions()
sessionEnabled()
startSession()

Definition at line 1295 of file Application.php.

display ( main_content_only = false,
disableCache = false 
)

Displays the Dataface application.

Parameters:
boolean$main_content_onlyWhether to only show the main content or to show the full page with header and footer. This parameter is not respected by many of the current templates and may be removed in later releases.
boolean$disableCacheWhether to disable the output cache. It is enabled by default.
Flow Chart
Display_flow_control.png?max_width=640

Enlarge.

Definition at line 2134 of file Application.php.

enableSessions ( )

Sets the cookie that causes sessions to be enabled by default. In order to maximize performance Xataface will try not to start a session until it absolutely has to . This allows public sites to not rack up huge amounts of Session files unnecessarily.

See also:
disableSessions()
sessionsEnabled()

Definition at line 1282 of file Application.php.

filterUrl ( url)

Filters a URL to add the current table and apply any filters that have been registered using registerUrlFilter()

Parameters:
string$urlThe URL to be filtered.
Returns:
string The filtered URL.
See also:
registerUrlFilter()

Definition at line 2595 of file Application.php.

fireEvent ( name,
params = null 
)

Fires an event to all event listeners.

Parameters:
string$nameThe name of the event. e.g. afterInsert
array$paramsArray of parameters to pass to the event listener.
Returns:
mixed Result of event. May be PEAR_Error if the event throws an error.
See also:
registerEventListener()

Definition at line 1729 of file Application.php.

& getAction ( )

Gets the settings array for the current action as specified by the -action parameter of the current query.

Returns:
array Action parameters (or null if action doesn't exist).

Definition at line 1237 of file Application.php.

& getAuthenticationTool ( )

Obtains reference to the authentication tool.

Returns:
Dataface_AuthenticationTool

Definition at line 1471 of file Application.php.

getAvailableLanguages ( )

Returns an array of all available languages in the application. This is derived from all languages listed in the [languages] section of the conf.ini file.

Returns:
array Array of 2-digit xataface language codes.
Since:
1.0
Example conf.ini:
 [languages]
        en=English
  fr=French
Example Inputs:
 $app->getAvailableLanguages();
Example Outputs:
 array(
        en => English
  fr => French
 )

Definition at line 431 of file Application.php.

getCustomPageLabel ( name)

Obtains the label for a custom page. The label is the same as the name except with capitalization of words and replacement of underscores with spaces.

Parameters:
string$nameThe custom page name.
Returns:
string The label for the custom page.

Definition at line 2862 of file Application.php.

getCustomPagePath ( name)

Obtains the full path (read for inclusion) of the custom page with name $name.

Parameters:
string$nameThe name of a custom page.
Returns:
string The path to the custom page.

Definition at line 2849 of file Application.php.

& getCustomPages ( )

PHP files located in the 'pages' directory of the site are considered to be custom pages. Passing the GET parameter -action=custom_<pagename> will cause the Application controller to display the page <pagename>.php from the pages directory. This method just returns an array of full paths to the custom pages that are available in the 'pages' directory.

Returns:
array Array of all of the pages in the pages directory that can be used as custom pages.

Definition at line 2822 of file Application.php.

& getDelegate ( )

Returns a reference to the delegate object for this application. The delegate object can be used to define custom functionality for the application.

Returns:
ApplicationDelegateClass The application delegate class instance. Or null if none defined.
See also:
ApplicationDelegateClass

Definition at line 2666 of file Application.php.

getErrors ( )

Returns an array of the errors that are set to be displayed to the user in the messages block.

Returns:
PEAR_Error[]
See also:
addError()
numErrors()

Definition at line 1627 of file Application.php.

getEventListeners ( name = null)

Gets a list of the callbacks that are registered for a given event.

Parameters:
$nameThe name of the event for which the callbacks are registered.
Returns:
array Either an array of callbacks for the event. Or associative array of array of callbacks for all events with the key on the event name.

Definition at line 1774 of file Application.php.

static& getInstance ( conf = null) [static]

Returns reference to the singleton instance of this class.

Parameters:
array$confOptional configuration associative array that matches the stucture of the conf.ini file. This parameter will only be considered the first time this method is called in the request.
Returns:
Dataface_Application
Since:
0.6
Example

Definition at line 969 of file Application.php.

getLanguage ( langCode)

Returns the language associated with a given language code.

Parameters:
string$langCodeThe 2-digit xataface language code. May be non-standard.
Returns:
string The 2-digit ISO-639 language code corresponding to the Xataface language code.
Since:
1.0
Example

Given a languages section in your conf.ini file that resembles:

Inputs:
 echo $app->getLanguage('zt');
 echo "\n". $app->getLanguage('zh');
Outputs
 zh
 zh
Since:
1.2

Definition at line 368 of file Application.php.

getLanguageCode ( locale)

Returns the Xataface language code for a particular locale. E.g. zh_CN would return zh, while zh_TW would return zt.

Parameters:
string$localeA local in the form <lang>_<COUNTRY>. E.g. en_US or zh_CN
Returns:
string The 2-digit xataface language code that handles the locale.
Inputs:
        echo $app->getLanguageCode('zh_TW');
Outputs:
        zh
Since:
1.2

Definition at line 394 of file Application.php.

getMessages ( )

Gets the messages that are to be displayed in the messages block. This will look in multiple sources for possible messages to display. It will include the following:

  1. $_SESSION['msg']
  2. $app->messages
  3. $app->response['--msg']
Returns:
string[]

Definition at line 1654 of file Application.php.

getMySQLMajorVersion ( )

Get the mysql major version number of MySQL. returns int.

Definition at line 1027 of file Application.php.

getNavItem ( key,
label = null 
)

Returns the nav item info for a key. This is a wrapper around the nav items defined in the [_tables] section of the conf.ini file.

This can be overridden using the Application Delegate class method of the same name.

Parameters:
string$keyThe key of the nav item. This would be the table name if using the traditional simple table nav items.
string$labelThe label for the nav item. This would be the table label if using the traditional simple table nav items.
Returns:
array
                href => The URL where the nav item is to link
                label => The label for the nav item.
                selected => boolean value indicating whether the item is currently selected.
See also:
isNavItemSelected()

Definition at line 1549 of file Application.php.

getPermissions ( params = array())

Returns the permissions that are currently available to the user in the current context. If we are in browse mode then permissions are checked against the current record. Otherwise, permissions are checked against the table.

This will first try to get the permissions on the current record (as retrieved via getRecord()), and if no record is currently selected, it will get the permissions on the current table.

Parameters:
array$paramsParameters that can be passed to getPermissions to specify a particular field or relationship.
Returns:
array Array of permissions / permissions matrix.
See also:
Dataface_Record::getPermissions()
Dataface_Table::getPermissions()
checkPermission()

Definition at line 2714 of file Application.php.

& getQuery ( )

Returns a reference to the current query object. This is very similar to the $_GET and $_REQUEST globals except this array has been filled in with missing values.

Returns:
array Reference to current query object.
Example
 $query =& $app->getQuery();
 if ( $query['-table'] == 'dashboard' ){
                // Always set the action for the dashboard to 'dashboard_action'
                $query['-action'] = 'dashboard_action';
 }

Definition at line 1094 of file Application.php.

& getQueryParam ( key)

Returns a query parameter.

Parameters:
string$keyThe query parameter to obtain. This should omit the leading '-' in the parameter name. E.g. Instead of '-action' this will be 'action'.
Returns:
mixed The query parameter or null if not present.
Example
Input:
 echo $app->getQueryParam('table');
 $query = $app->getQuery();
 echo $app['-table'];

Output:

 my_table
 my_table

Definition at line 1121 of file Application.php.

& getRecord ( )

Gets the current record based on the current query.

Returns:
Dataface_Record
How Is the Record Selected?
  1. It checks for the __keys__ parameter and uses these keys as a filter.
  2. It then checks for the -__keys__ parameter and uses these keys as a filter.
  3. It then checks for the --__keys__ parameter and uses these keys as a filter.
  4. It then checks for the --recordid parameter and returns the specified record.
  5. It then checks for the -recordid parameter and returns the specified record.
  6. It then loads the current result set and returns the record specified by the -cursor parameter (which is default 0).
The --no-query Parameter
Attention:
This method may be affected by the --no-query parameter which tells Xataface that no query should be performed automatically during this request. This parameter is meant for performance reasons so save load on the database at the developer's request. If --no-query is specified, then this method will simply return null.
Example
Given the following query:
        array(
                user_id => 10
  )
 @code
 We have @code
 $rec = $app->getRecord();  // Record with user_id 10.

Given the query:

 array(
     user_id => 10,
     -recordid => 'users?user_id=11'
 )

We have

 $rec = $app->getRecord() // Record with user_id 11

Definition at line 1187 of file Application.php.

static& getResponse ( ) [static]

Returns the response array used for compiling response. The response may include messages that need to be displayed to the screen as an alert. Currently the response array only includes a single key: --msg.

Returns:
array A response array with the following keys:
        --msg => <string> 

Definition at line 1698 of file Application.php.

& getResultSet ( )

Loads the current result set.

Returns:
Dataface_QueryTool

Definition at line 1134 of file Application.php.

getSiteTitle ( )

Gets the site title.

Returns:
string The site title.

If $app->_conf['title'] is set then this will just return that. If not it will determine an appropriate title based on the current record and the current table.

Definition at line 1045 of file Application.php.

handleRequest ( disableCache = false)

Handle a request. This method is the starting point for all Dataface application requests. It will delegate the request to the appropriate handler. The order of delegation is as follows:

  1. Uses the ActionTool to check permissions for the action. If permissions are not granted, dispatch the error handler. If permissions are granted then we continue down the delegation chain.
  2. If the current table's delegate class defines a handleRequest() method, then call that.
    1. If the current table's delegate class does not have a handleRequest() method or that method returns a PEAR_Error object with code E_DATAFACE_REQUEST_NOT_HANDLED, then check for a handler bearing the name of the action in one of the actions directories. Check the directories in the following order: a. <site url>="">/tables/
      b. <site url>="">/actions b. <dataface url>="">/actions
    2. If no handler can be found then use the default handler. The default handler can be quite powerful as it accepts the '-template' query parameter to use a specific template for display.
Parameters:
boolean$disableCacheWhether to disable the cache or not for this request.
See also:
ApplicationDelegateClass::beforeHandleRequest()

Definition at line 1824 of file Application.php.

isNavItemSelected ( key)

Checks whether the specified nav item is currently selected. This is used by the default implementation of getNavItem() and it an be used also in custom implementations. It can also be overridden by the application delegate class method of the same name.

Parameters:
string$keyThe nav item key. Traditionally the table name if using simple table navigation items.
Returns:
boolean True if the item is meant to be selected.
See also:
getNavItem()
ApplicationDelegateClass::isNavItemSelected()

Definition at line 1583 of file Application.php.

numErrors ( )

Returns the number of errors that are to be displayed to the user in the messages block.

Returns:
int
See also:
addError()
getErrors()

Definition at line 1618 of file Application.php.

numMessages ( )

Returns the number of messages to be displayed to the user.

Returns:
int

Definition at line 1680 of file Application.php.

parseString ( expression,
context = null 
)

Evaluates a string expression replacing PHP variables with appropriate values in the current record.

Parameters:
string$expressionA string containing PHP variables that need to be evaluated.
Dataface_Record$contextA Dataface_Record, Dataface_RelatedRecord object, or array whose values are treated as local variables when evaluating the expression.
Example expressions:
'${site_href}?-table=Profiles&ProfileID==${ProfileID}' -- in the above example, ${site_href} would be replaced with the url (including script name) of the site, and ${ProfileID} would be replaced with the value of the ProfileID field in the current record.
Expression Context
The following variables are set up in the context and can be used in the expression:
VariableTypeDescription
$site_urlString The Site URL (i.e. DATAFACE_SITE_URL). This includes the URL to the folder containing the application. It doesn't include the index.php file.
$site_hrefString The Site HREF (i.e. DATAFACE_SITE_HREF). This is the URL to the index.php file.
$dataface_urlString The URL to the Xataface directory.
$tableString The name of the current table.
$tableObjDataface_Table Reference to the Dataface_Table object encapsulating the current table.
$queryarray The current query array. See getQuery()
$resultSetDataface_QueryTool The current query result set. See getResultSet()
$recordDataface_Record The current record. This may be obtained from the 'record' key of the $context parameter. If omitted, then this will be the result of getRecord()
$relationshipDataface_Relationship The current relationship. This may be passed as the 'relationship' key of the $context parameter. If omitted then it is loaded from the current table and the $query['-relationship'] parameter.

Definition at line 2350 of file Application.php.

recordLoaded ( )

Checks is the current record has been loaded yet.

Returns:
boolean
See also:
getRecord()

Definition at line 1226 of file Application.php.

redirect ( url)

Redirects the browser to a particular URL. Using this method rather than using a Location HTTP header directly is preferred as it allows modules to hook in to provide their own redirect handler to override the redirect.

Parameters:
string$urlThe URL to redirect to.
Returns:
void
Redirect Handlers
You can assign your own redirect behavior by setting the redirect handler fo the application.

Definition at line 2633 of file Application.php.

registerEventListener ( name,
callback 
)

Registers an event listener to respond to events of a certain type.

Parameters:
string$nameThe name of the event to register for. e.g. afterInsert
mixed$callbackA standard PHP callback. Either a function name or an array of the form array(&$object,'method-name').
Returns:
void.
See also:
fireEvent()
unregisterEventListener()

Definition at line 1748 of file Application.php.

registerUrlFilter ( filter)

Registers a filter that acts on URLs that are build with link builder. This allows modules to affect URLs as they are built to add, remove, or change parameters.

Parameters:
callback$filterA callback function that follow the PHP callback conventions and call be called with call_user_func. This should accept a string as a input and provide the modified string as output.
Returns:
void
Example

A filter to add -foo=1 to the end of all URLs:

 function addFoo($string){
     return $string.'&-foo=1';
 }
 $app = Dataface_Application::getInstance();
 $app->registerUrlFilter('addFoo');
 
 // Now any URL produced will include &-foo=1 at the end of it
 $url = $app->url('');
     // Outputs index.php?-table=test&-action=list&-foo=1
See also:
filterUrl()

Definition at line 2581 of file Application.php.

saveMessage ( str)

Sets a message to be displayed as an info/alert the next time a page is rendered. This is handy if your action is performing some funcitons and then redirecting to a new page on complete - and you want the message to be displayed on the other page.

Parameters:
string$strThe message that should be displayed.
Returns:
void
Example
 $app->saveMessage("The record was saved successfully.");

Definition at line 1269 of file Application.php.

sessionEnabled ( )

Checks if sessions are enabled by default.

Returns:
boolean
See also:
enableSessions()
disableSessions()
startSession()

Definition at line 1307 of file Application.php.

startSession ( conf = null)

Starts a session if one does not already exist. If you are writing code that needs to use session data it is a good idea to explicitly call this before doing anything with the $_SESSION array. It is safe to call this multiple times.

Parameters:
array$confOptional configuration data that should follow the format of $app->_conf['_auth']
See also:
enableSessions()
disableSessions()

Definition at line 1322 of file Application.php.

testCondition ( condition,
context = null 
)

Tests an expression for a boolean result. This is primarly used by the condition directive of actions to be able to evaluate boolean expressions to determine if an action should be visible or not.

Parameters:
string$conditionA string that is executed in the sandbox context.
array$contextExtra context information to include. This does not allow arbitrary variables to be added to the context, only specific ones.
Returns:
boolean
Expression Context
The following variables are set up in the context and can be used in the expression:
VariableTypeDescription
$site_urlString The Site URL (i.e. DATAFACE_SITE_URL). This includes the URL to the folder containing the application. It doesn't include the index.php file.
$site_hrefString The Site HREF (i.e. DATAFACE_SITE_HREF). This is the URL to the index.php file.
$dataface_urlString The URL to the Xataface directory.
$tableString The name of the current table.
$tableObjDataface_Table Reference to the Dataface_Table object encapsulating the current table.
$queryarray The current query array. See getQuery()
$resultSetDataface_QueryTool The current query result set. See getResultSet()
$recordDataface_Record The current record. This may be obtained from the 'record' key of the $context parameter. If omitted, then this will be the result of getRecord()
$relationshipDataface_Relationship The current relationship. This may be passed as the 'relationship' key of the $context parameter. If omitted then it is loaded from the current table and the $query['-relationship'] parameter.
See also:
Dataface_ActionTool
parseString()

Definition at line 2479 of file Application.php.

unregisterEventListener ( name,
callback 
)

Unregisters an event listener.

See also:
registerEventListener()
fireEvent()

Definition at line 1760 of file Application.php.

url ( query,
useContext = true,
forceContext = false 
)

Builds a link to somewhere in the application. This will maintain the existing query information.

Parameters:
mixed$queryEither a query string or a query array.
boolean$useContextWhether to use the existing context variables or not.
boolean$forceContextWhether to force context.
See also:
Dataface_LinkTool::buildLink()
Example Using Query Array
Given that the current page is located at http://example.com/path/to/app/index.php?-table=foo&-action=bar&username=ted
 echo $app->url(array('-action'=>'browse'));
Output is:
 /path/to/app/index.php?-table=foo&action=browse&username=ted

(Actually this isn't entirely correct... the entire context will also be included and Xataface calculates some default context parameters at the beginning of every request so the actually result will include parameters like -skip, -limit, -cursor, etc.. as well).

Definition at line 2537 of file Application.php.


Field Documentation

$_conf

A configuration array to store configuration information.

Definition at line 464 of file Application.php.

$_parseStringContext = array()

Definition at line 2282 of file Application.php.

$prefs
Initial value:
 array(
                'show_result_stats'=>1, 
                'show_jump_menu'=>1,    
                'show_result_controller'=>1,    
                'show_table_tabs'=>1,                   
                'show_actions_menu'=>1,                 
                'show_logo'=>1,                                 
                'show_tables_menu'=>1,                  
                'show_search'=>1,                               
                'show_record_actions'=>1,               
                'show_recent_records_menu'=>1,  
                'show_bread_crumbs' => 1,               
                'show_record_tabs' => 1,                
                'show_record_tree' => 1,                
                'list_view_scroll_horizontal'=>1, 
                'list_view_scroll_vertical'=>1  
        
        )

User preferences matrix.

Definition at line 219 of file Application.php.

$rawQuery

Definition at line 182 of file Application.php.

$redirectHandler = null

An object that implements a method named 'redirect' that is supposed to handle requests to redirect to a new page. This gives an opportunity to suppress redirects or handle them differently inline. This is helpful if you're loading Xataface from a cron script or another application and need to prevent redirects.

Example

 $app = Dataface_Application::getInstance();
 class MyHandler {
     function redirect($url){
         echo "A request to redirect to $url.";
     }
 }
 $app->redirectHandler = new MyHandler();
 $app->display();

Note that if your handler does not either throw an exception or exit execution, then Xataface will throw a Dataface_Application_RedirectException which can be caught higher up the call stack.

Definition at line 117 of file Application.php.

Definition at line 89 of file Application.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations