<?php
/***
* XIRE - eXtendable Information Rendering Engine
* ----------------------------------------------
* LICENSE
* Copyright (C) 2006 David Duong
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Include the Template class
require_once '../lib/CacheTemplate.class.php';
// Instantiate a template object
$cache = new XIRE_CacheTemplate('index.tpl');
// The following three lines are optional, but you probably will want to make use of them
$cache->lifetime = 3600; // Set to consider caches older than 3600 secs (1 hour) expired
$cache->name = 'index'; // The cache filename will be based on this value
$cache->key = 'key'; // The cache will be saved to a folder whose name is based
// on the above value, and the cache filename will be based on
// this value
// Check to see if an up-to-date cache exists, if so then there is no need to generate
// and push information onto the template
// Otherwise, push data onto the template
if (!$cache->exists()) {
// This demos two ways to do the same thing (see demo/index.php)
$cache->template->set('variable', 'test variable');
$cache->template->set('true', true);
$cache->template['var'] = array('x', 'y', 'z');
$cache->template['false'] = false;
}
// Inefficient method, see below. Load the cache into the template's output document.
$cache->load();
// Finally, output the results
header('content-type: text/xml');
echo $cache->template->getXML(true);
/* It would be even better if $cache->getFile() is used instead to get the cache's filename
for you to parse into a URL redirection. This method would make use of any client-side
caching and eliminate the overhead of loading and parsing the cache file.
IMPORTANT NOTE: Make sure that you keep caches that may have sensitive information in a
non-www accessible location (see documentation on how to have caches stored in several
different locations)
Pseudo alternate method:
$url = yourPathToURLFunction($cache->getFile());
header("Location: $url");
*/
?>
|