From d70a6931377e1f7c635638ea3fe7b09a7b4304f3 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 7 Aug 2017 16:59:45 +0800 Subject: [PATCH] #35 Reworded 'addcertpage' string and changed button to a link Also added an icon next to the link and moved the location via CSS. --- classes/edit_form.php | 12 ++++++------ edit.php | 11 +++++------ lang/en/customcert.php | 2 +- styles.css | 5 +++++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/classes/edit_form.php b/classes/edit_form.php index 9c1d034..a5640f8 100644 --- a/classes/edit_form.php +++ b/classes/edit_form.php @@ -55,7 +55,7 @@ class edit_form extends \moodleform { * Form definition. */ public function definition() { - global $DB; + global $DB, $OUTPUT; $mform =& $this->_form; @@ -80,11 +80,11 @@ class edit_form extends \moodleform { $this->add_customcert_page_elements($page); } - $mform->closeHeaderBefore('addcertpage'); - - $mform->addElement('submit', 'addcertpage', get_string('addcertpage', 'customcert')); - - $mform->closeHeaderBefore('submitbtn'); + // Link to add another page. + $addpagelink = new \moodle_url('/mod/customcert/edit.php', array('tid' => $this->tid, 'aid' => 1, 'action' => 'addpage')); + $icon = $OUTPUT->pix_icon('t/switch_plus', get_string('addcertpage', 'customcert')); + $addpagehtml = \html_writer::link($addpagelink, $icon . get_string('addcertpage', 'customcert')); + $mform->addElement('html', \html_writer::tag('div', $addpagehtml, array('class' => 'addpage'))); // Add the submit buttons. $group = array(); diff --git a/edit.php b/edit.php index 9061157..292ca41 100644 --- a/edit.php +++ b/edit.php @@ -66,7 +66,6 @@ if ($context->contextlevel == CONTEXT_SYSTEM) { $PAGE->navbar->add(get_string('editcustomcert', 'customcert')); } - // Flag to determine if we are deleting anything. $deleting = false; @@ -84,6 +83,11 @@ if ($tid) { case 'emovedown' : $template->move_item('element', $actionid, 'down'); break; + case 'addpage' : + $template->add_page(); + $url = new \moodle_url('/mod/customcert/edit.php', array('tid' => $tid)); + redirect($url); + break; case 'deletepage' : if (!empty($confirm)) { // Check they have confirmed the deletion. $template->delete_page($actionid); @@ -182,11 +186,6 @@ if ($data = $mform->get_data()) { // Save any page data. $template->save_page($data); - // Check if we are adding a page. - if (!empty($data->addcertpage)) { - $template->add_page(); - } - // Loop through the data. foreach ($data as $key => $value) { // Check if they chose to add an element to a page. diff --git a/lang/en/customcert.php b/lang/en/customcert.php index b4f084e..1d9d7e1 100644 --- a/lang/en/customcert.php +++ b/lang/en/customcert.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['addcertpage'] = 'Add another certificate page'; +$string['addcertpage'] = 'Add page'; $string['addelement'] = 'Add element'; $string['awardedto'] = 'Awarded to'; $string['certificate'] = 'Certificate'; diff --git a/styles.css b/styles.css index 04a6aa0..9fbe30b 100644 --- a/styles.css +++ b/styles.css @@ -2,6 +2,11 @@ text-align: right; } +#page-mod-customcert-edit .addpage { + border-top: 1px solid #f4f4f4; + text-align: right; +} + #page-mod-customcert-edit #id_replace { margin-left: 10px; }