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

Public Member Functions

 __construct (string $user_id, string $name, ?dcRecord $rs=null)
 
 prefExists (string $name, bool $global=false)
 
 get (string $name)
 
 getGlobal (string $name)
 
 getLocal (string $name)
 
 __get (string $name)
 
 set (string $name, $value)
 
 __set (string $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, bool $force_global=false)
 
 dropEvery (string $name, bool $global=false)
 
 dropAll (bool $force_global=false)
 
 dumpWorkspace ()
 
 dumpPrefs ()
 
 dumpLocalPrefs ()
 
 dumpGlobalPrefs ()
 

Data Fields

const WS_TABLE_NAME = 'pref'
 
const WS_NAME_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9]+$/'
 

Protected Attributes

const WS_ID_SCHEMA = '/^[a-zA-Z][a-zA-Z0-9_]+$/'
 
 $con
 
 $table
 
 $user_id
 
 $global_prefs = []
 
 $local_prefs = []
 
 $prefs = []
 
 $workspace
 

Constructor & Destructor Documentation

◆ __construct()

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

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

Parameters
string$user_idThe user identifier
string$nameThe workspace name
dcRecord$rsThe recordset
Exceptions
Exception

References $user_id, dcCore\app(), and WS_TABLE_NAME.

Member Function Documentation

◆ prefExists()

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

Returns true if a pref exist, else false

Parameters
string$nameThe identifier
bool$globalThe global
Returns
bool

Referenced by drop(), dropEvery(), and put().

◆ get()

get ( string  $name)

Returns pref value if exists.

Parameters
string$namePref name
Returns
mixed

◆ getGlobal()

getGlobal ( string  $name)

Returns global pref value if exists.

Parameters
string$namePref name
Returns
mixed

◆ getLocal()

getLocal ( string  $name)

Returns local pref value if exists.

Parameters
string$namePref name
Returns
mixed

◆ __get()

__get ( string  $name)

Magic __get method.

Parameters
string$namePref name
Returns
mixed

◆ set()

set ( string  $name,
  $value 
)

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

Parameters
string$nameThe pref name
mixed$valueThe pref value

◆ __set()

__set ( string  $name,
  $value 
)

Magic __set method.

Parameters
string$nameThe pref name
mixed$valueThe pref value

◆ put()

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

Creates or updates a pref.

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

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

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

References $user_id, $workspace, drop(), and prefExists().

◆ rename()

rename ( string  $old_name,
string  $new_name 
)

Rename an existing pref in a Workspace

Parameters
string$old_nameThe old identifier
string$new_nameThe new identifier
Exceptions
Exception
Returns
bool false is error, true if renamed

◆ drop()

drop ( string  $name,
bool  $force_global = false 
)

Removes an existing pref. Workspace

Parameters
string$nameThe pref identifier
bool$force_globalForce global pref drop
Exceptions
Exception

References prefExists().

Referenced by put().

◆ dropEvery()

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

Removes every existing specific pref. in a workspace

Parameters
string$namePref ID
bool$globalRemove global pref too

References prefExists().

◆ dropAll()

dropAll ( bool  $force_global = false)

Removes all existing pref. in a Workspace

Parameters
bool$force_globalRemove global prefs too
Exceptions
Exception

◆ dumpWorkspace()

dumpWorkspace ( )

Dumps a workspace.

Returns
string

References $workspace.

◆ dumpPrefs()

dumpPrefs ( )

Dumps preferences.

Returns
array

References $prefs.

◆ dumpLocalPrefs()

dumpLocalPrefs ( )

Dumps local preferences.

Returns
array

References $local_prefs.

◆ dumpGlobalPrefs()

dumpGlobalPrefs ( )

Dumps global preferences.

Returns
array

References $global_prefs.

Field Documentation

◆ WS_TABLE_NAME

const WS_TABLE_NAME = 'pref'

◆ WS_NAME_SCHEMA

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

Referenced by dcPrefs\renWorkspace().

◆ WS_ID_SCHEMA

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

◆ $con

$con
protected

◆ $table

$table
protected

◆ $user_id

$user_id
protected

Referenced by __construct(), and put().

◆ $global_prefs

$global_prefs = []
protected

Referenced by dumpGlobalPrefs().

◆ $local_prefs

$local_prefs = []
protected

Referenced by dumpLocalPrefs().

◆ $prefs

$prefs = []
protected

Referenced by dumpPrefs().

◆ $workspace

$workspace
protected

Referenced by dumpWorkspace(), and put().


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