Skip to content

Commit

Permalink
improve html_sizechange() to recognize form class
Browse files Browse the repository at this point in the history
  • Loading branch information
ssahara committed Jul 10, 2020
1 parent 0fb48f9 commit b0f23f4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions inc/html.php
Expand Up @@ -2361,24 +2361,30 @@ function html_tab($href, $caption, $selected=false) {
* Display size change
*
* @param int $sizechange - size of change in Bytes
* @param Doku_Form $form - form to add elements to
* @param Form|Doku_Form $form - form to add elements to
*/

function html_sizechange($sizechange, Doku_Form $form) {
function html_sizechange($sizechange, &$form) {
if(isset($sizechange)) {
$class = 'sizechange';
$value = filesize_h(abs($sizechange));
if($sizechange > 0) {
if ($sizechange > 0) {
$class .= ' positive';
$value = '+' . $value;
} elseif($sizechange < 0) {
} elseif ($sizechange < 0) {
$class .= ' negative';
$value = '-' . $value;
} else {
$value = '±' . $value;
}
$form->addElement(form_makeOpenTag('span', array('class' => $class)));
$form->addElement($value);
$form->addElement(form_makeCloseTag('span'));
if ($form instanceof dokuwiki\Form\Form) {
$form->addTagOpen('span')->addClass($class);
$form->addHTML($value);
$form->addTagClose('span');
} else { // Doku_Form
$form->addElement(form_makeOpenTag('span', array('class' => $class)));
$form->addElement($value);
$form->addElement(form_makeCloseTag('span'));
}
}
}

0 comments on commit b0f23f4

Please sign in to comment.