summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd68dd7)
raw | patch | inline | side by side (parent: bd68dd7)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 27 Sep 2010 09:34:33 +0000 (09:34 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 27 Sep 2010 09:34:33 +0000 (09:34 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19793 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
index 01d9ecc484e05ce4b70fc30feac0a181ff550eda..61b1209fcbd892382c331a8b55a95fcdcba12b21 100644 (file)
private $TemplateEngine = NULL;
private $idToName = array();
+ private $currentItemName = "";
function __construct(&$config, $dn)
{
$this->TemplateEngine = new TemplateEngine($config);
+ $this->TemplateEngine->setTemplate('puppet.tpl');
$this->config = $config;
$str = '{
$this->setCurrentItem('root');
$this->addItem('PuppetModule','test1',
array(
- 'version' => 1,
- 'name' => 'test1',
- 'description' => 'Test Module')
+ 'dependency' => 'mozilla-2',
+ 'version' => '2.4-f',
+ 'name' => 'Thundebird',
+ 'description' => 'Mozilla mail client')
);
$this->addItem('PuppetModule','test2',
array(
'version' => 1,
- 'name' => 'test2',
+ 'name' => 'Firefox',
'description' => 'Test Module')
);
$this->setCurrentItem('test1');
}else{
$str .= $array['name'];
}
+ $str .= " <i>(".$array['type'].")</i>";
$str .= "</a>";
if(count($array['children'])){
function setCurrentItem($item)
{
+ if($this->currentItemName == $item) return;
$this->currentItemName = $item;
$this->currentItem = &$this->currentItemValues[$item];
$this->currentItemType = $this->currentItem['type'];
$this->currentItemDescriptor =&$this->itemConfig[$this->currentItem['type']];
+ $this->TemplateEngine->setType($this->currentItemType);
+ $this->TemplateEngine->setValues($this->currentItem['values']);
}
- $this->TemplateEngine->setType($this->currentItemType);
- $this->TemplateEngine->setValues($this->currentItem);
- $this->TemplateEngine->setTemplate('puppet.tpl');
$smarty->assign('template',$this->TemplateEngine->render());
return($smarty->fetch(get_template_path('goto/Config/DeviceConfig.tpl', TRUE)));
}
function save_object()
{
+ $this->TemplateEngine->save_object();
+
if(isset($_POST['addSubModule']) && isset($_POST['subModule'])){
$sub = get_post('subModule');
if(in_array($sub, $this->currentItemDescriptor['container'])){
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc
index f976ed51a33c73d9a54b9e63a4cbd6ddcdf56c28..6d7f3f705ed023489dcb6048a2a47c85ec9174e7 100644 (file)
$this->config = &$config;
}
- function setValues($array)
+ function setValues($values)
{
-# print_a($array);
+ foreach($values as $name => $value){
+ $this->widgets[$name]->setValue($value);
+ }
}
function setType($name)
$this->itemType = $name;
$this->widgets = array();
+ if(!isset($this->data[$this->itemType])){
+ trigger_error("Undefined item type '{$name}'!");
+ return;
+ }
$data = $this->data[$this->itemType];
if(isset($data['options']) && count($data['options'])){
foreach($data['options'] as $name => $item){
- $this->widgets[] = new TemplateWidget($this->config, $name, $item['value']);
+
+ $this->widgets[$name] = new TemplateWidget($this->config, $name,
+ $item['value'],
+ $item['description'],
+ $item['required'],
+ $item['type'],
+ $item['display']);
}
}
}
{
$smarty = get_smarty();
$smarty->assign("type", $this->itemType);
- foreach($this->getWidgets() as $widget){
+ foreach($this->widgets as $widget){
$smarty->assign($widget->getName(), $widget->render());
}
return($smarty->fetch(get_template_path("goto/Config/{$this->template}", TRUE)));
}
+
+ function save_object()
+ {
+ foreach($this->widgets as $widget){
+ $widget->save_object();
+ }
+ }
}
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc
index d946c3cc15074c1245b2167577c73a2a0db9f736..e48e06a2441811d5f44eb1eb41d57138db8386ae 100644 (file)
private $name = "unnamed";
private $value = "";
- function __construct(&$config, $name, $value)
+ private $description = "";
+ private $required = "";
+ private $type = "";
+ private $display = "";
+
+ function __construct(&$config, $name, $value, $description,$required,$type,$display)
{
+ $this->config = &$config;
+
+ echo '*';
$this->name = $name;
$this->value = $value;
- $this->config = &$config;
+ $this->description = $description;
+ $this->required = $required;
+ $this->type = $type;
+ $this->display = $display;
}
function render()
{
- return("<input type='text' name=\"{$this->name}\" value=\"".set_post($this->value)."\">");
+
+ $class = get_class();
+ return("{$this->display} <input type='text' name=\"{$class}_{$this->name}\" value=\"".set_post($this->value)."\">");
}
function save_object()
{
+ $class = get_class();
+ $name = "{$class}_{$this->name}";
+ if(isset($_POST[$name])){
+ $this->value = get_post($name);
+ }
}
function getValue()
{
+ return($this->value);
}
function getName()
return($this->name);
}
- function setValue()
+ function setValue($value)
{
+ $this->value = $value;
}
}