diff options
author | Benaka <diosmosis@users.noreply.github.com> | 2017-11-24 03:58:22 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-11-24 03:58:22 +0300 |
commit | f092d3b20289e8f6844674779b7b8b475e553cd1 (patch) | |
tree | b2374f6db41f9309f2ba19d4dc4d9c6cd9260262 /core/ReportRenderer | |
parent | 1f12b54962e58a893aa211b931b5e231c217df64 (diff) |
Use consistent HTML email body for all scheduled reports (HTML, PDF & CSV) (#12233)
* Extract mail configuring parts of sendReport method & write tests for them.
* Use twig in AttachedFileReportEmailGenerator.
* Extract header/footer of html scheduled report email into re-usable View subclasses & use for PDF/CSV emails.
* Fixing test failures.
* Integrationt est
Diffstat (limited to 'core/ReportRenderer')
-rw-r--r-- | core/ReportRenderer/Html.php | 67 |
1 files changed, 4 insertions, 63 deletions
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 3240a8ad94..b447cdf8e6 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -9,15 +9,8 @@ namespace Piwik\ReportRenderer; use Piwik\Piwik; -use Piwik\Plugin; -use Piwik\Plugins\API\API; -use Piwik\Plugins\CoreAdminHome\CustomLogo; use Piwik\ReportRenderer; -use Piwik\SettingsPiwik; -use Piwik\Site; -use Piwik\Date; use Piwik\View; -use Piwik\Plugins\ScheduledReports\ScheduledReports; /** * HTML report renderer @@ -27,11 +20,6 @@ class Html extends ReportRenderer const IMAGE_GRAPH_WIDTH = 700; const IMAGE_GRAPH_HEIGHT = 200; - const REPORT_TITLE_TEXT_SIZE = 24; - const REPORT_TABLE_HEADER_TEXT_SIZE = 11; - const REPORT_TABLE_ROW_TEXT_SIZE = '13px'; - const REPORT_BACK_TO_TOP_TEXT_SIZE = 9; - const HTML_CONTENT_TYPE = 'text/html'; const HTML_FILE_EXTENSION = 'html'; @@ -86,68 +74,21 @@ class Html extends ReportRenderer private function epilogue() { - $view = new View('@CoreHome/ReportRenderer/_htmlReportFooter'); - $view->hasWhiteLabel = Plugin\Manager::getInstance()->isPluginLoaded('WhiteLabel'); + $view = new View\HtmlEmailFooterView(); $this->rendering .= $view->render(); } public function renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment) { - $frontPageView = new View('@CoreHome/ReportRenderer/_htmlReportHeader'); - $this->assignCommonParameters($frontPageView); - - $period = $this->report['period']; - - $periods = ScheduledReports::getPeriodToFrequencyAsAdjective(); - $frontPageView->assign("period", $periods[$period]); - $frontPageView->assign("reportTitle", $reportTitle); - $frontPageView->assign("prettyDate", $prettyDate); - $frontPageView->assign("description", $description); - $frontPageView->assign("reportMetadata", $reportMetadata); - $frontPageView->assign("websiteName", Site::getNameFor($this->idSite)); - $frontPageView->assign("idSite", $this->idSite); - $frontPageView->assign("period", $period); - - $customLogo = new CustomLogo(); - $frontPageView->assign("isCustomLogo", $customLogo->isEnabled() && CustomLogo::hasUserLogo()); - $frontPageView->assign("logoHeader", $customLogo->getHeaderLogoUrl($pathOnly = false)); - - $date = Date::now()->setTimezone(Site::getTimezoneFor($this->idSite))->toString(); - $frontPageView->assign("date", $date); - - // segment - $displaySegment = ($segment != null); - $frontPageView->assign("displaySegment", $displaySegment); - if ($displaySegment) { - $frontPageView->assign("segmentName", $segment['name']); - } - + $frontPageView = new View\HtmlReportEmailHeaderView($reportTitle, $prettyDate, $description, $reportMetadata, + $segment, $this->idSite, $this->report['period']); $this->rendering .= $frontPageView->render(); } - 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); - $view->assign("tableHeaderBgColor", ReportRenderer::TABLE_HEADER_BG_COLOR); - $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()); - $view->assign("logoHeader", API::getInstance()->getHeaderLogoUrl()); - } - public function renderReport($processedReport) { $reportView = new View('@CoreHome/ReportRenderer/_htmlReportBody'); - $this->assignCommonParameters($reportView); + View\HtmlReportEmailHeaderView::assignCommonParameters($reportView); $reportMetadata = $processedReport['metadata']; $reportData = $processedReport['reportData']; |