1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Corrected processing of Glyph-types.

This commit is contained in:
Cameron
2014-01-28 05:59:40 -08:00
parent 2ff9c7cc76
commit d5e6dd0366
2 changed files with 37 additions and 31 deletions

View File

@@ -2713,36 +2713,41 @@ class e_parser
return "<i class='".$size." ".$text."'></i>"; return "<i class='".$size." ".$text."'></i>";
} }
// Bootstrap 3 Glyph names. // Get Glyph names.
$bs3 = e107::getMedia()->getGlyphs('bs3',''); $bs3 = e107::getMedia()->getGlyphs('bs3','');
$fa4 = e107::getMedia()->getGlyphs('fa4','');
if(substr($text,0,5) != 'icon-' && substr($text,0,3) != 'fa-')
{
$text = 'icon-'.$text.'.glyph';
}
list($cls,$tmp) = explode('.glyph',$text); list($cls,$tmp) = explode('.glyph',$text);
list($type, $tmp2) = explode("-",$text,2); // list($type, $tmp2) = explode("-",$text,2);
$id = str_replace("icon-","",$cls); $removePrefix = array('glyphicon-','icon-','fa-');
if(deftrue('FONTAWESOME') == 4 && !in_array($id ,$bs3)) // Convert FontAwesome 3 to 4. $id = str_replace($removePrefix, "", $cls);
// return print_r($fa4,true);
if(deftrue('FONTAWESOME') && in_array($id ,$fa4)) // Contains FontAwesome 3 set also.
{ {
$cls = str_replace('icon-', 'fa fa-', $cls); $prefix = 'fa fa-';
$prefix .= (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : '';
$tag = 'span';
} }
elseif(defset("BOOTSTRAP")===3) elseif(deftrue("BOOTSTRAP"))
{ {
$cls = str_replace('icon-', 'glyphicon glyphicon-', $cls); if(BOOTSTRAP === 3 && in_array($id ,$bs3))
{
$prefix = 'glyphicon glyphicon-';
$tag = 'span';
}
else
{
$prefix = 'icon-';
$tag = 'i';
}
} }
if($type == 'fa') $text = "<".$tag." class='".$prefix.$id."'></".$tag.">" ;
{
$cls = str_replace('fa-', 'fa fa-', $cls);
$cls .= (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : '';
}
// $text = (deftrue('BOOTSTRAP') === 3) ? "<span class='".$cls."'></span>" : "<i class='".$cls."'></i>"; // retain space.
$text = "<span class='".$cls."'></span>" ;
$text .= ($space !== false) ? $space : ""; $text .= ($space !== false) ? $space : "";
return $text; return $text;

View File

@@ -830,7 +830,7 @@ class e_media
} }
$cache = e107::getCache(); $cache = e107::getCache();
$cache->setMD5('_'); $cache->setMD5('_'.$prefix.$type);
if($data = $cache->retrieve($type,360,true)) if($data = $cache->retrieve($type,360,true))
{ {
@@ -840,12 +840,13 @@ class e_media
if($type == 'fa4') if($type == 'fa4')
{ {
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"(.+)";\s+}/'; $pattern = '/\.(fa-(?:\w+(?:-)?)+):before/';
$subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'); $subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
// print_a($subject);
} }
elseif($type == 'fa3') elseif($type == 'fa3')
{ {
$pattern = '/\.(icon-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"(.+)";\s+}/'; $pattern = '/\.(icon-(?:\w+(?:-)?)+):before/';
$subject = file_get_contents(e_WEB_JS.'font-awesome/css/font-awesome.css'); $subject = file_get_contents(e_WEB_JS.'font-awesome/css/font-awesome.css');
} }
@@ -855,7 +856,7 @@ class e_media
foreach($matches as $match) foreach($matches as $match)
{ {
$icons[] = $match[1]; $icons[] = $prefix.substr($match[1],3);
} }
$data = e107::serialize($icons); $data = e107::serialize($icons);