function display($args) { $show = array_get_default($args, 'show', 'home'); $page = null; foreach ($this->pages as $page) { if ($page['name'] == $show) { break; } } if (!$page) { $show = 'home'; $main_show = 'home'; } else { $main_show = array_key_exists('parent', $page) ? $page['parent'] : $show; } $args['show'] = $show; // Go to monitor if no id is specified $id = array_get_default($args, 'id', ''); if ($id == '') { header('Location: ../?' . http_build_query($args)); exit; } // Display menu $menu = $this->display_menu($main_show); $this->append(ax_ul_items($menu, array('id' => 'tablist'))); foreach ($this->forms as $form) { if ($form['name'] == $show) { break; } } if (!$form or $form['name'] != $show) { return; } $title = $form['descr']; $form = new $form['class']($args); if ($form->get_data($id)) { // Editing existing entity $title .= " {$id}"; } else { // Adding new entity $form->set_control_value('id', ''); $id = ""; unset($args['id']); $title .= " (new)"; } if (Request::is_post()) { $form->fill($_POST); $msg = $form->save_data(); $id = $form->get_control_value('id'); $form->get_data($id); if ($msg != "") { $this->append(ax_p($msg)); } } $fr = new AnewtFormRendererDefault(); $fr->set_form($form); $this->append(ax_h2($title)); $this->append($fr); }
function display($args) { $show = array_get_default($args, 'show', 'home'); $page = null; foreach ($this->pages as $page) { if ($page['name'] == $show) { break; } } if (!$page) { $show = 'home'; $main_show = 'home'; } else { $main_show = array_key_exists('parent', $page) ? $page['parent'] : $show; } $args['show'] = $show; $menu = $this->display_menu($main_show); $this->append(ax_ul_items($menu, array('id' => 'tablist'))); foreach ($this->pages as $page) { if ($page['name'] == $show) { // show header first $this->append(ax_h2($page['descr'])); // then submenu $submenu = $this->display_menu($show, $main_show); $this->append(ax_ul_items($submenu, array('id' => 'subtablist'))); // and finally the page $display = new $page['class']($this, $args, $this->pages); $display->show(); } } }