From 87d1ecfcc7c96e9c0a5ea85f86e7a276f353fa36 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sun, 6 Dec 2015 16:54:19 +0800 Subject: [PATCH] Removed the 'Download grid' functionality --- edit.php | 8 ++--- edit_form.php | 2 -- lang/en/customcert.php | 1 - locallib.php | 81 ------------------------------------------ 4 files changed, 2 insertions(+), 90 deletions(-) diff --git a/edit.php b/edit.php index 98de3b8..23c5963 100644 --- a/edit.php +++ b/edit.php @@ -163,12 +163,8 @@ if ($data = $mform->get_data()) { // Loop through the data. foreach ($data as $key => $value) { - // Check if they wanted to download the grid PDF. - if (strpos($key, 'downloadgrid_') !== false) { - // Get the page id. - $pageid = str_replace('downloadgrid_', '', $key); - customcert_generate_grid_pdf($pageid); - } else if (strpos($key, 'addelement_') !== false) { // Check if they chose to add an element to a page. + // Check if they chose to add an element to a page. + if (strpos($key, 'addelement_') !== false) { // Get the page id. $pageid = str_replace('addelement_', '', $key); // Get the element. diff --git a/edit_form.php b/edit_form.php index 511e4b0..3ef344b 100644 --- a/edit_form.php +++ b/edit_form.php @@ -187,8 +187,6 @@ class mod_customcert_edit_form extends moodleform { $mform->setType('pagemargin_' . $page->id, PARAM_INT); $mform->addHelpButton('pagemargin_' . $page->id, 'margin', 'customcert'); - $mform->addElement('submit', 'downloadgrid_' . $page->id, get_string('downloadgrid', 'customcert')); - $group = array(); $group[] = $mform->createElement('select', 'element_' . $page->id, '', customcert_get_elements()); $group[] = $mform->createElement('submit', 'addelement_' . $page->id, get_string('addelement', 'customcert')); diff --git a/lang/en/customcert.php b/lang/en/customcert.php index bc3e8f3..0469ab5 100644 --- a/lang/en/customcert.php +++ b/lang/en/customcert.php @@ -47,7 +47,6 @@ $string['deleteelement'] = 'Delete element'; $string['deleteelementconfirm'] = 'Are you sure you want to delete this element?'; $string['deletepageconfirm'] = 'Are you sure you want to delete this certificate page?'; $string['description'] = 'Description'; -$string['downloadgrid'] = 'Download grid'; $string['editcustomcert'] = 'Edit custom certificate'; $string['elementname'] = 'Element name'; $string['elementname_help'] = 'This will be the name used to identify this element when editing a custom certificate. For example, you may have multiple images on a diff --git a/locallib.php b/locallib.php index 73b2d83..7dd89e7 100644 --- a/locallib.php +++ b/locallib.php @@ -587,87 +587,6 @@ function customcert_generate_code() { return $code; } -/** - * Generate the grid PDF to show the layout of the PDF. - * - * @param int $pageid the customcert page - */ -function customcert_generate_grid_pdf($pageid) { - global $CFG, $DB; - - require_once($CFG->libdir . '/pdflib.php'); - - // Get the page. - $page = $DB->get_record('customcert_pages', array('id' => $pageid), '*', MUST_EXIST); - - // Set the PDF name. - $pdfname = get_string('gridpdfname', 'customcert', $page->id); - - // Create the pdf object. - $pdf = new pdf(); - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - $pdf->SetTitle($pdfname); - $pdf->SetMargins(0, 0); - $pdf->SetAutoPageBreak(true, 0); - - // Add the page to the PDF. - if ($page->width > $page->height) { - $orientation = 'L'; - } else { - $orientation = 'P'; - } - $pdf->AddPage($orientation, array($page->width, $page->height)); - - // The cell width. - $cellwidth = 10; - $cellheight = 10; - - // The increments we want to go up in. - $inc = 20; - $decpos = 4; - - // Draw first lines before we increment from here. - $pdf->Line(($inc / 2) + 2, 0, ($inc / 2) + 2, $page->height); - $pdf->Line(0, ($inc / 2), $page->width, ($inc / 2)); - - // Now we want to start drawing the lines to make the grid. - // Draw the horizontal lines. - for ($h = $inc; $h <= $page->height; $h += $inc) { - // Dirty hack cause the printer keeps cutting off characters - // near the end of the page for some BS reason. - if (strlen($h) <= 2) { - $lmargin = 5; - } else { - $lmargin = 4; - } - // Write the distance we are at. - $pdf->writeHTMLCell($cellwidth, $cellheight, $lmargin, $h - $decpos, $h); - - // Get the location we are going to draw the line and then draw it. - $hline = $h + ($inc / 2); - $pdf->Line(0, $hline, $page->width, $hline); - } - - // Draw the vertical lines. - for ($w = $inc; $w <= $page->width; $w += $inc) { - // Write the distance we are at. - $pdf->writeHTMLCell($cellwidth, $cellheight, $w - $decpos, 3, $w); - - // Get the location we are going to draw the line and then draw it. - $wline = $w + ($inc / 2); - $pdf->Line($wline, 0, $wline, $page->height); - } - - // Draw the margin line. - if (!empty($page->margin)) { - $pdf->Line($page->width - $page->margin, 0, $page->width - $page->margin, $page->height, array('dash' => '2')); - } - - $pdf->Output($pdfname . '.pdf', 'D'); - exit(); -} - /** * Generate the PDF for the specified customcert and user. *