update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
9abe039dc8
commit
47263617c5
66 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?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
|
||||
|
|
@ -31,7 +31,8 @@ class API extends \Piwik\Plugin\API
|
|||
Piwik::checkUserHasViewAccess($idSite);
|
||||
$archive = Archive::build($idSite, $period, $date, $segment);
|
||||
$dataTable = $archive->getDataTable($name);
|
||||
$dataTable->filter('Sort', array('label', 'asc', true));
|
||||
|
||||
$dataTable->filter('Sort', array('label', 'asc', true, false));
|
||||
$dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getTimeLabel'));
|
||||
$dataTable->queueFilter('ReplaceColumnNames');
|
||||
return $dataTable;
|
||||
|
|
@ -39,15 +40,23 @@ class API extends \Piwik\Plugin\API
|
|||
|
||||
public function getVisitInformationPerLocalTime($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
return $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
|
||||
$table = $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
|
||||
$table->filter('AddSegmentValue');
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime($idSite, $period, $date, $segment = false, $hideFutureHoursWhenToday = false)
|
||||
{
|
||||
$table = $this->getDataTable(Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
|
||||
|
||||
$timezone = Site::getTimezoneFor($idSite);
|
||||
$table->filter('Piwik\Plugins\VisitTime\DataTable\Filter\AddSegmentByLabelInUTC', array($timezone, $period, $date));
|
||||
|
||||
if ($hideFutureHoursWhenToday) {
|
||||
$table = $this->removeHoursInFuture($table, $idSite, $period, $date);
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +85,7 @@ class API extends \Piwik\Plugin\API
|
|||
}
|
||||
|
||||
// get metric data for every day within the supplied period
|
||||
$oPeriod = Period::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
|
||||
$oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
|
||||
$dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
|
||||
$archive = Archive::build($idSite, 'day', $dateRange, $segment);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?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
|
||||
|
|
@ -30,7 +30,15 @@ class Archiver extends \Piwik\Plugin\Archiver
|
|||
self::LOCAL_TIME_RECORD_NAME,
|
||||
self::SERVER_TIME_RECORD_NAME,
|
||||
);
|
||||
$this->getProcessor()->aggregateDataTableRecords($dataTableRecords);
|
||||
$columnsAggregationOperation = null;
|
||||
$this->getProcessor()->aggregateDataTableRecords(
|
||||
$dataTableRecords,
|
||||
$maximumRowsInDataTableLevelZero = null,
|
||||
$maximumRowsInSubDataTable = null,
|
||||
$columnToSortByBeforeTruncation = null,
|
||||
$columnsAggregationOperation,
|
||||
$columnsToRenameAfterAggregation = null,
|
||||
$countRowsRecursive = array());
|
||||
}
|
||||
|
||||
protected function aggregateByServerTime()
|
||||
|
|
|
|||
20
www/analytics/plugins/VisitTime/Columns/DayOfTheWeek.php
Normal file
20
www/analytics/plugins/VisitTime/Columns/DayOfTheWeek.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?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\VisitTime\Columns;
|
||||
|
||||
use Piwik\Columns\Dimension;
|
||||
use Piwik\Piwik;
|
||||
|
||||
class DayOfTheWeek extends Dimension
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('VisitTime_DayOfWeek');
|
||||
}
|
||||
}
|
||||
48
www/analytics/plugins/VisitTime/Columns/LocalTime.php
Normal file
48
www/analytics/plugins/VisitTime/Columns/LocalTime.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?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\VisitTime\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Plugins\VisitTime\Segment;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
|
||||
class LocalTime extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visitor_localtime';
|
||||
protected $columnType = 'TIME NOT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('visitLocalHour');
|
||||
$segment->setName('VisitTime_ColumnLocalTime');
|
||||
$segment->setSqlSegment('HOUR(log_visit.visitor_localtime)');
|
||||
$segment->setAcceptedValues('0, 1, 2, 3, ..., 20, 21, 22, 23');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('VisitTime_ColumnLocalTime');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
return $request->getLocalTime();
|
||||
}
|
||||
}
|
||||
33
www/analytics/plugins/VisitTime/Columns/ServerTime.php
Normal file
33
www/analytics/plugins/VisitTime/Columns/ServerTime.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?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\VisitTime\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
use Piwik\Plugins\VisitTime\Segment;
|
||||
|
||||
class ServerTime extends VisitDimension
|
||||
{
|
||||
protected $columnName = 'visit_last_action_time';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('visitServerHour');
|
||||
$segment->setName('VisitTime_ColumnServerTime');
|
||||
$segment->setSqlSegment('HOUR(log_visit.visit_last_action_time)');
|
||||
$segment->setAcceptedValues('0, 1, 2, 3, ..., 20, 21, 22, 23');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('VisitTime_ColumnServerTime');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?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
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Piwik\View;
|
||||
use Piwik\ViewDataTable\Factory;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -19,23 +18,8 @@ class Controller extends \Piwik\Plugin\Controller
|
|||
public function index()
|
||||
{
|
||||
$view = new View('@VisitTime/index');
|
||||
$view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true);
|
||||
$view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true);
|
||||
$view->dataTableVisitInformationPerLocalTime = $this->renderReport('getVisitInformationPerLocalTime');
|
||||
$view->dataTableVisitInformationPerServerTime = $this->renderReport('getVisitInformationPerServerTime');
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getVisitInformationPerLocalTime()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getByDayOfWeek()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?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\VisitTime\DataTable\Filter;
|
||||
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Period;
|
||||
|
||||
/**
|
||||
* Adds a segment value to each row by interpreting the label value as hour in the website's timezone and
|
||||
* converting the hour to UTC.
|
||||
*
|
||||
* **Basic usage example**
|
||||
*
|
||||
* $dataTable->filter('AddSegmentByLabelInUTC', array($idSite = 'UTC+1', $period = 'day', $date = 'today');
|
||||
*/
|
||||
class AddSegmentByLabelInUTC extends DataTable\Filter\AddSegmentValue
|
||||
{
|
||||
private $timezone;
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* @param DataTable $table
|
||||
* @param int $timezone The timezone of the current selected site / the timezone of the labels
|
||||
* @param string $period The requested period and date is needed to respect daylight saving etc.
|
||||
* @param string $date
|
||||
*/
|
||||
public function __construct($table, $timezone, $period, $date)
|
||||
{
|
||||
$this->timezone = $timezone;
|
||||
$this->date = Period\Factory::build($period, $date)->getDateEnd();
|
||||
|
||||
$self = $this;
|
||||
|
||||
parent::__construct($table, function ($label) use ($self) {
|
||||
$hour = str_pad($label, 2, 0, STR_PAD_LEFT);
|
||||
|
||||
return $self->convertHourToUtc($hour);
|
||||
});
|
||||
}
|
||||
|
||||
public function convertHourToUTC($hour)
|
||||
{
|
||||
$dateWithHour = $this->date->setTime($hour . ':00:00');
|
||||
$dateInTimezone = $dateWithHour->setTimezone($this->timezone);
|
||||
$hourInUTC = $dateInTimezone->getHourUTC();
|
||||
|
||||
return $hourInUTC;
|
||||
}
|
||||
}
|
||||
19
www/analytics/plugins/VisitTime/Menu.php
Normal file
19
www/analytics/plugins/VisitTime/Menu.php
Normal 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\VisitTime;
|
||||
|
||||
use Piwik\Menu\MenuReporting;
|
||||
|
||||
class Menu extends \Piwik\Plugin\Menu
|
||||
{
|
||||
public function configureReportingMenu(MenuReporting $menu)
|
||||
{
|
||||
$menu->addVisitorsItem('VisitTime_SubmenuTimes', $this->urlForAction('index'), $order = 65);
|
||||
}
|
||||
}
|
||||
40
www/analytics/plugins/VisitTime/Reports/Base.php
Normal file
40
www/analytics/plugins/VisitTime/Reports/Base.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?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\VisitTime\Reports;
|
||||
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar;
|
||||
|
||||
abstract class Base extends \Piwik\Plugin\Report
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->category = 'VisitsSummary_VisitsSummary';
|
||||
}
|
||||
|
||||
public function getDefaultTypeViewDataTable()
|
||||
{
|
||||
return Bar::ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ViewDataTable $view
|
||||
*/
|
||||
protected function setBasicConfigViewProperties(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_sort_column = 'label';
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->requestConfig->addPropertiesThatShouldBeAvailableClientSide(array('filter_sort_column'));
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_limit_control = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->show_offset_information = false;
|
||||
$view->config->show_pagination_control = false;
|
||||
}
|
||||
}
|
||||
76
www/analytics/plugins/VisitTime/Reports/GetByDayOfWeek.php
Normal file
76
www/analytics/plugins/VisitTime/Reports/GetByDayOfWeek.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?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\VisitTime\Reports;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\VisitTime\Columns\DayOfTheWeek;
|
||||
use Piwik\Period;
|
||||
use Piwik\Site;
|
||||
|
||||
class GetByDayOfWeek extends Base
|
||||
{
|
||||
protected $defaultSortColumn = '';
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new DayOfTheWeek();
|
||||
$this->name = Piwik::translate('VisitTime_VisitsByDayOfWeek');
|
||||
$this->documentation = Piwik::translate('VisitTime_WidgetByDayOfWeekDocumentation');
|
||||
$this->constantRowsCount = true;
|
||||
$this->order = 25;
|
||||
$this->widgetTitle = 'VisitTime_VisitsByDayOfWeek';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
|
||||
$view->requestConfig->filter_limit = 7;
|
||||
|
||||
$view->config->enable_sort = false;
|
||||
$view->config->show_footer_message = Piwik::translate('General_ReportGeneratedFrom', $this->getDateRangeForFooterMessage());
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
|
||||
$view->config->disable_row_evolution = true;
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
$view->config->show_all_ticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function getDateRangeForFooterMessage()
|
||||
{
|
||||
// get query params
|
||||
$idSite = Common::getRequestVar('idSite', false);
|
||||
$date = Common::getRequestVar('date', false);
|
||||
$period = Common::getRequestVar('period', false);
|
||||
|
||||
// create a period instance
|
||||
try {
|
||||
$oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
|
||||
} catch (\Exception $ex) {
|
||||
return ''; // if query params are incorrect, forget about the footer message
|
||||
}
|
||||
|
||||
// set the footer message using the period start & end date
|
||||
$start = $oPeriod->getDateStart()->toString();
|
||||
$end = $oPeriod->getDateEnd()->toString();
|
||||
if ($start == $end) {
|
||||
$dateRange = $start;
|
||||
} else {
|
||||
$dateRange = $start . " – " . $end;
|
||||
}
|
||||
return $dateRange;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?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\VisitTime\Reports;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\VisitTime\Columns\LocalTime;
|
||||
|
||||
class GetVisitInformationPerLocalTime extends Base
|
||||
{
|
||||
|
||||
protected $defaultSortColumn = '';
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new LocalTime();
|
||||
$this->name = Piwik::translate('VisitTime_WidgetLocalTime');
|
||||
$this->documentation = Piwik::translate('VisitTime_WidgetLocalTimeDocumentation', array('<strong>', '</strong>'));
|
||||
$this->constantRowsCount = true;
|
||||
$this->order = 20;
|
||||
$this->widgetTitle = 'VisitTime_WidgetLocalTime';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
|
||||
$view->requestConfig->filter_limit = 24;
|
||||
|
||||
$view->config->title = Piwik::translate('VisitTime_ColumnLocalTime');
|
||||
$view->config->addTranslation('label', Piwik::translate('VisitTime_LocalTime'));
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
}
|
||||
|
||||
// add the visits by day of week as a related report, if the current period is not 'day'
|
||||
if (Common::getRequestVar('period', 'day') != 'day') {
|
||||
$view->config->addRelatedReport('VisitTime.getByDayOfWeek', Piwik::translate('VisitTime_VisitsByDayOfWeek'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?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\VisitTime\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\VisitTime\Columns\ServerTime;
|
||||
|
||||
class GetVisitInformationPerServerTime extends Base
|
||||
{
|
||||
|
||||
protected $defaultSortColumn = '';
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new ServerTime();
|
||||
$this->name = Piwik::translate('VisitTime_WidgetServerTime');
|
||||
$this->documentation = Piwik::translate('VisitTime_WidgetServerTimeDocumentation', array('<strong>', '</strong>'));
|
||||
$this->constantRowsCount = true;
|
||||
$this->hasGoalMetrics = true;
|
||||
$this->order = 15;
|
||||
$this->widgetTitle = 'VisitTime_WidgetServerTime';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
|
||||
$view->requestConfig->filter_limit = 24;
|
||||
$view->requestConfig->request_parameters_to_modify['hideFutureHoursWhenToday'] = 1;
|
||||
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
www/analytics/plugins/VisitTime/Segment.php
Normal file
21
www/analytics/plugins/VisitTime/Segment.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?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\VisitTime;
|
||||
|
||||
/**
|
||||
* VisitTime segment base class.
|
||||
*
|
||||
*/
|
||||
class Segment extends \Piwik\Plugin\Segment
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->setCategory('Visit');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?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
|
||||
|
|
@ -8,227 +8,23 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Exception;
|
||||
|
||||
use Piwik\ArchiveProcessor;
|
||||
use Piwik\Common;
|
||||
use Piwik\Menu\MenuMain;
|
||||
use Piwik\Period;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar;
|
||||
use Piwik\Site;
|
||||
use Piwik\WidgetsList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// empty plugin definition, otherwise plugin won't be installed during test run
|
||||
class VisitTime extends \Piwik\Plugin
|
||||
{
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
* @see Piwik\Plugin::registerEvents
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
public function registerEvents()
|
||||
{
|
||||
$hooks = array(
|
||||
'WidgetsList.addWidgets' => 'addWidgets',
|
||||
'Menu.Reporting.addItems' => 'addMenu',
|
||||
'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
|
||||
'API.getReportMetadata' => 'getReportMetadata',
|
||||
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
|
||||
'ViewDataTable.configure' => 'configureViewDataTable',
|
||||
'ViewDataTable.getDefaultType' => 'getDefaultTypeViewDataTable'
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public function getReportMetadata(&$reports)
|
||||
{
|
||||
$reports[] = array(
|
||||
'category' => Piwik::translate('VisitsSummary_VisitsSummary'),
|
||||
'name' => Piwik::translate('VisitTime_WidgetLocalTime'),
|
||||
'module' => 'VisitTime',
|
||||
'action' => 'getVisitInformationPerLocalTime',
|
||||
'dimension' => Piwik::translate('VisitTime_ColumnLocalTime'),
|
||||
'documentation' => Piwik::translate('VisitTime_WidgetLocalTimeDocumentation', array('<strong>', '</strong>')),
|
||||
'constantRowsCount' => true,
|
||||
'order' => 20
|
||||
);
|
||||
|
||||
$reports[] = array(
|
||||
'category' => Piwik::translate('VisitsSummary_VisitsSummary'),
|
||||
'name' => Piwik::translate('VisitTime_WidgetServerTime'),
|
||||
'module' => 'VisitTime',
|
||||
'action' => 'getVisitInformationPerServerTime',
|
||||
'dimension' => Piwik::translate('VisitTime_ColumnServerTime'),
|
||||
'documentation' => Piwik::translate('VisitTime_WidgetServerTimeDocumentation', array('<strong>', '</strong>')),
|
||||
'constantRowsCount' => true,
|
||||
'order' => 15,
|
||||
);
|
||||
|
||||
$reports[] = array(
|
||||
'category' => Piwik::translate('VisitsSummary_VisitsSummary'),
|
||||
'name' => Piwik::translate('VisitTime_VisitsByDayOfWeek'),
|
||||
'module' => 'VisitTime',
|
||||
'action' => 'getByDayOfWeek',
|
||||
'dimension' => Piwik::translate('VisitTime_DayOfWeek'),
|
||||
'documentation' => Piwik::translate('VisitTime_WidgetByDayOfWeekDocumentation'),
|
||||
'constantRowsCount' => true,
|
||||
'order' => 25,
|
||||
return array(
|
||||
'Live.getAllVisitorDetails' => 'extendVisitorDetails',
|
||||
);
|
||||
}
|
||||
|
||||
function addWidgets()
|
||||
public function extendVisitorDetails(&$visitor, $details)
|
||||
{
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime');
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime');
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek');
|
||||
$visitor['visitLocalTime'] = $details['visitor_localtime'];
|
||||
$visitor['visitLocalHour'] = date('G', strtotime('2012-12-21 ' . $details['visitor_localtime']));
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
MenuMain::getInstance()->add('General_Visitors', 'VisitTime_SubmenuTimes',
|
||||
array('module' => 'VisitTime', 'action' => 'index'), true, $order = 65);
|
||||
}
|
||||
|
||||
public function getReportsWithGoalMetrics(&$dimensions)
|
||||
{
|
||||
$dimensions[] = array('category' => Piwik::translate('VisitTime_ColumnServerTime'),
|
||||
'name' => Piwik::translate('VisitTime_ColumnServerTime'),
|
||||
'module' => 'VisitTime',
|
||||
'action' => 'getVisitInformationPerServerTime',
|
||||
);
|
||||
}
|
||||
|
||||
public function getSegmentsMetadata(&$segments)
|
||||
{
|
||||
$acceptedValues = "0, 1, 2, 3, ..., 20, 21, 22, 23";
|
||||
$segments[] = array(
|
||||
'type' => 'dimension',
|
||||
'category' => Piwik::translate('General_Visit'),
|
||||
'name' => Piwik::translate('VisitTime_ColumnServerTime'),
|
||||
'segment' => 'visitServerHour',
|
||||
'sqlSegment' => 'HOUR(log_visit.visit_last_action_time)',
|
||||
'acceptedValues' => $acceptedValues
|
||||
);
|
||||
$segments[] = array(
|
||||
'type' => 'dimension',
|
||||
'category' => Piwik::translate('General_Visit'),
|
||||
'name' => Piwik::translate('VisitTime_ColumnLocalTime'),
|
||||
'segment' => 'visitLocalHour',
|
||||
'sqlSegment' => 'HOUR(log_visit.visitor_localtime)',
|
||||
'acceptedValues' => $acceptedValues
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaultTypeViewDataTable(&$defaultViewTypes)
|
||||
{
|
||||
$defaultViewTypes['VisitTime.getVisitInformationPerServerTime'] = Bar::ID;
|
||||
$defaultViewTypes['VisitTime.getVisitInformationPerLocalTime'] = Bar::ID;
|
||||
$defaultViewTypes['VisitTime.getByDayOfWeek'] = Bar::ID;
|
||||
}
|
||||
|
||||
public function configureViewDataTable(ViewDataTable $view)
|
||||
{
|
||||
switch ($view->requestConfig->apiMethodToRequestDataTable) {
|
||||
case 'VisitTime.getVisitInformationPerServerTime':
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
$this->configureViewForVisitInformationPerServerTime($view);
|
||||
break;
|
||||
case 'VisitTime.getVisitInformationPerLocalTime':
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
$this->configureViewForVisitInformationPerLocalTime($view);
|
||||
break;
|
||||
case 'VisitTime.getByDayOfWeek':
|
||||
$this->setBasicConfigViewProperties($view);
|
||||
$this->configureViewForByDayOfWeek($view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureViewForVisitInformationPerServerTime(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_limit = 24;
|
||||
$view->requestConfig->request_parameters_to_modify['hideFutureHoursWhenToday'] = 1;
|
||||
|
||||
$view->config->show_goals = true;
|
||||
$view->config->addTranslation('label', Piwik::translate('VisitTime_ColumnServerTime'));
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureViewForVisitInformationPerLocalTime(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_limit = 24;
|
||||
|
||||
$view->config->title = Piwik::translate('VisitTime_ColumnLocalTime');
|
||||
$view->config->addTranslation('label', Piwik::translate('VisitTime_LocalTime'));
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
}
|
||||
|
||||
// add the visits by day of week as a related report, if the current period is not 'day'
|
||||
if (Common::getRequestVar('period', 'day') != 'day') {
|
||||
$view->config->addRelatedReport('VisitTime.getByDayOfWeek', Piwik::translate('VisitTime_VisitsByDayOfWeek'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function configureViewForByDayOfWeek(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_limit = 7;
|
||||
|
||||
$view->config->enable_sort = false;
|
||||
$view->config->show_footer_message = Piwik::translate('General_ReportGeneratedFrom', self::getDateRangeForFooterMessage());
|
||||
$view->config->addTranslation('label', Piwik::translate('VisitTime_DayOfWeek'));
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->max_graph_elements = false;
|
||||
$view->config->show_all_ticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function getDateRangeForFooterMessage()
|
||||
{
|
||||
// get query params
|
||||
$idSite = Common::getRequestVar('idSite', false);
|
||||
$date = Common::getRequestVar('date', false);
|
||||
$period = Common::getRequestVar('period', false);
|
||||
|
||||
// create a period instance
|
||||
try {
|
||||
$oPeriod = Period::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
|
||||
} catch (Exception $ex) {
|
||||
return ''; // if query params are incorrect, forget about the footer message
|
||||
}
|
||||
|
||||
// set the footer message using the period start & end date
|
||||
$start = $oPeriod->getDateStart()->toString();
|
||||
$end = $oPeriod->getDateEnd()->toString();
|
||||
if ($start == $end) {
|
||||
$dateRange = $start;
|
||||
} else {
|
||||
$dateRange = $start . " – " . $end;
|
||||
}
|
||||
return $dateRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ViewDataTable $view
|
||||
*/
|
||||
private function setBasicConfigViewProperties(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_sort_column = 'label';
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->requestConfig->addPropertiesThatShouldBeAvailableClientSide(array('filter_sort_column'));
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_limit_control = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->show_offset_information = false;
|
||||
$view->config->show_pagination_control = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?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
|
||||
|
|
@ -13,7 +13,7 @@ use Piwik\Piwik;
|
|||
|
||||
function getTimeLabel($label)
|
||||
{
|
||||
return sprintf(Piwik::translate('VisitTime_NHour'), $label);
|
||||
return sprintf(Piwik::translate('Intl_NHoursShort'), $label);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,5 +36,5 @@ function dayOfWeekFromDate($dateStr)
|
|||
*/
|
||||
function translateDayOfWeek($dayOfWeek)
|
||||
{
|
||||
return Piwik::translate('General_LongDay_' . $dayOfWeek);
|
||||
return Piwik::translate('Intl_Day_Long_StandAlone_' . $dayOfWeek);
|
||||
}
|
||||
|
|
|
|||
11
www/analytics/plugins/VisitTime/lang/am.json
Normal file
11
www/analytics/plugins/VisitTime/lang/am.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"VisitTime": {
|
||||
"ColumnLocalTime": "አካባቢያዊ ሰዓት",
|
||||
"ColumnServerTime": "የአገልጋይ ሰዓት",
|
||||
"LocalTime": "ጉብኝቶች ከአካባቢያዊ ሰዓት",
|
||||
"ServerTime": "ጉብኝቶች ከአገልጋይ ሰዓት",
|
||||
"SubmenuTimes": "ሰዓታት",
|
||||
"WidgetLocalTime": "ጉብኝቶች በአካባቢያዊ ሰዓት",
|
||||
"WidgetServerTime": "ጉብኝቶች በአገልጋይ ሰዓት"
|
||||
}
|
||||
}
|
||||
12
www/analytics/plugins/VisitTime/lang/ar.json
Normal file
12
www/analytics/plugins/VisitTime/lang/ar.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"VisitTime": {
|
||||
"ColumnLocalTime": "التوقيت المحلي",
|
||||
"ColumnServerTime": "توقيت الملقم",
|
||||
"LocalTime": "الزيارات حسب التوقيت المحلي",
|
||||
"NHour": "%s س",
|
||||
"ServerTime": "الزيارات حسب توقيت الملقم",
|
||||
"SubmenuTimes": "التوقيت",
|
||||
"WidgetLocalTime": "الزيارات حسب التوقيت المحلي",
|
||||
"WidgetServerTime": "الزيارات حسب توقيت الملقم"
|
||||
}
|
||||
}
|
||||
14
www/analytics/plugins/VisitTime/lang/be.json
Normal file
14
www/analytics/plugins/VisitTime/lang/be.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"VisitTime": {
|
||||
"ColumnLocalTime": "Мясцовы час",
|
||||
"ColumnServerTime": "Серверны час",
|
||||
"LocalTime": "Наведванняў па мясцовым часе",
|
||||
"NHour": "%s ч.",
|
||||
"ServerTime": "Наведванняў па серверным часе",
|
||||
"SubmenuTimes": "Па часе",
|
||||
"WidgetLocalTime": "Наведванняў па мясцовым часе",
|
||||
"WidgetLocalTimeDocumentation": "Гэты графік паказвае, які %1$s час быў у наведвальніка %2$s пад час наведвання веб-сайту.",
|
||||
"WidgetServerTime": "Наведванняў па серверным часе",
|
||||
"WidgetServerTimeDocumentation": "Гэты графік паказвае, які %1$s час быў на серверы %2$s пад час наведвання веб-сайту."
|
||||
}
|
||||
}
|
||||
17
www/analytics/plugins/VisitTime/lang/bg.json
Normal file
17
www/analytics/plugins/VisitTime/lang/bg.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"VisitTime": {
|
||||
"ColumnLocalTime": "Локално време (на посетителя)",
|
||||
"ColumnServerTime": "Сървърно време (на сървъра)",
|
||||
"DayOfWeek": "Ден от седмицата",
|
||||
"LocalTime": "Посещения по локално време",
|
||||
"NHour": "%sч",
|
||||
"ServerTime": "Посещения по сървърно време",
|
||||
"SubmenuTimes": "Време",
|
||||
"VisitsByDayOfWeek": "Посещения по ден от седмицата",
|
||||
"WidgetByDayOfWeekDocumentation": "Графиката показва посещенията за всеки ден от седмицата.",
|
||||
"WidgetLocalTime": "Посещения по локално време",
|
||||
"WidgetLocalTimeDocumentation": "Тази графика показва колко е бил часът в %1$s часовия пояс на потребителите %2$s по време на посещенията им.",
|
||||
"WidgetServerTime": "Посещения по сървърно време",
|
||||
"WidgetServerTimeDocumentation": "Тази графика показва колко е бил часът в %1$s часовия пояс използван от сървъра %2$s по време на посещенията."
|
||||
}
|
||||
}
|
||||
18
www/analytics/plugins/VisitTime/lang/ca.json
Normal file
18
www/analytics/plugins/VisitTime/lang/ca.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"VisitTime": {
|
||||
"ColumnLocalTime": "Hora local",
|
||||
"ColumnServerTime": "Hora del servidor",
|
||||
"DayOfWeek": "Dia de la setmana",
|
||||
"LocalTime": "Visites segons l'hora local",
|
||||
"NHour": "%sh",
|
||||
"PluginDescription": "Mostra l'hora local i l'hora del servidor en que els visitants naveguen pel vostre lloc web o aplicació.",
|
||||
"ServerTime": "Visites segons l'hora del servidor",
|
||||
"SubmenuTimes": "Hores",
|
||||
"VisitsByDayOfWeek": "Visites per día de la setmana",
|
||||
"WidgetByDayOfWeekDocumentation": "Aquest gràfic mostre el nombre de visites que ha rebut el vostre lloc web cada dia de la setmana.",
|
||||
"WidgetLocalTime": "Visites segons l'hora local",
|
||||
"WidgetLocalTimeDocumentation": "Aquest gràfic mostra a quina hora era a %1$s la zona horària del visitant %2$s durant la seva visita.",
|
||||
"WidgetServerTime": "Visites segons l'hora del servidor",
|
||||
"WidgetServerTimeDocumentation": "Aquest gràfic quina hora era a la %1$s zona horària del servidor %2$s durant la visita."
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue