1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

toGlyph() speed optimization and fixes for custom glyphs set by theme.xml

This commit is contained in:
Cameron 2017-11-03 18:52:49 -07:00
parent ad485cd198
commit 6947cedf88
3 changed files with 58 additions and 13 deletions

View File

@ -1244,6 +1244,11 @@ class e107
}
$arr[] = $glyphConfig;
if(E107_DBG_INCLUDES)
{
e107::getDebug()->log("Loading Glyph Icons: ".print_a($glyphConfig,true));
}
}
}

View File

@ -3883,8 +3883,8 @@ class e_parser
}
// Get Glyph names.
$bs3 = e107::getMedia()->getGlyphs('bs3','');
$fa4 = e107::getMedia()->getGlyphs('fa4','');
// $bs3 = e107::getMedia()->getGlyphs('bs3','');
// $fa4 = e107::getMedia()->getGlyphs('fa4','');
@ -3893,19 +3893,21 @@ class e_parser
// return $cls;
$removePrefix = array('glyphicon-','icon-','fa-');
// $removePrefix = array('glyphicon-','icon-','fa-');
$id = str_replace($removePrefix, "", $cls);
// $id = str_replace($removePrefix, "", $cls);
$id = $cls;
$spin = null;
$rotate = null;
$fixedW = null;
$prefix = null;
$prefix = 'fa fa-'; // fallback
$size = null;
$tag = 'span';
// return print_r($fa4,true);
/*
if(deftrue('FONTAWESOME') && in_array($id ,$fa4)) // Contains FontAwesome 3 set also.
{
$prefix = 'fa fa-';
@ -3931,6 +3933,45 @@ class e_parser
$size = '';
}
*/
if(strpos($text, 'fa-') === 0) // Font-Awesome
{
$prefix = 'fa ';
$size = (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : '';
$tag = 'i';
$spin = !empty($parm['spin']) ? ' fa-spin' : '';
$rotate = !empty($parm['rotate']) ? ' fa-rotate-'.intval($parm['rotate']) : '';
$fixedW = !empty($parm['fw']) ? ' fa-fw' : "";
}
elseif(strpos($text, 'glyphicon-') === 0) // Bootstrap 3
{
$prefix = 'glyphicon ';
$tag = 'span';
}
elseif(strpos($text, 'icon-') === 0) // Bootstrap 2
{
$prefix = '';
$tag = 'i';
}
elseif($custom = e107::getThemeGlyphs()) // Custom Glyphs
{
foreach($custom as $glyphConfig)
{
if(strpos($text, $glyphConfig['prefix']) === 0)
{
$prefix = $glyphConfig['class'] . " ";
$tag = $glyphConfig['tag'];
continue;
}
}
}
$idAtt = (!empty($parm['id'])) ? "id='".$parm['id']."' " : '';
$style = (!empty($parm['style'])) ? "style='".$parm['style']."' " : '';
@ -3942,8 +3983,6 @@ class e_parser
return $text;
//$text = preg_replace('/\[(i_[\w]*)\]/',"<i class='$1'></i>", $text);
// return $text;
}

View File

@ -736,6 +736,7 @@ class e_theme
'name' => $val['@attributes']['name'],
'pattern' => $val['@attributes']['pattern'],
'path' => $val['@attributes']['path'],
'class' => $val['@attributes']['class'],
'prefix' => $val['@attributes']['prefix'],
'tag' => $val['@attributes']['tag'],
);