@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function &createArray($input_xml) { |
25 | 25 | $xml = self::getXMLRoot(); |
26 | - if(is_string($input_xml)) { |
|
26 | + if (is_string($input_xml)) { |
|
27 | 27 | $parsed = $xml->loadXML($input_xml); |
28 | - if(!$parsed) { |
|
28 | + if (!$parsed) { |
|
29 | 29 | throw new \Exception('[XML2Array] Error parsing the XML string.'); |
30 | 30 | } |
31 | 31 | } else { |
32 | - if(get_class($input_xml) != 'DOMDocument') { |
|
32 | + if (get_class($input_xml) != 'DOMDocument') { |
|
33 | 33 | throw new \Exception('[XML2Array] The input XML object should be of type: DOMDocument.'); |
34 | 34 | } |
35 | 35 | $xml = self::$xml = $input_xml; |
36 | 36 | } |
37 | 37 | $array[$xml->documentElement->tagName] = self::convert($xml->documentElement); |
38 | - self::$xml = null; // clear the xml node in the class for 2nd time use. |
|
38 | + self::$xml = null; // clear the xml node in the class for 2nd time use. |
|
39 | 39 | return $array; |
40 | 40 | } |
41 | 41 | /** |
@@ -54,43 +54,43 @@ discard block |
||
54 | 54 | break; |
55 | 55 | case XML_ELEMENT_NODE: |
56 | 56 | // for each child node, call the covert function recursively |
57 | - for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) { |
|
57 | + for ($i = 0, $m = $node->childNodes->length; $i < $m; $i++) { |
|
58 | 58 | $child = $node->childNodes->item($i); |
59 | 59 | $v = self::convert($child); |
60 | - if(isset($child->tagName)) { |
|
60 | + if (isset($child->tagName)) { |
|
61 | 61 | $t = $child->tagName; |
62 | 62 | // assume more nodes of same kind are coming |
63 | - if(!isset($output[$t])) { |
|
63 | + if (!isset($output[$t])) { |
|
64 | 64 | $output[$t] = array(); |
65 | 65 | } |
66 | 66 | $output[$t][] = $v; |
67 | 67 | } else { |
68 | 68 | //check if it is not an empty text node |
69 | - if($v !== '') { |
|
69 | + if ($v !== '') { |
|
70 | 70 | $output = $v; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | - if(is_array($output)) { |
|
74 | + if (is_array($output)) { |
|
75 | 75 | // if only one node of its kind, assign it directly instead if array($value); |
76 | 76 | foreach ($output as $t => $v) { |
77 | - if(is_array($v) && count($v)==1) { |
|
77 | + if (is_array($v) && count($v) == 1) { |
|
78 | 78 | $output[$t] = $v[0]; |
79 | 79 | } |
80 | 80 | } |
81 | - if(empty($output)) { |
|
81 | + if (empty($output)) { |
|
82 | 82 | //for empty nodes |
83 | 83 | $output = ''; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | // loop through the attributes and collect them |
87 | - if($node->attributes->length) { |
|
87 | + if ($node->attributes->length) { |
|
88 | 88 | $a = array(); |
89 | - foreach($node->attributes as $attrName => $attrNode) { |
|
89 | + foreach ($node->attributes as $attrName => $attrNode) { |
|
90 | 90 | $a[$attrName] = (string) $attrNode->value; |
91 | 91 | } |
92 | 92 | // if its an leaf node, store the value in @value instead of directly storing it. |
93 | - if(!is_array($output)) { |
|
93 | + if (!is_array($output)) { |
|
94 | 94 | $output = array('@value' => $output); |
95 | 95 | } |
96 | 96 | $output['@attributes'] = $a; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | /* |
103 | 103 | * Get the root XML node, if there isn't one, create it. |
104 | 104 | */ |
105 | - private static function getXMLRoot(){ |
|
106 | - if(empty(self::$xml)) { |
|
105 | + private static function getXMLRoot() { |
|
106 | + if (empty(self::$xml)) { |
|
107 | 107 | self::init(); |
108 | 108 | } |
109 | 109 | return self::$xml; |
@@ -285,22 +285,22 @@ |
||
285 | 285 | return "DATETIMECMP($params[0]; $params[1])"; |
286 | 286 | break; |
287 | 287 | case ODataConstants::DATETIME_YEAR: |
288 | - return 'EXTRACT(YEAR from '.$params[0].')'; |
|
288 | + return 'EXTRACT(YEAR from ' . $params[0] . ')'; |
|
289 | 289 | break; |
290 | 290 | case ODataConstants::DATETIME_MONTH: |
291 | - return 'EXTRACT(MONTH from '.$params[0].')'; |
|
291 | + return 'EXTRACT(MONTH from ' . $params[0] . ')'; |
|
292 | 292 | break; |
293 | 293 | case ODataConstants::DATETIME_DAY: |
294 | - return 'EXTRACT(DAY from '.$params[0].')'; |
|
294 | + return 'EXTRACT(DAY from ' . $params[0] . ')'; |
|
295 | 295 | break; |
296 | 296 | case ODataConstants::DATETIME_HOUR: |
297 | - return 'EXTRACT(HOUR from '.$params[0].')'; |
|
297 | + return 'EXTRACT(HOUR from ' . $params[0] . ')'; |
|
298 | 298 | break; |
299 | 299 | case ODataConstants::DATETIME_MINUTE: |
300 | - return 'EXTRACT(MINUTE from '.$params[0].')'; |
|
300 | + return 'EXTRACT(MINUTE from ' . $params[0] . ')'; |
|
301 | 301 | break; |
302 | 302 | case ODataConstants::DATETIME_SECOND: |
303 | - return 'EXTRACT(SECOND from '.$params[0].')'; |
|
303 | + return 'EXTRACT(SECOND from ' . $params[0] . ')'; |
|
304 | 304 | break; |
305 | 305 | case ODataConstants::MATHFUN_ROUND: |
306 | 306 | return "ROUND($params[0])"; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $query = 'SELECT * FROM `wp_posts` WHERE' |
190 | 190 | ." wp_posts.post_type = 'post'" |
191 | 191 | ." AND wp_posts.post_status = 'publish'" |
192 | - .' AND wp_posts.ID = '.$namedKeyValues['PostID'][0]; |
|
192 | + .' AND wp_posts.ID = ' . $namedKeyValues['PostID'][0]; |
|
193 | 193 | $stmt = mysql_query($query); |
194 | 194 | |
195 | 195 | //If resource not found return null to the library |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | .' FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt' |
206 | 206 | .' ON tt.term_id = t.term_id' |
207 | 207 | ." WHERE tt.taxonomy = 'post_tag'" |
208 | - .' AND t.term_id = '.$namedKeyValues['TagID'][0]; |
|
208 | + .' AND t.term_id = ' . $namedKeyValues['TagID'][0]; |
|
209 | 209 | $stmt = mysql_query($query); |
210 | 210 | |
211 | 211 | //If resource not found return null to the library |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | .' FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt' |
222 | 222 | .' ON tt.term_id = t.term_id' |
223 | 223 | ." WHERE tt.taxonomy = 'category'" |
224 | - .' AND t.term_id = '.$namedKeyValues['CategoryID'][0]; |
|
224 | + .' AND t.term_id = ' . $namedKeyValues['CategoryID'][0]; |
|
225 | 225 | $stmt = mysql_query($query); |
226 | 226 | |
227 | 227 | //If resource not found return null to the library |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | case 'Comments': |
236 | 236 | $query = 'SELECT * FROM `wp_comments`' |
237 | 237 | .' WHERE comment_approved = 1' |
238 | - .' AND comment_ID = '.$namedKeyValues['CommentID'][0]; |
|
238 | + .' AND comment_ID = ' . $namedKeyValues['CommentID'][0]; |
|
239 | 239 | $stmt = mysql_query($query); |
240 | 240 | |
241 | 241 | //If resource not found return null to the library |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $result = $this->_serializeComment($data); |
248 | 248 | break; |
249 | 249 | case 'Users': |
250 | - $query = 'SELECT * FROM `wp_users` WHERE ID = '.$namedKeyValues['UserID'][0]; |
|
250 | + $query = 'SELECT * FROM `wp_users` WHERE ID = ' . $namedKeyValues['UserID'][0]; |
|
251 | 251 | $stmt = mysql_query($query); |
252 | 252 | |
253 | 253 | //If resource not found return null to the library |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | $result = $this->_serializeComments($stmt); |
346 | 346 | } else { |
347 | - die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
347 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
348 | 348 | } |
349 | 349 | break; |
350 | 350 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | $result = $this->_serializePosts($stmt); |
371 | 371 | } else { |
372 | - die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
372 | + die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
373 | 373 | } |
374 | 374 | break; |
375 | 375 | |
@@ -394,12 +394,12 @@ discard block |
||
394 | 394 | |
395 | 395 | $result = $this->_serializePosts($stmt); |
396 | 396 | } else { |
397 | - die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
397 | + die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
398 | 398 | } |
399 | 399 | break; |
400 | 400 | |
401 | 401 | case $srcClass == 'Comment': |
402 | - die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
402 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
403 | 403 | break; |
404 | 404 | |
405 | 405 | case $srcClass == 'User': |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | |
432 | 432 | $result = $this->_serializeComments($stmt); |
433 | 433 | } else { |
434 | - die('User does not have navigation porperty with name: '.$navigationPropName); |
|
434 | + die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
435 | 435 | } |
436 | 436 | break; |
437 | 437 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | .' ON tr.term_taxonomy_id = tt.term_taxonomy_id' |
485 | 485 | ." WHERE tt.taxonomy IN ('post_tag')" |
486 | 486 | ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
487 | - .' AND tt.term_id = '.$namedKeyValues['TagID'][0]; |
|
487 | + .' AND tt.term_id = ' . $namedKeyValues['TagID'][0]; |
|
488 | 488 | $stmt = mysql_query($query); |
489 | 489 | $result = $this->_serializeTags($stmt); |
490 | 490 | } elseif ($navigationPropName == 'Categories') { |
@@ -496,18 +496,18 @@ discard block |
||
496 | 496 | .' ON tr.term_taxonomy_id = tt.term_taxonomy_id' |
497 | 497 | ." WHERE tt.taxonomy IN ('category')" |
498 | 498 | ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
499 | - .' AND tt.term_id = '.$namedKeyValues['CategoryID'][0]; |
|
499 | + .' AND tt.term_id = ' . $namedKeyValues['CategoryID'][0]; |
|
500 | 500 | $stmt = mysql_query($query); |
501 | 501 | $result = $this->_serializeCategories($stmt); |
502 | 502 | } elseif ($navigationPropName == 'Comments') { |
503 | 503 | $query = 'SELECT * FROM `wp_comments`' |
504 | 504 | .' WHERE comment_approved = 1' |
505 | 505 | ." AND comment_post_ID = $sourceEntityInstance->PostID" |
506 | - .' AND comment_ID = '.$namedKeyValues['CommentID'][0]; |
|
506 | + .' AND comment_ID = ' . $namedKeyValues['CommentID'][0]; |
|
507 | 507 | $stmt = mysql_query($query); |
508 | 508 | $result = $this->_serializeComments($stmt); |
509 | 509 | } else { |
510 | - die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
510 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
511 | 511 | } |
512 | 512 | break; |
513 | 513 | |
@@ -522,11 +522,11 @@ discard block |
||
522 | 522 | ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
523 | 523 | ." AND p.post_type = 'post'" |
524 | 524 | ." AND p.post_status = 'publish'" |
525 | - .' AND p.ID = '.$namedKeyValues['PostID'][0]; |
|
525 | + .' AND p.ID = ' . $namedKeyValues['PostID'][0]; |
|
526 | 526 | $stmt = mysql_query($query); |
527 | 527 | $result = $this->_serializePosts($stmt); |
528 | 528 | } else { |
529 | - die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
529 | + die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
530 | 530 | } |
531 | 531 | break; |
532 | 532 | |
@@ -541,16 +541,16 @@ discard block |
||
541 | 541 | ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
542 | 542 | ." AND p.post_type = 'post'" |
543 | 543 | ." AND p.post_status = 'publish'" |
544 | - .' AND p.ID = '.$namedKeyValues['PostID'][0]; |
|
544 | + .' AND p.ID = ' . $namedKeyValues['PostID'][0]; |
|
545 | 545 | $stmt = mysql_query($query); |
546 | 546 | $result = $this->_serializePosts($stmt); |
547 | 547 | } else { |
548 | - die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
548 | + die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
549 | 549 | } |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case $srcClass == 'Comment': |
553 | - die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
553 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
554 | 554 | break; |
555 | 555 | |
556 | 556 | case $srcClass == 'User': |
@@ -559,18 +559,18 @@ discard block |
||
559 | 559 | ." wp_posts.post_type = 'post'" |
560 | 560 | ." AND wp_posts.post_status = 'publish'" |
561 | 561 | ." AND wp_posts.post_author = $sourceEntityInstance->UserID" |
562 | - .' AND wp_posts.ID = '.$namedKeyValues['PostID'][0]; |
|
562 | + .' AND wp_posts.ID = ' . $namedKeyValues['PostID'][0]; |
|
563 | 563 | $stmt = mysql_query($query); |
564 | 564 | $result = $this->_serializePosts($stmt); |
565 | 565 | } elseif ($navigationPropName == 'Comments') { |
566 | 566 | $query = 'SELECT * FROM `wp_comments`' |
567 | 567 | .' WHERE comment_approved = 1' |
568 | 568 | ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
569 | - .' AND wp_comments.comment_ID = '.$namedKeyValues['CommentID'][0]; |
|
569 | + .' AND wp_comments.comment_ID = ' . $namedKeyValues['CommentID'][0]; |
|
570 | 570 | $stmt = mysql_query($query); |
571 | 571 | $result = $this->_serializeComments($stmt); |
572 | 572 | } else { |
573 | - die('User does not have navigation porperty with name: '.$navigationPropName); |
|
573 | + die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
574 | 574 | } |
575 | 575 | break; |
576 | 576 | } |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $result = null; |
617 | 617 | } |
618 | 618 | } else { |
619 | - die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
619 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
620 | 620 | } |
621 | 621 | break; |
622 | 622 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | $data = mysql_fetch_assoc($stmt); |
652 | 652 | $result = $this->_serializePost($data); |
653 | 653 | } else { |
654 | - die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
654 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
655 | 655 | } |
656 | 656 | break; |
657 | 657 | } |