1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-21 21:57:34 +02:00

Closes #4969, Fixes #5008, Fixes #4498 - FontAwesome6 support.

This commit is contained in:
camer0n
2023-11-17 11:18:23 -08:00
parent bf3ba04430
commit 34ba78023c
13 changed files with 216 additions and 61 deletions

View File

@@ -24,7 +24,7 @@
}
catch(Exception $e)
{
$this->assertTrue(false, $e->getMessage());
$this->fail($e->getMessage());
}
@@ -34,7 +34,7 @@
}
catch(Exception $e)
{
$this->assertTrue(false, $e->getMessage());
$this->fail($e->getMessage());
}
$coreLibraries = $this->corelib->config();
@@ -60,7 +60,7 @@
foreach($lookups as $name)
{
$this->assertFalse(true, "'version' key is missing in core_library:config() -- ".$name);
$this->fail("'version' key is missing in core_library:config() -- " . $name);
}
@@ -71,17 +71,18 @@
foreach($this->libraries as $name)
{
echo $name."\n";
$coded = $this->lib->detect($name);
$detected = $this->lib->detect($name, true);
if(empty($coded['version']))
{
$this->assertTrue(false, "No coded version returned in core_library:config() -- ".$name);
$this->fail("No coded version returned in core_library:config() -- " . $name);
}
if(empty($detected['version']))
{
$this->assertTrue(false, "No looked-up version in core_library:config() -- ".$name);
$this->fail("No looked-up version in core_library:config() -- " . $name);
}
$this->assertSame($coded['version'],$detected['version'], 'Version mismatch in core_library:config() -- '.$name);
@@ -90,6 +91,81 @@
}
public function testCoreLibraryPresence()
{
$coreLibraries = $this->corelib->config();
foreach($coreLibraries as $id => $item)
{
$path = $this->lib->getPath($id);
if(strpos($path, 'http') === 0) // Remote
{
if(!empty($item['files']))
{
foreach($item['files'] as $k=>$v)
{
foreach($v as $file => $info)
{
$url = $path.$file;
$valid = $this->isValidURL($url);
$this->assertTrue($valid, $url.' is not valid. (404)');
}
}
}
}
else // Local
{
if(!empty($item['files']))
{
foreach($item['files'] as $k=>$v)
{
foreach($v as $file => $info)
{
$this->assertStringNotContainsString('//',$path);
$this->assertFileExists($path.$file);
}
}
}
}
}
}
private function isValidURL($url)
{
if(empty($url))
{
return false;
}
if(!$headers = get_headers($url))
{
return false;
}
if(!empty($headers[0]) && strpos($headers[0], 'OK') !== false)
{
return true;
}
return false;
}
/*
public function testInfo()
{

View File

@@ -241,9 +241,9 @@
}
*/
private function compileFontAwesome5Meta()
private function compileFontAwesomeMeta($version)
{
$raw = file_get_contents(e_WEB."lib/font-awesome/5/metadata/icons.json");
$raw = file_get_contents(e_WEB."lib/font-awesome/$version/metadata/icons.json");
$icons = e107::unserialize($raw);
$ret = [];
@@ -261,15 +261,19 @@
}
$ret['fa5-shims'] = $this->compileFontAwesome5Shims();
$ret['fa'.$version.'-shims'] = $this->compileFontAwesomeShims($version);
return $ret;
}
private function compileFontAwesome5Shims()
/**
* @param string $version (major version number. eg. 5 or 6)
* @return array
*/
private function compileFontAwesomeShims($version)
{
$raw = file_get_contents(e_WEB."lib/font-awesome/5/metadata/shims.json");
$raw = file_get_contents(e_WEB."lib/font-awesome/$version/metadata/shims.json");
$icons = e107::unserialize($raw);
$ret = [];
@@ -289,7 +293,7 @@
{
// @todo uncomment to rebuild getGlyphs() arrays for fontawesome. (requires 'metadata' folder)
// $meta = $this->compileFontAwesome5Meta();
// $meta = $this->compileFontAwesomeMeta(6);
// var_export($meta);
// $far = $this->md->getGlyphs('far');
// $this->assertSame($meta['far'], $far);
@@ -299,19 +303,25 @@
// $this->assertSame($meta['fab'], $fab);
// Check that FontAwesome 5 meta arrays are up-to-date.
// FontAwesome 6
$fa6_fas = $this->md->getGlyphs('fa6-fas');
$this->assertContains('wine-glass-empty', $fa6_fas);
$fa6Shims = $this->md->getGlyphs('fa6-shims');
$this->assertArrayHasKey('glass', $fa6Shims);
// FontAwesome 5
$fab = $this->md->getGlyphs('fab');
$fab = $this->md->getGlyphs('fa5-fab');
$this->assertContains('500px', $fab);
$fas = $this->md->getGlyphs('fas');
$fas = $this->md->getGlyphs('fa5-fas');
$this->assertContains('address-book', $fas);
$far = $this->md->getGlyphs('far');
$far = $this->md->getGlyphs('fa5-far');
$this->assertContains('arrow-alt-circle-down', $far);
// Check FontAwesome 4
$fa4 = $this->md->getGlyphs('fas');
$fa4 = $this->md->getGlyphs('fa5-fas');
$this->assertContains('heart', $fa4);
// Check Bootstrap 3
@@ -319,11 +329,11 @@
$this->assertNotEmpty($result['adjust']);
$this->assertNotEmpty($result['zoom-out']);
// Check FontAweomse 5 Shims
// Check FontAwesome 5 Shims
$fa5Shims = $this->md->getGlyphs('fa5-shims');
$this->assertArrayHasKey('glass', $fa5Shims);
$prefixTest = $this->md->getGlyphs('fab', 'myprefix-');
$prefixTest = $this->md->getGlyphs('fa5-fab', 'myprefix-');
$this->assertContains('myprefix-500px', $prefixTest);
}

View File

@@ -2140,6 +2140,13 @@ EXPECTED;
$expected = "<i class='fab fa-mailchimp' ></i> ";
$this->assertEquals($expected, $result);
$this->tp->setFontAwesome(6);
$result = $this->tp->toGlyph('fa-wine-glass-empty');
$expected = "<i class='fas fa-wine-glass-empty' ></i> ";
$this->assertSame($expected, $result);
$result = $this->tp->toGlyph('fa-virus-covid');
$this->assertSame("<i class='fas fa-virus-covid' ></i> ", $result);
$this->tp->setFontAwesome(4);
@@ -2249,6 +2256,19 @@ EXPECTED;
$this->tp->setFontAwesome(5);
$result = $this->tp->toGlyph('fa-paypal.glyph');
$this->assertSame("<i class='fab fa-paypal' ></i> ", $result);
$this->tp->setFontAwesome(6);
$result = $this->tp->toGlyph('fa-paypal.glyph');
$this->assertSame("<i class='fab fa-paypal' ></i> ", $result);
$result = $this->tp->toGlyph('fa-clock.glyph');
$this->assertSame("<i class='fas fa-clock' ></i> ", $result);
$result = $this->tp->toGlyph('clock.glyph');
$this->assertSame("<i class='fas fa-clock' ></i> ", $result);
$this->tp->setFontAwesome(5);
}
/*