Class: I2CE FormStorage Mechanism

From IHRIS Wiki
Revision as of 13:03, 17 October 2009 by Litlfred (talk | contribs)

This article desrcibes the1 class I2CE_FormStorage_Mechanism.

@filesource Class I2CE_Module_FormStorage_Mechanism

Constants

I2CE_FormStorage_Mechanism::CHANGE_INITIAL

Constant signifying an initial entry. Defined as: 1

I2CE_FormStorage_Mechanism::CHANGE_VERIFY

Constant signifying a verified entry. Defined as: 2

I2CE_FormStorage_Mechanism::CHANGE_CORRECTION

Constant signifying a corrected entry. Defined as: 3

I2CE_FormStorage_Mechanism::CHANGE_UPDATE

Constant signifying an updated entry. Defined as: 4

Variables

$name

The short name for this storage mechanism

$global_options

  • Type: protected $global_options

$ordering

  • Type: protected $ordering

Methods

FF_IG_setSequence()

Set FormField_INT_GENERATE sequence

FF_populateHistory()

populate FormField history. By default does nothing.

  • Signature: public function FF_populateHistory($form_field)
  • Parameters:

FF_save()

Save the FormField to the database.

  • Signature: public function FF_save($form_field,$do_check,$user)
  • Parameters:
    • I2CE_FormField $form_field
    • boolean $do_check
      A flag to determine if a check should be made for the same value being saved.
    • I2CE_User $user
      The user saving this data.
  • Returns: boolean

__construct()

The constructor for the storage mechanism

  • Signature: public function __construct($name,$global_options)
  • Parameters:
    • string $name
    • array $global_options
      Default to empty array. The array of options that are the same across all all forms which share a commone storage mechanisms
      • Default Value: array()

compareFormsByFields()

Compares two forms to see which is greater based on the field ordering set in $this->ordering @param $form1 @param $form2

  • Signature: protected function compareFormsByFields($form1,$form2)
  • Parameters:
    • $form1
    • $form2
  • Returns: int

delete()

Deletes a form from the entry tables.

  • Signature: public function delete($form,$transact,$complete,$deleted_records)
  • Parameters:
    • I2CE_Form $form
    • boolean $transact
      a flag to use transactions or not. default: true
    • boolean $complete
      a flag to determine if a complete delete should happen. default: false
    • boolean $deleted_records
      a flag to determine if the record should not go to the deleted_records table. default: false
  • Returns: boolean

getFormsById()

Generates a SQL to select the required fields. @param callback $field_refernece_callback. A callback function whose first arguement is the form, the second arguements is the field and which returns the way the field value should be references as a field. If the callback is null (the default) then the reference used is "$form+$field"

  • Signature: public function getFormsById($form,$parent,$where_data,$ordering,$limit)
  • Parameters:
    • string $form
      The form we are select from
    • boolean $parent
      Defaults to false. If true, we include the parent id as a referenced field. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id.
    • mixed $where_data
      array or class implementing ArrayAccess, Iterator, and Countable (e.g. MagicDataNode) . the where data.
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
  • Returns: array
    with keys id's and values the I2CE_Form instance.

getIdsAsChild()

Gets the id's for the given child for this form.

  • Signature: public function getIdsAsChild($form_name,$parent_form_id,$order_by,$where,$limit)
  • Parameters:
    • string $form_name
    • mixed $parent_form_id
      the prent form id @param array/string: an optional orderBy array of fields @param array where @param integer: A limit of the number of children ids to return
    • $order_by
    • $where
    • $limit
  • Returns: array

getLimitedFields()

  • Signature: protected function getLimitedFields($expr)
  • Parameters:
    • $expr

getRecords()

Return an array of all the record ids for a given form.

  • Signature: abstract public function getRecords($form)
  • Parameters:
  • Returns: array

isWritable()

Checks to see if this storage mechansim implements the writing methods. You need to override this in a subclass that implements writable

  • Signature: abstract public function isWritable()
  • Returns: boolean

listDisplayFields()

  • Signature: public function listDisplayFields($form,$fields,$parent,$where_data,$ordering,$limit,$mod_time)
  • Parameters:
    • string $form
      THe form name
    • array $fields
      of string. The fields we want returned
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id. If true, we return the parent as one of the fields.
      • Default Value: false
    • array $where_data
      contains the where clause information about this form or a nested
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
    • integer $mod_time
      Defaults to -1. If non-negative, we only list the requested fields for an id if at least one of them has a modification time greater than or equal to $mod_time. If the form storage has no way of tracking modifucation time, all entries are listed.
      • Default Value: -1
  • Returns: mixed
    an array with key id's and value and array of values. the array of values has as keys the fields with their corresponding value.

listFields()

  • Signature: public function listFields($form,$fields,$parent,$where_data,$ordering,$limit,$mod_time)
  • Parameters:
    • string $form
      THe form name
    • array $fields
      of string. The fields we want returned
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id. If true, we return the parent as one of the fields.
      • Default Value: false
    • array $where_data
      contains the where clause information about this form or a nested
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
    • integer $mod_time
      Defaults to -1. If non-negative, we only list the requested fields for an id if at least one of them has a modification time greater than or equal to $mod_time. If the form storage has no way of tracking modifucation time, all entries are listed.
      • Default Value: -1
  • Returns: mixed
    an array with key id's and value and array of values. the array of values has as keys the fields with their corresponding value.

lookupDisplayField()

Looks up the description of the item based on the code. This is the default method that most implementations of lookup () use. It finds the description of the object based on the code and saves it in the cache and returns it.

  • Signature: public function lookupDisplayField($form,$id,$fields,$delim)
  • Parameters:
    • string $form
      The name of the form in the database.
    • integer $id
      The code of the entry to lookup.
    • array $fields
      A list of fields to look up and return.
    • string $delim
      The delimiter to put between returned fields if there are more than one. If false, returns the values as an array.
  • Returns: string
    false on failure

lookupField()

Looks up the description of the item based on the code. This is the default method that most implementations of lookup () use. It finds the description of the object based on the code and saves it in the cache and returns it.

  • Signature: public function lookupField($form,$id,$fields,$delim)
  • Parameters:
    • string $form
      The name of the form in the database.
    • integer $id
      The code of the entry to lookup.
    • array $fields
      A list of fields to look up and return.
    • string $delim
      The delimiter to put between returned fields if there are more than one. If false, returns the values as an array.
  • Returns: string
    false on failure

populate()

Populate the member variables of the object from the database.

  • Signature: abstract public function populate($form)
  • Parameters:

populateHistory()

Populate the member variables of the object from the database.

  • Signature: public function populateHistory($form)
  • Parameters:

save()

Save a form object into entry tables. If this functio is over-written, it should include the fuzzy method call foreach ($form as $field) { $field->save(true/false, $user) }

search()

  • Signature: public function search($form,$parent,$where_data,$ordering,$limit)
  • Parameters:
    • string $form
      The form name.
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id.
      • Default Value: false
    • mixed $where_data
      array or class implementing ArrayAccess, Iterator, and Countable (e.g. MagicDataNode) . the where data.
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
  • Returns: mixed
    an array of matching form ids. However, ff $limit_one is true or 1 or array ($offset,1) then then we return either the id or false, if none found or there was an error.

Inherited Methods

_hasMethod()

This public method is inherited from I2CE_Fuzzy->_hasMethod()

Inherited Fuzzy Methods

userMessage()

This method is inherited from I2CE_Fuzzy->userMessage()