blob: 55b3d0adfc05d5b2a6dd6d86c86680c7ee113596 (
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
|
<?php
/**
* PHPPgAdmin v6.0.0-beta.51
*/
namespace PHPPgAdmin\XHtml;
/**
* XHtmlElement.
*
* Used to generate Xhtml-Code for xhtml elements
* that can contain child elements
*/
class XHtmlElement extends XHtmlSimpleElement
{
public $_text;
public $_htmlcode = '';
public $_siblings = [];
public function __construct($text = null)
{
parent::__construct();
if ($text) {
$this->set_text($text);
}
}
/*
* Adds an xhtml child to element
*
* @param XHtmlElement $object The element to become a child of element
*/
public function add(&$object)
{
array_push($this->_siblings, $object);
}
/*
* The CDATA section of Element
*
* @param string $text Text content of the element
*/
public function set_text($text)
{
if ($text) {
$this->_text = htmlspecialchars($text);
}
}
public function fetch()
{
return $this->_html();
}
public function _html()
{
$this->_htmlcode = "<{$this->_element}";
foreach ($this->_attributes as $attribute => $value) {
if (!empty($value)) {
$this->_htmlcode .= sprintf(' %s="%s" ', $attribute, $value);
}
}
$this->_htmlcode .= '>';
if ($this->_text) {
$this->_htmlcode .= $this->_text;
}
foreach ($this->_siblings as $obj) {
$this->_htmlcode .= $obj->fetch();
}
$this->_htmlcode .= "</{$this->_element}>";
return $this->_htmlcode;
}
// Returns siblings of Element
public function get_siblings()
{
return $this->_siblings;
}
public function has_siblings()
{
return 0 != count($this->_siblings);
}
}
|