Skip to content

Commit

Permalink
Fix #6
Browse files Browse the repository at this point in the history
Fix: long filenames in jDownloads do not work #6
Improved: small codes changes.
  • Loading branch information
Tazzios committed Jul 26, 2021
1 parent d93e208 commit 6e1b336
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions pdfviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 {
Expand All @@ -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' );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -380,7 +380,7 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) {

JHTML::_('behavior.modal');

return '<a class="modal" rel="{handler: \'iframe\', size: {x:'. $width .', y:'. $height .'}}" /*x is width */ href="data:image/jpg;base64,'. base64_encode($img) . '">'. $linktext .'</a>';
return '<a class="modal" rel="{handler: \'iframe\', size: {x:'. $width .', y:'. $height .'}}" href="data:image/jpg;base64,'. base64_encode($img) . '">'. $linktext .'</a>';
}
// New window
IF ($style=='new') {
Expand Down

0 comments on commit 6e1b336

Please sign in to comment.