Text formatter differences

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
User avatar
JoshyPHP
Registered User
Posts: 381
Joined: Fri Jul 08, 2011 9:43 pm

Re: Text formatter differences

Post by JoshyPHP »

I think we're just using a different terminology. You start with the original text, then it is parsed and serialized into another format (kind-of HTML in 3.1, XML in 3.2), then it's stored in the database for a while before it is rendered into HTML whenever it's displayed.

It doesn't matter whether you modify the data before or after it's saved to the database, what's important is that once the original text has been parsed you need to be careful not to break the format it's been serialized to. In the snippet you posted I can see there's some HTML in the middle of the XML, which would prevent it from being read. That's why it's best to stick to modifying either the original text or the rendered HTML.

User avatar
RMcGirr83
Registered User
Posts: 360
Joined: Fri Mar 09, 2007 1:51 am
Contact:

Re: Text formatter differences

Post by RMcGirr83 »

Well I know this change will effect quite a few extensions. Chat extensions, a few of mine and apparently one of David's.

For others that care, using this

Code: Select all

				$url = $this->root_path . 'memberlist.' . $this->php_ext . '?mode=viewprofile&u=' . $this->user->data['user_id'];
				$color = $this->user->data['user_colour'];
				$user_name = $this->user->data['is_registered'] ? '[url=' . $url . '][color=#' . $color . ']' . $this->user->data['username'] . '[/color][/url]' : $data['username'];
it then gets displayed correctly but, naturally, fails for 3.1.9. ***sigh***

Thanks for the clue JoshyPHP :)
Do not hire Christian Bullock he won't finish the job and will keep your money

Paul Online
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 373
Joined: Thu Sep 16, 2004 9:02 am
Contact:

Re: Text formatter differences

Post by Paul »

So just include then full url?

User avatar
3Di
Registered User
Posts: 951
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: Text formatter differences

Post by 3Di »

paulus wrote: Mon May 23, 2016 12:24 pm So just include then full url?
Yup, do you mean it could be better to..

Code: Select all

	/**
	* Use this event to change the output of get_username_string()
	*
	* @event core.modify_username_string
	* @var string mode				profile|username|colour|full|no_profile
or to write a custom function instead?
🆓 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. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
RMcGirr83
Registered User
Posts: 360
Joined: Fri Mar 09, 2007 1:51 am
Contact:

Re: Text formatter differences

Post by RMcGirr83 »

paulus wrote: Mon May 23, 2016 12:24 pm So just include then full url?
https://github.com/rmcgirr83/contactadm ... #L267-L276

Code: Select all

				if (phpbb_version_compare($this->config['version'], '3.2.0-b2', '>='))
				{
					$url = $this->root_path . 'memberlist.' . $this->php_ext . '?mode=viewprofile&u=' . $this->user->data['user_id'];
					$color = $this->user->data['user_colour'];
					$user_name = $this->user->data['is_registered'] ? '[url=' . $url . '][color=#' . $color . ']' . $this->user->data['username'] . '[/color][/url]' : $data['username'];
				}
				else
				{
					$user_name = $this->user->data['is_registered'] ? get_username_string('full', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']) : $data['username'];
				}
:?:
Do not hire Christian Bullock he won't finish the job and will keep your money

Paul Online
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 373
Joined: Thu Sep 16, 2004 9:02 am
Contact:

Re: Text formatter differences

Post by Paul »

Code: Select all

					$url = generat_board_url() . 'memberlist.' . $this->php_ext . '?mode=viewprofile&u=' . $this->user->data['user_id'];
					$color = $this->user->data['user_colour'];
					$user_name = $this->user->data['is_registered'] ? '[url=' . $url . '][color=#' . $color . ']' . $this->user->data['username'] . '[/color][/url]' : $data['username'];
Should work on both ;).

User avatar
3Di
Registered User
Posts: 951
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: Text formatter differences

Post by 3Di »

Perhaps Paul refers to the cases: profile and no_profile.

That usually are managed by auths

Code: Select all

($this->auth->acl_get('u_viewprofile'))
🆓 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. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
RMcGirr83
Registered User
Posts: 360
Joined: Fri Mar 09, 2007 1:51 am
Contact:

Re: Text formatter differences

Post by RMcGirr83 »

paulus wrote: Mon May 23, 2016 2:32 pm

Code: Select all

					$url = generat_board_url() . 'memberlist.' . $this->php_ext . '?mode=viewprofile&u=' . $this->user->data['user_id'];
					$color = $this->user->data['user_colour'];
					$user_name = $this->user->data['is_registered'] ? '[url=' . $url . '][color=#' . $color . ']' . $this->user->data['username'] . '[/color][/url]' : $data['username'];
Should work on both ;).
Yep, tried that but IIRC the url link wasn't displayed correctly probably due to me using $this->root_path instead of generate_board_url but that then brings up the problem of nubs changing their domain name (could happen if moving from freeforum host to paid I think) in which case the generate_board_url thing would break (lead to a can't find domain or whatever).

@ 3Di, I'm not concerned with auths as the only ones that should have access to view these types of posts (and PMs for that matter) are admins, or at least those in the admin group, and/or founders and the link to the user name is only created if the user is registered on the forum.

I suppose I have to choose the lesser of two evils. Either way no problem with validation as it relates to this part of the code @paulus?
Do not hire Christian Bullock he won't finish the job and will keep your money

Paul Online
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 373
Joined: Thu Sep 16, 2004 9:02 am
Contact:

Re: Text formatter differences

Post by Paul »

The URL problem will apply for a lot of posts, so adding a bunch more is not that much of an issue in my opinion. You can always try to do something with a custom BBCode which you replace somewhere in a event, but I don't think you can really do that (Without much hacking) in 3.1.
For validating I see no issue with using BBCode. I have some problems with using HTML as thats really not how it should be used. (And is really hacky)

User avatar
RMcGirr83
Registered User
Posts: 360
Joined: Fri Mar 09, 2007 1:51 am
Contact:

Re: Text formatter differences

Post by RMcGirr83 »

Good point, guess I'll use the @paulus nubland method. ;)

Grats!

PS I now owe you three beers
Do not hire Christian Bullock he won't finish the job and will keep your money

Post Reply