custom report WIP, declared a 1.0.0 version

This commit is contained in:
Alexander Yakovlev 2018-12-06 22:28:59 +07:00
parent fa6c8be2ca
commit 59de8336d1
10 changed files with 296 additions and 166 deletions

38
API.php Normal file
View file

@ -0,0 +1,38 @@
<?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\ClickHeat;
use Piwik\DataTable;
use Piwik\DataTable\Row;
/**
* API for plugin ClickHeat
*
* @method static \Piwik\Plugins\ClickHeat\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
/**
* 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 getClickHeatmap($idSite, $period, $date, $segment = false)
{
$table = new DataTable();
$table->addRowFromArray(array(Row::COLUMNS => array('nb_visits' => 5)));
return $table;
}
}

View file

@ -9,3 +9,4 @@
* rename clickheat.php to clickheat_config.php (Windows mixes up ClickHeat.php with clickheat.php)
* 0.1.7 fixed bug
* 0.1.9 fixed bug
* 1.0.0 Matomo 3.7 upgrade

View file

@ -13,23 +13,24 @@
namespace Piwik\Plugins\ClickHeat;
use Piwik\Config;
require_once "clickheat_config.php";
class ClickHeat extends \Piwik\Plugin
{
function install()
{
global $clickheatConf;
/** Create main cache paths */
$dir = PIWIK_INCLUDE_PATH.'/tmp/cache/clickheat/';
if (!is_dir($dir.'logs'))
$logPath = $clickheatConf['logPath'];
$cachePath = $clickheatConf['cachePath'];
if (!is_dir($logPath))
{
mkdir($dir.'logs', 0777, true);
mkdir($logPath, 0777, true);
}
if (!is_dir($dir.'cache'))
if (!is_dir($cachePath))
{
mkdir($dir.'cache', 0777, true);
}
$htaccess = PIWIK_INCLUDE_PATH.'/plugins/ClickHeat/dot_htaccess';
if (file_exists($htaccess)) {
copy($htaccess, PIWIK_INCLUDE_PATH.'/plugins/ClickHeat/.htaccess');
mkdir($cachePath, 0777, true);
}
}
}

19
Reports/Base.php Normal file
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\ClickHeat\Reports;
use Piwik\Plugin\Report;
abstract class Base extends Report
{
protected function init()
{
$this->categoryId = 'General_Visitors';
}
}

101
Reports/GetClickHeatmap.php Normal file
View file

@ -0,0 +1,101 @@
<?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\ClickHeat\Reports;
use Piwik\Piwik;
use Piwik\Plugin\Report;
use Piwik\Plugin\ViewDataTable;
use Piwik\View;
/**
* This class defines a new report.
*
* See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
*/
class GetClickHeatmap extends Base
{
protected function init()
{
parent::init();
$this->name = Piwik::translate('ClickHeat_ClickHeatmap');
$this->dimension = null;
$this->documentation = Piwik::translate('');
// This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
$this->order = 41;
// By default standard metrics are defined but you can customize them by defining an array of metric names
// $this->metrics = array('nb_visits', 'nb_hits');
// Uncomment the next line if your report does not contain any processed metrics, otherwise default
// processed metrics will be assigned
// $this->processedMetrics = array();
// Uncomment the next line if your report defines goal metrics
// $this->hasGoalMetrics = true;
// Uncomment the next line if your report should be able to load subtables. You can define any action here
// $this->actionToLoadSubTables = $this->action;
// Uncomment the next line if your report always returns a constant count of rows, for instance always
// 24 rows for 1-24hours
// $this->constantRowsCount = true;
// If a subcategory is specified, the report will be displayed in the menu under this menu item
// $this->subcategoryId = 'ClickHeat_ClickHeatmap';
}
/**
* 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 (!empty($this->dimension)) {
$view->config->addTranslations(array('label' => $this->dimension->getName()));
}
// $view->config->show_search = false;
// $view->requestConfig->filter_sort_column = 'nb_visits';
// $view->requestConfig->filter_limit = 10';
$view->config->columns_to_display = array_merge(array('label'), $this->metrics);
}
/**
* Here you can define related reports that will be shown below the reports. Just return an array of related
* report instances if there are any.
*
* @return \Piwik\Plugin\Report[]
*/
public function getRelatedReports()
{
return array(); // eg return array(new XyzReport());
}
/**
* A report is usually completely automatically rendered for you but you can render the report completely
* customized if you wish. Just overwrite the method and make sure to return a string containing the content of the
* report. Don't forget to create the defined twig template within the templates folder of your plugin in order to
* make it work. Usually you should NOT have to overwrite this render method.
*
* @return string
public function render()
{
$view = new View('@ClickHeat/getClickHeatmap');
$view->myData = array();
return $view->render();
}
*/
}

View file

@ -1 +0,0 @@
0.1.9

View file

@ -1,35 +0,0 @@
<?php
/**
* ClickHeat - Clicks' heatmap
*
* @link http://www.dugwood.com/clickheat/index.html
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
*
* @package Piwik\Plugins\ClickHeat
*/
namespace Piwik\Plugins\ClickHeat;
use Piwik\Config;
class ClickHeat extends \Piwik\Plugin
{
function install()
{
/** Create main cache paths */
$dir = PIWIK_INCLUDE_PATH.'/tmp/cache/clickheat/';
if (!is_dir($dir.'logs'))
{
mkdir($dir.'logs', 0777, true);
}
if (!is_dir($dir.'cache'))
{
mkdir($dir.'cache', 0777, true);
}
$htaccess = PIWIK_INCLUDE_PATH.'/plugins/ClickHeat/dot_htaccess';
if (file_exists($htaccess)) {
copy($htaccess, PIWIK_INCLUDE_PATH.'/plugins/ClickHeat/.htaccess');
}
}
}

View file

@ -13,11 +13,11 @@
"LANG_GROUP": "Group",
"LANG_BROWSER": "Browser",
"LANG_ALL": "All",
"LANG_UNKNOWN" : "Other/unknown",
"LANG_UNKNOWN": "Other\/unknown",
"LANG_EXAMPLE_URL": "Webpage",
"LANG_LAYOUT": "Group's layout",
"LANG_LAYOUT_FIXED" : "Fixed content/menu",
"LANG_LAYOUT_LIQUID" : "Liquid content/menu (automatic adjusting to available space)",
"LANG_LAYOUT_FIXED": "Fixed content\/menu",
"LANG_LAYOUT_LIQUID": "Liquid content\/menu (automatic adjusting to available space)",
"LANG_LAYOUT_NONE": "Margin (no content), liquid",
"LANG_LAYOUT_0": "Liquid content and menu",
"LANG_LAYOUT_1": "Fixed left menu, liquid content",
@ -45,11 +45,10 @@
"LANG_JAVASCRIPT_GROUP": "Group name, to group similar pages for a simpler analysis",
"LANG_JAVASCRIPT_GROUP0": "use a keyword",
"LANG_JAVASCRIPT_GROUP1": "allowed characters: A-Z, a-z, 0-9, underscore, hyphen, dot",
"LANG_JAVASCRIPT_GROUP2" : "use webpage's title (<a href=\"http://www.Dugwood.com/clickheat/performance.html\" onclick=\"window.open(this.href, 'external',return false\">not recommended</a>)",
"LANG_JAVASCRIPT_GROUP3" : "use webpage's URL (<a href=\"http://www.Dugwood.com/clickheat/performance.html\" onclick=\"window.open(this.href, 'external',return false\">not recommended</a>)",
"LANG_JAVASCRIPT_PASTE" : "Copy and paste the code below on your pages, just before the end of the page (before &lt;/body&gt; tag):",
"LANG_JAVASCRIPT_DEBUG" : "Once the code pasted on your pages, don't forget to test if the code works correctly, by calling your page with the parameter <span class=\"error\">debugclickheat</span>. For example for http://www.site.com/index.html call http://www.site.com/index.html<span class=\"error\">?debugclickheat</span>. You should see a message showing the state of Clickheat. If you encounter any problem, feel free to contact us",
"LANG_NO_CLICK_BELOW" : "Leave below this line in English please",
"LANG_JAVASCRIPT_GROUP2": "use webpage's title (<a href=\"http:\/\/www.Dugwood.com\/clickheat\/performance.html\" onclick=\"window.open(this.href, 'external',return false\">not recommended<\/a>)",
"LANG_JAVASCRIPT_GROUP3": "use webpage's URL (<a href=\"http:\/\/www.Dugwood.com\/clickheat\/performance.html\" onclick=\"window.open(this.href, 'external',return false\">not recommended<\/a>)",
"LANG_JAVASCRIPT_PASTE": "Copy and paste the code below on your pages, just before the end of the page (before &lt;\/body&gt; tag):",
"LANG_JAVASCRIPT_DEBUG": "Once the code pasted on your pages, don't forget to test if the code works correctly, by calling your page with the parameter <span class=\"error\">debugclickheat<\/span>. For example for http:\/\/www.site.com\/index.html call http:\/\/www.site.com\/index.html<span class=\"error\">?debugclickheat<\/span>. You should see a message showing the state of Clickheat. If you encounter any problem, feel free to contact us",
"LANG_NO_CLICK_BELOW": "No clicks recorded beneath this line",
"LANG_ERROR_GROUP": "Unknown group. _JAVASCRIPT_",
"LANG_ERROR_DATA": "No logs for the selected period (first think removing filters: browser, screensize). _JAVASCRIPT_",
@ -63,9 +62,9 @@
"LANG_CHECK_WRITABLE": "Write permissions in configuration directory",
"LANG_CHECK_NOT_WRITABLE": "PHP hasn't got write permission in the configuration directory",
"LANG_CHECK_GD": "GD graphic library",
"LANG_CHECK_GD_IMG" : "imagecreatetruecolor() unavailable, can't create images (with good quality), check that GD is installed",
"LANG_CHECK_GD_IMG": "imagecreatetruecolor() unavailable, can't create images (with good quality), check that GD\u00a0is installed",
"LANG_CHECK_GD_ALPHA": "imagecolorallocatealpha() unavailable, can't create transparent images (you can ignore this, but transparency is really recommended)",
"LANG_CHECK_GD_PNG" : "imagepng() unavailable, can't create PNG images, sorry",
"LANG_CHECK_GD_PNG": "imagepng() unavailable, can't create PNG\u00a0images, sorry",
"LANG_CHECKS_OK": "Next step: configuration",
"LANG_CHECKS_KO": "One or more tests have failed. Please correct problems and refresh this page.",
"LANG_CONFIG": "Configuration",
@ -83,7 +82,7 @@
"LANG_CONFIG_GROUPS": "Group names (separated by commas) allowed to log clicks on this server",
"LANG_CONFIG_FILESIZE": "Maximum logfile size (in KB) of a group over a day (1000 clicks are about 25KB, 0 = no size limit)",
"LANG_CONFIG_CHECK": "Check configuration",
"LANG_CONFIG_MEMORY" : "Memory limit (default php.ini value: %dMB, limits: from %d to %dMB, but <a href=\"http://www.Dugwood.com/clickheat/performance.html\" onclick=\"window.open(this.href, 'external',return false\">be careful with high values</a>)",
"LANG_CONFIG_MEMORY": "Memory limit (default php.ini value: %dMB, limits: from %d to %dMB, but <a href=\"http:\/\/www.Dugwood.com\/clickheat\/performance.html\" onclick=\"window.open(this.href, 'external',return false\">be careful with high values<\/a>)",
"LANG_CONFIG_MEMORY_KO": "please stay in the specified range",
"LANG_CONFIG_STEP": "Clicks grouping by X*X pixels' zones (speed up display of heatmaps)",
"LANG_CONFIG_STEP_KO": "zones can't be under 1x1 pixels",
@ -111,6 +110,7 @@
"LANG_CLEANER_RUN": "Cleaning finished: %d files and %d directories have been deleted",
"LANG_CANCEL": "Cancel",
"LANG_UPGRADE": "Upgrade",
"LANG_UPGRADE_NEXT" : "Check your configuration, then save it to finish upgrade"
"LANG_UPGRADE_NEXT": "Check your configuration, then save it to finish upgrade",
"ClickHeatmap": "Click Heatmap"
}
}

0
libs/click.php Executable file → Normal file
View file

View file

@ -1,24 +1,30 @@
{
"name": "ClickHeat",
"homepage": "http://piwikjapan.org",
"version": "0.1.9",
"homepage": "http:\/\/piwikjapan.org",
"version": "1.0.0",
"description": "ClickHeat is a visual heatmap of clicks on a HTML page. This plugin based on Dugwood's ClickHeat version 1.14. Plugin not consider IIS. Sorry.",
"theme": false,
"keywords": ["clickheat", "heatmap", "dugwood", "piwikjapan", "YAMAMOTO Takashi"],
"keywords": [
"clickheat",
"heatmap",
"dugwood",
"piwikjapan",
"YAMAMOTO Takashi"
],
"require": {
"piwik": ">=2.11.0"
"piwik": ">=3.7.0-stable,<4.0.0-b1"
},
"license": "GPLv3 or later",
"authors": [
{
"name": "Dugwood",
"email": "",
"homepage": "http://www.dugwood.com/clickheat/index.html"
"homepage": "http:\/\/www.dugwood.com\/clickheat\/index.html"
},
{
"name": "YAMAMOTO Takashi (PiwikJapan)",
"email": "yamachan@piwikjapan.org",
"homepage": "http://www.piwikjapan.org/"
"homepage": "http:\/\/www.piwikjapan.org\/"
}
],
"support": {