Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom style for opt-out page #70

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/CoreAdminHome/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ public function optOut()
$view->language = Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language)
? $language
: Piwik_LanguagesManager::getLanguageCodeForCurrentUser();

$customStyle = Piwik_Common::getRequestVar('style', false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here use Piwik_Common::isValidFilename() and throw exception if not valid filename
so you dont need str_replace below

if (!empty($customStyle)) {
$customStyle = 'optout_' . str_replace(array('.', '/', ':'), '_', $customStyle) . '.css';
if (file_exists(PIWIK_DOCUMENT_ROOT . '/themes/' . $customStyle)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halfdan what would you recommend here for filename and path of the optional CSS?

$view->customStyle = $customStyle;
}
}

echo $view->render();
}

Expand Down
3 changes: 3 additions & 0 deletions plugins/CoreAdminHome/templates/optOut.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
{% if customStyle %}
<link rel="stylesheet" type="text/css" href="themes/{{ customStyle }}">
{% endif %}
</head>
<body>
{% if not trackVisits %}
Expand Down