Location: PHPKode > projects > Myphpim > MyPhPim-01.05/includes/html_cl.inc
<?php

//****************************************************************************************
//                Copyright (C) 2000 Koen de Boeve
//
//        This program is free software; you can redistribute it and/or
//        modify it under the terms of the GNU General Public License
//        as published by the Free Software Foundation; either version 2
//        of the License, or (at your option) any later version.
//
//        This program is distributed in the hope that it will be useful,
//        but WITHOUT ANY WARRANTY; without even the implied warranty of
//        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//        GNU General Public License for more details.
//
//        You should have received a copy of the GNU General Public License
//        along with this program; if not, write to the Free Software
//        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//        Version : MyPhPim-01.05
//        Author : Koen de Boeve
//        Contact: hide@address.com
//**************************************************************************************** 
if ( file_exists ( "conf" ) ) { $conf = "conf"; }
if ( file_exists ( "../conf" ) ) { $conf = "../conf"; }
include $conf . "/config.inc";

// Class for some html Functions like making headers and footers
// and other really boring stuff like forms *sigh*


//#############################################################################################################
//#############################################################################################################
//#############################################################################################################
//#############################################################################################################

class HtmlCl {

//###################################################################

	// this puts a standard header on every page.

        Function HtmlHeader ( $title, $bodyargs )
        {
                global $layout;
		global $user;
		$db = new DB; 
		$user_id = $db->UserId ( $user );
		$vars = $db->SearchPendingRecords ( $user_id, 0 );
		$vars1 = $db->SearchAddedRecords ( 0 );
		$vars2 = $db->SearchRejectedRecords ( 0 );
		$numvars = count ( $vars );
		$numvars1 = count ( $vars1 );
		$numvars2 = count ( $vars2 );
                echo "<html>\n";
                echo "<head>\n";
                echo "<title>$title</title>\n";
		echo "<!--\n";
        	echo "  Created by MyPhPim\n";
        	echo "  Author: Koen de Boeve\n";
        	echo "  Released under the GPL licence\n";
        	echo "  contact: hide@address.com\n";
        	echo "-->\n";
//		echo "<meta http-equiv='Pragma' content='no-cache'>"; 
		echo "<style type=\"text/css\">\n";
		echo "<!--\n";
                echo "body { margin: 0 }\n";
                echo "A.blue:link{text-decoration:none; color: blue}\n";
                echo "A.blue:visited{text-decoration:none; color: blue}\n";
                echo "A.blue:active{text-decoration:none; color: blue}\n";
                echo "A.white:link{text-decoration:none; color: white}\n";
                echo "A.white:visited{text-decoration:none; color: white}\n";
                echo "A.white:active{text-decoration:none; color: white}\n";
                echo "A.red:link{text-decoration:none; color: red}\n";
                echo "A.red:visited{text-decoration:none; color: red}\n";
                echo "A.red:active{text-decoration:none; color: red}\n";
                echo "A.black:link{text-decoration:none; color: black}\n";
                echo "A.black:visited{text-decoration:none; color: black}\n";
                echo "A.black:active{text-decoration:none; color: black}\n";
                echo "-->\n";
                echo "</style>\n";
		echo "<script language='javascript'>\n";
		echo "<!--\n";
		echo "function checkevents () {\n"; 
		for ( $i = 0; $i < $numvars; $i++ ) {
			$data = $vars[$i];
			echo "alert$i = window.open(\"popup.php3?type=mr&mrid=$data->mr_id&action=new\" , \"alert$i\",\"scrollbar=yes,toolbar=no,menubar=no,screenX=250,screenY=150,top=150,left=250\");\n";
			
		}
		for ( $i = 0; $i < $numvars1; $i++ ) {
			$data = $vars1[$i];
			echo "alert1$i = window.open(\"popup.php3?type=mr&mrid=$data->mr_id&action=added\" , \"alert1$i\",\"height=370,width=500,scrollbar=yes,toolbar=no,menubar=no,screenX=250,screenY=150,top=150,left=250\");\n";
		}
		for ( $i = 0; $i < $numvars2; $i++ ) {
			$data = $vars2[$i];
			echo "alert2$i = window.open(\"popup.php3?type=mr&mrid=$data->mr_id&action=rejected\" , \"alert2$i\",\"height=370,width=500,scrollbar=yes,toolbar=no,menubar=no,screenX=250,screenY=150,top=150,left=250\");\n";
		}
		echo "}\n";
		echo "function DoWhatWithemail ( mailaddress )\n
		      {\n
		      window.open(\"popup.php3?type=email&mailaddress=\" + mailaddress ,\"dowhatwithemail\", \"height=150,width=500,toolbar=no,scrollbars=no,menubar=no\");\n
		      }\n";
		echo "function GetAddressList ( mailto, mailcc, mailbcc, field, names, folder, msgno, act )\n
		      {\n
			
		      window.open(\"popup.php3?type=address&field=\" + field + \"&names=\" +  names + \"&msgno=\" + msgno + \"&folder=\" + folder + \"&act=\" + act + \"&mailto=\" + mailto + \"&mailcc=\" + mailcc + \"&mailbcc=\" + mailbcc ,\"AddressList\", \"height=250,width=450,toolbar=no,scrollbars=yes,menubar=no\");\n
		      }\n";
		echo "-->\n";
		echo "</script>\n";
                echo "</head>\n";
                echo "<body bgcolor=$layout[bgcolor] $bodyargs onLoad=\"checkevents()\">\n";
                echo "<center><font size=+1>$title</font></center><p>\n";
        }

//###################################################################

	// Gosh ! and this closes a html page :-)

        Function HtmlFooter ( )
        {
                echo "</body>\n";
                echo "</html>\n";
        }

//###################################################################
	
	// quickly make a hyperlink for an emailaddress

        Function mailto ( $email )
        {
                echo "<a href=mailto:$email><font size=-1>$email</font></a>";
        }

//###################################################################

	// create hyperlink for URL

        Function url ( $link , $name)
        {
                echo "<a href=$link><font size=-1>$name</font></a>";
        }

//###################################################################

	// Function to create a new window, and show an image in that new popup window

	Function HtmlHeadPopScript ( $title ) {
		global $layout;
                echo "<html>\n";
                echo "<head>\n";
                echo "<title>$title</title>\n";
		echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
    		echo "<!--//hide script from old browsers\n";
		echo " var dir , msgnr, partno;\n"; 
    		echo "	function launch ( dir, msgnr, partno ) {\n";
    		echo "		open('viewfile.php3?folder=dir&msgno=msgnr&part_no=partno', 'viewfile', 'resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, width=500,
    				height=300') }\n";
    		echo "//end hiding contents -->\n";
    		echo "</SCRIPT>\n"; 
                echo "</head>\n";
                echo "<body bgcolor=$layout[bgcolor] link=$layout[link] vlink=$layout[vlink] alink=$layout[alink]>\n";
                echo "<center><h1>$title</h1></center>\n";
	}
}

//#############################################################################################################
//#############################################################################################################
//#############################################################################################################
//#############################################################################################################

class FormCl {
	

//###################################################################

	// Ok we need a form, so lets start one...

	Function init ( $action, $method, $name )
	{
		if ( $name ) {
			echo "<form action=\"$action\" method=$method name=$name>\n";
		} else {
			echo "<form action=\"$action\" method=$method>\n";
		}
	}

//###################################################################

	// What has been opened needs to be closed again :-)	

	Function close ( ) { echo "</form>\n"; }

//###################################################################

	// create a 1 line text box
	
	Function text ( $name, $value, $maxlength, $size, $password ) 
	{
		if ( $password == 1 )
		{
			$type=password;
		} else 
		{
			$type=text;
		}
		echo "<input type=$type name=$name value=\"$value\" maxlength=$maxlength size=$size>\n";

	}	

//###################################################################

	// create a selectbox where you can only choose 1 Item

	Function SimpleSelect ( $varname, $values, $names, $selected) 
	{
		$numnames = count ( $names );
		echo "<select name=$varname>\n";
		for ( $i = 0; $i < $numnames; $i++ )
		{
			if ( $selected == $names[$i] || $selected == $values[$i] )
			{
				echo "<option value=\"$values[$i]\" selected>$names[$i]</option>\n";
			} else 
			{
				echo "<option value=\"$values[$i]\">$names[$i]</option>\n";
			}
		}
		echo "</select>\n";
	}

//###################################################################

	// Create A selectbox where you can select multiple items
	
	Function MultiSelect ( $varname, $values, $names, $selected, $rows )
	{
		$numnames = count ( $names );
		$numselected = count ( $selected );
		echo "<select name=$varname size=$rows multiple>\n";
		for ( $i = 0; $i < $numnames; $i++ )
		{
			for ( $j = 0; $j < $numselected; $j++ )
			{
				if ( $selected[$j] == $names[$i] )
				{
					$select = "selected";
					break;
				} else
				{
					$select = "";

				}
			}
			echo "<option value=\"$values[$i]\" $select>$names[$i]</option>\n";
		}
		echo "</select>\n";
	}	

//###################################################################

	// Create a button

	Function submit ( $name, $var )
	{
			echo "<input type=submit name=$name value=\"$var\">\n";
	}

//###################################################################

	// and this one doesn't show on the page but is used 
	// to send along other variables from one place to another.
	
	Function hidden ( $name, $var )
	{
		echo "<input type=hidden name=$name value=\"$var\">\n";
	}

//###################################################################

	// multiline textbox

	Function textarea ( $varname, $value, $cols, $rows )
	{
		echo "<textarea name=$varname rows=$rows cols=$cols>$value</textarea>\n";
	}

//###################################################################

	// File upload widget

	function file ( $varname, $size ) {
		echo "<input type=file name=$varname size=$size>\n";
	}

//###################################################################

	// Create a set of radiobuttons
	// $values is an array 
	
	Function radio ( $direction,  $varname, $values, $checked ) 
	{
		$direction = strtoupper ( $direction );
		$numvalues = count ( $values );
		$end = $numvalues - 1;
		for ( $i = 0; $i < $numvalues; $i++ )
		{
			if ( $checked == $values[$i] ) 
			{
				$check = "checked";
			} else
			{
				$check = "";
			}
			if ( $direction == "HOR" ) 
			{ 
				echo "<input type=radio name=$varname value=$values[$i] $check> $values[$i] &nbsp; &nbsp;\n";
			} else 
			{
				if ( $i == $end ) 
				{
					echo "<input type=radio name=$varname value=$values[$i] $check> $values[$i]\n";
				} else
				{
					echo "<input type=radio name=$varname value=$values[$i] $check> $values[$i]<br>\n";
				}	
			}
		}
	}

//###################################################################

	// checkbox

	Function checkbox ( $varname, $checked , $printvarname ) 
	{
		if ( $checked == 1 )
		{
			if ( $printvarname == 0 ) {
				echo "<input type=checkbox name=$varname value=\"Y\" checked>\n";
			} else  {		
				echo "<input type=checkbox name=$varname value=\"Y\" checked> $varname\n";
			}
		} else if ( $checked == 0 )
		{
			if ( $printvarname == 0 ) {
				echo "<input type=checkbox name=$varname value=\"Y\">\n";
			} else {
				echo "<input type=checkbox name=$varname value=\"Y\"> $varname\n";
			}
		} else {
			echo "<input type=checkbox name=$varname value=$printvarname>\n";
		}
	}

//###################################################################

	// create 3 text boxes to enter dates 1 box for year, 1 box for month and 1 for day of the month
	
	Function dates ( $var, $day, $month, $year ) {
		$cal = new CalendarCl; 
		$j = 1;
		for ( $i = 0; $i < 12; $i++ ) {
			$months[$i] = $cal->Cal_ReturnMonthName ( $j );
			$j++;
		} 
		$months[$i] = "--";
		$j = 1;
		for ( $i = 0; $i < 31; $i++ ) {
			$days[$i] = $j;
			$j++;
		}
		$days[$i] = "--";
		$j = 0;
		for ( $i = 1990; $i < 2026; $i++ ) {
			$years[$j] = $i;
			$j++;
		}
		$years[$j] = "--";
		if ( !$day ) { $day = "--"; }
		if ( !$month ) { $month = "--"; }
		if ( !$year ) { $year = "--"; }
		$this->simpleselect ( $var . "day", $days, $days, $day );
		$this->simpleselect ( $var . "month", $months, $months, $month );
		$this->simpleselect ( $var . "year", $years, $years, $year );
	}								 
}
?>
Return current item: Myphpim