Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oleksiy Zubovskyy  >  HTML Data Parser  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Test for HTML Template Data Parser
Class: HTML Data Parser
Parse HTML and template files
Author: By
Last change: improvement
Date: 5 years ago
Size: 4,579 bytes
 

Contents

Class file image Download
<?
////////////////////////////////////////////////////////////////////////////////
// Test for HTML Template Data Parser                                         //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// VERSION      : 1.1                                                         //
// AUTHOR       : Oleksiy Zubovskyy                                           //
// CREATED      : 16 Dec 2003                                                 //
// WEBSITE      :                                                             //
// SUPPORT      : alex.zubovsky@gmail.com                                     //
// BUG-REPORT   : alex.zubovsky@gmail.com                                     //
// COMMENT      : HTML template oriented data parser class                    //
// LEGAL        : Copyright (C) 2003 Oleksiy Zubovskyy.                       //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// This code may be used and modified by anyone so long as  this header and   //
// copyright  information remains intact.                                     //
//                                                                            //
// The code is provided "as-is" and without warranty of any kind,             //
// expressed, implied or otherwise, including and without limitation, any     //
// warranty of merchantability or fitness for a  particular purpose.          //
//                                                                            //
// In no event shall the author be liable for any special, incidental,        //
// indirect or consequential damages whatsoever (including, without           //
// limitation, damages for loss of profits, business interruption, loss       //
// of information, or any other loss), whether or not advised of the          //
// possibility of damage, and on any theory of liability, arising out of      //
// or in connection with the use or inability to use this software.           //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
// HISTORY :                                                                  //
////////////////////////////////////////////////////////////////////////////////


require("templateparser.php");

/* Testing */
$parser = new HTMLTemplateDataParser_Class;
$parser->LoadHTML("step2.html");
$parser->Parse();
$result=$parser->GetElements(&$htmlcode);
if (
$result){
     echo 
"HTML source:<BR>";
     while (list(
$key$code) = each ($htmlcode)){
         echo 
$key."-".htmlentities($code)."<BR>";
     }
}else{
  die(
"Error");
}

// echo "<BR>///////////////////////////////////////////<BR>";

$result=$parser->LoadTemplate("tmpl");
if (!
$result){
   die(
"Template load error");
}

// echo "<BR>Template:<BR>";

/*
$result=$parser->GetTemplate(&$template);
if ($result){
       for($i=0;$i<count($template);$i++){
         for($j=0;$j<count($template[$i]);$j++)
            for($n=0;$n<count($template[$i][$j]);$n++)
                while (list($key, $code) = each ($template[$i][$j][$n]))
                    echo "template[".$i."][".$j."][".$n."][".$key."]=".htmlentities($code)."<BR>";

       }
}else{
   die("Template error");
}
*/

// echo "<BR>Values:<BR>";


echo "<table border=0 cellpadding=5 cellspacing=1 bgcolor=#000000 align=center>";
echo 
"<tr valign=middle bgcolor=#9999cc><th>Index</th><th>Code</th><th>Name</th><th>Points</th><th>Price</th></tr>";

$i=0;

if(
$parser->FindFirst()){
    
$i++;
    
$parser->GetValues(&$values);
    echo 
"<tr valign=baseline bgcolor=#cccccc>";
    echo 
"<td align=right>".$i."</td><td>".$values["code"]."</td><td>".$values["name"]."</td><td align=right>".$values["points"]."</td><td align=right>".$values["price"]."</td>";
    echo 
"</tr>";
    while(
$parser->FindNext()){
        
$parser->GetValues(&$values);
        
$i++;
        echo 
"<tr valign=baseline bgcolor=#cccccc>";
        echo 
"<td align=right>".$i."</td><td>".$values["code"]."</td><td>".$values["name"];
        if(isset(
$values["text"])) echo " <u>".$values["text"]."</u> ";
        echo 
"</td><td align=right>".$values["points"]."</td><td align=right>".$values["price"]."</td>";
        echo 
"</tr>";
    }
}

echo 
"</table>";


?>