[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * dom_xmlrpc_domit_document wraps a DOMIT! 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_parser.php'); 17 require_once (DOM_XMLRPC_INCLUDE_PATH . 'dom_xmlrpc_constants.php'); 18 19 /** 20 * Wraps a DOMIT! 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_document extends DOMIT_Document { 26 27 /** 28 * Constructor: instantiates the DOMIT! superclass 29 */ 30 function dom_xmlrpc_domit_document() { 31 $this->DOMIT_Document(); 32 } //dom_xmlrpc_domit_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 70 //else throw exception 71 } //getParams 72 73 /** 74 * Gets a reference to the specified param 75 * @param int The index of the requested param 76 * @return object A reference to the specified param 77 */ 78 function &getParam($index) { 79 switch ($this->getMethodType()) { 80 case DOM_XMLRPC_TYPE_METHODCALL: 81 return $this->documentElement->childNodes[1]->childNodes[$index]; 82 break; 83 84 case DOM_XMLRPC_TYPE_METHODRESPONSE: 85 if (!$this->isFault()) { 86 return $this->documentElement->firstChild->childNodes[$index]; 87 } 88 break; 89 } 90 91 //else throw exception 92 } //getParam 93 94 /** 95 * Gets the number of existing params 96 * @return int The number of existing params 97 */ 98 function getParamCount() { 99 switch ($this->getMethodType()) { 100 case DOM_XMLRPC_TYPE_METHODCALL: 101 return $this->documentElement->childNodes[1]->childCount; 102 break; 103 104 case DOM_XMLRPC_TYPE_METHODRESPONSE: 105 if (!$this->isFault()) { 106 return $this->documentElement->firstChild->childCount; //either 0 or 1 107 } 108 break; 109 } 110 return -1; //maybe throw an exception? 111 } //getParamCount 112 113 /** 114 * Determines whether the method response is a fault 115 * @return boolean True if the method response is a fault 116 */ 117 function isFault() { 118 return ($this->documentElement->firstChild->nodeName == DOM_XMLRPC_TYPE_FAULT); 119 } //isFault 120 121 /** 122 * Returns the fault code, if a fault has occurred 123 * @return int The fault code, if a fault has occurred 124 */ 125 function getFaultCode() { 126 if ($this->isFault()) { 127 $faultStruct =& $this->documentElement->firstChild->firstChild->firstChild; 128 return ($faultStruct->childNodes[0]->childNodes[1]->firstChild->firstChild->nodeValue); 129 } 130 } //getFaultCode 131 132 /** 133 * Returns the fault string, if a fault has occurred 134 * @return string The fault string, if a fault has occurred 135 */ 136 function getFaultString() { 137 if ($this->isFault()) { 138 $faultStruct =& $this->documentElement->firstChild->firstChild->firstChild; 139 return ($faultStruct->childNodes[1]->childNodes[1]->firstChild->firstChild->nodeValue); 140 } 141 } //getFaultString 142 143 /** 144 * Returns the type of the specified param 145 * @param object A reference to the param to be tested for type 146 * @return string The type of the param 147 */ 148 function getParamType(&$node) { 149 switch ($node->nodeName) { 150 case DOM_XMLRPC_TYPE_PARAM: 151 return $node->firstChild->firstChild->nodeName; 152 break; 153 154 default: 155 //throw exception 156 } 157 } //getParamType 158 } //dom_xmlrpc_domit_document 159 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |