<?php
//Svacant author hide@address.com - www.svacant.com
//Tag class for generate html code with php, it's very simple
class tag{
var $modality = 'return';
//W3c Check Block
private function w3c_check($tag){
$tags = array('applet','basefont','center','dir','font','isindex','menu','s','strike','u','xmp','embed','marquee');
foreach($tags as $tagd){ if($tag == $tagd){ $this->popup(ucwords('deprecated '.$tagd.' - w3c')); }}
}
function popup($msg){
echo"<script>alert('".$msg."');</script>";
}
//W3c Check Block finish
//Open close Block
public function open_close($tag,$args=''){
//Strtolower the vars for standard w3c
$tag=strtolower($tag);
//Open the tag and attach arguments
$args = $this->get_arguments($args);
$this->w3c_check($tag);
return $this->mode_view("\n\t<$tag$args />\n");
}
//Open close Block finish
public function open_b2w($tag,$args='',$text='Specify Text'){
//Strtolower the vars for standard w3c
$tag=strtolower($tag);
//Open the tag and attach arguments
$args = $this->get_arguments($args);
$this->w3c_check($tag);
return $this->mode_view("\n<$tag$args>$text</$tag>\n");
}
public function open($tag,$args=''){
//Strtolower the vars for standard w3c
$tag=strtolower($tag);
//Open the tag and attach arguments
$args = $this->get_arguments($args);
$this->w3c_check($tag);
return $this->mode_view("\n\t<$tag$args>\n");
}
public function close($tag){
//Strtolower the vars for standard w3c
$tag=strtolower($tag);
//Simple close Tag
return $this->mode_view("\n\t</$tag>\n ");
}
private function get_arguments($args){
if(!$args){ return; }
//Explode arguments
preg_match_all('/(\w+?)=(.+?)(?=(,\w+=|$))/', $args, $matches, PREG_SET_ORDER);
foreach($matches as $match){
$match[2] = str_replace('"','\'',$match[2]);
$arguments .= ' '.strtolower($match[1]).'="'.$match[2].'"';
}
//Give the arguments
return $arguments;
}
private function mode_view($data){
if($this->modality == 'return'){
return $data;
}else{
echo $data;
}
}
public function __tostring(){
return "\n<b>Not use \$tag variable</b>\n";
}
}
?>