@@ -43,23 +43,19 @@ discard block |
||
43 | 43 | if(is_object($xml)){ |
44 | 44 | if (is_a($xml, 'DOMElement')) { |
45 | 45 | $this->appendChild($this->importNode($xml, true)); |
46 | - } |
|
47 | - else if (is_a($xml, 'BetterDOMDocument\DOMDoc')) { |
|
46 | + } else if (is_a($xml, 'BetterDOMDocument\DOMDoc')) { |
|
48 | 47 | if ($xml->documentElement) { |
49 | 48 | $this->appendChild($this->importNode($xml->documentElement, true)); |
50 | 49 | } |
51 | 50 | $this->ns = $xml->ns; |
52 | - } |
|
53 | - else if (is_a($xml, 'DOMDocument')) { |
|
51 | + } else if (is_a($xml, 'DOMDocument')) { |
|
54 | 52 | if ($xml->documentElement) { |
55 | 53 | $this->appendChild($this->importNode($xml->documentElement, true)); |
56 | 54 | } |
57 | - } |
|
58 | - else if (method_exists($xml, '__toString')) { |
|
55 | + } else if (method_exists($xml, '__toString')) { |
|
59 | 56 | $this->loadFromString($xml->__toString()); |
60 | 57 | } |
61 | - } |
|
62 | - else if (is_string($xml) && !empty($xml)) { |
|
58 | + } else if (is_string($xml) && !empty($xml)) { |
|
63 | 59 | $this->loadFromString($xml); |
64 | 60 | } |
65 | 61 | |
@@ -113,8 +109,7 @@ discard block |
||
113 | 109 | public function lookupURL($prefix) { |
114 | 110 | if (isset($this->ns[$prefix])) { |
115 | 111 | return $this->ns[$prefix]; |
116 | - } |
|
117 | - else { |
|
112 | + } else { |
|
118 | 113 | return FALSE; |
119 | 114 | } |
120 | 115 | } |
@@ -148,15 +143,13 @@ discard block |
||
148 | 143 | |
149 | 144 | if ($context) { |
150 | 145 | $result = $xob->query($xpath, $context); |
151 | - } |
|
152 | - else { |
|
146 | + } else { |
|
153 | 147 | $result = $xob->query($xpath); |
154 | 148 | } |
155 | 149 | |
156 | 150 | if ($result) { |
157 | 151 | return new DOMList($result, $this); |
158 | - } |
|
159 | - else { |
|
152 | + } else { |
|
160 | 153 | return FALSE; |
161 | 154 | } |
162 | 155 | } |
@@ -180,8 +173,7 @@ discard block |
||
180 | 173 | |
181 | 174 | if (empty($result) || !count($result)) { |
182 | 175 | return FALSE; |
183 | - } |
|
184 | - else { |
|
176 | + } else { |
|
185 | 177 | return $result->item(0); |
186 | 178 | } |
187 | 179 | } |
@@ -260,13 +252,11 @@ discard block |
||
260 | 252 | if ($context->hasChildNodes()) { |
261 | 253 | if ($context->childNodes->length == 1 && $context->firstChild->nodeType == XML_TEXT_NODE) { |
262 | 254 | $array['#text'] = $context->firstChild->nodeValue; |
263 | - } |
|
264 | - else { |
|
255 | + } else { |
|
265 | 256 | foreach ($context->childNodes as $childNode) { |
266 | 257 | if ($childNode->nodeType == XML_ELEMENT_NODE) { |
267 | 258 | $array[$childNode->nodeName][] = $this->getArray($raw, $childNode); |
268 | - } |
|
269 | - elseif ($childNode->nodeType == XML_CDATA_SECTION_NODE) { |
|
259 | + } elseif ($childNode->nodeType == XML_CDATA_SECTION_NODE) { |
|
270 | 260 | $array['#text'] = $childNode->textContent; |
271 | 261 | } |
272 | 262 | } |
@@ -298,8 +288,7 @@ discard block |
||
298 | 288 | $matches = array(); |
299 | 289 | if (preg_match($pattern, $this->saveXML($context), $matches)) { |
300 | 290 | return $matches[1]; |
301 | - } |
|
302 | - else { |
|
291 | + } else { |
|
303 | 292 | return ''; |
304 | 293 | } |
305 | 294 | } |
@@ -445,8 +434,7 @@ discard block |
||
445 | 434 | if ($context->nextSibling) { |
446 | 435 | // $context has an immediate sibling : insert newnode before this one |
447 | 436 | return $context->parentNode->insertBefore($newnode, $context->nextSibling); |
448 | - } |
|
449 | - else { |
|
437 | + } else { |
|
450 | 438 | return $context->parentNode->appendChild($newnode); |
451 | 439 | } |
452 | 440 | } |
@@ -512,11 +500,9 @@ discard block |
||
512 | 500 | foreach($node as $item) { |
513 | 501 | $this->remove($item); |
514 | 502 | } |
515 | - } |
|
516 | - else if (get_class($node) == 'DOMNodeList') { |
|
503 | + } else if (get_class($node) == 'DOMNodeList') { |
|
517 | 504 | $this->remove(new DOMList($node, $this)); |
518 | - } |
|
519 | - else { |
|
505 | + } else { |
|
520 | 506 | $parent = $node->parentNode; |
521 | 507 | $parent->removeChild($node); |
522 | 508 | } |
@@ -538,8 +524,7 @@ discard block |
||
538 | 524 | public function tranform($xsl, $context = NULL) { |
539 | 525 | if (!$context) { |
540 | 526 | $doc = $this; |
541 | - } |
|
542 | - else { |
|
527 | + } else { |
|
543 | 528 | if (is_string($context)) { |
544 | 529 | $context = $this->xpathSingle($context); |
545 | 530 | } |
@@ -590,8 +575,7 @@ discard block |
||
590 | 575 | |
591 | 576 | $transformed = $this->tranform($xsl, $node); |
592 | 577 | return $this->replace($node, $transformed->documentElement); |
593 | - } |
|
594 | - else { |
|
578 | + } else { |
|
595 | 579 | // @@TODO: Report the correct calling file and number |
596 | 580 | throw new Exception("Changing the namespace of a " . get_class($node) . " is not supported"); |
597 | 581 | } |
@@ -676,14 +660,12 @@ discard block |
||
676 | 660 | // Add in xlink options |
677 | 661 | if ($options['xlink'] === TRUE) { |
678 | 662 | $options['xlink'] = "@xlink:type = 'simple'"; |
679 | - } |
|
680 | - else if (empty($options['xlink'])) { |
|
663 | + } else if (empty($options['xlink'])) { |
|
681 | 664 | $options['xlink'] = "false()"; |
682 | 665 | } |
683 | 666 | $xslOptions = str_replace("||xlink||", $options['xlink'], $xslOptions); |
684 | 667 | $transformed = $this->tranform($xslOptions, $context); |
685 | - } |
|
686 | - else { |
|
668 | + } else { |
|
687 | 669 | $transformed = $this->tranform($xslSimple, $context); |
688 | 670 | } |
689 | 671 | |
@@ -719,8 +701,7 @@ discard block |
||
719 | 701 | // Find any of these elements that have no child nodes and are therefore candidates for self-closing, replace them with a self-closed version. |
720 | 702 | $pattern = '<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(\b[^<]*)><\/\1>'; |
721 | 703 | return preg_replace('/' . $pattern . '/', '<$1$2/>', $output); |
722 | - } |
|
723 | - else { |
|
704 | + } else { |
|
724 | 705 | return $this->saveXML($context, LIBXML_NOEMPTYTAG); |
725 | 706 | } |
726 | 707 | } |
@@ -749,8 +730,7 @@ discard block |
||
749 | 730 | // Check up error-checking |
750 | 731 | if ($error_checking == FALSE) { |
751 | 732 | $this->error_checking = 'none'; |
752 | - } |
|
753 | - else { |
|
733 | + } else { |
|
754 | 734 | $this->error_checking = $error_checking; |
755 | 735 | } |
756 | 736 | if ($this->error_checking != 'strict') { |
@@ -791,8 +771,7 @@ discard block |
||
791 | 771 | if ($namespace->prefix != 'xml' && $namespace->nodeValue != 'http://www.w3.org/XML/1998/namespace') { |
792 | 772 | $this->registerNamespace($namespace->prefix, $namespace->nodeValue); |
793 | 773 | } |
794 | - } |
|
795 | - else { |
|
774 | + } else { |
|
796 | 775 | $this->default_ns = $namespace->nodeValue; |
797 | 776 | if (is_string($auto_register_namespaces)) { |
798 | 777 | $this->registerNamespace($auto_register_namespaces, $namespace->nodeValue); |
@@ -823,8 +802,7 @@ discard block |
||
823 | 802 | $this->registerNamespace($tagname, $attr->value); |
824 | 803 | } |
825 | 804 | } |
826 | - } |
|
827 | - else if (substr($attr->name,0,6) == 'xmlns:') { |
|
805 | + } else if (substr($attr->name,0,6) == 'xmlns:') { |
|
828 | 806 | $prefix = substr($attr->name,6); |
829 | 807 | $this->registerNamespace($prefix, $attr->value); |
830 | 808 | } |
@@ -863,12 +841,10 @@ discard block |
||
863 | 841 | } |
864 | 842 | $context = $this->importNode($context->documentElement, TRUE); |
865 | 843 | return; |
866 | - } |
|
867 | - else if (is_a($context, 'DOMDocument')) { |
|
844 | + } else if (is_a($context, 'DOMDocument')) { |
|
868 | 845 | $context = $this->importNode($context->documentElement, TRUE); |
869 | 846 | return; |
870 | - } |
|
871 | - else { |
|
847 | + } else { |
|
872 | 848 | $context = $this->importNode($context, TRUE); |
873 | 849 | return; |
874 | 850 | } |
@@ -880,8 +856,7 @@ discard block |
||
880 | 856 | protected function loadFromString($xml) { |
881 | 857 | if ($this->error_checking == 'none') { |
882 | 858 | @$this->loadXML($xml, LIBXML_COMPACT); |
883 | - } |
|
884 | - else if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
|
859 | + } else if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
|
885 | 860 | trigger_error('BetterDOMDocument\DOMDoc: Could not load: ' . htmlspecialchars($xml), E_USER_WARNING); |
886 | 861 | } |
887 | 862 | } |