<?php
class Setting_Control
{
private $Setting;
public function __construct()
{
require_once( MODELS . '/setting.php' );
$this->Setting = new Setting();
}
public function get_setting($id)
{
$node = $this->Setting->get_setting_node($id);
return $this->Setting->get_setting_value($node);
}
public function set_setting($id, $value)
{
if($id == 'oracle_path')
{
$value = str_replace('\\\\', '/', $value);
}
$node = $this->Setting->get_setting_node($id);
$node = $this->Setting->set_setting($node, $value);
$bytes_written = $this->Setting->save($node);
if($bytes_written > 0)
{
return true;
}
else
{
return false;
}
}
public function get_settings()
{
$settings = array();
$nodes = $this->Setting->get_settings();
foreach($nodes as $node)
{
$settings[$node->getAttribute('id')] = array('label' => $node->getAttribute('label'),
'value' => $node->nodeValue,
'ref' => $node->getAttribute('ref'));
}
return $settings;
}
public function get_setting_options($setting_id)
{
$options = array();
$i = 0;
$nodes = $this->Setting->get_setting_options($setting_id);
foreach($nodes as $node)
{
foreach($node->attributes as $attribute)
{
$options[$i][$attribute->name] = $attribute->value;
}
$options[$i]['value'] = $node->nodeValue;
$i++;
}
return $options;
}
}
?>