Class: AbstractSettings
Source Location: /blogs/inc/settings/model/_abstractsettings.class.php
Class AbstractSettings
|
Class to handle settings in an abstract manner (to get used with either 1, 2 or 3 DB column keys). Arrays and Objects automatically get serialized and unserialized (in AbstractSettings::get() and AbstractSettings::dbupdate()). Note: I've evaluated splitting this into single classes for performance reasons, but only get() is relevant performance-wise and we could now only get rid of the switch() therein, which is not sufficient to split it into *_base + _X classes. (blueyed, 2006-08) Located in /blogs/inc/settings/model/_abstractsettings.class.php [line 50] Author(s):
|
| Child Class | Description |
|---|---|
| UserSettings | Class to handle the settings for users |
| PluginSettings | Class to handle settings for plugins |
| PluginUserSettings | Class to handle settings for plugins |
| GeneralSettings | Class to handle the global settings. |
| CollectionSettings | Class to handle the settings for collections/blogs |
| boolean | $all_loaded | Do we have loaded everything? |
| array | $cache | The internal cache. |
| integer | $cache_by_col_keys | The number of column keys to cache by. This are the first x keys of $col_key_names. 0 means 'load all'. |
| array | $col_key_names | Array with DB column key names. |
| string | $col_value_name | DB column name for the value. |
| string | $db_table_name | The DB table which stores the settings. |
| array | $_defaults | Default settings. |
| AbstractSettings | AbstractSettings() | Constructor. |
| boolean | dbupdate() | Commit changed settings to DB. |
| boolean | delete() | Remove a setting. |
| void | delete_array() | Delete an array of values. |
| string|false|NULL | get() | Get a setting from the DB settings table. |
| boolean | get_cond() | Only set the first variable (passed by reference) if we could retrieve a setting. |
| NULL|mixed | get_default() | Get the default for the last key of $col_key_names |
| void | load_all() | Load all settings, disregarding the derived classes setting of $cache_by_col_keys
|
| void | reset() | Reset cache (includes settings to be written to DB). |
| boolean | restore_defaults() | Delete values for $_defaults in DB. |
| boolean | set() | Temporarily sets a setting (dbupdate() writes it to DB). |
| void | set_array() | Set an array of values. |
| boolean | _load() | Loads the settings. Not meant to be called directly, but gets called when needed. |
The internal cache.
false, if settings could not be loaded or NULL if not initialized.
API Tags:| Access: | protected |
The number of column keys to cache by. This are the first x keys of $col_key_names. 0 means 'load all'.
Array with DB column key names.
API Tags:| Access: | protected |
The DB table which stores the settings.
API Tags:| Access: | protected |
Default settings.
Maps last colkeyname to some default setting that will be used by get() if no value was defined (and it is set as a default).
- UserSettings::$_defaults : The default settings to use, when a setting is not given in the database.
- GeneralSettings::$_defaults : The default settings to use, when a setting is not given in the database.
- CollectionSettings::$_defaults : The default settings to use, when a setting is not defined in the database.
|
Constructor.
Parameters:| string | $db_table_name: | The name of the DB table with the settings stored. |
| array | $col_key_names: | List of names for the DB columns keys that reference a value. |
| string | $col_value_name: | The name of the DB column that holds the value. |
| integer | $cache_by_col_keys: | The number of column keys to cache by. This are the first x keys of $col_key_names. 0 means 'load all'. |
|
Commit changed settings to DB.
API Tags:
| Return: | true, if settings have been updated; false otherwise |
|
Remove a setting.
Parameters:| array | $args: | List of $col_key_names |
- UserSettings::delete() : Mark a setting for deletion (dbupdate() writes it to DB).
- PluginSettings::delete() : Delete a setting.
- PluginUserSettings::delete() : Delete a setting.
|
Delete an array of values.
Parameters:| array | $array: | Array of parameters for delete() |
|
Get a setting from the DB settings table.
Parameters:| string | $col_key1: | First column key |
| string | $col_key2: | Second column key |
| string | $col_key3: | Third column key |
API Tags:
| Return: | value as string on success; NULL if not found; false in case of error |
| Uses: | AbstractSettings::get_default() |
- UserSettings::get() : Get a setting from the DB user settings table
- PluginSettings::get() : Get a setting by name for the Plugin.
- PluginUserSettings::get() : Get a setting by name for the Plugin.
|
Only set the first variable (passed by reference) if we could retrieve a setting.
Parameters:| string | 1: | the values for the column keys (depends on $this->col_key_names and must match its count and order) |
| mixed | &$toset: | variable to set maybe (by reference) |
API Tags:
| Return: | true on success (variable was set), false if not |
|
Get the default for the last key of $col_key_names
Parameters:| string | $last_key: | The last column key |
API Tags:
| Return: | NULL if no default is set, otherwise the value (should be string). |
| Usedby: | AbstractSettings::get() |
|
Load all settings, disregarding the derived classes setting of $cache_by_col_keys
all user settings for example.
|
Reset cache (includes settings to be written to DB).
This is useful, to rollback settings that have been made, e.g. when a Plugin decides that his settings should not get updated.
|
Delete values for $_defaults in DB.
This will use the default settings on the next get() again.
API Tags:
| Return: | true, if settings have been updated; false otherwise |
|
Temporarily sets a setting (dbupdate() writes it to DB).
Parameters:| string | $args,...: | the values for the column keys and column value. Must match order and count! |
API Tags:
| Return: | true, if the value has been set, false if it has not changed. |
- UserSettings::set() : Temporarily sets a user setting (dbupdate() writes it to DB)
- PluginSettings::set() : Set a Plugin setting. Use dbupdate() to write it to the database.
- PluginUserSettings::set() : Set a Plugin setting. Use dbupdate() to write it to the database.
|
Set an array of values.
Parameters:| array | $array: | Array of parameters for set() |
|
Loads the settings. Not meant to be called directly, but gets called when needed.
Parameters:| string | $arg1: | First column key |
| string | $arg2: | Second column key |
| string | $arg3: | Third column key |
API Tags:
| Return: | always true |
| Access: | protected |
- CollectionSettings::_load() : Loads the settings. Not meant to be called directly, but gets called when needed.
