public function getForm($action) { $form = new form_renderer($action); $form->append($tabs = new widget_tabs()); foreach ($this->info as $cat => $category) { $inputs = array(); foreach ($category['items'] as $id => $field) { $name = "options[{$cat}][{$id}]"; $value = $this->{$cat}->{$id}; $class = 'data_option_' . $field['type']; if (class_exists($class)) { $provider = new $class($field); $inputs[] = $provider->getField($name, $value); } elseif ($field['type'] == 'text') { $inputs[] = new form_field_text($name, $field['caption'], $value); } elseif ($field['type'] == 'textarea') { $inputs[] = new form_field_textarea($name, $field['caption'], $value); } elseif ($field['type'] == 'checkbox') { $inputs[] = new form_field_checkbox($name, $field['caption'], $value); } } $tabs->add(literal($category['caption']), implode('', $inputs)); } return $form; }
public function index() { $pack = $this->package; $self = MODUL_SELF . '&edit=' . $pack['id']; $cond = db()->format("package = '%s'", $pack['id']); $rcf = new data_controller('update_file', $self . '#tabs-2-hash'); $rcf->add('path', 'Datei-Pfad'); $rcf->add('version', 'Version'); $rcf->edit = $rcf->create = false; $rcf->condition = $cond; $rcf->prefix = 'file_'; $rcf->pk = 'path'; $plink = MODUL_SELF . '&action=add_files&edit=' . $pack['id']; $addbtn = '<p align="center"><input type="button" class="btn btn-primary" ' . 'value="Dateien hinzufügen" onclick="popup( \'' . $plink . '\', 800 )"></p>'; if ($rcf->run()) { throw new redirect($self . '#tabs-2-hash'); } $rcs = new data_controller('update_share', $self . '#tabs-3-hash'); $rcs->add('comment', 'Kommentar', 1, 1, 1, 1); $rcs->add('pattern', 'Freigabe', 1, 1, 1, 1); $rcs->condition = $cond; $rcs->auto['create'] = array('package' => $pack['id']); $rcs->prefix = 'share_'; if ($rcs->run()) { throw new redirect($self . '#tabs-3-hash'); } $depend = array_keys($GLOBALS['packages']); $rcd = new data_controller('update_dependency', $self . '#tabs-4-hash'); $rcd->add('required', 'Benötigtes Paket', 1, 1, 1, 1, 'select', $depend); $rcd->add('version', 'Version', 1, 1, 1, 1); $rcd->condition = $cond; $rcd->auto['create'] = array('package' => $pack['id']); $rcd->prefix = 'depend_'; if ($rcd->run()) { throw new redirect($self . '#tabs-4-hash'); } $tabs = new widget_tabs('update_files', $self); $tabs->add('Infos', template('iv.packages.info')->render($pack)); $tabs->add('Dateien', $rcf->get_list(25) . $addbtn); $tabs->add('Freigaben', $rcs->get_form() . $rcs->get_list()); $tabs->add('Abhängigkeiten', $rcd->get_form() . $rcd->get_list()); $this->view->box($tabs, 'Paket bearbeiten', '600px'); }