mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Extracted toGlyphEmbed() method from toGlyph() and fixed some backward compatibility issues.
This commit is contained in:
@@ -36,7 +36,9 @@ class search_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
if(isset($parm['label']))
|
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']);
|
unset($parm['label']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3706,6 +3706,34 @@ class e_parse
|
|||||||
return $ret;
|
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.
|
* Parse xxxxx.glyph file to bootstrap glyph format.
|
||||||
@@ -3793,20 +3821,9 @@ class e_parse
|
|||||||
/** @experimental - subject to removal at any time. */
|
/** @experimental - subject to removal at any time. */
|
||||||
if(!empty($parm['embed']))
|
if(!empty($parm['embed']))
|
||||||
{
|
{
|
||||||
$dirs = ['far'=>'regular', 'fab'=>'brands', 'fas'=>'solid'];
|
if($ret = $this->toGlyphEmbed($cat, $id, $parm))
|
||||||
|
|
||||||
$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 ';
|
return $ret;
|
||||||
$class .= $id;
|
|
||||||
$class .= ' fa-w-16';
|
|
||||||
$class .= !empty($parm['fw']) ? ' fa-fw' : '';
|
|
||||||
|
|
||||||
return str_replace('<svg', '<svg class="'.$class.'" role="img" ', $ret);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3830,11 +3847,11 @@ class e_parse
|
|||||||
$prefix = '';
|
$prefix = '';
|
||||||
$id = $shims[$code];
|
$id = $shims[$code];
|
||||||
}
|
}
|
||||||
elseif(in_array($code, $fab))
|
elseif(isset($fab[$code]))
|
||||||
{
|
{
|
||||||
$prefix = 'fab ';
|
$prefix = 'fab ';
|
||||||
}
|
}
|
||||||
elseif(in_array($code, $fas))
|
elseif(isset($fas[$code]))
|
||||||
{
|
{
|
||||||
$prefix = 'fas ';
|
$prefix = 'fas ';
|
||||||
$id = 'fa-'.$code;
|
$id = 'fa-'.$code;
|
||||||
@@ -3853,6 +3870,19 @@ class e_parse
|
|||||||
$prefix = ($this->bootstrap === 3) ? 'glyphicon glyphicon-' : 'fa fa-';
|
$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)
|
elseif($this->fontawesome === 4)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user