- phpBB od 3.2+ (s9e TextFormatter) má zámerne obmedzené nested parsovanie v custom BBCode definovaných cez ACP – {TEXT} / {ANYTHING} sa parsujú ako plain text (raw), nie ako plnohodnotný BBCode obsah. Toto je zámerné rozhodnutie autora parsera (JoshyPHP)
- bud sa da nainstalovat rozsirenie - Advanced BBCode Box 3 (ale tam bude treba asi vsetky tagy poprerabat podla ich nalezitosti)
- alebo vytvvorit na to custom extension vid. nizsie.
Mozno pomoze, vyskusajte...
Extension, ktorá prepíše definíciu VCOL cez core.text_formatter_s9e_configure_after.
/ext/miro/vcol/composer.json
json
Code: Select all
{
"name": "miro/vcol",
"type": "phpbb-extension",
"description": "vcol s podporou vnútorných BBCode",
"version": "1.0.0",
"license": "GPL-2.0-only",
"authors": [
{
"name": "miro m.",
"email": "",
"homepage": "",
"role": "Developer"
}
],
"require": {
"php": ">=7.1",
"phpbb/phpbb": ">=3.3.0"
},
"extra": {
"display-name": "vcol with nested parsing",
"soft-require": {
"phpbb/phpbb": ">=3.3.0"
}
}
}php
Code: Select all
<?php
namespace miro\vcol;
class ext extends \phpbb\extension\base
{
}php
Code: Select all
<?php
namespace miro\vcol\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class main_listener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'core.text_formatter_s9e_configure_after' => 'configure_vcol',
];
}
public function configure_vcol($event)
{
$configurator = $event['configurator'];
// odstráň starú definíciu ak existuje (pre bezpečnosť)
unset($configurator->BBCodes['vcol']);
$configurator->BBCodes->addCustom(
'[vcol={NUMBER}]{TEXT}[/vcol]',
'<div style="display:flex;width:100%;gap:15px;align-items:flex-start;clear:both;">
<div style="width:{NUMBER}%;flex-shrink:0;white-space:pre-line;display:flow-root;">{TEXT1}</div>
<div style="flex-grow:1;white-space:pre-line;display:flow-root;">{TEXT2}</div>
</div>'
);
// rozdelíme obsah na dve časti podľa %|
$configurator->BBCodes['vcol']->setTemplate(
'<div style="display:flex;width:100%;gap:15px;align-items:flex-start;clear:both;">
<div style="width:{NUMBER}%;flex-shrink:0;white-space:pre-line;display:flow-root;">
<xsl:value-of select="@TEXT1"/>
</div>
<div style="flex-grow:1;white-space:pre-line;display:flow-root;">
<xsl:value-of select="@TEXT2"/>
</div>
</div>'
);
// filter na rozdelenie {TEXT} → TEXT1 | TEXT2
$configurator->BBCodes['vcol']->addParameter('TEXT1');
$configurator->BBCodes['vcol']->addParameter('TEXT2');
$configurator->tags['vcol']->filterChain->append(function ($tag) {
$content = (string) $tag->getAttribute('content');
$parts = explode('%|', $content, 2);
$tag->setAttribute('TEXT1', $parts[0] ?? '');
$tag->setAttribute('TEXT2', $parts[1] ?? '');
return true;
});
}
}