Example #1
0
 function __toString()
 {
     if (method_exists($this->object, '__toString')) {
         return $this->savant->escape($this->object->__toString());
     }
     throw new BadMethodCallException('Object of class ' . $this->__getClass() . ' could not be converted to string');
 }
Example #2
0
<?php

require_once dirname(__DIR__) . '/../../autoload.php';
ini_set('display_errors', true);
session_start();
$view = new PEAR2\Pyrus\Developer\CoverageAnalyzer\Web\View();
$rooturl = parse_url($_SERVER['REQUEST_URI']);
$rooturl = $rooturl['path'];
$controller = new PEAR2\Pyrus\Developer\CoverageAnalyzer\Web\Controller($_GET);
$controller::$rooturl = $rooturl;
$savant = new PEAR2\Templates\Savant\Main();
$savant->setClassToTemplateMapper(new PEAR2\Pyrus\Developer\CoverageAnalyzer\Web\ClassToTemplateMapper());
$savant->setTemplatePath(__DIR__ . '/templates');
$savant->setEscape('htmlentities');
echo $savant->render($controller);
Example #3
0
            $this->view = $options['view'];
        }
        $this->output = new $this->view_map[$this->view]();
    }
}
class BaseballPlayer
{
    public $name = 'Joseph Baseball <AKA: Joey B>';
    public $years_on_team = array(2005, 2008);
    function __construct()
    {
        $this->years_on_team[] = new PartialSeason(date('Y'));
    }
}
class PartialSeason
{
    public $start;
    public $end;
    function __construct($start, $end = null)
    {
        $this->start = $start;
        if ($end) {
            $this->end = $end;
        }
    }
}
$team = new BaseballTeam();
$team->name = 'Phillies';
$savant = new PEAR2\Templates\Savant\Main();
$savant->setEscape('htmlspecialchars');
echo $savant->render($team);
Example #4
0
<?php

ini_set('display_errors', true);
error_reporting(E_ALL ^ E_STRICT);
require_once __DIR__ . '/../../autoload.php';
// Set up a view object we'd like to display
$class = new stdClass();
$class->var1 = '<p>This is var1 inside a standard class</p>';
$savant = new \PEAR2\Templates\Savant\Main();
$savant->addTemplatePath(__DIR__ . '/templates');
// Display a simple string
echo $savant->render('<h1>Welcome to the Savant Demo</h1>');
// Display a string, in a custom template
echo $savant->render('mystring', 'StringView.tpl.php');
// Display an array
echo $savant->render(array('<ul>', '<li>This is an array</li>', '</ul>'));
// Display an object using a default class name to template mapping function
echo $savant->render($class);
// Display the object using a specific template
echo $savant->render($class, 'MyTemplate.tpl.php');
echo $savant->render('<h2>Output Filtering</h2>');
$savant->addFilters('htmlspecialchars');
// Now show an entire template with htmlspecialchars
echo $savant->render($class);
// Ok, now remove the output filters
$savant->setFilters();
highlight_file(__FILE__);
Example #5
0
<?php

require_once dirname(__FILE__) . '/AutoloadPackage.php';
$savant = new \PEAR2\Templates\Savant\Main();
echo $savant->render('I did it. Do you think I\'ve gone too far?');