Line feeds fixed, not change in functionality

This commit is contained in:
Michael 2018-03-24 18:39:13 +00:00
parent 885d794958
commit 850d9b4c0b
20 changed files with 2256 additions and 2256 deletions

View file

@ -1,72 +1,72 @@
<?php
namespace Friendica\Core\Config;
/**
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
interface IConfigAdapter
{
/**
* @brief Loads all configuration values into a cached storage.
*
* All configuration values of the system are stored in global cache
* which is available under the global variable $a->config
*
* @param string $cat The category of the configuration values to load
*
* @return void
*/
public function load($cat = "config");
/**
* @brief Get a particular user's config variable given the category name
* ($family) and a key.
*
* Get a particular config value from the given category ($family)
* and the $key from a cached storage in $a->config[$uid].
* $instore is only used by the set_config function
* to determine if the key already exists in the DB
* If a key is found in the DB but doesn't exist in
* local config cache, pull it into the cache so we don't have
* to hit the DB again for this item.
*
* @param string $cat The category of the configuration value
* @param string $k The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
public function get($cat, $k, $default_value = null, $refresh = false);
/**
* @brief Sets a configuration value for system config
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* Note: Please do not store booleans - convert to 0/1 integer values!
*
* @param string $family The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return mixed Stored $value or false if the database update failed
*/
public function set($cat, $k, $value);
/**
* @brief Deletes the given key from the system configuration.
*
* Removes the configured value from the stored cache in $a->config
* and removes it from the database.
*
* @param string $cat The category of the configuration value
* @param string $k The configuration key to delete
*
* @return mixed
*/
public function delete($cat, $k);
}
<?php
namespace Friendica\Core\Config;
/**
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
interface IConfigAdapter
{
/**
* @brief Loads all configuration values into a cached storage.
*
* All configuration values of the system are stored in global cache
* which is available under the global variable $a->config
*
* @param string $cat The category of the configuration values to load
*
* @return void
*/
public function load($cat = "config");
/**
* @brief Get a particular user's config variable given the category name
* ($family) and a key.
*
* Get a particular config value from the given category ($family)
* and the $key from a cached storage in $a->config[$uid].
* $instore is only used by the set_config function
* to determine if the key already exists in the DB
* If a key is found in the DB but doesn't exist in
* local config cache, pull it into the cache so we don't have
* to hit the DB again for this item.
*
* @param string $cat The category of the configuration value
* @param string $k The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
public function get($cat, $k, $default_value = null, $refresh = false);
/**
* @brief Sets a configuration value for system config
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* Note: Please do not store booleans - convert to 0/1 integer values!
*
* @param string $family The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return mixed Stored $value or false if the database update failed
*/
public function set($cat, $k, $value);
/**
* @brief Deletes the given key from the system configuration.
*
* Removes the configured value from the stored cache in $a->config
* and removes it from the database.
*
* @param string $cat The category of the configuration value
* @param string $k The configuration key to delete
*
* @return mixed
*/
public function delete($cat, $k);
}

View file

@ -1,77 +1,77 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Friendica\Core\Config;
/**
*
* @author benlo
*/
interface IPConfigAdapter
{
/**
* @brief Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored in global cache
* which is available under the global variable $a->config[$uid].
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
*
* @return void
*/
public function load($uid, $cat);
/**
* @brief Get a particular user's config variable given the category name
* ($family) and a key.
*
* Get a particular user's config value from the given category ($family)
* and the $key from a cached storage in $a->config[$uid].
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
public function get($uid, $cat, $k, $default_value = null, $refresh = false);
/**
* @brief Sets a configuration value for a user
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* @note Please do not store booleans - convert to 0/1 integer values!
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to set
* @param string $value The value to store
*
* @return mixed Stored $value or false
*/
public function set($uid, $cat, $k, $value);
/**
* @brief Deletes the given key from the users's configuration.
*
* Removes the configured value from the stored cache in $a->config[$uid]
* and removes it from the database.
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to delete
*
* @return mixed
*/
public function delete($uid, $cat, $k);
}
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Friendica\Core\Config;
/**
*
* @author benlo
*/
interface IPConfigAdapter
{
/**
* @brief Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored in global cache
* which is available under the global variable $a->config[$uid].
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
*
* @return void
*/
public function load($uid, $cat);
/**
* @brief Get a particular user's config variable given the category name
* ($family) and a key.
*
* Get a particular user's config value from the given category ($family)
* and the $key from a cached storage in $a->config[$uid].
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
public function get($uid, $cat, $k, $default_value = null, $refresh = false);
/**
* @brief Sets a configuration value for a user
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* @note Please do not store booleans - convert to 0/1 integer values!
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to set
* @param string $value The value to store
*
* @return mixed Stored $value or false
*/
public function set($uid, $cat, $k, $value);
/**
* @brief Deletes the given key from the users's configuration.
*
* Removes the configured value from the stored cache in $a->config[$uid]
* and removes it from the database.
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
* @param string $k The configuration key to delete
*
* @return mixed
*/
public function delete($uid, $cat, $k);
}

View file

@ -1,90 +1,90 @@
<?php
namespace Friendica\Core\Config;
use dba;
use Exception;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBM;
require_once 'include/dba.php';
/**
* Preload Configuration Adapter
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
{
private $config_loaded = false;
public function __construct()
{
$this->load();
}
public function load($family = 'config')
{
if ($this->config_loaded) {
return;
}
$configs = dba::select('config', ['cat', 'v', 'k']);
while ($config = dba::fetch($configs)) {
self::getApp()->setConfigValue($config['cat'], $config['k'], $config['v']);
}
dba::close($configs);
$this->config_loaded = true;
}
public function get($cat, $k, $default_value = null, $refresh = false)
{
if ($refresh) {
$config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setConfigValue($cat, $k, $config['v']);
}
}
$return = self::getApp()->getConfigValue($cat, $k, $default_value);
return $return;
}
public function set($cat, $k, $value)
{
// We store our setting values as strings.
// So we have to do the conversion here so that the compare below works.
// The exception are array values.
$compare_value = !is_array($value) ? (string)$value : $value;
if (self::getApp()->getConfigValue($cat, $k) === $compare_value) {
return true;
}
self::getApp()->setConfigValue($cat, $k, $value);
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
$result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $cat . '][' . $k . ']');
}
return true;
}
public function delete($cat, $k)
{
self::getApp()->deleteConfigValue($cat, $k);
$result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
return $result;
}
}
<?php
namespace Friendica\Core\Config;
use dba;
use Exception;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBM;
require_once 'include/dba.php';
/**
* Preload Configuration Adapter
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
{
private $config_loaded = false;
public function __construct()
{
$this->load();
}
public function load($family = 'config')
{
if ($this->config_loaded) {
return;
}
$configs = dba::select('config', ['cat', 'v', 'k']);
while ($config = dba::fetch($configs)) {
self::getApp()->setConfigValue($config['cat'], $config['k'], $config['v']);
}
dba::close($configs);
$this->config_loaded = true;
}
public function get($cat, $k, $default_value = null, $refresh = false)
{
if ($refresh) {
$config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setConfigValue($cat, $k, $config['v']);
}
}
$return = self::getApp()->getConfigValue($cat, $k, $default_value);
return $return;
}
public function set($cat, $k, $value)
{
// We store our setting values as strings.
// So we have to do the conversion here so that the compare below works.
// The exception are array values.
$compare_value = !is_array($value) ? (string)$value : $value;
if (self::getApp()->getConfigValue($cat, $k) === $compare_value) {
return true;
}
self::getApp()->setConfigValue($cat, $k, $value);
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
$result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $cat . '][' . $k . ']');
}
return true;
}
public function delete($cat, $k)
{
self::getApp()->deleteConfigValue($cat, $k);
$result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
return $result;
}
}

View file

@ -1,92 +1,92 @@
<?php
namespace Friendica\Core\Config;
use dba;
use Exception;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBM;
require_once 'include/dba.php';
/**
* Preload User Configuration Adapter
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
{
private $config_loaded = false;
public function __construct($uid)
{
$this->load($uid, 'config');
}
public function load($uid, $family)
{
if ($this->config_loaded) {
return;
}
$pconfigs = dba::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
while ($pconfig = dba::fetch($pconfigs)) {
self::getApp()->setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
}
dba::close($pconfigs);
$this->config_loaded = true;
}
public function get($uid, $cat, $k, $default_value = null, $refresh = false)
{
if ($refresh) {
$config = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setPConfigValue($uid, $cat, $k, $config['v']);
} else {
self::getApp()->deletePConfigValue($uid, $cat, $k);
}
}
$return = self::getApp()->getPConfigValue($uid, $cat, $k, $default_value);
return $return;
}
public function set($uid, $cat, $k, $value)
{
// We store our setting values as strings.
// So we have to do the conversion here so that the compare below works.
// The exception are array values.
$compare_value = !is_array($value) ? (string)$value : $value;
if (self::getApp()->getPConfigValue($uid, $cat, $k) === $compare_value) {
return true;
}
self::getApp()->setPConfigValue($uid, $cat, $k, $value);
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
$result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $uid . '][' . $cat . '][' . $k . ']');
}
return true;
}
public function delete($uid, $cat, $k)
{
self::getApp()->deletePConfigValue($uid, $cat, $k);
$result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
return $result;
}
}
<?php
namespace Friendica\Core\Config;
use dba;
use Exception;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBM;
require_once 'include/dba.php';
/**
* Preload User Configuration Adapter
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
{
private $config_loaded = false;
public function __construct($uid)
{
$this->load($uid, 'config');
}
public function load($uid, $family)
{
if ($this->config_loaded) {
return;
}
$pconfigs = dba::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
while ($pconfig = dba::fetch($pconfigs)) {
self::getApp()->setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
}
dba::close($pconfigs);
$this->config_loaded = true;
}
public function get($uid, $cat, $k, $default_value = null, $refresh = false)
{
if ($refresh) {
$config = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setPConfigValue($uid, $cat, $k, $config['v']);
} else {
self::getApp()->deletePConfigValue($uid, $cat, $k);
}
}
$return = self::getApp()->getPConfigValue($uid, $cat, $k, $default_value);
return $return;
}
public function set($uid, $cat, $k, $value)
{
// We store our setting values as strings.
// So we have to do the conversion here so that the compare below works.
// The exception are array values.
$compare_value = !is_array($value) ? (string)$value : $value;
if (self::getApp()->getPConfigValue($uid, $cat, $k) === $compare_value) {
return true;
}
self::getApp()->setPConfigValue($uid, $cat, $k, $value);
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
$result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $uid . '][' . $cat . '][' . $k . ']');
}
return true;
}
public function delete($uid, $cat, $k)
{
self::getApp()->deletePConfigValue($uid, $cat, $k);
$result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
return $result;
}
}