Location: PHPKode > scripts > PHP-Loader > view/AJAXView.class.php
<?php
/**
 * WAPView.class.php
 *
 * Subclass for the PhritzTpl class. Sets the template directory to the WAP
 * folder, assigns the template file with a processing instruction in the XML
 * and displays the compiled XML string.
 *
 * LICENSE: This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * @package Phritz
 * @link http://phritz.fritz-works.com
 * @author Michael Collado <hide@address.com>
 * @copyright 2006
 * @version 0.0.1a
 **/
require_once 'PhritzTpl.class.php';

class AJAXView extends PhritzTpl {
 
    private $template;
    
    public function __construct() {
        parent::__construct();
        parent::setThemePath('templates'.DIR_SEP.'html'.DIR_SEP.'default');
    }
    
    public function setThemePath($dir) {
        return parent::setThemePath('templates'.DIR_SEP.'html'.DIR_SEP.$dir);
    }

    public function formatResponse($request, $response) {
        if ($response instanceof PhritzException) {
            $this->assign('FAULT', 1);
            $this->assign('ERROR', array('CODE'=>$response->getCode(),
                                    'MESSAGE'=>$response->getMessage()));
        } else {
            $this->assign('RESPONSE', $response->toArray());
            $this->template = $response->getTemplate();
        }
        $this->allow_xml_output(true);
        return;
    }
    
    public function display($tpl = '', $cacheid = '') {
        header('Content-type: text/xml');
        parent::display($this->template);
    }
}
?>
Return current item: PHP-Loader