diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-16 16:07:54 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-16 16:07:54 +0400 |
commit | d9852b2ad9a2f814989aee002ca24e95a3b72097 (patch) | |
tree | e345edc4c53578fcc984f67cf392ff7edbedb918 /plugins/ExampleAPI | |
parent | f3cac5d4287b340aca83adb4a298e6492e0908a5 (diff) |
Refs #1403
Added support for JSON/Serialized PHP export of Multi dimensional arrays in API responses, used by Alert plugin in the UI (json)
git-svn-id: http://dev.piwik.org/svn/trunk@2514 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/ExampleAPI')
7 files changed, 107 insertions, 0 deletions
diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php index 2ffb0bdcc2..6c35269a35 100644 --- a/plugins/ExampleAPI/API.php +++ b/plugins/ExampleAPI/API.php @@ -153,6 +153,24 @@ class Piwik_ExampleAPI_API { return "Check http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything"; } + + /** + * Returns a Multidimensional Array + * Only supported in JSON + * + * @return array + */ + public function getMultiArray() + { + $return = array( + 'Limitation' => array( + "Multi dimensional arrays is only supported by format=JSON", + "Known limitation" + ), + 'Second Dimension' => array( true, false, 1, 0, 152, 'test', array( 42 => 'end') ), + ); + return $return; + } } /** diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv new file mode 100644 index 0000000000..8203371f4e --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv @@ -0,0 +1,21 @@ +Error: Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&format=original&serialize=1'; you will get the original php data structure serialized. The data structure looks like this: + $data = array ( + 'Limitation' => + array ( + 0 => 'Multi dimensional arrays is only supported by format=JSON', + 1 => 'Known limitation', + ), + 'Second Dimension' => + array ( + 0 => true, + 1 => false, + 2 => 1, + 3 => 0, + 4 => 152, + 5 => 'test', + 6 => + array ( + 42 => 'end', + ), + ), +);
\ No newline at end of file diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html new file mode 100644 index 0000000000..24d7c53aef --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html @@ -0,0 +1,21 @@ + Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&format=original&serialize=1'; you will get the original php data structure serialized. The data structure looks like this: <br /> + $data = array (<br /> + 'Limitation' => <br /> + array (<br /> + 0 => 'Multi dimensional arrays is only supported by format=JSON',<br /> + 1 => 'Known limitation',<br /> + ),<br /> + 'Second Dimension' => <br /> + array (<br /> + 0 => true,<br /> + 1 => false,<br /> + 2 => 1,<br /> + 3 => 0,<br /> + 4 => 152,<br /> + 5 => 'test',<br /> + 6 => <br /> + array (<br /> + 42 => 'end',<br /> + ),<br /> + ),<br /> +);
\ No newline at end of file diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json new file mode 100644 index 0000000000..d5d2d57132 --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json @@ -0,0 +1 @@ +{"Limitation":["Multi dimensional arrays is only supported by format=JSON","Known limitation"],"Second Dimension":[true,false,1,0,152,"test",{"42":"end"}]}
\ No newline at end of file diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php new file mode 100644 index 0000000000..02cb8b8afb --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php @@ -0,0 +1 @@ +a:2:{s:10:"Limitation";a:2:{i:0;s:57:"Multi dimensional arrays is only supported by format=JSON";i:1;s:16:"Known limitation";}s:16:"Second Dimension";a:7:{i:0;b:1;i:1;b:0;i:2;i:1;i:3;i:0;i:4;i:152;i:5;s:4:"test";i:6;a:1:{i:42;s:3:"end";}}}
\ No newline at end of file diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv new file mode 100644 index 0000000000..8203371f4e --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv @@ -0,0 +1,21 @@ +Error: Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&format=original&serialize=1'; you will get the original php data structure serialized. The data structure looks like this: + $data = array ( + 'Limitation' => + array ( + 0 => 'Multi dimensional arrays is only supported by format=JSON', + 1 => 'Known limitation', + ), + 'Second Dimension' => + array ( + 0 => true, + 1 => false, + 2 => 1, + 3 => 0, + 4 => 152, + 5 => 'test', + 6 => + array ( + 42 => 'end', + ), + ), +);
\ No newline at end of file diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml new file mode 100644 index 0000000000..bbd47da257 --- /dev/null +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <error message=" Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&format=original&serialize=1'; you will get the original php data structure serialized. The data structure looks like this: + $data = array ( + 'Limitation' => + array ( + 0 => 'Multi dimensional arrays is only supported by format=JSON', + 1 => 'Known limitation', + ), + 'Second Dimension' => + array ( + 0 => true, + 1 => false, + 2 => 1, + 3 => 0, + 4 => 152, + 5 => 'test', + 6 => + array ( + 42 => 'end', + ), + ), +); " /> +</result>
\ No newline at end of file |