Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions attachments_component/admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@
<option value="attachment">ATTACH_ATTACHMENT</option>
<option value="inline">ATTACH_INLINE</option>
</field>
<field name="show_raw_download" type="radio" default="0" layout="joomla.form.field.radio.switcher"
label="ATTACH_SHOW_RAW_DOWNLOAD"
description="ATTACH_SHOW_RAW_DOWNLOAD_DESCRIPTION"
showon="download_mode:inline[AND]file_link_open_mode:in_a_popup">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>

<fieldset name="permissions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ ATTACH_SHOW_MODIFICATION_DATE="Εμφάνιση ημερομηνίας τροπ
ATTACH_SHOW_MODIFICATION_DATE_DESCRIPTION="Ορίζει αν η ημερομηνία τροποποίησης για το συνημμένο πρέπει να εμφανίζεται."
ATTACH_SHOW_NUMBER_OF_DOWNLOADS="Εμφάνιση αριθμού λήψεων;"
ATTACH_SHOW_NUMBER_OF_DOWNLOADS_DESCRIPTION="Εμφάνιση του αριθμού των λήψεων. ΠΡΟΕΙΔΟΠΟΙΗΣΗ: Αυτή η επιλογή λειτουργεί μόνο σε ασφαλή λειτουργία."
ATTACH_SHOW_RAW_DOWNLOAD="Εμφάνιση εικονιδίου λήψης για αρχεία που ανοίγουν σε αναδυόμενο παράθυρο"
ATTACH_SHOW_RAW_DOWNLOAD_DESCRIPTION="Αυτή η επιλογή εμφανίζει ένα εικονίδιο δίπλα από το σύνδεσμο του συνημμένου που επιτρέπει τη λήψη του αρχείου αντί για εμφάνιση του αρχείου σε αναδυόμενο παράθυρο."
ATTACH_SORT_ATTACHMENT_ID="ID Συνημμένου (σειρά επισύναψης)"
ATTACH_SORT_CREATED_DATE="Ημερομηνία δημιουργίας (παλαιότερο πρώτο)"
ATTACH_SORT_CREATED_DATE_DESCENDING="Ημερομηνία δημιουργίας (νεότερο πρώτο)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ ATTACH_SHOW_MODIFICATION_DATE="Show attachment modification date?"
ATTACH_SHOW_MODIFICATION_DATE_DESCRIPTION="Sets whether the modification date for the attachment should be shown."
ATTACH_SHOW_NUMBER_OF_DOWNLOADS="Show number of downloads?"
ATTACH_SHOW_NUMBER_OF_DOWNLOADS_DESCRIPTION="Show the number of downloads. WARNING: This option only works in secure mode."
ATTACH_SHOW_RAW_DOWNLOAD="Show a download icon"
ATTACH_SORT_ATTACHMENT_ID="Attachment ID (order of attachment)"
ATTACH_SORT_CREATED_DATE="Creation date (oldest first)"
ATTACH_SORT_CREATED_DATE_DESCENDING="Creation date (newest first)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ ATTACH_SHOW_MODIFICATION_DATE="Afficher la date de modification de la pièce joi
ATTACH_SHOW_MODIFICATION_DATE_DESCRIPTION="Définit si la date de modification pour la pièce jointe doit être montrée."
ATTACH_SHOW_NUMBER_OF_DOWNLOADS="Afficher le nombre de téléchargements ?"
ATTACH_SHOW_NUMBER_OF_DOWNLOADS_DESCRIPTION="Affiche le nombre de téléchargements. Attention: cette option fonctionne seulement en mode sécurisé."
ATTACH_SHOW_RAW_DOWNLOAD="Affiche une icône de download"
ATTACH_SORT_ATTACHMENT_ID="ID de la pièce jointe"
ATTACH_SORT_CREATED_DATE="Date de création (plus ancienne en premier)"
ATTACH_SORT_CREATED_DATE_DESCENDING="Date de création (plus récente en premier)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,10 @@ public function download()
$errmsg = Text::sprintf('ATTACH_ERROR_INVALID_ATTACHMENT_ID_N', $id) . ' (ERR 12)';
throw new \Exception($errmsg, 500);
}

$raw = $this->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);
}


Expand Down
17 changes: 11 additions & 6 deletions attachments_component/site/src/Helper/AttachmentsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
17 changes: 12 additions & 5 deletions attachments_component/site/tmpl/attachments/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
$modalParams['width'] = '80%';
$modalParams['bodyHeight'] = '80';
$modalParams['modalWidth'] = '80';
$url .= "&popup=1";
$html .= LayoutHelper::render(
'libraries.html.bootstrap.modal.main',
[
Expand Down Expand Up @@ -280,7 +281,7 @@
$is_empty = 0;
if ( StringHelper::strlen($description) == 0) {
$description = '&nbsp;';
$is_empty = 1;
$is_empty = 1;
}

if ( $this->show_column_titles )
Expand All @@ -298,7 +299,7 @@
$is_empty = 0;
if ( StringHelper::strlen($user_field) == 0 ) {
$user_field = '&nbsp;';
$is_empty = 1;
$is_empty = 1;
}

if ( $this->show_column_titles )
Expand All @@ -315,7 +316,7 @@
$is_empty = 0;
if ( StringHelper::strlen($user_field) == 0 ) {
$user_field = '&nbsp;';
$is_empty = 1;
$is_empty = 1;
}

if ( $this->show_column_titles )
Expand All @@ -332,7 +333,7 @@
$is_empty = 0;
if ( StringHelper::strlen($user_field) == 0 ) {
$user_field = '&nbsp;';
$is_empty = 1;
$is_empty = 1;
}

if ( $this->show_column_titles )
Expand All @@ -358,7 +359,13 @@
}
$html .= '<td class="at_file_size">' . $file_size_str . '</td>';
}

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 .= '<td class="at_icon">';
$tooltip = Text::sprintf('ATTACH_DOWNLOAD_THIS_FILE_S', $actual_filename);
$html .= "<a class=\"". $a_class . "\" href=\"$url\"$target title=\"$tooltip\">" .
HTMLHelper::image("com_attachments/download.gif", "", null, true) . '</a></td>';
}
// Show number of downloads (maybe)
if ( $this->secure && $this->show_downloads ) {
$num_downloads = (int)$attachment->download_count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"