Documentation

GRIS_SETTINGS
in package

Class for managing setting as key an value

With this class all settings for GRIS can be managed. Every setting ist written to a database after a change in the array. Also seetings can be grouped and controlled vocabulary can be accessed.

PHP version 7

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany

Tags
copyright

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences

link

GESIS Leibniz Institute for the Social Sciences

since
1

File available since Release 1.0

version
1.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = 'gris_settings'
The constant for the database table where the settings are stored
$dbconnection  : object
The database object for managing the connection
$instance  : object
The instance counter
$settings  : array<string|int, mixed>
The settings array
__construct()  : mixed
The class constructor
get_all()  : string
Returns all settings (this is only a prototype without editing) [THIS SHOULD BE USED FOR DEBUG ONLY!]
get_setting()  : string
Returns a value for a given key
get_settings()  : array<string|int, mixed>
Returns all settings
get_vocabulary()  : array<string|int, mixed>
Returns an array with the controlled vocabulary of the given group
get_vocabulary_by_value()  : array<string|int, mixed>
Returns a vocabulary by a given group and value
get_vocabulary_entry()  : array<string|int, mixed>
Returns a vocabulary by a given id
get_vocabulary_ids()  : array<string|int, mixed>
Returns an array with the vocabulary with ids
getInstance()  : mixed
The instance creator
set_setting()  : bool
Sets a value for a given key
set_vocabulary()  : bool
Sets a vocabulary entry
__clone()  : mixed
The instance creator
check_usage()  : bool
Checks if an ID is in the usage list of the vocabulary
read_settings()  : bool
Reads all settings of a group from the database
write_to_db()  : bool
Writes key/value couples to the database

Constants

dbtable

The constant for the database table where the settings are stored

public mixed dbtable = 'gris_settings'

Properties

$dbconnection

The database object for managing the connection

private object $dbconnection = NULL
Tags
access

private

$instance

The instance counter

private static object $instance = NULL
Tags
access

private

$settings

The settings array

private array<string|int, mixed> $settings = NULL
Tags
access

private

Methods

__construct()

The class constructor

public __construct() : mixed

Initializes the objects

Return values
mixed

get_all()

Returns all settings (this is only a prototype without editing) [THIS SHOULD BE USED FOR DEBUG ONLY!]

public get_all([string $type = NULL ]) : string
Parameters
$type : string = NULL

The output type (As a direct output via echo when set to "html" or as a string if not set.

Return values
string

The table with all settings

get_setting()

Returns a value for a given key

public get_setting(string $group, string $key) : string
Parameters
$group : string

The settings group

$key : string

The key

Return values
string

The value of the key in this group

get_settings()

Returns all settings

public get_settings([bool $group = false ][, bool $hidden = false ]) : array<string|int, mixed>
Parameters
$group : bool = false

Group the settings (array(group => array(settings_of_group)))

$hidden : bool = false

Filter hidden settings if true

Return values
array<string|int, mixed>

The array with all settings

get_vocabulary()

Returns an array with the controlled vocabulary of the given group

public get_vocabulary(string $group[, string $id = NULL ][, bool $value = false ][, bool $whole = false ][, bool $sorted_by_value = false ]) : array<string|int, mixed>
Parameters
$group : string

The settings group

$id : string = NULL

The ID to check

$value : bool = false

Return the value as key (default is false)

$whole : bool = false

Return the whole vocabulary item (default is false)

$sorted_by_value : bool = false

Sort vocabulary by value (instead of text)

Return values
array<string|int, mixed>

The controlled vocabulary (just for this ID or if ID = NULL the whole group)

get_vocabulary_by_value()

Returns a vocabulary by a given group and value

public get_vocabulary_by_value(string $group, int $value) : array<string|int, mixed>
Parameters
$group : string

The vocabulary group

$value : int

The vocabulary ID

Return values
array<string|int, mixed>

the entry

get_vocabulary_entry()

Returns a vocabulary by a given id

public get_vocabulary_entry(string $id) : array<string|int, mixed>
Parameters
$id : string

The vocabulary ID

Return values
array<string|int, mixed>

the entry

get_vocabulary_ids()

Returns an array with the vocabulary with ids

public get_vocabulary_ids([string $group = NULL ]) : array<string|int, mixed>
Parameters
$group : string = NULL

The settings group

Return values
array<string|int, mixed>

The controlled vocabulary (just for this ID or if ID = NULL the whole group)

getInstance()

The instance creator

public static getInstance() : mixed

Returns an instance of the object

Return values
mixed

set_setting()

Sets a value for a given key

public set_setting(string $group, string $key, string $value[, bool $new = false ]) : bool
Parameters
$group : string

The settings group

$key : string

The key

$value : string

The value

$new : bool = false

Set only if setting is new

Return values
bool

true

set_vocabulary()

Sets a vocabulary entry

public set_vocabulary(string $id, string $group, string $text, string $value, string $usage) : bool
Parameters
$id : string

The vocabulary ID

$group : string

The vocabulary group

$text : string

The vocabulary text

$value : string

The vocabulary value

$usage : string

The vocabulary usage

Return values
bool

Returns true on success and false on error

__clone()

The instance creator

private __clone() : mixed

Prohibits external cloning of the object

Return values
mixed

check_usage()

Checks if an ID is in the usage list of the vocabulary

private check_usage(string $id, string $usage) : bool
Parameters
$id : string

The ID to check

$usage : string

The usage list for this text

Syntax for usage list: allow|deny (IDs komma separated, * is wildcard) Exmaples: |1,2 (allow all except 1 and 2) 1,2| (deny all except 1 and 2)

Return values
bool

Returns true if ID is in list

read_settings()

Reads all settings of a group from the database

private read_settings() : bool
Return values
bool

true

write_to_db()

Writes key/value couples to the database

private write_to_db(string $group, string $key) : bool
Parameters
$group : string

The settings group

$key : string

The key to be written to the database

Return values
bool

true

Search results