blob: 0f84535ec36e83dacf7c84e615f36def83fecebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
namespace Icinga\Web\Form\Decorator;
use Zend_Form_Decorator_Abstract;
/**
* Decorator to hide elements using a >noscript< tag instead of
* type='hidden' or css styles.
*
* This allows to hide depending elements for browsers with javascript
* (who can then automatically refresh their pages) but show them in
* case JavaScript is disabled
*/
class ConditionalHidden extends Zend_Form_Decorator_Abstract
{
/**
* Generate a field that will be wrapped in <noscript> tag if the
* "condition" attribute is set and false or 0
*
* @param string $content The tag's content
*
* @return string The generated tag
*/
public function render($content = '')
{
$attributes = $this->getElement()->getAttribs();
$condition = isset($attributes['condition']) ? $attributes['condition'] : 1;
if ($condition != 1) {
$content = '<noscript>' . $content . '</noscript>';
}
return $content;
}
}
|