ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCloudPluginConfig Class Reference

Class ilCloudPluginConfig. More...

+ Collaboration diagram for ilCloudPluginConfig:

Public Member Functions

 __construct ($table_name)
 
 setTableName ($table_name)
 
 getTableName ()
 
 __call ($method, $params)
 
 setValue ($key, $value)
 
 getValue ($key)
 
 initDB ()
 
 tableExists ()
 

Static Public Member Functions

static _fromCamelCase ($str)
 
static _toCamelCase ($str, $capitalise_first_char=false)
 

Protected Attributes

 $table_name = ""
 
 $cache = array()
 

Detailed Description

Class ilCloudPluginConfig.

Model class for the administration settings. Note the use of the __call Function. The value max_file_size could be for example set by the method setMaxFileSize without the declaring this method. Similarly it could be get by getMaxFileSize

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
$Id$

Definition at line 17 of file class.ilCloudPluginConfig.php.

Constructor & Destructor Documentation

◆ __construct()

ilCloudPluginConfig::__construct (   $table_name)
Parameters
$table_name

Definition at line 32 of file class.ilCloudPluginConfig.php.

33 {
34 $this->table_name = $table_name;
35 }

References $table_name.

Member Function Documentation

◆ __call()

ilCloudPluginConfig::__call (   $method,
  $params 
)
Parameters
$method
$params
Returns
bool|null

Definition at line 58 of file class.ilCloudPluginConfig.php.

59 {
60 $index = substr($method, 3);
61 if (substr($method, 0, 3) == 'get') {
62 if (!isset($this->cache[$index])) {
63 $this->cache[$index] = $this->getValue(self::_fromCamelCase(substr($method, 3)));
64 }
65 if ($this->cache[$index] == null) {
66 $this->cache[$index] = false;
67 }
68
69 return $this->cache[$index];
70 } elseif (substr($method, 0, 3) == 'set') {
71 $this->cache[$index] = $params[0];
72 $this->setValue(self::_fromCamelCase(substr($method, 3)), $params[0]);
73 return true;
74 } else {
76 }
77 }
Class ilCloudPluginConfigException.
$index
Definition: metadata.php:60

References $index, PHPMailer\PHPMailer\$params, getValue(), ilCloudPluginConfigException\NO_VALID_GET_OR_SET_FUNCTION, and setValue().

+ Here is the call graph for this function:

◆ _fromCamelCase()

static ilCloudPluginConfig::_fromCamelCase (   $str)
static
Parameters
string$str
Returns
string

Definition at line 158 of file class.ilCloudPluginConfig.php.

159 {
160 $str[0] = strtolower($str[0]);
161 return preg_replace_callback('/([A-Z])/', function ($c) {
162 return "_" . strtolower($c[1]);
163 }, $str);
164 }

References $c.

◆ _toCamelCase()

static ilCloudPluginConfig::_toCamelCase (   $str,
  $capitalise_first_char = false 
)
static
Parameters
string$str
bool$capitalise_first_char
Returns
string

Definition at line 171 of file class.ilCloudPluginConfig.php.

172 {
173 if ($capitalise_first_char) {
174 $str[0] = strtoupper($str[0]);
175 }
176 return preg_replace_callback('/-([a-z])/', function ($c) {
177 return strtoupper($c[1]);
178 }, $str);
179 }

References $c.

◆ getTableName()

ilCloudPluginConfig::getTableName ( )
Returns
string

Definition at line 48 of file class.ilCloudPluginConfig.php.

49 {
50 return $this->table_name;
51 }

References $table_name.

Referenced by initDB(), and tableExists().

+ Here is the caller graph for this function:

◆ getValue()

ilCloudPluginConfig::getValue (   $key)
Parameters
$key
Returns
bool|string

Definition at line 103 of file class.ilCloudPluginConfig.php.

104 {
105 global $DIC;
106 $ilDB = $DIC['ilDB'];
107
108
109 if (!$this->tableExists($this->table_name)) {
111 }
112
113 $result = $ilDB->query("SELECT config_value FROM " . $this->table_name . " WHERE config_key = " . $ilDB->quote($key, "text"));
114
115 if ($result->numRows() == 0) {
116 return false;
117 }
118 $record = $ilDB->fetchAssoc($result);
119 return (string) $record['config_value'];
120 }
$result
$key
Definition: croninfo.php:18
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, $ilDB, $key, $result, ilCloudPluginConfigException\TABLE_DOES_NOT_EXIST, and tableExists().

Referenced by __call(), and setValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDB()

ilCloudPluginConfig::initDB ( )
Returns
bool

Definition at line 127 of file class.ilCloudPluginConfig.php.

128 {
129 global $DIC;
130 $ilDB = $DIC['ilDB'];
131
132 if (!$ilDB->tableExists($this->getTableName())) {
133 $fields = array(
134 'config_key' => array(
135 'type' => 'text',
136 'length' => 128,
137 'notnull' => true),
138 'config_value' => array(
139 'type' => 'clob',
140 'notnull' => false),);
141 $ilDB->createTable($this->getTableName(), $fields);
142 $ilDB->addPrimaryKey($this->getTableName(), array("config_key"));
143 }
144
145 return true;
146 }

References $DIC, $ilDB, and getTableName().

+ Here is the call graph for this function:

◆ setTableName()

ilCloudPluginConfig::setTableName (   $table_name)
Parameters
string$table_name

Definition at line 40 of file class.ilCloudPluginConfig.php.

41 {
42 $this->table_name = $table_name;
43 }

References $table_name.

◆ setValue()

ilCloudPluginConfig::setValue (   $key,
  $value 
)
Parameters
$key
$value

Definition at line 83 of file class.ilCloudPluginConfig.php.

84 {
85 global $DIC;
86 $ilDB = $DIC['ilDB'];
87
88 if (!$ilDB->tableExists($this->table_name)) {
90 }
91
92 if (!is_string($this->getValue($key))) {
93 $ilDB->insert($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)));
94 } else {
95 $ilDB->update($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)), array("config_key" => array("text", $key)));
96 }
97 }

References $DIC, $ilDB, $key, getValue(), and ilCloudPluginConfigException\TABLE_DOES_NOT_EXIST.

Referenced by __call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tableExists()

ilCloudPluginConfig::tableExists ( )

Definition at line 181 of file class.ilCloudPluginConfig.php.

182 {
183 global $DIC;
184 $ilDB = $DIC['ilDB'];
185 $result = $ilDB->query("show tables like '" . $this->getTableName() . "'");
186
187 if ($result->numRows() == 0) {
188 return false;
189 } else {
190 return true;
191 }
192 }

References $DIC, $ilDB, $result, and getTableName().

Referenced by getValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

ilCloudPluginConfig::$cache = array()
protected

Definition at line 27 of file class.ilCloudPluginConfig.php.

◆ $table_name

ilCloudPluginConfig::$table_name = ""
protected

Definition at line 22 of file class.ilCloudPluginConfig.php.

Referenced by __construct(), getTableName(), and setTableName().


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