From faad55ed1ff4668c54b975cdf826eb26ca8bb519 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 13 Jan 2021 16:13:58 -0600 Subject: [PATCH] Show donation alert 25% of the time on ebook detail pages --- config/phpstan/phpstan.neon | 3 +-- lib/Constants.php | 7 ++++--- templates/DonationAlert.php | 11 ++++++++++- www/ebooks/ebook.php | 4 +++- www/ebooks/index.php | 4 ++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config/phpstan/phpstan.neon b/config/phpstan/phpstan.neon index d74ac90b..cb223de9 100644 --- a/config/phpstan/phpstan.neon +++ b/config/phpstan/phpstan.neon @@ -26,6 +26,5 @@ parameters: - %rootDir%/../../../www - %rootDir%/../../../scripts dynamicConstantNames: + - DONATION_HOLIDAY_ALERT_ON - DONATION_ALERT_ON - - DONATION_ALERT_ALWAYS_ON - - DONATION_ALERT_ON_DURING_HOLIDAYS diff --git a/lib/Constants.php b/lib/Constants.php index a36fc8f9..eb4dd329 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -36,9 +36,10 @@ const SOURCE_FADED_PAGE = 9; const AVERAGE_READING_WORDS_PER_MINUTE = 275; define('PD_YEAR', intval(gmdate('Y')) - 96); -const DONATION_ALERT_ALWAYS_ON = false; -const DONATION_ALERT_ON_DURING_HOLIDAYS = true; -define('DONATION_ALERT_ON', DONATION_ALERT_ALWAYS_ON | (DONATION_ALERT_ON_DURING_HOLIDAYS && (time() > strtotime('December 1, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y'))))); + +define('DONATION_HOLIDAY_ALERT_ON', time() > strtotime('December 1, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y'))); +define('DONATION_ALERT_ON', rand(1, 4) == 2); + // No trailing slash on any of the below constants. const SITE_URL = 'https://standardebooks.org'; const SITE_ROOT = '/standardebooks.org'; diff --git a/templates/DonationAlert.php b/templates/DonationAlert.php index 8fb22143..4cff1e14 100644 --- a/templates/DonationAlert.php +++ b/templates/DonationAlert.php @@ -1,4 +1,13 @@ + diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index d407ebc6..4fb4d5b5 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -133,7 +133,9 @@ catch(\Exception $ex){

Description

- + + true]) ?> + LongDescription === null){ ?> diff --git a/www/ebooks/index.php b/www/ebooks/index.php index 091e885b..d6d304e4 100644 --- a/www/ebooks/index.php +++ b/www/ebooks/index.php @@ -130,8 +130,8 @@ catch(\Exception $ex){ ?> $pageTitle, 'highlight' => 'ebooks', 'description' => $pageDescription]) ?>

- - + + true]) ?> $query, 'tags' => $tags, 'sort' => $sort, 'view' => $view, 'perPage' => $perPage]) ?>