Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
Static Public Member Functions
Dataface_Utilities Class Reference

Static Public Member Functions

static groupBy ($fieldname, $records, $order=array(), $titles=array())
static query2html ($query, $keyFilter=array())
static flattenQuery ($in, &$out, $path=array())
static fireEvent ($name, $params=array())
static quoteIdent ($ident)
static redirect ($msg=null, $error=null)

Detailed Description

Contains Utility functions.

Definition at line 26 of file Utilities.php.

Member Function Documentation

static fireEvent (   $name,
  $params = array() 
)
static

Fires an event on the delegate classes. In effect, this calls a method called $name on the current table's delegate class if it exists - otherwise it will call the function on the application's delegate class - if it exists.

Parameters
string$nameThe name of the event. Must be valid method name in a delegate class.
Returns
void

Definition at line 202 of file Utilities.php.

static flattenQuery (   $in,
$out,
  $path = array() 
)
static

Flattens the variables of a query so that they can be written safely to an HTML form.

E.g.: [ 'userid'=>10, 'FirstName'=>'Steve', 'LastName'=>'Hannah', 'Address'=> [ 'Country'=>'Canada', 'Province'=>'BC' ] ] would be converted to: [ 'userid'=>10, 'FirstName'=>'Steve', 'LastName'=>'Hannah', 'Address[Country]'=>'Canada', 'Address[Province]'=>'BC' ]

Parameters
array$inThe input query array.
array&$outThe output query array.
$path$path An array representing the path of the current element since this method uses itself recursively.
Returns
void

Definition at line 167 of file Utilities.php.

static groupBy (   $fieldname,
  $records,
  $order = array(),
  $titles = array() 
)
static

Groups an array of records by a field.

Parameters
string$fieldnameThe name of the field on which to group the records.
array$recordsThe array of records. This may be an array of associative arrays, an array of Dataface_Record objects, or an array of Dataface_RelatedRecord objects.
Returns
Array( [Grouped Field value] -> Array(Records) )

Definition at line 38 of file Utilities.php.

static query2html (   $query,
  $keyFilter = array() 
)
static

Converts an query array into a string with a bunch of HTML hidden fields to be placed on an HTML form.

E.g.: $html = Dataface_Utilities::query2Html( array('FirstName'=>'Steve', 'LastName'=>'Hannah', 'Address'=>array('Country'=>'Canada', 'Province'=>'BC') ) );

echo $html; Would output: <input type="hidden" name="FirstName" value="Steve"> <input type="hidden" name="LastName" value="Hannah"> <input type="hidden" name="Address[Country]" value="Canada"> <input type="hidden" name="Address[Province]" value="BC">

Parameters
array$queryArray of request query parameters. e.g. $_REQUEST
array$keyFilterOptional array of keys that should be omitted.
Returns
string

Definition at line 117 of file Utilities.php.

static quoteIdent (   $ident)
static

Quotes identifiers for use in SQL queries.

Definition at line 227 of file Utilities.php.

static redirect (   $msg = null,
  $error = null 
)
static

Redirects the user to a new page based on the query attributes: –redirect, –error_page, and –success_page.

Parameters
string$msgThe message to be sent as the –msg attribute.
PEAR_ErrorThe error object in case we should be sending back an error code.

This also respects the –prefix GET parameter that will be prepended to the names of the –msg, –error_code, and –error_message variables that are passed to the redirected pages.

Definition at line 242 of file Utilities.php.


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