[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/settings/model/ -> _abstractsettings.class.php (sommaire)

This file implements the AbstractSettings class designed to handle any kind of settings. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

Author: blueyed: Daniel HAHLER
Author: fplanque: Francois PLANQUE
Copyright: (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
Version: $Id: _abstractsettings.class.php,v 1.1 2007/06/25 11:01:20 fplanque Exp $
Poids: 738 lignes (21 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

AbstractSettings:: (13 méthodes):
  AbstractSettings()
  load_all()
  _load()
  get()
  get_default()
  get_cond()
  set()
  set_array()
  delete()
  delete_array()
  restore_defaults()
  dbupdate()
  reset()


Classe: AbstractSettings  - X-Ref

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 {@link AbstractSettings::get()} and {@link 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)

AbstractSettings( $db_table_name, $col_key_names, $col_value_name, $cache_by_col_keys = 0 )   X-Ref
Constructor.

param: string The name of the DB table with the settings stored.
param: array List of names for the DB columns keys that reference a value.
param: string The name of the DB column that holds the value.
param: integer The number of column keys to cache by. This are the first x keys of {@link $col_key_names}. 0 means 'load all'.

load_all()   X-Ref
Load all settings, disregarding the derived classes setting of
{@link $cache_by_col_keys} - useful if you know that you want to get
all user settings for example.


_load( $arg1 = NULL, $arg2 = NULL, $arg3 = NULL )   X-Ref
Loads the settings. Not meant to be called directly, but gets called
when needed.

param: string First column key
param: string Second column key
param: string Third column key
return: boolean always true

get( $col_key1, $col_key2 = NULL, $col_key3 = NULL )   X-Ref
Get a setting from the DB settings table.

param: string First column key
param: string Second column key
param: string Third column key
return: string|false|NULL value as string on success; NULL if not found; false in case of error

get_default( $last_key )   X-Ref
Get the default for the last key of {@link $col_key_names}

param: string The last column key
return: NULL|mixed NULL if no default is set, otherwise the value (should be string).

get_cond( & $toset )   X-Ref
Only set the first variable (passed by reference) if we could retrieve a
setting.

param: mixed variable to set maybe (by reference)
param: string the values for the column keys (depends on $this->col_key_names
return: boolean true on success (variable was set), false if not

set()   X-Ref
Temporarily sets a setting ({@link dbupdate()} writes it to DB).

param: string $args,... the values for the {@link $col_key_names column keys}
return: boolean true, if the value has been set, false if it has not changed.

set_array( $array )   X-Ref
Set an array of values.

param: array Array of parameters for {@link set()}

delete( $args )   X-Ref
Remove a setting.

param: array List of {@link $col_key_names}
return: boolean

delete_array( $array )   X-Ref
Delete an array of values.

param: array Array of parameters for {@link delete()}

restore_defaults()   X-Ref
Delete values for {@link $_defaults default settings} in DB.

This will use the default settings on the next {@link get()}
again.

return: boolean true, if settings have been updated; false otherwise

dbupdate()   X-Ref
Commit changed settings to DB.

return: boolean true, if settings have been updated; false otherwise

reset()   X-Ref
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.



Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics