Location: PHPKode > scripts > XHTML Page Creator > xhtml-page-creator/example.php
<?php
#------------------------------------------------------------------------------------------------------
#
#	CLASS:			XHTML 1.0 Page Creator Class
#	FILE:			XHTMLClass.php
#	AUTHOR:			Gabor Magasvari [Hungary]
#	COPYRIGHT:		Gábor Magasvári (c) 2005/11/13
#	LICENCE:		Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Hungary License
#					- Look at: http://creativecommons.org/licenses/by-nc-nd/2.5/hu/
#					- If you used the class send a thanks e-mail to: magasvari[at]gmail[dot]com. 
#					Subject: "XHTML 1.0 Page Creator Class" 
#	VERSION:		2.0
#
#-------------------------------------------------------------------------------------------------------

require_once("XHTMLClass.php");
/////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE:
/////////////////////////////////////////////////////////////////////////////////////
// Datas from database or file:
//------------------------------------------------------------------------------------

$head_profile = "http://dublincore.org/documents/dcq-html/"; //  Head profile example

// MetaData 1: array ("name|http-equiv", "content name", "content") // Simple
// MetaData 2: array ("name|http-equiv", "content name", array ("content1", "content2", "content3")) // Simple (with array data)
// MetaData 3: array ("name|http-equiv", "content name", "content", array ("xml:lang|lang|scheme" => "content")) // With plus information
// Comments: "Simple text"

// Examples:
$meta_array = array (
	array ("name", "keywords", array ("XHTML", "xhtml", "Class", "OOP")), // MetaData 2
	array ("name", "description", "Create valid XHTML document!"), // MetaData 1
	array ("name", "DC.Subject", array ("quality", "web page", "tip", "XHTML", "class", "help"), array ("lang" => "en")), // MetaData 3
	array ("name", "DC.Subject", array ("minoség", "weblap", "tipp", "XHTML", "osztály", "segítség"), array ("xml:lang" => "hu")), // The same data in an other language
	array ("name", "DC.Title", "XHTML Class", array ("lang" => "en")),
	array ("name", "DC.Creator", "Gábor Magasvári"),
	array ("name", "DC.Publisher", "Gábor Magasvári"),
	array ("name", "DC.Rights", "http://creativecommons.org/licenses/by-nc-nd/2.5/hu/"),
	array ("name", "DC.Date", "2001-07-18", array ("scheme" => "W3CDTF")), // Scheme example
	array ("name", "robots", "all"),
	array ("name", "copyright", "copyright 2005 (c) Gábor Magasvári"),
	array ("name", "revisit-after", "1 days"),
	array ("name", "expires", "1"),
	
	"Html Comment", // HTML Comment in the head section
	
	array ("name", "identifier", "0-8230-2355-9", array ("scheme" => "ISBN")), // Other scheme example
	array ("name", "DC.identifier", "http://www.ietf.org/rfc/rfc1866.txt"),
	
	# array ("http-equiv", "refresh", "10;URL=http://www.w3.org/"), // How do I set up a redirect? (<META http-equiv="refresh" content="time;URL=url"> )

	array ("http-equiv", "expires", "Tue, 20 Aug 1996 14:25:27 GMT"), // Http-equiv example
	array ("http-equiv", "reply-to", "magasvari[at]gmail[dot]com"),
	array ("http-equiv", "PICS-Label", "(PICS-1.1 \"http://www.gcf.org/v2.5\"
    labels on \"1994.11.05T08:15-0500\"
      until \"1995.12.31T23:59-0000\"
      for \"http://w3.org/PICS/Overview.html\"
    ratings (suds 0.5 density 0 color/hue 1))"), // This example illustrates how one can use a META declaration to include a PICS 1.1 label
	//array ("", ""),
	);

// Link 1: array ("rel|rev", "content", "href") // Simple
// Link 2: array ("rel|rev", "content", "href", array ("hreflang|title" => "content")) // Plus an attribute  
// Link 3: array ("rel|rev", "content" "href", array ("type|media|hreflang|title" => "content", array ("type|media|hreflang|title" => "content") // Full 
// Comment: "Simple Text"

// Examples:
$link_array = array (
	"Link Section (HTML Comment)", // HTML Comment
	array ("rel", "Start", "index.html"), // The classical start of an HTML document: - Start gives the starting point of the section,
	array ("rel", "Prev", "prev.html"), // - Prev gives the previous item,
	array ("rel", "Next", "next.html"), // - Next gives the next item.
	array ("rel", "Contents","/contents/contents.html"), // Contents points to the index of the section.
	array ("rel", "Help", "/website-help.html"), // Help gives the possibility to link to a page helping your visitors use your Web site.

	array ("rel", "DC.identifier", "http://www.ietf.org/rfc/rfc1866.txt", array("type" => "text/plain")), // The example is the same as: $meta_array ("name", "DC.identifier", "http://www.ietf.org/rfc/rfc1866.txt")
	
	array ("rev", "made", "mailto:magasvari[at]gmail[dot]com"), // (Example for "rev") A way to contact the author of the Web site
	
	array ("rel", "alternate", "/magyar_hungarian.php", array("hreflang" => "hu"), array("title" => "Hungarian Translation")), // It gives you access to a translation of the document in another language, in this case Hungarian.
	array ("rel", "alternate", "/updates.rdf", array("type" => "application/rss+xml"), array("title" => "RSS")), // It gives the possibility to RSS Readers to find the Web site updates feed. Note that, at the time of this writing, the mime-type application/rss+xml is still a draft "The application/rss+xml Media Type" and is not yet accepted by IETF.
	array ("rel", "meta", "http://astro.example.org/foaf.xrdf", array("type" => "application/rdf+xml"), array("title" => "FOAF")), // It gives the possibility to FOAF Readers to find the metadata on document. It could be the author. Note that, at the time of this writing, the mime-type application/rdf+xml is not yet accepted by IETF and there were no further work on it since the last proposal.
	array ("rel", "stylesheet", "/css/screencss.css", array("type" => "text/css"), array("media" => "screen")), //Specify the CSS to display your Web site. For example in this link, we have specified that the stylesheet was for screen rendering. We could have other stylesheets for other media.
	array ("rel", "stylesheet", "/css/printcss.css", array("type" => "text/css"), array("media" => "print")),

	//array ("rel", "", "", array("" => ""), array("" => "")),
	);
// Links:
// DCMI Metadata Terms - http://dublincore.org/documents/dcmi-terms/	
// Meta data - http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.4

// Example: insert of other (JavaScript) head elements
$elements = '<script language="JavaScript" type="text/JavaScript">
<!--
// Example:
// simplePreload( \'01.gif\', \'02.gif\' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
//-->
</script>'."\n";

// Example: insert of other (CSS) head elements
$elements .= '<style type="text/css">
<!--
@import url("/css/home.css");
-->
</style>';

//------------------------------------------------------------------------------------
// USAGE:
//------------------------------------------------------------------------------------
$MyXHTMLDocument = new CreateXHTMLDocument; // Create New Class

$MyXHTMLDocument -> GetDynamic (); // Dynamic content (If the content is dynamic then generate dynamic header  )

$MyXHTMLDocument -> SetProfile ($head_profile); // Set head profile (<head profile="...">)

$MyXHTMLDocument -> SetDocumentTitle ("My XTHML Document"); // Set the Document Title.
$MyXHTMLDocument -> SetCharset ("charset=iso-8859-2"); // Set Charset. Default: "charset=iso-8859-1"!
$MyXHTMLDocument -> SetXMLLang ("hu"); // Set <html xml:lang. Default "eng"!
$MyXHTMLDocument -> SetMeta ($meta_array); // Meta datas (optional)
$MyXHTMLDocument -> SetMetaLinks ($link_array); // Meta link datas (optional)
$MyXHTMLDocument -> OtherHeadElement ($elements); // Other datas (Javascript, attached CSS, etc...) (optional)

$MyXHTMLDocument -> Header (); // XHTML document start # This function is required!!!

// Start the content:
// Example (this source):

   $f = file_get_contents($_SERVER['SCRIPT_FILENAME']);
   highlight_string($f);

/*
 file_get_contents (PHP 4 >= 4.3.0, PHP 5)
 highlight_string (PHP 4, PHP 5)

"...This program cannot be run in DOS mode." bug (PHP: Predefined Variables - Manual http://www.php.net/reserved.variables):

$f = file_get_contents($_SERVER['SCRIPT_FILENAME']); // under Windows

    The absolute pathname of the currently executing script.
    Comments: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. 

$f = file_get_contents(__FILE__); // Windows

    __FILE__
    The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.
*/
   //exit();
   
   echo '<p style="text-align: center;"><a href="http://validator.w3.org/check?uri=referer" target="_blank">Validate current document! (Validator '.ValidatorStatusCheck ().')</a></p>';

$MyXHTMLDocument -> DocumentEnd (); // XHTML document end # This function is required!!!

// Extra :-)
function ValidatorStatusCheck ()
	{
	$file = @fopen( "http://validator.w3.org/check", "r" );
	if (!$file) {
    	return ('status: <span style="color:red;">offline</span>'); // OFFLINE
	}
	else
	{
    	return ('status: <span style="color:green;">online</span>'); // ONLINE
	}
}

?>
Return current item: XHTML Page Creator