Skip to content

Commit

Permalink
Issue jmcameron#92 show attachments in a popup
Browse files Browse the repository at this point in the history
implement Issue jmcameron#92
correct also language $lang->load('plg_attachments_framework')
  • Loading branch information
JLTRY committed Dec 13, 2024
1 parent 1c601de commit e106799
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
3 changes: 2 additions & 1 deletion attachments_component/admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@
label="ATTACH_CSS_STYLE_FOR_ATTACHMENTS_TABLES" size="40"
description="ATTACH_CSS_STYLE_FOR_ATTACHMENTS_TABLES_DESCRIPTION">
</field>
<field name="file_link_open_mode" type="radio" default="in_same_window" layout="joomla.form.field.radio.switcher"
<field name="file_link_open_mode" type="radio" default="in_same_window" class="btn-group btn-group-yesno"
label="ATTACH_FILE_LINK_OPEN_MODE"
description="ATTACH_FILE_LINK_OPEN_MODE_DESCRIPTION">
<option value="new_window">ATTACH_IN_NEW_WINDOW</option>
<option value="in_same_window">ATTACH_IN_SAME_WINDOW</option>
<option value="in_a_popup">ATTACH_IN_A_POPUP</option>
</field>
<field name="attachments_titles" type="textarea" default=""
label="ATTACH_CUSTOM_TITLES_FOR_ATTACHMENTS_LISTS" rows="3" cols="60"
Expand Down
3 changes: 3 additions & 0 deletions attachments_component/admin/src/View/Add/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class HtmlView extends BaseHtmlView
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$lang = $app->getLanguage();
$lang->load('plg_attachments_framework', JPATH_PLUGINS . '/attachments/framework');
// For convenience below
$attachment = $this->attachment;
$parent_id = $attachment->parent_id;
Expand Down
40 changes: 37 additions & 3 deletions attachments_component/site/tmpl/attachments/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,40 @@
$tooltip = Text::sprintf('ATTACH_ACCESS_THIS_URL_S', $attachment->url);
}
}
$html .= "<a class=\"at_icon\" href=\"$url\"$target title=\"$tooltip\">";
$html .= HTMLHelper::image('com_attachments/file_icons/'.$icon, $tooltip, null, true);
if ( $this->file_link_open_mode == 'in_a_popup' ) {
$a_class = 'modal-button mx-2';
} else {
$a_class = 'at_icon';
}
if ( $this->file_link_open_mode == 'in_a_popup' ) {
$randomId = base64_encode('show'.$actual_filename);
// Remove +,/,= from the $randomId
$randomId = strtr($randomId, "+/=", "AAA");
$modalParams['title'] = $this->escape($tooltip);
$modalParams['url'] = $url;
$modalParams['height'] = '80%';
$modalParams['width'] = '80%';
$modalParams['bodyHeight'] = '800';
$modalParams['modalWidth'] = '1000';
$html .= LayoutHelper::render(
'libraries.html.bootstrap.modal.main',
[
'selector' => 'modal-' . $randomId,
'body' => "<iframe src=\"$url\" scrolling=\"auto\" loading=\"lazy\" height=\"750\" width=\"750\"></iframe>",
'params' => $modalParams
]
);

$show_link = "<a class=\"$a_class\" type=\"button\" data-bs-toggle='modal' data-bs-target='#modal-$randomId'";
$show_link .= "title=\"$tooltip\">";
$show_link .= HTMLHelper::image('com_attachments/file_icons/'.$icon, $tooltip, null, true);
$show_link .= "&nbsp;" . $filename . "</a>";
}
else {
$show_link = "<a class=\"". $a_class . "\" href=\"$url\"$target title=\"$tooltip\">";
$show_link .= HTMLHelper::image('com_attachments/file_icons/'.$icon, $tooltip, null, true);
}
$html .= $show_link;
if ( ($attachment->uri_type == 'url') && $this->superimpose_link_icons ) {
if ( $attachment->url_valid ) {
$html .= HTMLHelper::image('com_attachments/file_icons/link_arrow.png', '', 'class="link_overlay"', true);
Expand All @@ -222,7 +254,9 @@
}
}
$html .= "</a>";
$html .= "<a class=\"at_url\" href=\"$url\"$target title=\"$tooltip\">$filename</a>";
if ( $this->file_link_open_mode != 'in_a_popup' ) {
$html .= "<a class=\"at_url\" href=\"$url\"$target title=\"$tooltip\">$filename</a>";
}
}
else {
$tooltip = Text::sprintf('ATTACH_DOWNLOAD_THIS_FILE_S', $actual_filename);
Expand Down
4 changes: 1 addition & 3 deletions attachments_plugin_framework/src/PlgAttachmentsFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function getCanonicalEntityId($parent_entity)
else
{
$lang = $this->app->getLanguage();
$lang->load('plg_attachments_plugin_framework', JPATH_PLUGINS . '/attachments/framework');
$lang->load('plg_attachments_framework', JPATH_PLUGINS . '/attachments/framework');
$errmsg = Text::sprintf('ATTACH_ERROR_INVALID_ENTITY_S_FOR_PARENT_S', $parent_entity, $this->parent_type) . ' (ERR 300)';
throw new \Exception($errmsg, 500);
}
Expand Down Expand Up @@ -922,8 +922,6 @@ public function insertAttachmentsList(&$content, $parent_id, $parent_entity)
{
$attachments_tag[] = $match[0];
}

var_dump($match);
if (($attachments_placement === "custom") && isset($match["arguments"]) && $match["arguments"])
{
$attachments_tag_args_raw = $match["arguments"];
Expand Down
11 changes: 11 additions & 0 deletions pkg_attachments/language/fr-FR/fr-FR.pkg_attachments.sys.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; en-GB.com_attachments.sys.ini (installation)
; Attachments for Joomla! extension
; Copyright (C) 2011-2018 Jonathan M. Cameron, All rights reserved.
; License http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
; Note : All ini files need to be saved as UTF-8 - No BOM

; English translation

ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_40PLUS="Attachments pour Joomla 4.0+"
ATTACH_PACKAGE_NOTICE_UNINSTALL_PACKAGE_S="Pour désinstaller l'extensions attachements, désinstaller le package '%s'!"
PKG_ATTACHMENTS="Package: Attachments pour Joomla 4.0+"

0 comments on commit e106799

Please sign in to comment.