Login   Register  
PHP Classes
elePHPant
Icontem

File: test_ngenie.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sergey cheeba  >  nGenie  >  test_ngenie.php  >  Download  
File: test_ngenie.php
Role: Example script
Content type: text/plain
Description: ngenie class example
Class: nGenie
Template engine with block iteration support
Author: By
Last change:
Date: 10 years ago
Size: 1,380 bytes
 

Contents

Class file image Download
<?
    
include_once("ngenie.lib.php");
    
    
$doc = new nGenie();
    
    
$lines file("test_ngenie.dat");
    foreach (
$lines as $line) {
        
$line trim($line);
        if (
preg_match("/\[([a-z_]+)\]/i"$line$matches)) {
            
$current_section $matches[1];
        } else {
            
$data[$current_section][] = $line;
        }
    }
    
//print_r($data);
    
    
$doc->start("test_ngenie.tpl");
    
    if (
count($data["Authors"])) {
        
$authors_block = new block("authors_block");
        foreach (
$data["Authors"] as $key => $author_name) {
            
$author = new block("author");
            
$author->set_param("AUTHOR_NAME"$author_name);
            
$authors_block->set_block("AUTHOR"$author);
        }
        
$doc->set_block("AUTHORS"$authors_block);
    }
    
    if (
count($data["Colors"])) {
        
$color_table_block = new block("color_table_block");
        foreach (
$data["Colors"] as $key => $color_line) {
            list(
$color_name$color) = split("="$color_line);
            
$color_cell = new block("color_cell_block");
            
$color_cell->set_param("COLOR"$color);
            
$color_cell->set_param("COLOR_NAME"$color_name);
            
$color_table_block->set_block("COLOR_CELL"$color_cell);
        }
        
$doc->set_block("COLOR_TABLE"$color_table_block);
    }
    
    
$doc->output();
?>