<?xml version="1.0"?>
<record><wiki id="wiki?page_id=44">
	<page_name>timestamp</page_name>
	<page_id>44</page_id>
	<page_title>timestamp</page_title>
	<content>Return to [[fields.ini file]]

A very simple sample of this could be your table contains the table date_created as a type of date.  In your fields.ini, you would include this:

&lt;code&gt;
[date_created]
timestamp=insert
widget:type=hidden
&lt;/code&gt;

The widget:type=hidden will make the field not visible during entry and editing.  And the timestamp=insert causes the field to be filled upon insertion of a new record.

===Possible Values===

* &apos;&apos;&apos;update&apos;&apos;&apos; - Causes timestamp to be updated whenever the record is modified.
* &apos;&apos;&apos;insert&apos;&apos;&apos; - Causes the timestamp to be updated only when the record is first inserted.</content>
	<keywords>timestamp, date, datetime</keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=126">
	<page_name>getChildren</page_name>
	<page_id>126</page_id>
	<page_title>getChildren Delegate Class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

The getChildren() method can be implemented in a table&apos;s delegate class to specify the logical &quot;child&quot; records of a given record which can be used when creating hierarchical applications.  This method will effectively override the output of the Dataface_Record::getChildren() method for records of this table.

===Signature===

&lt;code&gt;
function getChildren( Dataface_Record $record) : Dataface_Record[]
&lt;/code&gt;

===Parameters===

# &apos;&apos;&apos;$record&apos;&apos;&apos; - The Dataface_Record that is the subject of the query 

===Returns===

This method should return an array of Dataface_Record objects that are considered to be children of the subject record.

===Examples===

&lt;code&gt;
function getChildren($record){
    return df_get_records(&apos;webpages&apos;, 
        array(
            &apos;parent_id&apos;=&gt;&apos;=&apos;.$record-&gt;val(&apos;webpage_id&apos;)
        )
    );
}
&lt;/code&gt;


==See Also==

* &apos;&apos;&apos;[[getParent]]&apos;&apos;&apos; - A Delegate class method to return the logical parent of a given record.</content>
	<keywords>getChildren Delegate class method</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=108">
	<page_name>beforeAddRelatedRecord</page_name>
	<page_id>108</page_id>
	<page_title>beforeAddRelatedRecord Delegate Class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

==Synopsis==

The &apos;&apos;beforeAddRelatedRecord&apos;&apos; delegate class method can be implemented in any table&apos;s delegate class.  It will be executed before any related record is added to that table&apos;s relationships.  Since it will be fired for all relationships on the table, you will have to include logic to only execute if the relationship that you are targeting is being added to.

==Method Signature==

&lt;code&gt;
function beforeAddRelatedRecord( Dataface_RelatedRecord $record );
&lt;/code&gt;

==Parameters==

* &apos;&apos;&apos;$record&apos;&apos;&apos; - The [http://dataface.weblite.ca/Dataface_RelatedRecord Dataface_RelatedRecord] object encapsulating the record that is being added to the relationship.

===Returns===

* void - If all is well
* [http://dataface.weblite.ca/Dataface_Error Dataface_Error] object if something went wrong.  

It is quite common to return a permission denied error from this method after doing some checks. e.g.

&lt;code&gt;
function beforeAddRelatedRecord($record){
    if ( /* some checks here */ ){
        return Dataface_Error::permissionDenied(&apos;Sorry you don\&apos;t have permission to do this.&apos;);
    }
}
&lt;/code&gt;

==Examples==

===Example 1: Permission Check===

&lt;code&gt;
function beforeAddRelatedRecord($record){
    if ( $record-&gt;_relationshipName == &apos;program_roles&apos; ){
        // check to make sure that we are allowed to add roles to this program
        $program = df_get_record(&apos;programs&apos;, array(&apos;program_id&apos;=&gt;&apos;=&apos;.$record-&gt;val(&apos;program_id&apos;)));
        if ( !$program ){
            return Dataface_Error::permissionDenied(&quot;Program could not be found&quot;);
        }
        if ( !$program-&gt;checkPermission(&apos;add new related record&apos;, array(
                &apos;relationship&apos; =&gt; &apos;program_roles&apos;
                )
             )
           ){
            return Dataface_Error::permissionDenied(&quot;You don&apos;t have permission to add roles to this program&quot;);
        }
    }
}
&lt;/code&gt;

The above example requires a little bit of context to understand.  This method is defined in the &apos;users&apos; table.  There is a relationship between the &apos;&apos;users&apos;&apos; table and the &apos;&apos;programs&apos;&apos; table called &apos;program_roles&apos;.  It keeps track of the roles that users have with respect to programs.  There is a mirror relationshp in the &apos;&apos;programs&apos;&apos; table that goes to the &apos;&apos;users&apos;&apos; table, also named &apos;&apos;program_roles&apos;&apos;.  Both the &apos;&apos;users&apos;&apos; table and the &apos;&apos;programs&apos;&apos; table contain rel_program_roles__roles() methods to define who can and cannot add to this relationship.  However these don&apos;t discern on the content that is being added to the relationship, so it is still possible that an ineligible program could be added to the relationship via the users table (or vice versa).

So, in the &apos;&apos;users&apos;&apos; table we defined the &apos;&apos;beforeAddRelatedRecord&apos;&apos; above which checks the permissions of the programs table to see if that particular program can be added to this relationship by this user.


==See Also==

* [http://dataface.weblite.ca/Dataface_RelatedRecord Dataface_RelatedRecord API Docs]
* [[Delegate class methods]]
* [http://xataface.com/documentation/tutorial/getting_started/relationships Introduction to Relationships] - from the Getting Started Tutorial
* [[relationships.ini file]] reference
</content>
	<keywords>beforeAddRelatedRecord, Delegate class methods, relationship triggers</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=133">
	<page_name>fieldname__default</page_name>
	<page_id>133</page_id>
	<page_title>fieldname__default Delegate Class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

===Synopsis===

Xataface allows you to pre-populate any particular field in a table by adding a fieldname__default method to the table&apos;s delegate class of the form:
&lt;code&gt;
function fieldname__default(){
    return value;
}&lt;/code&gt;

Returns the default value for the field fieldname. New record forms will be prepopulated with this value.

===Examples===

&lt;code&gt;
function minimum_bid__default(){
    return 100;
}&lt;/code&gt;

&lt;code&gt;
function mydatecol__default(){
    return date(&apos;Y-m-d&apos;);
}&lt;/code&gt;

&lt;code&gt;
function owner_id__default(){
    $auth =&amp; Dataface_AuthenticationTool::getInstance();
    $user =&amp; $auth-&gt;getLoggedInUser();
    if ( isset($user) ) return $user-&gt;val(&apos;userid&apos;);
    return null;
}&lt;/code&gt;

===See Also===

* [http://xataface.com/forum/viewtopic.php?t=5028 Pre-entered Data] (forum thread) - setting defaults field values on general fields using the fieldname__default delegate class function
* [http://xataface.com/forum/viewtopic.php?t=4004 How to initialize a Date field to today&apos;s date?] (forum thread) - alternate methods to use specifically with a date/time field
* [http://xataface.com/forum/viewtopic.php?t=3988 Setting default select setting from users table] (forum thread) - solution to populate the current user</content>
	<keywords>default, initialize, populate, pre-populate, delegate class default</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=94">
	<page_name>fieldname__validate</page_name>
	<page_id>94</page_id>
	<page_title>fieldname__validate Delegate Class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

===Synopsis===

Xataface allows you to add validation on any particular field in table by adding a fieldname__validate method to the table&apos;s delegate class of the form:
&lt;code&gt;
function myfield__validate(&amp;$record, $value, &amp;$params){
    if ( $value != &apos;Steve&apos; ){
        $params[&apos;message&apos;] = &apos;Sorry you must enter &quot;Steve&quot;&apos;;
        return false;
    }
    return true;
}
&lt;/code&gt;

===Parameters===

* &amp;$record : A [http://dataface.weblite.ca/Dataface_Record Dataface_Record] object encapsulating the record we are validating.  Note that the values of this object correspond with the submitted values from the form, and not necessarily the actual values of the record in the database.
* $value : The value that is being inserted.
* &amp;$params : An output array that can be used to pass back a message if validation fails.  You would set this array&apos;s &apos;message&apos; parameter to be a message.

===Returns===

Returns a boolean value.  True if the value is ok and false if validation failed.

===See Also===

* [[validators]] - For simple validation rules you can use the [[validators|validator:VALIDATOR_NAME]] directive of the [[fields.ini file]].
* [http://xataface.com/documentation/tutorial/getting_started/validation Form Validation] - Section on form validation in the Getting Started tutorial.

</content>
	<keywords>validate, validation, delegate class validation, custom validator</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=124">
	<page_name>beforeCopy</page_name>
	<page_id>124</page_id>
	<page_title>beforeCopy Delegate Class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

===Synopsis===

A delegate class method that will be executed before a record is copied using the copy set or copy selected function.  All xataface copies are shallow which means that related records are not copied by default.  If you want a more complex copy function for a table you can implement functionality in this hook.

Available since version 1.3

===Signature===
&lt;code&gt;
function beforeCopy( Dataface_Record $original, array $values);
&lt;/code&gt;

===Parameters===

* &apos;&apos;&apos;$original&apos;&apos;&apos; - The original record that is to be copied.
* &apos;&apos;&apos;$values&apos;&apos;&apos; - Associative array of values that are meant to be changed in the copy.  Keys correspond with column names.

===Returns===

* Either return nothing or you may return a PEAR_Error object to indicate that an error occurred with the copy.

==See Also==

* [[afterCopy]] - The afterCopy hook that can be implemented in the delegate class to run just after a record is copied.
</content>
	<keywords>beforeCopy, copy records</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=123">
	<page_name>afterCopy</page_name>
	<page_id>123</page_id>
	<page_title>afterCopy Delegate class Method</page_title>
	<content>Return to [[Delegate class methods]]

[[toc]]

===Synopsis===

A delegate class method that will be executed after a record is copied using the copy set or copy selected function.  All xataface copies are shallow which means that related records are not copied by default.  If you want a more complex copy function for a table you can implement functionality in this hook.

Available since version 1.3

===Signature===
&lt;code&gt;
function afterCopy( Dataface_Record $original, Dataface_Record $copy);
&lt;/code&gt;

===Parameters===

* &apos;&apos;&apos;$original&apos;&apos;&apos; - The original record that was copied.
* &apos;&apos;&apos;$copy&apos;&apos;&apos; - The resulting copied record.

===Returns===

* Either return nothing or you may return a PEAR_Error object to indicate that an error occurred with the copy.

==See Also==

* [[beforeCopy]] - The beforeCopy hook that can be implemented in the delegate class to run just before a record is copied.
</content>
	<keywords>afterCopy, copy record hook</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=141">
	<page_name>field__fieldname</page_name>
	<page_id>141</page_id>
	<page_title>Defining Calculated Fields</page_title>
	<content>Return to [[Delegate class methods]]

Xataface allows you to define calculated fields using the delegate class.  These fields won&apos;t be visible in the UI by default, but they will be accessible to some modules (e.g. the HTML Reports Module) and they are always accessible to you via the API.

E.g.  If you define a calculated field named &apos;&apos;year&apos;&apos;, you would be able to access this value using the regular Dataface_Record syntax:

&lt;code&gt;
$record-&gt;val(&apos;year&apos;);
&lt;/code&gt;

You could also define any number of filter methods and permissions on this field just as you can on regular fields.

e.g. &lt;code&gt;
function year__permissions($record){
    // Return special permissions on the year field.
}
&lt;/code&gt;

or &lt;code&gt;
function year__display($record){
    // Override how the year is displayed in the UI.
    return $record-&gt;val(&apos;year&apos;).&apos; A.D.&apos;;
}
&lt;/code&gt;

==How to Define a Calculated Field==

In the delegate class you simply create a method with the following naming convention:
&lt;code&gt;
function field__fieldname(Dataface_Record $record);
&lt;/code&gt;

where the return value is the value that the given record should have for the field &apos;&apos;filedname&apos;&apos;.

E.g.

&lt;code&gt;
function field__year($record){
    $time = trtotime($record-&gt;strval(&apos;date&apos;));
    if ( $time ){
        return date(&apos;Y&apos;, $time));
    } else {
        return &apos;&apos;;
    }
}
&lt;/code&gt;</content>
	<keywords>calculated fields, field__fieldname</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=87">
	<page_name>sql_delegate_method</page_name>
	<page_id>87</page_id>
	<page_title>__sql__ Delegate Method</page_title>
	<content>return to [[Delegate class methods]]

===Synopsis===

The __sql__ delegate class method can be defined in any delegate class to specify the SQL query that should be used to fetch records for a given table.  This method overrides the [[__sql__]] directive of the fields.ini file.  This strategy is primarily used to graft columns from another table onto the base table.

=====Use Caution=====

This is an advanced feature and, if used incorrectly, can muck up your application. Make sure that your SQL query includes a superset of the columns in the base table, and is a row-for-row match for the rows in the base table.  I.e. you should never use an internal join.  Always use a left join so that all of the rows of the base table are returned even if the join table doesn&apos;t have a corresponding row.

If you want to simply filter a table&apos;s records, and don&apos;t need to graft any additional columns onto the table, you should use the [[setSecurityFilters]] method.

===Example===

Given the table foo, its delegate class:

&lt;code&gt;
class tables_foo {
    function __sql__(){
        return &quot;select f.*, c.category_name from foo f left join categories c on f.category_id=c.category_id&quot;;
    }
}
&lt;/code&gt;

This effectively grafts a column &quot;category_name&quot; onto the foo table based on a join with the categories table.

</content>
	<keywords>__sql__, SQL queries, delegate class</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=92">
	<page_name>Authenticating_Against_the_PHPBB_Users_table</page_name>
	<page_id>92</page_id>
	<page_title>Authenticating Against the PHPBB Users Table</page_title>
	<content>Return to [[authentication]]

[[toc]]

Xataface is able to use the PHPBB users table to authenticate against so that, you can allow your users to log into your Xataface application using the same credentials as they use to access your PHPBB message forum.  Achieving this level of integration requires 2 simple steps:

# Set up the [[_auth]] section of your [[conf.ini file]] to reference the PHPBB users table and the correct username and password columns.
# Specify the correct encryption on the password column.  This step will be different for different versions of PHPBB.

==PHPBB 2==

PHPBB version 2 and lower simply use MD5 encryption on the password column, which Xataface supports natively via the [[encryption]] directive of the [[fields.ini file]].  Therefore we can set up our Xataface application to authenticate against our PHPBB2 database (&apos;&apos;&apos;assuming that our PHPBB is set up in the same database as our Xataface app&apos;&apos;&apos;) by doing the following:

# Set up the [_auth] section of the [[conf.ini file]] as follows:&lt;code&gt;
[_auth]
users_table = phpbb_users
username_column = username
password_column = user_password
&lt;/code&gt;
# Set up the user_password field to use md5 encryption in the &apos;&apos;tables/phpbb_users/fields.ini&apos;&apos; file &lt;code&gt;
[user_password]
encryption=md5
&lt;/code&gt;

That&apos;s it!  Now you should be able to log into your Xataface application using the username/password from PHPBB.


==PHPBB 3==

PHPBB version 3 and higher uses a custom encryption function for the password column so it is a little more complicated (but not that much).  Step one (the [[conf.ini file]]) is the same as for PHPBB version 2 listed above.  The 2nd part, however, requires us to implement a custom serialization for the user_password field.  So the steps are below:

# Set up the [_auth] section of the [[conf.ini file]] as follows:&lt;code&gt;
[_auth]
users_table = phpbb_users
username_column = username
password_column = user_password
&lt;/code&gt;
# Implement the user_password__serialize() method in your phpbb_users delegate class (i.e. the &apos;&apos;tables/phpbb_users/phpbb_users.php&apos;&apos; file):&lt;code&gt;
&lt;?php
class tables_phpbb_users {
	

	function user_password__serialize($password){
		$itoa64 = &apos;./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&apos;;
		$sql = &quot;select user_password from phpbb_users where username=&apos;&quot;.addslashes($_POST[&apos;UserName&apos;]).&quot;&apos;&quot;;
		$res = mysql_query($sql, df_db());
		if ( !$res ) throw new Exception(mysql_error(df_db()));
		$row = mysql_fetch_assoc($res);
		mysql_free_result($res);
		$hash = $this-&gt;_hash_crypt_private($password, $row[&apos;user_password&apos;], $itoa64);
		return $hash;
	}
	
	
	/**
	* The crypt function/replacement
	*/
	function _hash_crypt_private($password, $setting, &amp;$itoa64)
	{
		$output = &apos;*&apos;;
	
		// Check for correct hash
		if (substr($setting, 0, 3) != &apos;$H$&apos;)
		{
			return $output;
		}
	
		$count_log2 = strpos($itoa64, $setting[3]);
	
		if ($count_log2 &lt; 7 || $count_log2 &gt; 30)
		{
			return $output;
		}
	
		$count = 1 &lt;&lt; $count_log2;
		$salt = substr($setting, 4, 8);
	
		if (strlen($salt) != 8)
		{
			return $output;
		}
	
		/**
		* We&apos;re kind of forced to use MD5 here since it&apos;s the only
		* cryptographic primitive available in all versions of PHP
		* currently in use.  To implement our own low-level crypto
		* in PHP would result in much worse performance and
		* consequently in lower iteration counts and hashes that are
		* quicker to crack (by non-PHP code).
		*/
		if (PHP_VERSION &gt;= 5)
		{
			$hash = md5($salt . $password, true);
			do
			{
				$hash = md5($hash . $password, true);
			}
			while (--$count);
		}
		else
		{
			$hash = pack(&apos;H*&apos;, md5($salt . $password));
			do
			{
				$hash = pack(&apos;H*&apos;, md5($hash . $password));
			}
			while (--$count);
		}
	
		$output = substr($setting, 0, 12);
		$output .= $this-&gt;_hash_encode64($hash, 16, $itoa64);
	
		return $output;
	}
	
	/**
	* Encode hash
	*/
	function _hash_encode64($input, $count, &amp;$itoa64)
	{
		$output = &apos;&apos;;
		$i = 0;
	
		do
		{
			$value = ord($input[$i++]);
			$output .= $itoa64[$value &amp; 0x3f];
	
			if ($i &lt; $count)
			{
				$value |= ord($input[$i]) &lt;&lt; 8;
			}
	
			$output .= $itoa64[($value &gt;&gt; 6) &amp; 0x3f];
	
			if ($i++ &gt;= $count)
			{
				break;
			}
	
			if ($i &lt; $count)
			{
				$value |= ord($input[$i]) &lt;&lt; 16;
			}
	
			$output .= $itoa64[($value &gt;&gt; 12) &amp; 0x3f];
	
			if ($i++ &gt;= $count)
			{
				break;
			}
	
			$output .= $itoa64[($value &gt;&gt; 18) &amp; 0x3f];
		}
		while ($i &lt; $count);
	
		return $output;
	}

	

}
&lt;/code&gt;</content>
	<keywords>PHPBB, authentication, security, authentication modules</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=125">
	<page_name>getNavItem</page_name>
	<page_id>125</page_id>
	<page_title>getNavItem Application Delegate Class Method</page_title>
	<content>Return to [[Application Delegate Class]]

[[toc]]

===Synopsis===

The getNavItem() method of the application delegate class can be used to override the items that appear in the navigation menu (i.e. the menu that allows users to select the table via either tabs along the top or items along the side).  It should return an associative array with characteristics of the navigation item including the href (i.e. link), label, and selected status.

Using this method it is now possible to have non-table navigation items as well.  You would just add these items to the \[_tables\] section of the [[conf.ini file]] then override the item using this method.

&apos;&apos;&apos;Since 1.3&apos;&apos;&apos;

====How the Nav Menu Is Built====

Xataface builds the navigation menu by looping through each item in the [_tables] section of the conf.ini file, passing it to the getNavItem() method, and adding the resulting navigation item to the menu.  If getNavItem() returns null, then that item will be skipped.  If getNavItem throws an exception, then the default rendering for the menu item will take place.

===Signature===

&lt;code&gt;
function mixed getNavItem( string $key, string $label ) throws Exception
&lt;/code&gt;

===Parameters===

* &apos;&apos;&apos;$key&apos;&apos;&apos; - The key of the nav item.  In the case of a table, this would be the table name.
* &apos;&apos;&apos;$label&apos;&apos;&apos; - The label of the nav item (may be overridden).

===Returns===

This method should return either:

# An associative array with the properties of the nav item.
# null to indicate that this nav item should be omitted altogether.  (e.g. if the user shouldn&apos;t have permission for it).

If returning an associative array, it should contain the following keys:

* &apos;&apos;&apos;href&apos;&apos;&apos; - (String) The URL where this nav item should point.
* &apos;&apos;&apos;label&apos;&apos;&apos; - (String) The label of this nav item.
* &apos;&apos;&apos;selected&apos;&apos;&apos; - (Boolean) True if the nav item is currently selected.  False otherwise.

===Throws===

If you want to signal Xataface to just use default rendering for the current navigation item you can just throw an exception.  The default rendering will link to the table named &apos;&apos;$key&apos;&apos;, and the item&apos;s label will be the same as &apos;&apos;$label&apos;&apos;.


==Examples==

Given the following conf.ini file:

&lt;code&gt;
...
[_tables]
   people=People
   books=Books
   accounts=Accounts
   reports=Reports

...
&lt;/code&gt;

Suppose we want the navigation menu to only show the &apos;&apos;people&apos;&apos; and &apos;&apos;books&apos;&apos; options for regular users.  Admin users can see all options.

In addition, the &apos;reports&apos; option doesn&apos;t correspond with a table of the database.  Instead we are just going to link it to a custom action named &apos;reports&apos;.

Our getNavItem() method will look something like this:
&lt;code&gt;
function getNavItem($key, $label){
    if (!isAdmin() ){
        switch ($key){
            case &apos;people&apos;:
            case &apos;books&apos;:
                // non-admin users can see these
                throw new Exception(&quot;Use default rendering&quot;);
        }
        // Non-admin users can&apos;t see any other table.
        return null;
 
    } else {

        //Admin users can see everything..
        $query =&amp; Dataface_Application::getInstance()-&gt;getQuery();
        switch ($key){
            case &apos;reports&apos;:
                // reports is not a table so we need to return custom properties.
                return array(
                    &apos;href&apos; =&gt; DATAFACE_SITE_HREF.&apos;?-action=reports&apos;,
                    &apos;label&apos; =&gt; $label,
                    &apos;selected&apos; =&gt; ($query[&apos;-action&apos;] == &apos;reports&apos;)
                );
            
        }
        

        // For other actions we need to make sure that they aren&apos;t selected
        // if the current action is reports because we want the &apos;reports&apos;
        // tab to be selected only in that case.
        return array(
            &apos;selected&apos; =&gt; ($query[&apos;-table&apos;] == $key and $query[&apos;-action&apos;] != &apos;reports&apos;)
        );
    }
}
&lt;/code&gt;


===See Also===

* [[isNavItemSelected]] - Overrides default behavior of whether a navigation item is currently selected.
   </content>
	<keywords>getNavItem, navigation menu</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=107">
	<page_name>beforeHandleRequest</page_name>
	<page_id>107</page_id>
	<page_title>beforeHandleRequest Application Delegate Class Method</page_title>
	<content>Return to [[Application Delegate Class]]

[[toc]]

===Synopsis===

The beforeHandleRequest method is a very useful hook that can be implemented in an [[Application Delegate Class]] to perform some processing before every request.  

This hook is called after user authentication is taken care of, but before control has been passed to the specific action.  This means that it is possible to do things such as change the current action or adjust query parameters depending on various factors.

===Example Uses===

* To require users to fill agree to license terms before they can visit particular parts of the application.
* To implement custom logging functionality to record user actions
* To change the default action for some or all tables.
* To automatically create user accounts in some cases.
* To change query parameters (e.g. default sorting etc...).

==Examples==

===Example 1: Changing the default action for a particular table===

&lt;code&gt;
class conf_ApplicationDelegate {
	
	function beforeHandleRequest(){
		$app = Dataface_Application::getInstance();
		$query =&amp; $app-&gt;getQuery();
			// Make sure you assign by reference (i.e. =&amp; )
			// for this if you want to make changes to the query
			
		if ( $query[&apos;-table&apos;] == &apos;dashboard&apos; and $app-&gt;_conf[&apos;using_default_action&apos;] ){
			$query[&apos;-action&apos;] = &apos;my_default_action&apos;;
		}
	}
}
&lt;/code&gt;

In the above example, we make use of the Application configuration variable [[using_default_action]] to find out if the request is using the default action.  This flag is set by Xataface if the user hasn&apos;t explicitly declared the action in the URL (i.e. -action has not explicitly been set).


==See Also==

* [[Application Delegate Class]]
* [http://dataface.weblite.ca/Dataface_Application Dataface_Application API Docs]
* [[Xataface URL Conventions]]
* &apos;&apos;&apos;[[Customizing Theme Based on IP Address]]&apos;&apos;&apos; - Article containing an example of using beforeHandleRequest hook.</content>
	<keywords>beforeHandleRequest, Application Delegate</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=122">
	<page_name>getResetPasswordEmailInfo</page_name>
	<page_id>122</page_id>
	<page_title>getResetPasswordEmailInfo Application Delegate Class Method</page_title>
	<content>Return to [[Application Delegate Class]]

[[toc]]

===Synopsis===

Optional method to define the settings for the email that is sent to the user when they request to reset their password.

Introduced in Xataface 1.3.  Exists in 1.3 or higher.


===Signature===

&lt;code&gt;
function getResetPasswordEmailInfo(Dataface_Record $user, string $reset_url){}
&lt;/code&gt;

===Parameters===

* &apos;&apos;&apos;$user&apos;&apos;&apos; - The Dataface_Record of the user whose password has been changed.
* &apos;&apos;&apos;$reset_url&apos;&apos;&apos; - The URL where the user should go to reset their password.  When they visit this URL they will receive a message saying that their password has been changed and the new password has been emailed to them.  That subsequent email can be customized using the [[getPasswordChangedEmailInfo]] method.

===Returns===

This method should return an associative array with 0 or more of the following keys:

* &apos;&apos;&apos;subject&apos;&apos;&apos; - The subject line of the email.
* &apos;&apos;&apos;message&apos;&apos;&apos; - The message content of the email.
* &apos;&apos;&apos;headers&apos;&apos;&apos; - The Email headers (as a string).
* &apos;&apos;&apos;parameters&apos;&apos;&apos; - Extra parameters for the mail function.

==See Also==

* [[getPasswordChangedEmailInfo]] - A delegate class method to define the email that is sent to the user once their password has been reset to a temporary password.  It informs the user of their new temporary password and should include instructions on how to change their password to their own choice.  This step immediately follows the reset password step.</content>
	<keywords>forgot password, reset password</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=121">
	<page_name>getPasswordChangedEmailInfo</page_name>
	<page_id>121</page_id>
	<page_title>getPasswordChangedEmailInfo Application Delegate Class Method</page_title>
	<content>Return to [[Application Delegate Class]]

[[toc]]

===Synopsis===

Optional method to define the settings for the email that is sent to the user upon successful resetting of their password using the password reset function. 

Introduced in Xataface 1.3.  Exists in 1.3 or higher.


===Signature===

&lt;code&gt;
function getPasswordChangedEmailInfo(Dataface_Record $user, string $password){}
&lt;/code&gt;

===Parameters===

* &apos;&apos;&apos;$user&apos;&apos;&apos; - The Dataface_Record of the user whose password has been changed.
* &apos;&apos;&apos;$password&apos;&apos;&apos; - The new temporary password that has been assigned to the user.

===Returns===

This method should return an associative array with 0 or more of the following keys:

* &apos;&apos;&apos;subject&apos;&apos;&apos; - The subject line of the email.
* &apos;&apos;&apos;message&apos;&apos;&apos; - The message content of the email.
* &apos;&apos;&apos;headers&apos;&apos;&apos; - The Email headers (as a string).
* &apos;&apos;&apos;parameters&apos;&apos;&apos; - Extra parameters for the mail function.

==See Also==

* [[getResetPasswordEmailInfo]] - A delegate class method to define the email that is sent to the user when they request a password reset.  This is the step that immediately precedes the Password Changed email step.</content>
	<keywords>forgot password, reset password</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=181">
	<page_name>after_action_activate</page_name>
	<page_id>181</page_id>
	<page_title>after_action_activate Delegate Class Method</page_title>
	<content>Return to [[Application Delegate Class]]

[[toc]]


The &apos;&apos;&apos;after_action_activate&apos;&apos;&apos; hook is a method that can be defined in the [[Application Delegate Class]] which is called after an account has been activated via the registration process.  The full registration process goes as follows:

# User fills in registration form.
# An email is sent to the user with a link to activate their account.
# User clicks on activation link.
# User is taken back to the application and activation occurs, which consists of creating a new record in the &apos;&apos;&apos;users&apos;&apos;&apos; table.
# The &apos;&apos;after_action_activate&apos;&apos; trigger is called.

===Since===

This hook has been available since Xataface Version 1.2

===Example===

&lt;code&gt;
/**
 * A trigger to send the user a confirmation email after their account has been activated.
 * @params array $params Associative array of passed parameters.  Contains a single key &apos;record&apos;
 * with the Dataface_Record object of the users table with the user that was activated.
 */
function after_action_activate(array $params){
    $user = $params[&apos;record&apos;];
    
    mail($user-&gt;val(&apos;email&apos;), &apos;Your account is activated&apos;, &apos;Your account has been activated... etc..&apos;);
}
&lt;/code&gt;

===See Also===

* [[Application Delegate Class]]
* [[registration_form]] - More information user registration forms.
* [[beforeRegister]] - Trigger called before the user registration form is saved.
* [[afterRegister]] - Trigger called after registration form is saved.
* [[validateRegistrationForm]] - Validates the input into the registration form.
* [[sendRegistrationActivationEmail]] - Overrides the sending of the registration activation email.
* [[getRegistrationActivationEmailInfo]] - Overrides the activation email info.  Returns an associative array of the email details (e.g. subject, to, headers, etc...
* [[getRegistrationActivationEmailSubject]] - Returns the subject of the activation email.
* [[getRegistrationActivationEmailMessage]] - Returns the message body for the activation email.
* [[getRegistrationActivationEmailParameters]] - Returns the parameters for the actication email.
* [[getRegistrationActivationEmailHeaders]] - Returns the headers for the activation email.
</content>
	<keywords>Registration, activation, register, activate, users</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=102">
	<page_name>before_authenticate</page_name>
	<page_id>102</page_id>
	<page_title>before_authenticate hook</page_title>
	<content>Return to [[Application Delegate Class]]

The &apos;&apos;&apos;before_authenticate&apos;&apos;&apos; hook is a method that can be defined in the [[Application Delegate Class]] which is called before the authentication step occurs on &apos;&apos;&apos;every&apos;&apos;&apos; request (not just on login).  It is meant to be used to perform custom code that may affect the authentication settings.

===Since===

This hook has been available since Xataface Version 1.2.5.

===Example===

&lt;code&gt;
/**
 * Implemented trigger to be called before authentication to set the authentication
 * type to basic.
 */
function before_authenticate(){
    $auth = Dataface_AuthenticationTool::getInstance();
    if ( @$_SESSION[&apos;-login-type&apos;] == &apos;basic&apos; ) $auth-&gt;setAuthType(&apos;basic&apos;);
}
&lt;/code&gt;

In the above example we used a separate action to store the user&apos;s preferred login type in a session variable.  This preference is then applied in the before_authenticate method to override the authentication type.

===Chain Authentication Support===

The most common use of this hook is likely to implement some sort of chain authentication, where authentication methods are attempted until one succeeds. 

===See Also===

* [[Application Delegate Class]]
* [[authentication]] - Overview of Xataface authentication
* [[Writing Custom Authentication Plugins]]
* [[Authenticating Against the PHPBB Users Table]]
* [[LDAP or Active Directory]] - Using LDAP or Active Directory for authentication.
* [http://xataface.com/documentation/tutorial/getting_started/permissions Permissions Section of the Getting Started tutorial]
* [[_auth]] - Directives available in the [[_auth]] section of the [[conf.ini file]].</content>
	<keywords>authentication</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=180">
	<page_name>viewable_editable_fields</page_name>
	<page_id>180</page_id>
	<page_title>How to make a field editable for some users and only viewable for some other users</page_title>
	<content>If we want only some users to edit a field and some other users only to view that field, then we need to define a &apos;&apos;&apos;fieldX__permissions()&apos;&apos;&apos; method for that field which gives desired permissions for specific users.

One solution is as below.

==permissions.ini==
&lt;code&gt;
[Field Viewer]
view=1
edit=0
new=0

[Field Editor extends Field Viewer]
new=1
edit=1
&lt;/code&gt;

==TableX.php (Delegate class of TableX)==
&lt;code&gt;
function fieldX__permissions(&amp;$record) {
	$user=&amp;Dataface_AuthenticationTool::getInstance()-&gt;getLoggedInUser();
	
	if($user) {
		if($user-&gt;val(&apos;usernameField&apos;)==&quot;UserX&quot;)
			$role=&apos;Field Viewer&apos;;
		else if($user-&gt;val(&apos;usernameField&apos;)==&quot;UserY&quot;)
			$role=&apos;Field Editor&apos;;				

			return Dataface_PermissionsTool::getRolePermissions($role);
	}
		
	return Dataface_PermissionsTool::NO_ACCESS();
}
&lt;/code&gt;</content>
	<keywords></keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=177">
	<page_name>test_page_34</page_name>
	<page_id>177</page_id>
	<page_title>Hello World</page_title>
	<content>Hello world</content>
	<keywords></keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=100">
	<page_name>calendar</page_name>
	<page_id>100</page_id>
	<page_title>Calendar Widget</page_title>
	<content>Back to [[widget:type]]

[[toc]]

===Synopsis===

The calendar widget is the default widget for editing date and datetime fields.  It is javascript pop-up calendar that allows users to select date and time visually.  It can be configured to allow different date and time formats, themes, starting days of the week, and more.

[[image:http://media.weblite.ca/files/photos/calendar_widget.png?max_width=400]]

===Usage===

For DATE and DATETIME fields, the calendar widget is the default widget used, so you need not specify it explicitly in the fields.ini file.  For other types of fields you may designate them to use the calendar widget in the [[fields.ini file]] as follows:

&lt;code&gt;
[my_field]
    widget:type=calendar
&lt;/code&gt;

===Configuration Options===

The calendar widget supports some configuration options that can be set in the [[fields.ini file]].  These options are as follows:

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Default
! Version
|-
| [[widget:lang]]
| The language to use for the calendar.  This is a 2-digit ISO language code.
| en
| 0.5.3
|-
| [[widget:theme]]
| The theme to use for the calendar.  It only ships with one theme at present.
| calendar-win2k-2
| 0.5.3
|-
| [[widget:firstDay]]
| The first day of the week  (e.g. Monday=1)
| 1
| 0.5.3
|-
| [[widget:showsTime]]
| Boolean value indicating whether the calendar should show the time as well.
| 0 for DATE fields, 1 for DATETIME fields.
| 0.5.3
|-
| [[widget:ifFormat]]
| The input format of the date.  This takes a formatting string as supported by [http://ca2.php.net/strftime the strftime function].
| %Y-%m-%d %I:%M %P
| 0.5.3
|-
| [[widget:timeFormat]]
| Whether to use 12 hour or 24 hour time format.
| 12
| 0.5.3
|}

===Examples===

====Setting the time to use 24 hour format====

In your [[fields.ini file]]:
&lt;code&gt;
[my_field]
    wiget:type=calendar
    widget:timeFormat = 24
&lt;/code&gt;


===See Also===

* [[date]] Widget - A widget for editing date and time using select drop-down lists.
* [[time]] Widget - A widget for selecting time from a set of possibilities in a single select list.</content>
	<keywords>calendar widget, fields.ini file, widget:type</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=109">
	<page_name>beforeSave</page_name>
	<page_id>109</page_id>
	<page_title>beforeSave Trigger</page_title>
	<content>Back to [[Delegate class methods]]

[[toc]]



===Synopsis===

The beforeSave trigger can be implemented in any table&apos;s [[delegate class|Delegate Class Methods]] to perform functionality that should be run *before* a record of that table is saved.  This is a useful place to insert additional field values depending on the input of the save record form.

This method is called both when records are inserted and when existing records are updated.  Some other triggers include [[beforeInsert]], [[beforeUpdate]], [[afterSave]], [[afterInsert]], and [[afterUpdate]], which do what you might expect.


===Method Signature===

&lt;code&gt;function beforeSave( Dataface_Record $record);&lt;/code&gt;

====Parameters====

# &apos;&apos;&apos;$record&apos;&apos;&apos; - The record that is about to be saved.  This is a [http://dataface.weblite.ca/Dataface_Record Dataface_Record] object.

====Returns====

# [http://dataface.weblite.ca/Dataface_Error Dataface_Error] on failure (if you want to cancel the save).


===Examples===

Given a table named &quot;people&quot;, suppose we wanted to automatically populate a field named &quot;full_name&quot;  with the concatenation of the &quot;first_name&quot; and &quot;last_name&quot; fields.  (Note you could also achieve a similar thing by making a calculated field for &quot;full_name&quot;, but for this example, we assume that we actually want to store this in the database.

We create a beforeSave() trigger that automatically updates the &quot;full_name&quot; field every time the record is saved.

In the &quot;people&quot; table delegate class (i.e. tables/people/people.php)
&lt;code&gt;
class tables_people {
    function beforeSave($record){
        $record-&gt;setValue(&apos;full_name&apos;, 
            $record-&gt;val(&apos;first_name&apos;).&apos; &apos;.$record-&gt;val(&apos;last_name&apos;)
        );
    }
}
&lt;/code&gt;

==See Also==

* [http://www.xataface.com/documentation/tutorial/getting_started/triggers Triggers section of the Xataface Getting Started Tutorial]
</content>
	<keywords>triggers, beforeSave,</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=101">
	<page_name>Introduction_to_the_Xataface_API</page_name>
	<page_id>101</page_id>
	<page_title>Introduction to the Xataface API</page_title>
	<content>Back to [http://xataface.com/wiki the wiki]

[[toc]]

===Synopsis===

Xataface is provides an API to help in developing your own custom actions.  This API includes objects and functions to more easily interact with the database (i.e. search, edit, delete, and save records), build forms, use templates, and more.  This section of the wiki endeavors to highlight some of the more useful and commonly used aspects of the API.

===The dataface-public-api.php Facade===

Much of the functionality provided by the Xataface API is wrapped up easy-to-use functions which are made available in the dataface-public-api.php script, which is always present in a Xataface application (it is loaded at the beginning of your index.php file).

===Some Common Tasks===

====Loading a Single Record from the Database====

&lt;code&gt;
// Load record from &apos;people&apos; table matching person_id=10
$record = df_get_record(&apos;people&apos;, array(&apos;person_id&apos;=&gt;10)); 

// Load record from people table with first_name &apos;John&apos; and last_name &apos;Smith&apos; 
$record2 = df_get_record(&apos;people&apos;, array(&apos;first_name&apos;=&gt;&apos;=John&apos;, &apos;last_name&apos;=&gt;&apos;=Smith&apos;));

// $record and $record2 are Dataface_Record objects.
echo &quot;Loaded Person: &quot;.$record-&gt;val(&apos;person_id&apos;).
      &quot; named &quot;.$record-&gt;val(&apos;first_name&apos;).&apos; &apos;.$record-&gt;val(&apos;last_name&apos;);
&lt;/code&gt;

In the above examples we load a [http://dataface.weblite.ca/Dataface_Record Dataface_Record] object and use the val() method to display particular field values.

The 2nd arguments of df_get_record() is an array which serves as a query.  See [[URL Conventions]] for more examples of the types of queries that you can provide here.

====Loading a set of records from the Database====

&lt;code&gt;
//  Load the first 30 canadians from the people table
$people = df_get_records_array(&apos;people&apos;, array(&apos;nationality&apos;=&gt;&apos;=canadian&apos;));
foreach ( $people as $person){
    // $person is a Dataface_Record object
    echo &quot;&lt;br&gt;Person &quot;.$person-&gt;val(&apos;person_id&apos;).&quot; is named &quot;.$person-&gt;val(&apos;first_name&apos;);
}
&lt;/code&gt;

&apos;&apos;&apos;Caveat:  Note that when loading records using df_get_records_array() it only loads a preview of each record for memory&apos;s sake.&apos;&apos;&apos;  A preview of the record is the same as a full record except that all fields are truncated to be less than 255 characters.  If you have long text fields that you need to load, then these will be truncated.  There are a few different solutions if you need to load the entire contents of a long field, including:

* Use df_get_record instead.  (This is only preferable if you are only loading a single record).
* Use the [[struct]] [[fields.ini file]] directive on the field to designative the field contents as a &apos;stucture&apos; that should never be truncated.
* Use the extended form of &apos;&apos;df_get_records_array()&apos;&apos; with the 5th parameter (preview) set to false.  E.g. &lt;code&gt;
$people = df_get_records_array(&apos;people&apos;,array(), null, null, false);
&lt;/code&gt;

====Editing and Saving a Record====

&lt;code&gt;
$person = df_get_record(&apos;people&apos;, array(&apos;person_id&apos;=&gt;10));

// Using setValue() to set a single field value.
$person-&gt;setValue(&apos;first_name&apos;, &apos;Peggy&apos;);

// Using setValues() to set multiple field values at once
$person-&gt;setValues(array(&apos;first_name&apos;=&gt;&apos;Peggy&apos;, &apos;last_name&apos;=&gt;&apos;Sue&apos;));

// Commit the changes to the database
$person-&gt;save();
&lt;/code&gt;

</content>
	<keywords>xataface api, df_get_record, df_get_records_array, Dataface_Record, Editing, Saving, Loading, Searching</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=2">
	<page_name>testpage2</page_name>
	<page_id>2</page_id>
	<page_title>testpage2</page_title>
	<content>Another test page
[[testpage]]</content>
	<keywords></keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=9">
	<page_name>__prefs__</page_name>
	<page_id>9</page_id>
	<page_title>__prefs__</page_title>
	<content>==__prefs__ fields.ini Section==

A global section of the [[fields.ini file]] that sets the preferences for the given table and its records.

E.g.
&lt;code&gt;
[__prefs__]
    hide_posted_by=1 ; Hides the &quot;Posted by&quot; text in glance lists (e.g. related records in the view tab).
    hide_updated=1 ; Hides the &quot;Updated&quot; text in glance lists (e.g. the related records in the view tab).
&lt;/code&gt;


===Available Preferences===

Ultimately, all of the preferences available at a global level should be available here, however currently this is not the case and only selected preferences are available at the table level.

{| class=&quot;listing listing2&quot;
! Name
! Description
! Version
|-
| [[hide_posted_by]]
| HIdes the &apos;&apos;posted_by&apos;&apos; text in glance lists.  E.g. In the view tab of a record, the related records are shown in the left column.  This will hide the &apos;&apos;posted_by&apos;&apos; text next to each related record.
| 1.0b4
|-
| [[hide_updated]]
| Hides the &apos;&apos;updated&apos;&apos; text in glance lists.  E.g. In the view tab of a record, the related records are shown in the left column.  This will hide the &apos;&apos;updated&apos;&apos; text next to each related record.
| 1.0b4
|-
|}</content>
	<keywords></keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=37">
	<page_name>URL_Conventions</page_name>
	<page_id>37</page_id>
	<page_title>URL_Conventions</page_title>
	<content>==Xataface URL Conventions==

[[toc]]

Xataface adheres to a few simple URL conventions for all of its actions.  When you understand how Xataface URLs work you begin to get far more out of your applications.  By specifying the appropriate query parameters to can jump directly to any point in your application, or produce a specific result set.

For example, the URL &apos;&apos;index.php?-table=people&apos;&apos; will take you to the &apos;&apos;people&apos;&apos; table (and since the default action for a Xataface application is &apos;&apos;list&apos;&apos;, it will take you to the &apos;&apos;list&apos;&apos; view.

You could be more explicit by specifying the action in the URL directly: &apos;&apos;index.php?-table=people&amp;-action=list&apos;&apos;.  This would take you to the same screen.  From this example, you see that you can specify such things as the table and action via GET parameters.  Xataface accepts many more GET parameters also, as you&apos;ll see in the next section.

===Available GET Parameters===


{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Default
! Version
|-
| -action
| Specifies the action to perform.  E.g. &apos;&apos;browse&apos;&apos;, &apos;&apos;list&apos;&apos;, &apos;&apos;find&apos;&apos;, &apos;&apos;edit&apos;&apos;, &apos;&apos;new&apos;&apos;, ... etc..
| list
| all
|-
| -table
| The name of the table to use as the context table.
| The first table in the [_tables] section of your [[conf.ini file]]
| all
|-
| -skip
| Skip a certain number of results in the current found set to display.  E.g. If there are 100 records in the table and you want to start browsing from the 30th record, you would set &apos;&apos;-skip=29&apos;&apos;.

Not to be confused with the &apos;&apos;-cursor&apos;&apos; parameter which is used to specify which record to view in the &apos;&apos;details&apos;&apos; tab.
| 0
| all
|-
| -limit
| The maximum number of records in the found set to display.
| 30
| all
|-
| -cursor
| The index of the record in the current found set that is treated as the &quot;current&quot; record.  This is used in the &apos;&apos;details&apos;&apos; tab to identify which record to act on.  E.g. which record to view or edit.
| 0
| all
|-
| -sort
| A comma-delimited list of columns to sort the result set on.
| null
| all
|-
| -relationship
| If we are browsing related records, this specifies the name of the relationship.
| null
| all
|-
| -related:start
| If we are browsing related records, this is the first record in the relationship to show.
| 0
| all
|-
| -related:limit
| If we are browsing related records, this is the number of records to show per page.
| 30
| all
|-
| -search
| A keyword search term to filter the found set on.  Any row containing any field that matches the query will be returned.
| null
| all
|-
| --no-query=1
| A flag to indicate that xataface should not query the database by default.  This flag is used in the new record form to prevent the form parameters from being interpreted as query parameters to search in the database.  If you set this flag, it likely result in a message saying &quot;No records found&quot;.  Generally you would only use this in a custom action where you are not relying on Xataface&apos;s default found set.
| 0
| 1.3
|}

There are many other GET parameters that are used in various contexts but the above parameters are available throughout the entire application.

===Finding Records using the URL===

Notice that all of the GET parameters mentioned in the previous section begin with a hyphen (i.e. &apos;-&apos;).  This is a convention Xataface uses to distinguish directives from search queries.  All parameters that do not begin with &apos;-&apos; are treated as a query to filter the found set.

For example, &apos;&apos;first_name=bob&apos;&apos; used as a GET parameter would cause the found set to be filtered so that only records where the &apos;&apos;first_name&apos;&apos; column contains the phrase &quot;bob&quot; are returned.  Putting this all together, suppose we wanted to show the list tab for the &apos;&apos;people&apos;&apos; table, but only wanted to show the people with first names containing &quot;bob&quot;:

index.php?-action=list&amp;-table=people&amp;first_name=bob

====Exact, Range, and Pattern Matching====

By default, queries on text columns look for partial matches.  I.e. if you search for &quot;bob&quot; it will match &quot;bob&quot;, &quot;bobby&quot;, &quot;rubob&quot;, and any other text that contains &quot;bob&quot;.  If you are only interested in finding records that match &apos;&apos;exactly&apos;&apos; &quot;bob&quot;, then you can prepend an &quot;=&quot; to the query.  E.g. &apos;&apos;first_name==bob&apos;&apos;, or the full URL:

index.php?-action=list&amp;-table=people&amp;first_name==bob

This should show the &apos;&apos;list&apos;&apos; tab for the &apos;&apos;people&apos;&apos; table with only records with first name exactly &quot;bob&quot;.

There are a number of modifiers that you can prepend to your query to modify how it is executed.  They are as follows:

=====Search Operators=====

{| class=&quot;listing listing2&quot;
|-
! Prefix
! Usage Example
! Description
|- 
| &gt;
| age=&gt;10
| Match records greater than search parameter.
|-
| &lt;
| age=&lt;10
| Match records less than search parameter.
|-
| &gt;=
| age=&gt;=10
| Match records greater than or equal to the search parameter.
|-
| &lt;=
| age=&lt;=10
| Match records less than or equal to the search parameter.
|-
| ..
| age=10..20
| Match records in a given range.
|-
| =
| first_name==bob
| Match records that exactly match the search parameter (if there is no prefix then it will search for partial matches on text/varchar/char fields.).
|-
| ~
| first_name=~a%
| Exact match, but you can include wildcards such as &apos;%&apos; and &apos;?&apos; in your search.
|}


=====Search Examples=====

Given the following data set:

{| class=&quot;listing listing2&quot;
|-
! first_name
! age
|-
| Bob
| 10
|-
| Cindy
| 12
|-
| Julie
| 6
|-
| Jake
| 8
|-
| Kabob
| 16
|}

Here are some example queries on this data set and their results:

{| class=&quot;listing listing2&quot;
|-
! Query
! Matches
|- 
| age=&gt;10 
| match records where &apos;&apos;age&apos;&apos; is greater than 10.  This includes &apos;&apos;Cindy&apos;&apos; and &apos;&apos;Kabob&apos;&apos;.
|-
| age=&lt;10 
| match records where &apos;&apos;age&apos;&apos; is less than 10.  This includes &apos;&apos;Julie&apos;&apos; and &apos;&apos;Jake&apos;&apos;
|-
| age=&gt;=10 
| match records where &apos;&apos;age&apos;&apos; is greater or equal to 10.  This includes &apos;&apos;Bob&apos;&apos;, &apos;&apos;Cindy&apos;&apos;, and &apos;&apos;Kabob&apos;&apos;.
|-
| age=&lt;=10
| match records where &apos;&apos;age&apos;&apos; is less than or equal to 10. This includes &apos;&apos;Bob&apos;&apos;, &apos;&apos;Julie&apos;&apos;, and &apos;&apos;Jake&apos;&apos;.
|-
| age=8..10
| match records where &apos;&apos;age&apos;&apos; is between 8 and 10.  This includes &apos;&apos;Bob&apos;&apos; and &apos;&apos;Jake&apos;&apos;.
|-
| first_name=bob
| Matches records where &apos;&apos;first_name&apos;&apos; contains &quot;bob&quot;.  This includes &apos;&apos;Bob&apos;&apos; and &apos;&apos;Kabob&apos;&apos;.
|-
| first_name==bob
| Matches records where &apos;&apos;first_name&apos;&apos; is exactly &quot;bob&quot;.  This includes &apos;&apos;Bob&apos;&apos; only.
|-
| first_name=~J%
| Matches records that begin with &quot;J&quot;.  This includes &apos;&apos;Jake&apos;&apos; and &apos;&apos;Julie&apos;&apos;
|}

====Matching on Related Records====

It is also possible to match records based on their related data (i.e. data that is not physically stored in the record itself, but in related records via a relationship).  For example if we want to find authors who have written about a particular topic, we would normally have to first find all of the articles that contain a topic, and then cross-reference that result against the &apos;&apos;authors&apos;&apos; table.  With Xataface we can perform this query directly from the &apos;&apos;authors&apos;&apos; table using something like the following query:
 index.php?-table=authors&amp;articles/title=sports
This assumes that the &apos;&apos;authors&apos;&apos; table has a relationship named &apos;&apos;articles&apos;&apos; that contains all of the articles that an author has written.  So the above query returns precisely those authors who have written at least one article whose &apos;&apos;title&apos;&apos; field contains the phrase &quot;sports&quot;.


=====Anatomy of a Related Query=====

 %relationship%/%field%=%query%
This matches all records in the current table such that at least one record in its &apos;&apos;&lt;relationship&gt;&apos;&apos; relationship matches the query: &apos;&apos;%field%=%query%&apos;&apos;.


====Using the &apos;&apos;OR&apos;&apos; Operator====

Xataface allows you to search for more than one value at a time using the &apos;&apos;OR&apos;&apos; operator.  E.g.
 first_name=bob+OR+steve
Would match all records with &apos;&apos;first_name&apos;&apos; containing &quot;bob&quot; or &quot;steve&quot;.
 first_name=bob+OR+=steve
Would match all records with &apos;&apos;first_name&apos;&apos; containing &quot;bob&quot; or exactly matching &quot;steve&quot;
 age=&lt;10+OR+&gt;20
Would match all records with age less than 10 or greater than 20.

====Combining Multiple Queries in One Request====

Xataface allows you to filter on more than one field at a time.  If you combine multiple queries in the same request it has the effect of strengthening the filter, matching only those rows that match &apos;&apos;both&apos;&apos; queries.  E.g.
 age=&gt;10&amp;first_name=bob
would match all records where &apos;&apos;age&apos;&apos; is greater than 10 &apos;&apos;&apos;AND&apos;&apos;&apos; that have &apos;&apos;first_name&apos;&apos; containing &quot;bob&quot;.

=====Examples of Combined Queries=====

Given the same data set as the previous set of examples:

{| class=&quot;listing listing2&quot;
|-
! first_name
! age
|-
| Bob
| 10
|-
| Cindy
| 12
|-
| Julie
| 6
|-
| Jake
| 8
|-
| Kabob
| 16
|}

 first_name=bob&amp;age=11
would return no matches because there are no records that contain both &apos;&apos;first_name&apos;&apos; &quot;bob&quot; and &apos;&apos;age&apos;&apos; 11.  However
 first_name=bob&amp;age=10
would return only &apos;&apos;Bob&apos;&apos; and
 first_name=bob&amp;age=16
would return only &apos;&apos;Kabob&apos;&apos;.

====Special Common Queries====

=====Search For Null or Blank Value=====

Searching for a null value or a blank value is an exact match for &quot;&quot;.  Therefore you can simply search for &quot;=&quot;.  E.g. To find records with a null or blank first_name you would use the query &apos;&apos;first_name==&apos;&apos;.  Or the full query:
 index.php?-table=people&amp;first_name==

=====Search for Non-blank Value=====

Searching for a non-blank value is the same as searching for a value greater than &quot;&quot;.  Therefore you can simply search for &quot;&gt;&quot;.  E.g. if you wanted to find records with a first_name, you would use the query &apos;&apos;first_name=&gt;&apos;&apos;.  Or the full query:
 index.php?-table=people&amp;first_name=&gt;

==Preserved vs Non-preserved Parameters==

As mentioned above any parameters that are prefixed by a hyphen (i.e. &quot;=&quot;) are treated as directives rather than search filters.  Hence if you want to use your own GET parameters you should always prefix them with a &quot;-&quot; to ensure that Xataface does not attempt to apply it as a search filter.  In order to keep a consistent context for users, all browsing within the same table preserves both search queries and directives.  Hence if you go to the URL:
 index.php?-table=people&amp;-action=list&amp;first_name=bob
It will show you the &apos;&apos;list&apos;&apos; tab of the &apos;&apos;people&apos;&apos; table with only those records with &apos;&apos;first_name&apos;&apos; &quot;bob&quot;.  Now if you click on the &apos;&apos;details&apos;&apos; tab it will preserve your query &apos;&apos;first_name&apos;&apos;.  The query will become something like:
 index.php?-table=people&amp;-action=details&amp;first_name=bob&amp;...etc... more parameters
(Although the parameters may appear in a different order).  This allows you to navigate forward and back to previous and next records and stay within the same found set.  It also ensures that if you click on the &apos;&apos;list&apos;&apos; tab to return to the list view, it will retain your place in the list.

Note that navigating within the same table it will also preserve your directives.  E.g. If you specify the &apos;&apos;-limit&apos;&apos; directive to show 100 records per page:
 index.php?-table=people&amp;-action=list&amp;-limit=100
And then you click on the &apos;&apos;details&apos;&apos; tab, it will retain your &apos;&apos;-limit&apos;&apos; parameter.  Of course the &apos;&apos;-limit&apos;&apos; parameter is not actually used by the &apos;&apos;details&apos;&apos; action because it works on only one record at a time (it uses the &apos;&apos;-cursor&apos;&apos; parameter instead), when you click back on the &apos;&apos;list&apos;&apos; tab it will still show you 100 records per page.

Because of this, we call the &apos;&apos;-limit&apos;&apos; parameter a preserved parameter.  It is retained when navigating within the same table.  &apos;&apos;&apos;Note:&apos;&apos;&apos; parameters are retained in the HTTP Query string, not in sessions or cookies.  This ensures that there are no surprises when you enter a URL to your Xataface application.

===Unpreserved Parameters===

If you &apos;&apos;don&apos;t&apos;&apos; want Xataface to preserve one of your parameters, you should prefix two hyphens to the parameter name.  I.e. &quot;--&quot;.  One example of an unpreserved parameters throughout Xataface applications is the &apos;&apos;--msg&apos;&apos; parameter.  The value of this parameter will be displayed on the page as an info message to the user.  Clearly you don&apos;t want this parameter preserved across requests, as you only want the user to see a message once.  E.g.
 index.php?--msg=Record+Successfully+saved.
Would didsplay the mesage &quot;Record Successfully Saved&quot; at the top of the page.  If you click on any link in the application, it will not retain the &apos;&apos;--msg&apos;&apos; parameter so you will not see the message on subsequent requests.

This parameter is useful if you want to give feedback to the user about an action that has been carried out.

===Summary===

{| class=&quot;listing listing2&quot;
|-
! Parameter Type
! Prefix
! Examples
! Description
|-
| Preserved
| -
| -limit, -skip, -cursor, -action, -table
| Parameter value is preserved when user navigates away from the page (within the same table).
|-
| Unpreserved Parameters
| --
| --msg
| Parameter is &apos;&apos;NOT&apos;&apos; retrained with the user navigates away from the page.
|}





</content>
	<keywords>URL Conventions, GET Parameters, POST parameters, Request Parameters</keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=49">
	<page_name>Troubleshooting</page_name>
	<page_id>49</page_id>
	<page_title>Troubleshooting</page_title>
	<content>==Xataface Troubleshooting==

This document is intended to help Xataface developers through some of the most common issues.

[[toc]]

==All I get is a blank white screen!==

The most common issue mentioned in the forums is that an application comes up with a blank white screen in the web browser.  This can happen for a number of reasons but the most common reason is because PHP has encountered a fatal error and your PHP installation is not set up to display errors.  

The first step to troubleshooting this problem must be to find out what the error is.  You can do that in one of the following ways:

# Check your Apache error log if you know where it is.  One common location on many linux installations is &lt;code&gt;
/var/log/httpd/error_log
&lt;/code&gt; but your system may have it located elsewhere.  If you cannot find your error log, continue to the next option.
# Turn on the &apos;&apos;display_errors&apos;&apos; flag in your &apos;&apos;php.ini&apos;&apos; file.  I.e., in your &apos;&apos;php.ini&apos;&apos; file, find where it says &lt;code&gt;
display_errors Off
&lt;/code&gt; and change it to &lt;code&gt;
display_errors On
&lt;/code&gt;.  After this is done, restart your apache webserver.  If you don&apos;t know where your &apos;&apos;php.ini&apos;&apos; file is located see the section later in this document on locating your &apos;&apos;php.ini&apos;&apos; file.  If you don&apos;t have access to your php.ini file, move on to the next option.
# In your application&apos;s &apos;&apos;.htaccess&apos;&apos; file, add the following directives to enable displaying errors:&lt;code&gt;
php_flag display_errors on
&lt;/code&gt; .  Note that this method will only work if your apache config file allows you to override these values at the directory level.  If you still get a blank white screen after this, continue to the next option.
# At the beginning of your application&apos;s index.php file, add the following:&lt;code&gt;
&lt;?php
error_reporting(E_ALL);
ini_set(&apos;display_errors&apos;, &apos;on&apos;);
&lt;/code&gt; .  Note that if the error occurs in the parsing or compiling of your PHP files you will still get a blank screen.  But this will at least display runtime errors on the page.

Once you can see the error messages that caused the blank white screen you are in a much better position to solve the problem.

==Locating your php.ini file==

Locating your &apos;&apos;php.ini&apos;&apos; file is actually quite easy.  The quickest way is to create a php script with the following contents:
&lt;code&gt;
&lt;?php
phpinfo();
&lt;/code&gt;
then navigate to this page in your web browser.  This look at the line where it says the &apos;&apos;php.ini file&apos;&apos;.  It will list the path there.</content>
	<keywords></keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=23">
	<page_name>xataface_templates</page_name>
	<page_id>23</page_id>
	<page_title>xataface_templates</page_title>
	<content>==Xataface Templates==

[[toc]]

Xataface uses the [http://smarty.php.net Smarty Template Engine] to power all of its templates.  Templates are stored in the one of the following locations:

* %XATAFACE_ROOT%/Dataface/templates
* %SITE_ROOT%/templates

Where %XATAFACE_ROOT% is the Xataface directory (includes files such as dataface-public-api.php), and %SITE_ROOT% is the path to your application.

You may also have subdirectories within these templates directories.

===Cascading Templates===

Xataface uses a simple cascading technique for deciding which template to use.  If there are templates in the %SITE_ROOT%/templates and %XATAFACE_ROOT%/Dataface/templates directories with the same name, then Xataface will use the one in the %SITE_ROOT%/templates directory.  In this way, you are able to override any of Xataface&apos;s core templates by adding one of the same name to your %SITE_ROOT%/templates directory.

The most common template to override is the Dataface_Main_Template.html template which defines the look and feel for the entire application (e.g. header, footer, etc...).  Hence, if you wanted to customize the look &amp; feel of your application, you would likely start by copying %XATAFACE_ROOT%/Dataface/templates/Dataface_Main_Template.html into the %SITE_ROOT%/templates directory and make modifications to it as desired.

===Useful Smarty Tags introduced by Xataface===

In addition to the standard set of Smarty tags, Xataface templates provide some of its own.

==Xataface Templates==

Xataface uses the [http://smarty.php.net Smarty Template Engine] to power all of its templates.  Templates are stored in the one of the following locations:

* %XATAFACE_ROOT%/Dataface/templates
* %SITE_ROOT%/templates

Where %XATAFACE_ROOT% is the Xataface directory (includes files such as dataface-public-api.php), and %SITE_ROOT% is the path to your application.

You may also have subdirectories within these templates directories.

===Cascading Templates===

Xataface uses a simple cascading technique for deciding which template to use.  If there are templates in the %SITE_ROOT%/templates and %XATAFACE_ROOT%/Dataface/templates directories with the same name, then Xataface will use the one in the %SITE_ROOT%/templates directory.  In this way, you are able to override any of Xataface&apos;s core templates by adding one of the same name to your %SITE_ROOT%/templates directory.

The most common template to override is the Dataface_Main_Template.html template which defines the look and feel for the entire application (e.g. header, footer, etc...).  Hence, if you wanted to customize the look &amp; feel of your application, you would likely start by copying %XATAFACE_ROOT%/Dataface/templates/Dataface_Main_Template.html into the %SITE_ROOT%/templates directory and make modifications to it as desired.

===Useful Smarty Tags introduced by Xataface===

In addition to the standard set of Smarty tags, Xataface templates provide some of its own.

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Version
|-
| [[templates:tags:use_macro|use_macro]]
| Include another template with the option to override certain sections.
| 0.6
|-
| define_slot
| Marks a section that can be overridden by other templates that include this one via the use_macro tag.
| 0.6
|-
| fill_slot
| Overrides content in a template that has been included via the use_macro tag.
| 0.6
|-
| block
| Marks an insertion point where content can be inserted by delegate classes and modules.
| 0.6
|-
| load_record
| Loads a [http://dataface.weblite.ca Dataface_Record] object from the database to be used in the template.
| 0.6
|-
| group
| Groups an array of records together based on a field value.
| 0.6
|-
| img
| Displays a thumbnail of an image.
| 0.6
|-
| actions
| Loads an associative array of actions defined in the actions.ini file, based on certain criteria.
| 0.6
|-
| actions_menu
| Displays a menu of actions based on certain criteria.
| 0.6
|-
| record_actions
| A specialization of the actions_menu tag.  This displays a menu of actions only in the record_actions category.
| 0.6
|-
| record_tabs
| A specialization of the actions_menu tag.  This displays a menu of actions only in the record_tabs category.
| 0.6
|-
| result_controller
| Displays the paging controls for the current table&apos;s records.   Use this for any listing of records.
| 0.6
|-
| result_list
| Displays the result list (from the list tab) for the current request.
| 0.6
|-
| related_list
| Displays the related records list for the current request.
| 0.6
|-
| bread_crumbs
| Displays the bread crumbs for the current request.
| 0.6
|-
| search_form
| Displays the find form for the current table.
| 0.6
|-
| language_selector
| Displays a menu to select the user&apos;s preferred language.
| 0.6
|-
| next_link
| Displays a link to the next XXX records.
| 0.6
|-
| prev_link
| Displays a link to the previous XXX records.
| 0.6
|-
| jump_menu
| Displays the select list of the records found in this found-set so that the user can jump directly to any record.
| 0.6
|-
| limit_field
| Displays a text field for the user to select the number of records to display per page.
| 0.6
|-
| result_index
| Displays the index of pages (1 to XXX) for this query.
| 0.6
|-
| summary_list
| Displays a list of records in the current found set using a summary format rather than the regular table format.
| 0.6
|-
| sort_controller
| Displays a control to sort the results on any column.
| 0.6
|-
| glance_list
| Displays a simple, brief list of records matching certain criteria.
| 0.6
|-
| record_view
| Loads structured data for a record as required for the view tab.
| 0.6
|-
| feed
| Generates a link to an RSS feed based on certain criteria.
| 0.6
|-
| translate
| Display a section of text in the user&apos;s selected language. (i18n).
| 0.6
|-
| if_allowed
| The contents of this block are shown only if the user has certain permissions.
| 0.6
|-
| editable
| Make a section of the page editable using AJAX.
| 0.6
|-
| abs
| Convert a URL into an absolute URL.
| 0.6
|}


===Useful Template Variables===

Xataface makes certain variables available to every template:

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Version
|-
| $ENV.REQUEST
| Reference to the $_REQUEST array (HTTP Request parameters, both GET and POST)
| 0.6
|-
| $ENV.SESSION
| Reference to the $_SESSION array (the session variables)
| 0.6
|-
| $ENV.DATAFACE_PATH
| The file system path to the Xataface directory (i.e. the directory containing all of the Xataface files such as dataface-public-api.php).
| 0.6
|-
| $ENV.DATAFACE_URL
| The URL to the Xataface directory.
| 0.6
|-
| $ENV.DATAFACE_SITE_PATH
| The file system path to your application directory. (i.e. the directory containing your conf.ini and index.php files).
| 0.6
|-
| $ENV.DATAFACE_SITE_URL
| The URL to your application directory.
| 0.6
|-
| $ENV.DATAFACE_SITE_HREF
| The URL to your application&apos;s script.  This differs from the $ENV.DATAFACE_SITE_URL variable in that this also includes the script name.
| 0.6
|-
| $ENV.SCRIPT_NAME
| Same as $ENV.DATAFACE_SITE_HREF
| 0.6
|-
| $ENV.APPLICATION
| A reference to the application&apos;s conf array (i.e. the parsed contents of the conf.ini file).
| 0.6
|-
| $ENV.APPLICATION_OBJECT
| A reference to the Dataface_Application object for the application.
| 0.6
|-
| $ENV.SERVER
| A reference to the $_SERVER array.
| 0.6
|-
| $ENV.QUERY
| A reference to the current query (i.e.  Dataface_Application::getInstance()-&gt;getQuery())
| 0.6
|-
| $ENV.action
| The name of the current action as specified by the -action REQUEST parameter.
| 0.6
|-
| $ENV.table
| The name of the current table as specified by the -table REQUEST parameter.
| 0.6
|-
| $ENV.table_object
| A reference to the current table.
| 0.6
|-
| $ENV.relationship
| The name of the current relationship as specified by the -relationship REQUEST parameter.
| 0.6
|-
| $ENV.limit
| The value of the -limit REQUEST parameter.  This is the number of records to show per page.
| 0.6
|-
| $ENV.start
| The value of the -start REQUEST parmeter.  This is the starting point in the result set which is currently being displayed.
| 0.6
|-
| $ENV.resultSet
| A reference to the [http://dataface.weblite.ca/Dataface_QueryTool Dataface_QueryTool] object for this result set.
| 0.6
|-
| $ENV.record
| A reference to the [http://dataface.weblite.ca/Dataface_Record Dataface_Record] object that is matched by the current query.
| 0.6
|-
| $ENV.mode
| The name of the current mode.  e.g. find, list, browse
| 0.6
|-
| $ENV.language
| The 2-digit ISO language code that is currently selected as the user&apos;s preferred language.
| 0.6
|-
| $ENV.prefs
| A reference to the preferences array ($conf[&apos;_prefs&apos;])
| 0.6
|-
| $ENV.search
| The value of the current full-text search (i.e. the search that was entered into the upper right search field.
| 0.6
|}


==Smarty Plugins==

One of the most powerful features of [http://www.smarty.net Smarty] is its pluggable architecture.  You can easily add your own custom plugins to a registered &quot;plugins&quot; directory to add functions, modifiers, blocks, and other features to your templates.

Prior to Xataface 2.0, you Smarty plugins could only be placed in the  &apos;&apos;lib/Smarty/plugins&apos;&apos; directory of the Xataface distribution folder.  This is not very conducive to Xataface updates, though.  In general it is best practice to not change anything inside the xataface directory.  Most other configuration and extensions can be handled by making changes to your application&apos;s directory which override corresponding functionality in Xataface.

As of Xataface 2.0, you can create a directory named &apos;&apos;plugins&apos;&apos; to your application directory, Smarty knows to look in this directory for plugins.

For versions of Xataface prior to 2.0, you can make a small modification to the SkinTool to also add support as desribed in [http://xataface.com/forum/viewtopic.php?f=4&amp;t=6722 this post].

===Example Plugin===

The following is an example Smarty plugin adapted from [http://www.smarty.net/docs/en/plugins.functions.tpl this page] but modified slightly to work in Xataface.  It is a simple &quot;eightball&quot; plugin that adds a tag {eightball} to Xataface that you can use in any of your templates.  Whenever this tag is rendered it outputs one of a set of predefined strings randomly.

# Add a &apos;&apos;plugins&apos;&apos; directory to your application directory.  i.e.  &apos;&apos;path/to/app/plugins&apos;&apos;
# Add a file inside this &apos;&apos;plugins&apos;&apos; directory called &apos;&apos;&lt;nowiki&gt;function.eightball.php&lt;/nowiki&gt;&apos;&apos; with the following content:&lt;code&gt;
&lt;?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.eightball.php
 * Type:     function
 * Name:     eightball
 * Purpose:  outputs a random magic answer
 * -------------------------------------------------------------
 */
function smarty_function_eightball($params, Dataface_SkinTool $template)
{
    $answers = array(&apos;Yes&apos;,
                     &apos;No&apos;,
                     &apos;No way&apos;,
                     &apos;Outlook not so good&apos;,
                     &apos;Ask again soon&apos;,
                     &apos;Maybe in your reality&apos;);

    $result = array_rand($answers);
    return $answers[$result];
}
&lt;/code&gt;
# If you compare this function to the original example in [http://www.smarty.net/docs/en/plugins.functions.tpl the smarty tutorial] you&apos;ll notice that the 2nd parameter has been changed to type &apos;&apos;Dataface_SkinTool&apos;&apos; from &apos;&apos;Smarty_Internal_Template&apos;&apos;. If you don&apos;t make this change, you will get a fatal error when you try to use the tag.  This function defines an &apos;&apos;{eightball}&apos;&apos; tag that can be added to any Smarty template in Xataface.
# Next we&apos;ll create a template that uses this tag.  If your application doesn&apos;t have a &apos;&apos;templates&apos;&apos; directory, create one now (i.e. path/to/app/templates).
# Add a file inside your templates directory called &apos;&apos;testing.html&apos;&apos; with the following content:&lt;code&gt;
The eight ball says {eightball}
&lt;/code&gt;
# Now we need to display this template somewhere in our interface.  In this case, we&apos;ll choose the &apos;&apos;before_record_content&apos;&apos; block.  (This will render the template before the main section of the view tab).  Add the following method to your [[Application_Delegate_Class]]:&lt;code&gt;
function block__before_record_content(){
    df_display(array(), &apos;testing.html&apos;);
}
&lt;/code&gt;
# Now if you load your application in a web browser and navigate to the details view for a record, you should see something like the following:
&lt;nowiki&gt;&lt;img src=&quot;http://media.weblite.ca/files/photos/Screen_Shot_2012-04-16_at_12.33.01_PM.png?max_width=640&quot;/&gt;&lt;/nowiki&gt;

===See also:===

* [http://www.xataface.com/documentation/tutorial/getting_started/changing-look-and-feel Changing the Look &amp; Feel of Xataface] (From the Getting Started Tutorial)
* [http://www.xataface.com/documentation/tutorial/customizing-the-dataface-look-and-feel Cusomizing the Xataface Look &amp; Feel] Tutorial</content>
	<keywords>templates, plugins, smarty</keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=31">
	<page_name>ShoppingCart</page_name>
	<page_id>31</page_id>
	<page_title>ShoppingCart</page_title>
	<content>==Xataface Shopping Cart Module==

[[toc]]

Status: Under development
Current Version: 0.2

===Synopsis===

Add a shopping cart to your xataface application.  You can treat any record as a product that can be sold.  Includes Paypal connectivity, shipping calculation, and more.

===Requirements===

* Xataface 1.0 or higher
* PHP 5 or higher
* MySQL 4.1 or higher

===Installation Instructions===

# Download the ShoppingCart module, extract it, and place the ShoppingCart directory in your Xataface modules directory. (i.e. /path/to/xataface/modules/ShoppingCart).
# Add the following line to the [_modules] section of your [[conf.ini file]]:&lt;code&gt;
modules_ShoppingCart=modules/ShoppingCart/ShoppingCart.php
&lt;/code&gt;
# Add the following to the beginning of your [[index.php file]]:&lt;code&gt;
function __autoload($class){
    if ( $class == &apos;ShoppingCart&apos; ) require_once &apos;modules/ShoppingCart/lib/ShoppingCart/ShoppingCart.class.php&apos;;
}
&lt;/code&gt;
# In the [[fields.ini file]] for any table whose records you wish to represent items for sale, add the following:&lt;code&gt;
[__implements__]
    InventoryItem=1
&lt;/code&gt;
# Specify which fields should be used for the item description, price, width, height, length, and weight in the [[fields.ini file]] for each table whose records you wish to represent items for sale by adding the following directives to the appropriate fields:&lt;code&gt;
ShoppingCart.description=1
ShoppingCart.unitPrice=1
ShoppingCart.weight=1
ShoppingCart.width=1
ShoppingCart.height=1
ShoppingCart.length=1
&lt;/code&gt; E.g. if your table has a field named &quot;&quot;price&quot;&quot; that you want to represent the unit price, you would have something like:&lt;code&gt;
[price]
    ShoppingCart.unitPrice=1
&lt;/code&gt;  The shopping cart module will make its best guess on which fields to use for these values if they are not explicitly specified.
# Specify the paypal account where money should be deposited by adding the following to your application&apos;s [[actions.ini file]]:&lt;code&gt;
[view_cart]
    paypal.account=&quot;youremail@example.com&quot;
&lt;/code&gt;


===Usage Instructions===

Once the Shopping Cart module is installed you can:

# Add items to your shopping cart
# View your cart contents
# Checkout and pay with paypal

====Adding Items to the Cart====

In the View tab of any salable record, you&apos;ll notice a little block on the left side of the page with the heading &quot;Add Item to Cart&quot;.  This includes a field to specify the quantity and a button to add the item to the shopping cart.

====Viewing Cart Contents====

The Shopping Cart module automatically introduces an action to view the cart contents.  This action is named &quot;view_cart&quot;.  Hence you can always view the cart contents by entering the URL: index.php?-action=view_cart .

====Checking Out====

# View the cart contents.
# Click &quot;Check out&quot;
# This will take you to a paypal page to pay for your items.


==Actions==

This module adds the following actions to your application.

{| class=&quot;listing listing2&quot;
|-
! Name
! Content-type
! Description
! Version
|-
| checkout
| text/html
| Sends user to paypal to pay for the contents of their cart.
| 0.1
|-
| calculate_shipping
| text/html
| Calculates the shipping charges for the cart.
| 0.1
|-
| add_to_cart
| text/html
| Adds an item to the cart.
| 0.1
|-
| clear_cart
| text/html
| Empties the shopping cart.
| 0.1
|-
| get_shipping_provinces
| text/json
| Returns JSON array of provinces for a given country.
| 0.1
|-
| invoices
| text/html
| Displays the current user&apos;s invoices.
| 0.1
|-
| payment_complete
| text/html
| Page that is displayed after a successful payment on paypal.
| 0.1
|-
| paypal_ipn
| none
| Handles paypal events such as successful payments.
| 0.1
|-
| refresh_shipping_methods
| text/html
| Refreshes the shipping methods available to the system.
| 0.1
|-
| set_shipping_method
| text/html
| Sets the selected shipping method to a particular method.
| 0.1
|- 
| view_cart
| text/html
| View the cart contents.
| 0.1
|}

==Blocks and Slots==

This module adds the following blocks and slots to your applications.

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Version
|-
| shipping_method
| A block with a form to select the shipping method.
| 0.1
|-
| add_to_cart
| A block with a form to add a record/item to the shopping cart.
| 0.1 
|}

==Application Delegate Class Hooks==

You can modify the shopping cart behavior by defining the following methods to the application delegate class.

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Version
|-
| isShippingMandatory
| Returns a boolean value indicating whether the user must select a shipping method.
| 0.1
|-
| getDefaultShippingMethod
| Returns a string with the name of the default shipping method to be used.
| 0.1
|}


==Table Delegate Class Hooks==

You can modify the behavior of the shopping cart by defining the following methods to the delegate class of any table that implements the InventoryItem ontology (i.e. any table that is to be used to store products that can be added to the cart).

{| class=&quot;listing listing2&quot;
|-
! Name
! Description
! Version
|-
| field__taxes
| A calculated field that returns an associative array of all applicable taxes for a product.
| 0.1
|}

==Internal Storage==

This module creates the following tables to store its data:

===dataface__invoices===

The dataface__invoices table stores the actual invoices for purchases made.  An invoice is automatically created as soon as the user &quot;checks out&quot;.

{| class=&quot;listing listing2&quot;
|-
! Column Name
! Data Type
! Description
! Version
|-
| InvoiceID
| int(11)
| Auto incrementing primary key for the invoice.
| 0.1
|-
| dateCreated
| datetime
| The date that the invoice was created.
| 0.1
|-
| dateModified
| datetime
| The date that the invoice was last modified
| 0.1
|-
| status
| enum
| The status of the invoice (either PENDING, PAID, or APPROVED).
| 0.1
|-
| amount
| decimal(10,2)
| The total amount on the invoice.
| 0.1
|-
| paymentMethod
| varchar(32)
| The name of the payment method used.
| 0.1
|-
| referenceID
| varchar(64)
| ??
| 0.1
|-
| username
| varchar(32)
| The username of the user who owns this invoice.
| 0.1
|-
| firstName
| varchar(32)
| The first name of the payer.
| 0.1
|-
| lastName
| varchar(32)
| The last name of the payer.
| 0.1
|-
| address_name
| varchar(100)
| The name on the shipping address.
| 0.1
|-
| address1
| varchar(100)
| The shipping address line 1.
| 0.1
|-
| address2
| varchar(100)
| The shipping address line 2.
| 0.1
|-
| city
| varchar(40)
| The shipping address city.
| 0.1
|-
| province
| varchar(2)
| The shipping province or state.
| 0.1
|-
| country
| varchar(2)
| The shipping country.
| 0.1
|-
| postalCode
| varchar(32)
| The shipping postal code.
| 0.1
|-
| shipping_method
| varchar(50)
| The name of the shipping method to use.
| 0.1
|-
| phone
| varchar(32)
| The phone number of the payer.
| 0.1
|-
| email
| varchar(127)
| The email address of the buyer.
| 0.1
|-
| data
| text
| Serialize shopping cart data.
| 0.1
|}


===dataface__shipping_methods===

Stores the available shipping methods.

{| class=&quot;listing listing2&quot;
|-
! Column Name
! Data Type
! Description
! Version
|-
| shipping_method_id
| int(11)
| Auto increment ID for a shipping method.
| 0.1
|-
| shipping_method_name
| varchar(50)
| The name of the shipping method.
| 0.1
|-
| shipping_method_label
| varchar(100)
| The label for the shipping method (displayed to the user).
| 0.1
|-
| shipping_method_enabled
| tinyint(1)
| Whether or not this shipping method is currently enabled.
| 0.1
|-
| shipping_method_module
| varchar(32)
| The name of the handler that this shipping method belongs to.
| 0.1
|}

==Payment Handlers==

Information about payment handlers to be added here.

==Shipping Handlers==

The Shopping Cart module is itself modular, allowing you to develop custom shipping handlers for different types of shipping.  A shipping handler is responsible for calculating shipping costs to a destination address.  Currently only a UPS shipping handler has been created, but it is not difficult to create other handlers.

===Shipping Handler Public Interface===

{| class=&quot;listing listing2&quot;
|-
! Method
! Description
! Version
|-
| calculateShipping
| Calculates the shipping cost for the current shopping cart, and adds the shipping cost to the cart as a line item.
| 0.1
|-
| getInfo
| Returns an array of shipping methods that can be handled by this handler.
| 0.1
|}






</content>
	<keywords></keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=115">
	<page_name>Using_RecordGrid</page_name>
	<page_id>115</page_id>
	<page_title>Using RecordGrid</page_title>
	<content>==Xataface RecordGrid Class and Template==

Also see [http://lamp.weblite.ca/dataface-0.6/docs/index.php?-table=Classes&amp;-action=browse&amp;ClassID=30| RecordGrid in the API Doc].


[[toc collapse=0]]

===Introduction===
As we learned in &apos;&apos;&apos;[http://xataface.com/documentation/tutorial/getting_started/dataface_actions Actions I: The Basics]&apos;&apos;&apos;, we can retrieve custom data from the DB in action via queries. This site deals with showing data in tabular form, like it could be received from even such a query. It is done by using Dataface_RecordGrid.


===First Example===
&lt;code&gt;
class actions_testTableAction {

	// Will be called from Xataface, if this action is called
	function handle(&amp;$params){
		$this-&gt;app =&amp; Dataface_Application::getInstance();  // reference to Dataface_Application object

		// Custom query
		$result = mysql_query(&quot;select * from testTable&quot;, $this-&gt;app-&gt;db());
		$body = &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
		
		if(!$result)
		{
			// Error handling
			$body .= &quot;MySQL Error ...&quot;;
		}else
		{
			while($row = mysql_fetch_assoc($result))	// Fetch all rows
			{
				// Maybe do something with the single rows
				$data[] = $row;	// Add singe row to the data
			}
			mysql_free_result($result); // Frees the result after finnished using it

			$grid = new Dataface_RecordGrid($data);	// Create new RecordGrid with the data
			
			$body .= $grid-&gt;toHTML();	// Get the HTML of the RecordGrid
		}

		// Shows the content (RecordGrid or error message) in the Main Template
		df_display(array(&apos;body&apos; =&gt; $body), &apos;Dataface_Main_Template.html&apos;);
	}
}
&lt;/code&gt;

You get your data from the query, fetch it into an associative array, create with it an RecordGrid and use the toHTML function. This is sure better than manually create the html tags around the data.

=====Screenshot: Blank RecordGrid=====
&lt;nowiki&gt;
&lt;img src=&quot;http://i89.photobucket.com/albums/k234/horchr/xataface/RecordGrid_blank.png?max_width=610&quot;/&gt;
&lt;/nowiki&gt;

=====Screenshot: ResultList=====

&lt;nowiki&gt;
&lt;img src=&quot;http://i89.photobucket.com/albums/k234/horchr/xataface/RecordList.png?max_width=713&quot;/&gt;
&lt;/nowiki&gt;


===Colored Example===

As you see above, the resultlist has colored rows, our First Example not. But you can easily change this, when you override the Dataface_RecordGrid.html template:

&lt;code&gt;
&lt;table id=&quot;{$id}&quot; class=&quot;listing {$class}&quot;&gt;
	&lt;thead&gt;
		&lt;tr&gt;
		{foreach from=$labels item=label}
		&lt;th&gt;{$label}&lt;/th&gt;
		{/foreach}
		&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
		{section name=row loop=$data}
		&lt;tr class=&quot;listing {cycle values=&quot;odd,even&quot;}&quot;&gt;
			{foreach from=$columns item=col}
			&lt;td&gt;{$data[row][$col]}&lt;/td&gt;
			{/foreach}
		&lt;/tr&gt;
		{/section}
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;/code&gt;

The magic happens in &lt;tr class=&quot;listing {cycle values=&quot;odd,even&quot;}&quot;&gt;
The {cycle values=&quot;odd,even&quot;} value cycles these two values and creates so the alternating row classes, like they are in the RecordList. By the way, {cycle ...} is a Smarty Function, see [http://www.smarty.net/docsv2/en/language.custom.functions.tpl| Smarty Doc].

(Find fruther information to template overriding in the tutorial and its links: [http://xataface.com/documentation/tutorial/getting_started/changing-look-and-feel| Changing the Look and Feel])

=====Screenshot: colored RecordGrid=====

&lt;nowiki&gt;
&lt;img src=&quot;http://i89.photobucket.com/albums/k234/horchr/xataface/RecordGrid_colored.png?max_width=610&quot;/&gt;
&lt;/nowiki&gt;


===Example completly imitating ResultList===

The Colored Example doesn&apos;t look like the ResulList? Its rows aren&apos;t as high as theres? That&apos;s a styling matter or rather in this case a cause of the checkboxes. Here an example with checkboxes and added (empty) links, so it looks completly like the ResultList:

Change the part in action.php
&lt;code&gt;
			while($row = mysql_fetch_assoc($result))	// Fetch all rows
			{
				// Maybe do something with the single rows
				$row[&apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;] = &apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;;
				$data[] = $row;	// Add singe row to the data
			}
			mysql_free_result($result); // Frees the result after finnished using it

			$grid = new Dataface_RecordGrid($data,	// Create new RecordGrid with the data
				  array(&apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;, &apos;testID&apos;, &apos;name&apos;, &apos;description&apos;, &apos;number&apos;),	
				//Order and selection of the colums
				  null);	// No other labels defined -&gt; it uses keys of the associative array
			
			$body .= $grid-&gt;toHTML();	// Get the HTML of the RecordGrid
&lt;/code&gt;

Dataface_RecordGrid.html template
&lt;code&gt;
&lt;table id=&quot;{$id}&quot; class=&quot;listing {$class}&quot;&gt;
	&lt;thead&gt;
		&lt;tr&gt;
		{foreach from=$labels item=label}
		&lt;th&gt;&lt;a class=&quot;unmarked_link&quot;&gt;{$label}&lt;/a&gt;&lt;/th&gt;
		{/foreach}
		&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
		{section name=row loop=$data}
		&lt;tr class=&quot;listing {cycle values=&quot;odd,even&quot;}&quot;&gt;
			{foreach from=$columns item=col}
			&lt;td&gt;&lt;a class=&quot;unmarked_link&quot;&gt;{$data[row][$col]}&lt;/a&gt;&lt;/td&gt;
			{/foreach}
		&lt;/tr&gt;
		{/section}
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;/code&gt;

=====Screenshot: RecordGrid completly imitating ResultList=====

&lt;nowiki&gt;
&lt;img src=&quot;http://i89.photobucket.com/albums/k234/horchr/xataface/RecordGrid_colored_checkboxes_links.png?max_width=610&quot;/&gt;
&lt;/nowiki&gt;

=====Screenshot: ResultList=====

&lt;nowiki&gt;
&lt;img src=&quot;http://i89.photobucket.com/albums/k234/horchr/xataface/RecordList.png?max_width=713&quot;/&gt;
&lt;/nowiki&gt;

===Try it out===

Use the following code with static test data and any template in this article (or even without overriding it) to try it out.

&lt;code&gt;
class actions_testTableAction {

	// Will be called from Xataface, if this action is called
	function handle(&amp;$params){
		$this-&gt;app =&amp; Dataface_Application::getInstance();  // reference to Dataface_Application object

		$result_dummy = array(
			array(&apos;testID&apos; =&gt; &apos;1&apos;, &apos;name&apos; =&gt; &apos;testname&apos;, 
				&apos;description&apos; =&gt; &apos;a short description&apos;, &apos;number&apos; =&gt; &apos;258&apos;),
			array(&apos;testID&apos; =&gt; &apos;2&apos;, &apos;name&apos; =&gt; &apos;another name&apos;, 
				&apos;description&apos; =&gt; &apos;a bit longer description to this data set&apos;, &apos;number&apos; =&gt; &apos;946&apos;),
			array(&apos;testID&apos; =&gt; &apos;3&apos;, &apos;name&apos; =&gt; &apos;dummy name&apos;, 
				&apos;description&apos; =&gt; &apos;yea, a dummy data set!&apos;, &apos;number&apos; =&gt; &apos;1342&apos;),
			array(&apos;testID&apos; =&gt; &apos;4&apos;, &apos;name&apos; =&gt; &apos;not empty&apos;, 
				&apos;description&apos; =&gt; &apos;this data set isn\&apos;t empty ...&apos;, &apos;number&apos; =&gt; &apos;282&apos;),
			array(&apos;testID&apos; =&gt; &apos;5&apos;, &apos;name&apos; =&gt; &apos;your entry&apos;, 
				&apos;description&apos; =&gt; &apos;this entry is only for you&apos;, &apos;number&apos; =&gt; &apos;79&apos;),
			array(&apos;testID&apos; =&gt; &apos;6&apos;, &apos;name&apos; =&gt; &apos;no idea&apos;, 
				&apos;description&apos; =&gt; &apos;running out of ideas ...&apos;, &apos;number&apos; =&gt; &apos;203&apos;),
			array(&apos;testID&apos; =&gt; &apos;7&apos;, &apos;name&apos; =&gt; &apos;the last one&apos;, 
				&apos;description&apos; =&gt; &apos;the end&apos;, &apos;number&apos; =&gt; &apos;26841&apos;)
		);
		$body = &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
		
		foreach($result_dummy as $row)	// Fetch all rows
		{
			// Maybe do something with the singe rows
			$row[&apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;] = &apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;;
			$data[] = $row;	// Add singe row to the data
		}

		$grid = new Dataface_RecordGrid($data,	// Create new RecordGrid with the data
			array(&apos;&lt;input type=&quot;checkbox&quot;&gt;&apos;, &apos;testID&apos;, &apos;name&apos;, &apos;description&apos;, &apos;number&apos;),	
			//Order and selection of the colums
			  null);	// No other labels defined -&gt; it uses keys of the associative array

		$body .= $grid-&gt;toHTML();	// Get the HTML of the RecordGrid

		// Shows the content (RecordGrid or error message) in the Main Template
		df_display(array(&apos;body&apos; =&gt; $body), &apos;Dataface_Main_Template.html&apos;);
	}
}
&lt;/code&gt;
</content>
	<keywords>RecordGrid, Dataface_RecordGrid, data in tabular form</keywords>
	<language>en</language>
	<original_page></original_page>
</wiki>
<wiki id="wiki?page_id=10">
	<page_name>preferences</page_name>
	<page_id>10</page_id>
	<page_title>preferences</page_title>
	<content>==Xataface Preferences==

[[toc]]

Xataface preferences can be defined in 3 ways:

# In the &apos;&apos;[_prefs]&apos;&apos; section of rhe [[conf.ini file]] for global static preferences.
# Implementing the [[getPreferences]] method in the [[Application Delegate Class]]
# In the [[__prefs__]] section of the fields.ini file for a table for static preferences on that table.  (Limited to only certain preferences).

===Example [_prefs] section===
In the conf.ini
&lt;code&gt;
[_prefs]
    hide_updated=1
    hide_posted_by=1
&lt;/code&gt;

===Example [[getPreferences]] method===
In the [[Application Delegate Class]]:
&lt;code&gt;
function getPreferences(){
    return array(&apos;hide_update&apos;=&gt;1, &apos;hide_posted_by&apos;=&gt;1);

}
&lt;/code&gt;

===Available Preferences===

{| class=&quot;listing listing2&quot;
! Name
! Description
! Default
! Version
|-
| show_result_stats
| Show the result statistics (e.g. found x of y records in table z)
| 1
| 0.6
|-
| show_jump_menu
| Show he drop-down menu that allows you to &quot;jump&quot; to any record in the found set.
| 1
| 0.6
|-
| show_result_controller
| Show Next, previous, page number .. links...
| 1
| 0.6
|-
| show_table_tabs
| Show  Details, List, Find, etc... tabs.
| 1
| 0.6
|-
| show_actions_menu
| Show New record, Show all, delete, etc..
| 1
| 0.6
|-
| show_logo
| Show logo at top of app
| 1
| 0.6
|-
| show_tables_menu
| Show the tabs to select a table.
| 1
| 0.6
|-
| show_search
| Show search field in upper right.
| 1
| 0.6
|-
| show_record_actions
| Show actions related to particular record
| 1
| 0.6
|-
| show_bread_crumbs
| Show bread crumbs at top of page to show where you are.
| 1
| 0.6
|-
| show_record_tabs
| View, Edit, Translate, History, etc...
| 1
| 0.6
|-
| show_record_tree
| Show tree to navigate the relationships of this record.
| 1
| 0.6
|-
| list_view_scroll_horizontal
| Whether to scroll list horizontal if it exceeds page width
| 1
| 0.6
|-
| list_view_scroll_vertical
| Whether to scroll list vertical if it exceeds page height.
| 1
| 0.6
|-
| hide_posted_by
| Whether to hide the &apos;&apos;posted by&apos;&apos; text in glance lists (e.g. in the view tab, the related records are shown in the left column.  This hides the &apos;&apos;posted by&apos;&apos; text next to each related record.
| 0
| 1.0b4
|-
| hide_updated
| Whether to hide the &apos;&apos;updated&apos;&apos; text in the glance lists (e.g. in the view tab, the related records are shown in the left column.  This hides the &apos;&apos;updated&apos;&apos; text next to each related record.
| 0
| 1.0b4
|-
| SummaryList_logo_width
| The width of the logo to be used as the preview image in summary lists.
| null
| 0.7
|-
| SummaryList_hideSort
| Hides the sort control for a summary list (the box that allows users to sort by column).
| 0
| 0.7
|-
| hide_user_status
| Hides the user&apos;s status (e.g. &quot;You are logged in as ...&quot;
| 0
| 0.7
|-
| hide_personal_tools
| Hides the personal tool links in upper right.  This includes likes such as &quot;Control Panel&quot; and &quot;My Profile&quot;
| 0
| 0.7
|-
| hide_resultlist_controller
| Hides the controller for a result list (E.g. next/back/results per page etc...).
| 0
| 0.7
|-
| hide_related_sections
| Hides the sections of the view tab that show the related records.  These are the sortable section boxes.  Not the related tabs.
| 0
| 1.3
|-
| hide_record_search
| Hides the record search form that appears in the view tab.  Not to be confused with the find tab.
| 0
| 1.3
|-
| show_resultlist_controller_only_when_needed
| Sets the resultlist controller (e.g. back/next/results per page/etc...) to only show up if paging is required (i.e. if there are more records than can be shown on one page (according to the &apos;-limit&apos; parameter).
| 0
| 1.0
|-
| hide_record_view_logo
| Hides the logo for a record that appears in the upper left of the view tab for each record.
| 0
| 0.7
|-
| horizontal_tables_menu
| Whether to force the tables menu to appear as tabs along the top of the page (alternative is as a menu on the left). If there are 10 or fewer allowed tables, then the default is 1, otherwise the default is set to 0.
| 1
| 0.6
|-
| hide_result_filters
| In list view, setting this value to 1 will cause the column filters to be hidden (the select lists to filter the results).
| 0
| 0.7
|-
| disable_select_rows
| A value of 1 causes the checkboxes in each row of the list view to be hidden.
| 0
| 0.7
|-
| result_list_use_geturl
| Use the getURL() method to link to records in the list view rather than the default (which uses the -cursor parameter).
| 0
| 0.7
|-
| disable_ajax_record_details
| Whether to disable the ajax record details (the &apos;+&apos; sign beside each record in list view that expands to show the record details.
| 1
| 0.7
|-
| use_old_resultlist_controller
| As of Xataface 1.1, a new style result list controller is used that resembles facebook.  It is more slimmed down and is easier to manage.  If you prefer the old controller, set this preference to 1.
| 0
| 1.1
|}

===Inverse Preferences===

The following preferences perform the inverse of some of the options above. When these options are set to 1, their respective option is set to 0.

{| class=&quot;listing listing2&quot;
! Name
! Inverse
|-
| hide_nav_menu
| show_tables_menu
|-
| hide_view_tabs
| show_table_tabs
|-
| hide_result_controller
| show_result_controller
|-
| hide_table_result_stats
| show_result_stats
|-
| hide_search
| show_search
|}
</content>
	<keywords>preferences, prefs, getPreferences</keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki>
<wiki id="wiki?page_id=34">
	<page_name>examples</page_name>
	<page_id>34</page_id>
	<page_title>examples</page_title>
	<content>==Xataface Examples==

[[toc]]

This section includes concrete examples of how Xataface has been used in the past.

===Demo Applications===

{| class=&quot;listing listing2&quot;
|-
! Screenshot
! Title/Description
! Developed by
|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://demo.weblite.ca/apps/librariandb/]]
| &apos;&apos;&apos;Librarian DB&apos;&apos;&apos;

A searchable database of library books.  Useful for small libraries (e.g. Church Libraries).

Log in with:
username: admin
password: password

[http://demo.weblite.ca/apps/librariandb/ Try the app]
| [http://solutions.weblite.ca Web Lite Solutions Corp.]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://demo.weblite.ca/apps/webauction/]]
| &apos;&apos;&apos;Web Auction&apos;&apos;&apos;

A simple web-based auction application for organizations to hold auctions.

Login with:
username: admin
password: password

[http://demo.weblite.ca/apps/webauction/ Try the app]
| [http://solutions.weblite.ca Web Lite Solutions Corp.]


|}

===Websites Powered by Xataface===

{| class=&quot;listing listing2&quot;
|-
! Screenshot
! Title/Description
! Developed by
|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://fueleconomydb.com]]
| &apos;&apos;&apos;Fuel Economy Database&apos;&apos;&apos; - A searchable database of gas mileage and fuel economy statistics for automobiles from 1986 to present.

[http://fueleconomydb.com Visit the site]
| [http://solutions.weblite.ca Web Lite Solutions Corp.]
|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://physics.sfu.ca]]
| &apos;&apos;&apos;Department of Physics, Simon Fraser University&apos;&apos;&apos;
This website is completely powered by Xataface.  It is backed by a MySQL database that stores faculty members, research groups, news, events, and more.  Faculty members are able to update their personal profiles and research profiles through a Xataface administration console.

[http://physics.sfu.ca Visit the site]
| [http://fas.sfu.ca/ SFU Faculty of Applied Sciences]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://science.ca]]
| &apos;&apos;&apos;Science.ca&apos;&apos;&apos;

The source for science in Canada.  Includes profiles for prominent scientists as well as other useful science-related information.  Xataface is used to power the bilingual (English/French) capabilities of this site.  It includes web-based administrative console for the administrator to manage all content, and for translators to translate the content.

[http://science.ca Visit the site]
| Science.ca web team

|-

| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://translation.weblite.ca]]
| &apos;&apos;&apos;Simple Website Translation Engine&apos;&apos;&apos;

A service that allows website owners to easily convert their website into multiple languages.  Support human and machine translation.  This service is powered by Xataface, and provides an administrative console for users to manage their website translations.

[http://translation.weblite.ca Visit the Site]

[http://swete.weblite.ca More about this service]

| [http://translation.weblite.ca Web Lite Translation Corp.]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://www.credituniondb.com]]
| &apos;&apos;&apos;Credit Union Database&apos;&apos;&apos;

A database of credit unions in the United States.  This site is powered by Xataface.

[http://www.credituniondb.com Visit the site]

| Vlad

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://ierg.net/lessonplans/unit_plans.php]]
| &apos;&apos;&apos;IERG Lesson Plans Database&apos;&apos;&apos;

A searchable database of lesson plans created by the Imaginative Education Research Group.  This database is managed by Xataface.  It provides researchers with a web-based control panel to manage their lesson plans.

[http://ierg.net/lessonplans/unit_plans.php Visit the site]

| [http://solutions.weblite.ca Web Lite Solutions Corp.]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://ierg.net/people/]]
| &apos;&apos;&apos;IERG People Database&apos;&apos;&apos;

A simple database to manage the contributors and associates of the Imaginative Education Research Group.  Administrators have a web-based control panel to manage the people profiles in this database.

[http://ierg.net/people/ Visit the site]

| [http://solutions.weblite.ca Web Lite Solutions Corp.]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://sustain-gradnetwork.envr.sfu.ca/]]
| &apos;&apos;&apos;Sustainability Research Database&apos;&apos;&apos;

A database at Simon Fraser University for grad students to post and share research profiles.

[http://sustain-gradnetwork.envr.sfu.ca/ Visit the site]

| [http://fas.sfu.ca Faculty of Applied Sciences Web Team]

|-
| [[Image:http://images.websnapr.com/?size=150&amp;key=40f0knTakb1b&amp;url=http://apps.weblite.ca/]]
| &apos;&apos;&apos;Web Lite Applications Catalog&apos;&apos;&apos;

A catalog of applications available through Web Lite Solutions.  Allows users to set up their own online applications on Web Lite&apos;s servers.  This site is completely powered by Xataface.

[http://apps.weblite.ca/ Visit the site]

| [http://solutions.weblite.ca Web Lite Solutions Corp.]
|}


</content>
	<keywords>examples, samples</keywords>
	<language>en</language>
	<original_page>0</original_page>
</wiki></record>