From c3884631f58e87b76e8e75b7e59225103b45a718 Mon Sep 17 00:00:00 2001 From: mattab Date: Tue, 18 Feb 2014 16:04:43 +1300 Subject: [PATCH] Refs #4701 Commit pull request proposed file (Just changed the icon for csv) --- core/ReportRenderer.php | 3 ++- plugins/ScheduledReports/ScheduledReports.php | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php index b09505efa14..4634f9197c8 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -18,7 +18,6 @@ /** * A Report Renderer produces user friendly renderings of any given Piwik report. * All new Renderers must be copied in ReportRenderer and added to the $availableReportRenderers. - * */ abstract class ReportRenderer { @@ -32,10 +31,12 @@ abstract class ReportRenderer const HTML_FORMAT = 'html'; const PDF_FORMAT = 'pdf'; + const CSV_FORMAT = 'csv'; static private $availableReportRenderers = array( self::PDF_FORMAT, self::HTML_FORMAT, + self::CSV_FORMAT, ); /** diff --git a/plugins/ScheduledReports/ScheduledReports.php b/plugins/ScheduledReports/ScheduledReports.php index 9deaa618dd2..cb2309b5cef 100644 --- a/plugins/ScheduledReports/ScheduledReports.php +++ b/plugins/ScheduledReports/ScheduledReports.php @@ -11,7 +11,6 @@ use Exception; use Piwik\Common; use Piwik\Config; -use Piwik\Date; use Piwik\Db; use Piwik\DbHelper; use Piwik\Mail; @@ -69,7 +68,8 @@ class ScheduledReports extends \Piwik\Plugin static private $managedReportFormats = array( ReportRenderer::HTML_FORMAT => 'plugins/Zeitgeist/images/html_icon.png', - ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif' + ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif', + ReportRenderer::CSV_FORMAT => 'plugins/Morpheus/images/export.png', ); /** @@ -304,6 +304,24 @@ public function sendReport($reportType, $report, $contents, $filename, $prettyDa $mail->setBodyHtml($message . "

" . $contents); break; + + case 'csv': + $message .= "\n" . Piwik::translate('ScheduledReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle)); + + if ($displaySegmentInfo) { + $message .= " " . $segmentInfo; + } + + $mail->setBodyText($message); + $mail->createAttachment( + $contents, + 'application/csv', + Zend_Mime::DISPOSITION_INLINE, + Zend_Mime::ENCODING_BASE64, + $attachmentName . '.csv' + ); + break; + default: case 'pdf': $message .= "\n" . Piwik::translate('ScheduledReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle));