/** !! * Determins the config of the user, * @param key $config_sect used as a key to select config sections * @param int $manage_mode determins if the user is a user or super user * @return PAForm $form returns the form to be used */ public function getConfigSection($config_sect, $manage_mode) { global $app, $error_msg; if (!isset($this->sections[$config_sect])) { $error_msg = __('Section does not exist!'); return "skip"; } $section = $this->sections[$config_sect]; $condition = '@readonly=\'false\''; if ($manage_mode == 1) { // super user mode $condition = null; } list($info, $data) = $app->configObj->getConfigSection($section, $condition); //echo "<pre>" . print_r($data,1) . "</pre>"; $this->section = $section; $form = new PAForm("form_data[{$section}]"); $form->addContentTag('h1', array('value' => $info['description'])); $form->openTag('div', array('class' => 'field')); $form->closeTag('div'); $form->openTag('fieldset', array('class' => 'center_box')); foreach ($data as $name => $item) { $this->populate_data($item, $name, $form); //echo "<pre>" . print_r($item,1) . "</pre>"; } $form->addInputTag('hidden', array('name' => 'action', 'value' => 'saveConfSection')); $form->addInputTag('hidden', array('name' => 'section', 'value' => "{$this->section}")); $form->addInputTag('submit', array('name' => 'submit', 'value' => "Save changes")); $form->closeTag('fieldset'); return $form; }
private function get_config_section_form($name, $condition = null) { list($info, $results) = $this->get_config_section($name, $condition); $section_name = $info['name']; $form = new PAForm('pa_inst'); $form->addContentTag('legend', array('value' => $info['description'])); $form->addHtml('<div>'); foreach ($results as $key => $data) { $form->addInputField('text', $data['attributes']['description'], array('id' => $key, 'required' => true, 'value' => $data['value'])); } $form->addInputTag('hidden', array('id' => 'section_name', 'value' => $section_name)); $form->addHtml('</div>'); return $form->getHtml(); }