JoomlaPolska / jezyk-J4

Język polski dla Joomla 4
GNU General Public License v2.0
3 stars 5 forks source link

Added plugin event triggers to the new mod_articles module #586

Open joomlapl-bot opened 2 months ago

joomlapl-bot commented 2 months ago

PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/44132 Poniżej zmiany w oryginale:

Click to expand the diff! ```diff diff --git a/language/en-GB/mod_articles.ini b/language/en-GB/mod_articles.ini index 7a9ced1a83f9..d7a2d7d0485d 100644 --- a/language/en-GB/mod_articles.ini +++ b/language/en-GB/mod_articles.ini @@ -64,6 +64,8 @@ MOD_ARTICLES_FIELD_TITLEONLY_LABEL="Title Only (lists)" MOD_ARTICLES_FIELD_TITLE_HEADING="Header Level" MOD_ARTICLES_FIELD_TITLE_HEADING_NONE="None" MOD_ARTICLES_FIELD_TITLE_LABEL="Article Title" +MOD_ARTICLES_FIELD_TRIGGER_EVENTS_DESC="Enable this option to trigger three plugin events (afterDisplayTitle, beforeDisplayContent, afterDisplayContent) for each article in the results list." +MOD_ARTICLES_FIELD_TRIGGER_EVENTS_LABEL="Trigger Plugin Events" MOD_ARTICLES_INFO="Details" MOD_ARTICLES_OPTION_ASCENDING_VALUE="Ascending" MOD_ARTICLES_OPTION_CREATED_VALUE="Created Date" diff --git a/modules/mod_articles/mod_articles.xml b/modules/mod_articles/mod_articles.xml index 1ae7df1860f2..bd0d2ad7fda0 100644 --- a/modules/mod_articles/mod_articles.xml +++ b/modules/mod_articles/mod_articles.xml @@ -344,6 +344,19 @@ + + + + + link = Route::_('index.php?option=com_users&view=login&Itemid=' . $Itemid . '&return=' . $return); } + $item->event = new \stdClass(); + + // Check if we should trigger additional plugin events + if ($params->get('trigger_events', 0)) { + $dispatcher = Factory::getApplication()->getDispatcher(); + + // Process the content plugins. + PluginHelper::importPlugin('content', null, true, $dispatcher); + + $contentEventArguments = [ + 'context' => 'com_content.article', + 'subject' => $item, + 'params' => $item->params, + ]; + + // Extra content from events + + $contentEvents = [ + 'afterDisplayTitle' => new Content\AfterTitleEvent('onContentAfterTitle', $contentEventArguments), + 'beforeDisplayContent' => new Content\BeforeDisplayEvent('onContentBeforeDisplay', $contentEventArguments), + 'afterDisplayContent' => new Content\AfterDisplayEvent('onContentAfterDisplay', $contentEventArguments), + ]; + + foreach ($contentEvents as $resultKey => $event) { + $results = $dispatcher->dispatch($event->getName(), $event)->getArgument('result', []); + + $item->event->{$resultKey} = $results ? trim(implode("\n", $results)) : ''; + } + } else { + $item->event->afterDisplayTitle = ''; + $item->event->beforeDisplayContent = ''; + $item->event->afterDisplayContent = ''; + } + // Used for styling the active article $item->active = $item->id == $active_article_id ? 'active' : ''; diff --git a/modules/mod_articles/tmpl/default_items.php b/modules/mod_articles/tmpl/default_items.php index c3c1a293c765..4d77d7964e2f 100644 --- a/modules/mod_articles/tmpl/default_items.php +++ b/modules/mod_articles/tmpl/default_items.php @@ -22,7 +22,7 @@
    displayHits || $item->displayAuthorName || $item->displayCategoryTitle || $item->displayDate; + $displayInfo = $item->displayHits || $item->displayAuthorName || $item->displayCategoryTitle || $item->displayDate; ?>
  • @@ -44,6 +44,8 @@ > + event->afterDisplayTitle; ?> + get('info_layout') == 1) ? 'list-inline' : 'list-unstyled'; ?>
    @@ -100,10 +102,14 @@
- get('show_introtext')) : ?> - displayIntrotext; ?> + event->beforeDisplayContent; ?> + + get('show_introtext', 1)) : ?> + introtext; ?> + event->afterDisplayContent; ?> + get('show_readmore')) : ?> $item, 'params' => $item->params, 'link' => $item->link]); ?> diff --git a/plugins/sampledata/blog/src/Extension/Blog.php b/plugins/sampledata/blog/src/Extension/Blog.php index 74d5a9ff4fd0..326c8f358084 100644 --- a/plugins/sampledata/blog/src/Extension/Blog.php +++ b/plugins/sampledata/blog/src/Extension/Blog.php @@ -1454,6 +1454,7 @@ public function onAjaxSampledataApplyStep3() 'show_hits' => 0, 'info_layout' => 0, 'show_tags' => 0, + 'trigger_events' => 0, 'show_introtext' => 0, 'introtext_limit' => 100, 'image' => 0, @@ -1517,6 +1518,7 @@ public function onAjaxSampledataApplyStep3() 'show_author' => 0, 'info_layout' => 1, 'show_tags' => 0, + 'trigger_events' => 0, 'show_introtext' => 1, 'introtext_limit' => 0, 'image' => 0, @@ -1581,6 +1583,7 @@ public function onAjaxSampledataApplyStep3() 'show_hits' => 0, 'info_layout' => 0, 'show_tags' => 0, + 'trigger_events' => 0, 'show_introtext' => 0, 'introtext_limit' => 100, 'image' => 0, ```