Skip to content

Commit

Permalink
Trying to deal with custom BBCodes on 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jan 16, 2017
1 parent 287761a commit b97c050
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 29 deletions.
15 changes: 9 additions & 6 deletions bundle.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "Embed third-party content in your phpBB forum",
"homepage": "https://github.com/s9e/phpbb-ext-mediaembed/",
"version": "20161227",
"version": "20170116",
"keywords": ["phpbb","embed","forum","media"],
"license": "MIT",
"require": {
Expand Down
36 changes: 34 additions & 2 deletions listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class listener implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
'core.text_formatter_s9e_configure_before' => 'onConfigure',
'core.text_formatter_s9e_configure_after' => 'onConfigure',
'core.modify_format_display_text_after' => 'onPreview',
'core.modify_submit_post_data' => 'onSubmit',
'core.modify_text_for_display_after' => 'onDisplay',
Expand All @@ -28,8 +28,40 @@ public static function getSubscribedEvents()

public function onConfigure($event)
{
$configurator = $event['configurator'];
$attrMap = array();
foreach ($configurator->MediaEmbed->defaultSites as $siteId => $definition)
{
if (isset($configurator->BBCodes[$siteId]))
{
$configurator->BBCodes[$siteId]->defaultAttribute = 'url';
$configurator->BBCodes[$siteId]->contentAttributes = array('url');
}
if (isset($configurator->tags[$siteId]))
{
foreach ($configurator->tags[$siteId]->attributes as $attrName => $attribute)
{
if ($attrName === 'id')
{
break;
}
}
$attrMap[$siteId] = $attrName;
}
}

$bundleConfigurator = new MediaPackConfigurator;
$bundleConfigurator->configure($event['configurator']);
$bundleConfigurator->configure($configurator);

foreach ($attrMap as $siteId => $attrName)
{
$tag = $configurator->tags[$siteId];
if (!isset($tag->attributes['id']))
{
continue;
}
$tag->template = '<xsl:choose><xsl:when test="@id">' . $tag->template . '</xsl:when><xsl:otherwise>' . str_replace('@id', '@' . $attrName, $tag->template) . '</xsl:otherwise></xsl:choose>';
}
}

public function onDisplay($event)
Expand Down
20 changes: 10 additions & 10 deletions parsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter;
Expand Down Expand Up @@ -1041,7 +1041,7 @@ protected static function compareTags(Tag $a, Tag $b)

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Parser;
Expand Down Expand Up @@ -1286,7 +1286,7 @@ protected static function validateUrl(array $urlConfig, array $p)

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Parser;
Expand Down Expand Up @@ -1351,7 +1351,7 @@ public function warn($msg, array $context = array())

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Parser;
Expand Down Expand Up @@ -1537,7 +1537,7 @@ public function setAttributes(array $attributes)

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Plugins\MediaEmbed;
Expand Down Expand Up @@ -1699,7 +1699,7 @@ protected static function wget($url, $cacheDir = \null)

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Plugins;
Expand All @@ -1722,7 +1722,7 @@ abstract public function parse($text, array $matches);

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Utils;
Expand All @@ -1738,7 +1738,7 @@ public static function getClient()

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Utils\Http;
Expand All @@ -1752,7 +1752,7 @@ abstract public function post($url, $headers = array(), $body = '');

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Utils\Http\Clients;
Expand Down Expand Up @@ -1799,7 +1799,7 @@ protected function getNewHandle()

/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2016 The s9e Authors
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Utils\Http\Clients;
Expand Down
16 changes: 8 additions & 8 deletions rendering.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/s9e/TextFormatter
Submodule TextFormatter updated 150 files
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"stable":{"20161227":{"current":"20161227","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20161227\/s9e-mediaembed-20161227.zip","eol":null,"security":false}}}
{"stable":{"20170116":{"current":"20170116","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20170116\/s9e-mediaembed-20170116.zip","eol":null,"security":false}}}

0 comments on commit b97c050

Please sign in to comment.