mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-22338 PDFs now display in resources :/
This commit is contained in:
parent
26ffb4b172
commit
b8037d7316
3 changed files with 30 additions and 3 deletions
|
@ -409,6 +409,30 @@ EOT;
|
||||||
return $code;
|
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.
|
* Returns general link or file embedding html.
|
||||||
* @param string $fullurl
|
* @param string $fullurl
|
||||||
|
@ -448,7 +472,7 @@ EOT;
|
||||||
</object>
|
</object>
|
||||||
</div>
|
</div>
|
||||||
EOT;
|
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;
|
return $code;
|
||||||
|
|
|
@ -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
|
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
|
||||||
$code = resourcelib_embed_image($fullurl, $title);
|
$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') {
|
} else if ($mimetype == 'audio/mp3') {
|
||||||
// MP3 audio file
|
// MP3 audio file
|
||||||
$code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
|
$code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#page-mod-resource-view .resourcecontent.resourcepdf {width: 100%;}
|
|
||||||
.path-mod-resource .popupnotice {text-align:center;margin:40px;}
|
.path-mod-resource .popupnotice {text-align:center;margin:40px;}
|
||||||
|
|
||||||
.resourcecontent object {height:480px;width:600px;}
|
.resourcecontent object {height:480px;width:600px;}
|
||||||
.resourcecontent.resourcepdf object{height: 800px;width: 800px;}
|
.resourcecontent.resourcepdf object{height: 800px;width: 100%;}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue