Phang  2.1
 All Classes Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
Ui_model Class Reference

Models a UI component which is derived from a data model object Designed to be a dumb 'container' object - Ui_Mapper should be doing all the heavy lifting. More...

Inheritance diagram for Ui_model:
Db_Model Base

List of all members.

Public Member Functions

 __construct ($table_name=null)
 Class constructor.
 set_table_properties ()
 Set table properties (based on schema information in core_table).
 get_fields ($view=null)
 Gets required fields, and sorts it so it's in the right order.
 get_name ()
 Get the model name.
 set_field_properties ()
 Set the field properties (based on core_field information).
 set_relational_fields ()
 Set the relational fields.
 get_save_values ($record)
 Get the values to save as an array.
 get_labels ($view='')
 Get an array of field labels.
 get_user ()
 Gets the current user as stored in the session – NB this should probably be moved to a separate area of the application.
 has_field_access ($field, $view='')
 Does this view have access to the field?
 export_csv ($sql=null)
 Export records to CSV.
- Public Member Functions inherited from Db_Model
 set_fields ()
 Gets information on fields in a table.
 set_relations ()
 Gets information on relations between the selected table and others (one-to-many and many-to-one).
 get_field_properties ($db_model, $map_table)
 Get the field properties.
 get ($id=null)
 Get a record.
 first ($where=array(), $order_by=array())
 Get the first record matching criteria.
 all ($where=array(), $order_by=array(), $limit=array())
 Get an array of all records matching criteria.
 is_field ($field_name)
 Does the field exist?
 get_field ($field_name)
 Get a field.
 has_children ()
 Is this model recursive?
 has_parent ()
 Is this model recursive?
 get_parent_field_name ()
 For recursive models, Get the field name which stores the parent ID.
 save (Db_Record &$record)
 Save a record.
 delete ($where=array())
 Delete one or more records.
 set_default ()
 Update the singleton record of the model to this one for future use.
 sql ()
 Get the SQL data.
 root ()
 For recursive models, get the root node of a tree.
- Public Member Functions inherited from Base
 __call ($function, $params)
 The 'magic' call method will get/set for us invoked when the interpreter can not find a method the user is asking for.
 set_parameters ($arguments)
 Set variables from an array to member fields requires $this->optional_arguments or $this->required_arguments to have been set by the subclass.

Static Public Member Functions

static create ($table_name)
 Factory method.
- Static Public Member Functions inherited from Db_Model
static create ($table_name, $class_name='')
 Factory method.

Public Attributes

 $fields = array()
 Array of Ui_Model_Field objects.
- Public Attributes inherited from Db_Model
 $h2o_safe = 1
 can be used in h2o

Protected Attributes

 $name = ''
 Name of model.
 $to_string = ''
 Identifying field or expression.
 $sequence_field = ''
 Sequence field (if using ui sequence classes)
 $group_by_field = ''
 Group by field (for sequence field)
 $order_by = ''
 Order by string.
 $before_update = array()
 Callback function to perform before a record is updated.
 $after_update = array()
 Callback function to perform after a record is updated.
 $parents = array()
 tables with a many-to-one relationship
 $children = array()
 tables with a one-to-many relationship
 $access = ''
 array: view => list of acces types
 $field_class = "Ui_model_field"
 field class name - this can be overridden to a custom class on a subclass
 $record_class = "Ui_Record"
 record class name - this can be overridden to a custom class on a subclass
 $callback_script = ''
 array: Callback script
 $callback_function = ''
 array: Callback function
 $callback_parameters = ''
 array: Callback parameters
- Protected Attributes inherited from Db_Model
 $table_name = ''
 Table name.
 $schema_name = ''
 Schema (database) name.
 $primary_key = ''
 Primary key field.
 $db = ''
 Database object.
 $relations = array()
 Relations data.
 $last_id = 0
 The ID of the last record that was inserted.
- Protected Attributes inherited from Base
 $optional_arguments = array()
 Array of options that can be set to variables.
 $required_arguments = array()
 Array of options that need to be set to variables.

Detailed Description

Models a UI component which is derived from a data model object Designed to be a dumb 'container' object - Ui_Mapper should be doing all the heavy lifting.


Constructor & Destructor Documentation

Ui_model::__construct (   $table_name = null)

Class constructor.

  • $table_name: name of the table
  • $fields: array of Ui_Model_Field objects:

Reimplemented from Db_Model.


Member Function Documentation

static Ui_model::create (   $table_name)
static

Factory method.

Creates a new singleton instance of the class. If it has already been created, it uses the instance in the $_REQUEST array to save duplicate objects flying about.

Ui_model::get_fields (   $view = null)

Gets required fields, and sorts it so it's in the right order.

Todo:
this is not the most clever or efficient way of doing things - should be in the right order already!
Ui_model::get_save_values (   $record)

Get the values to save as an array.

Only the modified data is saved.

Reimplemented from Db_Model.


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