Skip to content
Permalink
Browse files

PDF view with viewerjs in LP

  • Loading branch information...
aragonc committed Nov 8, 2018
1 parent 92962a9 commit ad1ecb2b28f92ef7afce5ace00202e3aac19fb20
Showing with 27 additions and 0 deletions.
  1. +18 −0 main/inc/lib/link.lib.php
  2. +9 −0 main/lp/learnpath.class.php
@@ -1564,6 +1564,24 @@ public static function is_youtube_link($url)
return $is_youtube_link;
}
/**
* This function checks if the url is a PDF File link.
*
* @author Jorge Frisancho
* @author Alex Aragón - Fixing code
*
* @version 1.0
*/
public static function is_pdf_link($url)
{
$is_pdf_link = strrpos($url, ".pdf") || strrpos(
$url,
".PDF"
);
return $is_pdf_link;
}
/**
* Get youtube id from an URL.
*
@@ -3665,6 +3665,14 @@ public function get_link($type = 'http', $item_id = null, $provided_toc = false)
}
switch ($lp_item_type) {
case 'document':
if(api_get_configuration_value('allow_pdf_viewerjs_in_lp')){
if(Link::is_pdf_link($file)){
$pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html#'.$file;
$file = $pdfUrl;
}
}
break;
case 'dir':
$file = 'lp_content.php?type=dir';
break;
@@ -3742,6 +3750,7 @@ public function get_link($type = 'http', $item_id = null, $provided_toc = false)
}
$tmp_array = explode('/', $file);
$document_name = $tmp_array[count($tmp_array) - 1];
if (strpos($document_name, '_DELETED_')) {
$file = 'blank.php?error=document_deleted';

0 comments on commit ad1ecb2

Please sign in to comment.
You can’t perform that action at this time.