Keep action links consistent
This commit is contained in:
parent
43d20c0d1b
commit
d848bc73e8
2 changed files with 60 additions and 58 deletions
|
@ -197,12 +197,12 @@ class edit_form extends \moodleform {
|
|||
// Place the ordering arrows.
|
||||
// Only display the move up arrow if it is not the first.
|
||||
if ($page->pagenumber > 1) {
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('moveup' => $page->id));
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('action' => 'pmoveup', 'aid' => $page->id));
|
||||
$mform->addElement('html', $OUTPUT->action_icon($url, new \pix_icon('t/up', get_string('moveup'))));
|
||||
}
|
||||
// Only display the move down arrow if it is not the last.
|
||||
if ($page->pagenumber < $this->numpages) {
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('movedown' => $page->id));
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('action' => 'pmovedown', 'aid' => $page->id));
|
||||
$mform->addElement('html', $OUTPUT->action_icon($url, new \pix_icon('t/down', get_string('movedown'))));
|
||||
}
|
||||
|
||||
|
@ -256,20 +256,22 @@ class edit_form extends \moodleform {
|
|||
'action' => 'edit'));
|
||||
$icons = $OUTPUT->action_icon($link, new \pix_icon('t/edit', get_string('edit')));
|
||||
// Link to delete the element.
|
||||
$link = new \moodle_url($editlink, $editlinkparams + array('id' => $element->id,
|
||||
'deleteelement' => $element->id));
|
||||
$link = new \moodle_url($editlink, $editlinkparams + array('action' => 'deleteelement',
|
||||
'aid' => $element->id));
|
||||
$icons .= $OUTPUT->action_icon($link, new \pix_icon('t/delete', get_string('delete')));
|
||||
// Now display any moving arrows if they are needed.
|
||||
if ($numelements > 1) {
|
||||
// Only display the move up arrow if it is not the first.
|
||||
$moveicons = '';
|
||||
if ($element->sequence > 1) {
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('emoveup' => $element->id));
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('action' => 'emoveup',
|
||||
'aid' => $element->id));
|
||||
$moveicons .= $OUTPUT->action_icon($url, new \pix_icon('t/up', get_string('moveup')));
|
||||
}
|
||||
// Only display the move down arrow if it is not the last.
|
||||
if ($element->sequence < $numelements) {
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('emovedown' => $element->id));
|
||||
$url = new \moodle_url($editlink, $editlinkparams + array('action' => 'emovedown',
|
||||
'aid' => $element->id));
|
||||
$moveicons .= $OUTPUT->action_icon($url, new \pix_icon('t/down', get_string('movedown')));
|
||||
}
|
||||
$icons .= $moveicons;
|
||||
|
@ -289,7 +291,7 @@ class edit_form extends \moodleform {
|
|||
// Add option to delete this page if there is more than one page.
|
||||
if ($this->numpages > 1) {
|
||||
// Link to delete the element.
|
||||
$deletelink = new \moodle_url($editlink, $editlinkparams + array('deletepage' => $page->id));
|
||||
$deletelink = new \moodle_url($editlink, $editlinkparams + array('action' => 'deletepage', 'aid' => $page->id));
|
||||
$deletelink = \html_writer::tag('a', get_string('deletecertpage', 'customcert'), array('href' => $deletelink->out(false), 'class' => 'deletebutton'));
|
||||
$mform->addElement('html', \html_writer::tag('div', $deletelink, array('class' => 'deletebutton')));
|
||||
}
|
||||
|
|
54
edit.php
54
edit.php
|
@ -25,12 +25,10 @@
|
|||
require_once('../../config.php');
|
||||
|
||||
$tid = optional_param('tid', 0, PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
$emoveup = optional_param('emoveup', 0, PARAM_INT);
|
||||
$emovedown = optional_param('emovedown', 0, PARAM_INT);
|
||||
$deleteelement = optional_param('deleteelement', 0, PARAM_INT);
|
||||
$deletepage = optional_param('deletepage', 0, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
if ($action) {
|
||||
$actionid = required_param('aid', PARAM_INT);
|
||||
}
|
||||
$confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
|
||||
// Edit an existing template.
|
||||
|
@ -78,24 +76,22 @@ if ($tid && $DB->count_records('customcert_templates', array('contextid' => CONT
|
|||
$deleting = false;
|
||||
|
||||
if ($tid) {
|
||||
// Check if they are moving a custom certificate page.
|
||||
if ((!empty($moveup)) || (!empty($movedown))) {
|
||||
// Check if we are moving a page up.
|
||||
if (!empty($moveup)) {
|
||||
$template->move_page_up($moveup);
|
||||
} else { // Must be moving a page down.
|
||||
$template->move_page_down($movedown);
|
||||
}
|
||||
} else if ((!empty($emoveup)) || (!empty($emovedown))) { // Check if we are moving a custom certificate element.
|
||||
// Check if we are moving an element up.
|
||||
if (!empty($emoveup)) {
|
||||
$template->move_element_up($emoveup);
|
||||
} else { // Must be moving a element down.
|
||||
$template->move_element_down($emovedown);
|
||||
}
|
||||
} else if (!empty($deletepage)) { // Check if we are deleting a page.
|
||||
switch ($action) {
|
||||
case 'pmoveup' :
|
||||
$template->move_page_up($actionid);
|
||||
break;
|
||||
case 'pmovedown' :
|
||||
$template->move_page_down($actionid);
|
||||
break;
|
||||
case 'emoveup' :
|
||||
$template->move_element_up($actionid);
|
||||
break;
|
||||
case 'emovedown' :
|
||||
$template->move_element_down($actionid);
|
||||
break;
|
||||
case 'deletepage' :
|
||||
if (!empty($confirm)) { // Check they have confirmed the deletion.
|
||||
$template->delete_page($deletepage);
|
||||
$template->delete_page($actionid);
|
||||
} else {
|
||||
// Set deletion flag to true.
|
||||
$deleting = true;
|
||||
|
@ -104,13 +100,15 @@ if ($tid) {
|
|||
// Create the link options.
|
||||
$nourl = new moodle_url('/mod/customcert/edit.php', array('tid' => $tid));
|
||||
$yesurl = new moodle_url('/mod/customcert/edit.php', array('tid' => $tid,
|
||||
'deletepage' => $deletepage,
|
||||
'action' => 'deletepage',
|
||||
'aid' => $actionid,
|
||||
'confirm' => 1,
|
||||
'sesskey' => sesskey()));
|
||||
}
|
||||
} else if (!empty($deleteelement)) { // Check if we are deleting an element.
|
||||
break;
|
||||
case 'deleteelement' :
|
||||
if (!empty($confirm)) { // Check they have confirmed the deletion.
|
||||
$template->delete_element($deleteelement);
|
||||
$template->delete_element($actionid);
|
||||
} else {
|
||||
// Set deletion flag to true.
|
||||
$deleting = true;
|
||||
|
@ -119,10 +117,12 @@ if ($tid) {
|
|||
// Create the link options.
|
||||
$nourl = new moodle_url('/mod/customcert/edit.php', array('tid' => $tid));
|
||||
$yesurl = new moodle_url('/mod/customcert/edit.php', array('tid' => $tid,
|
||||
'deleteelement' => $deleteelement,
|
||||
'action' => 'deleteelement',
|
||||
'aid' => $actionid,
|
||||
'confirm' => 1,
|
||||
'sesskey' => sesskey()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue