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:
authorThomas Steur <thomas.steur@gmail.com>2013-10-03 07:01:17 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-10-03 07:01:17 +0400
commit955ef7c705955f998a39308d527a609165182fb1 (patch)
tree1de8084a42d358751307d3b258bb2fd57d14bc0c /plugins/ExampleUI
parenta963a8707fd0ac6e23e2b7d17848a57c69492727 (diff)
refs #3994 this is an example how to make a customized existing visualization reusable
Diffstat (limited to 'plugins/ExampleUI')
-rw-r--r--plugins/ExampleUI/Controller.php29
-rw-r--r--plugins/ExampleUI/CustomDataTable.php44
2 files changed, 52 insertions, 21 deletions
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php
index fa6c7d39b2..6f7c769d5f 100644
--- a/plugins/ExampleUI/Controller.php
+++ b/plugins/ExampleUI/Controller.php
@@ -23,28 +23,15 @@ class Controller extends \Piwik\Controller
{
public function dataTables()
{
- $view = ViewDataTable::factory('table', 'ExampleUI.getTemperatures', $controllerAction = 'ExampleUI.dataTables');
-
- $view->translations['value'] = "Temperature in °C";
- $view->translations['label'] = "Hour of day";
- $view->filter_sort_column = 'label';
- $view->filter_sort_order = 'asc';
- $view->filter_limit = 24;
- $view->y_axis_unit = '°C'; // useful if the user requests the bar graph
- $view->show_exclude_low_population = false;
- $view->show_table_all_columns = false;
- $view->visualization_properties->setForVisualization(
- 'Piwik\\Plugins\\CoreVisualizations\\Visualizations\\HtmlTable',
- 'disable_row_evolution',
- true
- );
- $view->visualization_properties->setForVisualization(
- 'Piwik\\Plugins\\CoreVisualizations\\Visualizations\\JqplotGraph',
- 'max_graph_elements',
- 24
- );
+ $controllerAction = $this->pluginName . '.' . __FUNCTION__;
+ $apiAction = 'ExampleUI.getTemperatures';
- echo $view->render();
+ /**
+ * this is an example how you can make a custom visualization reusable.
+ */
+ $table = new CustomDataTable();
+
+ echo $table->render('Temperature in °C', 'Hour of day', $apiAction, $controllerAction);
}
public function evolutionGraph()
diff --git a/plugins/ExampleUI/CustomDataTable.php b/plugins/ExampleUI/CustomDataTable.php
new file mode 100644
index 0000000000..d130495a96
--- /dev/null
+++ b/plugins/ExampleUI/CustomDataTable.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik_Plugins
+ * @package ExampleUI
+ */
+
+namespace Piwik\Plugins\ExampleUI;
+
+use Piwik\ViewDataTable;
+
+class CustomDataTable
+{
+ public function render($value, $label, $apiAction, $controllerAction)
+ {
+ $view = ViewDataTable::factory('exampleui-customtable', $apiAction, $controllerAction);
+
+ $view->translations['value'] = $value;
+ $view->translations['label'] = $label;
+ $view->filter_sort_column = 'label';
+ $view->filter_sort_order = 'asc';
+ $view->filter_limit = 24;
+ $view->y_axis_unit = '°C'; // useful if the user requests the bar graph
+ $view->show_exclude_low_population = false;
+ $view->show_table_all_columns = false;
+ $view->visualization_properties->setForVisualization(
+ 'Piwik\\Plugins\\CoreVisualizations\\Visualizations\\HtmlTable',
+ 'disable_row_evolution',
+ true
+ );
+ $view->visualization_properties->setForVisualization(
+ 'Piwik\\Plugins\\CoreVisualizations\\Visualizations\\JqplotGraph',
+ 'max_graph_elements',
+ 24
+ );
+
+ return $view->render();
+ }
+
+} \ No newline at end of file