/** * For internal use only. */ public function edit($parent, $key = null) { if ($this->is_back()) { return false; } $id = Utils_CommonDataCommon::get_id($parent); if (!$id) { print __('No such array'); return false; } $f = $this->init_module(Libs_QuickForm::module_name(), null, 'edit'); $f->addElement('header', null, $key === null ? __('New node') : __('Edit node')); $f->add_table('utils_commondata_tree', array(array('name' => 'akey', 'label' => __('Key'), 'rule' => array(array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key'), 'message' => __('Specified key already exists')), array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key2'), 'message' => __('Specified contains invalid character "/"')))), array('name' => 'value', 'label' => __('Value')))); if ($key !== null) { $value = Utils_CommonDataCommon::get_value($parent . '/' . $key); $f->setDefaults(array('akey' => $key, 'value' => $value)); } if ($f->validate()) { $submited = $f->exportValues(); if ($key !== null) { Utils_CommonDataCommon::rename_key($parent, $key, $submited['akey']); } Utils_CommonDataCommon::set_value($parent . '/' . $submited['akey'], $submited['value']); return false; } Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href()); Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href()); $f->display(); return true; }