<?php
/**
* SOAPView.class.php
*
* Subclass for the PhritzTpl class. Sets the template directory to the SOAP
* folder, formats the response and displays the result
*
* 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 SOAPView extends PhritzTpl implements PhritzViewInterface {
public function __construct() {
parent::__construct();
parent::setThemePath('templates'.DIR_SEP.'soap');
}
/**
* setThemePath()
*
* disallows changing the theme path for soap calls
*/
public function setThemePath($dir) {
return false;
}
public function formatResponse($request, $response) {
if ($response instanceof PhritzException) {
$this->assign('FAULT', 1);
$this->assign('ERROR', array('CODE'=>$response->getCode(),
'MESSAGE'=>$response->getMessage()));
} elseif ($response->getStatus() == 0) {
$this->assign('FAULT', 1);
$this->assign('ERROR', array('CODE'=>$response->getErrorCode(),
'MESSAGE'=>$response->getMessage()));
} else {
$this->assign('FAULT', 0);
$this->assign('RESPONSE', $response->toArray());
}
try {
$content = $this->fetch('soap_content.tpl');
$this->assign('CONTENT', $content);
} catch (PhritzException $e) {
$this->assign('FAULT', 1);
$this->assign('ERROR', array('CODE'=>$e->getCode(),
'MESSAGE'=>$e->getMessage()));
$content = $this->fetch('soap_content.tpl');
$this->assign('CONTENT', $content);
}
return;
}
public function display($tpl = '', $cacheid= '') {
echo $this->fetch('soap.tpl');
}
}
?>