mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 04:44:48 -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue