<?php
/* HTML tag functions.
*
* Written by: Chris Studholme
* Copyright: GPL (http://www.fsf.org/copyleft/gpl.html)
* $Id: html.php,v 1.1 2003/12/23 06:07:15 cstudhol Exp $
*/
$HTML_VERIFIER = false;
if ($DEBUG_LEVEL>0) {
require("include/html_verifier.php");
$HTML_VERIFIER = new HTMLVerifier();
}
/* Full tag. This function also accepts the prototype tag($tag,$content).
*/
function tag($tag,$attributes=false,$content=false) {
$result = "<".$tag;
if (is_array($attributes)) {
reset($attributes);
while (list($key,$value)=each($attributes)) {
if (!is_bool($value)) {
if (!ereg("\"",$value))
$result .= " ".$key."=\"".$value."\"";
else
$result .= " ".$key."='".$value."'";
}
else if ($value)
$result .= " ".$key;
}
}
else if ($content==false)
$content = $attributes;
$result.=">".$content."</".$tag.">";
global $HTML_VERIFIER;
if ($HTML_VERIFIER)
$HTML_VERIFIER->check_tag($tag,$attributes,$content,$result);
return $result;
}
/* singleton tag (no end tag)
*/
function stag($tag,$attributes=false) {
$result = "<".$tag;
if (is_array($attributes)) {
reset($attributes);
while (list($key,$value)=each($attributes)) {
if (!is_bool($value)) {
if (!ereg("\"",$value))
$result .= " ".$key."=\"".$value."\"";
else
$result .= " ".$key."='".$value."'";
}
else if ($value)
$result .= " ".$key;
}
}
$result.=">";
global $HTML_VERIFIER;
if ($HTML_VERIFIER)
$HTML_VERIFIER->check_stag($tag,$attributes,$result);
return $result;
}
/* begin tag
*/
function btag($tag,$attributes=false) {
$result = "<".$tag;
if (is_array($attributes)) {
reset($attributes);
while (list($key,$value)=each($attributes)) {
if (!is_bool($value))
$result .= " ".$key."=\"".
ereg_replace("\"","\\\"",$value)."\"";
else if ($value)
$result .= " ".$key;
}
}
$result.=">";
global $HTML_VERIFIER;
if ($HTML_VERIFIER)
$HTML_VERIFIER->check_btag($tag,$attributes,$result);
return $result;
}
/* end tag
*/
function etag($tag) {
$result="</".$tag.">";
global $HTML_VERIFIER;
if ($HTML_VERIFIER)
$HTML_VERIFIER->check_etag($tag,$result);
return $result;
}
// create a script to automatically reload the parent of this window
function html_reload_parent() {
//return tag("script","window.opener.location=window.opener.location;");
return tag("script","window.opener.location.reload();");
}
// create script to automatically close a popup window
function html_close_popup() {
echo tag("script","window.close();")."\n";
}
?>