-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathDonationCounter.php
66 lines (62 loc) · 2.58 KB
/
DonationCounter.php
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
<?
// Hide the alert if the user has closed it.
if(!DONATION_DRIVE_COUNTER_ENABLED || ($autoHide ?? (HttpInput::Bool(COOKIE, 'hide-donation-alert') ?? false)) || NOW > DONATION_DRIVE_COUNTER_END){
return;
}
$autoHide = $autoHide ?? true;
$showDonateButton = $showDonateButton ?? true;
$current = 0;
if(NOW < DONATION_DRIVE_COUNTER_START || NOW > DONATION_DRIVE_COUNTER_END){
return;
}
$deadline = DONATION_DRIVE_COUNTER_END->format('F j');
$timeLeft = NOW->diff(DONATION_DRIVE_COUNTER_END);
$timeString = '';
if($timeLeft->d < 1 && $timeLeft->h < 20){
$timeString = 'Just hours';
}
elseif($timeLeft->d >= 1 && $timeLeft->h <= 12){
$timeString = $timeLeft->d . ' day';
if($timeLeft->d > 1){
$timeString .= 's';
}
else{
$timeString = 'Only ' . $timeString;
}
}
else{
$timeString = ($timeLeft->d + 1) . ' day';
if($timeLeft->d + 1 > 1){
$timeString .= 's';
}
else{
$timeString = 'Only ' . $timeString;
}
}
$digits = str_split(str_pad((string)$current, 3, "0", STR_PAD_LEFT))
?>
<aside class="donation counter closable">
<? if($autoHide){ ?>
<form action="/settings" method="<?= Enums\HttpMethod::Post->value ?>">
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Patch->value ?>" />
<input type="hidden" name="hide-donation-alert" value="true" />
<button class="close" title="Close this box">Close this box</button>
</form>
<? } ?>
<header>
<p><?= $timeString ?> left to help us win $1,000</p>
</header>
<div class="flipboard">
<? foreach($digits as $digit){ ?><span><?= $digit ?></span><? } ?>
entries
</div>
<p>Our fiscal sponsor, <a href="https://www.fracturedatlas.org">Fractured Atlas</a>, is celebrating the twenty-year anniversary of their fiscal sponsorship program by <a href="https://media.fracturedatlas.org/what-would-you-do-with-an-extra-1000">distributing $1,000 to twenty different projects</a>.</p>
<p><strong>Each one-time donation of any amount to Standard Ebooks through <?= $deadline ?> gives us one entry in this $1,000 giveaway.</strong> The more donations we receive through <?= $deadline ?>, the more chances we have to win!</p>
<p><strong>This is a great time to <a href="/donate#patrons-circle">join our Patrons Circle</a> with a donation of <?= Formatter::FormatCurrency(PATRONS_CIRCLE_YEARLY_COST, true) ?>.</strong> Not only will your donation support us directly, but it’ll give us one more entry in this big giveaway.</p>
<p>Will you show your support for free, beautiful digital literature?</p>
<? if($showDonateButton){ ?>
<p class="donate-button">
<a class="button" href="/donate">Make a one-time donation!</a>
</p>
<? } ?>
</aside>