------------------------------------------------------------
revno: 1182
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Wed 2012-04-25 22:06:54 +0200
message:
removed ending ?> and new line
modified:
libs/config.php
--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk
Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'libs/config.php'
--- libs/config.php 2012-03-06 19:30:19 +0000
+++ libs/config.php 2012-04-25 20:06:54 +0000
@@ -27,9 +27,9 @@
/**
* A class to handle settings and configuration.
- *
+ *
* This class provide support for multisite,multiview and multilangague
- * configuration.
+ * configuration.
*
* @category Aiki
* @package Library
@@ -48,9 +48,9 @@
/**
* set timezone calling date_default_timezone_set
- *
- * @return void
- *
+ *
+ * @return void
+ *
*/
function set_timezone() {
@@ -60,51 +60,51 @@
if ($timezone) {
date_default_timezone_set($timezone);
} else {
- // see http://php.net/manual/en/function.date-default-timezone-get.php to understand this
+ // see http://php.net/manual/en/function.date-default-timezone-get.php to understand this
date_default_timezone_set( @date_default_timezone_get());
- }
+ }
}
-
+
}
/**
* Load configuration for actual site/view/language
- *
- * The constructor calls this methods, so use this method
+ *
+ * The constructor calls this methods, so use this method
* only when you want reload configuration.
- *
+ *
* @return integer number of setting loaded.
- *
+ *
* @global $aiki
*/
function load_configuration() {
global $aiki, $config, $db;
-
+
// cache site,view, language
$this->site = $aiki->site->get_site();
$this->view = $aiki->site->view();
$this->language = $aiki->site->language();
-
+
if (count($config)) {
$checkPrevious = " OR config_name IN ('" . implode("','", array_keys($config)) . "')";
} else {
$checkPrevious = "";
}
-
+
// search autoload config setting and previuos config.
$sql = "SELECT config_selector, config_name, config_value ".
" FROM aiki_settings RIGHT JOIN aiki_configs ON setting_name=config_name".
" WHERE setting_autoload=1". $checkPrevious.
- " ORDER by config_important DESC, config_weight DESC";
-
+ " ORDER by config_important DESC, config_weight DESC";
+
$values = $db->get_results($sql);
if (!is_array($values)) {
- return 0;
+ return 0;
}
$prevName="";
$count = 0;
-
+
foreach ($values as $value) {
// only store first value than match selector.
if ( $prevName != $value->config_name &&
@@ -114,23 +114,23 @@
$count++;
}
}
-
+
// special config values
$this->set_timezone();
-
+
return $count;
}
/**
* Constructor.
- *
+ *
* Cache site, language and view and load configuration.
*
*/
function __construct(){
- $this->load_configuration();
+ $this->load_configuration();
}
/**
@@ -166,18 +166,18 @@
$ret = array(
( $parts[0] ? $parts[0] : "*" ),
( $parts[1] ? $parts[1] : "*" ),
- ( $parts[2] ? $parts[2] : "*" ));
+ ( $parts[2] ? $parts[2] : "*" ));
}
-
+
return $returnString ? implode("/", $ret) : $ret;
}
-
-
+
+
/**
* unserialize a value only if it seems like a serialized value
**/
-
+
private function _unserialize( $what ){
return $what=="N;" || preg_match ("/^[abidsO]:/", $what ) ? unserialize($what) : $what;
}
@@ -213,11 +213,11 @@
" FROM aiki_configs" .
" WHERE config_name='" . addslashes($setting) . "'" .
" ORDER BY config_important DESC,config_weight DESC";
-
- // if any value is valid only seek first.
+
+ // if any value is valid only seek first.
// note: apps that don't have site/view/language use this way.
if ( $selector=="*" || $selector=="*/*/*" ){
- $value = $db->get_var($sql);
+ $value = $db->get_var($sql);
if ( is_null($value) ) {
return $default;
}
@@ -225,19 +225,19 @@
$config[$setting]= $ret;
return $ret;
}
-
+
// firt obtain all values
$values = $db->get_results($sql);
- list($site,$view,$language)= $this->selector($selector);
-
- // and filter the first that match selector
+ list($site,$view,$language)= $this->selector($selector);
+
+ // and filter the first that match selector
if (is_array($values)) {
- foreach ($values as $value) {
+ foreach ($values as $value) {
if ($aiki->match_pair($value->config_selector, $site, $view, $language)) {
- $ret= $this->_unserialize($value->config_value);
+ $ret= $this->_unserialize($value->config_value);
$config[$setting]= $ret;
return $ret;
- }
+ }
}
}
return $default;
@@ -260,12 +260,12 @@
}
/**
- * delete values for a setting
- *
+ * delete values for a setting
+ *
* Always deletes database and (optional) config.
*
* @param string $setting
- * @param boolen $deleteConfig, if true, unsets $config[$setting]
+ * @param boolen $deleteConfig, if true, unsets $config[$setting]
*
* @global $config
* @globla $db
@@ -274,7 +274,7 @@
if ( $deleteConfig && isset($config[$setting]) ) {
unset( $config[$setting]);
}
- $db->query("DELETE FROM aiki_configs WHERE config_name='" . addslashes($setting) . "'");
+ $db->query("DELETE FROM aiki_configs WHERE config_name='" . addslashes($setting) . "'");
}
/**
@@ -289,7 +289,7 @@
* @param string $value
* @param string $selector
* @return boolean true is setting has been saved in database
- *
+ *
* @global $config
* @global $db
* @global $aiki
@@ -306,7 +306,7 @@
$selector = $givenSelector;
}
- if ( $givenSelector == "CURRENT" ||
+ if ( $givenSelector == "CURRENT" ||
$givenSelector=="*" || $givenSelector =="*/*/*" ||
$aiki->match_pair($givenSelector, $this->site, $this->view, $this->language) ) {
// value will only store in config, in selector is current, * (all) or match against
@@ -317,7 +317,7 @@
$parts = $this->selector($selector);
// Rules: a given site value 100, a view 10, a language only 1, * cero.
- $weight =
+ $weight =
( $parts[0] != "*" && $parts[0] != "" ? 100 : 00 ) +
( $parts[1] != "*" && $parts[1] != "" ? 10 : 00 ) +
( $parts[2] != "*" && $parts[2] != "" ? 1 : 00 );
@@ -325,7 +325,7 @@
$name = addslashes($setting);
$selector = addslashes("{$parts[0]}/{$parts[1]}/{$parts[2]}");
$where = " WHERE config_name='$name' AND config_selector='$selector'";
-
+
if ($db->get_var("SELECT config_id FROM aiki_configs $where")) {
$SQL =
"UPDATE aiki_configs SET" .
@@ -343,16 +343,16 @@
addslashes(serialize($value)),
$important,
$weight,
- $selector);
+ $selector);
return $db->query($SQL);
-
+
}
}
-
-
+
+
/**
- * Shortcut for aiki->config->get
+ * Shortcut for aiki->config->get
*
* You can define a default value, used when setting, and selector than can be
* a trio of site/view/languages (you can use *), or string like
@@ -362,17 +362,17 @@
* @param string $default Value to return if not faound (false)
* @param string $selector (CURRENT is default)
* @return setting if found.
- *
+ *
* @global $aiki
*/
-
+
function config($setting, $default=false, $selector="CURRENT") {
global $aiki;
return $aiki->config->get($setting, $default, $selector);
}
/**
- * Shortcut for aiki->config->set
+ * Shortcut for aiki->config->set
*
* set a setting permantely and for actual page if selector match.
*
@@ -385,7 +385,7 @@
* @param string $value to set
* @param string $selector (CURRENT is default)
* @return boolean true is setting has been saved in database
- *
+ *
* @global $aiki
*/
@@ -400,10 +400,10 @@
* Set error level depending of config debug options
*
* Call this function after aiki load "config" and "membership" class.
- *
+ *
* @param integer $newLevel (optional) the new level if debug if off.
* @return integer previous error level
- *
+ *
* @global $aiki
*/
@@ -411,7 +411,7 @@
global $aiki;
if (is_debug_on()) {
$oldLevel = error_reporting( E_ALL | E_STRICT );
- } else {
+ } else {
if ( $newLevel === false ) {
$newLevel = $aiki->config->get("error_level", E_ALL | E_STRICT );
}
@@ -431,27 +431,25 @@
* 2 : show debug if current user is SystemGOD or ModulesGod
*
* @return boolean true is setting has been saved in database
- *
+ *
* @global $aiki
*/
function is_debug_on() {
global $aiki;
$debug= $aiki->config->get("debug",false);
-
+
if ( $debug === false || $debug === true ) {
// boolean. Backwark compatibility
return $debug;
}
-
+
if ( $debug == 1 ||
( $debug == 2 && isset($aiki->membership) &&
( $aiki->membership->permissions =="SystemGOD" ||
- $aiki->membership->permissions =="ModulesGOD" ) ) ) {
+ $aiki->membership->permissions =="ModulesGOD" ) ) ) {
return true;
}
return false;
-
+
}
-
-?>
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help : https://help.launchpad.net/ListHelp