Skip to content

Commit

Permalink
Updated build script to detect all attributes in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Nov 5, 2013
1 parent f17cb1a commit 3976892
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<addon addon_id="s9e" title="s9e Media Pack" url="https://github.com/s9e/XenForoMediaBBCodes" version_id="20131103" version_string="201311030" install_callback_class="s9e_MediaBBCodes" install_callback_method="install">
<addon addon_id="s9e" title="s9e Media Pack" url="https://github.com/s9e/XenForoMediaBBCodes" version_id="20131105" version_string="201311050" install_callback_class="s9e_MediaBBCodes" install_callback_method="install">
<bb_code_media_sites>
<site media_site_id="bandcamp" site_title="Bandcamp" site_url="http://bandcamp.com/" match_is_regex="1" embed_html_callback_class="s9e_MediaBBCodes" embed_html_callback_method="embed" match_callback_class="s9e_MediaBBCodes" match_callback_method="matchBandcamp">
<match_urls>!bandcamp\.com/album/.!
Expand Down
10 changes: 9 additions & 1 deletion build/upload/library/s9e/MediaBBCodes.php
Expand Up @@ -216,6 +216,8 @@ protected static function getNamedCaptures($string, $regexps)

public static function renderBandcamp($vars)
{
$vars += array('album_id' => null, 'track_num' => null);

$html='<iframe width="400" height="'.htmlspecialchars((isset($vars['track_num'])?42:120),2).'" allowfullscreen="" frameborder="0" scrolling="no" src="http://bandcamp.com/EmbeddedPlayer/album='.htmlspecialchars($vars['album_id'],2).'/size=';if(isset($vars['track_num'])){$html.='small/t='.htmlspecialchars($vars['track_num'],2);}else{$html.='medium';}$html.='"/></iframe>';

return $html;
Expand Down Expand Up @@ -341,7 +343,7 @@ public static function matchIndiegogo($url)

public static function renderKickstarter($vars)
{
$vars += array('id' => null);
$vars += array('id' => null, 'video' => null);

$html='';if(isset($vars['video'])){$html.='<iframe width="480" height="360" src="http://www.kickstarter.com/projects/'.htmlspecialchars($vars['id'],2).'/widget/video.html" allowfullscreen="" frameborder="0" scrolling="no"/></iframe>';}else{$html.='<iframe width="220" height="380" src="http://www.kickstarter.com/projects/'.htmlspecialchars($vars['id'],2).'/widget/card.html" allowfullscreen="" frameborder="0" scrolling="no"/></iframe>';}

Expand Down Expand Up @@ -384,6 +386,8 @@ public static function matchSlideshare($url)

public static function renderSpotify($vars)
{
$vars += array('path' => null, 'uri' => null);

$html='<iframe width="300" height="80" allowfullscreen="" frameborder="0" scrolling="no" src="https://embed.spotify.com/?uri=';if(isset($vars['uri'])){$html.=htmlspecialchars($vars['uri'],2);}else{$html.='spotify:'.htmlspecialchars(strtr($vars['path'],'/',':'),2);}$html.='"/></iframe>';

return $html;
Expand Down Expand Up @@ -425,6 +429,8 @@ public static function matchTraileraddict($url)

public static function renderTwitch($vars)
{
$vars += array('archive_id' => null, 'channel' => null, 'chapter_id' => null);

$html='<object type="application/x-shockwave-flash" typemustmatch="" width="620" height="378" data="http://www.twitch.tv/widgets/'.htmlspecialchars((isset($vars['archive_id'])||isset($vars['chapter_id'])?'arch':'l'),2).'ive_embed_player.swf"><param name="allowfullscreen" value="true"/></param><param name="flashvars" value="channel='.htmlspecialchars($vars['channel'],2);if(isset($vars['archive_id'])){$html.='&amp;archive_id='.htmlspecialchars($vars['archive_id'],2);}if(isset($vars['chapter_id'])){$html.='&amp;chapter_id='.htmlspecialchars($vars['chapter_id'],2);}$html.='"/></param><embed type="application/x-shockwave-flash" width="620" height="378" src="http://www.twitch.tv/widgets/'.htmlspecialchars((isset($vars['archive_id'])||isset($vars['chapter_id'])?'arch':'l'),2).'ive_embed_player.swf" allowfullscreen=""/></embed></object>';

return $html;
Expand Down Expand Up @@ -458,6 +464,8 @@ public static function matchVk($url)

public static function renderYoutube($vars)
{
$vars += array('id' => null, 't' => null);

$html='<iframe width="560" height="315" allowfullscreen="" frameborder="0" scrolling="no" src="//www.youtube.com/embed/'.htmlspecialchars($vars['id'],2);if(isset($vars['t'])){$html.='?start='.htmlspecialchars($vars['t'],2);}$html.='"/></iframe>';

return $html;
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.php
Expand Up @@ -350,7 +350,7 @@ protected static function getNamedCaptures($string, $regexps)

// Collect the name of all vars in use to initialize them with a null value
$vars = [];
preg_match_all('(\\{@(\\w+)\\})', $template, $matches);
preg_match_all('(@(\\w+))', $template, $matches);
foreach ($matches[1] as $varName)
{
$vars[$varName] = var_export($varName, true) . ' => null';
Expand Down

0 comments on commit 3976892

Please sign in to comment.