/** * Modify how the menu items * are glued together - each * one is a row in a table. * * @return string **/ protected function menuitems_to_html($menuitems, $depth = 0) { global $CFG; $action = optional_param('action', '', PARAM_ALPHA); if ($action == 'move') { $moveid = required_param('linkid', PARAM_INT); $alt = s(get_string('movehere')); $movewidget = "<a title=\"{$alt}\" href=\"{$CFG->wwwroot}/mod/pagemenu/edit.php?a={$this->pagemenuid}&action=movehere&linkid={$moveid}&sesskey=" . sesskey() . '&after=%d">' . "<img src=\"{$CFG->pixpath}/movehere.gif\" border=\"0\" alt=\"{$alt}\" /></a>"; $move = true; } else { $move = false; } $table = new stdClass(); $table->id = 'edit-table'; $table->width = '90%'; $table->tablealign = 'center'; $table->cellpadding = '5px'; $table->cellspacing = '0'; $table->data = array(); if ($move) { $table->head = array(get_string('movingcancel', 'pagemenu', "{$CFG->wwwroot}/mod/pagemenu/edit.php?a={$this->pagemenuid}")); $table->wrap = array('nowrap'); $table->data[] = array(sprintf($movewidget, 0)); } else { $table->head = array(get_string('linktype', 'pagemenu'), get_string('actions', 'pagemenu'), get_string('rendered', 'pagemenu')); $table->align = array('left', 'center', ''); $table->size = array('*', '*', '100%'); $table->wrap = array('nowrap', 'nowrap', 'nowrap'); } foreach ($this->links as $link) { if (array_key_exists($link->link->id, $menuitems)) { $html = $this->renderer->menuitems_to_html(array($menuitems[$link->link->id])); } else { $html = get_string('linkitemerror', 'pagemenu'); } if ($move) { if ($moveid != $link->link->id) { $table->data[] = array($html); $table->data[] = array(sprintf($movewidget, $link->link->id)); } } else { $widgets = array(); foreach (array('move', 'edit', 'delete') as $widget) { $alt = s(get_string($widget)); $widgets[] = "<a title=\"{$alt}\" href=\"{$CFG->wwwroot}/mod/pagemenu/edit.php?a={$this->pagemenuid}&action={$widget}&linkid={$link->link->id}&sesskey=" . sesskey() . '">' . "<img src=\"{$CFG->pixpath}/t/{$widget}.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"{$alt}\" /></a>"; } $table->data[] = array($link->get_name(), implode(' ', $widgets), $html); } } return print_table($table, true); }
/** * Need to clear out post in the menuitem * which is usually an image and the YUI * uses its own image * * @return string **/ protected function a($menuitem) { $cloned = clone $menuitem; $cloned->post = ''; return parent::a($cloned); }