<?php
class html {
private $html;
public function __construct($h="") {
$this->html = $h;
}
public function toon() {
return $this->html;
}
public function tag($name,$arg1="",$arg2="",$arg3="") {
switch($name) {
case 'meta':
$this->html .= "<meta name='viewport' content='width=device-width,initial-scale=1,maximum-scale=1'>\n";
break;
case 'link':
$this->html .= "<link rel='$arg1' type='$arg2' href='$arg3'>\n";
break;
case 'script':
$this->html .= "<script src='$arg1'></script>\n";
break;
default:
if ($arg1 == "start") $this->html .= "<$name>\n";
if ($arg1 == "end") $this->html .= "</$name>\n";
if (empty($arg1)) $this->html .= "<$name>\n";
break;
}
}
public function form_start($css="",$action="",$method="POST") {
$this->html .= "<form class='".$css."' action='".$action."' method='".$method."'>\n";
}
public function form_end() {
$this->html .= "</form>\n";
}
public function br() {
$this->html .= "<br />\n";
}
public function h_start($nr,$css="") {
$this->html .= "<h".$nr." class='".$css."'>\n";
}
public function h_end($nr) {
$this->html .= "</h".$nr.">\n";
}
public function anchor($href,$css="",$caption="link",$par="") {
if ($par === "p") {
$this->html .= "<p><a href='".$href."' class='".$css."'>".$caption."</a><p>\n";
} else {
$this->html .= "<a href='".$href."' class='".$css."'>".$caption."</a>\n";
}
}
public function label($css="",$caption="label") {
$this->html .= "<label class='".$css."'><b>".$caption."</b></label>\n";
}
public function input($css="",$type,$name,$value="",$required="",$placeholder="") {
$this->html .= "<input class='".$css."' type='".$type."' name='".$name."' value='".$value."' placeholder='".$placeholder."' ".$required." style='width:98%;'/>\n";
}
public function div_start($css="",$style="",$id="") {
$this->html .= "<div class='".$css."' style='".$style."' id='$id'>\n";
}
public function div_end() {
$this->html .= "</div>\n";
}
public function div($css="",$caption="",$style="") {
$this->html .= "<div class='".$css."' style='".$style."'>".$caption."</div>\n";
}
public function button($css="",$type,$caption="button",$click="") {
$this->html .= "<button class='".$css."' type='".$type."' onclick='$click'>".$caption."</button>\n";
}
public function select_start($css="",$name) {
$this->html .= "<p><select class='".$css."' name='".$name."'>\n";
}
public function select_end() {
$this->html .= "</select></p>\n";
}
public function option($css="",$value,$caption,$selected="",$disabled="") {
$this->html .= "<option class='".$css."' value='".$value."' ".$disabled." ".$selected.">".$caption."</option>\n";
}
}