Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2010-07-16 16:07:54 +0400
committermattpiwik <matthieu.aubry@gmail.com>2010-07-16 16:07:54 +0400
commitd9852b2ad9a2f814989aee002ca24e95a3b72097 (patch)
treee345edc4c53578fcc984f67cf392ff7edbedb918 /plugins/ExampleAPI
parentf3cac5d4287b340aca83adb4a298e6492e0908a5 (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')
-rw-r--r--plugins/ExampleAPI/API.php18
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.csv21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.html21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.json1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.php1
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.tsv21
-rw-r--r--plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml24
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 '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this:
+ $data = array (
+ 'Limitation' =&gt;
+ array (
+ 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',
+ 1 =&gt; 'Known limitation',
+ ),
+ 'Second Dimension' =&gt;
+ array (
+ 0 =&gt; true,
+ 1 =&gt; false,
+ 2 =&gt; 1,
+ 3 =&gt; 0,
+ 4 =&gt; 152,
+ 5 =&gt; 'test',
+ 6 =&gt;
+ array (
+ 42 =&gt; '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 '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this: <br />
+ $data = array (<br />
+ 'Limitation' =&gt; <br />
+ array (<br />
+ 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',<br />
+ 1 =&gt; 'Known limitation',<br />
+ ),<br />
+ 'Second Dimension' =&gt; <br />
+ array (<br />
+ 0 =&gt; true,<br />
+ 1 =&gt; false,<br />
+ 2 =&gt; 1,<br />
+ 3 =&gt; 0,<br />
+ 4 =&gt; 152,<br />
+ 5 =&gt; 'test',<br />
+ 6 =&gt; <br />
+ array (<br />
+ 42 =&gt; '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 '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this:
+ $data = array (
+ 'Limitation' =&gt;
+ array (
+ 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',
+ 1 =&gt; 'Known limitation',
+ ),
+ 'Second Dimension' =&gt;
+ array (
+ 0 =&gt; true,
+ 1 =&gt; false,
+ 2 =&gt; 1,
+ 3 =&gt; 0,
+ 4 =&gt; 152,
+ 5 =&gt; 'test',
+ 6 =&gt;
+ array (
+ 42 =&gt; '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 '&amp;format=original&amp;serialize=1'; you will get the original php data structure serialized. The data structure looks like this:
+ $data = array (
+ 'Limitation' =&gt;
+ array (
+ 0 =&gt; 'Multi dimensional arrays is only supported by format=JSON',
+ 1 =&gt; 'Known limitation',
+ ),
+ 'Second Dimension' =&gt;
+ array (
+ 0 =&gt; true,
+ 1 =&gt; false,
+ 2 =&gt; 1,
+ 3 =&gt; 0,
+ 4 =&gt; 152,
+ 5 =&gt; 'test',
+ 6 =&gt;
+ array (
+ 42 =&gt; 'end',
+ ),
+ ),
+); " />
+</result> \ No newline at end of file