fieldset = 0;
$this->html = new \DOMDocument('1.0', 'UTF-8');
$this->xmpp = '';
}
public function getHTML($xmpp){
$this->setXMPP($xmpp);
$this->create();
return $this->html->saveXML();
}
public function setXMPP($xmpp){
$this->xmpp = $xmpp;
}
public function create(){
$this->xmpp = str_replace('xmlns=', 'ns=', $this->xmpp);
$x = new SimpleXMLElement($this->xmpp);
foreach($x->children() as $element){
switch($element->getName()){
case "title":
$this->outTitle($element);
break;
case "instructions":
$this->outP($element);
break;
case "field":
//if($element['type'] != 'hidden' && $element['type'] != 'fixed')
// $this->html .='
';
switch($element['type']){
case "boolean":
$this->outCheckbox($element);
break;
//case "fixed":
// $this->outBold($element);
// break;
case "text-single":
$this->outInput($element, "", "");
break;
case "text-multi":
$this->outTextarea($element);
break;
case "text-private":
$this->outInput($element, "password", "");
break;
case "hidden":
$this->outHiddeninput($element);
break;
case "list-multi":
//$this->outList($element);
break;
case "list-single":
$this->outList($element);
break;
case "jid-multi":
$this->outInput($element, "email", "multiple");
break;
case "jid-single":
$this->outInput($element, "email", "");
break;
default:
//$this->html .= "";
}
//if($element['type'] != 'hidden')
// $this->html .='
';
break;
case 'url':
break;
/*XML without element*/
case 'username':
case 'email':
case 'password':
//$this->html .='';
$this->outGeneric($element->getName());
//$this->html .='
';
break;
default:
//$this->html .= "";
}
}
/*if($this->fieldset>0){
$this->html .= '';
}*/
}
private function outGeneric($s){
$div = $this->html->createElement('div');
$div->setAttribute('class', 'element');
$this->html->appendChild($div);
$input = $this->html->createElement('input');
$input->setAttribute('type', $s);
$input->setAttribute('id', $s);
$input->setAttribute('name', 'generic_'.$s);
$input->setAttribute('required', 'required');
$div->appendChild($input);
$label = $this->html->createElement('label', $s);
$label->setAttribute('for', $s);
$div->appendChild($label);
}
private function outTitle($s){
$ul = $this->html->createElement('ul');
$ul->setAttribute('class', 'list thin');
$this->html->appendChild($ul);
$li = $this->html->createElement('li');
$title = $this->html->createElement('p', $s);
$title->setAttribute('class', 'normal line');
$li->appendChild($title);
$ul->appendChild($li);
}
private function outP($s){
$ul = $this->html->createElement('ul');
$ul->setAttribute('class', 'list thin');
$this->html->appendChild($ul);
$li = $this->html->createElement('li');
$ul->appendChild($li);
$title = $this->html->createElement('p', $s);
$title->setAttribute('class', 'normal line');
$li->appendChild($title);
}
private function outUrl($s) {
$a = $this->html->createElement('a', $s->getName());
$a->setAttribute('href', $s->getName());
$this->html->appendChild($a);
}
/*
private function outBold($s){
if($this->fieldset > 0){
$this->html .= '';
}
$this->html .= '