-
Notifications
You must be signed in to change notification settings - Fork 0
/
Combo.php
46 lines (41 loc) · 1.3 KB
/
Combo.php
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
<?php
// Lucas Tiago de Moraes
// include class DHX
include_once 'DHX.php';
// class Combo
class Combo extends DHX {
private $document; // ref document
private $complete; // ref complete
public $add; // set add
// auto construct
function __construct($value = ''){
if($value){
$this->encoding($value);
}
$this->document = $this->document();
$this->complete = $this->document->appendChild(new DOMElement('complete'));
}
// public option
public function option(){
$data = func_get_args();
foreach($data as $row){
$option = $this->complete->appendChild(new DOMElement('option'));
foreach($row as $key => $value){
if($key == 'text'){
$option->appendChild($this->document->createTextNode($value));
}elseif($key == 'cdata'){
$option->appendChild(new DOMCdataSection($value));
}else{
$option->setAttributeNode(new DOMAttr($key, $value));
}
}
}
}
// public result
public function result(){
if($this->add){
$this->complete->setAttributeNode(new DOMAttr('add', $this->add));
}
return $this->document->saveXML();
}
}