EmailStyles.php
126 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Piwik - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace Piwik\Mail; |
| 11 | |
| 12 | use Piwik\Piwik; |
| 13 | use Piwik\ReportRenderer; |
| 14 | |
| 15 | class EmailStyles |
| 16 | { |
| 17 | const REPORT_TITLE_TEXT_SIZE = 24; |
| 18 | const REPORT_TABLE_HEADER_TEXT_SIZE = 11; |
| 19 | const REPORT_TABLE_ROW_TEXT_SIZE = '13px'; |
| 20 | const REPORT_BACK_TO_TOP_TEXT_SIZE = 9; |
| 21 | |
| 22 | /** |
| 23 | * @var string |
| 24 | */ |
| 25 | public $reportFontFamily = ReportRenderer::DEFAULT_REPORT_FONT_FAMILY; |
| 26 | |
| 27 | /** |
| 28 | * @var string |
| 29 | */ |
| 30 | public $reportTitleTextColor; |
| 31 | |
| 32 | /** |
| 33 | * @var int |
| 34 | */ |
| 35 | public $reportTitleTextSize = self::REPORT_TITLE_TEXT_SIZE; |
| 36 | |
| 37 | /** |
| 38 | * @var string |
| 39 | */ |
| 40 | public $reportTextColor; |
| 41 | |
| 42 | /** |
| 43 | * @var string |
| 44 | */ |
| 45 | public $tableHeaderBgColor; |
| 46 | |
| 47 | /** |
| 48 | * @var string |
| 49 | */ |
| 50 | public $tableHeaderTextColor; |
| 51 | |
| 52 | /** |
| 53 | * @var string |
| 54 | */ |
| 55 | public $tableCellBorderColor; |
| 56 | |
| 57 | /** |
| 58 | * @var string |
| 59 | */ |
| 60 | public $tableBgColor; |
| 61 | |
| 62 | /** |
| 63 | * @var string |
| 64 | */ |
| 65 | public $reportTableHeaderTextWeight = ReportRenderer::TABLE_HEADER_TEXT_WEIGHT; |
| 66 | |
| 67 | /** |
| 68 | * @var int |
| 69 | */ |
| 70 | public $reportTableHeaderTextSize = self::REPORT_TABLE_HEADER_TEXT_SIZE; |
| 71 | |
| 72 | /** |
| 73 | * @var string |
| 74 | */ |
| 75 | public $reportTableHeaderTextTransform = ReportRenderer::TABLE_HEADER_TEXT_TRANSFORM; |
| 76 | |
| 77 | /** |
| 78 | * @var string |
| 79 | */ |
| 80 | public $reportTableRowTextSize = self::REPORT_TABLE_ROW_TEXT_SIZE; |
| 81 | |
| 82 | /** |
| 83 | * @var int |
| 84 | */ |
| 85 | public $reportBackToTopTextSize = self::REPORT_BACK_TO_TOP_TEXT_SIZE; |
| 86 | |
| 87 | /** |
| 88 | * @var string |
| 89 | */ |
| 90 | public $brandNameLong; |
| 91 | |
| 92 | public function __construct() |
| 93 | { |
| 94 | $this->reportTitleTextColor = self::rgbToHex(ReportRenderer::REPORT_TITLE_TEXT_COLOR); |
| 95 | $this->reportTextColor = self::rgbToHex(ReportRenderer::REPORT_TEXT_COLOR); |
| 96 | $this->tableHeaderBgColor = self::rgbToHex(ReportRenderer::TABLE_HEADER_BG_COLOR); |
| 97 | $this->tableHeaderTextColor = self::rgbToHex(ReportRenderer::TABLE_HEADER_TEXT_COLOR); |
| 98 | $this->tableCellBorderColor = self::rgbToHex(ReportRenderer::TABLE_CELL_BORDER_COLOR); |
| 99 | $this->tableBgColor = self::rgbToHex(ReportRenderer::TABLE_BG_COLOR); |
| 100 | |
| 101 | $this->brandNameLong = 'Matomo, ' . Piwik::translate('General_OpenSourceWebAnalytics'); |
| 102 | } |
| 103 | |
| 104 | public static function rgbToHex($rgbValues) |
| 105 | { |
| 106 | list($r, $g, $b) = explode(',', $rgbValues); |
| 107 | |
| 108 | $r = str_pad(dechex($r), 2, "0", STR_PAD_LEFT); |
| 109 | $g = str_pad(dechex($g), 2, "0", STR_PAD_LEFT); |
| 110 | $b = str_pad(dechex($b), 2, "0", STR_PAD_LEFT); |
| 111 | |
| 112 | return '#' . $r . $g . $b; |
| 113 | } |
| 114 | |
| 115 | public static function get() |
| 116 | { |
| 117 | $result = new self(); |
| 118 | |
| 119 | /** |
| 120 | * @ignore |
| 121 | */ |
| 122 | Piwik::postEvent('Email.configureEmailStyle', [$result]); |
| 123 | |
| 124 | return $result; |
| 125 | } |
| 126 | } |