diff --git a/attachments_component/admin/config.xml b/attachments_component/admin/config.xml index 567ff945..76a66338 100644 --- a/attachments_component/admin/config.xml +++ b/attachments_component/admin/config.xml @@ -255,6 +255,13 @@ + + + +
input->getInt('raw', 0); + $popup = $this->input->getInt('popup', 0); // NOTE: The helper download_attachment($id) function does the access check - AttachmentsHelper::download_attachment($id); + AttachmentsHelper::download_attachment($id, $raw, $popup); } diff --git a/attachments_component/site/src/Helper/AttachmentsHelper.php b/attachments_component/site/src/Helper/AttachmentsHelper.php index b723ec8a..5d050936 100644 --- a/attachments_component/site/src/Helper/AttachmentsHelper.php +++ b/attachments_component/site/src/Helper/AttachmentsHelper.php @@ -1506,7 +1506,7 @@ public static function add_url(&$attachment, &$parent, $verify, $relative_url=fa * * @param int $id the attachment id */ - public static function download_attachment($id) + public static function download_attachment($id, $raw=0, $popup=0) { $base_url = Uri::base(false); @@ -1614,14 +1614,19 @@ public static function download_attachment($id) } // Force the download - if ($download_mode == 'attachment') { - // attachment - header("Content-Disposition: attachment; filename=\"$mod_filename\""); + $content_disposition = 'attachment'; + // in popup model attachment is inline + if ( $popup == 1 ) { + $content_disposition = 'inline'; } - else { + else if ( $raw == 1 ) { // inline - header("Content-Disposition: inline; filename=\"$mod_filename\""); + $content_disposition = 'attachment'; } + else if ($download_mode != 'attachment' ) { + $content_disposition = 'inline'; + } + header("Content-Disposition: ". $content_disposition ."; filename=\"$mod_filename\""); header('Content-Transfer-Encoding: binary'); header("Content-Type: $content_type"); diff --git a/attachments_component/site/src/View/Attachments/HtmlView.php b/attachments_component/site/src/View/Attachments/HtmlView.php index 2d48267d..84360642 100644 --- a/attachments_component/site/src/View/Attachments/HtmlView.php +++ b/attachments_component/site/src/View/Attachments/HtmlView.php @@ -179,6 +179,7 @@ public function display($tpl = null) $this->show_created_date = $params->get('show_created_date', false); $this->show_modified_date = $params->get('show_modified_date', false); $this->file_link_open_mode = $params->get('file_link_open_mode', 'in_same_window'); + $this->show_raw_download = $params->get('show_raw_download', false); // Set up the file/url titleshow_mod_date if ( $this->show_column_titles ) { diff --git a/attachments_component/site/tmpl/attachments/default.php b/attachments_component/site/tmpl/attachments/default.php index 38a9f982..88d7a81c 100644 --- a/attachments_component/site/tmpl/attachments/default.php +++ b/attachments_component/site/tmpl/attachments/default.php @@ -233,6 +233,7 @@ $modalParams['width'] = '80%'; $modalParams['bodyHeight'] = '80'; $modalParams['modalWidth'] = '80'; + $url .= "&popup=1"; $html .= LayoutHelper::render( 'libraries.html.bootstrap.modal.main', [ @@ -280,7 +281,7 @@ $is_empty = 0; if ( StringHelper::strlen($description) == 0) { $description = ' '; - $is_empty = 1; + $is_empty = 1; } if ( $this->show_column_titles ) @@ -298,7 +299,7 @@ $is_empty = 0; if ( StringHelper::strlen($user_field) == 0 ) { $user_field = ' '; - $is_empty = 1; + $is_empty = 1; } if ( $this->show_column_titles ) @@ -315,7 +316,7 @@ $is_empty = 0; if ( StringHelper::strlen($user_field) == 0 ) { $user_field = ' '; - $is_empty = 1; + $is_empty = 1; } if ( $this->show_column_titles ) @@ -332,7 +333,7 @@ $is_empty = 0; if ( StringHelper::strlen($user_field) == 0 ) { $user_field = ' '; - $is_empty = 1; + $is_empty = 1; } if ( $this->show_column_titles ) @@ -358,7 +359,13 @@ } $html .= '' . $file_size_str . ''; } - + if ( $this->show_raw_download && $show_in_modal ) { + $url = Route::_($base_url . "index.php?option=com_attachments&task=download&id=" . (int)$attachment->id . "&raw=1"); + $html .= ''; + $tooltip = Text::sprintf('ATTACH_DOWNLOAD_THIS_FILE_S', $actual_filename); + $html .= "" . + HTMLHelper::image("com_attachments/download.gif", "", null, true) . ''; + } // Show number of downloads (maybe) if ( $this->secure && $this->show_downloads ) { $num_downloads = (int)$attachment->download_count; diff --git a/attachments_plugin/language/en-GB/en-GB.plg_content_attachments.ini b/attachments_plugin/language/en-GB/en-GB.plg_content_attachments.ini index 28ae4105..6732b1c3 100644 --- a/attachments_plugin/language/en-GB/en-GB.plg_content_attachments.ini +++ b/attachments_plugin/language/en-GB/en-GB.plg_content_attachments.ini @@ -29,3 +29,4 @@ ATTACH_LAST_MODIFIED="Last modified" ATTACH_REALLY_DELETE_ATTACHMENT="Really delete attachment?" ATTACH_UPDATE_THIS_FILE="Update this file" ATTACH_URL="URL" +ATTACH_VIEW_THIS_ATTACHMENT="View this File" diff --git a/attachments_plugin/language/fr-FR/fr-FR.plg_content_attachments.ini b/attachments_plugin/language/fr-FR/fr-FR.plg_content_attachments.ini index e1edcc9e..1ebac005 100644 --- a/attachments_plugin/language/fr-FR/fr-FR.plg_content_attachments.ini +++ b/attachments_plugin/language/fr-FR/fr-FR.plg_content_attachments.ini @@ -29,3 +29,4 @@ ATTACH_REALLY_DELETE_ATTACHMENT="Voulez-vous vraiment supprimer cette pièce joi ATTACH_S_KB="%s Ko" ATTACH_UPDATE_THIS_FILE="Mettre à jour ce fichier" ATTACH_URL="Adresse URL" +ATTACH_VIEW_THIS_ATTACHMENT="Voir cette pièce jointe"