PHP Classes
elePHPant
Icontem

File: example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gregory Patmore  >  TPLManager  >  example2.php  >  Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: another example
Class: TPLManager
Template engine that uses regular expressions
Author: By
Last change:
Date: 7 years ago
Size: 1,317 bytes
 

Contents

Class file image Download
<?php

function getTPLV_NAME(){ return 'John Q. Public'; }
function
getTPLV_SUPPORTEMAIL(){ return 'mail@gregorypatmore.com'; }
function
getTPLV_MY_NAME(){ return 'Gregory Patmore'; }

/**
 * example1.php
 * Example usage of the TPLManager using the load-n-launch method
 *
 * @author Gregory Patmore (mail at gregorypatmore dot com)
 * @version 1.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package TPLManager
 * @access public
 */
try{
    print
"Example Usage of the TPLManager class using the CREATE-N-LOOP method";
   
   
/* Include the file. */
   
include('tplmanager.class.php');
   
   
/* Create a new instance */
   
$t = new TPLManager('thanks_email.tpl');
   
   
/* Retrieve the hotspot list */
   
$spots = $t->getHotspotList();
   
    if(
is_array($spots)){
       
       
/* Loop through and assign a value */
       
foreach($spots as $s){
           
$func = 'getTPLV_' . strtoupper($s);
            if(
function_exists($func))
               
$t->setVal($s, $func());
        }
       
       
/* Retrieve the processed text */
       
$procTxt = $t->getParsed();
       
       
/* (Do something useful with it here) */
       
print '<pre>' . $procTxt . '</pre>';
        exit;
       
    }else
trigger_error('Template processing failed to find any hotspots to replace', E_USER_WARNING);

}catch(
Exception $e){
   
/* Do something with an error here */
   
exit($e->getMessage());
}
?>