1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Improved docs on toGlyph() method.

This commit is contained in:
Cameron
2017-10-20 11:38:31 -07:00
parent e484795de6
commit 8d95e4e176

View File

@@ -3647,32 +3647,36 @@ class e_parser
/** /**
* Parse xxxxx.glyph file to bootstrap glyph format. * Parse xxxxx.glyph file to bootstrap glyph format.
* @param string $text * @param string $text
* @param array of $parms * @param array|string $options
* @param bool $options['size'] 2x, 3x, 4x, or 5x
* @param bool $options['fw'] Fixed-Width
* @param bool $options['spin'] Spin
* @param int $options['rotate'] Rotate in Degrees.
* @example $tp->toGlyph('fa-spinner', 'spin=1'); * @example $tp->toGlyph('fa-spinner', 'spin=1');
* @example $tp->toGlyph('fa-spinner', array('spin'=>1)); * @example $tp->toGlyph('fa-spinner', array('spin'=>1));
* @example $tp->toGlyph('fa-shield', array('rotate'=>90, 'size'=>'2x')); * @example $tp->toGlyph('fa-shield', array('rotate'=>90, 'size'=>'2x'));
*/ */
public function toGlyph($text, $space=" ") public function toGlyph($text, $options=" ")
{ {
if(empty($text)) if(empty($text))
{ {
return false; return false;
} }
if(is_array($space)) if(is_array($options))
{ {
$parm = $space; $parm = $options;
$space = varset($parm['space'],''); $options = varset($parm['space'],'');
} }
elseif(strpos($space,'=')) elseif(strpos($options,'='))
{ {
parse_str($space,$parm); parse_str($options,$parm);
$space = varset($parm['space'],''); $options = varset($parm['space'],'');
} }
else else
{ {
$parm = array(); $parm = array();
} }
@@ -3689,19 +3693,19 @@ class e_parser
return "<i class='".$size." ".$text."'></i>"; return "<i class='".$size." ".$text."'></i>";
} }
// Get Glyph names. // Get Glyph names.
$bs3 = e107::getMedia()->getGlyphs('bs3',''); $bs3 = e107::getMedia()->getGlyphs('bs3','');
$fa4 = e107::getMedia()->getGlyphs('fa4',''); $fa4 = e107::getMedia()->getGlyphs('fa4','');
list($cls) = explode('.glyph',$text,2); list($cls) = explode('.glyph',$text,2);
// list($type, $tmp2) = explode("-",$text,2); // list($type, $tmp2) = explode("-",$text,2);
// return $cls; // return $cls;
$removePrefix = array('glyphicon-','icon-','fa-'); $removePrefix = array('glyphicon-','icon-','fa-');
$id = str_replace($removePrefix, "", $cls); $id = str_replace($removePrefix, "", $cls);
$spin = null; $spin = null;
@@ -3712,17 +3716,17 @@ class e_parser
$tag = 'span'; $tag = 'span';
// return print_r($fa4,true); // return print_r($fa4,true);
if(deftrue('FONTAWESOME') && in_array($id ,$fa4)) // Contains FontAwesome 3 set also. if(deftrue('FONTAWESOME') && in_array($id ,$fa4)) // Contains FontAwesome 3 set also.
{ {
$prefix = 'fa fa-'; $prefix = 'fa fa-';
$size = (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : ''; $size = (vartrue($parm['size'])) ? ' fa-'.$parm['size'] : '';
$tag = 'i'; $tag = 'i';
$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' : "";
} }
elseif(deftrue("BOOTSTRAP")) elseif(deftrue("BOOTSTRAP"))
{ {
if(BOOTSTRAP === 3 && in_array($id ,$bs3)) if(BOOTSTRAP === 3 && in_array($id ,$bs3))
{ {
@@ -3734,23 +3738,23 @@ class e_parser
// $prefix = 'icon-'; // $prefix = 'icon-';
$tag = 'i'; $tag = 'i';
} }
$size = ''; $size = '';
} }
$idAtt = (!empty($parm['id'])) ? "id='".$parm['id']."' " : ''; $idAtt = (!empty($parm['id'])) ? "id='".$parm['id']."' " : '';
$style = (!empty($parm['style'])) ? "style='".$parm['style']."' " : ''; $style = (!empty($parm['style'])) ? "style='".$parm['style']."' " : '';
$class = (!empty($parm['class'])) ? $parm['class']." " : ''; $class = (!empty($parm['class'])) ? $parm['class']." " : '';
$text = "<".$tag." {$idAtt}class='".$class.$prefix.$id.$size.$spin.$rotate.$fixedW."' {$style}></".$tag.">" ; $text = "<".$tag." {$idAtt}class='".$class.$prefix.$id.$size.$spin.$rotate.$fixedW."' {$style}></".$tag.">" ;
$text .= ($space !== false) ? $space : ""; $text .= ($options !== false) ? $options : "";
return $text; return $text;
//$text = preg_replace('/\[(i_[\w]*)\]/',"<i class='$1'></i>", $text); //$text = preg_replace('/\[(i_[\w]*)\]/',"<i class='$1'></i>", $text);
// return $text; // return $text;
} }