@@ -15,56 +15,56 @@ class UtilityComponent extends AppComponent
15
15
{
16
16
17
17
/**
18
- * The main function for converting to an XML document.
19
- * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
20
- *
21
- * @param array $data
22
- * @param string $rootNodeName - what you want the root node to be - defaultsto data.
23
- * @param SimpleXMLElement $xml - should only be used recursively
24
- * @return string XML
25
- */
26
- public function toXml ($ data , $ rootNodeName = 'data ' , $ xml= null )
18
+ * The main function for converting to an XML document.
19
+ * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
20
+ *
21
+ * @param array $data
22
+ * @param string $rootNodeName - what you want the root node to be - defaultsto data.
23
+ * @param SimpleXMLElement $xml - should only be used recursively
24
+ * @return string XML
25
+ */
26
+ public function toXml ($ data , $ rootNodeName = 'data ' , $ xml = null )
27
27
{
28
- // turn off compatibility mode as simple xml throws a wobbly if you don't.
29
- if (ini_get ('zend.ze1_compatibility_mode ' ) == 1 )
28
+ // turn off compatibility mode as simple xml throws a wobbly if you don't.
29
+ if (ini_get ('zend.ze1_compatibility_mode ' ) == 1 )
30
30
{
31
- ini_set ('zend.ze1_compatibility_mode ' , 0 );
31
+ ini_set ('zend.ze1_compatibility_mode ' , 0 );
32
32
}
33
33
34
- if ($ xml == null )
34
+ if ($ xml == null )
35
35
{
36
- $ xml = simplexml_load_string ("<?xml version='1.0' encoding='utf-8'?>< $ rootNodeName /> " );
36
+ $ xml = simplexml_load_string ("<?xml version='1.0' encoding='utf-8'?>< " . $ rootNodeName. " /> " );
37
37
}
38
38
39
- // loop through the data passed in.
40
- foreach ($ data as $ key => $ value )
39
+ // loop through the data passed in.
40
+ foreach ($ data as $ key => $ value )
41
41
{
42
- // no numeric keys in our xml please!
43
- if (is_numeric ($ key ))
42
+ // no numeric keys in our xml please!
43
+ if (is_numeric ($ key ))
44
44
{
45
- // make string key...
46
- $ key = "unknownNode_ " . (string ) $ key ;
45
+ // make string key...
46
+ $ key = "unknownNode_ " . (string ) $ key ;
47
47
}
48
48
49
- // replace anything not alpha numeric
50
- $ key = preg_replace ('/[^a-z]/i ' , '' , $ key );
49
+ // replace anything not alpha numeric
50
+ $ key = preg_replace ('/[^a-z]/i ' , '' , $ key );
51
51
52
- // if there is another array found recrusively call this function
53
- if (is_array ($ value ))
52
+ // if there is another array found recrusively call this function
53
+ if (is_array ($ value ))
54
54
{
55
- $ node = $ xml ->addChild ($ key );
56
- // recrusive call.
57
- $ this ->toXml ($ value , $ rootNodeName , $ node );
55
+ $ node = $ xml ->addChild ($ key );
56
+ // recrusive call.
57
+ $ this ->toXml ($ value , $ rootNodeName , $ node );
58
58
}
59
- else
59
+ else
60
60
{
61
- // add single node.
61
+ // add single node.
62
62
$ value = htmlentities ($ value );
63
- $ xml ->addChild ($ key ,$ value );
63
+ $ xml ->addChild ($ key , $ value );
64
64
}
65
65
}
66
- // pass back as string. or simple xml object if you want!
67
- return $ xml ->asXML ();
66
+ // pass back as string. or simple xml object if you want!
67
+ return $ xml ->asXML ();
68
68
}
69
69
/** Get all the modules */
70
70
public function getAllModules ()
0 commit comments