PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Verne Joe  >  XML Guestbook  >  index.php  >  Download  
File: index.php
Role: Application script
Content type: text/plain
Description: index page of guestbook
Class: XML Guestbook
Create and manage guestbooks stored in XML files
Author: By
Last change: modify
Date: 10 years ago
Size: 3,962 bytes
 

Contents

Class file image Download
<?php

/////////////////////////////////////////////////////////////////////
//
// this is the index page of guestbook
// it display records on page and format them with HTML tags
// last modify was on 2004-12-27
//
/////////////////////////////////////////////////////////////////////


include('xml_class.php');
include(
'constant.php');

//creat a object of class xml_opration
$xml = new xml_opration;
$xml->xmlFormat();
$xml->page();

//display records for appointed count
$data = $xml->xmlPartFormat($page,$pagecount);

echo
"<html>
         <head>
            <title>"
.PAGE_TITLE."</title>
            <link type='text/css' rel='stylesheet' href='style.css'>
         </head>
         <body bgcolor='#FFFBDA'>"
;

echo
"<table width='70%' align=center border=0 cellpadding=5 cellspacing=1 bgcolor='#7BBBE3'>";
echo
"<tr align=center class=title><td>".PAGE_TITLE."</td></tr>";
echo
"</table><br>";
echo
"<table width='70%' align=center border=0 cellpadding=5 cellspacing=1 bgcolor='#7BBBE3'>";


//////////////////////////////////////////////////
// traversal the array $data //
// and get attributes or values of every node //
// at last display these data and format them //
//////////////////////////////////////////////////

$i = 1;
foreach(
$data as $val){
   
//print_r($val);
   
if ($val['tag'] == 'root' && $val['type'] == 'open')
      continue;
    if (
$val['tag'] == 'root' && $val['type'] == 'close')
      break;
    if (
$val['tag'] == 'subject' && $val['type'] == 'open'){
          
$id = $val['attributes']['id'];
           continue;
    }
    if (
$val['tag'] == 'title'){
          
$title = $val['value'];
           continue;
    }
    if (
$val['tag'] == 'author'){
          
$author = $val['value'];
           continue;
    }
    if (
$val['tag'] == 'content'){
          
$content = $val['value'];
           continue;
    }
    if (
$val['tag'] == 'time'){
          
$time = $val['value'];
           continue;
    }
    if (
$val['tag'] == 'picture'){
          
$picture = $val['value'];
           continue;
    }

    if (
$i == 1 && $page == 1)
        echo
"<tr class=text><td><a href=rss.xml target='_BLANK'>xml</a></td><td align=right><a href=creatnew.php?id=".$id.">".NEW_LEAVE_WORD."</a></td></tr>";
    elseif (
$i == 1 && $page != 1)
        echo
"<tr class=text><td><a href=rss.xml target='_BLANK'>xml</a></td><td align=right>".WANT_CEART_WORD."</td></tr>";
   
//format data with HTML tags
   
echo "<tr bgcolor='#DAFFDC' class=text>
             <td width=20%>"
.WORD_AUTHOR.$author."</td>
             <td>"
.WORD_TITLE.$title."</td>
         </tr>
         <tr bgcolor='#B5FEB9' class=text>
             <td><img src='images/person/"
.$picture.".gif'</td>
             <td>"
.WORD_CONTENT.$content."</td>
         </tr></td></tr>
         <tr bgcolor='#DAFFDC' class=text>
             <td colspan=2>"
.WORD_TIME.$time."</td>
         </tr>
         <tr bgcolor='#FFFBDA' align=right class=text>
             <td colspan=2><a href=modify.php?id="
.$id.">".WORD_MODIFY."</a>&nbsp;&nbsp;<a href=delete.php?id=".$id.">".WORD_DELETE."</a></td>
         </tr>"
;
   
$i++;
    if (
$val['tag'] == 'subject' && $val['type'] == 'close')
      continue;
}

//Here is the pagenite system in depth of page

echo "<tr class=text><td>".TOTAL_RECORD_FRONT.$pagecount.PAGE.$total.TOTAL_RECORD_BACK."</td>";
echo
"<td align=right>".$pagestring."&nbsp;";
$select="<select onchange=\"location='?page='+this.options[this.selectedIndex].value\">";
    for (
$i=1;$i<=$pagecount;$i++){
   
$select.="<option value='$i'".(($i==$page)?' selected':'').">".$i."</option>";
    }
$select.="</select>".PAGE."</td></tr>";
echo
$select;

echo
"</table>";
echo
"<table width='70%' align=center border=0 cellpadding=5 cellspacing=1 bgcolor='#7BBBE3'>";
echo
"</table><br>";
echo
"</body>";
echo
"</html>";


?>