update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,11 +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\ReportRenderer;
|
||||
|
||||
use Piwik\DataTable\DataTableInterface;
|
||||
use Piwik\DataTable\Renderer\Csv as CsvDataTableRenderer;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\ReportRenderer;
|
||||
use Piwik\DataTable\Renderer\Csv as CsvDataTableRenderer;
|
||||
use Piwik\DataTable\DataTableInterface;
|
||||
|
||||
/**
|
||||
* CSV report renderer
|
||||
*/
|
||||
class Csv extends ReportRenderer
|
||||
{
|
||||
/**
|
||||
|
|
@ -105,7 +115,7 @@ class Csv extends ReportRenderer
|
|||
);
|
||||
|
||||
$reportData = $csvRenderer->render($processedReport);
|
||||
if(empty($reportData)) {
|
||||
if (empty($reportData)) {
|
||||
$reportData = Piwik::translate('CoreHome_ThereIsNoDataForThisReport');
|
||||
}
|
||||
|
||||
|
|
@ -148,4 +158,17 @@ class Csv extends ReportRenderer
|
|||
{
|
||||
return str_replace("_", ".", $uniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report attachments, ex. graph images
|
||||
*
|
||||
* @param $report
|
||||
* @param $processedReports
|
||||
* @param $prettyDate
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachments($report, $processedReports, $prettyDate)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,22 +8,23 @@
|
|||
*/
|
||||
namespace Piwik\ReportRenderer;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\API\API;
|
||||
use Piwik\ReportRenderer;
|
||||
use Piwik\SettingsPiwik;
|
||||
use Piwik\View;
|
||||
|
||||
/**
|
||||
*
|
||||
* HTML report renderer
|
||||
*/
|
||||
class Html extends ReportRenderer
|
||||
{
|
||||
const IMAGE_GRAPH_WIDTH = 700;
|
||||
const IMAGE_GRAPH_HEIGHT = 200;
|
||||
|
||||
const REPORT_TITLE_TEXT_SIZE = 11;
|
||||
const REPORT_TITLE_TEXT_SIZE = 24;
|
||||
const REPORT_TABLE_HEADER_TEXT_SIZE = 11;
|
||||
const REPORT_TABLE_ROW_TEXT_SIZE = 11;
|
||||
const REPORT_TABLE_ROW_TEXT_SIZE = '13px';
|
||||
const REPORT_BACK_TO_TOP_TEXT_SIZE = 9;
|
||||
|
||||
const HTML_CONTENT_TYPE = 'text/html';
|
||||
|
|
@ -106,6 +107,7 @@ class Html extends ReportRenderer
|
|||
|
||||
private function assignCommonParameters(View $view)
|
||||
{
|
||||
$view->assign("reportFontFamily", ReportRenderer::DEFAULT_REPORT_FONT_FAMILY);
|
||||
$view->assign("reportTitleTextColor", ReportRenderer::REPORT_TITLE_TEXT_COLOR);
|
||||
$view->assign("reportTitleTextSize", self::REPORT_TITLE_TEXT_SIZE);
|
||||
$view->assign("reportTextColor", ReportRenderer::REPORT_TEXT_COLOR);
|
||||
|
|
@ -113,7 +115,9 @@ class Html extends ReportRenderer
|
|||
$view->assign("tableHeaderTextColor", ReportRenderer::TABLE_HEADER_TEXT_COLOR);
|
||||
$view->assign("tableCellBorderColor", ReportRenderer::TABLE_CELL_BORDER_COLOR);
|
||||
$view->assign("tableBgColor", ReportRenderer::TABLE_BG_COLOR);
|
||||
$view->assign("reportTableHeaderTextWeight", self::TABLE_HEADER_TEXT_WEIGHT);
|
||||
$view->assign("reportTableHeaderTextSize", self::REPORT_TABLE_HEADER_TEXT_SIZE);
|
||||
$view->assign("reportTableHeaderTextTransform", ReportRenderer::TABLE_HEADER_TEXT_TRANSFORM);
|
||||
$view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE);
|
||||
$view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE);
|
||||
$view->assign("currentPath", SettingsPiwik::getPiwikUrl());
|
||||
|
|
@ -161,4 +165,56 @@ class Html extends ReportRenderer
|
|||
|
||||
$this->rendering .= $reportView->render();
|
||||
}
|
||||
|
||||
public function getAttachments($report, $processedReports, $prettyDate)
|
||||
{
|
||||
$additionalFiles = array();
|
||||
|
||||
foreach ($processedReports as $processedReport) {
|
||||
if ($processedReport['displayGraph']) {
|
||||
$additionalFiles[] = $this->getAttachment($report, $processedReport, $prettyDate);
|
||||
}
|
||||
}
|
||||
|
||||
return $additionalFiles;
|
||||
}
|
||||
|
||||
protected function getAttachment($report, $processedReport, $prettyDate)
|
||||
{
|
||||
$additionalFile = array();
|
||||
|
||||
$segment = \Piwik\Plugins\ScheduledReports\API::getSegment($report['idsegment']);
|
||||
|
||||
$segmentName = $segment != null ? sprintf(' (%s)', $segment['name']) : '';
|
||||
|
||||
$processedReportMetadata = $processedReport['metadata'];
|
||||
|
||||
$additionalFile['filename'] =
|
||||
sprintf(
|
||||
'%s - %s - %d - %s %d%s.png',
|
||||
$processedReportMetadata['name'],
|
||||
$prettyDate,
|
||||
$report['idsite'],
|
||||
Piwik::translate('General_Report'),
|
||||
$report['idreport'],
|
||||
$segmentName
|
||||
);
|
||||
|
||||
$additionalFile['cid'] = $processedReportMetadata['uniqueId'];
|
||||
|
||||
$additionalFile['content'] =
|
||||
ReportRenderer::getStaticGraph(
|
||||
$processedReportMetadata,
|
||||
Html::IMAGE_GRAPH_WIDTH,
|
||||
Html::IMAGE_GRAPH_HEIGHT,
|
||||
$processedReport['evolutionGraph'],
|
||||
$segment
|
||||
);
|
||||
|
||||
$additionalFile['mimeType'] = 'image/png';
|
||||
|
||||
$additionalFile['encoding'] = \Zend_Mime::ENCODING_BASE64;
|
||||
|
||||
return $additionalFile;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -10,6 +10,7 @@ namespace Piwik\ReportRenderer;
|
|||
|
||||
use Piwik\Common;
|
||||
use Piwik\Filesystem;
|
||||
use Piwik\NumberFormatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\API\API;
|
||||
use Piwik\ReportRenderer;
|
||||
|
|
@ -19,11 +20,9 @@ use Piwik\TCPDF;
|
|||
* @see libs/tcpdf
|
||||
*/
|
||||
require_once PIWIK_INCLUDE_PATH . '/plugins/ScheduledReports/config/tcpdf_config.php';
|
||||
require_once PIWIK_INCLUDE_PATH . '/libs/tcpdf/config/lang/eng.php';
|
||||
require_once PIWIK_INCLUDE_PATH . '/core/TCPDF.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* PDF report renderer
|
||||
*/
|
||||
class Pdf extends ReportRenderer
|
||||
{
|
||||
|
|
@ -75,7 +74,7 @@ class Pdf extends ReportRenderer
|
|||
private $reportColumns;
|
||||
private $reportRowsMetadata;
|
||||
private $currentPage = 0;
|
||||
private $reportFont = ReportRenderer::DEFAULT_REPORT_FONT;
|
||||
private $reportFont = ReportRenderer::DEFAULT_REPORT_FONT_FAMILY;
|
||||
private $TCPDF;
|
||||
private $orientation = self::PORTRAIT;
|
||||
|
||||
|
|
@ -92,7 +91,16 @@ class Pdf extends ReportRenderer
|
|||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
// WARNING
|
||||
// To make Piwik release smaller, we're deleting some fonts from the Piwik build package.
|
||||
// If you change this code below, make sure that the fonts are NOT deleted from the Piwik package:
|
||||
// https://github.com/piwik/piwik-package/blob/master/scripts/build-package.sh
|
||||
switch ($locale) {
|
||||
case 'bn':
|
||||
case 'hi':
|
||||
$reportFont = 'freesans';
|
||||
break;
|
||||
|
||||
case 'zh-tw':
|
||||
$reportFont = 'msungstdlight';
|
||||
break;
|
||||
|
|
@ -110,20 +118,30 @@ class Pdf extends ReportRenderer
|
|||
break;
|
||||
|
||||
case 'ar':
|
||||
$reportFont = 'almohanad';
|
||||
$reportFont = 'aealarabiya';
|
||||
break;
|
||||
|
||||
case 'am':
|
||||
case 'ta':
|
||||
case 'th':
|
||||
$reportFont = 'freeserif';
|
||||
break;
|
||||
|
||||
case 'te':
|
||||
// not working with bundled fonts
|
||||
case 'en':
|
||||
default:
|
||||
$reportFont = ReportRenderer::DEFAULT_REPORT_FONT;
|
||||
$reportFont = ReportRenderer::DEFAULT_REPORT_FONT_FAMILY;
|
||||
break;
|
||||
}
|
||||
// WARNING: Did you read the warning above?
|
||||
|
||||
$this->reportFont = $reportFont;
|
||||
}
|
||||
|
||||
public function sendToDisk($filename)
|
||||
{
|
||||
$filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$filename = ReportRenderer::makeFilenameWithExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$outputFilename = ReportRenderer::getOutputPath($filename);
|
||||
|
||||
$this->TCPDF->Output($outputFilename, 'F');
|
||||
|
|
@ -133,13 +151,13 @@ class Pdf extends ReportRenderer
|
|||
|
||||
public function sendToBrowserDownload($filename)
|
||||
{
|
||||
$filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$filename = ReportRenderer::makeFilenameWithExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$this->TCPDF->Output($filename, 'D');
|
||||
}
|
||||
|
||||
public function sendToBrowserInline($filename)
|
||||
{
|
||||
$filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$filename = ReportRenderer::makeFilenameWithExtension($filename, self::PDF_CONTENT_TYPE);
|
||||
$this->TCPDF->Output($filename, 'I');
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +203,6 @@ class Pdf extends ReportRenderer
|
|||
|
||||
// segment
|
||||
if ($segment != null) {
|
||||
|
||||
$this->TCPDF->Ln();
|
||||
$this->TCPDF->Ln();
|
||||
$this->TCPDF->SetFont($this->reportFont, '', $this->reportHeaderFontSize - 2);
|
||||
|
|
@ -328,7 +345,7 @@ class Pdf extends ReportRenderer
|
|||
$this->TCPDF->SetTextColor($this->reportTextColor[0], $this->reportTextColor[1], $this->reportTextColor[2]);
|
||||
$this->TCPDF->SetFont('');
|
||||
|
||||
$fill = false;
|
||||
$fill = true;
|
||||
$url = false;
|
||||
$leftSpacesBeforeLogo = str_repeat(' ', $this->leftSpacesBeforeLogo);
|
||||
|
||||
|
|
@ -389,7 +406,7 @@ class Pdf extends ReportRenderer
|
|||
if (empty($rowMetrics[$columnId])) {
|
||||
$rowMetrics[$columnId] = 0;
|
||||
}
|
||||
$this->TCPDF->Cell($this->cellWidth, $this->cellHeight, $rowMetrics[$columnId], 'LR', 0, 'L', $fill);
|
||||
$this->TCPDF->Cell($this->cellWidth, $this->cellHeight, NumberFormatter::getInstance()->format($rowMetrics[$columnId]), 'LR', 0, 'L', $fill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +478,7 @@ class Pdf extends ReportRenderer
|
|||
&& $columnsCount <= 3
|
||||
) {
|
||||
$totalWidth = $this->reportWidthPortrait * 2 / 3;
|
||||
} else if ($this->orientation == self::LANDSCAPE) {
|
||||
} elseif ($this->orientation == self::LANDSCAPE) {
|
||||
$totalWidth = $this->reportWidthLandscape;
|
||||
} else {
|
||||
$totalWidth = $this->reportWidthPortrait;
|
||||
|
|
@ -494,12 +511,13 @@ class Pdf extends ReportRenderer
|
|||
$posX = $initPosX;
|
||||
foreach ($this->reportColumns as $columnName) {
|
||||
$columnName = $this->formatText($columnName);
|
||||
|
||||
//Label column
|
||||
if ($countColumns == 0) {
|
||||
$this->TCPDF->MultiCell($this->labelCellWidth, $maxCellHeight, $columnName, 1, 'C', true);
|
||||
$this->TCPDF->MultiCell($this->labelCellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
|
||||
$this->TCPDF->SetXY($posX + $this->labelCellWidth, $posY);
|
||||
} else {
|
||||
$this->TCPDF->MultiCell($this->cellWidth, $maxCellHeight, $columnName, 1, 'C', true);
|
||||
$this->TCPDF->MultiCell($this->cellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
|
||||
$this->TCPDF->SetXY($posX + $this->cellWidth, $posY);
|
||||
}
|
||||
$countColumns++;
|
||||
|
|
@ -523,4 +541,17 @@ class Pdf extends ReportRenderer
|
|||
$this->TCPDF->Write("1em", $message);
|
||||
$this->TCPDF->Ln();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report attachments, ex. graph images
|
||||
*
|
||||
* @param $report
|
||||
* @param $processedReports
|
||||
* @param $prettyDate
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachments($report, $processedReports, $prettyDate)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue