Extensions and phpBB 3.2: you should probably read this topic

Discussion forum for Extension Writers regarding Extension Development.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

I'm afraid I don't understand what you're asking.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

s9e/TextFormatter is only for PHP?
Do not have javascript version? Like this https://github.com/wGEric/phpBB-BBCode- ... ipt-Parser
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

The library can generate a JavaScript parser, yes. There's some doc there: http://s9etextformatter.readthedocs.io/ ... roduction/
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

Sorry but where do I put the code to generate js? And Can I do it directly in phpBB? Or do I have to install s9e \ TextFormatter?
And after generate js how do I use this (BBCode to HTML and HTML to BBCode)?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

You'd need to use the configurator to get the JS then inject the JS inside the page, then use the JavaScript API to do the thing. In other words you need to write an extension for it.

Ideally there would be an event around the call to finalize() to retrieve the JavaScript parser at the same time the rest is generated. It would make things easier/more efficient.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

Thanks, i will try.
But what folder will generate the js file?
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

JoshyPHP wrote: Thu Jul 13, 2017 10:46 pm Ideally there would be an event around the call to finalize() to retrieve the JavaScript parser at the same time the rest is generated. It would make things easier/more efficient.
but i can use this event? https://github.com/phpbb/phpbb/blob/mas ... y.php#L363
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

You can use that event, yes.

No folder, it's returned by finalize(). http://s9etextformatter.readthedocs.io/ ... roduction/
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

Now I understand.
I saw API here, but it looks like it only has BBCode to HTML (s9e.TextFormatter.preview($text, $target);).
So, do not have function for HTML to BBCode? Correct?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

No, there's no HTML-to-BBCode conversion.
I wrote the library that handles markup in phpBB 3.2+.
martec
Registered User
Posts: 324
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec »

JoshyPHP wrote: Thu Jul 13, 2017 11:27 pm No, there's no HTML-to-BBCode conversion.
Thank you.
Unfortunately it was quite complicated to use this.
I'll have the same problem with new line quantities.
rxu
Extensions Development Team
Posts: 3711
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Contact:

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by rxu »

Is there some built-in means to render a post partially? Say, certain paragraph of it (if any) and so on.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP »

No, there's nothing like that. What would be the typical use case?
I wrote the library that handles markup in phpBB 3.2+.
rxu
Extensions Development Team
Posts: 3711
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Contact:

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by rxu »

There's a user request to dynamically load a part of [editable/variable content] post consisting of paragraphs (f.e. from $3 to the end) on external site (or even to another topic).
Zukero
Registered User
Posts: 52
Joined: Fri Oct 16, 2015 9:19 am
Contact:

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by Zukero »

Hello.

I'm trying to write an extension for phpbb 3.2 that adds a custom bbcode.

I'm using php, and not the simple custom bbcodes from the acp, because there are core APIs that already do exactly what I need (including database queries).

I access the @user_loader service which can directly produce the HTML code I want, but nothing's produced. What am I doing wrong? Wrong event used? Incorrect usage of s9e API? Please help.

BBCode:

Code: Select all

[mytag]{TEXT1}[/mytag] 
Replacement:

Code: Select all

{TEXT1}
Php code extracts

Code: Select all

class main_listener implements EventSubscriberInterface
{
	static public function getSubscribedEvents()
	{
		return array(
        'core.text_formatter_s9e_configure_after' => 'configure_usernamebbcode',
        'core.text_formatter_s9e_render_before'     => 'prepare_render_usernamebbcode',
		);
	}
	
	    public function configure_usernamebbcode($event)
    {
        // Get the BBCode configurator 
        $configurator = $event['configurator']; 

        // Let's unset any existing BBCode that might already exist 
        unset($configurator->BBCodes['user']); 
        unset($configurator->tags['user']); 

// Let's create the new BBCode 
$configurator->BBCodes->addCustom( '[mytag]{TEXT1}[/mytag]', '{TEXT1}');
    }

    public function prepare_render_usernamebbcode($event)
    {
        $renderer = $event['renderer']->get_renderer();


        $username = $renderer->getParameter('TEXT1');
        $userid = $this->user_loader->load_user_by_username($username);
        $user = $this->user_loader->get_user($userid,  true);

        if ( $user == false or $user['username_clean'] == 'anonymous' )
        {
            $userbbcode = $username;
        } 
        else
        {
            $userbbcode = $this->user_loader->get_username($userid, 'full', false, false, true);
        }

        $renderer->setParameter('TEXT1', $userbbcode);
        
    }
    
} 
	
Post Reply

Return to “Extension Writers Discussion”