mirror of
https://github.com/TechplexEngineer/opensimWebAssets.git
synced 2026-08-14 09:12:10 +00:00
minor: rough import of our Config_Ini class
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?
|
||||
/**
|
||||
* @file Engine.class.php
|
||||
* @brief Config Engine abstract class declaration
|
||||
*/
|
||||
|
||||
/** @addtogroup Config */
|
||||
/** @{ */
|
||||
|
||||
/**
|
||||
* @brief Config Engine class abstract
|
||||
* @details Our Config engine class signature
|
||||
* @abstract
|
||||
*/
|
||||
abstract class Config_Engine implements IConfigEngine {
|
||||
|
||||
/** @brief pointer to current instance */
|
||||
protected static $_instance;
|
||||
|
||||
/** @brief singleton mechanism */
|
||||
abstract public static function instance();
|
||||
|
||||
/** @brief per-extending class custom initialization */
|
||||
abstract protected function init();
|
||||
|
||||
function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* @file Ini.class.php
|
||||
* @brief Config_Engine_Ini class implementation
|
||||
*/
|
||||
|
||||
/** @addtogroup Config */
|
||||
/** @{ */
|
||||
|
||||
/**
|
||||
* @brief INI file configuration class
|
||||
* @details Simple ini-file accessor
|
||||
*/
|
||||
class Config_Engine_Ini extends Config_Engine {
|
||||
/** @brief currently loaded ini file */
|
||||
private $_filename;
|
||||
|
||||
/** @brief currently loaded config array */
|
||||
private $_config;
|
||||
|
||||
function __destruct() {
|
||||
|
||||
}
|
||||
|
||||
protected function init() {
|
||||
$this->_config = array();
|
||||
$this->_filename = "";
|
||||
if (defined('CONFIG_INI'))
|
||||
$this->load(CONFIG_INI);
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
if (!self::$_instance)
|
||||
self::$_instance = new Config_Engine_Ini();
|
||||
return (self::$_instance);
|
||||
}
|
||||
|
||||
public function load($cfg_identifier) {
|
||||
if (!is_file($cfg_identifier))
|
||||
throw new RuntimeException('invalid config identifier');
|
||||
$process_sections = true;
|
||||
$this->_config = parse_ini_file($cfg_identifier, $process_sections);
|
||||
$this->_filename = $cfg_identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo implement this
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns given key within given section
|
||||
* @param group - ini section where to load given key
|
||||
* @param key - key to retrieve
|
||||
* @return mixed - given key value within given section
|
||||
*/
|
||||
public function getkey($group, $key) {
|
||||
if (!array_key_exists($group, $this->_config))
|
||||
return (array());
|
||||
if (!array_key_exists($key, $this->_config[$group]))
|
||||
return (array());
|
||||
return ($this->_config[$group][$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo implement this
|
||||
*/
|
||||
public function setkey($group, $key, $val) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns currently loaded config as an array
|
||||
* @return array - associative array representing loaded ini file
|
||||
*/
|
||||
public function get() {
|
||||
return ($this->_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get given ini section, as an array
|
||||
* @param $group string - ini section to load
|
||||
* @return array - loaded section as an associative array
|
||||
*/
|
||||
public function getGroup($group) {
|
||||
if (!array_key_exists($group, $this->_config))
|
||||
return (array());
|
||||
return ($this->_config[$group]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* @file Xml.class.php
|
||||
* @brief Config_Engine_Xml class implementation
|
||||
*/
|
||||
|
||||
/** @addtogroup Config */
|
||||
/** @{ */
|
||||
|
||||
/**
|
||||
* @brief XML config loader
|
||||
* @details Simple xml-config accessor
|
||||
*/
|
||||
class Config_Engine_Xml extends Config_Engine {
|
||||
|
||||
function __destruct() {
|
||||
|
||||
}
|
||||
|
||||
protected function init() {
|
||||
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
if (!self::$_instance)
|
||||
self::$_instance = new Config_Engine_Xml();
|
||||
return (self::$_instance);
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function load($cfg_identifier) {
|
||||
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function save() {
|
||||
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function getkey($group, $key) {
|
||||
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function setkey($group, $key, $val) {
|
||||
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function get() {
|
||||
|
||||
}
|
||||
|
||||
/** @todo implement this */
|
||||
public function getGroup($group) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
?>
|
||||
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
interface IConfigEngine {
|
||||
|
||||
/** @brief loads given config */
|
||||
function load($cfg_identifier);
|
||||
|
||||
/** @brief saves current configuration */
|
||||
function save();
|
||||
|
||||
/** @brief retrieve given key, within given group */
|
||||
function getkey($group, $key);
|
||||
|
||||
/** @brief assign given val to given group/key */
|
||||
function setkey($group, $group, $val);
|
||||
|
||||
/** @brief returns current config as a php array */
|
||||
function get();
|
||||
|
||||
/** @brief returns given config group as an array */
|
||||
function getGroup($group);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -6,7 +6,13 @@
|
||||
*/
|
||||
require_once('bootstrap.php');
|
||||
|
||||
$cfg = Config_Engine_Ini::instance();
|
||||
// ...
|
||||
|
||||
$viewer = WebAsset_Viewer::instance();
|
||||
// ...
|
||||
|
||||
$asset = new WebAsset();
|
||||
// ...
|
||||
|
||||
?>
|
||||
|
||||
Vendored
Reference in New Issue
Block a user