Skip to content

Commit

Permalink
Updated to the latest s9e\TextFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Sep 30, 2015
1 parent de22729 commit 2a16d79
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 51 deletions.
4 changes: 2 additions & 2 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": "20150813",
"version": "20150930",
"keywords": ["phpbb","embed","forum","media"],
"license": "MIT",
"require": {
Expand Down
83 changes: 44 additions & 39 deletions parsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected function finalizeOutput()
$this->outputText($this->textLen, 0, \true);
do
{
$this->output = \preg_replace('(<(?!/)[^>]+></[\\w:]+>)', '', $this->output, -1, $cnt);
$this->output = \preg_replace('(<([^ />]+)></\\1>)', '', $this->output, -1, $cnt);
}
while ($cnt > 0);
if (\strpos($this->output, '</i><i>') !== \false)
Expand Down Expand Up @@ -1554,45 +1554,9 @@ public function parse($text, array $matches)
public static function filterTag(Tag $tag, TagStack $tagStack, array $sites)
{
if ($tag->hasAttribute('media'))
{
$tagName = $tag->getAttribute('media');
if (!$tag->hasAttribute('id')
&& $tag->hasAttribute('url')
&& \strpos($tag->getAttribute('url'), '://') === \false)
$tag->setAttribute('id', $tag->getAttribute('url'));
}
self::addTagFromMediaId($tag, $tagStack, $sites);
elseif ($tag->hasAttribute('url'))
{
$p = \parse_url($tag->getAttribute('url'));
if (isset($p['scheme']) && isset($sites[$p['scheme'] . ':']))
$tagName = $sites[$p['scheme'] . ':'];
elseif (isset($p['host']))
{
$host = $p['host'];
do
{
if (isset($sites[$host]))
{
$tagName = $sites[$host];
break;
}
$pos = \strpos($host, '.');
if ($pos === \false)
break;
$host = \substr($host, 1 + $pos);
}
while ($host > '');
}
}
if (isset($tagName))
{
$endTag = $tag->getEndTag() ?: $tag;
$lpos = $tag->getPos();
$rpos = $endTag->getPos() + $endTag->getLen();
$newTag = $tagStack->addSelfClosingTag(\strtoupper($tagName), $lpos, $rpos - $lpos);
$newTag->setAttributes($tag->getAttributes());
$newTag->setSortPriority($tag->getSortPriority());
}
self::addTagFromMediaUrl($tag, $tagStack, $sites);
return \false;
}
public static function hasNonDefaultAttribute(Tag $tag)
Expand All @@ -1613,6 +1577,47 @@ public static function scrape(Tag $tag, array $scrapeConfig, $cacheDir = \null)
self::scrapeEntry($url, $tag, $scrape, $cacheDir);
return \true;
}
protected static function addSiteTag(Tag $tag, TagStack $tagStack, $siteId)
{
$endTag = $tag->getEndTag() ?: $tag;
$lpos = $tag->getPos();
$rpos = $endTag->getPos() + $endTag->getLen();
$newTag = $tagStack->addSelfClosingTag(\strtoupper($siteId), $lpos, $rpos - $lpos);
$newTag->setAttributes($tag->getAttributes());
$newTag->setSortPriority($tag->getSortPriority());
}
protected static function addTagFromMediaId(Tag $tag, TagStack $tagStack, array $sites)
{
if (!$tag->hasAttribute('id') && $tag->hasAttribute('url') && \strpos($tag->getAttribute('url'), '://') === \false)
$tag->setAttribute('id', $tag->getAttribute('url'));
$siteId = \strtolower($tag->getAttribute('media'));
if (\in_array($siteId, $sites, \true))
self::addSiteTag($tag, $tagStack, $siteId);
}
protected static function addTagFromMediaUrl(Tag $tag, TagStack $tagStack, array $sites)
{
$p = \parse_url($tag->getAttribute('url'));
if (isset($p['scheme']) && isset($sites[$p['scheme'] . ':']))
$siteId = $sites[$p['scheme'] . ':'];
elseif (isset($p['host']))
$siteId = self::findSiteIdByHost($p['host'], $sites);
if (!empty($siteId))
self::addSiteTag($tag, $tagStack, $siteId);
}
protected static function findSiteIdByHost($host, array $sites)
{
do
{
if (isset($sites[$host]))
return $sites[$host];
$pos = \strpos($host, '.');
if ($pos === \false)
break;
$host = \substr($host, 1 + $pos);
}
while ($host > '');
return \false;
}
protected static function replaceTokens($url, array $vars)
{
return \preg_replace_callback(
Expand Down
14 changes: 7 additions & 7 deletions rendering.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/s9e/TextFormatter
Submodule TextFormatter updated 42 files
+1 −1 composer.json
+1 −1 src/Bundles/Fatdown.php
+3 −3 src/Bundles/Fatdown/Renderer.php
+1 −1 src/Bundles/Forum.php
+4 −4 src/Bundles/Forum/Renderer.php
+1 −1 src/Bundles/MediaPack.php
+6 −6 src/Bundles/MediaPack/Renderer.php
+455 −73 src/Configurator.php
+29 −19 src/Configurator/JavaScript.php
+6 −13 src/Configurator/JavaScript/CallbackGenerator.php
+60 −23 src/Configurator/JavaScript/ConfigOptimizer.php
+56 −0 src/Configurator/JavaScript/ConfigValue.php
+11 −4 src/Configurator/JavaScript/Encoder.php
+2 −2 src/Configurator/JavaScript/Minifiers/ClosureCompilerApplication.php
+3 −1 src/Configurator/JavaScript/Minifiers/ClosureCompilerService.php
+112 −0 src/Configurator/JavaScript/StylesheetCompressor.php
+219 −0 src/Configurator/JavaScript/externs.application.js
+15 −29 src/Configurator/JavaScript/externs.service.js
+25 −5 src/Parser.js
+1 −1 src/Parser.php
+8 −0 src/Parser/utils.js
+26 −0 src/Plugins/Autoimage/Configurator.php
+9 −0 src/Plugins/Autoimage/Parser.js
+23 −0 src/Plugins/Autoimage/Parser.php
+4 −0 src/Plugins/Autolink/Parser.js
+1 −0 src/Plugins/Autolink/Parser.php
+7 −4 src/Plugins/BBCodes/Configurator/repository.xml
+1 −1 src/Plugins/Censor/Helper.php
+1 −1 src/Plugins/Emoji/Parser.js
+172 −149 src/Plugins/Litedown/Parser.js
+89 −95 src/Plugins/Litedown/Parser.php
+23 −161 src/Plugins/MediaEmbed/Configurator.php
+55 −57 src/Plugins/MediaEmbed/Configurator/CachedSiteDefinitionProvider.php
+43 −0 src/Plugins/MediaEmbed/Configurator/TemplateBuilder.php
+99 −0 src/Plugins/MediaEmbed/Configurator/TemplateGenerator.php
+31 −0 src/Plugins/MediaEmbed/Configurator/TemplateGenerators/Choose.php
+34 −0 src/Plugins/MediaEmbed/Configurator/TemplateGenerators/Flash.php
+27 −0 src/Plugins/MediaEmbed/Configurator/TemplateGenerators/Iframe.php
+43 −38 src/Plugins/MediaEmbed/Parser.php
+113 −47 src/Plugins/MediaEmbed/Parser/tagFilter.js
+1 −1 src/Renderer.php
+1 −1 src/Utils.php
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"stable":{"20150813":{"current":"20150813","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20150813\/s9e-mediaembed-20150813.zip","eol":null,"security":false}}}
{"stable":{"20150930":{"current":"20150930","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20150930\/s9e-mediaembed-20150930.zip","eol":null,"security":false}}}

0 comments on commit 2a16d79

Please sign in to comment.