All Data Structures Namespaces Files Functions Variables
Config Class Reference
Inheritance diagram for Config:

## Static Public Member Functions

static | setConfig ($lang, $key, $value)
static | getConfig ($lang=null, $key=null, $defaultValue=null)
Static Public Member Functions inherited from ModelBase
static | init ($config=null)
static | getDbPrefix ()
static | setup ()

## Protected Member Functions

| install ()
Protected Member Functions inherited from ModelBase
| install ()

## Static Private Attributes

static | $config = array()

## Additional Inherited Members

Public Member Functions inherited from ModelBase
| __construct ($id=null)
| getTableName ()
| getMeta ($lang=null)
| __get ($key)
| __set ($key, $value)
| save ()
| delete ()
| selects ($criteria=null, $orderBy=null)
| selectById ($id)
Static Protected Attributes inherited from ModelBase
static | $dbo = null

## Detailed Description

Definition at line 5 of file Config.php.

## Member Function Documentation

static getConfig | ( |  | $lang = `null`,
|  |  | $key = `null`,
|  |  | $defaultValue = `null`
| ) |  |

static

Definition at line 43 of file Config.php.

{
$fetcher = new self();
if (isset(self::$config[$lang]))
return;
$values = $fetcher->selects(array("lang" => $lang));
foreach ($values as $i)
self::$config[$lang][$i->key] = $i->value;
if ($key)
return (isset(self::$config[$lang][$key]) ? self::$config[$lang][$key] : $defaultValue);
return $defaultValue;
}

install | ( |  | ) |

protected

Definition at line 9 of file Config.php.

{
$dbPrefix = $this->getDbPrefix();
$result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}config` (
`lang` VARCHAR(8) NULL,
`key` VARCHAR(64) NOT NULL,
`value` TEXT NULL,
UNIQUE(`lang`, `key`)
)");
if ($result === false)
throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
return true;
}
Entity\ModelBase\getDbPrefix
static getDbPrefix()
Definition: ModelBase.php:42

static setConfig | ( |  | $lang,
|  |  | $key,
|  |  | $value
| ) |  |

static

Definition at line 23 of file Config.php.

{
$fetcher = new self();
$data = $fetcher->selects(array("lang" => $lang, "key" => $key));
if (empty($data))
{
$data = new self();
$data->lang = $lang;
$data->key = $key;
$data->value = $value;
$data->save();
}
else
{
$data = $data[0];
$data->value = $value;
$data->save();
}
}

## Field Documentation

$config = array()

staticprivate

Definition at line 7 of file Config.php.

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

- core/models/Config.php