define_dynamic( 'TABLE1', $tplflag ); $title_name = "XXXX"; //echo "Target : ".$target."
"; switch($target) { case "about": $title_name = "XXXX"; break; case "gukeng": $title_name = "111古坑服務區"; break; } $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage13($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/news', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "最新消息"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage12($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/home', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "首頁"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage11($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/domestics', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "服務據點"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage10($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/about', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "國道服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage2($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/gukeng', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "古坑服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage3($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/gukeng', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "古坑服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage4($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/hukou', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "湖口服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage5($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/hukou', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "湖口服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage6($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/zhongli', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "中壢服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage7($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/zhongli', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "中壢服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage8($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/taian', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "泰安服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage9($target) { $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/taian', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "泰安服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage14($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/hsilo', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "西螺服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage20($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/hsilo', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "西螺服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage21($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/dongshan', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "東山服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage22($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/dongshan', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "東山服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage23($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/eda', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "義大醫院商場"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage24($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/eda', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "義大醫院商場"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage25($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/guanmiao', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "關廟服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage26($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/guanmiao', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "關廟服務區"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage27($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/beimen', $tplflag, 'header.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "北門商場"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } function HeaderPage28($target) { //$DB = & DB(); $tplflag = 'tpl_ca_edit'; $tpl = tpl('template/beimen', $tplflag, 'header2.html'); $tpl->define_dynamic( 'TABLE1', $tplflag ); $title_name = "北門商場"; $tpl->assign('V_TITLE',$title_name); $tpl->parse( 'F_'.$tplflag, $tplflag ); $tpl->fastprint(); } ?>dbh = @mysql_connect($dbhost,$dbuser,$dbpassword); if ( ! $this->dbh ) { $this->print_error("
    Error establishing a database connection!
  1. Are you sure you have the correct user/password?
  2. Are you sure that you have typed the correct hostname?
  3. Are you sure that the database server is running?
"); } $this->select($dbname); } // ================================================================== // Select a DB (if another one needs to be selected) function select($db) { if ( !@mysql_select_db($db,$this->dbh)) { $this->print_error("
    Error selecting database $db!
  1. Are you sure it exists?
  2. Are you sure there is a valid database connection?
"); } } // ================================================================== // Print SQL/DB error. function print_error($str = "") { if ( !$str ) $str = mysql_error(); // If there is an error then take note of it print "
"; print "SQL/DB Error -- "; print "[$str]"; print "
"; } // ================================================================== // Kill cached query results function flush() { // Get rid of these $this->last_result = null; $this->col_info = null; $this->last_query = null; } // ================================================================== // Basic Query - see docs for more detail function query($query) { // Flush cached values.. $this->flush(); //mysql_query("SET NAMES uft8"); mysql_query("set character set utf8"); // Log how the function was called $this->func_call = "\$db->query(\"$query\")"; // Keep track of the last query for debug.. $this->last_query = $query; // Perform the query via std mysql_query function.. $this->result = mysql_query($query,$this->dbh); // If there was an insert, delete or update see how many rows were affected // (Also, If there there was an insert take note of the insert_id $query_type = array("insert","delete","update"); // loop through the above array foreach ( $query_type as $word ) { // This is true if the query starts with insert, delete or update if ( preg_match("/$word /",strtolower($query)) ) { $this->rows_affected = mysql_affected_rows(); // This gets the insert ID if ( $word == "insert" ) { $this->insert_id = mysql_insert_id(); } } } if ( mysql_error() ) { // If there is an error then take note of it.. $this->print_error(); } else { // In other words if this was a select statement.. if ( $this->result ) { // ======================================================= // Take note of column info $i=0; while ($i < @mysql_num_fields($this->result)) { $this->col_info[$i] = @mysql_fetch_field($this->result); $i++; } // ======================================================= // Store Query Results $i=0; while ( $row = @mysql_fetch_object($this->result) ) { // Store relults as an objects within main array $this->last_result[$i] = $row; $i++; } // Log number of rows the query returned $this->num_rows = $i; @mysql_free_result($this->result); // If there were results then return true for $db->query if ( $i ) { return true; } else { return false; } } } } // ================================================================== // Get one variable from the DB - see docs for more detail function get_var($query=null,$x=0,$y=0) { // Log how the function was called $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Extract var out of cached results based x,y vals if ( $this->last_result[$y] ) { $values = array_values(get_object_vars($this->last_result[$y])); } // If there is a value return it else return null return $values[$x]?$values[$x]:null; } // ================================================================== // Get one row from the DB - see docs for more detail function get_row($query=null,$y=0,$output=OBJECT) { // Log how the function was called $this->func_call = "\$db->get_row(\"$query\",$y,$output)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // If the output is an object then return object using the row offset.. if ( $output == OBJECT ) { return $this->last_result[$y]?$this->last_result[$y]:null; } // If the output is an associative array then return row as such.. elseif ( $output == ARRAY_A ) { return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null; } // If the output is an numerical array then return row as such.. elseif ( $output == ARRAY_N ) { return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null; } // If invalid output type was specified.. else { $this->print_error(" \$db->get_row(string query,int offset,output type) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N "); } } // ================================================================== // Function to get 1 column from the cached result set based in X index // se docs for usage and info function get_col($query=null,$x=0) { // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Extract the column values for ( $i=0; $i < count($this->last_result); $i++ ) { $new_array[$i] = $this->get_var(null,$x,$i); } return $new_array; } // ================================================================== // Return the the query as a result set - see docs for more details function get_results($query=null, $output = OBJECT) { // Log how the function was called $this->func_call = "\$db->get_results(\"$query\", $output)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Send back array of objects. Each row is an object if ( $output == OBJECT ) { return $this->last_result; } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { if ( $this->last_result ) { $i=0; foreach( $this->last_result as $row ) { $new_array[$i] = get_object_vars($row); if ( $output == ARRAY_N ) { $new_array[$i] = array_values($new_array[$i]); } $i++; } return $new_array; } else { return null; } } } // ================================================================== // Function to get column meta data info pertaining to the last query // see docs for more info and usage function get_col_info($info_type="name",$col_offset=-1) { if ( $this->col_info ) { if ( $col_offset == -1 ) { $i=0; foreach($this->col_info as $col ) { $new_array[$i] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[$col_offset]->{$info_type}; } } } // ================================================================== // Dumps the contents of any input variable to screen in a nicely // formatted and easy to understand way - any type: Object, Var or Array function vardump($mixed) { echo "
"; echo "
";

                        if ( ! $this->vardump_called )
                        {
                                echo "ezSQL (v".EZSQL_VERSION.") Variable Dump..\n\n";
                        }

                        $var_type = gettype ($mixed);
                        print_r(($mixed?$mixed:"No Value / False"));
                        echo "\n\nType: " . ucfirst($var_type) . "\n";
                        echo "Last Query: ".($this->last_query?$this->last_query:"NULL")."\n";
                        echo "Last Function Call: " . ($this->func_call?$this->func_call:"None")."\n";
                        echo "Last Rows Returned: ".count($this->last_result)."\n";
                        echo "
"; echo "\n
"; $this->vardump_called = true; } // Alias for the above function function dumpvar($mixed) { $this->vardump($mixed); } // ================================================================== // Displays the last query string that was sent to the database & a // table listing results (if there were any). // (abstracted into a seperate file to save server overhead). function debug() { echo "
"; // Only show ezSQL credits once.. if ( ! $this->debug_called ) { echo "ezSQL (v".EZSQL_VERSION.") Debug..

\n"; } echo "Query -- "; echo "[$this->last_query]

"; echo "Query Result.."; echo "

"; if ( $this->col_info ) { // ===================================================== // Results top rows echo ""; echo ""; for ( $i=0; $i < count($this->col_info); $i++ ) { echo ""; } echo ""; // ====================================================== // print main results if ( $this->last_result ) { $i=0; foreach ( $this->get_results(null,ARRAY_N) as $one_row ) { $i++; echo ""; foreach ( $one_row as $item ) { echo ""; } echo ""; } } // if last result else { echo ""; } echo "
(row){$this->col_info[$i]->type} {$this->col_info[$i]->max_length}
{$this->col_info[$i]->name}
$i$item
No Results
"; } // if col_info else { echo "No Results"; } echo "

"; $this->debug_called = true; } } $db = new db(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST); ?> set_win32(); } if(!empty($pathToTemplates)) { $this->set_root($pathToTemplates); } } // end (new) FastTemplate () // ************************************************************ // All templates will be loaded from this "root" directory // Can be changed in mid-process by re-calling with a new // value. function set_root ($root) { $trailer = substr($root,-1); if(!$this->WIN32) { if( (ord($trailer)) != 47 ) { $root = "$root". chr(47); } if(is_dir($root)) { $this->ROOT = $root; } else { $this->ROOT = ""; $this->error("Specified ROOT dir [$root] is not a directory"); } } else { // WIN32 box - no testing if( (ord($trailer)) != 92 ) { $root = "$root" . chr(92); } $this->ROOT = $root; } } // End set_root() // ************************************************************** // Calculates current microtime // I throw this into all my classes for benchmarking purposes // It's not used by anything in this class and can be removed // if you don't need it. function utime () { $time = explode( " ", microtime()); $usec = (double)$time[0]; $sec = (double)$time[1]; return $sec + $usec; } // ************************************************************** // call this function if the OS is WIN32 function set_win32 () { $this->WIN32 = true; } // ************************************************************** // Strict template checking, if true sends warnings to STDOUT when // parsing a template with undefined variable references // Used for tracking down bugs-n-such. Use no_strict() to disable. function strict () { $this->STRICT = true; } // ************************************************************ // Silently discards (removes) undefined variable references // found in templates function no_strict () { $this->STRICT = false; } // ************************************************************ // A quick check of the template file before reading it. // This is -not- a reliable check, mostly due to inconsistencies // in the way PHP determines if a file is readable. function is_safe ($filename) { if(!file_exists($filename)) { $this->error("[$filename] does not exist",0); return false; } return true; } // ************************************************************ // Grabs a template from the root dir and // reads it into a (potentially REALLY) big string function get_template ($template) { if(empty($this->ROOT)) { $this->error("Cannot open template. Root not valid.",1); return false; } $filename = "$this->ROOT"."$template"; //echo "filename : ".$filename."
"; $contents = implode("",(@file($filename))); //echo "contents : ".$contents."
"; if( (!$contents) or (empty($contents)) ) { $this->error("get_template() failure: [$filename] $php_errormsg",1); } return $contents; } // end get_template // ************************************************************ // Prints the warnings for unresolved variable references // in template files. Used if STRICT is true function show_unknowns ($Line) { $unknown = array(); if (ereg("({[A-Z0-9_]+})",$Line,$unknown)) { $UnkVar = $unknown[1]; if(!(empty($UnkVar))) { @error_log("[FastTemplate] Warning: no value found for variable: $UnkVar ",0); } } } // end show_unknowns() // ************************************************************ // This routine get's called by parse() and does the actual // {VAR} to VALUE conversion within the template. function parse_template ($template, $tpl_array) { while ( list ($key,$val) = each ($tpl_array) ) { if (!(empty($key))) { if(gettype($val) != "string") { settype($val,"string"); } //$template = ereg_replace("{$key}","$val","$template"); $template = str_replace("{".$key."}","$val","$template"); } } if(!$this->STRICT) { // Silently remove anything not already found $template = ereg_replace("\{"."([A-Z0-9_]+)"."\}","",$template); } else { // Warn about unresolved template variables if (ereg("({[A-Z0-9_]+})",$template)) { $unknown = split("\n",$template); while (list ($Element,$Line) = each($unknown) ) { $UnkVar = $Line; if(!(empty($UnkVar))) { $this->show_unknowns($UnkVar); } } } } $template = str_replace("###{###","{",$template); return $template; } // end parse_template(); // ************************************************************ // The meat of the whole class. The magic happens here. function parse ( $ReturnVar, $FileTags ) { $append = false; $this->LAST = $ReturnVar; $this->HANDLE[$ReturnVar] = 1; if (gettype($FileTags) == "array") { unset($this->$ReturnVar); // Clear any previous data while ( list ( $key , $val ) = each ( $FileTags ) ) { if ( (!isset($this->$val)) || (empty($this->$val)) ) { $this->LOADED["$val"] = 1; if(isset($this->DYNAMIC["$val"])) { $this->parse_dynamic($val,$ReturnVar); } else { $fileName = $this->FILELIST["$val"]; $this->$val = $this->get_template($fileName); } } // Array context implies overwrite $this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS); // For recursive calls. $this->assign( array( $ReturnVar => $this->$ReturnVar ) ); } } // end if FileTags is array() else { // FileTags is not an array $val = $FileTags; if( (substr($val,0,1)) == '.' ) { // Append this template to a previous ReturnVar $append = true; $val = substr($val,1); } if ( (!isset($this->$val)) || (empty($this->$val)) ) { $this->LOADED["$val"] = 1; if(isset($this->DYNAMIC["$val"])) { $this->parse_dynamic($val,$ReturnVar); } else { $fileName = $this->FILELIST["$val"]; $this->$val = $this->get_template($fileName); } } if($append) { $this->$ReturnVar .= $this->parse_template($this->$val,$this->PARSEVARS); } else { $this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS); } // For recursive calls. $this->assign(array( $ReturnVar => $this->$ReturnVar) ); } return; } // End parse() // ************************************************************ function FastPrint ( $template = "" ) { if(empty($template)) { $template = $this->LAST; } if( (!(isset($this->$template))) || (empty($this->$template)) ) { $this->error("Nothing parsed, nothing printed",0); return; } else { print $this->$template; } return; } // ************************************************************ function fetch ( $template = "" ) { if(empty($template)) { $template = $this->LAST; } if( (!(isset($this->$template))) || (empty($this->$template)) ) { $this->error("Nothing parsed, nothing printed",0); return ""; } return($this->$template); } // ************************************************************ function define_dynamic ($Macro, $ParentName) { // A dynamic block lives inside another template file. // It will be stripped from the template when parsed // and replaced with the {$Tag}. $this->DYNAMIC["$Macro"] = $ParentName; return true; } // ************************************************************ function parse_dynamic ($Macro,$MacroName) { // The file must already be in memory. $ParentTag = $this->DYNAMIC["$Macro"]; if( (!$this->$ParentTag) or (empty($this->$ParentTag)) ) { $fileName = $this->FILELIST[$ParentTag]; $this->$ParentTag = $this->get_template($fileName); $this->LOADED[$ParentTag] = 1; } if($this->$ParentTag) { $template = $this->$ParentTag; $DataArray = split("\n",$template); $newMacro = ""; $newParent = ""; $outside = true; $start = false; $end = false; while ( list ($lineNum,$lineData) = each ($DataArray) ) { $lineTest = trim($lineData); if("" == "$lineTest" ) { $start = true; $end = false; $outside = false; } if("" == "$lineTest" ) { $start = false; $end = true; $outside = true; } if( (!$outside) and (!$start) and (!$end) ) { $newMacro .= "$lineData\n"; // Restore linebreaks } if( ($outside) and (!$start) and (!$end) ) { $newParent .= "$lineData\n"; // Restore linebreaks } if($end) { $newParent .= "{".$MacroName."}\n"; } // Next line please if($end) { $end = false; } if($start) { $start = false; } } // end While $this->$Macro = $newMacro; $this->$ParentTag = $newParent; return true; } // $ParentTag NOT loaded - MAJOR oopsie else { @error_log("ParentTag: [$ParentTag] not loaded!",0); $this->error("ParentTag: [$ParentTag] not loaded!",0); } return false; } // ************************************************************ // Strips a DYNAMIC BLOCK from a template. function clear_dynamic ($Macro="") { if(empty($Macro)) { return false; } // The file must already be in memory. $ParentTag = $this->DYNAMIC["$Macro"]; if( (!$this->$ParentTag) or (empty($this->$ParentTag)) ) { $fileName = $this->FILELIST[$ParentTag]; $this->$ParentTag = $this->get_template($fileName); $this->LOADED[$ParentTag] = 1; } if($this->$ParentTag) { $template = $this->$ParentTag; $DataArray = split("\n",$template); $newParent = ""; $outside = true; $start = false; $end = false; while ( list ($lineNum,$lineData) = each ($DataArray) ) { $lineTest = trim($lineData); if("" == "$lineTest" ) { $start = true; $end = false; $outside = false; } if("" == "$lineTest" ) { $start = false; $end = true; $outside = true; } if( ($outside) and (!$start) and (!$end) ) { $newParent .= "$lineData\n"; // Restore linebreaks } // Next line please if($end) { $end = false; } if($start) { $start = false; } } // end While $this->$ParentTag = $newParent; return true; } // $ParentTag NOT loaded - MAJOR oopsie else { @error_log("ParentTag: [$ParentTag] not loaded!",0); $this->error("ParentTag: [$ParentTag] not loaded!",0); } return false; } // ************************************************************ function define ($fileList) { while ( list ($FileTag,$FileName) = each ($fileList) ) { $this->FILELIST["$FileTag"] = $FileName; } return true; } // ************************************************************ /* function clear_parse ( $ReturnVar = "") { $this->clear($ReturnVar); } */ // ************************************************************ function clear ( $ReturnVar = "" ) { // Clears out hash created by call to parse() if(!empty($ReturnVar)) { if( (gettype($ReturnVar)) != "array") { unset($this->$ReturnVar); return; } else { while ( list ($key,$val) = each ($ReturnVar) ) { unset($this->$val); } return; } } // Empty - clear all of them while ( list ( $key,$val) = each ($this->HANDLE) ) { $KEY = $key; unset($this->$KEY); } return; } // end clear() // ************************************************************ function clear_all () { $this->clear(); $this->clear_assign(); $this->clear_define(); $this->clear_tpl(); return; } // end clear_all // ************************************************************ function clear_tpl ($fileHandle = "") { if(empty($this->LOADED)) { // Nothing loaded, nothing to clear return true; } if(empty($fileHandle)) { // Clear ALL fileHandles while ( list ($key, $val) = each ($this->LOADED) ) { unset($this->$key); } unset($this->LOADED); return true; } else { if( (gettype($fileHandle)) != "array") { if( (isset($this->$fileHandle)) || (!empty($this->$fileHandle)) ) { unset($this->LOADED[$fileHandle]); unset($this->$fileHandle); return true; } } else { while ( list ($Key, $Val) = each ($fileHandle) ) { unset($this->LOADED[$Key]); unset($this->$Key); } return true; } } return false; } // end clear_tpl // ************************************************************ function clear_define ( $FileTag = "" ) { if(empty($FileTag)) { unset($this->FILELIST); return; } if( (gettype($Files)) != "array") { unset($this->FILELIST[$FileTag]); return; } else { while ( list ( $Tag, $Val) = each ($FileTag) ) { unset($this->FILELIST[$Tag]); } return; } } // ************************************************************ // Aliased function - used for compatibility with CGI::FastTemplate function clear_parse () { $this->clear_assign(); } // ************************************************************ // Clears all variables set by assign() function clear_assign () { if(!(empty($this->PARSEVARS))) { while(list($Ref,$Val) = each ($this->PARSEVARS) ) { unset($this->PARSEVARS["$Ref"]); } } } // ************************************************************ function clear_href ($href) { if(!empty($href)) { if( (gettype($href)) != "array") { unset($this->PARSEVARS[$href]); return; } else { while (list ($Ref,$val) = each ($href) ) { unset($this->PARSEVARS[$Ref]); } return; } } else { // Empty - clear them all $this->clear_assign(); } return; } // ************************************************************ function assign ($tpl_array, $trailer="") { if(gettype($tpl_array) == "array") { while ( list ($key,$val) = each ($tpl_array) ) { if (!(empty($key))) { // Empty values are allowed // Empty Keys are NOT $val = str_replace("{","###{###",$val); $this->PARSEVARS["$key"] = $val; } } } else { // Empty values are allowed in non-array context now. if (!empty($tpl_array)) { $this->PARSEVARS["$tpl_array"] = $trailer; } } } // ************************************************************ // Return the value of an assigned variable. // Christian Brandel cbrandel@gmx.de function get_assigned($tpl_name = "") { if(empty($tpl_name)) { return false; } if(isset($this->PARSEVARS["$tpl_name"])) { return ($this->PARSEVARS["$tpl_name"]); } else { return false; } } // ************************************************************ function error ($errorMsg, $die = 0) { $this->ERROR = $errorMsg; echo "ERROR: $this->ERROR
\n"; if ($die == 1) { exit; } return; } // end error() // ************************************************************ // ************************************************************ } // End class.FastTemplate.php3 ?>