<?php
/**
* RPCView.class.php
*
* Subclass for the PhritzTpl class. Sets the template directory to the RPC
* 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 RPCView extends PhritzTpl implements PhritzViewInterface {
public function __construct() {
parent::__construct();
parent::setThemePath('templates'.DIR_SEP.'rpc');
}
/**
* setThemePath()
*
* disallows changing the theme path for rpc 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);
$data = $response->toArray();
$co = count($data);
$keys = array_keys($data);
for ($x = 0; $x < $co; $x++) {
$type = XMLRPC_prepare($data[$keys[$x]]);
$this->append('RESPONSE', $type);
}
}
return;
}
public function display($tpl = '', $cacheid= '') {
echo $this->fetch('rpc.tpl');
}
}
?>