Skip to content

Commit 350109f

Browse files
authored
Merge pull request #85 from jmcameron/attachmentsid
add new button for {attachments id=xxx }
2 parents b499e48 + 5a94834 commit 350109f

24 files changed

+369
-11
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ all: parts $(ZIPFILE)
1010

1111
INSTALLS = attachments_plugin \
1212
add_attachment_btn_plugin \
13+
insert_attachments_id_token_btn_plugin \
1314
insert_attachments_token_btn_plugin \
1415
attachments_plugin_framework \
1516
attachments_for_content \

attachments_component/admin/language/el-GR/el-GR.com_attachments.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ATTACH_ACCESS_THIS_ATTACHMENT_TITLE="Προσπέλασε/κάνε λήψη αυ
1212
ATTACH_ADDED_DATA_FOR_N_ATTACHMENTS="Προστέθηκαν δεδομένα για %d συνημμένα!"
1313
ATTACH_ADDED_ICON_FILENAMES_TO_N_ATTACHMENTS="Προστέθηκαν ονόματα αρχείων εικονιδίων σε %d συνημμένα."
1414
ATTACH_ADD_ATTACHMENT="Προσθήκη συνημμένου"
15+
ATTACH_ADD_ATTACHMENT_IDS="Προσθήκη επιλεγμένων συνημμένων"
16+
ATTACH_ADD_ATTACHMENT_IDS_DESCRIPTION="Αυτή είναι μια λίστα των συνημμένων που έχουν ήδη προστεθεί στο άρθρο/κατηγορία. Επιλέξτε αυτό(ά) που θέλετε να προσθέσετε χρησιμοποιώντας την ένδειξη και πατήστε το κουμπί 'Προσθήκη επιλεγμένων συνημμένων'."
1517
ATTACH_ADD_ATTACHMENT_TITLE="Πρόσθεσε συνημμένο σε αυτό το άρθρο ή αντικείμενο περιεχομένου"
1618
ATTACH_ADD_ATTACHMENT_TO_S_INSTEAD_OF_S_TOOLTIP="Πρόσθεσε το συνημμένο σε %s (αντί για %s)"
1719
ATTACH_ADD_URL="Προσθήκη URL"

attachments_component/admin/language/en-GB/en-GB.com_attachments.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ATTACH_ACCESS_THIS_ATTACHMENT_TITLE="Access/download this attachment"
1212
ATTACH_ADDED_DATA_FOR_N_ATTACHMENTS="Added data for %d attachments!"
1313
ATTACH_ADDED_ICON_FILENAMES_TO_N_ATTACHMENTS="Added icon filenames to %d attachment(s)."
1414
ATTACH_ADD_ATTACHMENT="Add attachment"
15+
ATTACH_ADD_ATTACHMENT_IDS="Add selected attachments"
16+
ATTACH_ADD_ATTACHMENT_IDS_DESCRIPTION="This is a list of attachments already added the the article/category. Select which one(s) you want to insert using the token and press the 'Add selected attachments' button."
1517
ATTACH_ADD_ATTACHMENT_TITLE="Add attachment to this article or content item"
1618
ATTACH_ADD_ATTACHMENT_TO_S_INSTEAD_OF_S_TOOLTIP="Add the attachment to a %s (instead of %s)"
1719
ATTACH_ADD_URL="Add URL"

attachments_component/admin/language/fr-FR/fr-FR.com_attachments.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ATTACH_ACCESS_THIS_ATTACHMENT_TITLE="Voir/télécharger cette pièce jointe"
1212
ATTACH_ADDED_DATA_FOR_N_ATTACHMENTS="Donnée ajoutée pour %d pièces jointes!"
1313
ATTACH_ADDED_ICON_FILENAMES_TO_N_ATTACHMENTS="Icône ajoutée à %d pièce(s)-jointe(s)."
1414
ATTACH_ADD_ATTACHMENT="Ajouter une pièce jointe"
15+
ATTACH_ADD_ATTACHMENT_IDS="Ajoute la(les) pièces jointe(s) sélectionnée(s)"
16+
ATTACH_ADD_ATTACHMENT_IDS_DESCRIPTION="Si desssous vous avez la liste des pièces jointes déjà ajoutées à l'article/la catégorie. Selectionnez celle(s) qu vous voulez ajouter avec le token et apputer sur le bouton 'Ajoute la(les) pièces jointe(s) sélectionnée(s)'."
1517
ATTACH_ADD_ATTACHMENT_TITLE="Ajouter la pièce jointe à l'article ou au contenu"
1618
ATTACH_ADD_ATTACHMENT_TO_S_INSTEAD_OF_S_TOOLTIP="Ajouter la pièce jointe à un %s (Au lieu de %s)"
1719
ATTACH_ADD_URL="Ajouter l'adresse"

attachments_component/admin/language/fr-FR/fr-FR.com_attachments.sys.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_16PLUS="Attachments pour Joomla 2.5+"
1313
ATTACH_PLEASE_REPORT_BUGS_AND_SUGGESTIONS_TO_S="Merci de signaler les bugs et vos suggestions à %s"
1414
COM_ATTACHMENTS="Attachments"
1515
COM_ATTACHMENTS_CONFIGURATION="Configuration du composant Attachments"
16+
ATTACH_PACKAGE_NOTICE_UNINSTALL_PACKAGE_S="Pou désinstaller l'extension 'Attachments, désinstaller le Package '%s'!"

attachments_component/admin/src/Model/AttachmentsModel.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct($config = array())
4545
if (empty($config['filter_fields'])) {
4646
$config['filter_fields'] = array(
4747
'id',
48+
'parent_id',
4849
'a.state',
4950
'a.access',
5051
'a.filename',
@@ -80,7 +81,11 @@ protected function getListQuery()
8081
/** @var \Joomla\Database\DatabaseDriver $db */
8182
$db = Factory::getContainer()->get('DatabaseDriver');
8283
$query = $db->getQuery(true);
83-
84+
$id = $this->getState('filter.parent_id');
85+
if (is_numeric($id))
86+
{
87+
$query->where('a.parent_id = ' . (int) $id);
88+
}
8489
$query->select('a.*, a.id as id');
8590
$query->from('#__attachments as a');
8691

attachments_component/admin/src/View/Attachments/HtmlView.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use JMCameron\Component\Attachments\Administrator\Helper\AttachmentsPermissions;
1717
use JMCameron\Component\Attachments\Site\Helper\AttachmentsDefines;
1818
use JMCameron\Plugin\AttachmentsPluginFramework\AttachmentsPluginManager;
19+
use JMCameron\Component\Attachments\Administrator\Model\AttachmentsModel;
1920
use Joomla\CMS\Component\ComponentHelper;
2021
use Joomla\CMS\Factory;
2122
use Joomla\CMS\HTML\HTMLHelper;
@@ -52,10 +53,18 @@ public function display($tpl = null)
5253
return;
5354
}
5455

56+
$app = Factory::getApplication();
57+
$jinput = $app->getInput();
58+
$this->editor = $jinput->getString('editor', null);
59+
$id = $jinput->getInt('parent_id', null);
60+
if ($id) {
61+
$model = $this->getModel();
62+
$model->setState('filter.parent_id', $id);
63+
}
5564
$this->items = $this->get('Items');
5665
$this->state = $this->get('State');
5766
$this->pagination = $this->get('Pagination');
58-
67+
5968
// Check for errors.
6069
if (count($errors = $this->get('Errors'))) {
6170
throw new \Exception(implode("\n", $errors) . ' (ERR 175)', 500);
@@ -166,9 +175,22 @@ public function display($tpl = null)
166175
}
167176

168177
// Set the toolbar
169-
$this->addToolBar();
178+
if ( !$this->editor ) {
179+
$this->addToolBar();
180+
}
170181

171182
// Display the attachments
183+
if ( $this->editor ) {
184+
$document = Factory::getDocument();
185+
HTMLHelper::_('jquery.framework');
186+
$document->addScriptDeclaration('function insertAttachmentsIdToken($, editorName) {
187+
let editor = parent.Joomla.editors.instances[editorName];
188+
var adminform = document.getElementById("adminForm");
189+
var Data = new FormData(adminform);
190+
editor.replaceSelection("{attachments id=" + Data.getAll("cid[]") +"}");
191+
$(".btn-close", parent.document).click();
192+
}');
193+
}
172194
parent::display($tpl);
173195
}
174196

attachments_component/admin/tmpl/attachments/default.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
use Joomla\CMS\Factory;
1515
use Joomla\CMS\HTML\HTMLHelper;
1616
use Joomla\CMS\Router\Route;
17+
use Joomla\CMS\Language\Text;
1718
use Joomla\CMS\Uri\Uri;
1819

20+
1921
// No direct access
2022
defined('_JEXEC') or die('Restricted access');
2123

@@ -31,7 +33,15 @@
3133

3234
?>
3335
<form action="<?php echo Route::_('index.php?option=com_attachments'); ?>" method="post" name="adminForm" id="adminForm">
34-
<?php echo $this->loadTemplate('filter');?>
36+
<?php if ( $this->editor ) : ?>
37+
<p><?php echo Text::_('ATTACH_ADD_ATTACHMENT_IDS_DESCRIPTION'); ?></p>
38+
<button onclick="insertAttachmentsIdToken(jQuery, '<?php echo $this->editor ?>');"><?php echo Text::_('ATTACH_ADD_ATTACHMENT_IDS'); ?></button>
39+
<?php endif; ?>
40+
<?php
41+
if (!$this->editor ) {
42+
echo $this->loadTemplate('filter');
43+
}
44+
?>
3545
<table class="adminlist" id="attachmentsList">
3646
<thead><?php echo $this->loadTemplate('head');?></thead>
3747
<tbody><?php echo $this->loadTemplate('body');?></tbody>
@@ -44,5 +54,7 @@
4454
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
4555
<?php echo HTMLHelper::_('form.token'); ?>
4656
</div>
57+
4758
</form>
4859

60+

attachments_component/admin/tmpl/attachments/default_body.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,14 @@
115115
?>
116116
<tr class="<?php echo "row$k"; ?>">
117117
<td class="at_checked hidden-phone"><?php echo $checked; ?></td>
118+
<?php if ( !$this->editor ) : ?>
118119
<td class="at_published" align="center"><?php echo $published;?></td>
120+
<?php endif; ?>
119121
<td class="at_filename">
120-
<a href="<?php echo $link; ?>" title="<?php echo $edit_attachment_title; ?>"
121-
><?php echo HTMLHelper::image('com_attachments/file_icons/'.$icon, $download_verb, null, true);
122+
<?php if ( !$this->editor ) : ?>
123+
<a href="<?php echo $link; ?>" title="<?php echo $edit_attachment_title; ?>" >
124+
<?php endif; ?>
125+
<?php echo HTMLHelper::image('com_attachments/file_icons/'.$icon, $download_verb, null, true);
122126
if ( ($item->uri_type == 'url') && $superimpose_link_icons ) {
123127
if ( $item->url_valid ) {
124128
echo HTMLHelper::image('com_attachments/file_icons/link_arrow.png', '', 'class="link_overlay"', true);
@@ -127,7 +131,11 @@
127131
echo HTMLHelper::image('com_attachments/file_icons/link_broken.png', '', 'class="link_overlay"', true);
128132
}
129133
}
130-
?></a>&nbsp;<a
134+
?>
135+
<?php if ( !$this->editor ) : ?>
136+
</a>
137+
<?php endif; ?>
138+
&nbsp;<a
131139
href="<?php echo $link; ?>" title="<?php echo $edit_attachment_title; ?>"
132140
><?php if ( $item->uri_type == 'file' ) {
133141
echo $item->filename;

attachments_component/admin/tmpl/attachments/default_head.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
<th class="at_checked hidden-phone">
3131
<input type="checkbox" name="checkall-toggle" value="" onclick="Joomla.checkAll(this)" />
3232
</th>
33+
<?php if ( !$this->editor ) : ?>
3334
<th class="at_published" width="5%" nowrap="nowrap"><?php echo HTMLHelper::_('grid.sort', 'ATTACH_PUBLISHED',
3435
'a.state', $listDirn, $listOrder ) ?></th>
36+
<?php endif; ?>
3537
<th class="at_filename"><?php echo HTMLHelper::_('grid.sort', 'ATTACH_ATTACHMENT_FILENAME_URL',
3638
'a.filename', $listDirn, $listOrder ) ?></th>
3739
<th class="at_description"><?php echo HTMLHelper::_('grid.sort', 'ATTACH_DESCRIPTION',

0 commit comments

Comments
 (0)