[3.2.9-3.3.x][RC] Glossary 3.0.20

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Anti-Spam Guide
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by 3Di »

oakhearted wrote: Wed Jan 12, 2022 3:59 am i cant see the extension installed, help
Read the first post for instructions.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

I can't give a better answer.
User avatar
motte
Registered User
Posts: 73
Joined: Wed Jan 30, 2013 10:15 pm
Name: Ralph

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by motte »

A really great idea would be if it is also stated who added and edited an entry.
Renault Scenic Forum 🚘 since 2003 ...

... lover of Modeltrains 🚂🚃🚃
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

Fine idea.
I'll take a note for next version.
In the mean time, you could use the cat column to store the author name.
wamfiya
Registered User
Posts: 1
Joined: Wed Oct 30, 2019 7:43 pm

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by wamfiya »

Another cool improvement might be the use of the bbcode editor for the 'definition' field.
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

Another good idea.
User avatar
gbergna
Registered User
Posts: 41
Joined: Sat Jul 29, 2017 10:05 pm
Name: Federico Bergna

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by gbergna »

Installed the latest version available on github (3.0.23) with phpbb version 3.3.12 and everything works perfectly.

However, I would like to propose one important change, in my opinion.

- in a post, I may have text where a word is repeated very often anchored to the glossary link. It would be sufficient to anchor the link just once for each type of word in that post without continuing to anchor links to the same words.

For example:
1) a user posts a response
2) in the answer, the words "meteorite" are present 4 times and the words "orbit" 5 times. I therefore find myself having 9 words with 9 links in that answer.
3) It would therefore be sufficient to anchor to the link "once the word meteorite" and "once the word orbit"

This would allow you to have a much tidier text on the forum from a visual and also functional point of view. There is no point in having too many words with links anchored to them.
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

Hello,

This is a fine idea. I'll try to implement it.
User avatar
gbergna
Registered User
Posts: 41
Joined: Sat Jul 29, 2017 10:05 pm
Name: Federico Bergna

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by gbergna »

gbergna wrote: Wed Jul 03, 2024 8:32 pm Installed the latest version available on github (3.0.23) with phpbb version 3.3.12 and everything works perfectly.

However, I would like to propose one important change, in my opinion.

- in a post, I may have text where a word is repeated very often anchored to the glossary link. It would be sufficient to anchor the link just once for each type of word in that post without continuing to anchor links to the same words.

For example:
1) a user posts a response
2) in the answer, the words "meteorite" are present 4 times and the words "orbit" 5 times. I therefore find myself having 9 words with 9 links in that answer.
3) It would therefore be sufficient to anchor to the link "once the word meteorite" and "once the word orbit"

This would allow you to have a much tidier text on the forum from a visual and also functional point of view. There is no point in having too many words with links anchored to them.
Probably, I have find a solution. Change the function

Code: Select all

private function glossary_pass($texte)
in listener.php like this:

Code: Select all

	private function glossary_pass($texte)
	{
		static $glossterms;
	
		$anchored_terms = []; // Reset per ogni chiamata della funzione
	
		if (!isset($glossterms) || !is_array($glossterms))
		{
			$this->compute_glossary_list();
			$glossterms = $this->cache->get('_glossterms');
		}
		if (sizeof($glossterms))
		{
			$acro = $code = $quote = $img = $link = $script = false;
			$rech = $glossterms['rech'];
			$remp = $glossterms['remp'];
			preg_match_all('#[][><][^][><]*|[^][><]+#', $texte, $matches);
			$parts = $matches[0];
			if (empty($parts))
			{
				return '';
			}
			foreach ($parts as $index => $part)
			{
				// Code
				if (strstr($part, '[code'))
				{
					$code = true;
				}
				if (!empty($code) && strstr($part, '[/code'))
				{
					$code = false;
				}
				// quote 3.2.0
				if (strstr($part, '[quote'))
				{
					$quote = true;
				}
				if (!empty($quote) && strstr($part, '[/quote'))
				{
					$quote = false;
				}
				// Pictures
				if (strstr($part, '[img'))
				{
					$img = true;
				}
				if (!empty($img) && strstr($part, '[/img'))
				{
					$img = false;
				}
				// <a> - <a> links
				if (strstr($part, '<a '))
				{
					$link = true;
				}
				if (!empty($link) && strstr($part, '</a'))
				{
					$link = false;
				}
				// [url] - [url] links
				if (strstr($part, '[url'))
				{
					$link = true;
				}
				if (!empty($link) && strstr($part, '[/url'))
				{
					$link = false;
				}
				// Script
				if (strstr($part, '<script '))
				{
					$script = true;
				}
				if (!empty($script) && strstr($part, '</script'))
				{
					$script = false;
				}
				if (!($part[0] == '<') && !($part[0] == '[') &&
					empty($code) && empty($quote) &&
					empty($img) && empty($link) && empty($script))
				{
					foreach ($rech as $key => $pattern)
					{
						if (preg_match($pattern, $part, $matches))
						{
							$term = strtolower($matches[1]); // Convertire a minuscolo per confronto case-insensitive
							// Check if this term has already been anchored
							if (!in_array($term, $anchored_terms))
							{
								$part = preg_replace($pattern, $remp[$key], $part, 1);
								$anchored_terms[] = $term; // Aggiungiamo il termine all'array dei termini ancorati
							}
							else
							{
								// Term has already been anchored, do not replace again
								$part = preg_replace($pattern, '$1', $part, 1);
							}
						}
					}
					$parts[$index] = $part;
				}
			}
			unset($part);
			return implode("", $parts);
		}
		else
		{
			return ($texte);
		}
	} // glossary_pass
User avatar
gbergna
Registered User
Posts: 41
Joined: Sat Jul 29, 2017 10:05 pm
Name: Federico Bergna

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by gbergna »

Another tips... change the database table "variants" from varchar(80) to varchar(500) so in this way, we can put more words into the "terms of variant" fot ancora them
Last edited by gbergna on Thu Jul 04, 2024 6:35 am, edited 1 time in total.
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

Thanks for your contribution.
I'll have a look at it later on. I'm now in holidays.
Hervé
Registered User
Posts: 598
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by Hervé »

Hi,
Filling the form for each term is tedious, is it possible to add terms in batch ?

It seams that the terms are not case sensitive, for instance if I add "PAR" (Photosynthetically Active Radiation) in upper case.
The words "par" in lower case which means "by" and is very common in french are also highlighted !
User avatar
pierredu
Registered User
Posts: 1276
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by pierredu »

You can do that in the database, directly.
There are indeed false positives.
I don't think there is a solution for such a problem.
Hervé
Registered User
Posts: 598
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by Hervé »

Directly in the database, of course, but not given to anybody.
I could rather write a php script which inserts the data in the DB.

About the lowercase/uppercase, I guess there is something somewhere that identifies a world to highlight and doesn't care if it's the same case.
Would it be possible to modify this process so that it becomes case sensitive?
Some search functions of php exist with case sensitive or insensitive version.
Of course if I want to detect for example the word "word" I will have to specify "word, Word" so that it detects both.

Otherwise a trick so that if I specify "PAR" it does not highlight "par" but only "PAR"?
Hervé
Registered User
Posts: 598
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: [3.2.9-3.3.x][RC] Glossary 3.0.20

Post by Hervé »

I have tried with "P.A.R." but it is not detected in the message.
I've found a solution : "P A R".

In which module does the glossary search take place ?

Return to “Extensions in Development”