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,57 @@
<?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\ExamplePlugin;
use Piwik\DataTable;
use Piwik\DataTable\Row;
/**
* API for plugin ExamplePlugin
*
* @method static \Piwik\Plugins\ExamplePlugin\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
/**
* Example method. Please remove if you do not need this API method.
* You can call this API method like this:
* /index.php?module=API&method=ExamplePlugin.getAnswerToLife
* /index.php?module=API&method=ExamplePlugin.getAnswerToLife&truth=0
*
* @param bool $truth
*
* @return int
*/
public function getAnswerToLife($truth = true)
{
if ($truth) {
return 42;
}
return 24;
}
/**
* Another example method that returns a data table.
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getExampleReport($idSite, $period, $date, $segment = false)
{
$table = DataTable::makeFromSimpleArray(array(
array('label' => 'My Label 1', 'nb_visits' => '1'),
array('label' => 'My Label 2', 'nb_visits' => '5'),
));
return $table;
}
}

View File

@ -0,0 +1,62 @@
<?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\ExamplePlugin;
/**
* Class Archiver
* @package Piwik\Plugins\ExamplePlugin
*
* Archiver is class processing raw data into ready ro read reports.
* It must implement two methods for aggregating daily reports
* aggregateDayReport() and other for summing daily reports into periods
* like week, month, year or custom range aggregateMultipleReports().
*
* For more detailed information about Archiver please visit Piwik developer guide
* http://developer.piwik.org/api-reference/Piwik/Plugin/Archiver
*/
class Archiver extends \Piwik\Plugin\Archiver
{
/**
* It is a good practice to store your archive names (reports stored in database)
* in Archiver class constants. You can define as many record names as you want
* for your plugin.
*
* Also important thing is that record name must be prefixed with plugin name.
*
* This is only an example record name, so feel free to change it to suit your needs.
*/
const EXAMPLEPLUGIN_ARCHIVE_RECORD = "ExamplePlugin_archive_record";
public function aggregateDayReport()
{
/**
* inside this method you can implement your LogAggreagator usage
* to process daily reports, this one uses idvisitor to group results.
*
* $visitorMetrics = $this
* ->getLogAggregator()
* ->getMetricsFromVisitByDimension('idvisitor')
* ->asDataTable();
* $visitorReport = $visitorMetrics->getSerialized();
* $this->getProcessor()->insertBlobRecord(self::EXAMPLEPLUGIN_ARCHIVE_RECORD, $visitorReport);
*/
}
public function aggregateMultipleReports()
{
/**
* Inside this method you can simply point daily records
* to be summed. This work for most cases.
* However if needed, also custom queries can be implemented
* for periods to achieve more acurrate results.
*
* $this->getProcessor()->aggregateDataTableRecords(self::EXAMPLEPLUGIN_ARCHIVE_RECORD);
*/
}
}

View File

@ -0,0 +1,3 @@
## Changelog
Here goes the changelog text.

View File

@ -0,0 +1,28 @@
<?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\ExamplePlugin;
use Piwik\View;
/**
* A controller lets you for example create a page that can be added to a menu. For more information read our guide
* http://developer.piwik.org/guides/mvc-in-piwik or have a look at the our API references for controller and view:
* http://developer.piwik.org/api-reference/Piwik/Plugin/Controller and
* http://developer.piwik.org/api-reference/Piwik/View
*/
class Controller extends \Piwik\Plugin\Controller
{
public function index()
{
// Render the Twig template templates/index.twig and assign the view variable answerToLife to the view.
return $this->renderTemplate('index', array(
'answerToLife' => 42
));
}
}

View File

@ -0,0 +1,13 @@
<?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\ExamplePlugin;
class ExamplePlugin extends \Piwik\Plugin
{
}

View File

@ -0,0 +1,36 @@
<?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\ExamplePlugin;
use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuTop;
/**
* This class allows you to add, remove or rename menu items.
* To configure a menu (such as Admin Menu, Top Menu, User Menu...) simply call the corresponding methods as
* described in the API-Reference http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract
*/
class Menu extends \Piwik\Plugin\Menu
{
public function configureTopMenu(MenuTop $menu)
{
// $menu->addItem('ExamplePlugin_MyTopItem', null, $this->urlForDefaultAction(), $orderId = 30);
}
public function configureAdminMenu(MenuAdmin $menu)
{
// reuse an existing category. Execute the showList() method within the controller when menu item was clicked
// $menu->addManageItem('ExamplePlugin_MyUserItem', $this->urlForAction('showList'), $orderId = 30);
// $menu->addPlatformItem('ExamplePlugin_MyUserItem', $this->urlForDefaultAction(), $orderId = 30);
// or create a custom category
// $menu->addItem('CoreAdminHome_MenuManage', 'ExamplePlugin_MyUserItem', $this->urlForDefaultAction(), $orderId = 30);
}
}

View File

@ -0,0 +1,6 @@
# Matomo ExamplePlugin Plugin
## Description
Add your plugin description here.

View File

@ -0,0 +1,37 @@
<?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\ExamplePlugin;
class Tasks extends \Piwik\Plugin\Tasks
{
public function schedule()
{
$this->hourly('myTask'); // method will be executed once every hour
$this->daily('myTask'); // method will be executed once every day
$this->weekly('myTask'); // method will be executed once every week
$this->monthly('myTask'); // method will be executed once every month
// pass a parameter to the task
$this->weekly('myTaskWithParam', 'anystring');
// specify a different priority
$this->monthly('myTask', null, self::LOWEST_PRIORITY);
$this->monthly('myTaskWithParam', 'anystring', self::HIGH_PRIORITY);
}
public function myTask()
{
// do something
}
public function myTaskWithParam($param)
{
// do something
}
}

View File

@ -0,0 +1,68 @@
<?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\ExamplePlugin\Updates;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
use Piwik\Updater\Migration;
use Piwik\Updater\Migration\Factory as MigrationFactory;
/**
* Update for version 0.0.2.
*/
class Updates_0_0_2 extends PiwikUpdates
{
/**
* @var MigrationFactory
*/
private $migration;
public function __construct(MigrationFactory $factory)
{
$this->migration = $factory;
}
/**
* Return database migrations to be executed in this update.
*
* Database migrations should be defined here, instead of in `doUpdate()`, since this method is used
* in the `core:update` command when displaying the queries an update will run. If you execute
* migrations directly in `doUpdate()`, they won't be displayed to the user. Migrations will be executed in the
* order as positioned in the returned array.
*
* @param Updater $updater
* @return Migration\Db[]
*/
public function getMigrations(Updater $updater)
{
// many different migrations are available to be used via $this->migration factory
$migration1 = $this->migration->db->changeColumnType('log_visit', 'example', 'BOOLEAN NOT NULL');
// you can also define custom SQL migrations. If you need to bind parameters, use `->boundSql()`
$migration2 = $this->migration->db->sql($sqlQuery = 'SELECT 1');
return array(
// $migration1,
// $migration2
);
}
/**
* Perform the incremental version update.
*
* This method should perform all updating logic. If you define queries in the `getMigrations()` method,
* you must call {@link Updater::executeMigrations()} here.
*
* @param Updater $updater
*/
public function doUpdate(Updater $updater)
{
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));
}
}

View File

@ -0,0 +1,79 @@
<?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\ExamplePlugin\Widgets;
use Piwik\Widget\Widget;
use Piwik\Widget\WidgetConfig;
use Piwik\View;
/**
* This class allows you to add your own widget to the Piwik platform. In case you want to remove widgets from another
* plugin please have a look at the "configureWidgetsList()" method.
* To configure a widget simply call the corresponding methods as described in the API-Reference:
* http://developer.piwik.org/api-reference/Piwik/Plugin\Widget
*/
class MyExampleWidget extends Widget
{
public static function configure(WidgetConfig $config)
{
/**
* Set the category the widget belongs to. You can reuse any existing widget category or define
* your own category.
*/
$config->setCategoryId('About Matomo');
/**
* Set the subcategory the widget belongs to. If a subcategory is set, the widget will be shown in the UI.
*/
// $config->setSubcategoryId('General_Overview');
/**
* Set the name of the widget belongs to.
*/
$config->setName('Example Widget Name');
/**
* Set the order of the widget. The lower the number, the earlier the widget will be listed within a category.
*/
$config->setOrder(99);
/**
* Optionally set URL parameters that will be used when this widget is requested.
* $config->setParameters(array('myparam' => 'myvalue'));
*/
/**
* Define whether a widget is enabled or not. For instance some widgets might not be available to every user or
* might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then
* set `true` or `false`. If your widget is only available to users having super user access you can do the
* following:
*
* $config->setIsEnabled(\Piwik\Piwik::hasUserSuperUserAccess());
* or
* if (!\Piwik\Piwik::hasUserSuperUserAccess())
* $config->disable();
*/
}
/**
* This method renders the widget. It's on you how to generate the content of the widget.
* As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a
* twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the
* "templates" directory of your plugin.
*
* @return string
*/
public function render()
{
// or: return $this->renderTemplate('myViewTemplate', array(...view variables...));
return '<div class="widgetBody">My Widget Text</div>';
}
}

View File

@ -0,0 +1,23 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
(function () {
angular.module('piwikApp').controller('ComponentController', ComponentController);
ComponentController.$inject = [];
function ComponentController() {
// remember to keep controller very simple. Create a service/factory (model) if needed
var vm = this;
vm.myProperty = 'component';
vm.doSomething = doSomething;
function doSomething() {
}
}
})();

View File

@ -0,0 +1,3 @@
<div class="componentClass">
{{ componentAs.myProperty }}
</div>

View File

@ -0,0 +1,44 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Usage:
* <div piwik-component>
*/
(function () {
angular.module('piwikApp').directive('piwikComponent', piwikComponent);
piwikComponent.$inject = ['piwik'];
function piwikComponent(piwik){
var defaults = {
// showAllSitesItem: 'true'
};
return {
restrict: 'A',
scope: {
// showAllSitesItem: '<'
},
templateUrl: 'plugins/ExamplePlugin/angularjs/directive-component/component.directive.html?cb=' + piwik.cacheBuster,
controller: 'ComponentController',
controllerAs: 'componentAs',
compile: function (element, attrs) {
for (var index in defaults) {
if (defaults.hasOwnProperty(index) && attrs[index] === undefined) {
attrs[index] = defaults[index];
}
}
return function (scope, element, attrs) {
};
}
};
}
})();

View File

@ -0,0 +1,3 @@
.componentClass {
// ...
}

View File

@ -0,0 +1,3 @@
<div class="componentClass">
{{ componentAs.myProperty }}
</div>

View File

@ -0,0 +1,34 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Usage:
* <piwik-example-component>
*/
(function () {
angular.module('piwikApp').component('piwikComponent', {
templateUrl: 'plugins/ExamplePlugin/angularjs/example-component/example-component.component.html?cb=' + piwik.cacheBuster,
bindings: {
// showAllSitesItem: '<'
},
controller: ComponentController
});
ComponentController.$inject = [];
function ComponentController() {
// remember to keep controller very simple. Create a service/factory (model) if needed
var vm = this;
vm.myProperty = 'component';
vm.doSomething = doSomething;
function doSomething() {
}
}
})();

View File

@ -0,0 +1,3 @@
.componentClass {
// ...
}

View File

@ -0,0 +1,5 @@
## FAQ
__My question?__
My answer

View File

@ -0,0 +1 @@
## Documentation

View File

@ -0,0 +1,20 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
$(document).ready(function () {
/**
* Please note that this JavaScript file will be loaded only if you
* enable the following setting in your config:
*
* [Development]
* disable_merged_assets = 1
*/
if('undefined' != (typeof console)) { /* IE9 has no console */
console.log('Plugin file loaded');
}
});

View File

@ -0,0 +1,29 @@
{
"name": "ExamplePlugin",
"description": "Matomo Platform showcase: how to create widgets, menus, scheduled tasks, a custom archiver, plugin tests, and an AngularJS component.",
"version": "0.1.0",
"theme": false,
"require": {
"piwik": ">=3.0.0-b1,<4.0.0-b1"
},
"authors": [
{
"name": "Matomo",
"email": "",
"homepage": ""
}
],
"support": {
"email": "",
"issues": "",
"forum": "",
"irc": "",
"wiki": "",
"source": "",
"docs": "",
"rss": ""
},
"homepage": "",
"license": "GPL v3+",
"keywords": []
}

View File

@ -0,0 +1,8 @@
{% extends 'dashboard.twig' %}
{% block content %}
<strong>Hello world!</strong>
<br/>
The answer to life is {{ answerToLife }}
{% endblock %}