ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {{{
43 require_once 'XML/RPC2/Exception.php';
44 // }}}
45 
70 abstract 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  }
145  return self::$currentBackend;
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 }