Skip to content

Commit

Permalink
fix download comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anisa kusumadewi committed Nov 7, 2022
1 parent 3b3b291 commit e4cf369
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
1 change: 1 addition & 0 deletions lang/en/pdfannotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
$string['error:getAnnotations'] = 'An error has occured while getting all annotations.';
$string['error:getComments'] = 'An error has occured while getting the comments.';
$string['error:getQuestions'] = 'An error has occured while getting the questions for this page.';
$string['error:printComments'] = 'Error with data from server.';
$string['error:hideComment'] = "An error has occured while trying to hide the comment from participants' view.";
$string['error:markasread'] = 'The item could not be marked as read.';
$string['error:markasunread'] = 'The item could not be marked as unread.';
Expand Down
13 changes: 11 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
// Load and execute the javascript files.
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00033"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00034"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));

// Pass parameters from PHP to JavaScript.
Expand Down Expand Up @@ -167,7 +167,7 @@ function pdfannotator_extract_images($contentarr, $itemid, $context=null) {
}

function pdfannotator_split_content_image($content, $res, $itemid, $context=null) {

global $CFG;
// Gets all files in the comment with id itemid.
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_pdfannotator', 'post', $itemid);
Expand Down Expand Up @@ -226,6 +226,15 @@ function pdfannotator_split_content_image($content, $res, $itemid, $context=null
$data['filename'] = $tempinfo['filename'];
$data['filepath'] = $tempinfo['filepath'];
$data['filesize'] = $tempinfo['filesize'];
$data['imagestorage'] = 'intern';
} else if (!str_contains($CFG->wwwroot, $url[0])){
$data['imagestorage'] = 'extern';
$data['format'] = $format[0];
$data['image'] = 'data:image/' . $format[0] . ";base64," . base64_encode(file_get_contents($url[0]));
// $data['image'] = $url[0];
} else {
$data['success'] = "error";
$data['message'] = "cannot load image";
}

preg_match('/height=[0-9]+/', $imgstr, $height);
Expand Down
46 changes: 22 additions & 24 deletions shared/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_pdfannotator';
$plugin->version = 2022110201;
$plugin->version = 2022110700;
$plugin->release = 'PDF Annotator v1.4 release 11';
$plugin->requires = 2021051700;
$plugin->maturity = MATURITY_STABLE;

0 comments on commit e4cf369

Please sign in to comment.