Skip to content

Commit

Permalink
Merge pull request #2236 from splitbrain/AddSVGToButtons
Browse files Browse the repository at this point in the history
feat: add optionally an SVG to html_btn
  • Loading branch information
splitbrain committed Jan 24, 2018
2 parents e6517f1 + e824d63 commit a409094
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions inc/Menu/Item/AbstractItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public function asHtmlLink($classprefix = 'menuitem ', $svg = true) {
*
* Uses html_btn()
*
* @todo this does currently not support the SVG icon
* @return string
*/
public function asHtmlButton() {
Expand All @@ -182,7 +181,8 @@ public function asHtmlButton() {
$this->getParams(),
$this->method,
$this->getTitle(),
$this->getLabel()
$this->getLabel(),
$this->getSvg()
);
}

Expand Down
12 changes: 9 additions & 3 deletions inc/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ function html_topbtn(){
* @param string $method
* @param string $tooltip
* @param bool|string $label label text, false: lookup btn_$name in localization
* @param string $svg (optional) svg code, inserted into the button
* @return string
*/
function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false){
function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false, $svg=null){
global $conf;
global $lang;

Expand Down Expand Up @@ -233,7 +234,12 @@ function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label
$ret .= 'accesskey="'.$akey.'" ';
}
$ret .= 'title="'.$tip.'">';
$ret .= hsc($label);
if ($svg) {
$ret .= '<span>' . hsc($label) . '</span>';
$ret .= inlineSVG($svg);
} else {
$ret .= hsc($label);
}
$ret .= '</button>';
$ret .= '</div></form>';

Expand Down Expand Up @@ -2314,4 +2320,4 @@ function html_sizechange($sizechange, Doku_Form $form) {
$form->addElement($value);
$form->addElement(form_makeCloseTag('span'));
}
}
}

0 comments on commit a409094

Please sign in to comment.