<?php
# This script shows how use of SimpleObject and its child classes
# may ease your programming
# TASK - List all directory files
# include all required classes
require_once('simpleobject.php');
require_once('simpleiterator.php');
require_once('DirectoryIterator.php');
require_once('simpletemplate.php');
require_once('listtemplate.php');
# Create an instance of list template:
# Send an instance of DirectoryIterator as argument
$list_tpl =& new ListTemplate(new DirectoryIterator('/path/to/dir'));
# Set title (variable in template) to list
$list_tpl->set('list_title','What a Simple file listing!');
# Display the list of items:
$list_tpl->display('list_template.html','item_template.html');
# That's it!
# Don't forget to make list_template.html and item_template.html
# files such that they have markers like <!--$field_name--> in
# item_template.html and <!--$list--> and <!--$list_title-->
# in list_template.html. <!--$list--> will be replaced by output
# of item listing:
/*
list_template.html:
<h1><!--$list_title--></h1>
<p>Here are the files of /path/to/dir directory:</p>
<table>
<tr>
<th>filename</th>
</tr>
<!--$list-->
</table>
item_template.html:
<tr>
<td><!--$name--></td>
</tr>
You can modify DirectoryIterator to make it
match your requirements
*/
?>
|