mirror of
https://github.com/standardebooks/web.git
synced 2025-07-09 16:20:27 -04:00
Add more detail to ebook placeholder page
This commit is contained in:
parent
77056dd267
commit
bbb25488e1
2 changed files with 27 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
/**
|
||||
* @property bool $IsPublicDomain
|
||||
* @property string $TimeTillIsPublicDomain A string describing how much longer it will be before this work is in the U.S. public domain, like `3 months` or `20 years`.
|
||||
*/
|
||||
class EbookPlaceholder{
|
||||
use Traits\Accessor;
|
||||
|
@ -17,6 +18,7 @@ class EbookPlaceholder{
|
|||
public ?string $Notes = null;
|
||||
|
||||
protected bool $_IsPublicDomain;
|
||||
protected string $_TimeTillIsPublicDomain;
|
||||
|
||||
protected function GetIsPublicDomain(): bool{
|
||||
if(!isset($this->_IsPublicDomain)){
|
||||
|
@ -32,6 +34,30 @@ class EbookPlaceholder{
|
|||
return $this->_IsPublicDomain;
|
||||
}
|
||||
|
||||
protected function GetTimeTillIsPublicDomain(): string{
|
||||
if(!isset($this->_TimeTillIsPublicDomain)){
|
||||
if($this->IsPublicDomain || $this->YearPublished === null){
|
||||
$this->_TimeTillIsPublicDomain = '';
|
||||
}
|
||||
else{
|
||||
$years = (int)($this->YearPublished) + 96 - (int)(NOW->format('Y'));
|
||||
if($years > 1){
|
||||
$this->_TimeTillIsPublicDomain = $years . ' years';
|
||||
}
|
||||
else{
|
||||
$months = 13 - (int)(NOW->format('n'));
|
||||
$this->_TimeTillIsPublicDomain = $months . ' month';
|
||||
|
||||
if($months != 1){
|
||||
$this->_TimeTillIsPublicDomain .= 's';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_TimeTillIsPublicDomain;
|
||||
}
|
||||
|
||||
public function FillFromHttpPost(): void{
|
||||
$this->PropertyFromHttp('YearPublished');
|
||||
$this->PropertyFromHttp('IsWanted');
|
||||
|
|
|
@ -77,7 +77,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<p>We don’t have this ebook in our catalog yet.</p>
|
||||
<p>You can <a href="/donate#sponsor-an-ebook">sponsor the production of this ebook</a> and we’ll get working on it immediately!</p>
|
||||
<? }elseif($ebook->EbookPlaceholder->YearPublished !== null){ ?>
|
||||
<p>This book was published in <?= $ebook->EbookPlaceholder->YearPublished ?>, and will therefore enter the U.S. public domain on <b>January 1, <?= $ebook->EbookPlaceholder->YearPublished + 96 ?>.</b></p>
|
||||
<p>This book was published in <?= $ebook->EbookPlaceholder->YearPublished ?>, and will therefore enter the U.S. public domain <?= $ebook->EbookPlaceholder->TimeTillIsPublicDomain != '' ? 'in ' . $ebook->EbookPlaceholder->TimeTillIsPublicDomain : '' ?> on <b>January 1, <?= $ebook->EbookPlaceholder->YearPublished + 96 ?>.</b></p>
|
||||
<p>We can’t work on it any earlier than that.</p>
|
||||
<? }else{ ?>
|
||||
<p>This book is not yet in the U.S. public domain. We can’t offer it until it is.</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue