ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 33 of file class.ilCloudPluginConfig.php.

References $table_name.

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

Member Function Documentation

◆ __call()

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

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

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

64  {
65  $index = substr($method, 3);
66  if (substr($method, 0, 3) == 'get') {
67  if (!isset($this->cache[$index])) {
68  $this->cache[$index] = $this->getValue(self::_fromCamelCase(substr($method, 3)));
69  }
70  if ($this->cache[$index] == null) {
71  $this->cache[$index] = false;
72  }
73 
74  return $this->cache[$index];
75  } else {
76  if (substr($method, 0, 3) == 'set') {
77  $this->cache[$index] = $params[0];
78  $this->setValue(self::_fromCamelCase(substr($method, 3)), $params[0]);
79 
80  return true;
81  } else {
83  }
84  }
85  }
$index
Definition: metadata.php:128
Class ilCloudPluginConfigException.
+ Here is the call graph for this function:

◆ _fromCamelCase()

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

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

References Vendor\Package\$c.

172  {
173  $str[0] = strtolower($str[0]);
174 
175  return preg_replace_callback('/([A-Z])/', function ($c) {
176  return "_" . strtolower($c[1]);
177  }, $str);
178  }

◆ _toCamelCase()

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

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

References Vendor\Package\$c.

188  {
189  if ($capitalise_first_char) {
190  $str[0] = strtoupper($str[0]);
191  }
192 
193  return preg_replace_callback('/-([a-z])/', function ($c) {
194  return strtoupper($c[1]);
195  }, $str);
196  }

◆ getTableName()

ilCloudPluginConfig::getTableName ( )
Returns
string

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

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 114 of file class.ilCloudPluginConfig.php.

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

Referenced by __call(), and setValue().

115  {
116  global $DIC;
117  $ilDB = $DIC['ilDB'];
118 
119  if (!$this->tableExists($this->table_name)) {
121  }
122 
123  $result = $ilDB->query("SELECT config_value FROM " . $this->table_name . " WHERE config_key = " . $ilDB->quote($key, "text"));
124 
125  if ($result->numRows() == 0) {
126  return false;
127  }
128  $record = $ilDB->fetchAssoc($result);
129 
130  return (string) $record['config_value'];
131  }
$result
Class ilCloudPluginConfigException.
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDB()

ilCloudPluginConfig::initDB ( )
Returns
bool

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

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

138  {
139  global $DIC;
140  $ilDB = $DIC['ilDB'];
141 
142  if (!$ilDB->tableExists($this->getTableName())) {
143  $fields = array(
144  'config_key' => array(
145  'type' => 'text',
146  'length' => 128,
147  'notnull' => true,
148  ),
149  'config_value' => array(
150  'type' => 'clob',
151  'notnull' => false,
152  ),
153  );
154  $ilDB->createTable($this->getTableName(), $fields);
155  $ilDB->addPrimaryKey($this->getTableName(), array("config_key"));
156  }
157 
158  return true;
159  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ setTableName()

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

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

References $table_name.

43  {
44  $this->table_name = $table_name;
45  }

◆ setValue()

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

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

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

Referenced by __call().

93  {
94  global $DIC;
95  $ilDB = $DIC['ilDB'];
96 
97  if (!$ilDB->tableExists($this->table_name)) {
99  }
100 
101  if (!is_string($this->getValue($key))) {
102  $ilDB->insert($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)));
103  } else {
104  $ilDB->update($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)), array("config_key" => array("text", $key)));
105  }
106  }
Class ilCloudPluginConfigException.
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tableExists()

ilCloudPluginConfig::tableExists ( )

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

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

Referenced by getValue().

200  {
201  global $DIC;
202  $ilDB = $DIC['ilDB'];
203  $result = $ilDB->query("show tables like '" . $this->getTableName() . "'");
204 
205  if ($result->numRows() == 0) {
206  return false;
207  } else {
208  return true;
209  }
210  }
$result
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 23 of file class.ilCloudPluginConfig.php.

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


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