Skip to content

Commit

Permalink
#35 Reworded 'addcertpage' string and changed button to a link
Browse files Browse the repository at this point in the history
Also added an icon next to the link and moved the location via CSS.
  • Loading branch information
mdjnelson committed Aug 7, 2017
1 parent b626e4f commit 971a3fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
12 changes: 6 additions & 6 deletions classes/edit_form.php
Expand Up @@ -55,7 +55,7 @@ class edit_form extends \moodleform {
* Form definition.
*/
public function definition() {
global $DB;
global $DB, $OUTPUT;

$mform =& $this->_form;

Expand All @@ -80,11 +80,11 @@ public function definition() {
$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();
Expand Down
11 changes: 5 additions & 6 deletions edit.php
Expand Up @@ -66,7 +66,6 @@
$PAGE->navbar->add(get_string('editcustomcert', 'customcert'));
}


// Flag to determine if we are deleting anything.
$deleting = false;

Expand All @@ -84,6 +83,11 @@
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);
Expand Down Expand Up @@ -182,11 +186,6 @@
// 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.
Expand Down
2 changes: 1 addition & 1 deletion lang/en/customcert.php
Expand Up @@ -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';
Expand Down
5 changes: 5 additions & 0 deletions styles.css
Expand Up @@ -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;
}
Expand Down

0 comments on commit 971a3fd

Please sign in to comment.