ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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

ilCloudPluginConfig::__construct (   $table_name)
Parameters
$table_name

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

References $table_name.

{
$this->table_name = $table_name;
}

Member Function Documentation

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

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

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

{
$index = substr($method,3);
if (substr($method, 0, 3) == 'get')
{
if (!isset($this->cache[$index]))
{
$this->cache[$index] = $this->getValue(self::_fromCamelCase(substr($method, 3)));
}
if ($this->cache[$index] == null)
{
$this->cache[$index] = false;
}
return $this->cache[$index];
} else if (substr($method, 0, 3) == 'set')
{
$this->cache[$index] = $params[0];
$this->setValue(self::_fromCamelCase(substr($method, 3)), $params[0]);
return true;
} else
{
}
}

+ Here is the call graph for this function:

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

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

{
$str[0] = strtolower($str[0]);
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
return preg_replace_callback('/([A-Z])/', $func, $str);
}
static ilCloudPluginConfig::_toCamelCase (   $str,
  $capitalise_first_char = false 
)
static
Parameters
string$str
bool$capitalise_first_char
Returns
string

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

{
if ($capitalise_first_char)
{
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/-([a-z])/', $func, $str);
}
ilCloudPluginConfig::getTableName ( )
Returns
string

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

References $table_name.

Referenced by initDB(), and tableExists().

{
}

+ Here is the caller graph for this function:

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

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

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

Referenced by __call(), and setValue().

{
global $ilDB;
if (!$this->tableExists($this->table_name))
{
}
$result = $ilDB->query("SELECT config_value FROM ". $this->table_name ." WHERE config_key = " . $ilDB->quote($key, "text"));
if ($result->numRows() == 0)
{
return false;
}
$record = $ilDB->fetchAssoc($result);
return (string)$record['config_value'];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCloudPluginConfig::initDB ( )
Returns
bool

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

References $ilDB, and getTableName().

{
global $ilDB;
if (!$ilDB->tableExists($this->getTableName()))
{
$fields = array(
'config_key' => array(
'type' => 'text',
'length' => 128,
'notnull' => true),
'config_value' => array(
'type' => 'clob',
'notnull' => false),);
$ilDB->createTable($this->getTableName(), $fields);
$ilDB->addPrimaryKey($this->getTableName(), array("config_key"));
}
return true;
}

+ Here is the call graph for this function:

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

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

References $table_name.

{
$this->table_name = $table_name;
}
ilCloudPluginConfig::setValue (   $key,
  $value 
)
Parameters
$key
$value

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

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

Referenced by __call().

{
global $ilDB;
if(!$ilDB->tableExists($this->table_name))
{
}
if (!is_string($this->getValue($key)))
{
$ilDB->insert($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)));
}
else
{
$ilDB->update($this->table_name, array("config_key" => array("text", $key), "config_value" => array("text", $value)), array("config_key" => array("text", $key)));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCloudPluginConfig::tableExists ( )

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

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

Referenced by getValue().

{
global $ilDB;
$result = $ilDB->query("show tables like '".$this->getTableName()."'");
if ($result->numRows() == 0)
{
return false;
}
else return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCloudPluginConfig::$cache = array()
protected

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

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: