Feature Documentation Required RMDQ PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar korenevskiy
korenevskiy
28 Feb 2023

Added the ability to search by ID in the search field in the materials, categories, fields and modules manager without using the id: suffix.

In the process of working with content, you have to return to the articles for re-editing. We have to repeatedly use the ID to search. Since we often use articles with the same names. It is useless to search for an article by name. Our articles are in different categories. One article is the news about the publication, and the other article is the publication itself. Bad or good, we will not discuss it, I will say that it had to be done because of the lack of multicategories. Perhaps using tags as a category will solve this problem in the company.
Even if there were no duplicate articles, then in our company we also constantly re-edit articles.
Writing ID:1243 in the search field every time is tedious.

We know that the search services Google, Bing do not ask us, for example, about the file extension when searching in pictures, we just write the name and extension PNG in the search. After that we get some pictures with a translucent background. That's enough for us.

My add-on doesn't break the search at all. And only expands it for convenience. If there is at least one word or letter in the search, the result will not contain material with this ID, but if there is only a number in the field, then we will see as a result materials containing this number in the name of the material that has this ID.

Perhaps it will interfere with someone. But it will be 1% of users. While 99% of users will benefit from this fix.

Search additionally with ID
image
Search additionally with ID
image

Search as it was before.
image

avatar joomla-cms-bot joomla-cms-bot - change - 28 Feb 2023
Category Administration com_content com_modules
avatar korenevskiy korenevskiy - open - 28 Feb 2023
avatar korenevskiy korenevskiy - change - 28 Feb 2023
Status New Pending
avatar brianteeman
brianteeman - comment - 28 Feb 2023

This is obviously incomplete

avatar joomla-cms-bot joomla-cms-bot - change - 28 Feb 2023
Category Administration com_content com_modules Administration com_categories com_content com_modules
avatar korenevskiy korenevskiy - change - 28 Feb 2023
Labels Added: PR-4.3-dev
avatar korenevskiy korenevskiy - change - 28 Feb 2023
The description was changed
avatar korenevskiy korenevskiy - edited - 28 Feb 2023
avatar korenevskiy
korenevskiy - comment - 28 Feb 2023

This is obviously incomplete

Do you mean about the bad description of PR?

avatar brianteeman
brianteeman - comment - 28 Feb 2023

image

avatar korenevskiy
korenevskiy - comment - 28 Feb 2023

@brianteeman
I know that. I suggest making the search a little more intelligent. I can suggest that the script checks that only numbers are written in the field.
Because it is painful to search for an article every time to write the suffix ID: in it.

avatar joomla-cms-bot joomla-cms-bot - change - 28 Feb 2023
Category Administration com_content com_modules com_categories Administration com_categories com_content com_fields com_modules
avatar brianteeman
brianteeman - comment - 28 Feb 2023

I was telling you what was missing from this PR to make it complete ;)

Not that I agree with you that this PR is an improvement

avatar korenevskiy korenevskiy - change - 28 Feb 2023
The description was changed
avatar korenevskiy korenevskiy - edited - 28 Feb 2023
avatar korenevskiy
korenevskiy - comment - 28 Feb 2023

I was telling you what was missing from this PR to make it complete ;)

Please repeat briefly what is missing. I can't find where you talked about what's missing.
It's not like #28311

avatar brianteeman
brianteeman - comment - 28 Feb 2023

#39966 (comment)

If you change the code then you need to change the string. Otherwise people will still type id:

avatar korenevskiy
korenevskiy - comment - 28 Feb 2023

If you change the code then you need to change the string. Otherwise people will still type id:

I suppose you meant the field description . Ok. I'll need some time.

avatar joomla-cms-bot joomla-cms-bot - change - 1 Mar 2023
Category Administration com_content com_modules com_categories com_fields Administration com_categories com_content com_fields com_modules Language & Strings
avatar korenevskiy korenevskiy - change - 1 Mar 2023
Labels Added: Language Change
avatar Fedik
Fedik - comment - 1 Mar 2023

Hi Sergiy,

After a discussion in the Maintainer group we decided that this is not a change we see in a future Release of Joomla.
Thank you for your work, don't feel discouraged and continue to contribute to Joomla.

avatar Fedik Fedik - change - 1 Mar 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-03-01 16:50:18
Closed_By Fedik
avatar Fedik Fedik - close - 1 Mar 2023
avatar korenevskiy
korenevskiy - comment - 1 Mar 2023

Hi Sergiy,

After a discussion in the Maintainer group we decided that this is not a change we see in a future Release of Joomla. Thank you for your work, don't feel discouraged and continue to contribute to Joomla.

Maybe the problem is something else? Maybe I suggested the wrong search logic?
In the screenshot, I suggested displaying the article by ID along with other articles that may have a number in the title.

I would suggest the second option. Show articles with ID search only if only a number is in the search. I.e. if a word is in the search, then such a search is considered classic. But if there is not a single word and there is only a number, then only the article by ID and the article with the number in the title will be displayed.

Perhaps in the group, you discussed how the result will break when searching for words and numbers.
Example: Search: "Article 312".

I suggest reviewing the logic after your decision. And in this example, since there is the word ARTICLE, the result will be only in the classical style, without searching by ID.

But as soon as there is only a digit in the search, then the search will be by ID as well.

Perhaps in the group you discussed the correctness of my previous search option. But maybe you haven't considered other logic, and possible options.

Maybe my previous option is really too intrusive. And the new one is more delicate. Please consider more delicate options!!

avatar korenevskiy
korenevskiy - comment - 1 Mar 2023

Or. Perhaps I would suggest calling a plugin. This allows those who wish to use the plugin to enable ID search without using a suffix.

avatar brianteeman
brianteeman - comment - 1 Mar 2023

After thinking more about the reason for you wanting to make this change I think I now understand why and its not something that will have been considered by the maintenance team and should be a reason for them to reconsider their decision.

For me it is easy to type ID:1234 and at first glance it would appear to be easy for everyone making this change a matter of personal preference only.

However for a language that does not use a latin character set such as russian, greek and arabic it is not so easy as they have to switch from their default keyboard to a latin keyboard. This is definitely undesirable. Just as it is also undesirable that to search inside the content of an article you have to type CONTENT:string where CONTENT is not translatable etc

image

avatar brianteeman
brianteeman - comment - 1 Mar 2023

@Fedik please ask the maintainers to reconsider this

avatar korenevskiy
korenevskiy - comment - 1 Mar 2023

You are absolutely right.
As a programmer, I always have English. But my wife always uses Russian by default.
This is reminiscent of how programmers make apps for phones for $1,000. Because programmers have high salaries.

avatar richard67
richard67 - comment - 1 Mar 2023

I’m not Fedir, but I was reading too so I’ve notified other maintainers.

avatar brianteeman
brianteeman - comment - 1 Mar 2023

Thanks @richard67

avatar korenevskiy
korenevskiy - comment - 1 Mar 2023

Dear colleagues. In my work, there is support for museum websites. Don't get me wrong. I treat pensioners well. But I am constantly (always) faced with the stupidity of people working on a PC. I see many times how people print out a document, make corrections on it with a pen, then scan it and send it by mail, or send it to Whatsapp. And they do this not because they are bosses and want to show the places where they have been corrected, but because they do not know how to do it differently. These people from Excel rewrite the numbers on paper, recalculate them on a calculator and write them back into Excel. These people became familiar with the computer in quarantine.
This is not 1 person, it is a large organization with 3 branches. I learned to think like these pensioners. I am constantly thinking about how people can work with the Joomla Admin Panel. I live in a modern city. But as if there is a fact that half of humanity on earth lives without electricity at all, and even more so without the Internet. This means that there will still be many people, even English speakers, who will print out the document in order to scan it later. This means that the convenience of working with Joomla should be made simple to the very minimum, to the utmost minimum.
If anything, then printing out a document and scanning it is not a joke. And recalculating data to an Excel calculator is also not a joke. These are real people, and the whole organization is just such people. But these are the most ordinary pensioners.
The task of the developer is so that even an idiot can use his product. After all, a manager, a consultant, a doctor really does not care about the subtleties of prefixes at all. These people will just do it the way it would work on other platforms. They will do it for 3 hours, but they will do it without prefixes.

Addition
Microsoft converted its office to a Ribbon Panel in 2007. If anyone remembers the reason why Microsoft took this step. I'll try to remind you. The new interface is a pain for the user. Remember those times when it was somehow hard and unusual to master. But the bottom line is that 99% of People asked for functions in Word, which were already in it in 2003 and earlier versions. This means that the interface is bad. Here, in the same way, people should search for articles by ID intuitively, Even if you can use a prefix, even English-speaking people will have no idea about prefixes. If you want, just ask your friends, those who are not a programmer, but a Joomla user.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

Everyone who participates in the adoption of this PR. They themselves are the same as pensioners. The proof of this is that on the streets of any city, the prices of shops that are located on the road are always available 30%-50% higher than in stores from the yard. Do you always buy a product in the store from the yard? Of course, only when you know that there is a store there. This is such a big phenomenon that the prices are much higher. Understand, it's not that it's too lazy to write a prefix for the ID. It's just that few people know about it. It turns out that every website of any organization has its own problems, everywhere has its own entrance from the courtyard. For each site, you need to remember your own special regular expression. Every programmer will say, but it's not difficult for me to write regulars. 90%(I was wrong it's 95%) of people will just sort the list by ID column, and then flip through the pages at random.

avatar Fedik
Fedik - comment - 2 Mar 2023

After some discussion, I reopening it.

I have to warn that not everyone like this approach,
you have to make it really good, or it have a big chance to be closed again.

avatar Fedik Fedik - change - 2 Mar 2023
Status Closed New
Closed_Date 2023-03-01 16:50:18
Closed_By Fedik
avatar Fedik Fedik - change - 2 Mar 2023
Status New Pending
avatar Fedik Fedik - reopen - 2 Mar 2023
avatar brianteeman
brianteeman - comment - 2 Mar 2023

After some discussion, I reopening it.

I have to warn that not everyone like this approach, you have to make it really good, or it have a big chance to be closed again.

It is not about if people like it but about rectifying the search so that it is not dependant on hard coded strings in the latin character set and english language.

My personal preference would be to keep the search prefix but to make it translatable

PS no idea how to do that

avatar Fedik
Fedik - comment - 2 Mar 2023

My personal preference would be to keep the search prefix but to make it translatable

I think this can lead to translation mess. I do not think that we can guarantee that it will be translated correctly.
Example: tooltip may say use "ID:", and for a placeholder translator will translate it as "IDENTIFIER", and whole thing will be unusable.
We already had issue with Date format and Date filter translations, for calendar input.

I will be happy to be wong here :)

avatar brianteeman
brianteeman - comment - 2 Mar 2023

I will be happy to be wong here :)

Am not saying it will be easy but it is wrong that in this part of the UI you have to type in latin characters and in english language. I don't think removing the ID etc is the solution however.

Suprised that no one has brought this up before

avatar Fedik
Fedik - comment - 2 Mar 2023

The PR do not remove ID:, it still will be in use for "exact search". It just extends general search.

avatar brianteeman
brianteeman - comment - 2 Mar 2023

The PR do not remove ID:, it still will be in use for "exact search". It just extends general search.

My bad - I misread it then

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

And how can we consider cases when it is necessary to edit, say, 20 or 30 articles? It often happens that people just made a mistake in the date or something else.

Maybe the other participants also misunderstood? And participants thought that the prefix would be canceled.

I will fix it as the team wants. But what about the other components? For example, Notes in users, and other components.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

administrator/components/com_content/src/Model/ArticlesModel.php

@Fedik Please take a look. Removed the heuristic, added a comment.

avatar Fedik
Fedik - comment - 2 Mar 2023

Removed the heuristic, added a comment.

I meant, remove space and comma mix, use only comma.

And check the code I sugested.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

I meant, remove space and comma mix, use only comma.

But if we use only a comma. Then the request "Article 123" will not be regarded as a search in the ID. You suggest using a more delicate search.
I'll fix it now

avatar Fedik
Fedik - comment - 2 Mar 2023

Then the request "Article 123" will not be regarded as a search in the ID

That what I mean, with heuristic. It is seems to much magic.

Also please check how I map the values, to keep the integers,
Thanks.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

I also propose to make similar amendments to:

  1. Manager Menu
  2. Manager Tags
  3. Manager Banners: Tracks, Clients, Banner
  4. Manager Contacts
  5. Manager Redirect
  6. Manager Workflows
  7. Manager News Feeds
  8. Manager Search/Filter
  9. Manager Users: users, groups, levels, Notes, Messages, Categories.

If you don't mind, I will make similar amendments further.

avatar Fedik
Fedik - comment - 2 Mar 2023

I also propose to make similar amendments to:

Keep it only for articles, categories, fields, modules for now.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

I also propose to make similar amendments to:

Keep it only for articles, categories, fields, modules for now.

OK. but I think Tags are just as important. Only Tags.

avatar Fedik
Fedik - comment - 2 Mar 2023

okay

avatar joomla-cms-bot joomla-cms-bot - change - 2 Mar 2023
Category Administration com_content com_modules com_categories com_fields Language & Strings Administration com_categories com_content com_fields com_modules com_tags Language & Strings
avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

okay

Thanks. It seems that the world has become a little better.
I had another idea to make the search a little more delicate.

To begin with, for example, we will return the space separator. After that, we divide the string into an array by a space and a comma. Then we filter it. And then we compare the amount of the filtered array with the unfiltered array.
If the number matches, then the user was obviously looking for numbers.
This will also make the search more delicate, but at the same time be able to use a space as a separator.

addtition
Because in different layouts, the dot and comma are constantly confused. Even on a digital block, the dot becomes a comma when the layout is changed.

But it's also good as it is.

avatar Fedik
Fedik - comment - 2 Mar 2023

It will be to much.

Please update value filter to what I sent you before:

$ids = array_filter(array_map(function ($number) {
    $number = trim($number);
    return is_numeric($number) ? (int) $number : 0;
}, explode(',', $search)));

This transform a numbers to integer, and filter out empty.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023

This transform a numbers to integer, and filter out empty.

But what if "-123" is entered in the search. This will be regarded as an ID. And after that, the request will search for ID with -123

As well as an anonymous function in the Array_filter function, it is not necessary to return the value of the number. Unlike Array_Map, the internal function requires a return in the BOOL type.

return is_numeric($number) ? (int) $number : 0;
In fact, this is the same thing.
return is_numeric($number) && (int) $number;

If the internal anonymous function returns -123, then this is interpreted as TRUE.
And this means that the value with "-123" will get into the $query. And there is no ID with a negative ID.

addition
I didn't see the ARRAY_MAP function at first, but even with it, a search with a negative ID will occur in the $query.

avatar Fedik
Fedik - comment - 2 Mar 2023

If the internal anonymous function returns -123, then this is interpreted as TRUE.

Then this:

$ids = array_filter(array_map(function ($number) {
    $number = trim($number);
    return is_numeric($number) && $number > 0 ? (int) $number : 0;
}, explode(',', $search)));

Your code produce array of strings, should be integers.

avatar korenevskiy
korenevskiy - comment - 2 Mar 2023
$ids = array_filter($idsPrepare, function ($number) {
    $number = trim($number);
    return is_numeric($number) && (int)$number > -1;
});

My code creates an array of strings. But I had already thought about this initially and initially checked the types. But in my code,
In these cases, ["\t123", "\n321"], an anonymous function may return TRUE.

Even if the anonymous function returns TRUE for these raw strings \n\t123.
Then the method call $query->bindArray($ids); will make the array types cast to the INT type in itself.
Since in this method of converting an element to the INT type is used by default.

Which does not cause an error in any way, which also corresponds to filtering as in your example. I.e. it is the same code and gives the same result. Let's use your code in which we explicitly cast the INT type to a value. Since I am in my case, I used the built-in type conversion in the method

$query->bindArray($ids, ParameterType::INTEGER);

Before casting the types.
["\t123", "\n321"].
After converted to array INT number
[123, 321]
But we can use explicit conversion as in your code repeatedly. But maybe in my case it's wrong to do so.

avatar korenevskiy
korenevskiy - comment - 3 Mar 2023

I fixed everything as you recommended.

$ids        = array_filter(array_map(function ($number) {
    $number = trim($number);
    return is_numeric($number) && $number > 0 ? (int) $number : 0;
}, explode(',', $search)));
avatar korenevskiy korenevskiy - change - 3 Mar 2023
The description was changed
avatar korenevskiy korenevskiy - edited - 3 Mar 2023
avatar Hackwar
Hackwar - comment - 4 Mar 2023

Why can't we make the keywords translatable? Instead of this additional code executed on each search, allow for id, content, etc to be translated in the search input. Thus non-latin users can keep using their keyboard.

avatar Fedik
Fedik - comment - 4 Mar 2023

Theoreticaly it is possible, practicaly see my comment #39966 (comment)

avatar korenevskiy
korenevskiy - comment - 4 Mar 2023

Why can't we make the keywords translatable? Instead of this additional code executed on each search, allow for id, content, etc to be translated in the search input. Thus non-latin users can keep using their keyboard.

Let's simplify the work with the search for articles. After all, we do it for people: for the weak with vision, hearing, with limited mobility. Why do processing using regular expressions. If it can be done simply and conveniently for everyone.
This is called accessibility.

avatar Fedik Fedik - test_item - 4 Mar 2023 - Tested successfully
avatar Fedik
Fedik - comment - 4 Mar 2023

I have tested this item ✅ successfully on 5a7a5db


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39966.

avatar Fedik
Fedik - comment - 4 Mar 2023

For testing in Sample data go to Articles list, and search for 1,2,3.
Should get a list of articles with ID 1,2,3.

Repeat for Categories, Fields, Field groups, Modules (with existing ids).

avatar korenevskiy
korenevskiy - comment - 4 Mar 2023

The interesting thing is why our colleagues are against it. In the case of a search, they are not satisfied with the fact that they may accidentally see an article with the ID specified in the search. I can't understand how this hinders them. Maybe these colleagues here will tell us about their special case in which a new logic hinders them.

avatar korenevskiy
korenevskiy - comment - 4 Mar 2023

We can do so that for example:
"Aticle 111, 22, 33" - The classic search from the names will be displayed.
"111, 22, 33" - A new search will be displayed in both the names and the ID.
Add a check for the presence of words in the search. And if there are words, then consider such a search classic, without searching in ID.

avatar viocassel viocassel - test_item - 13 Mar 2023 - Tested successfully
avatar viocassel
viocassel - comment - 13 Mar 2023

I have tested this item ✅ successfully on 5a7a5db


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39966.

avatar richard67 richard67 - change - 13 Mar 2023
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 13 Mar 2023

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39966.

avatar Quy Quy - change - 13 Mar 2023
Labels Added: ?
avatar korenevskiy korenevskiy - change - 13 Mar 2023
Title
Adding ID search to the Materials and modules manager without the [id:] suffix
Adding ID search to the Articles and modules manager without the [id:] suffix
avatar korenevskiy korenevskiy - edited - 13 Mar 2023
avatar HLeithner
HLeithner - comment - 8 May 2023

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

avatar HLeithner HLeithner - change - 26 Jul 2023
Title
Adding ID search to the Articles and modules manager without the [id:] suffix
[5.0] Adding ID search to the Articles and modules manager without the [id:] suffix
avatar HLeithner HLeithner - edited - 26 Jul 2023
avatar HLeithner
HLeithner - comment - 26 Jul 2023

Hi @korenevskiy sorry that it took so long, we discussed this in the weekly maintainers sprint and we have 3 request.

  1. Please move the array_fillter code block to the ArrayHelper method in the v3.0 in the framework
  2. Maybe we can extend the check so if a number/search string is in Quotes (") not to search for the number.
  3. In oppsoite to what fedir said above we would like to have it for all extensions so it's consistent for the complete cms

Then we would like to merge it.

The commaUintToArray method could be something like this but I would suggest to make sure that 0 work as return value but not a string to 0 is returned.

This function makes it a bit better but also doesn't full fill the requirements (readable and correct values). Actually it doesn't return the number 0 and it will also be not possible because of the way array_filter work.

$ids = array_filter(
    array_map(
        function ($number) {
                $number = trim($number);
                return is_numeric($number) && $number >= 0 ? (int) $number : false;
            }, 
            explode(',', $search)
        )
    );

thanks for your work.

avatar korenevskiy korenevskiy - change - 23 Sep 2023
Labels Added: Feature Documentation Required ? ? PR-5.0-dev
Removed: ? PR-4.3-dev
avatar richard67 richard67 - change - 23 Sep 2023
Status Ready to Commit Pending
avatar richard67
richard67 - comment - 23 Sep 2023

Back to pending


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39966.

avatar joomla-cms-bot joomla-cms-bot - change - 25 Sep 2023
Category Administration com_content com_modules com_categories com_fields Language & Strings com_tags Administration com_banners com_categories com_contact com_content com_fields com_finder com_installer com_languages com_menus com_messages com_modules com_newsfeeds com_redirect com_tags com_templates
avatar korenevskiy korenevskiy - change - 25 Sep 2023
Labels Removed: Language Change
avatar korenevskiy
korenevskiy - comment - 25 Sep 2023

2. Maybe we can extend the check so if a number/search string is in Quotes (") not to search for the number.

My version of the clarification was as follows. it is necessary to count the number of words in the search and the number of digits, if the number matches, then search in ID, if the number of words and digits in the search is different, then search as before.
But, on the recommendation of the discussion, I deleted this option.

array_filter() Indeed, it excludes elements that return 0, BUT!, if we return a value as a string in a nested function. This way Everything will work.

avatar korenevskiy
korenevskiy - comment - 25 Sep 2023

Back to pending

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39966.

I have added ID search for these components

  • users (and groups, notes, levels)
  • messages
  • menu (items, types)
  • mails
  • Banners (Contacts )
  • News Feeds
  • Languages
  • Guidedtours
  • Privacy
  • Actionlogs
  • Workwflow
  • Scheduler
  • Templates
  • Redirect
avatar korenevskiy
korenevskiy - comment - 25 Sep 2023
  1. Please move the array_fillter code block to the ArrayHelper method in the v3.0 in the framework

@HLeithner
I wanted to move array_filter to Array_Helper. But since this class has a broader purpose. I was forced to completely rewrite the array_filter() code.

I can put this in the FrameWork

	public static function filterNum($array = [], $onlyPositive = true){
		
		$new_array = [];
		
		foreach ($array as $i => $val){
			$type = gettype($val);
			$val = trim($val);
			if($onlyPositive && is_numeric($val) && $val >= 0 ){
				settype ($val, $type);
				$new_array[$i] = $val;
			}
			elseif(is_numeric($number)){
				settype ($val, $type);
				$new_array[$i] = $val;
			}
		}
		
		return $new_array;
	}

And in components to support ID, you would have to write like this.

            // Search by ID without the prefix ID:, used numbers from the search.
           $ids        = Array_Helper::filterNum(explode(',', $search));

            if ($ids) {
                $query->orWhere($db->quoteName('a.id') . ' IN (' . implode(',', $query->bindArray($ids)) . ')');
            }
avatar korenevskiy
korenevskiy - comment - 25 Sep 2023

I think that the com_finder and com_extension components
should be tested more thoroughly.

avatar joomla-cms-bot joomla-cms-bot - change - 25 Sep 2023
Category Administration com_content com_modules com_categories com_fields com_tags com_banners com_contact com_finder com_installer com_languages com_menus com_messages com_newsfeeds com_redirect com_templates Administration com_banners com_categories com_contact com_content com_fields com_finder com_installer com_languages com_menus com_messages com_modules com_newsfeeds com_plugins com_redirect com_tags com_templates
avatar korenevskiy
korenevskiy - comment - 25 Sep 2023

@HLeithner , I created a PR by ArrayHelper.

joomla-framework/utilities#43

avatar izharaazmi
izharaazmi - comment - 26 Sep 2023

Instead of putting it in ArrayHelper I would prefer something like this:

namespace Joomla\CMS\MVC\ListFilter;

class KeywordSearch
{
	public static function toIds(string $text): array
	{
		if (!preg_match('/^[0-9, ]+$/', $text))
		{
			return [];
		}

		$parts   = preg_split('/[,\s]+/', $text);
		$numbers = [];

		foreach ($parts as $part)
		{
			if (is_numeric($part) && $part >= 0)
			{
				$numbers[] = (int) $part;
			}
		}

		return $numbers;
	}
}

var_dump(KeywordSearch::toIds('123, 32, 0 32 43'));

// array(5) {[0]=> int(123) [1]=> int(32) [2]=> int(0) [3]=> int(32) [4]=> int(43)}

var_dump(KeywordSearch::toIds('category 123'));

// array(0) {}

On a side note, I would now exclude 0 values as it is not a valid record ID

avatar korenevskiy
korenevskiy - comment - 26 Sep 2023

Instead of putting it in ArrayHelper I would prefer something like this:

You have combined 2 tasks into 1. 1.Splitting a string into an array. 2. Filtering the array. In principle, combining 2 tasks is useful. But it is useful for internal calculations. And the use of the helper class has a wider use in different places. It may turn out that you just need to filter the array without dividing the string into an array. So I suggested a simple filtering method.

Another question is the intuitiveness of the code. How would an average programmer write code.

KeywordSearch::toIds($str);

or

ArrayHelper::filterIds(explode(',',$str)); //or ArrayHelper::filterNum()

I would use only the second option. Although the first one is shorter, but it's not intuitive for me.

BUT, Let's discuss this in the PR Framework. joomla-framework/utilities#43

avatar izharaazmi
izharaazmi - comment - 26 Sep 2023

I agree to your explain, and I will do the same in a common scenario.

However in current use case it is not about one task or combination of two. It simply serves one single definitive purpose - extract IDs from keyword search.

avatar korenevskiy
korenevskiy - comment - 27 Sep 2023

However in current use case it is not about one task or combination of two. It simply serves one single definitive purpose - extract IDs from keyword search.

@izharaazmi Your example is very good. In the sense that it filters integer values without floating point. And so on. I'm not so good at regular expressions, I know how to put a * sign. But we need, in theory, to filter only integers. You should have emphasized this in the description of your function. But your function would be more useful exclusively only in the code of this PR. In fact, both functions are equally useful in the FrameWork.
I would suggest calling your function like this

StringHelper::toArrayFilteredNumeric($text);

This will allow only integers to be taken into account.

avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 5.1-dev.

avatar korenevskiy
korenevskiy - comment - 18 Dec 2023

Why is this PR not included in Joomla 5.1 alfa?

avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[5.0] Adding ID search to the Articles and modules manager without the [id:] suffix
[5.2] Adding ID search to the Articles and modules manager without the [id:] suffix
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar rdeutz rdeutz - change - 31 Jul 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-07-31 17:56:39
Closed_By rdeutz
Labels Added: RMDQ PR-5.2-dev
Removed: ? ? PR-5.0-dev
avatar rdeutz
rdeutz - comment - 31 Jul 2024

We discussed this again and still don't like it, we understand where you are coming from but this is the bachend of a CMS and not something like Google.

avatar rdeutz rdeutz - close - 31 Jul 2024
avatar korenevskiy
korenevskiy - comment - 7 Aug 2024

@rdeutz You're right, it might be unnecessary. But please tell me if there was a suggestion to use the setting so that you can turn this feature on or off in the settings panel. In general, this should be turned off by default.
Has this topic been discussed? Suggest this solution for those who are against it.
In general, there may be a political justification for such a decision. But even English-speaking users will not be able to use the prefix ID:. Only developers use it. But developers have no localization boundaries.

avatar korenevskiy
korenevskiy - comment - 7 Aug 2024

@rdeutz Also, the explanation that Joomla is not Google is a very dubious explanation. It becomes clear when you start thinking about it for a long time. So you can explain anything, for example, "a person does not need to wash at all, because when a person sits in the water for a long time, his skin becomes inflamed." I.e., explaining useful innovations with extremes suggests that this serves to lead participants away from the real reason for the ban.
You should think about it.

avatar korenevskiy
korenevskiy - comment - 7 Aug 2024

Show these messages to the participants, let them discuss the new idea with the settings panel.

avatar brianteeman
brianteeman - comment - 7 Aug 2024

You are completely wrong that only developers use this. I observed a conversation about how useful it was on facebook just this week,

And please, please no more options!!

avatar korenevskiy
korenevskiy - comment - 9 Aug 2024

Similarly. 80% of MS Excel users do not know such magic functions, and only 20% do. And 20% of users know 80% of the possibilities. I can say with confidence that I know only 20% of MS Excel, as it is easier for me to work with data in SQL. but the majority also have no need.
It is quite logical that most admin panel users need to write an article based on intuition. Have you witnessed a user's interaction with FaceBook, do you think that he got this knowledge intuitively? or he read the instructions from cover to cover.
In fact, we limit the capabilities of most users, of course I mentioned programmers, but this was a simplification. Of course, writing the keyword ID concerns a minority, since this is not intuitive knowledge.
But I told you that you can make a setting so that it is disabled. It is quite obvious that it will not work by default.
We also know that the search works by aliases, I'm sure that Facebook does not work by aliases, you need to attribute a dog there, but the search is conducted on Facebook by the full user name, and in Joomla the search is based on the alias part of the name, so it's not entirely logical to compare, their UX is different

avatar rdeutz
rdeutz - comment - 12 Aug 2024

@korenevskiy we discussed any possible aspect of this idea and decided to close the PR.

Add a Comment

Login with GitHub to post a comment