PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,103 @@
<?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;
use Piwik\DataTable;
use Piwik\Date;
use Piwik\Period\Range;
/**
* ExampleUI API is also an example API useful if you are developing a Matomo plugin.
*
* The functions listed in this API are returning the data used in the Controller to draw graphs and
* display tables. See also the ExampleAPI plugin for an introduction to Matomo APIs.
*
* @method static \Piwik\Plugins\ExampleUI\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
public static $disableRandomness = false;
public function getTemperaturesEvolution($date, $period)
{
$temperatures = array();
$date = Date::factory('2013-10-10', 'UTC');
$period = new Range($period, 'last30');
$period->setDefaultEndDate($date);
foreach ($period->getSubperiods() as $subPeriod) {
if (self::$disableRandomness) {
$server1 = 50;
$server2 = 40;
} else {
$server1 = mt_rand(50, 90);
$server2 = mt_rand(40, 110);
}
$value = array('server1' => $server1, 'server2' => $server2);
$temperatures[$subPeriod->getLocalizedShortString()] = $value;
}
return DataTable::makeFromIndexedArray($temperatures);
}
public function getTemperatures()
{
$xAxis = array(
'0h', '1h', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', '11h',
'12h', '13h', '14h', '15h', '16h', '17h', '18h', '19h', '20h', '21h', '22h', '23h',
);
$temperatureValues = array_slice(range(50, 90), 0, count($xAxis));
if (!self::$disableRandomness) {
shuffle($temperatureValues);
}
$temperatures = array();
foreach ($xAxis as $i => $xAxisLabel) {
$temperatures[$xAxisLabel] = $temperatureValues[$i];
}
return DataTable::makeFromIndexedArray($temperatures);
}
public function getPlanetRatios()
{
$planetRatios = array(
'Mercury' => 0.382,
'Venus' => 0.949,
'Earth' => 1.00,
'Mars' => 0.532,
'Jupiter' => 11.209,
'Saturn' => 9.449,
'Uranus' => 4.007,
'Neptune' => 3.883,
);
return DataTable::makeFromIndexedArray($planetRatios);
}
public function getPlanetRatiosWithLogos()
{
$planetsDataTable = $this->getPlanetRatios();
foreach ($planetsDataTable->getRows() as $row) {
$logo = sprintf('plugins/ExampleUI/images/icons-planet/%s.png', strtolower($row->getColumn('label')));
$url = sprintf('http://en.wikipedia.org/wiki/%s', $row->getColumn('label'));
$row->addMetadata('logo', $logo);
$row->addMetadata('url', $url);
}
return $planetsDataTable;
}
}

View File

@ -0,0 +1,17 @@
<?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\Categories;
use Piwik\Category\Category;
class ExampleUiCategory extends Category
{
protected $id = 'ExampleUI_UiFramework';
protected $order = 90;
}

View File

@ -0,0 +1,49 @@
<?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;
use Piwik\Common;
use Piwik\Notification;
use Piwik\Piwik;
use Piwik\View;
use Piwik\ViewDataTable\Factory as ViewDataTableFactory;
/**
*/
class Controller extends \Piwik\Plugin\Controller
{
public function notifications()
{
$notification = new Notification('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
Notification\Manager::notify('ExampleUI_InfoSimple', $notification);
$notification = new Notification('Neque porro quisquam est qui dolorem ipsum quia dolor sit amet.');
$notification->title = 'Warning:';
$notification->context = Notification::CONTEXT_WARNING;
$notification->flags = null;
Notification\Manager::notify('ExampleUI_warningWithClose', $notification);
$notification = new Notification('Phasellus tincidunt arcu at justo faucibus, et lacinia est accumsan. ');
$notification->title = 'Well done';
$notification->context = Notification::CONTEXT_SUCCESS;
$notification->type = Notification::TYPE_TOAST;
Notification\Manager::notify('ExampleUI_successToast', $notification);
$notification = new Notification('Phasellus tincidunt arcu at justo <a href="#">faucibus</a>, et lacinia est accumsan. ');
$notification->raw = true;
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('ExampleUI_error', $notification);
$view = new View('@ExampleUI/notifications');
$this->setGeneralVariablesView($view);
return $view->render();
}
}

View File

@ -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;
use Piwik\Menu\MenuAdmin;
class Menu extends \Piwik\Plugin\Menu
{
public function configureAdminMenu(MenuAdmin $menu)
{
$menu->addPlatformItem('ExampleUI_UiNotifications', $this->urlForAction('notifications'), $order = 10);
}
}

View File

@ -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';
}
}

View File

@ -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;
}
}
}

View File

@ -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');
}
}

View File

@ -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');
}
}
}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,3 @@
Author : Dan Wiersema
License: Free for non-commercial use.
http://www.iconspedia.com/icon/neptune-4672.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,9 @@
{
"ExampleUI": {
"UiFramework": "UI Framework",
"UiNotifications": "UI Notifications",
"GetTemperaturesDataTable": "Data tables",
"GetTemperaturesEvolution": "Temperatures evolution over time",
"TemperaturesEvolution": "Evolution of server temperatures over the last few days"
}
}

View File

@ -0,0 +1,24 @@
{
"name": "ExampleUI",
"description": "Matomo Platform showcase: how to display data tables, graphs, and the UI framework.",
"version": "1.0.1",
"keywords": [
"example",
"framework",
"platform",
"ui",
"visualization"
],
"homepage": "http:\/\/piwik.org",
"license": "GPL v3+",
"authors": [
{
"name": "Matomo",
"email": "hello@matomo.org",
"homepage": "http:\/\/matomo.org"
}
],
"require": {
"piwik": ">=3.3.0"
}
}

View File

@ -0,0 +1,3 @@
<h2>Evolution of server temperatures over the last few days</h2>
{{ evolutionGraph|raw }}

View File

@ -0,0 +1,16 @@
{% extends 'admin.twig' %}
{% set title %}UI Notification demo{% endset %}
{% block content %}
<h2>Inline notification example</h2>
<div style="display:inline-block;margin-top:10px;" id="exampleUI_notifications">
<div piwik-notification
notification-title="Info:"
noclear="true"
context="info">
This is an example for an inline notification. Have you noticed the success message disappeared after a few seconds?
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
<div class="sparkline">
{{ sparkline(urlSparkline1) }}
Evolution of temperature for server matomo.org
</div>
<div class="sparkline">
{{ sparkline(urlSparkline2) }}
Evolution of temperature for server developer.matomo.org
</div>