JoomlaPolska / jezyk-J4

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

[5.2] Fix filtering exclude and include articles #585

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/44142 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 519d7905d513..853c1ea9eacd 100644 --- a/language/en-GB/mod_articles.ini +++ b/language/en-GB/mod_articles.ini @@ -25,7 +25,8 @@ MOD_ARTICLES_FIELD_DATEGROUPINGFIELD_DESC="Select which date field you want the MOD_ARTICLES_FIELD_DATEGROUPINGFIELD_LABEL="Date Grouping Field" MOD_ARTICLES_FIELD_DATERANGEFIELD_LABEL="Date Range Field" MOD_ARTICLES_FIELD_ENDDATE_LABEL="To Date" -MOD_ARTICLES_FIELD_EXCLUDEDARTICLES_LABEL="Article IDs to Exclude" +MOD_ARTICLES_FIELD_EX_OR_INCLUDE_LABEL="Exclude or Include Articles" +MOD_ARTICLES_FIELD_EXCLUDEDARTICLES_LABEL="Articles to Exclude" MOD_ARTICLES_FIELD_EXCLUDE_CURRENT_LABEL="Exclude Current Article" MOD_ARTICLES_FIELD_GROUP_DISPLAY_LABEL="Display Options" MOD_ARTICLES_FIELD_GROUP_FILTERING_LABEL="Filtering Options" @@ -34,7 +35,7 @@ MOD_ARTICLES_FIELD_GROUP_ORDERING_LABEL="Ordering Options" MOD_ARTICLES_FIELD_IMAGES_ARTICLE_LABEL="Show Intro/Full Image" MOD_ARTICLES_FIELD_IMAGES_DESC="Show the images that are inside the text of the article." MOD_ARTICLES_FIELD_IMAGES_LABEL="Show Article Images" -MOD_ARTICLES_FIELD_INCLUDEDARTICLES_LABEL="Article IDs to Include" +MOD_ARTICLES_FIELD_INCLUDEDARTICLES_LABEL="Articles to Include" MOD_ARTICLES_FIELD_INFOLAYOUT_DESC="Layout for the Articles Info (Date, Hits, Category, Author)." MOD_ARTICLES_FIELD_INFOLAYOUT_LABEL="Articles Info Layout" MOD_ARTICLES_FIELD_INTROTEXTLIMIT_DESC="Truncate Introtext to a specified number of characters. Set to 0 to disable truncation." @@ -51,6 +52,7 @@ MOD_ARTICLES_FIELD_MONTHYEARFORMAT_DESC="Please enter in a valid date format. Se MOD_ARTICLES_FIELD_MONTHYEARFORMAT_LABEL="Month and Year Display Format" MOD_ARTICLES_FIELD_ONLYARCHIVED_LABEL="Archived Articles" MOD_ARTICLES_FIELD_RELATIVEDATE_LABEL="Relative Date" +MOD_ARTICLES_FIELD_SELECT_ARTICLE_LABEL="Select Article" MOD_ARTICLES_FIELD_SHOWCATEGORYLINK_LABEL="Category Link" MOD_ARTICLES_FIELD_SHOWCHILDCATEGORYARTICLES_DESC="Include or exclude articles in the child categories of the selected ones." MOD_ARTICLES_FIELD_SHOWCHILDCATEGORYARTICLES_LABEL="Child Category Articles" @@ -93,3 +95,4 @@ MOD_ARTICLES_OPTION_VOTE_VALUE="Vote" MOD_ARTICLES_OPTION_YEAR_VALUE="Year" MOD_ARTICLES_UNTAGGED="Untagged" MOD_ARTICLES_XML_DESCRIPTION="This module displays articles in a variety of ways." + diff --git a/modules/mod_articles/mod_articles.xml b/modules/mod_articles/mod_articles.xml index 05f868e61a5f..74d016535e48 100644 --- a/modules/mod_articles/mod_articles.xml +++ b/modules/mod_articles/mod_articles.xml @@ -22,7 +22,8 @@ -
+
+ + + + + + + multiple="true" + buttons="add,remove" + showon="ex_or_include_articles:0" + > +
+ + +
+ multiple="true" + buttons="add,remove" + showon="ex_or_include_articles:1" + > +
+ + +
setState('filter.published', ContentComponent::CONDITION_ARCHIVED); } - // Filter by id in case it should be excluded - $excluded_articles = $params->get('excluded_articles', ''); - if ( - $params->get('exclude_current', true) - && $input->get('option') === 'com_content' - && $input->get('view') === 'article' - ) { - // Add current article to excluded list - $excluded_articles .= "\r\n" . $input->get('id', 0, 'UINT'); - } + // Check if we include or exclude articles and process data + $ex_or_include_articles = $params->get('ex_or_include_articles', 0); + $filterInclude = true; + $articlesList = []; + + $articlesListToProcess = $params->get('included_articles', ''); - if ($excluded_articles) { - $excluded_articles = explode("\r\n", $excluded_articles); - $articles->setState('filter.article_id', $excluded_articles); + if ($ex_or_include_articles === 0) { + $filterInclude = false; - // Exclude - $articles->setState('filter.article_id.include', false); + if ( + $params->get('exclude_current', 1) === 1 + && $input->get('option') === 'com_content' + && $input->get('view') === 'article' + ) { + $articlesList[] = $input->get('id', 0, 'UINT'); + } + + $articlesListToProcess = $params->get('excluded_articles', ''); } - // Filter by id in case it should be included only - $included_articles = $params->get('included_articles', ''); - if ($included_articles) { - $included_articles = explode("\r\n", $included_articles); - $articles->setState('filter.article_id', $included_articles); + foreach (ArrayHelper::fromObject($articlesListToProcess) as $article) { + $articlesList[] = (int) $article['id']; + } - // Include - $articles->setState('filter.article_id.include', true); + if (!empty($articlesList)) { + $articles->setState('filter.article_id', $articlesList); + $articles->setState('filter.article_id.include', $filterInclude); } $date_filtering = $params->get('date_filtering', 'off'); ```