[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/includes/domit/ -> dom_xmlrpc_domit_lite_parser.php (source)

   1  <?php
   2  /**
   3  * dom_xmlrpc_domit_lite_document wraps a DOMIT! Lite DOM document in the DOM XML-RPC API
   4  * @package dom-xmlrpc
   5  * @copyright (C) 2004 John Heinstein. All rights reserved
   6  * @license http://www.gnu.org/copyleft/lesser.html LGPL License
   7  * @author John Heinstein <johnkarl@nbnet.nb.ca>
   8  * @link http://www.engageinteractive.com/dom_xmlrpc/ DOM XML-RPC Home Page
   9  * DOM XML-RPC is Free Software
  10  **/
  11  
  12  if (!defined('DOM_XMLRPC_INCLUDE_PATH')) {
  13      define('DOM_XMLRPC_INCLUDE_PATH', (dirname(__FILE__) . "/"));
  14  }
  15  
  16  require_once (DOM_XMLRPC_INCLUDE_PATH . 'xml_domit_lite_parser.php');
  17  require_once (DOM_XMLRPC_INCLUDE_PATH . 'dom_xmlrpc_constants.php');
  18  
  19  /**
  20  * Wraps a DOMIT_Lite DOM document in the DOM XML-RPC API
  21  *
  22  * @package dom-xmlrpc
  23  * @author John Heinstein <johnkarl@nbnet.nb.ca>
  24  */
  25  class dom_xmlrpc_domit_lite_document extends DOMIT_Lite_Document {
  26  
  27      /**
  28      * Constructor: instantiates the DOMIT! Lite superclass
  29      */
  30  	function dom_xmlrpc_domit_lite_document() {
  31          $this->DOMIT_Lite_Document();
  32      } //dom_xmlrpc_domit_lite_document
  33  
  34      /**
  35      * Gets the method type
  36      * @return string The method type
  37      */
  38  	function getMethodType() {
  39          return $this->documentElement->nodeName;
  40      } //getMethodType
  41  
  42      /**
  43      * Gets the method name
  44      * @return string The method name
  45      */
  46  	function getMethodName() {
  47          if ($this->getMethodType() == DOM_XMLRPC_TYPE_METHODCALL) {
  48              return $this->documentElement->childNodes[0]->firstChild->nodeValue;
  49          }
  50          //else throw exception
  51      } //getMethodName
  52  
  53      /**
  54      * Gets a reference to the method params node
  55      * @return object A reference to the method params node
  56      */
  57      function &getParams() {
  58          switch ($this->getMethodType()) {
  59              case DOM_XMLRPC_TYPE_METHODCALL:
  60                  return $this->documentElement->childNodes[1];
  61                  break;
  62  
  63              case DOM_XMLRPC_TYPE_METHODRESPONSE:
  64                  if (!$this->isFault()) {
  65                      return $this->documentElement->firstChild;
  66                  }
  67                  break;
  68          }
  69          //else throw exception
  70      } //getParams
  71  
  72      /**
  73      * Gets a reference to the specified param
  74      * @param int The index of the requested param
  75      * @return object A reference to the specified param
  76      */
  77      function &getParam($index) {
  78          switch ($this->getMethodType()) {
  79              case DOM_XMLRPC_TYPE_METHODCALL:
  80                  return $this->documentElement->childNodes[1]->childNodes[$index];
  81                  break;
  82  
  83              case DOM_XMLRPC_TYPE_METHODRESPONSE:
  84                  if (!$this->isFault()) {
  85                      return $this->documentElement->firstChild->childNodes[$index];
  86                  }
  87                  break;
  88          }
  89          //else throw exception
  90      } //getParam
  91  
  92      /**
  93      * Gets the number of existing params
  94      * @return int The number of existing params
  95      */
  96  	function getParamCount() {
  97          switch ($this->getMethodType()) {
  98              case DOM_XMLRPC_TYPE_METHODCALL:
  99                  return $this->documentElement->childNodes[1]->childCount;
 100                  break;
 101  
 102              case DOM_XMLRPC_TYPE_METHODRESPONSE:
 103                  if (!$this->isFault()) {
 104                      return $this->documentElement->firstChild->childCount; //either 0 or 1
 105                  }
 106                  break;
 107          }
 108          return -1; //maybe throw an exception?
 109      } //getParamCount
 110  
 111      /**
 112      * Determines whether the method response is a fault
 113      * @return boolean True if the method response is a fault
 114      */
 115  	function isFault() {
 116          return ($this->documentElement->firstChild->nodeName == DOM_XMLRPC_TYPE_FAULT);
 117      } //isFault
 118  
 119      /**
 120      * Returns the fault code, if a fault has occurred
 121      * @return int The fault code, if a fault has occurred
 122      */
 123  	function getFaultCode() {
 124          if ($this->isFault()) {
 125              $faultStruct =& $this->documentElement->firstChild->firstChild->firstChild;
 126              return ($faultStruct->childNodes[0]->childNodes[1]->firstChild->firstChild->nodeValue);
 127          }
 128      } //getFaultCode
 129  
 130      /**
 131      * Returns the fault string, if a fault has occurred
 132      * @return string The fault string, if a fault has occurred
 133      */
 134  	function getFaultString() {
 135          if ($this->isFault()) {
 136              $faultStruct =& $this->documentElement->firstChild->firstChild->firstChild;
 137              return ($faultStruct->childNodes[1]->childNodes[1]->firstChild->firstChild->nodeValue);
 138          }
 139      } //getFaultString
 140  
 141      /**
 142      * Returns the type of the specified param
 143      * @param object A reference to the param to be tested for type
 144      * @return string The type of the param
 145      */
 146  	function getParamType(&$node) {
 147          switch ($node->nodeName) {
 148              case DOM_XMLRPC_TYPE_PARAM:
 149                  return $node->firstChild->firstChild->nodeName;
 150                  break;
 151  
 152              default:
 153                  //throw exception
 154          }
 155      } //getParamType
 156  } //dom_xmlrpc_domit_lite_document
 157  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics