blob: feb58a7e27e86aed5065217d3cb6d0481aa8c818 (
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
|
<?php
/**
* PHPPgAdmin v6.0.0-RC7
*/
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
{
public $_element;
public $_siblings = [];
public $_htmlcode;
public $_attributes = [];
use \PHPPgAdmin\Traits\HelperTrait;
/**
* 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($style)
{
$this->set_attribute('style', $style);
}
public function set_class($class)
{
$this->set_attribute('class', $class);
}
public function is_element()
{
$lower_classname = strtolower(get_class($this));
$is_element_string = str_replace('phppgadmin\xhtml\xhtml', '', $lower_classname);
//$this->prtrace('is_element_string', $is_element_string, 'lower_classname', $lower_classname, '__CLASS__');
return $is_element_string;
}
/**
* 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()
{
echo $this->fetch();
}
public function set_attribute($attr, $value)
{
$this->_attributes[$attr] = $value;
}
}
|