Skip to content

Commit

Permalink
MDL-22338 PDFs now display in resources :/
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Jun 29, 2010
1 parent 26ffb4b commit b8037d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
26 changes: 25 additions & 1 deletion lib/resourcelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,30 @@ function resourcelib_embed_real($fullurl, $title, $clicktoopen) {
return $code;
}

/**
* Returns general link or pdf embedding html.
* @param string $fullurl
* @param string $title
* @param string $clicktoopen
* @return string html
*/
function resourcelib_embed_pdf($fullurl, $title, $clicktoopen) {
global $CFG, $PAGE;

$code = <<<EOT
<div class="resourcecontent resourcepdf">
<object id="resourceobject" data="$fullurl" type="application/pdf">
<param name="src" value="$fullurl" />
$clicktoopen
</object>
</div>
EOT;
//$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);

return $code;
}


/**
* Returns general link or file embedding html.
* @param string $fullurl
Expand Down Expand Up @@ -448,7 +472,7 @@ function resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype) {
</object>
</div>
EOT;
$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
//$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
}

return $code;
Expand Down
4 changes: 4 additions & 0 deletions mod/resource/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function resource_display_embed($resource, $cm, $course, $file) {
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
$code = resourcelib_embed_image($fullurl, $title);

} else if ($mimetype == 'application/pdf') {
// PDF document
$code = resourcelib_embed_pdf($fullurl, $title, $clicktoopen);

} else if ($mimetype == 'audio/mp3') {
// MP3 audio file
$code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
Expand Down
3 changes: 1 addition & 2 deletions mod/resource/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#page-mod-resource-view .resourcecontent.resourcepdf {width: 100%;}
.path-mod-resource .popupnotice {text-align:center;margin:40px;}

.resourcecontent object {height:480px;width:600px;}
.resourcecontent.resourcepdf object{height: 800px;width: 800px;}
.resourcecontent.resourcepdf object{height: 800px;width: 100%;}

0 comments on commit b8037d7

Please sign in to comment.