Commit 2bb22fa5 authored by Robert Lyon's avatar Robert Lyon

Bug 1838915: Allow externalmedia / iframe sources to use FontAwsome icons if available

behatnotneeded

Change-Id: Ib060fef54ac3ef4a1b881743ed00774e9eb6424a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent a1595373
......@@ -19,9 +19,20 @@ define('SECTION_PAGE', 'iframesites');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('upgrade.php');
define('TITLE', get_string('allowediframesites', 'admin'));
safe_require('blocktype', 'externalvideo');
$iframesources = get_records_menu('iframe_source', '', '', 'name,prefix');
$iframedomains = get_records_menu('iframe_source_icon');
$fa_domains = PluginBlocktypeExternalvideo::get_fa_brand_icons();
$data = array();
foreach ($iframedomains as $name => $domain) {
$data[$name]['name'] = $domain;
$data[$name]['icon'] = favicon_display_url($domain);
$lname = strtolower($name);
if (isset($fa_domains[$lname])) {
$data[$name]['faicon'] = $fa_domains[$lname]['faicon'];
$data[$name]['style'] = $fa_domains[$lname]['style'];
}
}
$newform = pieform(array(
'name' => 'newurl',
......@@ -85,7 +96,7 @@ foreach ($iframesources as $url => $name) {
'id' => $i,
'url' => $url,
'name' => $name,
'icon' => favicon_display_url($iframedomains[$name]),
'icon' => $data[$name],
'editform' => pieform(array(
'name' => 'editurl_' . $i,
'successcallback' => 'editurl_submit',
......
......@@ -364,6 +364,17 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
return false;
}
public static function get_fa_brand_icons() {
return array(
'slideshare' => array('faicon' => 'slideshare', 'style' => 'color: #0077B5'),
'vimeo' => array('faicon' => 'vimeo-square', 'style' => 'color: #1AB7EA'),
'youtube' => array('faicon' => 'youtube', 'style' => 'color: #FF0000'),
'youtube [privacy mode]' => array('faicon' => 'youtube-square', 'style' => 'color: #FF0000'),
'google' => array('faicon' => 'google', 'style' => 'color: #4285f4'),
'googlevideo' => array('faicon' => 'google', 'style' => 'color: #4285f4'),
);
}
/**
* Returns a block of HTML that the external video block can use to show the
* sites for which we will process URLs.
......@@ -372,6 +383,7 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
$source_instances = self::load_media_sources();
$wwwroot = get_config('wwwroot');
$fa_domains = self::get_fa_brand_icons();
$data = array();
foreach ($source_instances as $name => $source) {
$sourcestr = get_string($name, 'blocktype.externalvideo');
......@@ -380,8 +392,12 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
'url' => $source->get_base_url(),
'icon' => $wwwroot . 'blocktype/externalvideo/media_sources/' . $name . '/favicon.png',
);
$lname = strtolower($name);
if (isset($fa_domains[$lname])) {
$data[$sourcestr]['faicon'] = $fa_domains[$lname]['faicon'];
$data[$sourcestr]['style'] = $fa_domains[$lname]['style'];
}
}
ksort($data);
$smarty = smarty_core();
......@@ -398,7 +414,7 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
if (empty($iframedomains)) {
return '';
}
$fa_domains = self::get_fa_brand_icons();
$data = array();
foreach ($iframedomains as $name => $host) {
$data[$name] = array(
......@@ -406,6 +422,11 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
'url' => 'http://' . $host,
'icon' => favicon_display_url($host),
);
$lname = strtolower($name);
if (isset($fa_domains[$lname])) {
$data[$name]['faicon'] = $fa_domains[$lname]['faicon'];
$data[$name]['style'] = $fa_domains[$lname]['style'];
}
}
$smarty = smarty_core();
......@@ -433,6 +454,7 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
}
}
else {
$fa_domains = self::get_fa_brand_icons();
foreach ($service_instances as $name => $service) {
$servicestr = get_string($name, 'blocktype.externalvideo');
$data[$servicestr] = array(
......@@ -440,6 +462,11 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
'url' => $service->get_base_url(),
'icon' => $wwwroot . 'blocktype/externalvideo/embed_services/' . $name . '/favicon.png',
);
$lname = strtolower($name);
if (isset($fa_domains[$lname])) {
$data[$sourcestr]['faicon'] = $fa_domains[$lname]['faicon'];
$data[$sourcestr]['style'] = $fa_domains[$lname]['style'];
}
}
}
......
<ul class="text-inline unstyled">
{foreach from=$data item=item}
<li class="text-inline"><a href="{$item.url}"><img src="{$item.icon}" alt="{$item.name}" title="{$item.name}"></a></li>
<li class="text-inline"><a href="{$item.url}">
{if $item.faicon}
<span class="icon icon-lg icon-{$item.faicon} icon-brand" style="{$item.style}"></span>
{else}
<img src="{$item.icon}" alt="{$item.name}" title="{$item.name}">
{/if}</a></li>
{/foreach}
</ul>
\ No newline at end of file
......@@ -15,8 +15,12 @@
<tbody>
{foreach from=$editurls item=item name=urls}
<tr class="{cycle values='r0,r1' advance=false}">
<th><img src="{$item.icon}" alt="{$item.name}" title="{$item.name}">&nbsp;{$item.name}</th>
<th>{if $item.icon.faicon}
<span class="icon icon-lg icon-brand icon-{$item.icon.faicon}" style="{$item.icon.style}" alt="{$item.name}" title="{$item.name}"></span>
{else}
<img src="{$item.icon.icon}" alt="{$item.name}" title="{$item.name}">
{/if}
{$item.name}</th>
<td>{$item.url}</td>
<td class="buttonscell">
<div class="btn-group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment