Factorise code variables
This commit is contained in:
parent
69d8e4f408
commit
a2503e395d
|
@ -35,16 +35,8 @@ class m_piwik {
|
|||
/** Constructor
|
||||
*/
|
||||
function m_piwik() {
|
||||
$this->piwik_server_uri=variable_get('piwik_server_uri',null);
|
||||
if (is_null($this->piwik_server_uri)) { // if not configuration var, setup one (with a default value)
|
||||
variable_set('piwik_server_uri','','Remote Piwik server uri');
|
||||
$this->piwik_server_uri='';
|
||||
}
|
||||
$this->piwik_admin_token=variable_get('piwik_admin_token',null);
|
||||
if (is_null($this->piwik_admin_token)) { // if not configuration var, setup one (with a default value)
|
||||
variable_set('piwik_admin_token','','Remote Piwik super-admin token');
|
||||
$this->piwik_admin_token='';
|
||||
}
|
||||
$this->piwik_server_uri=variable_get('piwik_server_uri',null,'Remote Piwik server uri');
|
||||
$this->piwik_admin_token=variable_get('piwik_admin_token',null,'Remote Piwik super-admin token');
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
|
|
@ -78,16 +78,25 @@ function variable_init_maybe() {
|
|||
* The name of the variable to return.
|
||||
* @param $default
|
||||
* The default value to use if this variable has never been set.
|
||||
* @param $createit_comment
|
||||
* If variable doesn't exist, create it with the default value
|
||||
* and createit_comment value as comment
|
||||
* @return
|
||||
* The value of the variable.
|
||||
* @global $conf
|
||||
* A cache of the configuration.
|
||||
*/
|
||||
function variable_get($name, $default = null) {
|
||||
function variable_get($name, $default = null, $createit_comment = null) {
|
||||
global $conf;
|
||||
|
||||
variable_init_maybe();
|
||||
return isset($conf[$name]) ? $conf[$name] : $default;
|
||||
|
||||
if (isset($conf[$name])) {
|
||||
return $conf[$name];
|
||||
} elseif (!is_null($createit_comment)) {
|
||||
variable_set($name, $default, $createit_comment);
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +125,7 @@ function variable_set($name, $value, $comment=null) {
|
|||
|
||||
$db->query("$query");
|
||||
|
||||
variable_init_maybe();
|
||||
variable_init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue