@@ -791,7 +791,7 @@ |
||
| 791 | 791 | * returns a sample serialization of a given type, or false if no type by the given name |
| 792 | 792 | * |
| 793 | 793 | * @param string $type name of type |
| 794 | - * @return mixed |
|
| 794 | + * @return string|false |
|
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
@@ -14,275 +14,275 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class nusoap_xmlschema extends nusoap_base {
|
| 16 | 16 | |
| 17 | - // files |
|
| 18 | - var $schema = ''; |
|
| 19 | - var $xml = ''; |
|
| 20 | - // namespaces |
|
| 21 | - var $enclosingNamespaces; |
|
| 22 | - // schema info |
|
| 23 | - var $schemaInfo = array(); |
|
| 24 | - var $schemaTargetNamespace = ''; |
|
| 25 | - // types, elements, attributes defined by the schema |
|
| 26 | - var $attributes = array(); |
|
| 27 | - var $complexTypes = array(); |
|
| 28 | - var $complexTypeStack = array(); |
|
| 29 | - var $currentComplexType = null; |
|
| 30 | - var $elements = array(); |
|
| 31 | - var $elementStack = array(); |
|
| 32 | - var $currentElement = null; |
|
| 33 | - var $simpleTypes = array(); |
|
| 34 | - var $simpleTypeStack = array(); |
|
| 35 | - var $currentSimpleType = null; |
|
| 36 | - // imports |
|
| 37 | - var $imports = array(); |
|
| 38 | - // parser vars |
|
| 39 | - var $parser; |
|
| 40 | - var $position = 0; |
|
| 41 | - var $depth = 0; |
|
| 42 | - var $depth_array = array(); |
|
| 43 | - var $message = array(); |
|
| 44 | - var $defaultNamespace = array(); |
|
| 17 | + // files |
|
| 18 | + var $schema = ''; |
|
| 19 | + var $xml = ''; |
|
| 20 | + // namespaces |
|
| 21 | + var $enclosingNamespaces; |
|
| 22 | + // schema info |
|
| 23 | + var $schemaInfo = array(); |
|
| 24 | + var $schemaTargetNamespace = ''; |
|
| 25 | + // types, elements, attributes defined by the schema |
|
| 26 | + var $attributes = array(); |
|
| 27 | + var $complexTypes = array(); |
|
| 28 | + var $complexTypeStack = array(); |
|
| 29 | + var $currentComplexType = null; |
|
| 30 | + var $elements = array(); |
|
| 31 | + var $elementStack = array(); |
|
| 32 | + var $currentElement = null; |
|
| 33 | + var $simpleTypes = array(); |
|
| 34 | + var $simpleTypeStack = array(); |
|
| 35 | + var $currentSimpleType = null; |
|
| 36 | + // imports |
|
| 37 | + var $imports = array(); |
|
| 38 | + // parser vars |
|
| 39 | + var $parser; |
|
| 40 | + var $position = 0; |
|
| 41 | + var $depth = 0; |
|
| 42 | + var $depth_array = array(); |
|
| 43 | + var $message = array(); |
|
| 44 | + var $defaultNamespace = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * constructor |
|
| 48 | - * |
|
| 49 | - * @param string $schema schema document URI |
|
| 50 | - * @param string $xml xml document URI |
|
| 51 | - * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | - * @access public |
|
| 53 | - */ |
|
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | - parent::nusoap_base(); |
|
| 56 | - $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | - // files |
|
| 58 | - $this->schema = $schema; |
|
| 59 | - $this->xml = $xml; |
|
| 46 | + /** |
|
| 47 | + * constructor |
|
| 48 | + * |
|
| 49 | + * @param string $schema schema document URI |
|
| 50 | + * @param string $xml xml document URI |
|
| 51 | + * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | + * @access public |
|
| 53 | + */ |
|
| 54 | + function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | + parent::nusoap_base(); |
|
| 56 | + $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | + // files |
|
| 58 | + $this->schema = $schema; |
|
| 59 | + $this->xml = $xml; |
|
| 60 | 60 | |
| 61 | - // namespaces |
|
| 62 | - $this->enclosingNamespaces = $namespaces; |
|
| 63 | - $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 61 | + // namespaces |
|
| 62 | + $this->enclosingNamespaces = $namespaces; |
|
| 63 | + $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 64 | 64 | |
| 65 | - // parse schema file |
|
| 66 | - if($schema != ''){
|
|
| 67 | - $this->debug('initial schema file: '.$schema);
|
|
| 68 | - $this->parseFile($schema, 'schema'); |
|
| 69 | - } |
|
| 65 | + // parse schema file |
|
| 66 | + if($schema != ''){
|
|
| 67 | + $this->debug('initial schema file: '.$schema);
|
|
| 68 | + $this->parseFile($schema, 'schema'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - // parse xml file |
|
| 72 | - if($xml != ''){
|
|
| 73 | - $this->debug('initial xml file: '.$xml);
|
|
| 74 | - $this->parseFile($xml, 'xml'); |
|
| 75 | - } |
|
| 71 | + // parse xml file |
|
| 72 | + if($xml != ''){
|
|
| 73 | + $this->debug('initial xml file: '.$xml);
|
|
| 74 | + $this->parseFile($xml, 'xml'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * parse an XML file |
|
| 81 | - * |
|
| 82 | - * @param string $xml path/URL to XML file |
|
| 83 | - * @param string $type (schema | xml) |
|
| 84 | - * @return boolean |
|
| 85 | - * @access public |
|
| 86 | - */ |
|
| 87 | - function parseFile($xml,$type){
|
|
| 88 | - // parse xml file |
|
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 92 | - $msg = 'Error reading XML from '.$xml; |
|
| 93 | - $this->setError($msg); |
|
| 94 | - $this->debug($msg); |
|
| 95 | - return false; |
|
| 96 | - } else {
|
|
| 97 | - $this->debug("parsing $xml");
|
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 99 | - $this->debug("done parsing $xml");
|
|
| 100 | - return true; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return false; |
|
| 104 | - } |
|
| 80 | + * parse an XML file |
|
| 81 | + * |
|
| 82 | + * @param string $xml path/URL to XML file |
|
| 83 | + * @param string $type (schema | xml) |
|
| 84 | + * @return boolean |
|
| 85 | + * @access public |
|
| 86 | + */ |
|
| 87 | + function parseFile($xml,$type){
|
|
| 88 | + // parse xml file |
|
| 89 | + if($xml != ""){
|
|
| 90 | + $xmlStr = @join("",@file($xml));
|
|
| 91 | + if($xmlStr == ""){
|
|
| 92 | + $msg = 'Error reading XML from '.$xml; |
|
| 93 | + $this->setError($msg); |
|
| 94 | + $this->debug($msg); |
|
| 95 | + return false; |
|
| 96 | + } else {
|
|
| 97 | + $this->debug("parsing $xml");
|
|
| 98 | + $this->parseString($xmlStr,$type); |
|
| 99 | + $this->debug("done parsing $xml");
|
|
| 100 | + return true; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * parse an XML string |
|
| 108 | - * |
|
| 109 | - * @param string $xml path or URL |
|
| 110 | - * @param string $type (schema|xml) |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 113 | - function parseString($xml,$type){
|
|
| 114 | - // parse xml string |
|
| 115 | - if($xml != ""){
|
|
| 106 | + /** |
|
| 107 | + * parse an XML string |
|
| 108 | + * |
|
| 109 | + * @param string $xml path or URL |
|
| 110 | + * @param string $type (schema|xml) |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | + function parseString($xml,$type){
|
|
| 114 | + // parse xml string |
|
| 115 | + if($xml != ""){
|
|
| 116 | 116 | |
| 117 | - // Create an XML parser. |
|
| 118 | - $this->parser = xml_parser_create(); |
|
| 119 | - // Set the options for parsing the XML data. |
|
| 120 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 117 | + // Create an XML parser. |
|
| 118 | + $this->parser = xml_parser_create(); |
|
| 119 | + // Set the options for parsing the XML data. |
|
| 120 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 121 | 121 | |
| 122 | - // Set the object for the parser. |
|
| 123 | - xml_set_object($this->parser, $this); |
|
| 122 | + // Set the object for the parser. |
|
| 123 | + xml_set_object($this->parser, $this); |
|
| 124 | 124 | |
| 125 | - // Set the element handlers for the parser. |
|
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | - } |
|
| 125 | + // Set the element handlers for the parser. |
|
| 126 | + if($type == "schema"){
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | + } elseif($type == "xml"){
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Parse the XML file. |
|
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | - // Display an error message. |
|
| 137 | - $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | - xml_get_current_line_number($this->parser), |
|
| 139 | - xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | - ); |
|
| 141 | - $this->debug($errstr); |
|
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 143 | - $this->setError($errstr); |
|
| 144 | - } |
|
| 134 | + // Parse the XML file. |
|
| 135 | + if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | + // Display an error message. |
|
| 137 | + $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | + xml_get_current_line_number($this->parser), |
|
| 139 | + xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | + ); |
|
| 141 | + $this->debug($errstr); |
|
| 142 | + $this->debug("XML payload:\n" . $xml);
|
|
| 143 | + $this->setError($errstr); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - xml_parser_free($this->parser); |
|
| 147 | - } else{
|
|
| 148 | - $this->debug('no xml passed to parseString()!!');
|
|
| 149 | - $this->setError('no xml passed to parseString()!!');
|
|
| 150 | - } |
|
| 151 | - } |
|
| 146 | + xml_parser_free($this->parser); |
|
| 147 | + } else{
|
|
| 148 | + $this->debug('no xml passed to parseString()!!');
|
|
| 149 | + $this->setError('no xml passed to parseString()!!');
|
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * gets a type name for an unnamed type |
|
| 155 | - * |
|
| 156 | - * @param string Element name |
|
| 157 | - * @return string A type name for an unnamed type |
|
| 158 | - * @access private |
|
| 159 | - */ |
|
| 160 | - function CreateTypeName($ename) {
|
|
| 161 | - $scope = ''; |
|
| 162 | - for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | - } |
|
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 166 | - } |
|
| 153 | + /** |
|
| 154 | + * gets a type name for an unnamed type |
|
| 155 | + * |
|
| 156 | + * @param string Element name |
|
| 157 | + * @return string A type name for an unnamed type |
|
| 158 | + * @access private |
|
| 159 | + */ |
|
| 160 | + function CreateTypeName($ename) {
|
|
| 161 | + $scope = ''; |
|
| 162 | + for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | + $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | + } |
|
| 165 | + return $scope . $ename . '_ContainedType'; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * start-element handler |
|
| 170 | - * |
|
| 171 | - * @param string $parser XML parser object |
|
| 172 | - * @param string $name element name |
|
| 173 | - * @param string $attrs associative array of attributes |
|
| 174 | - * @access private |
|
| 175 | - */ |
|
| 176 | - function schemaStartElement($parser, $name, $attrs) {
|
|
| 168 | + /** |
|
| 169 | + * start-element handler |
|
| 170 | + * |
|
| 171 | + * @param string $parser XML parser object |
|
| 172 | + * @param string $name element name |
|
| 173 | + * @param string $attrs associative array of attributes |
|
| 174 | + * @access private |
|
| 175 | + */ |
|
| 176 | + function schemaStartElement($parser, $name, $attrs) {
|
|
| 177 | 177 | |
| 178 | - // position in the total number of elements, starting from 0 |
|
| 179 | - $pos = $this->position++; |
|
| 180 | - $depth = $this->depth++; |
|
| 181 | - // set self as current value for this depth |
|
| 182 | - $this->depth_array[$depth] = $pos; |
|
| 183 | - $this->message[$pos] = array('cdata' => '');
|
|
| 184 | - if ($depth > 0) {
|
|
| 185 | - $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | - } else {
|
|
| 187 | - $this->defaultNamespace[$pos] = false; |
|
| 188 | - } |
|
| 178 | + // position in the total number of elements, starting from 0 |
|
| 179 | + $pos = $this->position++; |
|
| 180 | + $depth = $this->depth++; |
|
| 181 | + // set self as current value for this depth |
|
| 182 | + $this->depth_array[$depth] = $pos; |
|
| 183 | + $this->message[$pos] = array('cdata' => '');
|
|
| 184 | + if ($depth > 0) {
|
|
| 185 | + $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | + } else {
|
|
| 187 | + $this->defaultNamespace[$pos] = false; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - // get element prefix |
|
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 192 | - // get unqualified name |
|
| 193 | - $name = $this->getLocalPart($name); |
|
| 194 | - } else {
|
|
| 195 | - $prefix = ''; |
|
| 190 | + // get element prefix |
|
| 191 | + if($prefix = $this->getPrefix($name)){
|
|
| 192 | + // get unqualified name |
|
| 193 | + $name = $this->getLocalPart($name); |
|
| 194 | + } else {
|
|
| 195 | + $prefix = ''; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | 199 | if(count($attrs) > 0){
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 200 | + foreach($attrs as $k => $v){
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 203 | - //$this->xdebug("$k: $v");
|
|
| 204 | - //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | - //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | - $this->namespaces[$ns_prefix] = $v; |
|
| 208 | - } else {
|
|
| 209 | - $this->defaultNamespace[$pos] = $v; |
|
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | - $this->XMLSchemaVersion = $v; |
|
| 216 | - $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - foreach($attrs as $k => $v){
|
|
| 202 | + if(preg_match('/^xmlns/',$k)){
|
|
| 203 | + //$this->xdebug("$k: $v");
|
|
| 204 | + //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | + if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | + //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | + $this->namespaces[$ns_prefix] = $v; |
|
| 208 | + } else {
|
|
| 209 | + $this->defaultNamespace[$pos] = $v; |
|
| 210 | + if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | + $this->XMLSchemaVersion = $v; |
|
| 216 | + $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + foreach($attrs as $k => $v){
|
|
| 221 | 221 | // expand each attribute |
| 222 | 222 | $k = strpos($k,':') ? $this->expandQname($k) : $k; |
| 223 | 223 | $v = strpos($v,':') ? $this->expandQname($v) : $v; |
| 224 | - $eAttrs[$k] = $v; |
|
| 225 | - } |
|
| 226 | - $attrs = $eAttrs; |
|
| 224 | + $eAttrs[$k] = $v; |
|
| 225 | + } |
|
| 226 | + $attrs = $eAttrs; |
|
| 227 | 227 | } else {
|
| 228 | - $attrs = array(); |
|
| 228 | + $attrs = array(); |
|
| 229 | 229 | } |
| 230 | - // find status, register data |
|
| 231 | - switch($name){
|
|
| 232 | - case 'all': // (optional) compositor content for a complexType |
|
| 233 | - case 'choice': |
|
| 234 | - case 'group': |
|
| 235 | - case 'sequence': |
|
| 236 | - //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | - $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | - //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | - // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | - //} |
|
| 241 | - break; |
|
| 242 | - case 'attribute': // complexType attribute |
|
| 243 | - //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | - $this->xdebug("parsing attribute:");
|
|
| 245 | - $this->appendDebug($this->varDump($attrs)); |
|
| 246 | - if (!isset($attrs['form'])) {
|
|
| 247 | - // TODO: handle globals |
|
| 248 | - $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | - } |
|
| 250 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | - if (!strpos($v, ':')) {
|
|
| 253 | - // no namespace in arrayType attribute value... |
|
| 254 | - if ($this->defaultNamespace[$pos]) {
|
|
| 255 | - // ...so use the default |
|
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 230 | + // find status, register data |
|
| 231 | + switch($name){
|
|
| 232 | + case 'all': // (optional) compositor content for a complexType |
|
| 233 | + case 'choice': |
|
| 234 | + case 'group': |
|
| 235 | + case 'sequence': |
|
| 236 | + //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | + $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | + //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | + // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | + //} |
|
| 241 | + break; |
|
| 242 | + case 'attribute': // complexType attribute |
|
| 243 | + //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | + $this->xdebug("parsing attribute:");
|
|
| 245 | + $this->appendDebug($this->varDump($attrs)); |
|
| 246 | + if (!isset($attrs['form'])) {
|
|
| 247 | + // TODO: handle globals |
|
| 248 | + $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | + } |
|
| 250 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | + if (!strpos($v, ':')) {
|
|
| 253 | + // no namespace in arrayType attribute value... |
|
| 254 | + if ($this->defaultNamespace[$pos]) {
|
|
| 255 | + // ...so use the default |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | if(isset($attrs['name'])){
|
| 261 | - $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | - $aname = $attrs['name']; |
|
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | - } else {
|
|
| 267 | - $aname = ''; |
|
| 268 | - } |
|
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 270 | - $aname = $attrs['ref']; |
|
| 261 | + $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | + $aname = $attrs['name']; |
|
| 263 | + } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | + $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | + } else {
|
|
| 267 | + $aname = ''; |
|
| 268 | + } |
|
| 269 | + } elseif(isset($attrs['ref'])){
|
|
| 270 | + $aname = $attrs['ref']; |
|
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 275 | - $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | - } |
|
| 277 | - // arrayType attribute |
|
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | - $prefix = $this->getPrefix($aname); |
|
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | - } else {
|
|
| 284 | - $v = ''; |
|
| 285 | - } |
|
| 274 | + if($this->currentComplexType){ // This should *always* be
|
|
| 275 | + $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | + } |
|
| 277 | + // arrayType attribute |
|
| 278 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | + $prefix = $this->getPrefix($aname); |
|
| 281 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | + } else {
|
|
| 284 | + $v = ''; |
|
| 285 | + } |
|
| 286 | 286 | if(strpos($v,'[,]')){
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
@@ -291,676 +291,676 @@ discard block |
||
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
| 294 | - } |
|
| 295 | - break; |
|
| 296 | - case 'complexContent': // (optional) content for a complexType |
|
| 297 | - $this->xdebug("do nothing for element $name");
|
|
| 298 | - break; |
|
| 299 | - case 'complexType': |
|
| 300 | - array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | - if(isset($attrs['name'])){
|
|
| 302 | - // TODO: what is the scope of named complexTypes that appear |
|
| 303 | - // nested within other c complexTypes? |
|
| 304 | - $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | - //$this->currentElement = false; |
|
| 306 | - $this->currentComplexType = $attrs['name']; |
|
| 307 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | - // This is for constructs like |
|
| 310 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | - // <sequence> |
|
| 312 | - // <element name="string" type="xsd:string" |
|
| 313 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | - // </sequence> |
|
| 315 | - // </complexType> |
|
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | - $this->xdebug('complexType is unusual array');
|
|
| 318 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | - } else {
|
|
| 320 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | - } |
|
| 322 | - } else {
|
|
| 323 | - $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | - $this->currentComplexType = $name; |
|
| 326 | - //$this->currentElement = false; |
|
| 327 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | - // This is for constructs like |
|
| 330 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | - // <sequence> |
|
| 332 | - // <element name="string" type="xsd:string" |
|
| 333 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | - // </sequence> |
|
| 335 | - // </complexType> |
|
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | - $this->xdebug('complexType is unusual array');
|
|
| 338 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | - } else {
|
|
| 340 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | - break; |
|
| 345 | - case 'element': |
|
| 346 | - array_push($this->elementStack, $this->currentElement); |
|
| 347 | - if (!isset($attrs['form'])) {
|
|
| 348 | - if ($this->currentComplexType) {
|
|
| 349 | - $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | - } else {
|
|
| 351 | - // global |
|
| 352 | - $attrs['form'] = 'qualified'; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - if(isset($attrs['type'])){
|
|
| 356 | - $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | - if ($this->defaultNamespace[$pos]) {
|
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - // This is for constructs like |
|
| 364 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | - // <sequence> |
|
| 366 | - // <element name="string" type="xsd:string" |
|
| 367 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | - // </sequence> |
|
| 369 | - // </complexType> |
|
| 370 | - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | - $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | - } |
|
| 374 | - $this->currentElement = $attrs['name']; |
|
| 375 | - $ename = $attrs['name']; |
|
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 377 | - $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | - $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | - $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | - } else {
|
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | - $this->currentElement = $attrs['name']; |
|
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | - $ename = $attrs['name']; |
|
| 386 | - } |
|
| 387 | - if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | - $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | - $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | - } elseif (!isset($attrs['ref'])) {
|
|
| 391 | - $this->xdebug("add element $ename to elements array");
|
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | - } |
|
| 395 | - break; |
|
| 396 | - case 'enumeration': // restriction value list member |
|
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | - if ($this->currentSimpleType) {
|
|
| 399 | - $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | - } elseif ($this->currentComplexType) {
|
|
| 401 | - $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | - } |
|
| 403 | - break; |
|
| 404 | - case 'extension': // simpleContent or complexContent type extension |
|
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | - if ($this->currentComplexType) {
|
|
| 407 | - $ns = $this->getPrefix($attrs['base']); |
|
| 408 | - if ($ns == '') {
|
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | - } else {
|
|
| 411 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | - } |
|
| 413 | - } else {
|
|
| 414 | - $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | - } |
|
| 416 | - break; |
|
| 417 | - case 'import': |
|
| 418 | - if (isset($attrs['schemaLocation'])) {
|
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 294 | + } |
|
| 295 | + break; |
|
| 296 | + case 'complexContent': // (optional) content for a complexType |
|
| 297 | + $this->xdebug("do nothing for element $name");
|
|
| 298 | + break; |
|
| 299 | + case 'complexType': |
|
| 300 | + array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | + if(isset($attrs['name'])){
|
|
| 302 | + // TODO: what is the scope of named complexTypes that appear |
|
| 303 | + // nested within other c complexTypes? |
|
| 304 | + $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | + //$this->currentElement = false; |
|
| 306 | + $this->currentComplexType = $attrs['name']; |
|
| 307 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | + // This is for constructs like |
|
| 310 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | + // <sequence> |
|
| 312 | + // <element name="string" type="xsd:string" |
|
| 313 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | + // </sequence> |
|
| 315 | + // </complexType> |
|
| 316 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | + $this->xdebug('complexType is unusual array');
|
|
| 318 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | + } else {
|
|
| 320 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | + } |
|
| 322 | + } else {
|
|
| 323 | + $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | + $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | + $this->currentComplexType = $name; |
|
| 326 | + //$this->currentElement = false; |
|
| 327 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | + // This is for constructs like |
|
| 330 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | + // <sequence> |
|
| 332 | + // <element name="string" type="xsd:string" |
|
| 333 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | + // </sequence> |
|
| 335 | + // </complexType> |
|
| 336 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | + $this->xdebug('complexType is unusual array');
|
|
| 338 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | + } else {
|
|
| 340 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | + break; |
|
| 345 | + case 'element': |
|
| 346 | + array_push($this->elementStack, $this->currentElement); |
|
| 347 | + if (!isset($attrs['form'])) {
|
|
| 348 | + if ($this->currentComplexType) {
|
|
| 349 | + $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | + } else {
|
|
| 351 | + // global |
|
| 352 | + $attrs['form'] = 'qualified'; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + if(isset($attrs['type'])){
|
|
| 356 | + $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | + if ($this->defaultNamespace[$pos]) {
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + // This is for constructs like |
|
| 364 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | + // <sequence> |
|
| 366 | + // <element name="string" type="xsd:string" |
|
| 367 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | + // </sequence> |
|
| 369 | + // </complexType> |
|
| 370 | + if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | + $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | + $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | + } |
|
| 374 | + $this->currentElement = $attrs['name']; |
|
| 375 | + $ename = $attrs['name']; |
|
| 376 | + } elseif(isset($attrs['ref'])){
|
|
| 377 | + $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | + $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | + $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | + } else {
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | + $this->currentElement = $attrs['name']; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | + $ename = $attrs['name']; |
|
| 386 | + } |
|
| 387 | + if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | + $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | + $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | + } elseif (!isset($attrs['ref'])) {
|
|
| 391 | + $this->xdebug("add element $ename to elements array");
|
|
| 392 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | + } |
|
| 395 | + break; |
|
| 396 | + case 'enumeration': // restriction value list member |
|
| 397 | + $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | + if ($this->currentSimpleType) {
|
|
| 399 | + $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | + } elseif ($this->currentComplexType) {
|
|
| 401 | + $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | + } |
|
| 403 | + break; |
|
| 404 | + case 'extension': // simpleContent or complexContent type extension |
|
| 405 | + $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | + if ($this->currentComplexType) {
|
|
| 407 | + $ns = $this->getPrefix($attrs['base']); |
|
| 408 | + if ($ns == '') {
|
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | + } else {
|
|
| 411 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | + } |
|
| 413 | + } else {
|
|
| 414 | + $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | + } |
|
| 416 | + break; |
|
| 417 | + case 'import': |
|
| 418 | + if (isset($attrs['schemaLocation'])) {
|
|
| 419 | + $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | - } else {
|
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 421 | + } else {
|
|
| 422 | + $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - break; |
|
| 429 | - case 'include': |
|
| 430 | - if (isset($attrs['schemaLocation'])) {
|
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 424 | + if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + break; |
|
| 429 | + case 'include': |
|
| 430 | + if (isset($attrs['schemaLocation'])) {
|
|
| 431 | + $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | - } else {
|
|
| 434 | - $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | - } |
|
| 436 | - break; |
|
| 437 | - case 'list': // simpleType value list |
|
| 438 | - $this->xdebug("do nothing for element $name");
|
|
| 439 | - break; |
|
| 440 | - case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 443 | - $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | - } elseif($this->currentComplexType){
|
|
| 445 | - $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - break; |
|
| 451 | - case 'schema': |
|
| 452 | - $this->schemaInfo = $attrs; |
|
| 453 | - $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | - if (isset($attrs['targetNamespace'])) {
|
|
| 455 | - $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | - } |
|
| 457 | - if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | - $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | - } |
|
| 460 | - if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | - $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | - } |
|
| 463 | - break; |
|
| 464 | - case 'simpleContent': // (optional) content for a complexType |
|
| 465 | - if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | - } else {
|
|
| 468 | - $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | - } |
|
| 470 | - break; |
|
| 471 | - case 'simpleType': |
|
| 472 | - array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | - $this->currentSimpleType = $attrs['name']; |
|
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | - } else {
|
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | - $this->currentSimpleType = $name; |
|
| 483 | - //$this->currentElement = false; |
|
| 484 | - $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | - $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | - } |
|
| 487 | - break; |
|
| 488 | - case 'union': // simpleType type list |
|
| 489 | - $this->xdebug("do nothing for element $name");
|
|
| 490 | - break; |
|
| 491 | - default: |
|
| 492 | - $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | - } |
|
| 494 | - } |
|
| 433 | + } else {
|
|
| 434 | + $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | + } |
|
| 436 | + break; |
|
| 437 | + case 'list': // simpleType value list |
|
| 438 | + $this->xdebug("do nothing for element $name");
|
|
| 439 | + break; |
|
| 440 | + case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | + $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | + if($this->currentSimpleType){
|
|
| 443 | + $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | + } elseif($this->currentComplexType){
|
|
| 445 | + $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | + if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + break; |
|
| 451 | + case 'schema': |
|
| 452 | + $this->schemaInfo = $attrs; |
|
| 453 | + $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | + if (isset($attrs['targetNamespace'])) {
|
|
| 455 | + $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | + } |
|
| 457 | + if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | + $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | + } |
|
| 460 | + if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | + $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | + } |
|
| 463 | + break; |
|
| 464 | + case 'simpleContent': // (optional) content for a complexType |
|
| 465 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | + } else {
|
|
| 468 | + $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | + } |
|
| 470 | + break; |
|
| 471 | + case 'simpleType': |
|
| 472 | + array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | + if(isset($attrs['name'])){
|
|
| 474 | + $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | + $this->currentSimpleType = $attrs['name']; |
|
| 476 | + $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | + $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | + } else {
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | + $this->currentSimpleType = $name; |
|
| 483 | + //$this->currentElement = false; |
|
| 484 | + $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | + $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | + } |
|
| 487 | + break; |
|
| 488 | + case 'union': // simpleType type list |
|
| 489 | + $this->xdebug("do nothing for element $name");
|
|
| 490 | + break; |
|
| 491 | + default: |
|
| 492 | + $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * end-element handler |
|
| 498 | - * |
|
| 499 | - * @param string $parser XML parser object |
|
| 500 | - * @param string $name element name |
|
| 501 | - * @access private |
|
| 502 | - */ |
|
| 503 | - function schemaEndElement($parser, $name) {
|
|
| 504 | - // bring depth down a notch |
|
| 505 | - $this->depth--; |
|
| 506 | - // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 508 | - $pos = $this->depth_array[$this->depth]; |
|
| 496 | + /** |
|
| 497 | + * end-element handler |
|
| 498 | + * |
|
| 499 | + * @param string $parser XML parser object |
|
| 500 | + * @param string $name element name |
|
| 501 | + * @access private |
|
| 502 | + */ |
|
| 503 | + function schemaEndElement($parser, $name) {
|
|
| 504 | + // bring depth down a notch |
|
| 505 | + $this->depth--; |
|
| 506 | + // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | + if(isset($this->depth_array[$this->depth])){
|
|
| 508 | + $pos = $this->depth_array[$this->depth]; |
|
| 509 | + } |
|
| 510 | + // get element prefix |
|
| 511 | + if ($prefix = $this->getPrefix($name)){
|
|
| 512 | + // get unqualified name |
|
| 513 | + $name = $this->getLocalPart($name); |
|
| 514 | + } else {
|
|
| 515 | + $prefix = ''; |
|
| 516 | + } |
|
| 517 | + // move on... |
|
| 518 | + if($name == 'complexType'){
|
|
| 519 | + $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | + $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | + $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | + //$this->currentElement = false; |
|
| 509 | 523 | } |
| 510 | - // get element prefix |
|
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 512 | - // get unqualified name |
|
| 513 | - $name = $this->getLocalPart($name); |
|
| 514 | - } else {
|
|
| 515 | - $prefix = ''; |
|
| 524 | + if($name == 'element'){
|
|
| 525 | + $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | + $this->currentElement = array_pop($this->elementStack); |
|
| 516 | 527 | } |
| 517 | - // move on... |
|
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | - $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | - $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | - //$this->currentElement = false; |
|
| 523 | - } |
|
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | - $this->currentElement = array_pop($this->elementStack); |
|
| 527 | - } |
|
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | - $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | - $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | - } |
|
| 533 | - } |
|
| 528 | + if($name == 'simpleType'){
|
|
| 529 | + $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | + $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | + $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | + } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * element content handler |
|
| 537 | - * |
|
| 538 | - * @param string $parser XML parser object |
|
| 539 | - * @param string $data element content |
|
| 540 | - * @access private |
|
| 541 | - */ |
|
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 543 | - $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | - $this->message[$pos]['cdata'] .= $data; |
|
| 545 | - } |
|
| 535 | + /** |
|
| 536 | + * element content handler |
|
| 537 | + * |
|
| 538 | + * @param string $parser XML parser object |
|
| 539 | + * @param string $data element content |
|
| 540 | + * @access private |
|
| 541 | + */ |
|
| 542 | + function schemaCharacterData($parser, $data){
|
|
| 543 | + $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | + $this->message[$pos]['cdata'] .= $data; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * serialize the schema |
|
| 549 | - * |
|
| 550 | - * @access public |
|
| 551 | - */ |
|
| 552 | - function serializeSchema(){
|
|
| 547 | + /** |
|
| 548 | + * serialize the schema |
|
| 549 | + * |
|
| 550 | + * @access public |
|
| 551 | + */ |
|
| 552 | + function serializeSchema(){
|
|
| 553 | 553 | |
| 554 | - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | - $xml = ''; |
|
| 556 | - // imports |
|
| 557 | - if (sizeof($this->imports) > 0) {
|
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 559 | - foreach ($list as $ii) {
|
|
| 560 | - if ($ii['location'] != '') {
|
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | - } else {
|
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - } |
|
| 568 | - // complex types |
|
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | - $contentStr = ''; |
|
| 571 | - // serialize child elements |
|
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 575 | - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | - } else {
|
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | - foreach ($eParts as $aName => $aValue) {
|
|
| 579 | - // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | - if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | - $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $contentStr .= "/>\n"; |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - // compositor wraps elements |
|
| 588 | - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | - $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | - } |
|
| 591 | - } |
|
| 592 | - // attributes |
|
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | - $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | - foreach ($aParts as $a => $v) {
|
|
| 597 | - if ($a == 'ref' || $a == 'type') {
|
|
| 598 | - $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | - $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | - $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | - } else {
|
|
| 603 | - $contentStr .= " $a=\"$v\""; |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - $contentStr .= "/>\n"; |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - // if restriction |
|
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | - $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | - // complex or simple content |
|
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | - $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - // finalize complex type |
|
| 618 | - if($contentStr != ''){
|
|
| 619 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | - } else {
|
|
| 621 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | - } |
|
| 623 | - $xml .= $contentStr; |
|
| 624 | - } |
|
| 625 | - // simple types |
|
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | - $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | - if (isset($eParts['enumeration'])) {
|
|
| 630 | - foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - // elements |
|
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 640 | - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - // attributes |
|
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 646 | - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - // finish 'er up |
|
| 650 | - $attr = ''; |
|
| 651 | - foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | - $attr .= " $k=\"$v\""; |
|
| 654 | - } |
|
| 655 | - } |
|
| 656 | - $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | - foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | - $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | - } |
|
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | - return $xml; |
|
| 662 | - } |
|
| 554 | + $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | + $xml = ''; |
|
| 556 | + // imports |
|
| 557 | + if (sizeof($this->imports) > 0) {
|
|
| 558 | + foreach($this->imports as $ns => $list) {
|
|
| 559 | + foreach ($list as $ii) {
|
|
| 560 | + if ($ii['location'] != '') {
|
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | + } else {
|
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + // complex types |
|
| 569 | + foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | + $contentStr = ''; |
|
| 571 | + // serialize child elements |
|
| 572 | + if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | + foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | + if(isset($eParts['ref'])){
|
|
| 575 | + $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | + } else {
|
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | + foreach ($eParts as $aName => $aValue) {
|
|
| 579 | + // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | + if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | + $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $contentStr .= "/>\n"; |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + // compositor wraps elements |
|
| 588 | + if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | + $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | + // attributes |
|
| 593 | + if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | + foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | + $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | + foreach ($aParts as $a => $v) {
|
|
| 597 | + if ($a == 'ref' || $a == 'type') {
|
|
| 598 | + $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | + } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | + $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | + $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | + } else {
|
|
| 603 | + $contentStr .= " $a=\"$v\""; |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + $contentStr .= "/>\n"; |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + // if restriction |
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | + $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | + // complex or simple content |
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | + $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + // finalize complex type |
|
| 618 | + if($contentStr != ''){
|
|
| 619 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | + } else {
|
|
| 621 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | + } |
|
| 623 | + $xml .= $contentStr; |
|
| 624 | + } |
|
| 625 | + // simple types |
|
| 626 | + if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | + foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | + $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | + if (isset($eParts['enumeration'])) {
|
|
| 630 | + foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | + $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + // elements |
|
| 638 | + if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | + foreach($this->elements as $element => $eParts){
|
|
| 640 | + $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + // attributes |
|
| 644 | + if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | + foreach($this->attributes as $attr => $aParts){
|
|
| 646 | + $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + // finish 'er up |
|
| 650 | + $attr = ''; |
|
| 651 | + foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | + if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | + $attr .= " $k=\"$v\""; |
|
| 654 | + } |
|
| 655 | + } |
|
| 656 | + $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | + foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | + $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | + } |
|
| 660 | + $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | + return $xml; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - /** |
|
| 665 | - * adds debug data to the clas level debug string |
|
| 666 | - * |
|
| 667 | - * @param string $string debug data |
|
| 668 | - * @access private |
|
| 669 | - */ |
|
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | - } |
|
| 664 | + /** |
|
| 665 | + * adds debug data to the clas level debug string |
|
| 666 | + * |
|
| 667 | + * @param string $string debug data |
|
| 668 | + * @access private |
|
| 669 | + */ |
|
| 670 | + function xdebug($string){
|
|
| 671 | + $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | - * get the PHP type of a user defined type in the schema |
|
| 676 | - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | - * returns false if no type exists, or not w/ the given namespace |
|
| 678 | - * else returns a string that is either a native php type, or 'struct' |
|
| 679 | - * |
|
| 680 | - * @param string $type name of defined type |
|
| 681 | - * @param string $ns namespace of type |
|
| 682 | - * @return mixed |
|
| 683 | - * @access public |
|
| 684 | - * @deprecated |
|
| 685 | - */ |
|
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 688 | - //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | - return $this->typemap[$ns][$type]; |
|
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | - //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | - return $this->complexTypes[$type]['phpType']; |
|
| 693 | - } |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 675 | + * get the PHP type of a user defined type in the schema |
|
| 676 | + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | + * returns false if no type exists, or not w/ the given namespace |
|
| 678 | + * else returns a string that is either a native php type, or 'struct' |
|
| 679 | + * |
|
| 680 | + * @param string $type name of defined type |
|
| 681 | + * @param string $ns namespace of type |
|
| 682 | + * @return mixed |
|
| 683 | + * @access public |
|
| 684 | + * @deprecated |
|
| 685 | + */ |
|
| 686 | + function getPHPType($type,$ns){
|
|
| 687 | + if(isset($this->typemap[$ns][$type])){
|
|
| 688 | + //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | + return $this->typemap[$ns][$type]; |
|
| 690 | + } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | + //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | + return $this->complexTypes[$type]['phpType']; |
|
| 693 | + } |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - /** |
|
| 698 | - * returns an associative array of information about a given type |
|
| 699 | - * returns false if no type exists by the given name |
|
| 700 | - * |
|
| 701 | - * For a complexType typeDef = array( |
|
| 702 | - * 'restrictionBase' => '', |
|
| 703 | - * 'phpType' => '', |
|
| 704 | - * 'compositor' => '(sequence|all)', |
|
| 705 | - * 'elements' => array(), // refs to elements array |
|
| 706 | - * 'attrs' => array() // refs to attributes array |
|
| 707 | - * ... and so on (see addComplexType) |
|
| 708 | - * ) |
|
| 709 | - * |
|
| 710 | - * For simpleType or element, the array has different keys. |
|
| 711 | - * |
|
| 712 | - * @param string $type |
|
| 713 | - * @return mixed |
|
| 714 | - * @access public |
|
| 715 | - * @see addComplexType |
|
| 716 | - * @see addSimpleType |
|
| 717 | - * @see addElement |
|
| 718 | - */ |
|
| 719 | - function getTypeDef($type){
|
|
| 720 | - //$this->debug("in getTypeDef for type $type");
|
|
| 721 | - if (substr($type, -1) == '^') {
|
|
| 722 | - $is_element = 1; |
|
| 723 | - $type = substr($type, 0, -1); |
|
| 724 | - } else {
|
|
| 725 | - $is_element = 0; |
|
| 726 | - } |
|
| 697 | + /** |
|
| 698 | + * returns an associative array of information about a given type |
|
| 699 | + * returns false if no type exists by the given name |
|
| 700 | + * |
|
| 701 | + * For a complexType typeDef = array( |
|
| 702 | + * 'restrictionBase' => '', |
|
| 703 | + * 'phpType' => '', |
|
| 704 | + * 'compositor' => '(sequence|all)', |
|
| 705 | + * 'elements' => array(), // refs to elements array |
|
| 706 | + * 'attrs' => array() // refs to attributes array |
|
| 707 | + * ... and so on (see addComplexType) |
|
| 708 | + * ) |
|
| 709 | + * |
|
| 710 | + * For simpleType or element, the array has different keys. |
|
| 711 | + * |
|
| 712 | + * @param string $type |
|
| 713 | + * @return mixed |
|
| 714 | + * @access public |
|
| 715 | + * @see addComplexType |
|
| 716 | + * @see addSimpleType |
|
| 717 | + * @see addElement |
|
| 718 | + */ |
|
| 719 | + function getTypeDef($type){
|
|
| 720 | + //$this->debug("in getTypeDef for type $type");
|
|
| 721 | + if (substr($type, -1) == '^') {
|
|
| 722 | + $is_element = 1; |
|
| 723 | + $type = substr($type, 0, -1); |
|
| 724 | + } else {
|
|
| 725 | + $is_element = 0; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | - $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | - return $this->complexTypes[$type]; |
|
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | - $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | - if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | - // get info for type to tack onto the simple type |
|
| 735 | - // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | - $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | - $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | - $etype = $this->getTypeDef($uqType); |
|
| 739 | - if ($etype) {
|
|
| 740 | - $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | - $this->xdebug($this->varDump($etype)); |
|
| 742 | - if (isset($etype['phpType'])) {
|
|
| 743 | - $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | - } |
|
| 745 | - if (isset($etype['elements'])) {
|
|
| 746 | - $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - return $this->simpleTypes[$type]; |
|
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 752 | - $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | - if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | - // get info for type to tack onto the element |
|
| 755 | - $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | - $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | - $etype = $this->getTypeDef($uqType); |
|
| 758 | - if ($etype) {
|
|
| 759 | - $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | - $this->xdebug($this->varDump($etype)); |
|
| 761 | - if (isset($etype['phpType'])) {
|
|
| 762 | - $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | - } |
|
| 764 | - if (isset($etype['elements'])) {
|
|
| 765 | - $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | - } |
|
| 767 | - if (isset($etype['extensionBase'])) {
|
|
| 768 | - $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | - } |
|
| 770 | - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | - $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | - $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - return $this->elements[$type]; |
|
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 777 | - $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | - return $this->attributes[$type]; |
|
| 779 | - } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | - $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | - $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | - $typeDef['phpType'] = 'scalar'; |
|
| 783 | - $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | - return $typeDef; |
|
| 785 | - } |
|
| 786 | - $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | - return false; |
|
| 788 | - } |
|
| 728 | + if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | + $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | + return $this->complexTypes[$type]; |
|
| 731 | + } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | + $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | + if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | + // get info for type to tack onto the simple type |
|
| 735 | + // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | + $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | + $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | + $etype = $this->getTypeDef($uqType); |
|
| 739 | + if ($etype) {
|
|
| 740 | + $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | + $this->xdebug($this->varDump($etype)); |
|
| 742 | + if (isset($etype['phpType'])) {
|
|
| 743 | + $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | + } |
|
| 745 | + if (isset($etype['elements'])) {
|
|
| 746 | + $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + return $this->simpleTypes[$type]; |
|
| 751 | + } elseif(isset($this->elements[$type])){
|
|
| 752 | + $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | + if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | + // get info for type to tack onto the element |
|
| 755 | + $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | + $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | + $etype = $this->getTypeDef($uqType); |
|
| 758 | + if ($etype) {
|
|
| 759 | + $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | + $this->xdebug($this->varDump($etype)); |
|
| 761 | + if (isset($etype['phpType'])) {
|
|
| 762 | + $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | + } |
|
| 764 | + if (isset($etype['elements'])) {
|
|
| 765 | + $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | + } |
|
| 767 | + if (isset($etype['extensionBase'])) {
|
|
| 768 | + $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | + } |
|
| 770 | + } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | + $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | + $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + return $this->elements[$type]; |
|
| 776 | + } elseif(isset($this->attributes[$type])){
|
|
| 777 | + $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | + return $this->attributes[$type]; |
|
| 779 | + } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | + $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | + $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | + $typeDef['phpType'] = 'scalar'; |
|
| 783 | + $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | + return $typeDef; |
|
| 785 | + } |
|
| 786 | + $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | + return false; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - /** |
|
| 791 | - * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | - * |
|
| 793 | - * @param string $type name of type |
|
| 794 | - * @return mixed |
|
| 795 | - * @access public |
|
| 796 | - * @deprecated |
|
| 797 | - */ |
|
| 790 | + /** |
|
| 791 | + * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | + * |
|
| 793 | + * @param string $type name of type |
|
| 794 | + * @return mixed |
|
| 795 | + * @access public |
|
| 796 | + * @deprecated |
|
| 797 | + */ |
|
| 798 | 798 | function serializeTypeDef($type){
|
| 799 | - //print "in sTD() for type $type<br>"; |
|
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | - $str .= '<'.$type; |
|
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | - $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 809 | - $str .= ">"; |
|
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | - $str .= $this->serializeTypeDef($element); |
|
| 812 | - } |
|
| 813 | - $str .= "</$type>"; |
|
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | - $str .= "></$type>"; |
|
| 816 | - } else {
|
|
| 817 | - $str .= "/>"; |
|
| 818 | - } |
|
| 819 | - return $str; |
|
| 820 | - } |
|
| 821 | - return false; |
|
| 799 | + //print "in sTD() for type $type<br>"; |
|
| 800 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | + $str .= '<'.$type; |
|
| 802 | + if(is_array($typeDef['attrs'])){
|
|
| 803 | + foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | + $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | + if(count($typeDef['elements']) > 0){
|
|
| 809 | + $str .= ">"; |
|
| 810 | + foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | + $str .= $this->serializeTypeDef($element); |
|
| 812 | + } |
|
| 813 | + $str .= "</$type>"; |
|
| 814 | + } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | + $str .= "></$type>"; |
|
| 816 | + } else {
|
|
| 817 | + $str .= "/>"; |
|
| 818 | + } |
|
| 819 | + return $str; |
|
| 820 | + } |
|
| 821 | + return false; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | - * returns HTML form elements that allow a user |
|
| 826 | - * to enter values for creating an instance of the given type. |
|
| 827 | - * |
|
| 828 | - * @param string $name name for type instance |
|
| 829 | - * @param string $type name of type |
|
| 830 | - * @return string |
|
| 831 | - * @access public |
|
| 832 | - * @deprecated |
|
| 833 | - */ |
|
| 834 | - function typeToForm($name,$type){
|
|
| 835 | - // get typedef |
|
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | - // if struct |
|
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 839 | - $buffer .= '<table>'; |
|
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | - $buffer .= " |
|
| 825 | + * returns HTML form elements that allow a user |
|
| 826 | + * to enter values for creating an instance of the given type. |
|
| 827 | + * |
|
| 828 | + * @param string $name name for type instance |
|
| 829 | + * @param string $type name of type |
|
| 830 | + * @return string |
|
| 831 | + * @access public |
|
| 832 | + * @deprecated |
|
| 833 | + */ |
|
| 834 | + function typeToForm($name,$type){
|
|
| 835 | + // get typedef |
|
| 836 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | + // if struct |
|
| 838 | + if($typeDef['phpType'] == 'struct'){
|
|
| 839 | + $buffer .= '<table>'; |
|
| 840 | + foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | + $buffer .= " |
|
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | - } |
|
| 845 | - $buffer .= '</table>'; |
|
| 846 | - // if array |
|
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | - $buffer .= '<table>'; |
|
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 850 | - $buffer .= " |
|
| 844 | + } |
|
| 845 | + $buffer .= '</table>'; |
|
| 846 | + // if array |
|
| 847 | + } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | + $buffer .= '<table>'; |
|
| 849 | + for($i=0;$i < 3; $i++){
|
|
| 850 | + $buffer .= " |
|
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
| 853 | - } |
|
| 854 | - $buffer .= '</table>'; |
|
| 855 | - // if scalar |
|
| 856 | - } else {
|
|
| 857 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | - } |
|
| 859 | - } else {
|
|
| 860 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | - } |
|
| 862 | - return $buffer; |
|
| 863 | - } |
|
| 853 | + } |
|
| 854 | + $buffer .= '</table>'; |
|
| 855 | + // if scalar |
|
| 856 | + } else {
|
|
| 857 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | + } |
|
| 859 | + } else {
|
|
| 860 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | + } |
|
| 862 | + return $buffer; |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * adds a complex type to the schema |
|
| 867 | - * |
|
| 868 | - * example: array |
|
| 869 | - * |
|
| 870 | - * addType( |
|
| 871 | - * 'ArrayOfstring', |
|
| 872 | - * 'complexType', |
|
| 873 | - * 'array', |
|
| 874 | - * '', |
|
| 875 | - * 'SOAP-ENC:Array', |
|
| 876 | - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | - * 'xsd:string' |
|
| 878 | - * ); |
|
| 879 | - * |
|
| 880 | - * example: PHP associative array ( SOAP Struct ) |
|
| 881 | - * |
|
| 882 | - * addType( |
|
| 883 | - * 'SOAPStruct', |
|
| 884 | - * 'complexType', |
|
| 885 | - * 'struct', |
|
| 886 | - * 'all', |
|
| 887 | - * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | - * ); |
|
| 889 | - * |
|
| 890 | - * @param name |
|
| 891 | - * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | - * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | - * @param compositor (all|sequence|choice) |
|
| 894 | - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | - * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | - * @param attrs = array( |
|
| 897 | - * array( |
|
| 898 | - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | - * ) |
|
| 901 | - * ) |
|
| 902 | - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | - * @access public |
|
| 904 | - * @see getTypeDef |
|
| 905 | - */ |
|
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | - $this->complexTypes[$name] = array( |
|
| 908 | - 'name' => $name, |
|
| 909 | - 'typeClass' => $typeClass, |
|
| 910 | - 'phpType' => $phpType, |
|
| 911 | - 'compositor'=> $compositor, |
|
| 912 | - 'restrictionBase' => $restrictionBase, |
|
| 913 | - 'elements' => $elements, |
|
| 914 | - 'attrs' => $attrs, |
|
| 915 | - 'arrayType' => $arrayType |
|
| 916 | - ); |
|
| 865 | + /** |
|
| 866 | + * adds a complex type to the schema |
|
| 867 | + * |
|
| 868 | + * example: array |
|
| 869 | + * |
|
| 870 | + * addType( |
|
| 871 | + * 'ArrayOfstring', |
|
| 872 | + * 'complexType', |
|
| 873 | + * 'array', |
|
| 874 | + * '', |
|
| 875 | + * 'SOAP-ENC:Array', |
|
| 876 | + * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | + * 'xsd:string' |
|
| 878 | + * ); |
|
| 879 | + * |
|
| 880 | + * example: PHP associative array ( SOAP Struct ) |
|
| 881 | + * |
|
| 882 | + * addType( |
|
| 883 | + * 'SOAPStruct', |
|
| 884 | + * 'complexType', |
|
| 885 | + * 'struct', |
|
| 886 | + * 'all', |
|
| 887 | + * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | + * ); |
|
| 889 | + * |
|
| 890 | + * @param name |
|
| 891 | + * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | + * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | + * @param compositor (all|sequence|choice) |
|
| 894 | + * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | + * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | + * @param attrs = array( |
|
| 897 | + * array( |
|
| 898 | + * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | + * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | + * ) |
|
| 901 | + * ) |
|
| 902 | + * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | + * @access public |
|
| 904 | + * @see getTypeDef |
|
| 905 | + */ |
|
| 906 | + function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | + $this->complexTypes[$name] = array( |
|
| 908 | + 'name' => $name, |
|
| 909 | + 'typeClass' => $typeClass, |
|
| 910 | + 'phpType' => $phpType, |
|
| 911 | + 'compositor'=> $compositor, |
|
| 912 | + 'restrictionBase' => $restrictionBase, |
|
| 913 | + 'elements' => $elements, |
|
| 914 | + 'attrs' => $attrs, |
|
| 915 | + 'arrayType' => $arrayType |
|
| 916 | + ); |
|
| 917 | 917 | |
| 918 | - $this->xdebug("addComplexType $name:");
|
|
| 919 | - $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | - } |
|
| 918 | + $this->xdebug("addComplexType $name:");
|
|
| 919 | + $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - /** |
|
| 923 | - * adds a simple type to the schema |
|
| 924 | - * |
|
| 925 | - * @param string $name |
|
| 926 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | - * @param string $typeClass (should always be simpleType) |
|
| 928 | - * @param string $phpType (should always be scalar) |
|
| 929 | - * @param array $enumeration array of values |
|
| 930 | - * @access public |
|
| 931 | - * @see nusoap_xmlschema |
|
| 932 | - * @see getTypeDef |
|
| 933 | - */ |
|
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | - $this->simpleTypes[$name] = array( |
|
| 936 | - 'name' => $name, |
|
| 937 | - 'typeClass' => $typeClass, |
|
| 938 | - 'phpType' => $phpType, |
|
| 939 | - 'type' => $restrictionBase, |
|
| 940 | - 'enumeration' => $enumeration |
|
| 941 | - ); |
|
| 922 | + /** |
|
| 923 | + * adds a simple type to the schema |
|
| 924 | + * |
|
| 925 | + * @param string $name |
|
| 926 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | + * @param string $typeClass (should always be simpleType) |
|
| 928 | + * @param string $phpType (should always be scalar) |
|
| 929 | + * @param array $enumeration array of values |
|
| 930 | + * @access public |
|
| 931 | + * @see nusoap_xmlschema |
|
| 932 | + * @see getTypeDef |
|
| 933 | + */ |
|
| 934 | + function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | + $this->simpleTypes[$name] = array( |
|
| 936 | + 'name' => $name, |
|
| 937 | + 'typeClass' => $typeClass, |
|
| 938 | + 'phpType' => $phpType, |
|
| 939 | + 'type' => $restrictionBase, |
|
| 940 | + 'enumeration' => $enumeration |
|
| 941 | + ); |
|
| 942 | 942 | |
| 943 | - $this->xdebug("addSimpleType $name:");
|
|
| 944 | - $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | - } |
|
| 943 | + $this->xdebug("addSimpleType $name:");
|
|
| 944 | + $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - /** |
|
| 948 | - * adds an element to the schema |
|
| 949 | - * |
|
| 950 | - * @param array $attrs attributes that must include name and type |
|
| 951 | - * @see nusoap_xmlschema |
|
| 952 | - * @access public |
|
| 953 | - */ |
|
| 954 | - function addElement($attrs) {
|
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | - } |
|
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 947 | + /** |
|
| 948 | + * adds an element to the schema |
|
| 949 | + * |
|
| 950 | + * @param array $attrs attributes that must include name and type |
|
| 951 | + * @see nusoap_xmlschema |
|
| 952 | + * @access public |
|
| 953 | + */ |
|
| 954 | + function addElement($attrs) {
|
|
| 955 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | + } |
|
| 958 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | - } |
|
| 961 | + $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | + } |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @version $Id: class.xmlschema.php,v 1.53 2010/04/26 20:15:08 snichol Exp $ |
| 13 | 13 | * @access public |
| 14 | 14 | */ |
| 15 | -class nusoap_xmlschema extends nusoap_base {
|
|
| 15 | +class nusoap_xmlschema extends nusoap_base {
|
|
| 16 | 16 | |
| 17 | 17 | // files |
| 18 | 18 | var $schema = ''; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string $namespaces namespaces defined in enclosing XML |
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 54 | + function nusoap_xmlschema($schema = '', $xml = '', $namespaces = array()) {
|
|
| 55 | 55 | parent::nusoap_base(); |
| 56 | 56 | $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
| 57 | 57 | // files |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | $this->namespaces = array_merge($this->namespaces, $namespaces); |
| 64 | 64 | |
| 65 | 65 | // parse schema file |
| 66 | - if($schema != ''){
|
|
| 66 | + if ($schema != '') {
|
|
| 67 | 67 | $this->debug('initial schema file: '.$schema);
|
| 68 | 68 | $this->parseFile($schema, 'schema'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // parse xml file |
| 72 | - if($xml != ''){
|
|
| 72 | + if ($xml != '') {
|
|
| 73 | 73 | $this->debug('initial xml file: '.$xml);
|
| 74 | 74 | $this->parseFile($xml, 'xml'); |
| 75 | 75 | } |
@@ -84,18 +84,18 @@ discard block |
||
| 84 | 84 | * @return boolean |
| 85 | 85 | * @access public |
| 86 | 86 | */ |
| 87 | - function parseFile($xml,$type){
|
|
| 87 | + function parseFile($xml, $type) {
|
|
| 88 | 88 | // parse xml file |
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 89 | + if ($xml != "") {
|
|
| 90 | + $xmlStr = @join("", @file($xml));
|
|
| 91 | + if ($xmlStr == "") {
|
|
| 92 | 92 | $msg = 'Error reading XML from '.$xml; |
| 93 | 93 | $this->setError($msg); |
| 94 | 94 | $this->debug($msg); |
| 95 | 95 | return false; |
| 96 | 96 | } else {
|
| 97 | 97 | $this->debug("parsing $xml");
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 98 | + $this->parseString($xmlStr, $type); |
|
| 99 | 99 | $this->debug("done parsing $xml");
|
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param string $type (schema|xml) |
| 111 | 111 | * @access private |
| 112 | 112 | */ |
| 113 | - function parseString($xml,$type){
|
|
| 113 | + function parseString($xml, $type) {
|
|
| 114 | 114 | // parse xml string |
| 115 | - if($xml != ""){
|
|
| 115 | + if ($xml != "") {
|
|
| 116 | 116 | |
| 117 | 117 | // Create an XML parser. |
| 118 | 118 | $this->parser = xml_parser_create(); |
@@ -123,28 +123,28 @@ discard block |
||
| 123 | 123 | xml_set_object($this->parser, $this); |
| 124 | 124 | |
| 125 | 125 | // Set the element handlers for the parser. |
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 126 | + if ($type == "schema") {
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser, 'schemaCharacterData'); |
|
| 129 | + } elseif ($type == "xml") {
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser, 'xmlCharacterData'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Parse the XML file. |
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 135 | + if (!xml_parse($this->parser, $xml, true)) {
|
|
| 136 | 136 | // Display an error message. |
| 137 | 137 | $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
| 138 | 138 | xml_get_current_line_number($this->parser), |
| 139 | 139 | xml_error_string(xml_get_error_code($this->parser)) |
| 140 | 140 | ); |
| 141 | 141 | $this->debug($errstr); |
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 142 | + $this->debug("XML payload:\n".$xml);
|
|
| 143 | 143 | $this->setError($errstr); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | xml_parser_free($this->parser); |
| 147 | - } else{
|
|
| 147 | + } else {
|
|
| 148 | 148 | $this->debug('no xml passed to parseString()!!');
|
| 149 | 149 | $this->setError('no xml passed to parseString()!!');
|
| 150 | 150 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | function CreateTypeName($ename) {
|
| 161 | 161 | $scope = ''; |
| 162 | 162 | for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 163 | + $scope .= $this->complexTypeStack[$i].'_'; |
|
| 164 | 164 | } |
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 165 | + return $scope.$ename.'_ContainedType'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // get element prefix |
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 191 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 192 | 192 | // get unqualified name |
| 193 | 193 | $name = $this->getLocalPart($name); |
| 194 | 194 | } else {
|
@@ -196,31 +196,31 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | - if(count($attrs) > 0){
|
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 199 | + if (count($attrs) > 0) {
|
|
| 200 | + foreach ($attrs as $k => $v) {
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 202 | + if (preg_match('/^xmlns/', $k)) {
|
|
| 203 | 203 | //$this->xdebug("$k: $v");
|
| 204 | 204 | //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 205 | + if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
|
|
| 206 | 206 | //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
| 207 | 207 | $this->namespaces[$ns_prefix] = $v; |
| 208 | 208 | } else {
|
| 209 | 209 | $this->defaultNamespace[$pos] = $v; |
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 210 | + if (!$this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 214 | + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
|
|
| 215 | 215 | $this->XMLSchemaVersion = $v; |
| 216 | 216 | $this->namespaces['xsi'] = $v.'-instance'; |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - foreach($attrs as $k => $v){
|
|
| 220 | + foreach ($attrs as $k => $v) {
|
|
| 221 | 221 | // expand each attribute |
| 222 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 223 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 222 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 223 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 224 | 224 | $eAttrs[$k] = $v; |
| 225 | 225 | } |
| 226 | 226 | $attrs = $eAttrs; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $attrs = array(); |
| 229 | 229 | } |
| 230 | 230 | // find status, register data |
| 231 | - switch($name){
|
|
| 231 | + switch ($name) {
|
|
| 232 | 232 | case 'all': // (optional) compositor content for a complexType |
| 233 | 233 | case 'choice': |
| 234 | 234 | case 'group': |
@@ -253,41 +253,41 @@ discard block |
||
| 253 | 253 | // no namespace in arrayType attribute value... |
| 254 | 254 | if ($this->defaultNamespace[$pos]) {
|
| 255 | 255 | // ...so use the default |
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].':'.$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | - if(isset($attrs['name'])){
|
|
| 260 | + if (isset($attrs['name'])) {
|
|
| 261 | 261 | $this->attributes[$attrs['name']] = $attrs; |
| 262 | 262 | $aname = $attrs['name']; |
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 263 | + } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
|
|
| 264 | 264 | if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
| 265 | 265 | $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 266 | 266 | } else {
|
| 267 | 267 | $aname = ''; |
| 268 | 268 | } |
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 269 | + } elseif (isset($attrs['ref'])) {
|
|
| 270 | 270 | $aname = $attrs['ref']; |
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 274 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 275 | 275 | $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
| 276 | 276 | } |
| 277 | 277 | // arrayType attribute |
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 278 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
|
|
| 279 | 279 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 280 | 280 | $prefix = $this->getPrefix($aname); |
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 281 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 282 | 282 | $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 283 | 283 | } else {
|
| 284 | 284 | $v = ''; |
| 285 | 285 | } |
| 286 | - if(strpos($v,'[,]')){
|
|
| 286 | + if (strpos($v, '[,]')) {
|
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
| 289 | - $v = substr($v,0,strpos($v,'[')); // clip the [] |
|
| 290 | - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
|
|
| 289 | + $v = substr($v, 0, strpos($v, '[')); // clip the [] |
|
| 290 | + if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
|
|
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | break; |
| 299 | 299 | case 'complexType': |
| 300 | 300 | array_push($this->complexTypeStack, $this->currentComplexType); |
| 301 | - if(isset($attrs['name'])){
|
|
| 301 | + if (isset($attrs['name'])) {
|
|
| 302 | 302 | // TODO: what is the scope of named complexTypes that appear |
| 303 | 303 | // nested within other c complexTypes? |
| 304 | 304 | $this->xdebug('processing named complexType '.$attrs['name']);
|
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // minOccurs="0" maxOccurs="unbounded" /> |
| 314 | 314 | // </sequence> |
| 315 | 315 | // </complexType> |
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 316 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 317 | 317 | $this->xdebug('complexType is unusual array');
|
| 318 | 318 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 319 | 319 | } else {
|
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | } else {
|
| 323 | 323 | $name = $this->CreateTypeName($this->currentElement); |
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 324 | + $this->xdebug('processing unnamed complexType for element '.$this->currentElement.' named '.$name);
|
|
| 325 | 325 | $this->currentComplexType = $name; |
| 326 | 326 | //$this->currentElement = false; |
| 327 | 327 | $this->complexTypes[$this->currentComplexType] = $attrs; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | // minOccurs="0" maxOccurs="unbounded" /> |
| 334 | 334 | // </sequence> |
| 335 | 335 | // </complexType> |
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 336 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 337 | 337 | $this->xdebug('complexType is unusual array');
|
| 338 | 338 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 339 | 339 | } else {
|
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | $attrs['form'] = 'qualified'; |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | - if(isset($attrs['type'])){
|
|
| 355 | + if (isset($attrs['type'])) {
|
|
| 356 | 356 | $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 357 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 358 | 358 | if ($this->defaultNamespace[$pos]) {
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos].':'.$attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type '.$attrs['type']);
|
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | // This is for constructs like |
@@ -368,20 +368,20 @@ discard block |
||
| 368 | 368 | // </sequence> |
| 369 | 369 | // </complexType> |
| 370 | 370 | if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 371 | + $this->xdebug('arrayType for unusual array is '.$attrs['type']);
|
|
| 372 | 372 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
| 373 | 373 | } |
| 374 | 374 | $this->currentElement = $attrs['name']; |
| 375 | 375 | $ename = $attrs['name']; |
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 376 | + } elseif (isset($attrs['ref'])) {
|
|
| 377 | 377 | $this->xdebug("processing element as ref to ".$attrs['ref']);
|
| 378 | 378 | $this->currentElement = "ref to ".$attrs['ref']; |
| 379 | 379 | $ename = $this->getLocalPart($attrs['ref']); |
| 380 | 380 | } else {
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType.'_'.$attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element ".$attrs['name'].' type '.$type);
|
|
| 383 | 383 | $this->currentElement = $attrs['name']; |
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$type; |
|
| 385 | 385 | $ename = $attrs['name']; |
| 386 | 386 | } |
| 387 | 387 | if (isset($ename) && $this->currentComplexType) {
|
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
| 390 | 390 | } elseif (!isset($attrs['ref'])) {
|
| 391 | 391 | $this->xdebug("add element $ename to elements array");
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 392 | + $this->elements[$attrs['name']] = $attrs; |
|
| 393 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 394 | 394 | } |
| 395 | 395 | break; |
| 396 | 396 | case 'enumeration': // restriction value list member |
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 397 | + $this->xdebug('enumeration '.$attrs['value']);
|
|
| 398 | 398 | if ($this->currentSimpleType) {
|
| 399 | 399 | $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
| 400 | 400 | } elseif ($this->currentComplexType) {
|
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | break; |
| 404 | 404 | case 'extension': // simpleContent or complexContent type extension |
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 405 | + $this->xdebug('extension '.$attrs['base']);
|
|
| 406 | 406 | if ($this->currentComplexType) {
|
| 407 | 407 | $ns = $this->getPrefix($attrs['base']); |
| 408 | 408 | if ($ns == '') {
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace.':'.$attrs['base']; |
|
| 410 | 410 | } else {
|
| 411 | 411 | $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
| 412 | 412 | } |
@@ -416,19 +416,19 @@ discard block |
||
| 416 | 416 | break; |
| 417 | 417 | case 'import': |
| 418 | 418 | if (isset($attrs['schemaLocation'])) {
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 419 | + $this->xdebug('import namespace '.$attrs['namespace'].' from '.$attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | 421 | } else {
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 422 | + $this->xdebug('import namespace '.$attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 424 | + if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace']; |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | break; |
| 429 | 429 | case 'include': |
| 430 | 430 | if (isset($attrs['schemaLocation'])) {
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 431 | + $this->xdebug('include into namespace '.$this->schemaTargetNamespace.' from '.$attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | 433 | } else {
|
| 434 | 434 | $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
@@ -438,12 +438,12 @@ discard block |
||
| 438 | 438 | $this->xdebug("do nothing for element $name");
|
| 439 | 439 | break; |
| 440 | 440 | case 'restriction': // simpleType, simpleContent or complexContent value restriction |
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 441 | + $this->xdebug('restriction '.$attrs['base']);
|
|
| 442 | + if ($this->currentSimpleType) {
|
|
| 443 | 443 | $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
| 444 | - } elseif($this->currentComplexType){
|
|
| 444 | + } elseif ($this->currentComplexType) {
|
|
| 445 | 445 | $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 446 | + if (strstr($attrs['base'], ':') == ':Array') {
|
|
| 447 | 447 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 448 | 448 | } |
| 449 | 449 | } |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | break; |
| 471 | 471 | case 'simpleType': |
| 472 | 472 | array_push($this->simpleTypeStack, $this->currentSimpleType); |
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 473 | + if (isset($attrs['name'])) {
|
|
| 474 | + $this->xdebug("processing simpleType for name ".$attrs['name']);
|
|
| 475 | 475 | $this->currentSimpleType = $attrs['name']; |
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 476 | + $this->simpleTypes[$attrs['name']] = $attrs; |
|
| 477 | + $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar'; |
|
| 479 | 479 | } else {
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType.'_'.$this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element '.$this->currentElement.' named '.$name);
|
|
| 482 | 482 | $this->currentSimpleType = $name; |
| 483 | 483 | //$this->currentElement = false; |
| 484 | 484 | $this->simpleTypes[$this->currentSimpleType] = $attrs; |
@@ -504,29 +504,29 @@ discard block |
||
| 504 | 504 | // bring depth down a notch |
| 505 | 505 | $this->depth--; |
| 506 | 506 | // position of current element is equal to the last value left in depth_array for my depth |
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 507 | + if (isset($this->depth_array[$this->depth])) {
|
|
| 508 | 508 | $pos = $this->depth_array[$this->depth]; |
| 509 | 509 | } |
| 510 | 510 | // get element prefix |
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 511 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 512 | 512 | // get unqualified name |
| 513 | 513 | $name = $this->getLocalPart($name); |
| 514 | 514 | } else {
|
| 515 | 515 | $prefix = ''; |
| 516 | 516 | } |
| 517 | 517 | // move on... |
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 518 | + if ($name == 'complexType') {
|
|
| 519 | + $this->xdebug('done processing complexType '.($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | 520 | $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
| 521 | 521 | $this->currentComplexType = array_pop($this->complexTypeStack); |
| 522 | 522 | //$this->currentElement = false; |
| 523 | 523 | } |
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 524 | + if ($name == 'element') {
|
|
| 525 | + $this->xdebug('done processing element '.($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | 526 | $this->currentElement = array_pop($this->elementStack); |
| 527 | 527 | } |
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 528 | + if ($name == 'simpleType') {
|
|
| 529 | + $this->xdebug('done processing simpleType '.($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | 530 | $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
| 531 | 531 | $this->currentSimpleType = array_pop($this->simpleTypeStack); |
| 532 | 532 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param string $data element content |
| 540 | 540 | * @access private |
| 541 | 541 | */ |
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 542 | + function schemaCharacterData($parser, $data) {
|
|
| 543 | 543 | $pos = $this->depth_array[$this->depth - 1]; |
| 544 | 544 | $this->message[$pos]['cdata'] .= $data; |
| 545 | 545 | } |
@@ -549,32 +549,32 @@ discard block |
||
| 549 | 549 | * |
| 550 | 550 | * @access public |
| 551 | 551 | */ |
| 552 | - function serializeSchema(){
|
|
| 552 | + function serializeSchema() {
|
|
| 553 | 553 | |
| 554 | 554 | $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
| 555 | 555 | $xml = ''; |
| 556 | 556 | // imports |
| 557 | 557 | if (sizeof($this->imports) > 0) {
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 558 | + foreach ($this->imports as $ns => $list) {
|
|
| 559 | 559 | foreach ($list as $ii) {
|
| 560 | 560 | if ($ii['location'] != '') {
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"".$ii['location'].'" namespace="'.$ns."\" />\n"; |
|
| 562 | 562 | } else {
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"".$ns."\" />\n"; |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | // complex types |
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 569 | + foreach ($this->complexTypes as $typeName => $attrs) {
|
|
| 570 | 570 | $contentStr = ''; |
| 571 | 571 | // serialize child elements |
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 572 | + if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
|
|
| 573 | + foreach ($attrs['elements'] as $element => $eParts) {
|
|
| 574 | + if (isset($eParts['ref'])) {
|
|
| 575 | 575 | $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
| 576 | 576 | } else {
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\""; |
|
| 578 | 578 | foreach ($eParts as $aName => $aValue) {
|
| 579 | 579 | // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
| 580 | 580 | if ($aName != 'name' && $aName != 'type') {
|
@@ -590,8 +590,8 @@ discard block |
||
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | // attributes |
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 593 | + if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
|
|
| 594 | + foreach ($attrs['attrs'] as $attr => $aParts) {
|
|
| 595 | 595 | $contentStr .= " <$schemaPrefix:attribute"; |
| 596 | 596 | foreach ($aParts as $a => $v) {
|
| 597 | 597 | if ($a == 'ref' || $a == 'type') {
|
@@ -607,15 +607,15 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | // if restriction |
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
|
|
| 611 | 611 | $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
| 612 | 612 | // complex or simple content |
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
|
|
| 614 | 614 | $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | // finalize complex type |
| 618 | - if($contentStr != ''){
|
|
| 618 | + if ($contentStr != '') {
|
|
| 619 | 619 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
| 620 | 620 | } else {
|
| 621 | 621 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | $xml .= $contentStr; |
| 624 | 624 | } |
| 625 | 625 | // simple types |
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 626 | + if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
|
|
| 627 | + foreach ($this->simpleTypes as $typeName => $eParts) {
|
|
| 628 | 628 | $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
| 629 | 629 | if (isset($eParts['enumeration'])) {
|
| 630 | 630 | foreach ($eParts['enumeration'] as $e) {
|
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | // elements |
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 638 | + if (isset($this->elements) && count($this->elements) > 0) {
|
|
| 639 | + foreach ($this->elements as $element => $eParts) {
|
|
| 640 | 640 | $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | // attributes |
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 644 | + if (isset($this->attributes) && count($this->attributes) > 0) {
|
|
| 645 | + foreach ($this->attributes as $attr => $aParts) {
|
|
| 646 | 646 | $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
| 658 | 658 | $el .= " xmlns:$nsp=\"$ns\""; |
| 659 | 659 | } |
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 660 | + $xml = $el.">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | 661 | return $xml; |
| 662 | 662 | } |
| 663 | 663 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | * @param string $string debug data |
| 668 | 668 | * @access private |
| 669 | 669 | */ |
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 670 | + function xdebug($string) {
|
|
| 671 | + $this->debug('<'.$this->schemaTargetNamespace.'> '.$string);
|
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | * @access public |
| 684 | 684 | * @deprecated |
| 685 | 685 | */ |
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 686 | + function getPHPType($type, $ns) {
|
|
| 687 | + if (isset($this->typemap[$ns][$type])) {
|
|
| 688 | 688 | //print "found type '$type' and ns $ns in typemap<br>"; |
| 689 | 689 | return $this->typemap[$ns][$type]; |
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 690 | + } elseif (isset($this->complexTypes[$type])) {
|
|
| 691 | 691 | //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
| 692 | 692 | return $this->complexTypes[$type]['phpType']; |
| 693 | 693 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | * @see addSimpleType |
| 717 | 717 | * @see addElement |
| 718 | 718 | */ |
| 719 | - function getTypeDef($type){
|
|
| 719 | + function getTypeDef($type) {
|
|
| 720 | 720 | //$this->debug("in getTypeDef for type $type");
|
| 721 | 721 | if (substr($type, -1) == '^') {
|
| 722 | 722 | $is_element = 1; |
@@ -725,10 +725,10 @@ discard block |
||
| 725 | 725 | $is_element = 0; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 728 | + if ((!$is_element) && isset($this->complexTypes[$type])) {
|
|
| 729 | 729 | $this->xdebug("in getTypeDef, found complexType $type");
|
| 730 | 730 | return $this->complexTypes[$type]; |
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 731 | + } elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
|
|
| 732 | 732 | $this->xdebug("in getTypeDef, found simpleType $type");
|
| 733 | 733 | if (!isset($this->simpleTypes[$type]['phpType'])) {
|
| 734 | 734 | // get info for type to tack onto the simple type |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | return $this->simpleTypes[$type]; |
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 751 | + } elseif (isset($this->elements[$type])) {
|
|
| 752 | 752 | $this->xdebug("in getTypeDef, found element $type");
|
| 753 | 753 | if (!isset($this->elements[$type]['phpType'])) {
|
| 754 | 754 | // get info for type to tack onto the element |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | return $this->elements[$type]; |
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 776 | + } elseif (isset($this->attributes[$type])) {
|
|
| 777 | 777 | $this->xdebug("in getTypeDef, found attribute $type");
|
| 778 | 778 | return $this->attributes[$type]; |
| 779 | 779 | } elseif (preg_match('/_ContainedType$/', $type)) {
|
@@ -795,23 +795,23 @@ discard block |
||
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
| 798 | - function serializeTypeDef($type){
|
|
| 798 | + function serializeTypeDef($type) {
|
|
| 799 | 799 | //print "in sTD() for type $type<br>"; |
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 800 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 801 | 801 | $str .= '<'.$type; |
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 802 | + if (is_array($typeDef['attrs'])) {
|
|
| 803 | + foreach ($typeDef['attrs'] as $attName => $data) {
|
|
| 804 | 804 | $str .= " $attName=\"{type = ".$data['type']."}\"";
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 808 | + if (count($typeDef['elements']) > 0) {
|
|
| 809 | 809 | $str .= ">"; |
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 810 | + foreach ($typeDef['elements'] as $element => $eData) {
|
|
| 811 | 811 | $str .= $this->serializeTypeDef($element); |
| 812 | 812 | } |
| 813 | 813 | $str .= "</$type>"; |
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 814 | + } elseif ($typeDef['typeClass'] == 'element') {
|
|
| 815 | 815 | $str .= "></$type>"; |
| 816 | 816 | } else {
|
| 817 | 817 | $str .= "/>"; |
@@ -831,22 +831,22 @@ discard block |
||
| 831 | 831 | * @access public |
| 832 | 832 | * @deprecated |
| 833 | 833 | */ |
| 834 | - function typeToForm($name,$type){
|
|
| 834 | + function typeToForm($name, $type) {
|
|
| 835 | 835 | // get typedef |
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 836 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 837 | 837 | // if struct |
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 838 | + if ($typeDef['phpType'] == 'struct') {
|
|
| 839 | 839 | $buffer .= '<table>'; |
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 840 | + foreach ($typeDef['elements'] as $child => $childDef) {
|
|
| 841 | 841 | $buffer .= " |
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | 844 | } |
| 845 | 845 | $buffer .= '</table>'; |
| 846 | 846 | // if array |
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 847 | + } elseif ($typeDef['phpType'] == 'array') {
|
|
| 848 | 848 | $buffer .= '<table>'; |
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 849 | + for ($i = 0; $i < 3; $i++) {
|
|
| 850 | 850 | $buffer .= " |
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @access public |
| 904 | 904 | * @see getTypeDef |
| 905 | 905 | */ |
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 906 | + function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
|
|
| 907 | 907 | $this->complexTypes[$name] = array( |
| 908 | 908 | 'name' => $name, |
| 909 | 909 | 'typeClass' => $typeClass, |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * @see nusoap_xmlschema |
| 932 | 932 | * @see getTypeDef |
| 933 | 933 | */ |
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 934 | + function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
|
|
| 935 | 935 | $this->simpleTypes[$name] = array( |
| 936 | 936 | 'name' => $name, |
| 937 | 937 | 'typeClass' => $typeClass, |
@@ -952,14 +952,14 @@ discard block |
||
| 952 | 952 | * @access public |
| 953 | 953 | */ |
| 954 | 954 | function addElement($attrs) {
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 955 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$attrs['type']; |
|
| 957 | 957 | } |
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 958 | + $this->elements[$attrs['name']] = $attrs; |
|
| 959 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 961 | + $this->xdebug("addElement ".$attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[$attrs['name']])); |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
@@ -447,7 +447,7 @@ |
||
| 447 | 447 | * |
| 448 | 448 | * @param array $headers The HTTP headers |
| 449 | 449 | * @param string $data unprocessed request data from client |
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 450 | + * @return false|null value of the message, decoded into a PHP type |
|
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
@@ -52,224 +52,224 @@ discard block |
||
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | 54 | class nusoap_client_mime extends nusoap_client {
|
| 55 | - /** |
|
| 56 | - * @var array Each array element in the return is an associative array with keys |
|
| 57 | - * data, filename, contenttype, cid |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $requestAttachments = array(); |
|
| 61 | - /** |
|
| 62 | - * @var array Each array element in the return is an associative array with keys |
|
| 63 | - * data, filename, contenttype, cid |
|
| 64 | - * @access private |
|
| 65 | - */ |
|
| 66 | - var $responseAttachments; |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $mimeContentType; |
|
| 55 | + /** |
|
| 56 | + * @var array Each array element in the return is an associative array with keys |
|
| 57 | + * data, filename, contenttype, cid |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $requestAttachments = array(); |
|
| 61 | + /** |
|
| 62 | + * @var array Each array element in the return is an associative array with keys |
|
| 63 | + * data, filename, contenttype, cid |
|
| 64 | + * @access private |
|
| 65 | + */ |
|
| 66 | + var $responseAttachments; |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $mimeContentType; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * adds a MIME attachment to the current request. |
|
| 75 | - * |
|
| 76 | - * If the $data parameter contains an empty string, this method will read |
|
| 77 | - * the contents of the file named by the $filename parameter. |
|
| 78 | - * |
|
| 79 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | - * |
|
| 81 | - * @param string $data The data of the attachment |
|
| 82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | - * @return string The content-id (cid) of the attachment |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 88 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | - if (! $cid) {
|
|
| 90 | - $cid = md5(uniqid(time())); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $info['data'] = $data; |
|
| 94 | - $info['filename'] = $filename; |
|
| 95 | - $info['contenttype'] = $contenttype; |
|
| 96 | - $info['cid'] = $cid; |
|
| 73 | + /** |
|
| 74 | + * adds a MIME attachment to the current request. |
|
| 75 | + * |
|
| 76 | + * If the $data parameter contains an empty string, this method will read |
|
| 77 | + * the contents of the file named by the $filename parameter. |
|
| 78 | + * |
|
| 79 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | + * |
|
| 81 | + * @param string $data The data of the attachment |
|
| 82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | + * @return string The content-id (cid) of the attachment |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | + if (! $cid) {
|
|
| 90 | + $cid = md5(uniqid(time())); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $info['data'] = $data; |
|
| 94 | + $info['filename'] = $filename; |
|
| 95 | + $info['contenttype'] = $contenttype; |
|
| 96 | + $info['cid'] = $cid; |
|
| 97 | 97 | |
| 98 | - $this->requestAttachments[] = $info; |
|
| 99 | - |
|
| 100 | - return $cid; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * clears the MIME attachments for the current request. |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - */ |
|
| 108 | - function clearAttachments() {
|
|
| 109 | - $this->requestAttachments = array(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * gets the MIME attachments from the current response. |
|
| 114 | - * |
|
| 115 | - * Each array element in the return is an associative array with keys |
|
| 116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | - * for addAttachment. |
|
| 118 | - * |
|
| 119 | - * @return array The attachments. |
|
| 120 | - * @access public |
|
| 121 | - */ |
|
| 122 | - function getAttachments() {
|
|
| 123 | - return $this->responseAttachments; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * gets the HTTP body for the current request. |
|
| 128 | - * |
|
| 129 | - * @param string $soapmsg The SOAP payload |
|
| 130 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | - * @access private |
|
| 132 | - */ |
|
| 133 | - function getHTTPBody($soapmsg) {
|
|
| 134 | - if (count($this->requestAttachments) > 0) {
|
|
| 135 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | - unset($params); |
|
| 138 | - |
|
| 139 | - $params['content_type'] = 'text/xml'; |
|
| 140 | - $params['encoding'] = '8bit'; |
|
| 141 | - $params['charset'] = $this->soap_defencoding; |
|
| 142 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 98 | + $this->requestAttachments[] = $info; |
|
| 99 | + |
|
| 100 | + return $cid; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * clears the MIME attachments for the current request. |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + */ |
|
| 108 | + function clearAttachments() {
|
|
| 109 | + $this->requestAttachments = array(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * gets the MIME attachments from the current response. |
|
| 114 | + * |
|
| 115 | + * Each array element in the return is an associative array with keys |
|
| 116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | + * for addAttachment. |
|
| 118 | + * |
|
| 119 | + * @return array The attachments. |
|
| 120 | + * @access public |
|
| 121 | + */ |
|
| 122 | + function getAttachments() {
|
|
| 123 | + return $this->responseAttachments; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * gets the HTTP body for the current request. |
|
| 128 | + * |
|
| 129 | + * @param string $soapmsg The SOAP payload |
|
| 130 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | + * @access private |
|
| 132 | + */ |
|
| 133 | + function getHTTPBody($soapmsg) {
|
|
| 134 | + if (count($this->requestAttachments) > 0) {
|
|
| 135 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | + unset($params); |
|
| 138 | + |
|
| 139 | + $params['content_type'] = 'text/xml'; |
|
| 140 | + $params['encoding'] = '8bit'; |
|
| 141 | + $params['charset'] = $this->soap_defencoding; |
|
| 142 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 143 | 143 | |
| 144 | - foreach ($this->requestAttachments as $att) {
|
|
| 145 | - unset($params); |
|
| 146 | - |
|
| 147 | - $params['content_type'] = $att['contenttype']; |
|
| 148 | - $params['encoding'] = 'base64'; |
|
| 149 | - $params['disposition'] = 'attachment'; |
|
| 150 | - $params['dfilename'] = $att['filename']; |
|
| 151 | - $params['cid'] = $att['cid']; |
|
| 152 | - |
|
| 153 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | - $data = fread($fd, filesize($att['filename'])); |
|
| 156 | - fclose($fd); |
|
| 157 | - } else {
|
|
| 158 | - $data = ''; |
|
| 159 | - } |
|
| 160 | - $mimeMessage->addSubpart($data, $params); |
|
| 161 | - } else {
|
|
| 162 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $output = $mimeMessage->encode(); |
|
| 167 | - $mimeHeaders = $output['headers']; |
|
| 144 | + foreach ($this->requestAttachments as $att) {
|
|
| 145 | + unset($params); |
|
| 146 | + |
|
| 147 | + $params['content_type'] = $att['contenttype']; |
|
| 148 | + $params['encoding'] = 'base64'; |
|
| 149 | + $params['disposition'] = 'attachment'; |
|
| 150 | + $params['dfilename'] = $att['filename']; |
|
| 151 | + $params['cid'] = $att['cid']; |
|
| 152 | + |
|
| 153 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | + $data = fread($fd, filesize($att['filename'])); |
|
| 156 | + fclose($fd); |
|
| 157 | + } else {
|
|
| 158 | + $data = ''; |
|
| 159 | + } |
|
| 160 | + $mimeMessage->addSubpart($data, $params); |
|
| 161 | + } else {
|
|
| 162 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $output = $mimeMessage->encode(); |
|
| 167 | + $mimeHeaders = $output['headers']; |
|
| 168 | 168 | |
| 169 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | - $this->debug("MIME header $k: $v");
|
|
| 171 | - if (strtolower($k) == 'content-type') {
|
|
| 172 | - // PHP header() seems to strip leading whitespace starting |
|
| 173 | - // the second line, so force everything to one line |
|
| 174 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | - } |
|
| 176 | - } |
|
| 169 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | + $this->debug("MIME header $k: $v");
|
|
| 171 | + if (strtolower($k) == 'content-type') {
|
|
| 172 | + // PHP header() seems to strip leading whitespace starting |
|
| 173 | + // the second line, so force everything to one line |
|
| 174 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - return $output['body']; |
|
| 179 | - } |
|
| 178 | + return $output['body']; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - return parent::getHTTPBody($soapmsg); |
|
| 182 | - } |
|
| 181 | + return parent::getHTTPBody($soapmsg); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * gets the HTTP content type for the current request. |
|
| 186 | - * |
|
| 187 | - * Note: getHTTPBody must be called before this. |
|
| 188 | - * |
|
| 189 | - * @return string the HTTP content type for the current request. |
|
| 190 | - * @access private |
|
| 191 | - */ |
|
| 192 | - function getHTTPContentType() {
|
|
| 193 | - if (count($this->requestAttachments) > 0) {
|
|
| 194 | - return $this->mimeContentType; |
|
| 195 | - } |
|
| 196 | - return parent::getHTTPContentType(); |
|
| 197 | - } |
|
| 184 | + /** |
|
| 185 | + * gets the HTTP content type for the current request. |
|
| 186 | + * |
|
| 187 | + * Note: getHTTPBody must be called before this. |
|
| 188 | + * |
|
| 189 | + * @return string the HTTP content type for the current request. |
|
| 190 | + * @access private |
|
| 191 | + */ |
|
| 192 | + function getHTTPContentType() {
|
|
| 193 | + if (count($this->requestAttachments) > 0) {
|
|
| 194 | + return $this->mimeContentType; |
|
| 195 | + } |
|
| 196 | + return parent::getHTTPContentType(); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * gets the HTTP content type charset for the current request. |
|
| 201 | - * returns false for non-text content types. |
|
| 202 | - * |
|
| 203 | - * Note: getHTTPBody must be called before this. |
|
| 204 | - * |
|
| 205 | - * @return string the HTTP content type charset for the current request. |
|
| 206 | - * @access private |
|
| 207 | - */ |
|
| 208 | - function getHTTPContentTypeCharset() {
|
|
| 209 | - if (count($this->requestAttachments) > 0) {
|
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - return parent::getHTTPContentTypeCharset(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * processes SOAP message returned from server |
|
| 217 | - * |
|
| 218 | - * @param array $headers The HTTP headers |
|
| 219 | - * @param string $data unprocessed response data from server |
|
| 220 | - * @return mixed value of the message, decoded into a PHP type |
|
| 221 | - * @access private |
|
| 222 | - */ |
|
| 199 | + /** |
|
| 200 | + * gets the HTTP content type charset for the current request. |
|
| 201 | + * returns false for non-text content types. |
|
| 202 | + * |
|
| 203 | + * Note: getHTTPBody must be called before this. |
|
| 204 | + * |
|
| 205 | + * @return string the HTTP content type charset for the current request. |
|
| 206 | + * @access private |
|
| 207 | + */ |
|
| 208 | + function getHTTPContentTypeCharset() {
|
|
| 209 | + if (count($this->requestAttachments) > 0) {
|
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + return parent::getHTTPContentTypeCharset(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * processes SOAP message returned from server |
|
| 217 | + * |
|
| 218 | + * @param array $headers The HTTP headers |
|
| 219 | + * @param string $data unprocessed response data from server |
|
| 220 | + * @return mixed value of the message, decoded into a PHP type |
|
| 221 | + * @access private |
|
| 222 | + */ |
|
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | - $this->responseAttachments = array(); |
|
| 226 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | - $this->debug('Decode multipart/related');
|
|
| 228 | - $input = ''; |
|
| 229 | - foreach ($headers as $k => $v) {
|
|
| 230 | - $input .= "$k: $v\r\n"; |
|
| 231 | - } |
|
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 233 | - $params['include_bodies'] = true; |
|
| 234 | - $params['decode_bodies'] = true; |
|
| 235 | - $params['decode_headers'] = true; |
|
| 224 | + $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | + $this->responseAttachments = array(); |
|
| 226 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | + $this->debug('Decode multipart/related');
|
|
| 228 | + $input = ''; |
|
| 229 | + foreach ($headers as $k => $v) {
|
|
| 230 | + $input .= "$k: $v\r\n"; |
|
| 231 | + } |
|
| 232 | + $params['input'] = $input . "\r\n" . $data; |
|
| 233 | + $params['include_bodies'] = true; |
|
| 234 | + $params['decode_bodies'] = true; |
|
| 235 | + $params['decode_headers'] = true; |
|
| 236 | 236 | |
| 237 | - $structure = Mail_mimeDecode::decode($params); |
|
| 238 | - |
|
| 239 | - foreach ($structure->parts as $part) {
|
|
| 240 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | - $root = $part->body; |
|
| 243 | - $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | - } else {
|
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | - $info['data'] = $part->body; |
|
| 247 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | - $info['cid'] = $part->headers['content-id']; |
|
| 250 | - $this->responseAttachments[] = $info; |
|
| 251 | - } |
|
| 252 | - } |
|
| 237 | + $structure = Mail_mimeDecode::decode($params); |
|
| 238 | + |
|
| 239 | + foreach ($structure->parts as $part) {
|
|
| 240 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | + $root = $part->body; |
|
| 243 | + $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | + } else {
|
|
| 245 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | + $info['data'] = $part->body; |
|
| 247 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | + $info['cid'] = $part->headers['content-id']; |
|
| 250 | + $this->responseAttachments[] = $info; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - if (isset($return)) {
|
|
| 255 | - $this->responseData = $root; |
|
| 256 | - return $return; |
|
| 257 | - } |
|
| 254 | + if (isset($return)) {
|
|
| 255 | + $this->responseData = $root; |
|
| 256 | + return $return; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $this->setError('No root part found in multipart/related content');
|
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - $this->debug('Not multipart/related');
|
|
| 263 | - return parent::parseResponse($headers, $data); |
|
| 264 | - } |
|
| 259 | + $this->setError('No root part found in multipart/related content');
|
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + $this->debug('Not multipart/related');
|
|
| 263 | + return parent::parseResponse($headers, $data); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /* |
| 268 | 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. |
| 269 | 269 | */ |
| 270 | 270 | if (!extension_loaded('soap')) {
|
| 271 | - class soapclientmime extends nusoap_client_mime {
|
|
| 272 | - } |
|
| 271 | + class soapclientmime extends nusoap_client_mime {
|
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,214 +282,214 @@ discard block |
||
| 282 | 282 | * @access public |
| 283 | 283 | */ |
| 284 | 284 | class nusoap_server_mime extends nusoap_server {
|
| 285 | - /** |
|
| 286 | - * @var array Each array element in the return is an associative array with keys |
|
| 287 | - * data, filename, contenttype, cid |
|
| 288 | - * @access private |
|
| 289 | - */ |
|
| 290 | - var $requestAttachments = array(); |
|
| 291 | - /** |
|
| 292 | - * @var array Each array element in the return is an associative array with keys |
|
| 293 | - * data, filename, contenttype, cid |
|
| 294 | - * @access private |
|
| 295 | - */ |
|
| 296 | - var $responseAttachments; |
|
| 297 | - /** |
|
| 298 | - * @var string |
|
| 299 | - * @access private |
|
| 300 | - */ |
|
| 301 | - var $mimeContentType; |
|
| 285 | + /** |
|
| 286 | + * @var array Each array element in the return is an associative array with keys |
|
| 287 | + * data, filename, contenttype, cid |
|
| 288 | + * @access private |
|
| 289 | + */ |
|
| 290 | + var $requestAttachments = array(); |
|
| 291 | + /** |
|
| 292 | + * @var array Each array element in the return is an associative array with keys |
|
| 293 | + * data, filename, contenttype, cid |
|
| 294 | + * @access private |
|
| 295 | + */ |
|
| 296 | + var $responseAttachments; |
|
| 297 | + /** |
|
| 298 | + * @var string |
|
| 299 | + * @access private |
|
| 300 | + */ |
|
| 301 | + var $mimeContentType; |
|
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * adds a MIME attachment to the current response. |
|
| 305 | - * |
|
| 306 | - * If the $data parameter contains an empty string, this method will read |
|
| 307 | - * the contents of the file named by the $filename parameter. |
|
| 308 | - * |
|
| 309 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | - * |
|
| 311 | - * @param string $data The data of the attachment |
|
| 312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | - * @return string The content-id (cid) of the attachment |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 318 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | - if (! $cid) {
|
|
| 320 | - $cid = md5(uniqid(time())); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $info['data'] = $data; |
|
| 324 | - $info['filename'] = $filename; |
|
| 325 | - $info['contenttype'] = $contenttype; |
|
| 326 | - $info['cid'] = $cid; |
|
| 303 | + /** |
|
| 304 | + * adds a MIME attachment to the current response. |
|
| 305 | + * |
|
| 306 | + * If the $data parameter contains an empty string, this method will read |
|
| 307 | + * the contents of the file named by the $filename parameter. |
|
| 308 | + * |
|
| 309 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | + * |
|
| 311 | + * @param string $data The data of the attachment |
|
| 312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | + * @return string The content-id (cid) of the attachment |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | + if (! $cid) {
|
|
| 320 | + $cid = md5(uniqid(time())); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $info['data'] = $data; |
|
| 324 | + $info['filename'] = $filename; |
|
| 325 | + $info['contenttype'] = $contenttype; |
|
| 326 | + $info['cid'] = $cid; |
|
| 327 | 327 | |
| 328 | - $this->responseAttachments[] = $info; |
|
| 329 | - |
|
| 330 | - return $cid; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * clears the MIME attachments for the current response. |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - */ |
|
| 338 | - function clearAttachments() {
|
|
| 339 | - $this->responseAttachments = array(); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * gets the MIME attachments from the current request. |
|
| 344 | - * |
|
| 345 | - * Each array element in the return is an associative array with keys |
|
| 346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | - * for addAttachment. |
|
| 348 | - * |
|
| 349 | - * @return array The attachments. |
|
| 350 | - * @access public |
|
| 351 | - */ |
|
| 352 | - function getAttachments() {
|
|
| 353 | - return $this->requestAttachments; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * gets the HTTP body for the current response. |
|
| 358 | - * |
|
| 359 | - * @param string $soapmsg The SOAP payload |
|
| 360 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | - * @access private |
|
| 362 | - */ |
|
| 363 | - function getHTTPBody($soapmsg) {
|
|
| 364 | - if (count($this->responseAttachments) > 0) {
|
|
| 365 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | - unset($params); |
|
| 368 | - |
|
| 369 | - $params['content_type'] = 'text/xml'; |
|
| 370 | - $params['encoding'] = '8bit'; |
|
| 371 | - $params['charset'] = $this->soap_defencoding; |
|
| 372 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 328 | + $this->responseAttachments[] = $info; |
|
| 329 | + |
|
| 330 | + return $cid; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * clears the MIME attachments for the current response. |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + */ |
|
| 338 | + function clearAttachments() {
|
|
| 339 | + $this->responseAttachments = array(); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * gets the MIME attachments from the current request. |
|
| 344 | + * |
|
| 345 | + * Each array element in the return is an associative array with keys |
|
| 346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | + * for addAttachment. |
|
| 348 | + * |
|
| 349 | + * @return array The attachments. |
|
| 350 | + * @access public |
|
| 351 | + */ |
|
| 352 | + function getAttachments() {
|
|
| 353 | + return $this->requestAttachments; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * gets the HTTP body for the current response. |
|
| 358 | + * |
|
| 359 | + * @param string $soapmsg The SOAP payload |
|
| 360 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | + * @access private |
|
| 362 | + */ |
|
| 363 | + function getHTTPBody($soapmsg) {
|
|
| 364 | + if (count($this->responseAttachments) > 0) {
|
|
| 365 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | + unset($params); |
|
| 368 | + |
|
| 369 | + $params['content_type'] = 'text/xml'; |
|
| 370 | + $params['encoding'] = '8bit'; |
|
| 371 | + $params['charset'] = $this->soap_defencoding; |
|
| 372 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 373 | 373 | |
| 374 | - foreach ($this->responseAttachments as $att) {
|
|
| 375 | - unset($params); |
|
| 376 | - |
|
| 377 | - $params['content_type'] = $att['contenttype']; |
|
| 378 | - $params['encoding'] = 'base64'; |
|
| 379 | - $params['disposition'] = 'attachment'; |
|
| 380 | - $params['dfilename'] = $att['filename']; |
|
| 381 | - $params['cid'] = $att['cid']; |
|
| 382 | - |
|
| 383 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | - $data = fread($fd, filesize($att['filename'])); |
|
| 386 | - fclose($fd); |
|
| 387 | - } else {
|
|
| 388 | - $data = ''; |
|
| 389 | - } |
|
| 390 | - $mimeMessage->addSubpart($data, $params); |
|
| 391 | - } else {
|
|
| 392 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $output = $mimeMessage->encode(); |
|
| 397 | - $mimeHeaders = $output['headers']; |
|
| 374 | + foreach ($this->responseAttachments as $att) {
|
|
| 375 | + unset($params); |
|
| 376 | + |
|
| 377 | + $params['content_type'] = $att['contenttype']; |
|
| 378 | + $params['encoding'] = 'base64'; |
|
| 379 | + $params['disposition'] = 'attachment'; |
|
| 380 | + $params['dfilename'] = $att['filename']; |
|
| 381 | + $params['cid'] = $att['cid']; |
|
| 382 | + |
|
| 383 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | + $data = fread($fd, filesize($att['filename'])); |
|
| 386 | + fclose($fd); |
|
| 387 | + } else {
|
|
| 388 | + $data = ''; |
|
| 389 | + } |
|
| 390 | + $mimeMessage->addSubpart($data, $params); |
|
| 391 | + } else {
|
|
| 392 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $output = $mimeMessage->encode(); |
|
| 397 | + $mimeHeaders = $output['headers']; |
|
| 398 | 398 | |
| 399 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | - $this->debug("MIME header $k: $v");
|
|
| 401 | - if (strtolower($k) == 'content-type') {
|
|
| 402 | - // PHP header() seems to strip leading whitespace starting |
|
| 403 | - // the second line, so force everything to one line |
|
| 404 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | - } |
|
| 406 | - } |
|
| 399 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | + $this->debug("MIME header $k: $v");
|
|
| 401 | + if (strtolower($k) == 'content-type') {
|
|
| 402 | + // PHP header() seems to strip leading whitespace starting |
|
| 403 | + // the second line, so force everything to one line |
|
| 404 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - return $output['body']; |
|
| 409 | - } |
|
| 408 | + return $output['body']; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - return parent::getHTTPBody($soapmsg); |
|
| 412 | - } |
|
| 411 | + return parent::getHTTPBody($soapmsg); |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - /** |
|
| 415 | - * gets the HTTP content type for the current response. |
|
| 416 | - * |
|
| 417 | - * Note: getHTTPBody must be called before this. |
|
| 418 | - * |
|
| 419 | - * @return string the HTTP content type for the current response. |
|
| 420 | - * @access private |
|
| 421 | - */ |
|
| 422 | - function getHTTPContentType() {
|
|
| 423 | - if (count($this->responseAttachments) > 0) {
|
|
| 424 | - return $this->mimeContentType; |
|
| 425 | - } |
|
| 426 | - return parent::getHTTPContentType(); |
|
| 427 | - } |
|
| 414 | + /** |
|
| 415 | + * gets the HTTP content type for the current response. |
|
| 416 | + * |
|
| 417 | + * Note: getHTTPBody must be called before this. |
|
| 418 | + * |
|
| 419 | + * @return string the HTTP content type for the current response. |
|
| 420 | + * @access private |
|
| 421 | + */ |
|
| 422 | + function getHTTPContentType() {
|
|
| 423 | + if (count($this->responseAttachments) > 0) {
|
|
| 424 | + return $this->mimeContentType; |
|
| 425 | + } |
|
| 426 | + return parent::getHTTPContentType(); |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * gets the HTTP content type charset for the current response. |
|
| 431 | - * returns false for non-text content types. |
|
| 432 | - * |
|
| 433 | - * Note: getHTTPBody must be called before this. |
|
| 434 | - * |
|
| 435 | - * @return string the HTTP content type charset for the current response. |
|
| 436 | - * @access private |
|
| 437 | - */ |
|
| 438 | - function getHTTPContentTypeCharset() {
|
|
| 439 | - if (count($this->responseAttachments) > 0) {
|
|
| 440 | - return false; |
|
| 441 | - } |
|
| 442 | - return parent::getHTTPContentTypeCharset(); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * processes SOAP message received from client |
|
| 447 | - * |
|
| 448 | - * @param array $headers The HTTP headers |
|
| 449 | - * @param string $data unprocessed request data from client |
|
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 451 | - * @access private |
|
| 452 | - */ |
|
| 429 | + /** |
|
| 430 | + * gets the HTTP content type charset for the current response. |
|
| 431 | + * returns false for non-text content types. |
|
| 432 | + * |
|
| 433 | + * Note: getHTTPBody must be called before this. |
|
| 434 | + * |
|
| 435 | + * @return string the HTTP content type charset for the current response. |
|
| 436 | + * @access private |
|
| 437 | + */ |
|
| 438 | + function getHTTPContentTypeCharset() {
|
|
| 439 | + if (count($this->responseAttachments) > 0) {
|
|
| 440 | + return false; |
|
| 441 | + } |
|
| 442 | + return parent::getHTTPContentTypeCharset(); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * processes SOAP message received from client |
|
| 447 | + * |
|
| 448 | + * @param array $headers The HTTP headers |
|
| 449 | + * @param string $data unprocessed request data from client |
|
| 450 | + * @return mixed value of the message, decoded into a PHP type |
|
| 451 | + * @access private |
|
| 452 | + */ |
|
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | - $this->requestAttachments = array(); |
|
| 456 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | - $this->debug('Decode multipart/related');
|
|
| 458 | - $input = ''; |
|
| 459 | - foreach ($headers as $k => $v) {
|
|
| 460 | - $input .= "$k: $v\r\n"; |
|
| 461 | - } |
|
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 463 | - $params['include_bodies'] = true; |
|
| 464 | - $params['decode_bodies'] = true; |
|
| 465 | - $params['decode_headers'] = true; |
|
| 454 | + $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | + $this->requestAttachments = array(); |
|
| 456 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | + $this->debug('Decode multipart/related');
|
|
| 458 | + $input = ''; |
|
| 459 | + foreach ($headers as $k => $v) {
|
|
| 460 | + $input .= "$k: $v\r\n"; |
|
| 461 | + } |
|
| 462 | + $params['input'] = $input . "\r\n" . $data; |
|
| 463 | + $params['include_bodies'] = true; |
|
| 464 | + $params['decode_bodies'] = true; |
|
| 465 | + $params['decode_headers'] = true; |
|
| 466 | 466 | |
| 467 | - $structure = Mail_mimeDecode::decode($params); |
|
| 468 | - |
|
| 469 | - foreach ($structure->parts as $part) {
|
|
| 470 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | - $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | - $info['data'] = $part->body; |
|
| 476 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | - $info['cid'] = $part->headers['content-id']; |
|
| 479 | - $this->requestAttachments[] = $info; |
|
| 480 | - } |
|
| 481 | - } |
|
| 467 | + $structure = Mail_mimeDecode::decode($params); |
|
| 468 | + |
|
| 469 | + foreach ($structure->parts as $part) {
|
|
| 470 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | + $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | + $info['data'] = $part->body; |
|
| 476 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | + $info['cid'] = $part->headers['content-id']; |
|
| 479 | + $this->requestAttachments[] = $info; |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - if (isset($return)) {
|
|
| 484 | - return $return; |
|
| 485 | - } |
|
| 483 | + if (isset($return)) {
|
|
| 484 | + return $return; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - $this->setError('No root part found in multipart/related content');
|
|
| 488 | - return; |
|
| 489 | - } |
|
| 490 | - $this->debug('Not multipart/related');
|
|
| 491 | - return parent::parseRequest($headers, $data); |
|
| 492 | - } |
|
| 487 | + $this->setError('No root part found in multipart/related content');
|
|
| 488 | + return; |
|
| 489 | + } |
|
| 490 | + $this->debug('Not multipart/related');
|
|
| 491 | + return parent::parseRequest($headers, $data); |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /* |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | */ |
| 88 | 88 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 89 | - if (! $cid) {
|
|
| 89 | + if (!$cid) {
|
|
| 90 | 90 | $cid = md5(uniqid(time())); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @access private |
| 222 | 222 | */ |
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 224 | + $this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 225 | 225 | $this->responseAttachments = array(); |
| 226 | 226 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 227 | 227 | $this->debug('Decode multipart/related');
|
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | foreach ($headers as $k => $v) {
|
| 230 | 230 | $input .= "$k: $v\r\n"; |
| 231 | 231 | } |
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 232 | + $params['input'] = $input."\r\n".$data; |
|
| 233 | 233 | $params['include_bodies'] = true; |
| 234 | 234 | $params['decode_bodies'] = true; |
| 235 | 235 | $params['decode_headers'] = true; |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | foreach ($structure->parts as $part) {
|
| 240 | 240 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 241 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 242 | 242 | $root = $part->body; |
| 243 | 243 | $return = parent::parseResponse($part->headers, $part->body); |
| 244 | 244 | } else {
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 245 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 246 | 246 | $info['data'] = $part->body; |
| 247 | 247 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 248 | 248 | $info['contenttype'] = $part->headers['content-type']; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @access public |
| 317 | 317 | */ |
| 318 | 318 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 319 | - if (! $cid) {
|
|
| 319 | + if (!$cid) {
|
|
| 320 | 320 | $cid = md5(uniqid(time())); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 454 | + $this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 455 | 455 | $this->requestAttachments = array(); |
| 456 | 456 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 457 | 457 | $this->debug('Decode multipart/related');
|
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | foreach ($headers as $k => $v) {
|
| 460 | 460 | $input .= "$k: $v\r\n"; |
| 461 | 461 | } |
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 462 | + $params['input'] = $input."\r\n".$data; |
|
| 463 | 463 | $params['include_bodies'] = true; |
| 464 | 464 | $params['decode_bodies'] = true; |
| 465 | 465 | $params['decode_headers'] = true; |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | foreach ($structure->parts as $part) {
|
| 470 | 470 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 471 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 472 | 472 | $return = parent::parseRequest($part->headers, $part->body); |
| 473 | 473 | } else {
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 474 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 475 | 475 | $info['data'] = $part->body; |
| 476 | 476 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 477 | 477 | $info['contenttype'] = $part->headers['content-type']; |
@@ -208,6 +208,8 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | /** |
| 210 | 210 | * Gives a list of people online now (and in the last $valid minutes) |
| 211 | + * @param integer $from |
|
| 212 | + * @param integer $time_limit |
|
| 211 | 213 | * @return array For each line, a list of user IDs and login dates, or FALSE on error or empty results |
| 212 | 214 | */ |
| 213 | 215 | function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false) |
@@ -424,6 +426,9 @@ discard block |
||
| 424 | 426 | } |
| 425 | 427 | } |
| 426 | 428 | |
| 429 | +/** |
|
| 430 | + * @param integer $uid |
|
| 431 | + */ |
|
| 427 | 432 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 428 | 433 | { |
| 429 | 434 | if (empty($coursecode)) { |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - //This query will show all registered users. Only for dev purposes. |
|
| 294 | - /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 293 | + //This query will show all registered users. Only for dev purposes. |
|
| 294 | + /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 295 | 295 | GROUP by u.id |
| 296 | 296 | ORDER BY $column $direction |
| 297 | 297 | LIMIT $from, $number_of_items";*/ |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | } else { |
| 318 | 318 | $time_limit = intval($time_limit); |
| 319 | 319 | } |
| 320 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | - $online_time = time() - $time_limit * 60; |
|
| 324 | - $current_date = api_get_utc_datetime($online_time); |
|
| 325 | - |
|
| 326 | - if ($friends) { |
|
| 327 | - // who friends from social network is online |
|
| 328 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 320 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | + $online_time = time() - $time_limit * 60; |
|
| 324 | + $current_date = api_get_utc_datetime($online_time); |
|
| 325 | + |
|
| 326 | + if ($friends) { |
|
| 327 | + // who friends from social network is online |
|
| 328 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 329 | 329 | FROM $track_online_table INNER JOIN $friend_user_table |
| 330 | 330 | ON (friend_user_id = login_user_id) |
| 331 | 331 | WHERE |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | friend_user_id <> '".api_get_user_id()."' AND |
| 334 | 334 | relation_type='".USER_RELATION_TYPE_FRIEND."' AND |
| 335 | 335 | user_id = '".api_get_user_id()."' "; |
| 336 | - } else { |
|
| 337 | - // All users online |
|
| 338 | - $query = "SELECT count(login_id) as count |
|
| 336 | + } else { |
|
| 337 | + // All users online |
|
| 338 | + $query = "SELECT count(login_id) as count |
|
| 339 | 339 | FROM $track_online_table track INNER JOIN $table_user u |
| 340 | 340 | ON (u.id=track.login_user_id) |
| 341 | 341 | WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date' "; |
| 342 | - } |
|
| 343 | - |
|
| 344 | - if (api_get_multiple_access_url()) { |
|
| 345 | - $access_url_id = api_get_current_access_url_id(); |
|
| 346 | - if ($access_url_id != -1) { |
|
| 347 | - if ($friends) { |
|
| 348 | - // friends from social network is online |
|
| 349 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + if (api_get_multiple_access_url()) { |
|
| 345 | + $access_url_id = api_get_current_access_url_id(); |
|
| 346 | + if ($access_url_id != -1) { |
|
| 347 | + if ($friends) { |
|
| 348 | + // friends from social network is online |
|
| 349 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 350 | 350 | FROM $track_online_table track |
| 351 | 351 | INNER JOIN $friend_user_table ON (friend_user_id = login_user_id) |
| 352 | 352 | WHERE |
@@ -354,29 +354,29 @@ discard block |
||
| 354 | 354 | login_date >= '".$current_date."' AND |
| 355 | 355 | friend_user_id <> '".api_get_user_id()."' AND |
| 356 | 356 | relation_type='".USER_RELATION_TYPE_FRIEND."' "; |
| 357 | - } else { |
|
| 358 | - // all users online |
|
| 359 | - $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 357 | + } else { |
|
| 358 | + // all users online |
|
| 359 | + $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 360 | 360 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 361 | 361 | WHERE |
| 362 | 362 | u.status != ".ANONYMOUS." AND |
| 363 | 363 | track.access_url_id = $access_url_id AND |
| 364 | 364 | login_date >= '$current_date' "; |
| 365 | - } |
|
| 366 | - } |
|
| 367 | - } |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | // Dev purposes show all users online |
| 370 | 370 | /*$table_user = Database::get_main_table(TABLE_MAIN_USER); |
| 371 | 371 | $query = "SELECT count(*) as count FROM ".$table_user;*/ |
| 372 | 372 | |
| 373 | - $result = Database::query($query); |
|
| 374 | - if (Database::num_rows($result) > 0) { |
|
| 375 | - $row = Database::fetch_array($result); |
|
| 376 | - return $row['count']; |
|
| 377 | - } else { |
|
| 378 | - return false; |
|
| 379 | - } |
|
| 373 | + $result = Database::query($query); |
|
| 374 | + if (Database::num_rows($result) > 0) { |
|
| 375 | + $row = Database::fetch_array($result); |
|
| 376 | + return $row['count']; |
|
| 377 | + } else { |
|
| 378 | + return false; |
|
| 379 | + } |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | |
@@ -404,52 +404,52 @@ discard block |
||
| 404 | 404 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 405 | 405 | $course_code = Database::escape_string($course_code); |
| 406 | 406 | $courseInfo = api_get_course_info($course_code); |
| 407 | - $courseId = $courseInfo['real_id']; |
|
| 407 | + $courseId = $courseInfo['real_id']; |
|
| 408 | 408 | |
| 409 | 409 | $from = intval($from); |
| 410 | 410 | $number_of_items = intval($number_of_items); |
| 411 | 411 | |
| 412 | - $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 412 | + $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 413 | 413 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' |
| 414 | 414 | LIMIT $from, $number_of_items "; |
| 415 | 415 | |
| 416 | - $result = Database::query($query); |
|
| 417 | - if ($result) { |
|
| 418 | - $users_online = array(); |
|
| 416 | + $result = Database::query($query); |
|
| 417 | + if ($result) { |
|
| 418 | + $users_online = array(); |
|
| 419 | 419 | |
| 420 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 420 | + while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 421 | 421 | $users_online[] = $login_user_id; |
| 422 | - } |
|
| 423 | - return $users_online; |
|
| 424 | - } else { |
|
| 425 | - return false; |
|
| 426 | - } |
|
| 422 | + } |
|
| 423 | + return $users_online; |
|
| 424 | + } else { |
|
| 425 | + return false; |
|
| 426 | + } |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 430 | 430 | { |
| 431 | - if (empty($coursecode)) { |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 435 | - $time_limit = Database::escape_string($time_limit); |
|
| 431 | + if (empty($coursecode)) { |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 435 | + $time_limit = Database::escape_string($time_limit); |
|
| 436 | 436 | |
| 437 | 437 | $online_time = time() - $time_limit * 60; |
| 438 | 438 | $current_date = api_get_utc_datetime($online_time); |
| 439 | - $courseId = api_get_course_int_id($coursecode); |
|
| 439 | + $courseId = api_get_course_int_id($coursecode); |
|
| 440 | 440 | |
| 441 | - if (empty($courseId)) { |
|
| 442 | - return false; |
|
| 443 | - } |
|
| 441 | + if (empty($courseId)) { |
|
| 442 | + return false; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - $query = "SELECT count(login_user_id) as count |
|
| 445 | + $query = "SELECT count(login_user_id) as count |
|
| 446 | 446 | FROM $track_online_table |
| 447 | 447 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' "; |
| 448 | - $result = Database::query($query); |
|
| 449 | - if (Database::num_rows($result) > 0) { |
|
| 450 | - $row = Database::fetch_array($result); |
|
| 451 | - return $row['count']; |
|
| 452 | - } else { |
|
| 453 | - return false; |
|
| 454 | - } |
|
| 448 | + $result = Database::query($query); |
|
| 449 | + if (Database::num_rows($result) > 0) { |
|
| 450 | + $row = Database::fetch_array($result); |
|
| 451 | + return $row['count']; |
|
| 452 | + } else { |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 455 | 455 | } |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $login_date = api_get_utc_datetime(); |
| 34 | 34 | $access_url_id = 1; |
| 35 | - if (api_get_multiple_access_url() && api_get_current_access_url_id()!=-1) { |
|
| 35 | + if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) { |
|
| 36 | 36 | $access_url_id = api_get_current_access_url_id(); |
| 37 | 37 | } |
| 38 | 38 | $session_id = api_get_session_id(); |
| 39 | 39 | // if the $_course array exists this means we are in a course and we have to store this in the who's online table also |
| 40 | 40 | // to have the x users in this course feature working |
| 41 | - if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) { |
|
| 42 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 41 | + if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) { |
|
| 42 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 43 | 43 | VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; |
| 44 | 44 | } else { |
| 45 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 45 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 46 | 46 | VALUES ($uid,$uid,'$login_date','$user_ip', 0, '$session_id', '$access_url_id')"; |
| 47 | 47 | } |
| 48 | 48 | Database::query($query); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $isFirstLogin = Session::read('first_user_login'); |
| 63 | 63 | if (empty($isFirstLogin)) { |
| 64 | 64 | $sql = "SELECT login_id FROM $table |
| 65 | - WHERE login_user_id = " . $userId . " LIMIT 1"; |
|
| 65 | + WHERE login_user_id = ".$userId." LIMIT 1"; |
|
| 66 | 66 | |
| 67 | 67 | $result = Database::query($sql); |
| 68 | 68 | $loginData = array(); |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | ORDER BY login_date DESC |
| 117 | 117 | LIMIT 0,1"; |
| 118 | 118 | $q_last_connection = Database::query($sql); |
| 119 | - if (Database::num_rows($q_last_connection)>0) { |
|
| 120 | - $i_id_last_connection = Database::result($q_last_connection,0,"login_id"); |
|
| 119 | + if (Database::num_rows($q_last_connection) > 0) { |
|
| 120 | + $i_id_last_connection = Database::result($q_last_connection, 0, "login_id"); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (!isset($_SESSION['login_as'])) { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 168 | 168 | $user_id = intval($user_id); |
| 169 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 169 | + $query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id"; |
|
| 170 | 170 | Database::query($query); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $access_url_id = api_get_current_access_url_id(); |
| 183 | 183 | $time_limit = api_get_setting('time_limit_whosonline'); |
| 184 | 184 | |
| 185 | - $online_time = time() - $time_limit*60; |
|
| 185 | + $online_time = time() - $time_limit * 60; |
|
| 186 | 186 | $limit_date = api_get_utc_datetime($online_time); |
| 187 | 187 | $user_id = intval($user_id); |
| 188 | 188 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $current_date = api_get_utc_datetime($online_time); |
| 240 | 240 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 241 | 241 | $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
| 242 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 242 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 243 | 243 | |
| 244 | 244 | if ($friends) { |
| 245 | 245 | // who friends from social network is online |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | LIMIT $from, $number_of_items"; |
| 256 | 256 | } else { |
| 257 | 257 | $query = "SELECT DISTINCT login_user_id, login_date |
| 258 | - FROM ".$track_online_table ." e |
|
| 259 | - INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
|
| 258 | + FROM ".$track_online_table." e |
|
| 259 | + INNER JOIN ".$table_user." u ON (u.id = e.login_user_id) |
|
| 260 | 260 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 261 | 261 | ORDER BY $column $direction |
| 262 | 262 | LIMIT $from, $number_of_items"; |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | } else { |
| 280 | 280 | // all users online |
| 281 | 281 | $query = "SELECT login_user_id, login_date |
| 282 | - FROM ".$track_online_table ." track |
|
| 283 | - INNER JOIN ".$table_user ." u |
|
| 282 | + FROM ".$track_online_table." track |
|
| 283 | + INNER JOIN ".$table_user." u |
|
| 284 | 284 | ON (u.id=track.login_user_id) |
| 285 | 285 | WHERE u.status != ".ANONYMOUS." AND track.access_url_id = $access_url_id AND |
| 286 | 286 | login_date >= '".$current_date."' |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if ($result) { |
| 418 | 418 | $users_online = array(); |
| 419 | 419 | |
| 420 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 420 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 421 | 421 | $users_online[] = $login_user_id; |
| 422 | 422 | } |
| 423 | 423 | return $users_online; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | -function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
|
| 429 | +function who_is_online_in_this_course_count($uid, $time_limit, $coursecode = null) |
|
| 430 | 430 | { |
| 431 | 431 | if (empty($coursecode)) { |
| 432 | 432 | return false; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Returns the contents of the CSS defined by the plugin |
| 146 | - * @return array |
|
| 146 | + * @return string |
|
| 147 | 147 | */ |
| 148 | 148 | public function get_css() |
| 149 | 149 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Returns an HTML form (generated by FormValidator) of the plugin settings |
| 164 | - * @return string FormValidator-generated form |
|
| 164 | + * @return FormValidator FormValidator-generated form |
|
| 165 | 165 | */ |
| 166 | 166 | public function get_settings_form() |
| 167 | 167 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param boolean $add_tool_link Whether to add a tool link or not |
| 384 | 384 | * (some tools might just offer a configuration section and act on the backend) |
| 385 | 385 | * |
| 386 | - * @return boolean False on error, null otherwise |
|
| 386 | + * @return boolean|null False on error, null otherwise |
|
| 387 | 387 | */ |
| 388 | 388 | public function install_course_fields($courseId, $add_tool_link = true) |
| 389 | 389 | { |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * tool on the course's homepage |
| 492 | 492 | * @param int $courseId |
| 493 | 493 | * |
| 494 | - * @return void |
|
| 494 | + * @return false|null |
|
| 495 | 495 | */ |
| 496 | 496 | public function uninstall_course_fields($courseId) |
| 497 | 497 | { |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param string $tabName |
| 597 | 597 | * @param string $url |
| 598 | 598 | * |
| 599 | - * @return boolean |
|
| 599 | + * @return false|string |
|
| 600 | 600 | */ |
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
@@ -591,13 +591,13 @@ |
||
| 591 | 591 | |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Add a tab to platform |
|
| 596 | - * @param string $tabName |
|
| 597 | - * @param string $url |
|
| 598 | - * |
|
| 599 | - * @return boolean |
|
| 600 | - */ |
|
| 594 | + /** |
|
| 595 | + * Add a tab to platform |
|
| 596 | + * @param string $tabName |
|
| 597 | + * @param string $url |
|
| 598 | + * |
|
| 599 | + * @return boolean |
|
| 600 | + */ |
|
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
| 603 | 603 | $sql = "SELECT * FROM settings_current |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->fields = $settings; |
| 61 | 61 | |
| 62 | 62 | global $language_files; |
| 63 | - $language_files[] = 'plugin_' . $this->get_name(); |
|
| 63 | + $language_files[] = 'plugin_'.$this->get_name(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $settings = $this->get_settings(); |
| 270 | 270 | foreach ($settings as $setting) { |
| 271 | - if ($setting['variable'] == $this->get_name() . '_' . $name) { |
|
| 271 | + if ($setting['variable'] == $this->get_name().'_'.$name) { |
|
| 272 | 272 | |
| 273 | 273 | return $setting['selected_value']; |
| 274 | 274 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if (!empty($this->course_settings)) { |
| 405 | 405 | foreach ($this->course_settings as $setting) { |
| 406 | 406 | $variable = $setting['name']; |
| 407 | - $value =''; |
|
| 407 | + $value = ''; |
|
| 408 | 408 | if (isset($setting['init_value'])) { |
| 409 | 409 | $value = $setting['init_value']; |
| 410 | 410 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | // Avoid Tab Name Spaces |
| 620 | 620 | $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName); |
| 621 | - $subkeytext = "Tabs" . $tabNameNoSpaces; |
|
| 621 | + $subkeytext = "Tabs".$tabNameNoSpaces; |
|
| 622 | 622 | |
| 623 | 623 | // Check if it is already added |
| 624 | 624 | $checkCondition = array( |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // End Check |
| 640 | - $subkey = 'custom_tab_' . $tabNum; |
|
| 640 | + $subkey = 'custom_tab_'.$tabNum; |
|
| 641 | 641 | $attributes = array( |
| 642 | 642 | 'variable' => 'show_tabs', |
| 643 | 643 | 'subkey' => $subkey, |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | // Save the id |
| 657 | 657 | $settings = $this->get_settings(); |
| 658 | - $setData = array ( |
|
| 658 | + $setData = array( |
|
| 659 | 659 | 'comment' => $subkey |
| 660 | 660 | ); |
| 661 | 661 | $whereCondition = array( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | $i = 1; |
| 697 | 697 | foreach ($tabs as $row) { |
| 698 | 698 | $attributes = array( |
| 699 | - 'subkey' => 'custom_tab_' . $i |
|
| 699 | + 'subkey' => 'custom_tab_'.$i |
|
| 700 | 700 | ); |
| 701 | 701 | $this->updateTab($row['subkey'], $attributes); |
| 702 | 702 | $i++; |
@@ -626,7 +626,7 @@ |
||
| 626 | 626 | |
| 627 | 627 | /** |
| 628 | 628 | * Get first SMS plugin name |
| 629 | - * @return string|boolean |
|
| 629 | + * @return string|false |
|
| 630 | 630 | */ |
| 631 | 631 | public function getSMSPluginName() |
| 632 | 632 | { |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | - * @param string $pluginName |
|
| 177 | - * @param int $urlId |
|
| 178 | - */ |
|
| 176 | + * @param string $pluginName |
|
| 177 | + * @param int $urlId |
|
| 178 | + */ |
|
| 179 | 179 | public function uninstall($pluginName, $urlId = null) |
| 180 | 180 | { |
| 181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @param string $region |
|
| 256 | - * @param string $template |
|
| 257 | - * @param bool $forced |
|
| 258 | - * |
|
| 259 | - * @return null|string |
|
| 260 | - */ |
|
| 255 | + * @param string $region |
|
| 256 | + * @param string $template |
|
| 257 | + * @param bool $forced |
|
| 258 | + * |
|
| 259 | + * @return null|string |
|
| 260 | + */ |
|
| 261 | 261 | public function load_region($region, $template, $forced = false) |
| 262 | 262 | { |
| 263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | //extra options |
| 426 | 426 | $plugin_settings = api_get_settings_params( |
| 427 | 427 | array( |
| 428 | - "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting') |
|
| 428 | + "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') |
|
| 429 | 429 | ) |
| 430 | 430 | ); |
| 431 | 431 | $settings_filtered = array(); |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | if (!empty($obj->course_settings)) { |
| 531 | 531 | if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$plugin_name.'.png')) { |
| 532 | 532 | $icon = Display::return_icon( |
| 533 | - $plugin_name . '.png', |
|
| 533 | + $plugin_name.'.png', |
|
| 534 | 534 | Security::remove_XSS($pluginTitle), |
| 535 | 535 | '', |
| 536 | 536 | ICON_SIZE_SMALL |
@@ -126,6 +126,7 @@ discard block |
||
| 126 | 126 | * Returns a temporary url to download files and/or folders. |
| 127 | 127 | * |
| 128 | 128 | * @param string|array $ids |
| 129 | + * @param string $tool |
|
| 129 | 130 | * @return string |
| 130 | 131 | */ |
| 131 | 132 | public static function download_url($ids, $tool) |
@@ -293,7 +294,7 @@ discard block |
||
| 293 | 294 | /** |
| 294 | 295 | * The name of the porfolio where to send. |
| 295 | 296 | * |
| 296 | - * @return type |
|
| 297 | + * @return string |
|
| 297 | 298 | */ |
| 298 | 299 | function get_portfolio() |
| 299 | 300 | { |
@@ -391,7 +392,6 @@ discard block |
||
| 391 | 392 | * Create a "send to portfolio" button |
| 392 | 393 | * |
| 393 | 394 | * @param string $tool The name of the tool: document, work. |
| 394 | - * @param int $c_id The id of the course |
|
| 395 | 395 | * @param int $id The id of the object |
| 396 | 396 | * @param array $attributes Html attributes |
| 397 | 397 | * @return \PortfolioShare |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | /** |
| 406 | 406 | * Returns the current secuirty token. Used to avoid see surfing attacks. |
| 407 | 407 | * |
| 408 | - * @return type |
|
| 408 | + * @return string |
|
| 409 | 409 | */ |
| 410 | 410 | static function security_token() |
| 411 | 411 | { |
@@ -420,6 +420,10 @@ discard block |
||
| 420 | 420 | protected $attributes = array(); |
| 421 | 421 | protected $tool = ''; |
| 422 | 422 | |
| 423 | + /** |
|
| 424 | + * @param string $tool |
|
| 425 | + * @param integer $id |
|
| 426 | + */ |
|
| 423 | 427 | function __construct($tool, $id, $attributes = array()) |
| 424 | 428 | { |
| 425 | 429 | $this->tool = $tool; |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | $attributes['z-index'] = 100000; |
| 483 | 483 | $s = ' '; |
| 484 | 484 | foreach ($attributes as $key => $value) { |
| 485 | - $s .= $key . '="' . $value . '" '; |
|
| 485 | + $s .= $key.'="'.$value.'" '; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | $result = array(); |
| 489 | - $result[] = '<span ' . $s . ' >'; |
|
| 489 | + $result[] = '<span '.$s.' >'; |
|
| 490 | 490 | $result[] = '<span class="dropdown" >'; |
| 491 | 491 | $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">'; |
| 492 | - $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>'; |
|
| 492 | + $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL).'<b class="caret"></b>'; |
|
| 493 | 493 | $result[] = '</a>'; |
| 494 | 494 | $result[] = '<ul class="dropdown-menu">'; |
| 495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | $parameters[PortfolioController::PARAM_TOOL] = $tool; |
| 506 | 506 | $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; |
| 507 | 507 | $result[] = '<li>'; |
| 508 | - $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>'; |
|
| 508 | + $result[] = '<a href="'.$url.'">'.$portfolio->get_title().'</a>'; |
|
| 509 | 509 | $result[] = '</li>'; |
| 510 | 510 | } |
| 511 | 511 | $result[] = '</ul>'; |
@@ -564,8 +564,8 @@ discard block |
||
| 564 | 564 | */ |
| 565 | 565 | public function __construct($portfolio) |
| 566 | 566 | { |
| 567 | - $this->name = md5(__CLASS__) . '_' . $portfolio->get_name(); |
|
| 568 | - $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo') . ' ' . $portfolio->get_name(); |
|
| 567 | + $this->name = md5(__CLASS__).'_'.$portfolio->get_name(); |
|
| 568 | + $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo').' '.$portfolio->get_name(); |
|
| 569 | 569 | $this->portfolio = $portfolio; |
| 570 | 570 | } |
| 571 | 571 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @return array |
|
| 132 | + * @return string[] |
|
| 133 | 133 | */ |
| 134 | 134 | public function get_status_list() |
| 135 | 135 | { |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | /** |
| 273 | 273 | * @param int $id |
| 274 | 274 | * |
| 275 | - * @return bool |
|
| 275 | + * @return null|false |
|
| 276 | 276 | */ |
| 277 | 277 | public function delete($id) |
| 278 | 278 | { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | case 'updated_at': |
| 58 | 58 | break; |
| 59 | 59 | case 'name': |
| 60 | - $val .= ' ' . get_lang('CopyLabelSuffix'); |
|
| 60 | + $val .= ' '.get_lang('CopyLabelSuffix'); |
|
| 61 | 61 | $new[$key] = $val; |
| 62 | 62 | break; |
| 63 | 63 | case 'created_at': |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | break; |
| 67 | 67 | case 'career_id': |
| 68 | 68 | if (!empty($career_id)) { |
| 69 | - $val = (int)$career_id; |
|
| 69 | + $val = (int) $career_id; |
|
| 70 | 70 | } |
| 71 | 71 | $new[$key] = $val; |
| 72 | 72 | break; |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | // Action links |
| 149 | 149 | echo '<div class="actions" style="margin-bottom:20px">'; |
| 150 | - echo '<a href="career_dashboard.php">' . Display::return_icon('back.png', |
|
| 151 | - get_lang('Back'), '', '32') . '</a>'; |
|
| 152 | - echo '<a href="' . api_get_self() . '?action=add">' . Display::return_icon('new_promotion.png', |
|
| 153 | - get_lang('Add'), '', '32') . '</a>'; |
|
| 154 | - echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_add.php">' . Display::return_icon('new_session.png', |
|
| 155 | - get_lang('AddSession'), '', '32') . '</a>'; |
|
| 150 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', |
|
| 151 | + get_lang('Back'), '', '32').'</a>'; |
|
| 152 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_promotion.png', |
|
| 153 | + get_lang('Add'), '', '32').'</a>'; |
|
| 154 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'.Display::return_icon('new_session.png', |
|
| 155 | + get_lang('AddSession'), '', '32').'</a>'; |
|
| 156 | 156 | echo '</div>'; |
| 157 | 157 | echo Display::grid_html('promotions'); |
| 158 | 158 | } |
@@ -15,6 +15,10 @@ |
||
| 15 | 15 | |
| 16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
| 17 | 17 | // thus default return value is always true |
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @param string $handler |
|
| 21 | + */ |
|
| 18 | 22 | public static function hasRight($handler) { |
| 19 | 23 | if (array_key_exists($handler, self::$rights_cache)) |
| 20 | 24 | return self::$rights_cache[$handler]; |
@@ -5,42 +5,42 @@ |
||
| 5 | 5 | * @deprecated Don't use this class |
| 6 | 6 | */ |
| 7 | 7 | class Rights { |
| 8 | - private static $rights_cache = array(); |
|
| 9 | - private static $rights = array ( |
|
| 10 | - 'show_tabs:reports' => |
|
| 11 | - array ( |
|
| 12 | - 'type' => 'const', |
|
| 13 | - 'const' => 'true' ) |
|
| 14 | - ); |
|
| 8 | + private static $rights_cache = array(); |
|
| 9 | + private static $rights = array ( |
|
| 10 | + 'show_tabs:reports' => |
|
| 11 | + array ( |
|
| 12 | + 'type' => 'const', |
|
| 13 | + 'const' => 'true' ) |
|
| 14 | + ); |
|
| 15 | 15 | |
| 16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
| 17 | - // thus default return value is always true |
|
| 18 | - public static function hasRight($handler) { |
|
| 19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | - return self::$rights_cache[$handler]; |
|
| 16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
| 17 | + // thus default return value is always true |
|
| 18 | + public static function hasRight($handler) { |
|
| 19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | + return self::$rights_cache[$handler]; |
|
| 21 | 21 | |
| 22 | - if (!array_key_exists($handler, self::$rights)) |
|
| 23 | - return true; // handler does not exists |
|
| 22 | + if (!array_key_exists($handler, self::$rights)) |
|
| 23 | + return true; // handler does not exists |
|
| 24 | 24 | |
| 25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
| 26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
| 27 | - if (Database::num_rows($result) > 0) |
|
| 28 | - $result = true; |
|
| 29 | - else |
|
| 30 | - $result = false; |
|
| 31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | - $result = self::$rights[$handler]['const']; |
|
| 33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | - $result = self::$rights[$handler]['func'](); |
|
| 35 | - else // handler type not implemented |
|
| 36 | - return true; |
|
| 37 | - self::$rights_cache[$handler] = $result; |
|
| 38 | - return $result; |
|
| 39 | - } |
|
| 25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
| 26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
| 27 | + if (Database::num_rows($result) > 0) |
|
| 28 | + $result = true; |
|
| 29 | + else |
|
| 30 | + $result = false; |
|
| 31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | + $result = self::$rights[$handler]['const']; |
|
| 33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | + $result = self::$rights[$handler]['func'](); |
|
| 35 | + else // handler type not implemented |
|
| 36 | + return true; |
|
| 37 | + self::$rights_cache[$handler] = $result; |
|
| 38 | + return $result; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public static function hasRightClosePageWithError($handler) { |
|
| 42 | - if (hasRight($handler) == false) |
|
| 43 | - die("You are not allowed here"); //FIXME |
|
| 44 | - } |
|
| 41 | + public static function hasRightClosePageWithError($handler) { |
|
| 42 | + if (hasRight($handler) == false) |
|
| 43 | + die("You are not allowed here"); //FIXME |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class Rights { |
| 8 | 8 | private static $rights_cache = array(); |
| 9 | - private static $rights = array ( |
|
| 9 | + private static $rights = array( |
|
| 10 | 10 | 'show_tabs:reports' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'type' => 'const', |
| 13 | 13 | 'const' => 'true' ) |
| 14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
| 16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
| 17 | 17 | // thus default return value is always true |
| 18 | 18 | public static function hasRight($handler) { |
| 19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | - return self::$rights_cache[$handler]; |
|
| 19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
| 20 | + return self::$rights_cache[$handler]; |
|
| 21 | + } |
|
| 21 | 22 | |
| 22 | - if (!array_key_exists($handler, self::$rights)) |
|
| 23 | - return true; // handler does not exists |
|
| 23 | + if (!array_key_exists($handler, self::$rights)) { |
|
| 24 | + return true; |
|
| 25 | + } |
|
| 26 | + // handler does not exists |
|
| 24 | 27 | |
| 25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
| 26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
| 27 | - if (Database::num_rows($result) > 0) |
|
| 28 | - $result = true; |
|
| 29 | - else |
|
| 30 | - $result = false; |
|
| 31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | - $result = self::$rights[$handler]['const']; |
|
| 33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | - $result = self::$rights[$handler]['func'](); |
|
| 35 | - else // handler type not implemented |
|
| 30 | + if (Database::num_rows($result) > 0) { |
|
| 31 | + $result = true; |
|
| 32 | + } else { |
|
| 33 | + $result = false; |
|
| 34 | + } |
|
| 35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
| 36 | + $result = self::$rights[$handler]['const']; |
|
| 37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
| 38 | + $result = self::$rights[$handler]['func'](); |
|
| 39 | + } else { |
|
| 40 | + // handler type not implemented |
|
| 36 | 41 | return true; |
| 42 | + } |
|
| 37 | 43 | self::$rights_cache[$handler] = $result; |
| 38 | 44 | return $result; |
| 39 | 45 | } |
| 40 | 46 | |
| 41 | 47 | public static function hasRightClosePageWithError($handler) { |
| 42 | - if (hasRight($handler) == false) |
|
| 43 | - die("You are not allowed here"); //FIXME |
|
| 48 | + if (hasRight($handler) == false) { |
|
| 49 | + die("You are not allowed here"); |
|
| 50 | + } |
|
| 51 | + //FIXME |
|
| 44 | 52 | } |
| 45 | 53 | |
| 46 | 54 | } |
@@ -71,6 +71,10 @@ |
||
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Get the terms stored at database |
| 74 | + * @param string $prefix |
|
| 75 | + * @param string $course_code |
|
| 76 | + * @param string $tool_id |
|
| 77 | + * @param integer $ref_id |
|
| 74 | 78 | * @return array Array of terms |
| 75 | 79 | */ |
| 76 | 80 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * code |
| 9 | 9 | */ |
| 10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
| 10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
| 11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
| 40 | 40 | return FALSE; |
| 41 | 41 | |
| 42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
| 42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
| 43 | 43 | |
| 44 | 44 | // compare terms |
| 45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // save it to search engine |
| 57 | 57 | foreach ($missing_terms as $term) { |
| 58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
| 58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
| 59 | 59 | } |
| 60 | 60 | foreach ($deprecated_terms as $term) { |
| 61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
| 61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return array Array of terms |
| 75 | 75 | */ |
| 76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
| 77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
| 78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
| 79 | 79 | $prefix_terms = array(); |
| 80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
| 37 | 37 | |
| 38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
| 39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
| 40 | - return FALSE; |
|
| 39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
| 40 | + return FALSE; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
| 43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | $doc = $this->get_document($search_did); |
| 46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
| 47 | 48 | $xterms = array(); |
| 48 | - foreach ($xapian_terms as $xapian_term) |
|
| 49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
| 49 | + foreach ($xapian_terms as $xapian_term) { |
|
| 50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $dterms = $terms; |
| 52 | 54 | |