Dotclear 2.24
Loading...
Searching...
No Matches
dcNamespace Class Reference

Public Member Functions

 __construct ($blog_id, string $name, ?dcRecord $rs=null)
 
 settingExists (string $name, bool $global=false)
 
 get ($name)
 
 getGlobal ($name)
 
 getLocal ($name)
 
 __get ($name)
 
 set ($name, $value)
 
 __set ($name, $value)
 
 put (string $name, $value, ?string $type=null, ?string $label=null, bool $ignore_value=true, bool $global=false)
 
 rename (string $old_name, string $new_name)
 
 drop (string $name)
 
 dropEvery (string $name, bool $global=false)
 
 dropAll (bool $force_global=false)
 
 dumpNamespace ()
 
 dumpSettings ()
 
 dumpLocalSettings ()
 
 dumpGlobalSettings ()
 

Data Fields

const NS_TABLE_NAME = 'setting'
 
const NS_NAME_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9]+$/'
 

Protected Attributes

const NS_ID_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9_]+$/'
 
 $con
 
 $table
 
 $blog_id
 
 $global_settings = []
 
 $local_settings = []
 
 $settings = []
 
 $namespace
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $blog_id,
string  $name,
?dcRecord  $rs = null 
)

Object constructor. Retrieves blog settings and puts them in $settings array. Local (blog) settings have a highest priority than global settings.

Parameters
mixed$blog_idThe blog identifier
string$nameThe namespace ID
dcRecord$rsThe recordset
Exceptions
Exception

References $blog_id, dcCore\app(), and NS_TABLE_NAME.

Member Function Documentation

◆ settingExists()

settingExists ( string  $name,
bool  $global = false 
)

Returns true if a setting exist, else false

Parameters
string$nameThe identifier
bool$globalThe global
Returns
bool

Referenced by put().

◆ get()

get (   $name)

Returns setting value if exists.

Parameters
string$nameSetting name
Returns
mixed

◆ getGlobal()

getGlobal (   $name)

Returns global setting value if exists.

Parameters
string$nameSetting name
Returns
mixed

◆ getLocal()

getLocal (   $name)

Returns local setting value if exists.

Parameters
string$nameSetting name
Returns
mixed

◆ __get()

__get (   $name)

Magic __get method.

Parameters
string$nameSetting name
Returns
mixed

◆ set()

set (   $name,
  $value 
)

Sets a setting in $settings property. This sets the setting for script execution time only and if setting exists.

Parameters
string$nameThe setting name
mixed$valueThe setting value

◆ __set()

__set (   $name,
  $value 
)

Magic __set method.

Parameters
string$nameThe setting name
mixed$valueThe setting value

◆ put()

put ( string  $name,
  $value,
?string  $type = null,
?string  $label = null,
bool  $ignore_value = true,
bool  $global = false 
)

Creates or updates a setting.

$type could be 'string', 'integer', 'float', 'boolean', 'array' or null. If $type is null and setting exists, it will keep current setting type.

$ignore_value allow you to not change setting. Useful if you need to change a setting label or type and don't want to change its value.

Parameters
string$nameThe setting identifier
mixed$valueThe setting value
string$typeThe setting type
string$labelThe setting label
bool$ignore_valueChange setting value or not
bool$globalSetting is global
Exceptions
Exception

References $blog_id, $namespace, drop(), and settingExists().

◆ rename()

rename ( string  $old_name,
string  $new_name 
)

Rename an existing setting in a Namespace

Parameters
string$old_nameThe old setting identifier
string$new_nameThe new setting identifier
Exceptions
Exception
Returns
bool

◆ drop()

drop ( string  $name)

Removes an existing setting in a Namespace.

Parameters
string$nameThe setting identifier
Exceptions
Exception

Referenced by put().

◆ dropEvery()

dropEvery ( string  $name,
bool  $global = false 
)

Removes every existing specific setting in a namespace

Parameters
string$nameSetting ID
boolean$globalRemove global setting too
Exceptions
Exception

◆ dropAll()

dropAll ( bool  $force_global = false)

Removes all existing settings in a Namespace.

Parameters
bool$force_globalForce global pref drop
Exceptions
Exception

◆ dumpNamespace()

dumpNamespace ( )

Dumps a namespace.

Returns
string

References $namespace.

◆ dumpSettings()

dumpSettings ( )

Dumps settings.

Returns
array

References $settings.

◆ dumpLocalSettings()

dumpLocalSettings ( )

Dumps local settings.

Returns
array

References $local_settings.

◆ dumpGlobalSettings()

dumpGlobalSettings ( )

Dumps global settings.

Returns
array

References $global_settings.

Field Documentation

◆ NS_TABLE_NAME

const NS_TABLE_NAME = 'setting'

◆ NS_NAME_SCHEMA

const NS_NAME_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9]+$/'

Referenced by dcSettings\renNamespace().

◆ NS_ID_SCHEMA

const NS_ID_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9_]+$/'
protected

◆ $con

$con
protected

◆ $table

$table
protected

◆ $blog_id

$blog_id
protected

Referenced by __construct(), and put().

◆ $global_settings

$global_settings = []
protected

Referenced by dumpGlobalSettings().

◆ $local_settings

$local_settings = []
protected

Referenced by dumpLocalSettings().

◆ $settings

$settings = []
protected

Referenced by dumpSettings().

◆ $namespace

$namespace
protected

Referenced by dumpNamespace(), and put().


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