1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 11:20:25 +02:00

FontAwesome5 support in toGlyph();

This commit is contained in:
Cameron
2019-02-26 15:03:29 -08:00
parent 8607d9454b
commit a6a5f84bc2

View File

@@ -3752,14 +3752,19 @@ class e_parser
/** /**
* @var DOMDocument * @var DOMDocument
*/ */
public $domObj = null; public $domObj = null;
public $isHtml = false; public $isHtml = false;
protected $removedList = array();
protected $nodesToDelete = array();
protected $nodesToConvert = array(); protected $bootstrap = null;
protected $nodesToDisableSC = array(); protected $fontawesome = null;
protected $pathList = array();
protected $allowedAttributes = array( protected $removedList = array();
protected $nodesToDelete = array();
protected $nodesToConvert = array();
protected $nodesToDisableSC = array();
protected $pathList = array();
protected $allowedAttributes = array(
'default' => array('id', 'style', 'class'), 'default' => array('id', 'style', 'class'),
'img' => array('id', 'src', 'style', 'class', 'alt', 'title', 'width', 'height'), 'img' => array('id', 'src', 'style', 'class', 'alt', 'title', 'width', 'height'),
'a' => array('id', 'href', 'style', 'class', 'title', 'target'), 'a' => array('id', 'href', 'style', 'class', 'title', 'target'),
@@ -3816,6 +3821,16 @@ class e_parser
{ {
$this->domObj = new DOMDocument(); $this->domObj = new DOMDocument();
if(defined('FONTAWESOME'))
{
$this->fontawesome = (int) FONTAWESOME;
}
if(defined('BOOTSTRAP'))
{
$this->bootstrap = (int) BOOTSTRAP;
}
} }
@@ -3887,6 +3902,24 @@ class e_parser
$this->scriptTags = $array; $this->scriptTags = $array;
} }
/**
* @param int $version
*/
public function setFontAwesome($version)
{
$this->fontawesome = (int) $version;
}
/**
* @param int $version
*/
public function setBootstrap($version)
{
$this->bootstrap = (int) $version;
}
/** /**
* Add leading zeros to a number. eg. 3 might become 000003 * Add leading zeros to a number. eg. 3 might become 000003
* @param $num integer * @param $num integer
@@ -4089,7 +4122,7 @@ class e_parser
} }
*/ */
if(strpos($text, 'fa-') === 0) // Font-Awesome if(strpos($text, 'fa-') === 0) // Font-Awesome 4 & 5
{ {
$prefix = 'fa '; $prefix = 'fa ';
$size = (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : ''; $size = (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : '';
@@ -4097,6 +4130,25 @@ class e_parser
$spin = !empty($parm['spin']) ? ' fa-spin' : ''; $spin = !empty($parm['spin']) ? ' fa-spin' : '';
$rotate = !empty($parm['rotate']) ? ' fa-rotate-'.intval($parm['rotate']) : ''; $rotate = !empty($parm['rotate']) ? ' fa-rotate-'.intval($parm['rotate']) : '';
$fixedW = !empty($parm['fw']) ? ' fa-fw' : ""; $fixedW = !empty($parm['fw']) ? ' fa-fw' : "";
if($this->fontawesome === 5)
{
$fab = e107::getMedia()->getGlyphs('fab');
$fas = e107::getMedia()->getGlyphs('fas');;
$code = substr($id,3);
if(in_array($code,$fab))
{
$prefix = "fab ";
}
elseif(in_array($code,$fas))
{
$prefix = "fas ";
}
}
} }
elseif(strpos($text, 'glyphicon-') === 0) // Bootstrap 3 elseif(strpos($text, 'glyphicon-') === 0) // Bootstrap 3
{ {
@@ -4106,7 +4158,7 @@ class e_parser
} }
elseif(strpos($text, 'icon-') === 0) // Bootstrap 2 elseif(strpos($text, 'icon-') === 0) // Bootstrap 2
{ {
if(deftrue('BOOTSTRAP') != 2) // bootrap 2 icon but running bootstrap3. if($this->bootstrap !== 2) // bootrap 2 icon but running bootstrap3.
{ {
$prefix = 'glyphicon '; $prefix = 'glyphicon ';
$tag = 'span'; $tag = 'span';
@@ -4721,7 +4773,7 @@ class e_parser
$ytqry = http_build_query($ytpref, null, '&'); $ytqry = http_build_query($ytpref, null, '&');
$defClass = (deftrue('BOOTSTRAP')) ? "embed-responsive embed-responsive-16by9" : "video-responsive"; // levacy backup. $defClass = !empty($this->bootstrap) ? "embed-responsive embed-responsive-16by9" : "video-responsive"; // levacy backup.
if($type === 'youtube') if($type === 'youtube')