add icons for Character groups
This commit is contained in:
commit
2d9a41a5fe
3461 changed files with 594457 additions and 0 deletions
156
www/analytics/plugins/VisitTime/API.php
Normal file
156
www/analytics/plugins/VisitTime/API.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Exception;
|
||||
use Piwik\Archive;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Date;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Period;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Site;
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . '/plugins/VisitTime/functions.php';
|
||||
|
||||
/**
|
||||
* VisitTime API lets you access reports by Hour (Server time), and by Hour Local Time of your visitors.
|
||||
*
|
||||
* @method static \Piwik\Plugins\VisitTime\API getInstance()
|
||||
*/
|
||||
class API extends \Piwik\Plugin\API
|
||||
{
|
||||
protected function getDataTable($name, $idSite, $period, $date, $segment)
|
||||
{
|
||||
Piwik::checkUserHasViewAccess($idSite);
|
||||
$archive = Archive::build($idSite, $period, $date, $segment);
|
||||
$dataTable = $archive->getDataTable($name);
|
||||
$dataTable->filter('Sort', array('label', 'asc', true));
|
||||
$dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getTimeLabel'));
|
||||
$dataTable->queueFilter('ReplaceColumnNames');
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
public function getVisitInformationPerLocalTime($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
return $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime($idSite, $period, $date, $segment = false, $hideFutureHoursWhenToday = false)
|
||||
{
|
||||
$table = $this->getDataTable(Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
|
||||
if ($hideFutureHoursWhenToday) {
|
||||
$table = $this->removeHoursInFuture($table, $idSite, $period, $date);
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns datatable describing the number of visits for each day of the week.
|
||||
*
|
||||
* @param string $idSite The site ID. Cannot refer to multiple sites.
|
||||
* @param string $period The period type: day, week, year, range...
|
||||
* @param string $date The start date of the period. Cannot refer to multiple dates.
|
||||
* @param bool|string $segment The segment.
|
||||
* @throws Exception
|
||||
* @return DataTable
|
||||
*/
|
||||
public function getByDayOfWeek($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
|
||||
Piwik::checkUserHasViewAccess($idSite);
|
||||
|
||||
// metrics to query
|
||||
$metrics = Metrics::getVisitsMetricNames();
|
||||
unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
|
||||
|
||||
// disabled for multiple dates
|
||||
if (Period::isMultiplePeriod($date, $period)) {
|
||||
throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
|
||||
}
|
||||
|
||||
// get metric data for every day within the supplied period
|
||||
$oPeriod = Period::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
|
||||
$dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
|
||||
$archive = Archive::build($idSite, 'day', $dateRange, $segment);
|
||||
|
||||
// disabled for multiple sites
|
||||
if (count($archive->getParams()->getIdSites()) > 1) {
|
||||
throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
|
||||
}
|
||||
|
||||
$dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
|
||||
|
||||
// if there's no data for this report, don't bother w/ anything else
|
||||
if ($dataTable->getRowsCount() == 0) {
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
// group by the day of the week (see below for dayOfWeekFromDate function)
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate'));
|
||||
|
||||
// create new datatable w/ empty rows, then add calculated datatable
|
||||
$rows = array();
|
||||
foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
|
||||
$rows[] = array('label' => $day, 'nb_visits' => 0);
|
||||
}
|
||||
$result = new DataTable();
|
||||
$result->addRowsFromSimpleArray($rows);
|
||||
$result->addDataTable($dataTable);
|
||||
|
||||
// set day of week integer as metadata
|
||||
$result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
|
||||
|
||||
// translate labels
|
||||
$result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek'));
|
||||
|
||||
// set datatable metadata for period start & finish
|
||||
$result->setMetadata('date_start', $oPeriod->getDateStart());
|
||||
$result->setMetadata('date_end', $oPeriod->getDateEnd());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataTable $table
|
||||
* @param int $idSite
|
||||
* @param string $period
|
||||
* @param string $date
|
||||
* @return mixed
|
||||
*/
|
||||
protected function removeHoursInFuture($table, $idSite, $period, $date)
|
||||
{
|
||||
$site = new Site($idSite);
|
||||
|
||||
if ($period == 'day'
|
||||
&& ($date == 'today'
|
||||
|| $date == Date::factory('now', $site->getTimezone())->toString())
|
||||
) {
|
||||
$currentHour = Date::factory('now', $site->getTimezone())->toString('G');
|
||||
// If no data for today, this is an exception to the API output rule, as we normally return nothing:
|
||||
// we shall return all hours of the day, with nb_visits = 0
|
||||
if ($table->getRowsCount() == 0) {
|
||||
for ($hour = 0; $hour <= $currentHour; $hour++) {
|
||||
$table->addRowFromSimpleArray(array('label' => $hour, 'nb_visits' => 0));
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
|
||||
$idsToDelete = array();
|
||||
foreach ($table->getRows() as $id => $row) {
|
||||
$hour = $row->getColumn('label');
|
||||
if ($hour > $currentHour) {
|
||||
$idsToDelete[] = $id;
|
||||
}
|
||||
}
|
||||
$table->deleteRows($idsToDelete);
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
}
|
||||
86
www/analytics/plugins/VisitTime/Archiver.php
Normal file
86
www/analytics/plugins/VisitTime/Archiver.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Piwik\DataArray;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Date;
|
||||
|
||||
class Archiver extends \Piwik\Plugin\Archiver
|
||||
{
|
||||
const SERVER_TIME_RECORD_NAME = 'VisitTime_serverTime';
|
||||
const LOCAL_TIME_RECORD_NAME = 'VisitTime_localTime';
|
||||
|
||||
public function aggregateDayReport()
|
||||
{
|
||||
$this->aggregateByLocalTime();
|
||||
$this->aggregateByServerTime();
|
||||
}
|
||||
|
||||
public function aggregateMultipleReports()
|
||||
{
|
||||
$dataTableRecords = array(
|
||||
self::LOCAL_TIME_RECORD_NAME,
|
||||
self::SERVER_TIME_RECORD_NAME,
|
||||
);
|
||||
$this->getProcessor()->aggregateDataTableRecords($dataTableRecords);
|
||||
}
|
||||
|
||||
protected function aggregateByServerTime()
|
||||
{
|
||||
$dataArray = $this->getLogAggregator()->getMetricsFromVisitByDimension(array("label" => "HOUR(log_visit.visit_last_action_time)"));
|
||||
$query = $this->getLogAggregator()->queryConversionsByDimension(array("label" => "HOUR(log_conversion.server_time)"));
|
||||
if ($query === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ($conversionRow = $query->fetch()) {
|
||||
$dataArray->sumMetricsGoals($conversionRow['label'], $conversionRow);
|
||||
}
|
||||
$dataArray->enrichMetricsWithConversions();
|
||||
$dataArray = $this->convertTimeToLocalTimezone($dataArray);
|
||||
$this->ensureAllHoursAreSet($dataArray);
|
||||
$report = $dataArray->asDataTable()->getSerialized();
|
||||
$this->getProcessor()->insertBlobRecord(self::SERVER_TIME_RECORD_NAME, $report);
|
||||
}
|
||||
|
||||
protected function aggregateByLocalTime()
|
||||
{
|
||||
$array = $this->getLogAggregator()->getMetricsFromVisitByDimension("HOUR(log_visit.visitor_localtime)");
|
||||
$this->ensureAllHoursAreSet($array);
|
||||
$report = $array->asDataTable()->getSerialized();
|
||||
$this->getProcessor()->insertBlobRecord(self::LOCAL_TIME_RECORD_NAME, $report);
|
||||
}
|
||||
|
||||
protected function convertTimeToLocalTimezone(DataArray &$array)
|
||||
{
|
||||
$date = Date::factory($this->getProcessor()->getParams()->getDateStart()->getDateStartUTC())->toString();
|
||||
$timezone = $this->getProcessor()->getParams()->getSite()->getTimezone();
|
||||
|
||||
$converted = array();
|
||||
foreach ($array->getDataArray() as $hour => $stats) {
|
||||
$datetime = $date . ' ' . $hour . ':00:00';
|
||||
$hourInTz = (int)Date::factory($datetime, $timezone)->toString('H');
|
||||
$converted[$hourInTz] = $stats;
|
||||
}
|
||||
return new DataArray($converted);
|
||||
}
|
||||
|
||||
private function ensureAllHoursAreSet(DataArray &$array)
|
||||
{
|
||||
$data = $array->getDataArray();
|
||||
for ($i = 0; $i <= 23; $i++) {
|
||||
if (empty($data[$i])) {
|
||||
$array->sumMetricsVisits($i, DataArray::makeEmptyRow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
41
www/analytics/plugins/VisitTime/Controller.php
Normal file
41
www/analytics/plugins/VisitTime/Controller.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Piwik\View;
|
||||
use Piwik\ViewDataTable\Factory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Controller extends \Piwik\Plugin\Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$view = new View('@VisitTime/index');
|
||||
$view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true);
|
||||
$view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true);
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getVisitInformationPerLocalTime()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getByDayOfWeek()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
234
www/analytics/plugins/VisitTime/VisitTime.php
Normal file
234
www/analytics/plugins/VisitTime/VisitTime.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class VisitTime extends \Piwik\Plugin
|
||||
{
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
{
|
||||
$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,
|
||||
);
|
||||
}
|
||||
|
||||
function addWidgets()
|
||||
{
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime');
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime');
|
||||
WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
40
www/analytics/plugins/VisitTime/functions.php
Normal file
40
www/analytics/plugins/VisitTime/functions.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\Plugins\VisitTime;
|
||||
|
||||
use Piwik\Piwik;
|
||||
|
||||
function getTimeLabel($label)
|
||||
{
|
||||
return sprintf(Piwik::translate('VisitTime_NHour'), $label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the day of the week for a date string, without creating a new
|
||||
* Date instance.
|
||||
*
|
||||
* @param string $dateStr
|
||||
* @return int The day of the week (1-7)
|
||||
*/
|
||||
function dayOfWeekFromDate($dateStr)
|
||||
{
|
||||
return date('N', strtotime($dateStr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translated long name of a day of the week.
|
||||
*
|
||||
* @param int $dayOfWeek 1-7, for Sunday-Saturday
|
||||
* @return string
|
||||
*/
|
||||
function translateDayOfWeek($dayOfWeek)
|
||||
{
|
||||
return Piwik::translate('General_LongDay_' . $dayOfWeek);
|
||||
}
|
||||
9
www/analytics/plugins/VisitTime/templates/index.twig
Normal file
9
www/analytics/plugins/VisitTime/templates/index.twig
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<div id='leftcolumn'>
|
||||
<h2 piwik-enriched-headline>{{ 'VisitTime_LocalTime'|translate }}</h2>
|
||||
{{ dataTableVisitInformationPerLocalTime|raw }}
|
||||
</div>
|
||||
|
||||
<div id='rightcolumn'>
|
||||
<h2 piwik-enriched-headline>{{ 'VisitTime_ServerTime'|translate }}</h2>
|
||||
{{ dataTableVisitInformationPerServerTime|raw }}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue