PHP Classes
Icontem

File: test_class_html.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Peter Klauer  >  ezhtml  >  test_class_html.php  
File: test_class_html.php
Role: Example script
Content type: text/plain
Description: Testfile, Demo
Class: ezhtml
Framework to generate HTML head, body and divs
 

Contents

Class file image Download
<?php
/*
 * Filename.....: test_class_html.php
 * Class........: html
 * Aufgabe......: Testfile for class_html.php (ezhtml) 
 * Parameter....: none
 * Erstellt am..: Montag, 30. Juni 2003, 15:21:30
 *       _  __      _ _
 *  ||| | |/ /     (_) |        Wirtschaftsinformatiker IHK
 * \. ./| ' / _ __  _| |_ ___   www.ingoknito.de
 * - ^ -|  < | '_ \| | __/ _ \  
 * / - \| . \| | | | | || (_) | Peter Klauer
 *  ||| |_|\_\_| |_|_|\__\___/  06131-651236
 * mailto.......: knito@knito.de
 */
 
include 'class_html.php';

#
# a new instance (object) of the class
#
$html = new html('EzHTML Demo');

$html->refresh true// always refresh this page (useless but example)

#
# setting debug state from posted var
#
$debug $_REQUEST['debug']; // get or post
if( !isset( $debug ) ) $debug false;
$html->debug $debug;

#
# writing a tidy head
#
$html->head( );

#
# look: a css declaration midst in the <head>!
#
?>

<style type="text/css">
<!--
body{ 
  background-color: #ddffdd;
  color: black;
  font-family: Verdana, Arial, sans-serif;
}
/* the classes folder and folderbutton are used by $html->folder */
a.folder, a.folderbutton{ text-decoration:none }
a.folder:hover { text-decoration:underline }

/* the rest is not used by $html, but by <html>! */
h1,h2,h3,h4,form{ margin: 0 }
table,tr,td{ padding: 4px }
label{ border: solid 1px #008000; font-size:smaller; padding: 4px; cursor:pointer }
.info{ border: dotted 1px #008000; padding:8px; background-color: #ffffe8; color:#008000; }
-->
</style>

<?php

#
# Starting the body of the page
#
$html->body();

echo 
"<div class=info><h2>$html->title</h2>";

#
# This is a form where you may enter whether you wish to debug or not
#
$checkedon $debug ' checked' '';
$checkedoff$debug '' ' checked'
?>
<table width="100%" summary="">
<colgroup><col span=2 width="50%"></colgroup>
<tr valign=top><td>
<form name="dbform" action="<?php echo $PHP_SELF?>" method=POST>
<input onClick="this.form.submit()" type=radio name="debug" value="1" id="dbon"<?php echo $checkedon?>>
<label for="dbon">debugging ON</label>&nbsp;
<input onClick="this.form.submit()" type=radio name="debug" value="0" id="dboff"<?php echo $checkedoff?>>
<label for="dboff">debugging OFF</label>&nbsp;
<input style="visibility:hidden" type=submit name="ok" value="ok"></form>
</td><td align=right><a href="http://knito.users.phpclasses.org/browse.html/package/1255.html">Get this class from PHPCLASSES</a>
</td></tr></table>

<?php

#
# In the above form the method is POST.
# If method=GET is chosen, then the debug var is passed via the command line.
# But I want to show you the more complicated way of putting a var into the
# command line:
#
if( $debug 
{
  
$QUERY_STRING $html->adjust_query_string$QUERY_STRING"debug=$debug" );
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# if register_globals is set to ON on your PHP installation then the
# call to $html->register_folders() in the following lines is not necessary.
#
# begin of unnecessary code - - - - - - - - - - - - - - - - - - - - - - - - - -
#

if( $html->debug == true )
{
  if( 
$html->folder'View debugging info' ))
  {
    echo 
'<br>Click on the folders to see what happens.';
    
$html->register_folders);
    
$html->db"\$QUERY_STRING: $QUERY_STRING" );
  }
}
else 
$html->register_folders); // unvisible

echo '</div>';

#
# using a table to have two columns
# each column shall use 50% of the pagewidth
#
echo '<table summary="" width="100%"><colgroup><col span=2 width="50%"><tr valign=top><td>';

#
# end of unnecessary code - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
echo '<br><br><b>Using standard (text) plus/minus</b>';

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# The first folder (if not debugging)
#
# The function $html->folder() returns TRUE if $folder1 
# (or $folder2 when debugging)
# is set to "open". 
#
# Thats simple, isn't it?

if( $html->folder'Header-Test (first folder)' ) )
{
  for( 
$i 1$i 5$i++ )
  {
    
$html->h$i"$html->title - $i" );
  }
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# The second
#
# If you put the content as the second argument of the $html->folder() function
# then you do not even need the if() clause.
#
# This is even more simple!
#
$content2 =
  
' text may be continued on the same row when the folder is opened. '.
  
' This is content for the second folder. '.
  
'You can output data with print, echo or '.
  
'like in the next folder, using simple html.'.
  
"<br>\$folder2 = $folder2<br>";  

$html->folder'Here you see how'$content2 );

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# folder number 3
#
if( $html->folder'Third test plain html' ) )
{
?>
<p>Punum brasn pem tesolue smenudront. Itasnius, stuhacrius ut nifecam haras. 
Snot urit, epham ehosci lo epopam tubitotis. Pugum, lebrit og tutriant apenant. 
Agaquor est. </p>
<?php
}

#
# Switching to the next column
#
echo '</td><td>';

 
echo 
'<br><br><b>Graphic button and a class for content</b>';

#
# introducing the graphical plus / minus buttons
#
$html->folder_plus '<img src="plus.gif" alt="plus" border=0>';
$html->folder_minus '<img src="minus.gif" alt="minus" border=0>';

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# next folder
#
if( $html->folder'Header-Test (4th folder)' ) )
{
  echo 
'<div class=info>';
  for( 
$i 1$i 5$i++ )
  {
    
$html->h$i"$html->title - $i" );
  }
  echo 
'</div>';
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# another one
#
$content5 =
  
'<div class=info>This is content for the fifth folder. '.
  
'You can output data with print, echo or '.
  
'like in the next folder, using simple html.'.
  
"<br>\$folder5 = $folder5</div>";  

$html->folder'Another test - fifth folder'$content5 );

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# and here is the last
#
if( $html->folder'Sixth test plain html' ) )
{
?>
<div class=info>
Punum brasn pem tesolue smenudront. Itasnius, stuhacrius ut nifecam haras. 
Snot urit, epham ehosci lo epopam tubitotis. Pugum, lebrit og tutriant apenant. 
Agaquor est. </div>
<?php
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# finito tabello
#
echo '</tr></table>';

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# finito htmello
#
$html->foot();

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products