Location: PHPKode > projects > BBS_Bulletin_Board > bbs_bulletin_board/cgi.php
<?php

class mytag
{
var $tagname;
var $tag="";

    function mytag()
    {
        $nargs = func_get_args();
        $atts = NULL;
        $cntr = 0;
        $endnow = false;
    
        $this->tagname = $nargs[0];
        $args = $nargs[1];
        
        if(isset($args[0]) && is_array($args[0]))
        {
          $atts = $args[0]; 
          $cntr = 1;
        }
   
        $stop = count($args);

        // cntr > 0 if atts array exists
        if($stop > $cntr)
            $endnow = true;
 
        $this->tag = '<'.$this->tagname;
        if($atts != NULL)
        {
          while(list($k,$v)=each($atts))
          {
             $this->tag .= " ".$k."=\"".$v."\" ";
          }
        }
        $this->tag .= '>';

        for($i=$cntr; $i<$stop; $i++)
        {
          $this->tag .= $args[$i];
        }
       if($endnow)
          $this->tag .=  '</' . $this->tagname. '>'; 
    }

    function getTag()
    { 
        return $this->tag; 
    }
}


function tr()
{
   $args = func_get_args();
   $tag = new mytag("tr", $args);
   return $tag->getTag();
}

function td()
{
   $args = func_get_args();
   $tag = new mytag("td", $args);
   return $tag->getTag();
}

function th()
{
   $args = func_get_args();
   $tag = new mytag("th", $args);
   return $tag->getTag();
}

function i()
{
   $args = func_get_args();
   $tag = new mytag("i", $args);
   return $tag->getTag();
}

function b()
{
   $args = func_get_args();
   $tag = new mytag("b", $args);
   return $tag->getTag();
}

function h1()
{
   $args = func_get_args();
   $tag = new mytag("h1", $args);
   return $tag->getTag();
}

function h2()
{
   $args = func_get_args();
   $tag = new mytag("h2", $args);
   return $tag->getTag();
}

function h3()
{
   $args = func_get_args();
   $tag = new mytag("h3", $args);
   return $tag->getTag();
}

function h4()
{
   $args = func_get_args();
   $tag = new mytag("h4", $args);
   return $tag->getTag();
}


function a()
{
   $args = func_get_args();
   $tag = new mytag("a", $args);
   return $tag->getTag();
}

function table()
{
   $args = func_get_args();
   $tag = new mytag("table", $args);
   return $tag->getTag();
}

function p()
{
   $args = func_get_args();
   $tag = new mytag("p", $args);
   return $tag->getTag();
}

function div()
{
   $args = func_get_args();
   $tag = new mytag("div", $args);
   return $tag->getTag();
}

function body()
{
   $args = func_get_args();
   $tag = new mytag("body", $args);
   return $tag->getTag();
}

function doctype()
{
 return ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';

}

function myheader($stylesheet='bbs.css')
{
 $header = '<head><link rel="stylesheet" href="'.$stylesheet.'" type="text/css"/>
 <title>Driftboat builder\'s quesion and answer forum</title>
</head>';

 return $header;
}

function html()
{
   $str = doctype() . "\n<html>";
   return $str;
}

function center()
{
   $args = func_get_args();
   $tag = new mytag("center", $args);
   return $tag->getTag();
}

function hr()
{
   $args = func_get_args();
   $tag = new mytag("hr", $args);
   return $tag->getTag();
}

function font()
{
   $args = func_get_args();
   $tag = new mytag("font", $args);
   return $tag->getTag();
}

function textfield()
{
   $aargs = func_get_args();
   $args = $aargs[0];
   $ret = '<input type="text" ';
   while(list($k,$v)=each($args))
     $ret .= ' '.$k.'="'.trim($v).'" ';
   $ret .= ' />';
   return $ret;
}

function hidden()
{
   $aargs = func_get_args();
   $args = $aargs[0];
   
   $ret = '<input type="hidden" ';
   while(list($k,$v)=each($args))
     $ret .= ' '.$k.'="'.$v.'" ';
   $ret .= ' />';
   return $ret;
}

function submit()
{
   $args = func_get_args();
   $cntr = 0;
   $atts = NULL;
   if(is_array($atts))
   {
        $cntr = 1;
        $atts = $args[0];
   } 
   else
        $name = ereg_replace(" ","_", $args[0]);

   $ret = '<input type="submit" ';
   if($atts != NULL)
   {
     while(list($k,$v)=each($atts))
       $ret .= ' '.$k.'="'.$v.'" ';
   }
   else
   {
       $ret .= 'name="'.$name.'" ';
       $ret .= 'value="'.$name.'" ';
   }
   
   $ret .= ' />';
   return $ret;
}

function textarea()
{
   $args = func_get_args();
   $ret = '<textarea ';
   $atts = NULL;
   if(is_array($args[0]))
      $atts = $args[0];
   while(list($k,$v)=each($atts))
   {
        $ret .= ' '.$k.'="'.$v.'" ';
   }
   if(!isset($args[1]))
      $args[1] = "";
   $ret .= '>'.$args[1].'</textarea>';
   return $ret;
}

function start_form($action, $method=null, $target=null)
{
        $str =  "<form action=\"".$action."\" ";
        if($target != null)
        $str .= " target=\"$target\" ";
        if($method != null)
        $str .= " method=\"".$method."\">\n";
        else
        $str .= " method=\"POST\">\n";
        return($str);
}

function end_table(){ return "</table>";}
function end_td(){ return "</td>";}
function end_tr(){ return "</tr>";}
function end_center(){ return "</center>";}
function end_html(){ return "</html>";}
function end_body(){ return "</body>";}
function end_form(){ return "</form>";}

function br(){ return '<br/>'; }


//echo "<table width=\"60%\" border=\"2\">" . tr(array("bgcolor"=>"green"),td("uga buga")) . "</table>";
//echo a(array("class"=>"lnkDispClr","href"=>"http://montana-riverboats.com"),b("MRB")),br();

//echo "<table><tr>", td(), "uga", end_td(),end_tr(),end_table(),"<br/>"; 
//echo "<table><tr>", td(array("align"=>"right"),"uga"),end_tr(),end_table(),"<br/>"; 
//echo html(), myheader(), body(array("class"=>"disp","background"=>"bkg.jpg"));
?>
Return current item: BBS_Bulletin_Board