Removed the 'Download grid' functionality

This commit is contained in:
Mark Nelson 2015-12-06 16:54:19 +08:00
parent 4efbac65ff
commit 87d1ecfcc7
4 changed files with 2 additions and 90 deletions

View file

@ -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.

View file

@ -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'));

View file

@ -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

View file

@ -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.
*