Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJouveer <35312684+Jouveer@users.noreply.github.com>2018-01-22 05:13:31 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2018-01-22 05:13:31 +0300
commite3f30fb8f498476ca9666cb26db4aabe656a7247 (patch)
treed4bad6d774fdf82ea792b08a34bcb3602bf10d2b /plugins/CoreAdminHome/OptOutManager.php
parente54d239a04ba248ddd6aa58d6907a1e230f570e7 (diff)
Added custom URL parameters to style the optOut iframe (#12472)
* Added custom URL parameters to style the optOut iframe * UI optOut customisation * Improved Features and iframe preview * Update .gitignore * Update en.json * Update CoreHome.php * Update opt-out-customizer.controller.js * Update opt-out-customizer.directive.html * Update PrivacyManager.php
Diffstat (limited to 'plugins/CoreAdminHome/OptOutManager.php')
-rw-r--r--plugins/CoreAdminHome/OptOutManager.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/CoreAdminHome/OptOutManager.php b/plugins/CoreAdminHome/OptOutManager.php
index 32b5ac5596..c52a95e8dd 100644
--- a/plugins/CoreAdminHome/OptOutManager.php
+++ b/plugins/CoreAdminHome/OptOutManager.php
@@ -198,6 +198,8 @@ class OptOutManager
'language' => $lang,
'setCookieInNewWindow' => 1
), false);
+
+ $this->addStylesheet($this->optOutStyling());
$this->view = new View("@CoreAdminHome/optOut");
$this->view->setXFrameOptions('allow');
@@ -215,6 +217,46 @@ class OptOutManager
return $this->view;
}
+ private function optOutStyling()
+ {
+ $cssfontsize = Common::getRequestVar('fontSize', false, 'string');
+ $cssfontcolour = Common::getRequestVar('fontColor', false, 'string');
+ $cssfontfamily = Common::getRequestVar('fontFamily', false, 'string');
+ $cssbackgroundcolor = Common::getRequestVar('backgroundColor', false, 'string');
+ $cssbody = 'body { ';
+
+ $hexstrings = array(
+ 'fontColor' => $cssfontcolour,
+ 'backgroundColor' => $cssbackgroundcolor
+ );
+ foreach ($hexstrings as $key => $testcase) {
+ if ($testcase && !(ctype_xdigit($testcase) && in_array(strlen($testcase),array(3,6), true))) {
+ throw new \Exception("The URL parameter $key value of '$testcase' is not valid. Expected value is for example 'ffffff' or 'fff'.\n");
+ }
+ }
+
+ if ($cssfontsize && (preg_match("/^[0-9]+[\.]?[0-9]*(px|pt|em|rem|%)$/", $cssfontsize))) {
+ $cssbody .= 'font-size: ' . $cssfontsize . '; ';
+ } else if ($cssfontsize) {
+ throw new \Exception("The URL parameter fontSize value of '$cssfontsize' is not valid. Expected value is for example '15pt', '1.2em' or '13px'.\n");
+ }
+
+ if ($cssfontfamily && (preg_match("/^[a-zA-Z-\ ,]+$/", $cssfontfamily))) {
+ $cssbody .= 'font-family: ' . $cssfontfamily . '; ';
+ } else if ($cssfontfamily) {
+ throw new \Exception("The URL parameter fontFamily value of '$cssfontfamily' is not valid. Expected value is for example 'sans-serif' or 'Monaco, monospace'.\n");
+ }
+
+ if ($cssfontcolour) {
+ $cssbody .= 'color: #' . $cssfontcolour . '; ';
+ }
+ if ($cssbackgroundcolor) {
+ $cssbody .= 'background-color: #' . $cssbackgroundcolor . '; ';
+ }
+
+ $cssbody .= '}';
+ return $cssbody;
+ }
/**
* @return DoNotTrackHeaderChecker
*/