mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 04:38:27 +01:00
Extracted toGlyphEmbed() method from toGlyph() and fixed some backward compatibility issues.
This commit is contained in:
parent
26afb93b4e
commit
c3d65075d0
@ -36,7 +36,9 @@ class search_shortcodes extends e_shortcode
|
||||
|
||||
if(isset($parm['label']))
|
||||
{
|
||||
$label = (strpos($parm['label'], '.glyph')!==false) ? e107::getParser()->toGlyph($parm['label'],'') : LAN_SEARCH;
|
||||
$opts = $parm;
|
||||
unset($opts['label'],$opts['class']);
|
||||
$label = (strpos($parm['label'], '.glyph')!==false) ? e107::getParser()->toGlyph($parm['label'], $opts) : LAN_SEARCH;
|
||||
unset($parm['label']);
|
||||
}
|
||||
|
||||
|
@ -3706,6 +3706,34 @@ class e_parse
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Glyph Embed Method Direct from svg file.
|
||||
* @param string $cat far|fab|fas
|
||||
* @param string $id eg. fa-search
|
||||
* @param array $parm eg. ['fw'=>true]
|
||||
* @return array|false|string|string[]|void
|
||||
*/
|
||||
private function toGlyphEmbed($cat, $id, $parm=array())
|
||||
{
|
||||
$dirs = ['far'=>'regular', 'fab'=>'brands', 'fas'=>'solid'];
|
||||
$path = e_WEB.'lib/font-awesome/5/svgs/';
|
||||
$path .= $dirs[$cat].'/';
|
||||
$path .= str_replace('fa-','',$id).".svg";
|
||||
|
||||
if($ret = file_get_contents($path))
|
||||
{
|
||||
$class = 'svg-inline--fa ';
|
||||
$class .= $id;
|
||||
$class .= ' fa-w-16';
|
||||
$class .= !empty($parm['fw']) ? ' fa-fw' : '';
|
||||
|
||||
return str_replace('<svg', '<svg class="'.$class.'" role="img" ', $ret);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse xxxxx.glyph file to bootstrap glyph format.
|
||||
@ -3793,20 +3821,9 @@ class e_parse
|
||||
/** @experimental - subject to removal at any time. */
|
||||
if(!empty($parm['embed']))
|
||||
{
|
||||
$dirs = ['far'=>'regular', 'fab'=>'brands', 'fas'=>'solid'];
|
||||
|
||||
$path = e_WEB.'lib/font-awesome/5/svgs/';
|
||||
$path .= $dirs[$cat].'/';
|
||||
$path .= str_replace('fa-','',$id).".svg";
|
||||
|
||||
if($ret = file_get_contents($path))
|
||||
if($ret = $this->toGlyphEmbed($cat, $id, $parm))
|
||||
{
|
||||
$class = 'svg-inline--fa ';
|
||||
$class .= $id;
|
||||
$class .= ' fa-w-16';
|
||||
$class .= !empty($parm['fw']) ? ' fa-fw' : '';
|
||||
|
||||
return str_replace('<svg', '<svg class="'.$class.'" role="img" ', $ret);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3830,11 +3847,11 @@ class e_parse
|
||||
$prefix = '';
|
||||
$id = $shims[$code];
|
||||
}
|
||||
elseif(in_array($code, $fab))
|
||||
elseif(isset($fab[$code]))
|
||||
{
|
||||
$prefix = 'fab ';
|
||||
}
|
||||
elseif(in_array($code, $fas))
|
||||
elseif(isset($fas[$code]))
|
||||
{
|
||||
$prefix = 'fas ';
|
||||
$id = 'fa-'.$code;
|
||||
@ -3853,6 +3870,19 @@ class e_parse
|
||||
$prefix = ($this->bootstrap === 3) ? 'glyphicon glyphicon-' : 'fa fa-';
|
||||
}
|
||||
|
||||
/** @experimental - subject to removal at any time. */
|
||||
if(!empty($parm['embed']))
|
||||
{
|
||||
$cat = trim($prefix);
|
||||
|
||||
if($ret = $this->toGlyphEmbed($cat, $id, $parm))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
$cat = trim($prefix);
|
||||
|
||||
}
|
||||
elseif($this->fontawesome === 4)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user