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>2015-07-03 03:54:27 +0300
committersgiehl <stefan@piwik.org>2015-10-06 18:25:13 +0300
commit9ba8f216fd7856ce5fef06bf82ecb8f8a2e7e630 (patch)
tree6ce07d18a85d00b39ab720abe042361c0775aead /plugins/ExampleUI/Reports
parent8ccc9dc05da021325cdbf141a548637fa52f16b2 (diff)
generate pages instead of implementing them in each controller
Diffstat (limited to 'plugins/ExampleUI/Reports')
-rw-r--r--plugins/ExampleUI/Reports/Base.php19
-rw-r--r--plugins/ExampleUI/Reports/GetPlanetRatios.php74
-rw-r--r--plugins/ExampleUI/Reports/GetPlanetRatiosWithLogos.php44
-rw-r--r--plugins/ExampleUI/Reports/GetTemperatures.php93
-rw-r--r--plugins/ExampleUI/Reports/GetTemperaturesEvolution.php95
5 files changed, 325 insertions, 0 deletions
diff --git a/plugins/ExampleUI/Reports/Base.php b/plugins/ExampleUI/Reports/Base.php
new file mode 100644
index 0000000000..88fa676754
--- /dev/null
+++ b/plugins/ExampleUI/Reports/Base.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\ExampleUI\Reports;
+
+use Piwik\Plugin\Report;
+
+abstract class Base extends Report
+{
+ protected function init()
+ {
+ $this->categoryId = 'ExampleUI_UiFramework';
+ }
+}
diff --git a/plugins/ExampleUI/Reports/GetPlanetRatios.php b/plugins/ExampleUI/Reports/GetPlanetRatios.php
new file mode 100644
index 0000000000..244e8f79c8
--- /dev/null
+++ b/plugins/ExampleUI/Reports/GetPlanetRatios.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\ExampleUI\Reports;
+
+use Piwik\Plugin\Report;
+use Piwik\Plugin\ViewDataTable;
+use Piwik\Plugins\CoreVisualizations\Visualizations\Cloud;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Pie;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\Widget\WidgetsList;
+
+/**
+ * This class defines a new report.
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
+ */
+class GetPlanetRatios extends Base
+{
+ protected function init()
+ {
+ parent::init();
+
+ $this->name = 'Pie graph';
+ $this->subcategoryId = $this->name;
+ $this->order = 112;
+ }
+
+ public function getDefaultTypeViewDataTable()
+ {
+ return PIE::ID;
+ }
+
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ $widgetsList->addWidgetConfig(
+ // in this case it will render PIE as configured as default
+ $factory->createWidget()
+ );
+
+ $widgetsList->addWidgetConfig(
+ $factory->createWidget()
+ ->setName('Simple tag cloud')
+ ->setSubcategoryId('Tag clouds')
+ ->forceViewDataTable(Cloud::ID)
+ ->setOrder(5)
+ );
+ }
+
+ public function configureView(ViewDataTable $view)
+ {
+ $view->config->addTranslation('value', 'times the diameter of Earth');
+
+ if ($view->isViewDataTableId(PIE::ID)) {
+
+ $view->config->columns_to_display = array('value');
+ $view->config->selectable_columns = array('value');
+ $view->config->show_footer_icons = false;
+ $view->config->max_graph_elements = 10;
+
+ } else if ($view->isViewDataTableId(Cloud::ID)) {
+
+ $view->config->columns_to_display = array('label', 'value');
+ $view->config->show_footer = false;
+
+ }
+ }
+
+}
diff --git a/plugins/ExampleUI/Reports/GetPlanetRatiosWithLogos.php b/plugins/ExampleUI/Reports/GetPlanetRatiosWithLogos.php
new file mode 100644
index 0000000000..d4d205e6c9
--- /dev/null
+++ b/plugins/ExampleUI/Reports/GetPlanetRatiosWithLogos.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\ExampleUI\Reports;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Report;
+use Piwik\Plugin\ViewDataTable;
+use Piwik\Plugins\CoreVisualizations\Visualizations\Cloud;
+
+/**
+ * This class defines a new report.
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
+ */
+class GetPlanetRatiosWithLogos extends Base
+{
+ protected function init()
+ {
+ parent::init();
+
+ $this->name = Piwik::translate('Advanced tag cloud: with logos and links');
+ $this->subcategoryId = 'Tag clouds';
+ $this->order = 113;
+ }
+
+ public function getDefaultTypeViewDataTable()
+ {
+ return Cloud::ID;
+ }
+
+ public function configureView(ViewDataTable $view)
+ {
+ $view->config->display_logo_instead_of_label = true;
+ $view->config->columns_to_display = array('label', 'value');
+ $view->config->addTranslation('value', 'times the diameter of Earth');
+ }
+
+}
diff --git a/plugins/ExampleUI/Reports/GetTemperatures.php b/plugins/ExampleUI/Reports/GetTemperatures.php
new file mode 100644
index 0000000000..0449e8b3e2
--- /dev/null
+++ b/plugins/ExampleUI/Reports/GetTemperatures.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\ExampleUI\Reports;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Report;
+use Piwik\Plugin\ViewDataTable;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar;
+use Piwik\Plugin\Manager as PluginManager;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\View;
+use Piwik\Widget\WidgetsList;
+
+/**
+ * This class defines a new report.
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
+ */
+class GetTemperatures extends Base
+{
+ protected function init()
+ {
+ parent::init();
+
+ $this->name = Piwik::translate('ExampleUI_GetTemperaturesDataTable');
+ $this->subcategoryId = 'ExampleUI_GetTemperaturesDataTable';
+ $this->order = 110;
+ }
+
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ // this will render the default view, in this case an Html Table
+ $widgetsList->addWidgetConfig($factory->createWidget());
+
+ $widgetsList->addWidgetConfig(
+ $factory->createWidget()
+ ->forceViewDataTable(Bar::ID)
+ ->setSubcategoryId('Bar graph')
+ );
+
+ if (PluginManager::getInstance()->isPluginActivated('TreemapVisualization')) {
+ $widgetsList->addWidgetConfig(
+ $factory->createWidget()
+ ->setName('Treemap example')
+ ->setSubcategoryId('Treemap')
+ ->forceViewDataTable('infoviz-treemap')
+ );
+
+ }
+ }
+
+ public function configureView(ViewDataTable $view)
+ {
+ if ($view->isViewDataTableId(BAR::ID)) {
+
+ $view->config->y_axis_unit = '°C';
+ $view->config->show_footer = false;
+ $view->config->translations['value'] = "Temperature";
+ $view->config->selectable_columns = array("value");
+ $view->config->max_graph_elements = 24;
+
+ } elseif ($view->isViewDataTableId('infoviz-treemap')) {
+
+ $view->config->translations['value'] = "Temperature";
+ $view->config->columns_to_display = array("label", "value");
+ $view->config->selectable_columns = array("value");
+ $view->config->show_evolution_values = 0;
+
+ } else {
+ // for default view datatable, eg HtmlTable
+
+ $view->config->translations['value'] = 'Temperature in °C';
+ $view->config->translations['label'] = 'Hour of day';
+ $view->requestConfig->filter_sort_column = 'label';
+ $view->requestConfig->filter_sort_order = 'asc';
+ $view->requestConfig->filter_limit = 24;
+ $view->config->columns_to_display = array('label', 'value');
+ $view->config->y_axis_unit = '°C'; // useful if the user requests the bar graph
+ $view->config->show_exclude_low_population = false;
+ $view->config->show_table_all_columns = false;
+ $view->config->disable_row_evolution = true;
+ $view->config->max_graph_elements = 24;
+ $view->config->metrics_documentation = array('value' => 'Documentation for temperature metric');
+ }
+ }
+
+}
diff --git a/plugins/ExampleUI/Reports/GetTemperaturesEvolution.php b/plugins/ExampleUI/Reports/GetTemperaturesEvolution.php
new file mode 100644
index 0000000000..ff8ea66e10
--- /dev/null
+++ b/plugins/ExampleUI/Reports/GetTemperaturesEvolution.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\ExampleUI\Reports;
+
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugin\Report;
+use Piwik\Plugin\ViewDataTable;
+
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Pie;
+use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\View;
+use Piwik\Widget\WidgetsList;
+
+/**
+ * This class defines a new report.
+ *
+ * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
+ */
+class GetTemperaturesEvolution extends Base
+{
+ protected function init()
+ {
+ parent::init();
+
+ $this->name = Piwik::translate('ExampleUI_GetTemperaturesEvolution');
+ $this->order = 111;
+ }
+
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ $widgetsList->addWidgetConfig(
+ $factory->createWidget()
+ ->setSubcategoryId('Sparklines')
+ ->forceViewDataTable(Sparklines::ID)
+ );
+
+ $widgetsList->addWidgetConfig(
+ $factory->createWidget()
+ ->setName('ExampleUI_TemperaturesEvolution')
+ ->setSubcategoryId('Evolution Graph')
+ ->forceViewDataTable(Evolution::ID)
+ ->setParameters(array('columns' => array('server1', 'server2')))
+ );
+
+ }
+
+ /**
+ * Here you can configure how your report should be displayed. For instance whether your report supports a search
+ * etc. You can also change the default request config. For instance change how many rows are displayed by default.
+ *
+ * @param ViewDataTable $view
+ */
+ public function configureView(ViewDataTable $view)
+ {
+ if ($view->isViewDataTableId(Sparklines::ID)) {
+
+ /** @var Sparklines $view */
+ $view->config->addSparklineMetric(array('server1'));
+ $view->config->addSparklineMetric(array('server2'));
+ $view->config->addTranslations(array('server1' => 'Evolution of temperature for server piwik.org'));
+ $view->config->addTranslations(array('server2' => 'Evolution of temperature for server dev.piwik.org'));
+
+ } elseif ($view->isViewDataTableId(Evolution::ID)) {
+
+ /** @var Evolution $view */
+ $selectableColumns = array('server1', 'server2');
+
+ $columns = Common::getRequestVar('columns', false);
+ if (!empty($columns)) {
+ $columns = Piwik::getArrayFromApiParameter($columns);
+ }
+
+ $columns = array_merge($columns ? $columns : array(), $selectableColumns);
+ $view->config->columns_to_display = $columns;
+
+ $view->config->addTranslations(array_combine($columns, $columns));
+ $view->config->selectable_columns = $selectableColumns;
+ $view->requestConfig->filter_sort_column = 'label';
+ $view->requestConfig->filter_sort_order = 'asc';
+ $view->config->documentation = 'My documentation';
+ $view->config->show_goals = false;
+ }
+ }
+
+}