update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -1 +0,0 @@
tests/processed/*xml

View file

@ -1,42 +0,0 @@
language: php
php:
- 5.3
env:
matrix:
- TEST_SUITE=CoreTests MYSQL_ADAPTER=PDO_MYSQL
- TEST_SUITE=PluginTests MYSQL_ADAPTER=PDO_MYSQL
script: ./travis.sh
install:
- TEST_PIWIK_VERSION=$(wget builds.piwik.org/LATEST -q -O -)
- TEST_PIWIK_VERSION=`echo $TEST_PIWIK_VERSION | tr -d ' ' | tr -d '\n'`
- mkdir ExamplePlugin
- cp -R !(ExamplePlugin) ExamplePlugin
- cp -R .git/ ExamplePlugin/
- git clone https://github.com/piwik/piwik.git piwik
- cd piwik
- git checkout "$TEST_PIWIK_VERSION"
- git submodule init
- git submodule update || true
- composer self-update
- composer install
- rm -rf plugins/ExamplePlugin
- cd ../
- mv ExamplePlugin piwik/plugins
before_script:
- cd piwik
- uname -a
- date
- mysql -e 'create database piwik_tests;'
- ./tests/travis/prepare.sh
- ./tests/travis/setup_webserver.sh
- wget https://raw.github.com/piwik/piwik-tests-plugins/master/activateplugin.php
- php activateplugin.php ExamplePlugin
- cd tests/PHPUnit
after_script:
- cat /var/log/nginx/error.log

View file

@ -1,13 +1,16 @@
<?php
/**
* Piwik - Open source web analytics
* 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
*
@ -19,11 +22,11 @@ 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
* /index.php?module=API&method=ExamplePlugin.getAnswerToLife&truth=0
*
* @param bool $truth
*
* @return bool
* @return int
*/
public function getAnswerToLife($truth = true)
{
@ -33,4 +36,22 @@ class API extends \Piwik\Plugin\API
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

@ -1,27 +1,28 @@
<?php
/**
* Piwik - Open source web analytics
* 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 let's 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()
{
$view = new View('@ExamplePlugin/index.twig');
$this->setBasicVariablesView($view);
$view->answerToLife = '42';
return $view->render();
// 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

@ -1,29 +1,13 @@
<?php
/**
* Piwik - Open source web analytics
* 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
{
/**
* @see Piwik\Plugin::getListHooksRegistered
*/
public function getListHooksRegistered()
{
return array(
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
);
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = 'plugins/ExamplePlugin/javascripts/plugin.js';
}
}

View file

@ -0,0 +1,58 @@
<?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\MenuReporting;
use Piwik\Menu\MenuTop;
use Piwik\Menu\MenuUser;
/**
* This class allows you to add, remove or rename menu items.
* To configure a menu (such as Admin Menu, Reporting 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 configureReportingMenu(MenuReporting $menu)
{
// reuse an existing category. Execute the showList() method within the controller when menu item was clicked
// $menu->addVisitorsItem('Report 1', $this->urlForAction('showList'), $orderId = 30);
// $menu->addActionsItem('Report 1', $this->urlForAction('showList'), $orderId = 30);
// or create a custom category 'UI Framework'
// $menu->addItem('UI Framework', '', $this->urlForDefaultAction(), $orderId = 30);
// $menu->addItem('UI Framework', 'Report 1', $this->urlForAction('showList'), $orderId = 30);
}
public function configureAdminMenu(MenuAdmin $menu)
{
// reuse an existing category
// $menu->addSettingsItem('My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
// $menu->addPlatformItem('My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
// or create a custom category
// $menu->addItem('General_Settings', 'My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
}
public function configureTopMenu(MenuTop $menu)
{
// $menu->addItem('My Top Item', null, $this->urlForDefaultAction(), $orderId = 30);
}
public function configureUserMenu(MenuUser $menu)
{
// reuse an existing category. Execute the showList() method within the controller when menu item was clicked
// $menu->addManageItem('My User Item', $this->urlForAction('showList'), $orderId = 30);
// $menu->addPlatformItem('My User Item', $this->urlForDefaultAction(), $orderId = 30);
// or create a custom category
// $menu->addItem('CoreAdminHome_MenuManage', 'My User Item', $this->urlForDefaultAction(), $orderId = 30);
}
}

View file

@ -7,6 +7,7 @@ Add your plugin description here.
## FAQ
__My question?__
My answer
## Changelog
@ -15,4 +16,4 @@ Here goes the changelog text.
## Support
Please direct any feedback to ...
Please direct any feedback to ...

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,63 @@
<?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\Common;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
/**
* Update for version 0.0.2.
*/
class Updates_0_0_2 extends PiwikUpdates
{
/**
* Return SQL to be executed in this update.
*
* SQL queries 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
* queries directly in `doUpdate()`, they won't be displayed to the user.
*
* @param Updater $updater
* @return array ```
* array(
* 'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
* 'ALTER .... ' => false, // if an error occurs, the update will stop and fail
* // and user will have to manually run the query
* )
* ```
*/
public function getMigrationQueries(Updater $updater)
{
$errorCodesToIgnore = array(1060);
$tableName = Common::prefixTable('log_visit');
$updateSql = "ALTER TABLE `" . $tableName . "` CHANGE `example` `example` BOOLEAN NOT NULL";
return array(
// $updateSql => $errorCodesToIgnore
);
}
/**
* Perform the incremental version update.
*
* This method should preform all updating logic. If you define queries in an overridden `getMigrationQueries()`
* method, you must call {@link Updater::executeMigrationQueries()} here.
*
* See {@link Updates} for an example.
*
* @param Updater $updater
*/
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,67 @@
<?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;
use Piwik\WidgetsList;
/**
* This class allows you to add your own widgets 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\Widgets
*/
class Widgets extends \Piwik\Plugin\Widgets
{
/**
* Here you can define the category the widget belongs to. You can reuse any existing widget category or define
* your own category.
* @var string
*/
protected $category = 'Example Category';
/**
* Here you can add one or multiple widgets. You can add a widget by calling the method "addWidget()" and pass the
* name of the widget as well as a method name that should be called to render the widget. The method can be
* defined either directly here in this widget class or in the controller in case you want to reuse the same action
* for instance in the menu etc.
*/
protected function init()
{
// $this->addWidget('Example Widget Name', $method = 'myExampleWidget');
// $this->addWidget('Example Widget 2', $method = 'myExampleWidget', $params = array('myparam' => 'myvalue'));
}
/**
* This method renders a widget as defined in "init()". 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 myExampleWidget()
{
// $view = new View('@ExamplePlugin/myViewTemplate');
// return $view->render();
return 'My Widget Text';
}
/**
* Here you can remove any widgets defined by any plugin.
*
* @param WidgetsList $widgetsList
*/
public function configureWidgetsList(WidgetsList $widgetsList)
{
// $widgetsList->remove('NameOfWidgetCategory'); // will remove all widgets having this category
// $widgetsList->remove('NameOfWidgetCategory', 'Widget name'); // will only remove a specific widget
}
}

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

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,7 +10,7 @@ $(document).ready(function () {
* Please note that this JavaScript file will be loaded only if you
* enable the following setting in your config:
*
* [Debug]
* [Development]
* disable_merged_assets = 1
*/

View file

@ -1,13 +1,19 @@
{
"name": "ExamplePlugin",
"version": "0.1.0",
"description": "ExampleDescription",
"theme": false,
"authors": [
{
"name": "Piwik",
"email": "",
"homepage": ""
}
]
"name": "ExamplePlugin",
"version": "0.1.0",
"description": "Piwik Platform showcase: how to create widgets, menus, scheduled tasks, a custom archiver, plugin tests, and a AngularJS component.",
"theme": false,
"require": {
"piwik": ">=PIWIK_VERSION"
},
"authors": [
{
"name": "Piwik",
"email": "",
"homepage": ""
}
],
"homepage": "",
"license": "GPL v3+",
"keywords": []
}

View file

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