PHP Pre-Processing with XMake: Customization |
>> << This Presentation: PHP Template |
<?php
// global vars are set by XMakefile.mks rules
// the source file to process
global $source_file;
// all text files require html entities conversion
global $is_text_file;
// preformatted text files use <pre>...</pre>
global $is_preformatted;
// php source files are displayed with syntax highlighting
global $is_php_file;
// html files are already formatted; simply echo
global $is_html_file;
////////////////////
$break_str="<br>";
include("header.php");
if (empty( $source_file)){
trigger_error("\$source_file is empty",E_USER_ERROR);
}
$source=join('',file($source_file));
if ($is_text_file){
$body=htmlentities($source);
if ($is_preformatted){
// add bold tags since Mac IE5 doesn't apply CSS inside <pre>
$body ="\n<pre><span class=\"preformatted\"><b>".$body."</b></span></pre>\n";
} else {
//$body =nl2br($body);
$body = str_replace("\n", $break_str."\n", $body );
}
} elseif ($is_html_file) {
$body=$source;
if ($is_preformatted){
$body ="\n<pre><span class=\"preformatted\"><b>".$body."</b></span></pre>\n";
}
} elseif ($is_php_file){
$body=highlight_string ( $source, $return=TRUE);
}
echo $body;
include("footer.php");
?>
>> << Copyright (c) 2003, Gregory Keranen. All rights reserved. |