1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\View;
use Piwik\Common;
use Piwik\Date;
use Piwik\Mail\EmailStyles;
use Piwik\Plugin\ThemeStyles;
use Piwik\Plugins\API\API;
use Piwik\Plugins\CoreAdminHome\CustomLogo;
use Piwik\Scheduler\Schedule\Schedule;
use Piwik\SettingsPiwik;
use Piwik\Site;
use Piwik\View;
use Piwik\Plugin\Manager;
class HtmlReportEmailHeaderView extends View
{
const TEMPLATE_FILE = '@CoreHome/ReportRenderer/_htmlReportHeader';
private static $reportFrequencyTranslationByPeriod = [
Schedule::PERIOD_NEVER => '',
Schedule::PERIOD_DAY => 'General_DailyReport',
Schedule::PERIOD_WEEK => 'General_WeeklyReport',
Schedule::PERIOD_MONTH => 'General_MonthlyReport',
Schedule::PERIOD_YEAR => 'General_YearlyReport',
Schedule::PERIOD_RANGE => 'General_RangeReports',
];
public function __construct($reportTitle, $prettyDate, $description, $reportMetadata, $segment, $idSite, $period)
{
parent::__construct(self::TEMPLATE_FILE);
self::assignCommonParameters($this);
$periods = self::getPeriodToFrequencyAsAdjective();
$this->assign("frequency", $periods[$period]);
$this->assign("reportTitle", $reportTitle);
$this->assign("prettyDate", $prettyDate);
$this->assign("description", $description);
$this->assign("reportMetadata", $reportMetadata);
$this->assign("websiteName", Site::getNameFor($idSite));
$this->assign("idSite", $idSite);
$this->assign("period", $period);
$date = Date::now()->setTimezone(Site::getTimezoneFor($idSite))->toString();
$this->assign("date", $date);
// segment
$displaySegment = ($segment != null);
$this->assign("displaySegment", $displaySegment);
if ($displaySegment) {
$this->assign("segmentName", $segment['name']);
}
}
public static function assignCommonParameters(View $view)
{
$themeStyles = ThemeStyles::get();
$emailStyles = EmailStyles::get();
$view->currentPath = SettingsPiwik::getPiwikUrl();
$view->themeStyles = $themeStyles;
$view->emailStyles = $emailStyles;
$view->fontStyle = 'color:' . $themeStyles->colorText . ';font-family:' . $themeStyles->fontFamilyBase.';';
$view->styleParagraphText = 'font-size:15px;line-height:24px;';
$view->styleParagraph = $view->styleParagraphText . 'margin:0 0 16px;';
$customLogo = new CustomLogo();
$view->isCustomLogo = $customLogo->isEnabled() && CustomLogo::hasUserLogo();
$view->logoHeader = $customLogo->getHeaderLogoUrl($pathOnly = false);
$pluginManager = Manager::getInstance();
$view->hasWhiteLabel = $pluginManager->isPluginLoaded('WhiteLabel')
&& $pluginManager->isPluginActivated('WhiteLabel')
&& $pluginManager->isPluginInFilesystem('WhiteLabel');
$view->idSite = Common::getRequestVar('idSite', false);
}
private static function getPeriodToFrequencyAsAdjective()
{
return array_map(['\Piwik\Piwik', 'translate'], self::$reportFrequencyTranslationByPeriod);
}
}
|