Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3135

report.class.php print_template rewriting for easy use of mpdf

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      PostgreSQL 8.4
    • Database:
      PostgreSQL
    • Workaround:
      Hide

      Edit:
      /var/www/blocks/configurable_reports/report.class.php
      Check for print_template function.
      Now the change is pretty simple. Every echo instruction has to be converted into a variable definition.
      I join some lines so that you understand what I mean:
      $print_template_html="<div id=\"printablediv\">\n";
      $print_template_html.=format_text($page_contents['header'], FORMAT_HTML);

      The only lines that do ot have to be inside the variable are (These are not the original lines but modified ones):
      <div class="centerpara"><br />';
      "<img src=\"{$CFG->wwwroot}/blocks/configurable_reports/img/print.png\" alt=\".get_string('printreport','block_configurable_reports')\"> <a href=\"javascript: printDiv('printablediv')\">".get_string('printreport','block_configurable_reports')."</a>";
      "</div>\n";

      Once $print_template_html is defined I can add my pdf button with this piece of code:

      global $CFG;
      include($CFG->libdir.'/mpdf/print.php');
      show_pdf_icon($print_template_html, false, false, 'absolute', '10px', '50px');

      Optionally you can run:
      echo $print_template_html;
      before the lines that do not have to modified so that the configurable reports behaviour remains the same except for the pdf button.

      I am using a hacked version of mpdf for moodle 19. I am actually going to post some bugs on it.

      Show
      Edit: /var/www/blocks/configurable_reports/report.class.php Check for print_template function. Now the change is pretty simple. Every echo instruction has to be converted into a variable definition. I join some lines so that you understand what I mean: $print_template_html="<div id=\"printablediv\">\n"; $print_template_html.=format_text($page_contents ['header'] , FORMAT_HTML); The only lines that do ot have to be inside the variable are (These are not the original lines but modified ones): <div class="centerpara"><br />'; "<img src=\"{$CFG->wwwroot}/blocks/configurable_reports/img/print.png\" alt=\".get_string('printreport','block_configurable_reports')\"> <a href=\"javascript: printDiv('printablediv')\">".get_string('printreport','block_configurable_reports')."</a>"; "</div>\n"; Once $print_template_html is defined I can add my pdf button with this piece of code: global $CFG; include($CFG->libdir.'/mpdf/print.php'); show_pdf_icon($print_template_html, false, false, 'absolute', '10px', '50px'); Optionally you can run: echo $print_template_html; before the lines that do not have to modified so that the configurable reports behaviour remains the same except for the pdf button. I am using a hacked version of mpdf for moodle 19. I am actually going to post some bugs on it.
    • Affected Branches:
      MOODLE_21_STABLE

      Description

      I am trying to integrate the mpdf extension into configurable reports.
      http://moodle.org/mod/data/view.php?d=13&rid=3907
      Basically what I do is add a button that thanks to some html code generates a pdf.

      I have found that the best way to integrate it into configurable reports is editing print_template function in report.class.php file.

      I will describe at workaround section what lines to modify.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: