ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Backend.php
Go to the documentation of this file.
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4
5// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6
40// }}}
41
42// dependencies {{{
43require_once 'XML/RPC2/Exception.php';
44// }}}
45
70abstract class XML_RPC2_Backend
71{
72
73 // {{{ properties
74
80 protected static $currentBackend;
81
82 // }}}
83 // {{{ setBackend()
84
98 public static function setBackend($backend)
99 {
100 $backend = ucfirst(strtolower($backend));
101 if (
102 $backend != 'Php' &&
103 $backend != 'Xmlrpcext'
104 ) {
105 throw new XML_RPC2_Exception(sprintf('Backend %s does not exist', $backend));
106 }
107 if (
108 $backend == 'Xmlrpcext' &&
109 !function_exists('xmlrpc_server_create') &&
110 !( // TODO Use PEAR::loadExtension once PEAR passes PHP5 unit tests (E_STRICT compliance, namely)
111 @dl('php_xmlrpc' . PHP_SHLIB_SUFFIX) || @dl('xmlrpc' . PHP_SHLIB_SUFFIX)
112 )
113 ) {
114 throw new XML_RPC2_Exception('Unable to load xmlrpc extension.');
115 }
116 self::$currentBackend = $backend;
117 }
118
119 // }}}
120 // {{{ getBackend()
121
135 protected static function getBackend()
136 {
137 if (!isset(self::$currentBackend)) {
138 try {
139 self::setBackend('XMLRPCext'); // We prefer this one
140 } catch (XML_RPC2_Exception $e) {
141 // TODO According to PEAR CG logging should occur here
142 self::setBackend('php'); // But will settle with this one in case of error
143 }
144 }
146 }
147
148 // }}}
149 // {{{ getServerClassname()
150
157 public static function getServerClassname() {
158 require_once(sprintf('XML/RPC2/Backend/%s/Server.php', self::getBackend()));
159 return sprintf('XML_RPC2_Backend_%s_Server', self::getBackend());
160 }
161
162 // }}}
163 // {{{ getClientClassname()
164
171 public static function getClientClassname() {
172 require_once(sprintf('XML/RPC2/Backend/%s/Client.php', self::getBackend()));
173 return sprintf('XML_RPC2_Backend_%s_Client', self::getBackend());
174 }
175
176 // }}}
177 // {{{ getValueClassname()
178
185 public static function getValueClassname() {
186 require_once(sprintf('XML/RPC2/Backend/%s/Value.php', self::getBackend()));
187 return sprintf('XML_RPC2_Backend_%s_Value', self::getBackend());
188 }
189
190 // }}}
191
192}
static getServerClassname()
Include the relevant php files for the server class, and return the backend server class name.
Definition: Backend.php:157
static $currentBackend
Definition: Backend.php:80
static getClientClassname()
Include the relevant php files for the client class, and return the backend client class name.
Definition: Backend.php:171
static setBackend($backend)
Backend setter.
Definition: Backend.php:98
static getValueClassname()
Include the relevant php files for the value class, and return the backend value class name.
Definition: Backend.php:185
static getBackend()
Backend getter.
Definition: Backend.php:135