Xataface 2.0
Xataface Application Framework
Public Member Functions | Static Public Member Functions | Data Fields
Dataface_SkinTool Class Reference

Public Member Functions

 Dataface_SkinTool ()
getResultController ()
 _get_compile_path ($resource_name)
 display ($context, $template=null, $compile_id=null)
 register_skin ($name, $template_dir)
 load_record ($params, &$smarty)
 record_view ($params, &$smarty)
 group ($params, &$smarty)
 img ($params, &$smarty)
 actions ($params, &$smarty)
 actions_menu ($params, &$smarty)
 record_actions ($params, &$smarty)
 record_tabs ($params, &$smarty)
 summary_list ($params, &$smarty)
 glance_list ($params, &$smarty)
 sort_controller ($params, &$smarty)
 use_macro ($params, $content, &$smarty)
 editable ($params, $content, &$smarty)
 define_slot ($params, $content, &$smarty, &$repeat)
 fill_slot ($params, $content, &$smarty)
 translate ($params, $content, &$smarty)
 result_controller ($params, &$smarty)
 next_link ($params, &$smarty)
 prev_link ($params, &$smarty)
 jump_menu ($params, &$smarty)
 limit_field ($params, &$smarty)
 result_index ($params, &$smarty)
 result_list ($params, &$smarty)
 filters ($params, &$smarty)
 records ($params, &$smarty)
 related_list ($params, &$smarty)
 bread_crumbs ($params, &$smarty)
 search_form ($params, &$smarty)
 if_allowed ($params, $content, &$smarty)
 language_selector ($params, &$smarty)
 block ($params, &$smarty)
 feed ($params, &$smarty)
 abs ($params, $url, &$smarty)

Static Public Member Functions

static & getInstance ()

Data Fields

 $compile_dir
 $ENV
 $skins = array()
 $locals = array()
 $languageTool
 $app
 $resultController = null

Detailed Description

Handles the display of content in Dataface using templates. Abstracts all templating.

Usage example

$tool =& Dataface_SkinTool::getInstance(); $context = array('var1'=>'value1', 'var2'=>'value2'); // context to provide information to the template. // var1 will be available as {$var1} in the template, etc...

$template = 'MyTemplate.html'; // The name of the template to use. Location of templates directory stored in // $GLOBALS['Dataface_Globals_Templates']

$tool->display($context, $template); // prints the template

Templates can use any of the standard smarty markup in addition to new markup that is added by the Skin Tool. Dataface-specific variables are available via the $ENV variable, which is an associative array of values relating to Dataface and the current context.

Some useful variables include:

$ENV.DATAFACE_PATH
The file path (not the URL path) to the current Dataface installation directory. e.g. /var/www/dataface
$ENV.DATAFACE_URL
The URL to the Dataface installation directory. Useful for including resources such as images in your templates. e.g. http://yourdomain.com/path/to/dataface
$ENV.DATAFACE_SITE_PATH
The file path (not the URL path) to your application's directory. e.g. /var/www/your/app
$ENV.DATAFACE_SITE_URL
The URL to your application's directory. e.g. http://yourdomain.com/path/to/your/app
$ENV.DATAFACE_SITE_HREF
The URL to your application's entry point script. e.g. http://yourdomain.com/path/to/your/app/index.php
$ENV.APPLICATION
The application's configuration array. This includes any settings that you added to your conf.ini file. e.g. {ENV.APPLICATION._database.host} will display the host name of the mysql database as specified in the conf.ini file.
$ENV.APPLICATION_OBJECT
A reference to the application object (Dataface_Application).
$ENV.action
The name of the action that is currently being performed. e.g. view, edit, new_related_record, etc..
$ENV.table
The name of the current database table.
$ENV.relationship
If there is a relationship currently specified in the request, this is the name of it.
$ENV.limit
The maximum number of records to show per page.
$ENV.start
The start position in the current result set.
$ENV.resultSet
A reference to the current record result set. This is a Dataface_QueryTool object.
$ENV.record
A reference to the current record. (if in browse mode).
$ENV.mode
The current application mode. e.g. browse, list, find
$ENV.language
The 2-digit language code of the currently selected language.
$ENV.prefs
The user's preferences array which decides which parts of the interface should be visible (among other settings).
$ENV.search
The current search term if a search has been performed in the search box.
See also:
df_display()
df_register_skin()

http://smarty.php.net The Smarty website. Contains extensive documentation about smarty.

Author:
Steve Hannah <shannah@sfu.ca> October 15, 2005

Definition at line 81 of file SkinTool.php.


Member Function Documentation

_get_compile_path ( resource_name)

Get the compile path for this resource.

This method is used internally by SkinTool to find out where the compiled version of a particular template is located.

Parameters:
string$resource_name
Returns:
string results of _get_auto_filename()

Definition at line 260 of file SkinTool.php.

abs ( params,
url,
&$  smarty 
)

Definition at line 1065 of file SkinTool.php.

actions ( params,
&$  smarty 
)

Returns an associative array of actions matching the criteria.

Parameters:
varThe name of the variable to store the actions in.
recordA Dataface record object.
tableThe name of a table
categoryThe category of actions.

Definition at line 557 of file SkinTool.php.

actions_menu ( params,
&$  smarty 
)

Definition at line 573 of file SkinTool.php.

block ( params,
&$  smarty 
)

Definition at line 1017 of file SkinTool.php.

bread_crumbs ( params,
&$  smarty 
)

Definition at line 925 of file SkinTool.php.

Definition at line 92 of file SkinTool.php.

define_slot ( params,
content,
&$  smarty,
&$  repeat 
)

Definition at line 754 of file SkinTool.php.

display ( context,
template = null,
compile_id = null 
)

Displays a template.

Parameters:
array&$contextAn associative array of variables that can be used in the template.
string$templateThe name of the template to be displayed. It will look inside any registered template directory. By default it will check the application's templates directory, then look in the Dataface/templates directory to find the template.

Definition at line 318 of file SkinTool.php.

editable ( params,
content,
&$  smarty 
)

Definition at line 739 of file SkinTool.php.

feed ( params,
&$  smarty 
)

Definition at line 1026 of file SkinTool.php.

fill_slot ( params,
content,
&$  smarty 
)

Definition at line 793 of file SkinTool.php.

filters ( params,
&$  smarty 
)

Definition at line 870 of file SkinTool.php.

static& getInstance ( ) [static]

Returns a singleton instance to the skin tool.

Returns:
Dataface_SkinTool

Definition at line 336 of file SkinTool.php.

& getResultController ( )

Obtains a reference to the result controller for this request. The result controller is the control that allows users to navigate between records of the current result set.

Returns:
Dataface_ResultController

Definition at line 239 of file SkinTool.php.

glance_list ( params,
&$  smarty 
)

Definition at line 697 of file SkinTool.php.

group ( params,
&$  smarty 
)

Groups an array of Records (or associative arrays) together based on a specific field.

Parameters:
array$paramsArray of parameters
Dataface_SkinTool&$smartyReference to Smarty template engine.
array$params,[from]The array that is to be grouped.
string$params,[var]The name of the variable to assign the grouped structure to.
string$params,[on]The name of the field on which to group the records.
string$params,[order]A comma-delimited string of order directives to specify the order in which the records should be displayed.
string$params,[titles]Titles for the groups in a format similar to css attributes.

Definition at line 456 of file SkinTool.php.

if_allowed ( params,
content,
&$  smarty 
)

Checks to see if the current user has a particular permission on a given record.

Parameters:
array$paramsAssociative array of parameters.
string$contentSince this method acts as a block tag, the second time it is called, it is passed the content of the block in this parameter.
Smarty&$smartyReference to the SkinTool object. -block boolean if_allowed -param string permission The name of the permission that is being checked. e.g. 'edit', or 'view'. -param Dataface_Record record The record to check the permission against.

Definition at line 990 of file SkinTool.php.

img ( params,
&$  smarty 
)

Prints an 'img' tag that will show a thumbnail of the requested image using phpThumb. This function is registered with smarty so that it can be used in the form of an {img} tag.

Parameters:
$params= { "src" -> The url to the image (required) "width" -> The max width of the thumbnail (optional) "height" -> The max height of the thumbnail. (optional) """ Any other parameters that are appropriate for the img tag. }

Definition at line 504 of file SkinTool.php.

jump_menu ( params,
&$  smarty 
)

Definition at line 841 of file SkinTool.php.

language_selector ( params,
&$  smarty 
)

Definition at line 1012 of file SkinTool.php.

limit_field ( params,
&$  smarty 
)

Definition at line 846 of file SkinTool.php.

load_record ( params,
&$  smarty 
)

Loads a record from the database and assigns it to a template variable.

{load_record var=myrecord} {*loads current record as specified by request's found set & query parameters.*} {$myrecord->val('FirstName')} {*Displays the value of the loaded record's 'FirstName' field. *}

Parameters:
array$paramsAssociative array of parameters.
Smarty&$smartyReference to the SkinTool object context.
Returns:
void

-function load_record -param string table The name of the table from which to load the record. (Optional - will default to current table). -param string var The name of the variable into which the record should be loaded. -param % Optional key-value pairs of field names / values to find a particular record. If none are provided, the current record will be returned.

Definition at line 397 of file SkinTool.php.

next_link ( params,
&$  smarty 
)

Definition at line 830 of file SkinTool.php.

prev_link ( params,
&$  smarty 
)

Definition at line 836 of file SkinTool.php.

record_actions ( params,
&$  smarty 
)

Definition at line 672 of file SkinTool.php.

record_tabs ( params,
&$  smarty 
)

Definition at line 677 of file SkinTool.php.

record_view ( params,
&$  smarty 
)

Definition at line 433 of file SkinTool.php.

records ( params,
&$  smarty 
)

Definition at line 883 of file SkinTool.php.

register_skin ( name,
template_dir 
)

Registers a skin to be used as the default skin. This skin is added to the top of the stack so it has the highest priority. If a template is requested and this skin does not contain that template, then the SkinTool will check the next skin in the stack. And so on...

Parameters:
string$template_dirThe directory to the templates for this skin.
string$compile_dirThe directory where the compiled templates should be stored.

Definition at line 358 of file SkinTool.php.

related_list ( params,
&$  smarty 
)

Definition at line 903 of file SkinTool.php.

result_controller ( params,
&$  smarty 
)

Definition at line 813 of file SkinTool.php.

result_index ( params,
&$  smarty 
)

Definition at line 851 of file SkinTool.php.

result_list ( params,
&$  smarty 
)

Definition at line 855 of file SkinTool.php.

search_form ( params,
&$  smarty 
)

Definition at line 967 of file SkinTool.php.

sort_controller ( params,
&$  smarty 
)

Definition at line 703 of file SkinTool.php.

summary_list ( params,
&$  smarty 
)

Definition at line 691 of file SkinTool.php.

translate ( params,
content,
&$  smarty 
)

Definition at line 804 of file SkinTool.php.

use_macro ( params,
content,
&$  smarty 
)

Definition at line 719 of file SkinTool.php.


Field Documentation

$app

Definition at line 89 of file SkinTool.php.

$compile_dir

Definition at line 84 of file SkinTool.php.

$ENV

Definition at line 85 of file SkinTool.php.

$languageTool

Definition at line 88 of file SkinTool.php.

$locals = array()

Definition at line 87 of file SkinTool.php.

$resultController = null

Definition at line 90 of file SkinTool.php.

$skins = array()

Definition at line 86 of file SkinTool.php.


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