aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/XConfig.php
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-09-05 00:23:42 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-11-03 23:04:27 +0100
commit1a737be2b408135177a9e94dcffd0f68c0aca90b (patch)
tree17e565688120ef94db2fa1e9635d0d55f2e43c58 /Zotlabs/Lib/XConfig.php
parent0ce7358f0f00cb000562dc34be13459eb5779c18 (diff)
downloadvolse-hubzilla-1a737be2b408135177a9e94dcffd0f68c0aca90b.tar.gz
volse-hubzilla-1a737be2b408135177a9e94dcffd0f68c0aca90b.tar.bz2
volse-hubzilla-1a737be2b408135177a9e94dcffd0f68c0aca90b.zip
:bulb: Improving Doxygen documentation.
Fix some Doxygen parsing errors. Improve hooks documentation.
Diffstat (limited to 'Zotlabs/Lib/XConfig.php')
-rw-r--r--Zotlabs/Lib/XConfig.php33
1 files changed, 25 insertions, 8 deletions
diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php
index bf78c360f..c5a108ac9 100644
--- a/Zotlabs/Lib/XConfig.php
+++ b/Zotlabs/Lib/XConfig.php
@@ -2,7 +2,26 @@
namespace Zotlabs\Lib;
-
+/**
+ * @brief Class for handling observer's config.
+ *
+ * <b>XConfig</b> is comparable to <i>PConfig</i>, except that it uses <i>xchan</i>
+ * (an observer hash) as an identifier.
+ *
+ * <b>XConfig</b> is used for observer specific configurations and takes a
+ * <i>xchan</i> as identifier.
+ * The storage is of size MEDIUMTEXT.
+ *
+ * @code{.php}$var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'key');
+ * // with default value for non existent key
+ * $var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'unsetkey', 'defaultvalue');@endcode
+ *
+ * The old (deprecated?) way to access a XConfig value is:
+ * @code{.php}$observer = App::get_observer_hash();
+ * if ($observer) {
+ * $var = get_xconfig($observer, 'category', 'key');
+ * }@endcode
+ */
class XConfig {
/**
@@ -15,7 +34,6 @@ class XConfig {
* The observer's hash
* @return void|false Returns false if xchan is not set
*/
-
static public function Load($xchan) {
if(! $xchan)
@@ -56,9 +74,9 @@ class XConfig {
* The category of the configuration value
* @param string $key
* The configuration key to query
+ * @param boolean $default (optional) default false
* @return mixed Stored $value or false if it does not exist
*/
-
static public function Get($xchan, $family, $key, $default = false) {
if(! $xchan)
@@ -70,7 +88,7 @@ class XConfig {
if((! array_key_exists($family, \App::$config[$xchan])) || (! array_key_exists($key, \App::$config[$xchan][$family])))
return $default;
- return ((! is_array(\App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$xchan][$family][$key]))
+ return ((! is_array(\App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$xchan][$family][$key]))
? unserialize(\App::$config[$xchan][$family][$key])
: \App::$config[$xchan][$family][$key]
);
@@ -82,7 +100,6 @@ class XConfig {
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the observer's $xchan hash.
*
- *
* @param string $xchan
* The observer's hash
* @param string $family
@@ -93,7 +110,6 @@ class XConfig {
* The value to store
* @return mixed Stored $value or false
*/
-
static public function Set($xchan, $family, $key, $value) {
// manage array value
@@ -106,7 +122,7 @@ class XConfig {
if(! array_key_exists($family, \App::$config[$xchan]))
\App::$config[$xchan][$family] = array();
- $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' ) ",
+ $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' )",
dbesc($xchan),
dbesc($family),
dbesc($key),
@@ -126,6 +142,7 @@ class XConfig {
if($ret)
return $value;
+
return $ret;
}
@@ -143,11 +160,11 @@ class XConfig {
* The configuration key to delete
* @return mixed
*/
-
static public function Delete($xchan, $family, $key) {
if(x(\App::$config[$xchan][$family], $key))
unset(\App::$config[$xchan][$family][$key]);
+
$ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'",
dbesc($xchan),
dbesc($family),