Esempio n. 1
0
$tpl->load_file($tplt, $path['templates'] . $tmpl['layout']);
/*****************************************************
 ** Register language file and additional text array
 *****************************************************/
if (isset($txt) and is_array($txt)) {
    reset($txt);
    while (list($key, $val) = each($txt)) {
        ${$key} = $val;
        $tpl->register($tplt, $key);
    }
}
if (isset($add_text) and is_array($add_text)) {
    reset($add_text);
    while (list($key, $val) = each($add_text)) {
        ${$key} = $val;
        $tpl->register($tplt, $key);
    }
}
/*****************************************************
 ** Parse template
 *****************************************************/
$tpl->register($tplt, array('bar_image_name', 'document_self', 'intern_vote_name', 'max_bar_width', 'rating', 'rating_image', 'script_self', 'total_votes', 'vote_form_fields', 'vote_text', 'vote_title', 'captcha_content', 'email_address'));
$tpl->parse_if($tplt, 'display_form');
$tpl->parse_if($tplt, 'display_results');
$tpl->parse_if($tplt, 'display_link');
$tpl->parse_if($tplt, 'display_email');
$tpl->parse_if($tplt, 'display_captcha');
$tpl->parse_loop($tplt, 'vote_result');
$tpl->parse_loop($tplt, 'message');
@eval($conf_var);
debug_mode(script_runtime($runtime_start), 'Script Runtime');
} else {
    /*****************************************************
     ** Parse global template (mostly for user debugging)
     *****************************************************/
    if (isset($add_text) and is_array($add_text)) {
        reset($add_text);
        foreach ($add_text as $key => $val) {
            ${$key} = $val;
            $tpl->register('dlcl', $key);
        }
    }
    $txt['txt_script_version'] = $script_version;
    if (!isset($show_error_messages) or $show_error_messages != 'yes') {
        unset($system_message);
        $system_message = array();
        $txt['txt_system_message'] = '';
    } else {
        $system_message[] = array('message' => $txt['txt_set_off_note']);
        $system_message[] = array('message' => $txt['txt_problems']);
    }
    if (isset($txt) and is_array($txt)) {
        reset($txt);
        foreach ($txt as $key => $val) {
            ${$key} = $val;
            $tpl->register('dlcl', $key);
        }
    }
    $tpl->parse_loop('dlcl', 'system_message');
    @eval($parse_template);
}
debug_mode(script_runtime($runtime_start), 'Script Runtime');
Esempio n. 3
0
/*****************************************************
 ** Load template
 *****************************************************/
$tpl = new template();
$tpl->load_file('global', './templates/test.tpl.html');
/*****************************************************
 ** Parse global template (mostly for user debugging)
 *****************************************************/
if (isset($add_text) and is_array($add_text)) {
    reset($add_text);
    foreach ($add_text as $key => $val) {
        ${$key} = $val;
        $tpl->register('global', $key);
    }
}
if (isset($extension_list) and !empty($extension_list) and is_array($extension_list)) {
    for ($i = 0; $i < count($extension_list); $i++) {
        $extensions[] = array('EXT' => strtoupper($extension_list[$i]), 'ext' => strtolower($extension_list[$i]));
    }
}
$tpl->parse_loop('global', 'system_message');
$tpl->parse_loop('global', 'extensions');
if (isset($txt) and is_array($txt)) {
    reset($txt);
    foreach ($txt as $key => $val) {
        ${$key} = $val;
        $tpl->register('global', $key);
    }
}
$tpl->parse('global');
$tpl->print_file('global');
** Filename.....: seperate-script.php
** Author.......: Richard Heyes
** Version......: 1.0
** Notes........: This shows how you can
**                use multiple template files.
** Last changed.: 23/05/00
** Last change..:
***************************************/
include 'class.template.inc';
/***************************************
** Set a couple of example variables.
***************************************/
$test_var = 'Hello world!';
$page_title = 'Template Class';
/***************************************
** Set a couple of example arrays.
***************************************/
$table_rows = array();
$table_rows[] = array('column_1' => 'This is column one on row one!', 'column_2' => 'This is column two on row one!', 'column_3' => 'This is column three on row one!');
$table_rows[] = array('column_1' => 'This is column one on row two!', 'column_2' => 'This is column two on row two!', 'column_3' => 'This is column three on row two!');
/***************************************
** The template goodies.
***************************************/
$tpl = new template();
$tpl->load_file('header', 'header-template.html');
$tpl->load_file('main', 'main-template.html');
$tpl->load_file('footer', 'footer-template.html');
$tpl->register('header', 'test_var, page_title');
$tpl->parse('header, main, footer');
$tpl->parse_loop('main', 'table_rows');
$tpl->print_file('header, main, footer');
$table_rows[] = array('column_1' => 'This is column one on row two!', 'column_2' => 'This is column two on row two!', 'column_3' => 'This is column three on row two!');
/***************************************
** Postgres stuff. This was the code I
** used to test the $obj->parse_pgsql()
** method. Worked too.
***************************************/
/*
        $pg = pg_connect('user=richard dbname=scripts port=5432');

        $sqlquery = 'SELECT col1 AS column_1, col2 AS column_2, col3 AS column_3 FROM test';
        $table_rows = pg_exec($pg, $sqlquery);
*/
/***************************************
** The template goodies, using shortcut
** functions.
***************************************/
$tpl = new template();
$tpl->load_file('complete', 'complete-template.html');
$tpl->parse_loop('complete', 'table_rows');
$tpl->pprint('complete', array('test_var', 'page_title'));
/***************************************
** The template goodies, using the
** longer method.
***************************************/
/*
        $tpl->load_file('complete', 'complete-template.html');
        $tpl->register('complete', 'test_var,page_title');
        $tpl->parse('complete');
        $tpl->parse_loop('complete', 'table_rows');
        $tpl->print_file('complete');
*/
Esempio n. 6
0
<?php

include 'tplutil.inc';
include 'class.template.inc';
$GLOBALS['TITLE'] = 'My Title';
$GLOBALS['USER'] = get_user();
$GLOBALS['users'] = get_users(true);
$tpl = new template();
$tpl->load_file('main', 'slides/pragmatic/templateclass.tpl');
$tpl->parse_loop('main', 'users');
$tpl->pprint('main', array('USER', 'TITLE'));