diff options
author | m.kurzeja <m.kurzeja@clearcode.cc> | 2014-06-09 17:51:04 +0400 |
---|---|---|
committer | m.kurzeja <m.kurzeja@clearcode.cc> | 2014-06-09 17:52:11 +0400 |
commit | f27939a57634a7c2290d7dcef6e6ed0fd007e510 (patch) | |
tree | 4a67764ff4c5ebc703c3aecbfb7c62c9dca8f95d /core/ReportRenderer/Html.php | |
parent | 09fdbeb98dc16cb42c1f1ad1337ac3b44df24ffc (diff) |
Moved attachment generation to report renderer
Diffstat (limited to 'core/ReportRenderer/Html.php')
-rw-r--r-- | core/ReportRenderer/Html.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 53fbe90a68..e6d0b90e8c 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -8,6 +8,7 @@ */ namespace Piwik\ReportRenderer; +use Piwik\Piwik; use Piwik\Plugins\API\API; use Piwik\ReportRenderer; use Piwik\SettingsPiwik; @@ -161,4 +162,58 @@ 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 - %s %d - %s %d%s.png', + $processedReportMetadata['name'], + $prettyDate, + Piwik::translate('General_Website'), + $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; + } } |