diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2015-11-09 12:19:46 -0500 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2015-11-09 12:20:26 -0500 |
commit | 9279147ad26f3c2d32b7e37da010f2346e77a6e7 (patch) | |
tree | e895a6fbf45424d8c57296e89dc6dbb7fdc5762e /src/usr/local/www/classes | |
parent | 3c986c5d90f88d4c20cce1ae58994d5932f415df (diff) | |
download | pfsense-9279147ad26f3c2d32b7e37da010f2346e77a6e7.zip pfsense-9279147ad26f3c2d32b7e37da010f2346e77a6e7.tar.gz |
Allow fa icons to be embedded in Form_Button class buttons
Diffstat (limited to 'src/usr/local/www/classes')
-rw-r--r-- | src/usr/local/www/classes/Form/Button.class.php | 12 | ||||
-rw-r--r-- | src/usr/local/www/classes/Form/Element.class.php | 19 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/usr/local/www/classes/Form/Button.class.php b/src/usr/local/www/classes/Form/Button.class.php index 32876a7..0b2a9de 100644 --- a/src/usr/local/www/classes/Form/Button.class.php +++ b/src/usr/local/www/classes/Form/Button.class.php @@ -36,7 +36,7 @@ class Form_Button extends Form_Input 'type' => 'submit', ); - public function __construct($name, $title, $link = null) + public function __construct($name, $title, $link = null, $icon = null) { // If we have a link; we're actually an <a class='btn'> if (isset($link)) @@ -45,6 +45,16 @@ class Form_Button extends Form_Input $this->_tagName = 'a'; $this->addClass('btn-default'); unset($this->_attributes['type']); + if(isset($icon)) { + $this->_attributes['icon'] = $icon; + } + } + else if(isset($icon)) + { + $this->_tagSelfClosing = false; + $this->_tagName = 'button'; + $this->_attributes['value'] = $title; + $this->_attributes['icon'] = $icon; } else { diff --git a/src/usr/local/www/classes/Form/Element.class.php b/src/usr/local/www/classes/Form/Element.class.php index d3ad142..163c14b 100644 --- a/src/usr/local/www/classes/Form/Element.class.php +++ b/src/usr/local/www/classes/Form/Element.class.php @@ -61,7 +61,7 @@ class Form_Element $this->_attributes[ $key ] = $value; return $this; } - + public function __toString() { $attributes = ''; @@ -79,12 +79,27 @@ class Form_Element if ($value === null) continue; + if ($key == "icon") + continue; + $attributes .= ' '. $key; if ($value !== true) $attributes .= '="' . htmlspecialchars($value) . '"'; } - return '<'. $this->_tagName . $attributes . ($this->_tagSelfClosing ? '/' : '') .'>'; + if (isset($this->_attributes['icon'])) { + $rv = '<'. $this->_tagName . $attributes .'>' . + '<i class="fa ' . $this->_attributes['icon'] . ' icon-embed-btn' . '">' . ' </i>' . + htmlspecialchars($this->_attributes['value']); + + if ($this->_tagName != 'a') { + $rv .= '</' . $this->_tagName . '>'; + } + + return $rv; + } else { + return '<'. $this->_tagName . $attributes . ($this->_tagSelfClosing ? '/' : '') .'>'; + } } protected function _setParent(Form_Element $parent) |