19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
21 require_once
$GLOBALS['xoops']->path('kernel/configoption.php');
22 require_once
$GLOBALS['xoops']->path('kernel/configitem.php');
60 var $_cachedConfigs = array();
67 function XoopsConfigHandler(&
$db)
79 function &createConfig()
81 $instance =& $this->_cHandler->create();
92 function &getConfig($id, $withoptions =
false)
94 $config =& $this->_cHandler->get($id);
95 if ($withoptions ==
true) {
96 $config->setConfOptions($this->getConfigOptions(
new Criteria(
'conf_id', $id)));
108 if (!$this->_cHandler->insert(
$config)) {
113 $conf_id =
$config->getVar(
'conf_id');
114 for(
$i = 0;
$i < $count;
$i ++) {
116 if (!$this->_oHandler->insert(
$options[
$i])) {
122 if (!empty($this->_cachedConfigs[
$config->getVar(
'conf_modid')][
$config->getVar(
'conf_catid')])) {
123 unset($this->_cachedConfigs[
$config->getVar(
'conf_modid')][
$config->getVar(
'conf_catid')]);
135 if (!$this->_cHandler->delete(
$config)) {
144 if (is_array(
$options) && $count > 0) {
145 for(
$i = 0;
$i < $count;
$i ++) {
149 if (!empty($this->_cachedConfigs[
$config->getVar(
'conf_modid')][
$config->getVar(
'conf_catid')])) {
150 unset($this->_cachedConfigs[
$config->getVar(
'conf_modid')][
$config->getVar(
'conf_catid')]);
164 function getConfigs(
$criteria = null, $id_as_key =
false, $with_options =
false)
166 return $this->_cHandler->getObjects(
$criteria, $id_as_key);
176 return $this->_cHandler->getCount(
$criteria);
187 function &getConfigsByCat($category,
$module = 0)
189 static $_cachedConfigs;
190 if (!empty($_cachedConfigs[
$module][$category])) {
191 return $_cachedConfigs[
$module][$category];
195 if (! empty($category)) {
201 $ret[
$configs[
$i]->getVar(
'conf_name')] = $configs[
$i]->getConfValueForOutput();
205 return $_cachedConfigs[
$module][$category];
214 function &createConfigOption()
216 $inst =& $this->_oHandler->create();
227 function &getConfigOption($id)
229 $inst =& $this->_oHandler->get($id);
241 function getConfigOptions(
$criteria = null, $id_as_key =
false)
243 return $this->_oHandler->getObjects(
$criteria, $id_as_key);
255 return $this->_oHandler->getCount(
$criteria);
266 function getConfigList($conf_modid, $conf_catid = 0)
268 if (!empty($this->_cachedConfigs[$conf_modid][$conf_catid])) {
269 return $this->_cachedConfigs[$conf_modid][$conf_catid];
272 if (empty($conf_catid)) {
278 for (
$i = 0;
$i < $confcount;
$i++) {
279 $ret[
$configs[
$i]->getVar(
'conf_name')] = $configs[
$i]->getConfValueForOutput();
281 $this->_cachedConfigs[$conf_modid][$conf_catid] = &
$ret;
291 trigger_error(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated', E_USER_WARNING);