Example #1
0
function session_test()
{
    tem_load('code/wfpl/test/session_test.html');
    db_delete('wfpl_sessions');
    db_delete('wfpl_session_data');
    session_dump('Clean slate');
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_dump('username jason');
    session_set('username', 'phil');
    session_dump('overwrote username as phil');
    $old = $GLOBALS['session_id'];
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_set('bamph', 'foo');
    session_dump('set username=jason and bamph=foo in new session');
    session_clear('username');
    session_dump('cleared username in new session');
    _kill_session($old);
    session_dump('killed old session');
    kill_session();
    session_dump('kill_session()');
    tem_output();
}
Example #2
0
function preview()
{
    tem_load('code/wfpl/metaform/preview.html');
    tem_set('form_name', $GLOBALS['form_name']);
    tem_set('fields', $_REQUEST['fields']);
    $preview_tem = new tem();
    $preview_tem->load_str(make_html(false));
    if ($GLOBALS['opt_db'] == 'Yes') {
        $preview_tem->show('new_msg');
    }
    $fields = get_fields();
    foreach ($fields as $field) {
        list($name, $type, $input, $format, $sql) = $field;
        if ($type == 'pulldown') {
            pulldown($name, array('option 1', 'option 2', 'option 3'));
        }
    }
    $preview = $preview_tem->run();
    unset($preview_tem);
    $preview = ereg_replace('type="submit"', 'type="submit" disabled="disabled"', $preview);
    tem_set('preview', $preview);
    tem_show('hiddens');
    set_form_action();
    tem_output();
}
Example #3
0
<?php

# Copyright (C) 2005 Jason Woofenden  PUBLIC DOMAIN
# This file (along with its html template) demonstrates, documents and tests
# the template system.
# First we'll need the functions in wfpl/template.php:
require_once 'code/wfpl/template.php';
# Always use the exact require_once statement above to get access to these
# functions. You should have in each directory of your projects a copy of wfpl
# or a symbolic link to it. This allows there to be different versions of wfpl
# without changing the php for the site.
# Now grab the template (you might want to take a look at this file)
tem_load('tem_test.php.html');
# This creates a template object to store all sorts of things, and then reads
# in the template file and scans through it for sub-templates. Sub templates
# are parts of the template that may appear any number of times in the output
# (even zero times) such as a table row meant to hold a database record.
# This is probably not the best example, but this template contains tables for
# login, and for displaying some fake database content. For this silly example
# I decide which I'm going to display by checking if the user has submitted a
# username.
if (!isset($_REQUEST['user'])) {
    # tem_set() gives a key/value pair to template.php. When the template is
    # output (or sub-templates are run with tem_sub) any occurences of ~user~
    # will be replaced with 'bert'.
    tem_set('user', 'bert');
    # The template file contains a sub-template called 'login'. By default,
    # sub-templates do not display at all. They display once for each time you
    # call tem_sub()
    tem_sub('login');
    # This runs the template and prints the output. Running the template is