ecom
E-commerce cms
 All Data Structures Namespaces Files Functions Variables
Static Public Member Functions | Protected Member Functions | Static Private Attributes
Config Class Reference
Inheritance diagram for Config:
ModelBase

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 44 of file Config.php.

45  {
46  $fetcher = new self();
47  $_lang = $lang;
48  if ($lang === null)
49  $_lang = "nolang";
50  if (isset(self::$config[$_lang]))
51  return isset(self::$config[$_lang][$key]) ? self::$config[$_lang][$key] : $defaultValue;
52  $values = $fetcher->selects(array("lang" => $lang));
53  foreach ($values as $i)
54  self::$config[$_lang][$i->key] = $i->value;
55  if ($key)
56  return (isset(self::$config[$_lang][$key]) ? self::$config[$_lang][$key] : $defaultValue);
57  return $defaultValue;
58  }
install ( )
protected

Definition at line 9 of file Config.php.

10  {
11  $dbPrefix = $this->getDbPrefix();
12  $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}config` (
13  `lang` VARCHAR(8) NULL,
14  `key` VARCHAR(64) NOT NULL,
15  `value` TEXT NULL,
16  UNIQUE(`lang`, `key`)
17  )");
18  if ($result === false)
19  throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
20  self::setConfig(null, "theme", "default");
21  return true;
22  }
static getDbPrefix()
Definition: ModelBase.php:42
static setConfig (   $lang,
  $key,
  $value 
)
static

Definition at line 24 of file Config.php.

25  {
26  $fetcher = new self();
27  $data = $fetcher->selects(array("lang" => $lang, "key" => $key));
28  if (empty($data))
29  {
30  $data = new self();
31  $data->lang = $lang;
32  $data->key = $key;
33  $data->value = $value;
34  $data->save();
35  }
36  else
37  {
38  $data = $data[0];
39  $data->value = $value;
40  $data->save();
41  }
42  }

Field Documentation

$config = array()
staticprivate

Definition at line 7 of file Config.php.


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