Class configuration

Description

Configuration This is for accessing generic configuration files which store useful crappola like GST rate, file paths etc. This object features dynamically creatable/deletable configuration fields.

Eg. Usage (single-level configuration): $conf = new configuration("myconfigname"); $avar = $conf->value("gstrate"); Eg. Usage (dual-level config, user preferences example): $conf = new configuration("userprefs", "matthew"); $avar = $conf->value("background_colour"); // Example of changing it.. $conf->set_value("background_colour", "#fefefe"); $conf->put();

Located in /configuration-defs.php (line 46)

RenderableObject
   |
   --configuration
Direct descendents
Class Description
 class configurator The configurator class is simply a descendant class of configuration which sets the parent class into 'autoconfigure' mode. In this mode the forms have buttons supplied, and the instantiation of the class automatically processes form POSTs.
Variable Summary
Method Summary
 configuration configuration ([string $name = "default"], [string $id = "default"], [bool $auto = false])
 void delete ()
 integer field_count ()
 void field_create (string $fname, [string $ftype = "text"], [string $flist = ""], [string $default = "???"])
 bool field_exists (string $fname)
 void field_remove (string $fname)
 void get (string $name, string $id)
 string html ()
 void put ()
 void set_value (mixed $fname, [mixed $fvalue = ""], string $name, string $value)
 mixed value (mixed $fname, string $name)
Variables
mixed $autoconfigurate = false (line 75)

Whether to show buttons on forms and auto-process POST or not

mixed $config_id = "default" (line 51)

Identity if the current configuration

mixed $config_name = "default" (line 49)

The name of the current configuration

mixed $db_configuration_exists = false (line 66)

Whether the configuration exists in database or not

mixed $db_config_exists = false (line 63)

Whether config definition exists in database or not

mixed $fields (line 53)

Array of configfield objects for the config

mixed $fieldschanged = false (line 69)

Whether field definitions have changed or not

mixed $form_mode = "edit" (line 60)

Mode to display the configuration in a form

mixed $set (line 55)

Set of configuration fields/values in this configuration set

mixed $setchanged = false (line 72)

Whether configuration data has changed or not

Methods
Constructor configuration (line 84)

Constructor Create a new configuration object. Sets basic field attributes.

configuration configuration ([string $name = "default"], [string $id = "default"], [bool $auto = false])
  • string $name: The name of the config.
  • string $id: The identity of the configuration set in the config
  • bool $auto: If true, put the configuration object into autoconfigure mode
delete (line 184)

Delete the whole config.

Delete this config from the database.

void delete ()
field_count (line 195)

Return fields present count.

  • return: Count of fields current defined in this config
integer field_count ()
field_create (line 260)

Create a new field for all configurations This retro-fits all sets of this config with the new field, and will assign the default value to each one.

void field_create (string $fname, [string $ftype = "text"], [string $flist = ""], [string $default = "???"])
  • string $fname: Name of the new field
  • string $ftype: Var type: 'text','numeric','bool', or 'datetime'
  • string $flist: List of allowed values, if any
  • string $default: Default value, if any
field_exists (line 208)

Check if field exists

  • return: True if named field exists in this configuration
bool field_exists (string $fname)
  • string $fname: The name of the field to check.
field_remove (line 292)

Remove a field from all sets of this config.

void field_remove (string $fname)
  • string $fname: Name of the field to remove from all configurations
get (line 100)

Get the configuration set.

Retreives the specified configuration set from database.

void get (string $name, string $id)
  • string $name: The name of the config.
  • string $id: The identity of the configuration set in the config
html (line 529)

Render this configuration.

depending on which form_mode we are in, we render the configuration as an edit form, an add form, or a delete form.

  • return: The HTML of the subform for this configuration action
string html ()

Redefinition of:
RenderableObject::html()
Return output suitable for normal HTML-capable device. This method must be over-ridden by a method of the same name in the descendant class which renders output to web browsers.
put (line 141)

Save the config.

Save this config to the database. Create a new one if it doesn't already exist.

void put ()
set_value (line 322)

Put a value in a field, in a set of the config.

void set_value (mixed $fname, [mixed $fvalue = ""], string $name, string $value)
  • string $name: Name of the field
  • string $value: Value to assign to the variable
value (line 364)

Get value from a field in a set of the config.

  • return: The value of the given field in the given set
mixed value (mixed $fname, string $name)
  • string $name: Name of the field to get value of

Inherited Methods

Inherited From RenderableObject

 RenderableObject::RenderableObject()
 RenderableObject::html()
 RenderableObject::render()
 RenderableObject::wml()
 RenderableObject::wmlup()
 RenderableObject::xml()

Documentation generated by phpDocumentor 1.3.0RC3