From d93e208c0461d8a62c00b102510321ddd82eaa22 Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Mon, 26 Jul 2021 18:04:29 +0200 Subject: [PATCH 1/2] Create workspace.xml Fix: long filenames in jDownloads do not work #6 Improved: small codes changes. --- .idea/workspace.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..2975134 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1625298795598 + + + + + + \ No newline at end of file From 6e1b336287c889d85a4c2977867ec7ba305de4cf Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Mon, 26 Jul 2021 18:06:35 +0200 Subject: [PATCH 2/2] Fix #6 Fix: long filenames in jDownloads do not work #6 Improved: small codes changes. --- Changelog.md | 4 ++++ pdfviewer.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 174811e..2436d59 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ +V1.1.1 + +Fix: long filenames in jDownloads do not work #6 +Improved: small codes changes. V1.1.0 New: PDFjs override [TEMPLATE]/html/plg_content_pdfviewer/assets/pdfjs/web/viewer.html diff --git a/pdfviewer.php b/pdfviewer.php index 2f944d6..e016477 100644 --- a/pdfviewer.php +++ b/pdfviewer.php @@ -54,7 +54,8 @@ public function onContentPrepare($context, &$article, &$params, $page = 0) //Transform the keys and values from the tag to an array //Delete space around the = and replace others by , to put then in an array - $tagparams = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $match[1]); // remove blank + $tagparams = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $match[1]); // remove blank + $tagparams = strip_tags($tagparams); //Remove htmlcode see: https://github.com/Tazzios/pdfviewer/issues/6 $tagparams = str_replace(' =','=', $tagparams); //avoid that key and value are seprated @@ -256,7 +257,7 @@ function CreatePdfviewer($filelink,$search,$pagenumber,$height,$width,$style,$li $height = 'height:'. $height . 'px;' ; - // If width is numeric then px else asume there is a % + // If width is numeric then px else assume there is a % if (is_numeric($width)) { $width = 'width:' .$width. 'px;'; } else { @@ -283,8 +284,7 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) { // code based on https://www.binarytides.com/convert-pdf-image-imagemagick-php/ //imagick needs a local path - $filelink = ''; - + // get root dir from jdownloads $jdownloads_params = JComponentHelper::getParams( 'com_jdownloads' ); $root_dir = $jdownloads_params->get( 'root_dir' ); @@ -315,12 +315,12 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) { $cat = $categories->get($cat_id); if ($cat->cat_dir_parent<>''){ - $cat_parents = '/' . $cat->cat_dir_parent; + $cat_parents = '. DS.' . $cat->cat_dir_parent; } - + //Full file link - $filelink = $root_dir . $cat_parents . '/'. $cat->title. '/' . $filename; + $filelink = $root_dir . $cat_parents . DS . $cat->title. DS . $filename; // Imagick starts with page 0 @@ -365,7 +365,7 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) { $height = ' height='. $height . 'px;' ; - // If width is numeric then px else asume there is a % + // If width is numeric then px else assume there is a % if (is_numeric($width)) { $width = ' width=' . $width . ''; } else { @@ -380,7 +380,7 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) { JHTML::_('behavior.modal'); - return ''. $linktext .''; + return ''. $linktext .''; } // New window IF ($style=='new') {