PHP Classes

File: test.php

Recommend this page to a friend!
  Packages of Gregory   PHTML::Template v2   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: test.php
Class: PHTML::Template v2
PHP template compiler engine
Author: By
Last change: bugfix
Date: 21 years ago
Size: 1,210 bytes
 

 

Contents

Class file image Download
<?
define ('GZIP',        FALSE);        // GZip support
define ('DEBUG',    TRUE);        // If TRUE, compiled templates not cached

require_once '/lib/class.tpl.inc';

// Engine initialisation
$path = dirname(__FILE__);
$tpl = new tpl('test', $path."/templates/new", $path."/templates");

$g = array(
    'r' => array(255, -8),
    'g' => array(255, -6),
    'b' => array(255, -4),
    );

$lines = array();
for ($i = 1; $i < 10; $i++) {        // Nested LOOP initialization
    $cells = array();
    for ($j = 1; $j < 10; $j++) {
        $k = $i * $j;
        array_push($cells, array('var1' => $k, 'odd' => $k % 2));
    }
    array_push($lines, array('cols' => $cells, 'color' =>_gradient($g, $i)));
}

// Initialize 'root' variable
$root = array(
    'rows' => &$lines,
    'title' => 'PHTML::Template 2.0',
    'sw' => 'three',
    );

$tpl->done();

/////////////////////////////////////////////////////////////////////
// Aux functions
/////////////////////////////////////////////////////////////////////

function _gradient($args, $x) {        // Color gradient generation
    // C + P * x;
    foreach ($args as $c => $p)
        $$c = (string)bin2hex(chr((string)(array_shift($p) + array_shift($p) * $x)));
    return strtoupper($r.$g.$b);
}

?>