blob: 500c93d6629ea3c9f1ac5a1762225ed8f8bcf9bc (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
/**
* PHPPgAdmin 6.1.0
*/
namespace PHPPgAdmin\XHtml;
/**
* XHtmlSimpleElement.
*
* Used to generate Xhtml-Code for simple xhtml elements
* (i.e. elements, that can't contain child elements)
*
* @author Felix Meinhold
*/
class XHtmlSimpleElement
{
use \PHPPgAdmin\Traits\HelperTrait;
public $_element;
public $_siblings = [];
public $_htmlcode;
public $_attributes = [];
public $container;
/**
* Constructor.
*
* @param null|mixed $element The element's name. Defaults to name of the
* derived class
*/
public function __construct($element = null)
{
$this->_element = $this->is_element();
}
public function set_style(string $style): void
{
$this->set_attribute('style', $style);
}
public function set_class($class): void
{
$this->set_attribute('class', $class);
}
public function is_element()
{
$lower_classname = \mb_strtolower(\get_class($this));
return \str_replace('phppgadmin\xhtml\xhtml', '', $lower_classname);
}
/**
* Private function generates xhtml.
*/
public function _html()
{
$this->_htmlcode = '<';
foreach ($this->_attributes as $attribute => $value) {
if (!empty($value)) {
$this->_htmlcode .= \sprintf(' %s="%s" ', $attribute, $value);
}
}
$this->_htmlcode .= '/>';
return $this->_htmlcode;
}
/**
* Returns xhtml code.
*/
public function fetch()
{
return $this->_html();
}
/**
* Echoes xhtml.
*/
public function show(): void
{
echo $this->fetch();
}
public function set_attribute(string $attr, string $value): void
{
$this->_attributes[$attr] = $value;
}
}
|