Ejemplo n.º 1
0
*
* @version $Id: 7_include.php,v 1.1 2004/10/04 01:52:24 pmjones Exp $
* 
*/
error_reporting(E_ALL);
require_once 'Savant2.php';
$conf = array('template_path' => 'templates', 'resource_path' => 'resources');
$savant = new Savant2($conf);
$array = array('key0' => 'val0', 'key1' => 'val1', 'key2' => 'val2');
$var1 = 'variable1';
$var2 = 'variable2';
$var3 = 'variable3';
$ref1 = 'reference1';
$ref2 = 'reference2';
$ref3 = 'reference3';
// assign vars
$savant->assign($var1, $var1);
$savant->assign($var2, $var2);
$savant->assign($var3, $var3);
// assigns $array to a variable $set
$savant->assign('set', $array);
// assigns the keys and values of array
$savant->assign($array);
// assign references
$savant->assignRef($ref1, $ref1);
$savant->assignRef($ref2, $ref2);
$savant->assignRef($ref3, $ref3);
// load the cycle plugin with preset cycle values
$savant->loadPlugin('cycle', array('values' => array('lightdark' => array('light', 'dark'))));
// run through the template
$savant->display('main.tpl.php');
Ejemplo n.º 2
0
$savant = new Savant2($conf);
$array = array('key0' => 'val0', 'key1' => 'val1', 'key2' => 'val2');
$var1 = 'variable1';
$var2 = 'variable2';
$var3 = 'variable3';
$ref1 = 'reference1';
$ref2 = 'reference2';
$ref3 = 'reference3';
// assign vars
$savant->assign($var1, $var1);
$savant->assign($var2, $var2);
$savant->assign($var3, $var3);
// assigns $array to a variable $set
$savant->assign('set', $array);
// assigns the keys and values of array
$savant->assign($array);
// assign references
$savant->assignRef($ref1, $ref1);
$savant->assignRef($ref2, $ref2);
$savant->assignRef($ref3, $ref3);
// load the cycle plugin with preset cycle values
$savant->loadPlugin('cycle', array('values' => array('lightdark' => array('light', 'dark'))));
// preload the image plugin
$savant->loadPlugin('image', array('imageDir' => 'resources/'));
// preload the dateformat plugin
$savant->loadPlugin('dateformat', array('custom' => array('mydate' => '%d/%m/%Y')));
// preload a custom plugin
$savant->loadPlugin('fester', null, true);
// run through the template
$savant->display('plugins.tpl.php');
// done!
Ejemplo n.º 3
0
/**
* 
* Tests default plugins
*
* @version $Id: 9_errors.php,v 1.2 2004/11/05 16:00:38 pmjones Exp $
* 
*/
error_reporting(E_ALL);
require_once 'Savant2.php';
$savant = new Savant2();
require_once 'PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
echo "<h1>PEAR_Error</h1>\n";
$savant->setError('pear');
$result = $savant->loadPlugin('nosuchthing');
echo "<pre>\n";
print_r($result);
echo "</pre>\n\n";
echo "<h1>PEAR_ErrorStack</h1>\n";
$savant->setError('stack');
$result = $savant->loadPlugin('nosuchthing');
echo "<pre>\n";
print_r($result);
echo "</pre>\n\n";
echo "<pre>\n";
print_r(print_r($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']));
echo "</pre>\n\n";
echo "<h1>Exception</h1>\n";
$savant->setError('exception');
$result = $savant->loadPlugin('nosuchthing');