mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Switch from EbookPlaceholder.Status to EbookPlaceholder.IsInProgress, and some type tweaks
This commit is contained in:
parent
1a742baa51
commit
e56de4b19d
8 changed files with 56 additions and 39 deletions
|
@ -1,10 +1,10 @@
|
|||
CREATE TABLE IF NOT EXISTS `EbookPlaceholders` (
|
||||
`EbookId` int(10) unsigned NOT NULL,
|
||||
`YearPublished` smallint unsigned NULL,
|
||||
`Status` enum('wanted', 'in_progress') NULL,
|
||||
`Difficulty` enum('beginner', 'intermediate', 'advanced') NULL,
|
||||
`TranscriptionUrl` varchar(511) NULL,
|
||||
`IsWanted` boolean NOT NULL DEFAULT FALSE,
|
||||
`IsInProgress` boolean NOT NULL DEFAULT FALSE,
|
||||
`IsPatron` boolean NOT NULL DEFAULT FALSE,
|
||||
`Notes` TEXT NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`EbookId`)
|
||||
|
|
16
config/sql/se/Projects.sql
Normal file
16
config/sql/se/Projects.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
CREATE TABLE IF NOT EXISTS `Projects` (
|
||||
`ProjectId` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Status` enum('in_progress','stalled','completed','abandoned') NOT NULL DEFAULT 'in_progress',
|
||||
`EbookId` int(11) NOT NULL,
|
||||
`ProducerName` varchar(151) DEFAULT NULL,
|
||||
`ProducerEmail` varchar(80) DEFAULT NULL,
|
||||
`DiscussionUrl` varchar(255) DEFAULT NULL,
|
||||
`VcsUrl` varchar(255) NOT NULL,
|
||||
`Created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`Updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
`Started` datetime NOT NULL,
|
||||
`Ended` datetime DEFAULT NULL,
|
||||
`ManagerUserId` int(11) NOT NULL,
|
||||
`ReviewerUserId` int(11) NOT NULL,
|
||||
PRIMARY KEY (`ProjectId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
@ -612,11 +612,16 @@ class Ebook{
|
|||
|
||||
protected function GetEbookPlaceholder(): ?EbookPlaceholder{
|
||||
if(!isset($this->_EbookPlaceholder)){
|
||||
$this->_EbookPlaceholder = Db::Query('
|
||||
SELECT *
|
||||
from EbookPlaceholders
|
||||
where EbookId = ?
|
||||
', [$this->EbookId], EbookPlaceholder::class)[0] ?? null;
|
||||
if(!isset($this->EbookId)){
|
||||
$this->_EbookPlaceholder = null;
|
||||
}
|
||||
else{
|
||||
$this->_EbookPlaceholder = Db::Query('
|
||||
SELECT *
|
||||
from EbookPlaceholders
|
||||
where EbookId = ?
|
||||
', [$this->EbookId], EbookPlaceholder::class)[0] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_EbookPlaceholder;
|
||||
|
|
|
@ -11,7 +11,7 @@ class EbookPlaceholder{
|
|||
public int $EbookId;
|
||||
public ?int $YearPublished = null;
|
||||
public bool $IsWanted = false;
|
||||
public ?Enums\EbookPlaceholderStatus $Status = null;
|
||||
public bool $IsInProgress = false;
|
||||
public ?Enums\EbookPlaceholderDifficulty $Difficulty = null;
|
||||
public ?string $TranscriptionUrl = null;
|
||||
public bool $IsPatron = false;
|
||||
|
@ -61,10 +61,10 @@ class EbookPlaceholder{
|
|||
public function FillFromHttpPost(): void{
|
||||
$this->PropertyFromHttp('YearPublished');
|
||||
$this->PropertyFromHttp('IsWanted');
|
||||
$this->PropertyFromHttp('IsInProgress');
|
||||
|
||||
// These properties apply only to books on the SE wanted list.
|
||||
if($this->IsWanted){
|
||||
$this->PropertyFromHttp('Status');
|
||||
$this->PropertyFromHttp('Difficulty');
|
||||
$this->PropertyFromHttp('TranscriptionUrl');
|
||||
$this->PropertyFromHttp('IsPatron');
|
||||
|
@ -104,8 +104,8 @@ class EbookPlaceholder{
|
|||
public function Create(): void{
|
||||
$this->Validate();
|
||||
Db::Query('
|
||||
INSERT into EbookPlaceholders (EbookId, YearPublished, Status, Difficulty, TranscriptionUrl,
|
||||
IsWanted, IsPatron, Notes)
|
||||
INSERT into EbookPlaceholders (EbookId, YearPublished, Difficulty, TranscriptionUrl,
|
||||
IsWanted, IsInProgress, IsPatron, Notes)
|
||||
values (?,
|
||||
?,
|
||||
?,
|
||||
|
@ -114,7 +114,7 @@ class EbookPlaceholder{
|
|||
?,
|
||||
?,
|
||||
?)
|
||||
', [$this->EbookId, $this->YearPublished, $this->Status, $this->Difficulty, $this->TranscriptionUrl,
|
||||
$this->IsWanted, $this->IsPatron, $this->Notes]);
|
||||
', [$this->EbookId, $this->YearPublished, $this->Difficulty, $this->TranscriptionUrl,
|
||||
$this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum EbookPlaceholderStatus: string{
|
||||
case Wanted = 'wanted';
|
||||
case InProgress = 'in_progress';
|
||||
}
|
|
@ -12,7 +12,7 @@ $collection = $collection ?? null;
|
|||
<meta property="schema:name" content="<?= Formatter::EscapeHtml($collection->Name) ?>"/>
|
||||
<? } ?>
|
||||
<? foreach($ebooks as $ebook){ ?>
|
||||
<li typeof="schema:Book"<? if($collection !== null){ ?> resource="<?= $ebook->Url ?>" property="schema:hasPart"<? if($ebook->GetCollectionPosition($collection) !== null){ ?> value="<?= $ebook->GetCollectionPosition($collection) ?>"<? } ?><? }else{ ?> about="<?= $ebook->Url ?>"<? } ?><? if($ebook->EbookPlaceholder?->IsWanted){ ?> class="ribbon <? if($ebook->EbookPlaceholder->Status == \Enums\EbookPlaceholderStatus::InProgress){ ?>in-progress<? }else{ ?>wanted<? } ?>"<? }elseif($ebook->EbookPlaceholder !== null && !$ebook->EbookPlaceholder->IsPublicDomain){ ?> class="ribbon not-pd"<? } ?>>
|
||||
<li typeof="schema:Book"<? if($collection !== null){ ?> resource="<?= $ebook->Url ?>" property="schema:hasPart"<? if($ebook->GetCollectionPosition($collection) !== null){ ?> value="<?= $ebook->GetCollectionPosition($collection) ?>"<? } ?><? }else{ ?> about="<?= $ebook->Url ?>"<? } ?><? if($ebook->EbookPlaceholder?->IsInProgress){ ?> class="ribbon in-progress"<? }elseif($ebook->EbookPlaceholder?->IsWanted){ ?> class="ribbon wanted"<? }elseif($ebook->EbookPlaceholder !== null && !$ebook->EbookPlaceholder->IsPublicDomain){ ?> class="ribbon not-pd"<? } ?>>
|
||||
<? if($collection !== null && $ebook->GetCollectionPosition($collection) !== null){ ?>
|
||||
<meta property="schema:position" content="<?= $ebook->GetCollectionPosition($collection) ?>"/>
|
||||
<? } ?>
|
||||
|
|
|
@ -74,7 +74,7 @@ $ebook = $ebook ?? new Ebook();
|
|||
<label class="icon book">
|
||||
<span>Title</span>
|
||||
<input type="text" name="ebook-title" required="required"
|
||||
value="<? if(isset($ebook->Title)){ ?><?= Formatter::EscapeHtml($ebook->Title) ?><? } ?>"/>
|
||||
value="<?= Formatter::EscapeHtml($ebook->Title ?? '') ?>"/>
|
||||
</label>
|
||||
<fieldset>
|
||||
<label class="icon year">
|
||||
|
@ -84,7 +84,7 @@ $ebook = $ebook ?? new Ebook();
|
|||
name="ebook-placeholder-year-published"
|
||||
inputmode="numeric"
|
||||
pattern="[0-9]{1,4}"
|
||||
value="<? if(isset($ebook->EbookPlaceholder)){ ?><?= Formatter::EscapeHtml((string)$ebook->EbookPlaceholder->YearPublished) ?><? } ?>"
|
||||
value="<?= Formatter::EscapeHtml((string)($ebook?->EbookPlaceholder?->YearPublished)) ?>"
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
@ -165,22 +165,34 @@ $ebook = $ebook ?? new Ebook();
|
|||
</fieldset>
|
||||
</details>
|
||||
<fieldset>
|
||||
|
||||
<label>
|
||||
<span>In progress?</span>
|
||||
<input type="hidden" name="ebook-placeholder-is-in-progress" value="false" />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="ebook-placeholder-is-in-progress"
|
||||
<? if($ebook?->EbookPlaceholder?->IsInProgress){ ?>checked="checked"<? } ?>
|
||||
/>
|
||||
</label>
|
||||
<legend>Wanted list</legend>
|
||||
<label class="controls-following-fieldset">
|
||||
<span>On the wanted list?</span>
|
||||
<input type="hidden" name="ebook-placeholder-is-wanted" value="false" />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="ebook-placeholder-is-wanted"
|
||||
<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->IsWanted){ ?>checked="checked"<? } ?>
|
||||
<? if($ebook?->EbookPlaceholder?->IsWanted){ ?>checked="checked"<? } ?>
|
||||
/>
|
||||
</label>
|
||||
<fieldset>
|
||||
<label>
|
||||
<span>Did a Patron request this book?</span>
|
||||
<input type="hidden" name="ebook-placeholder-is-patron" value="false" />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="ebook-placeholder-is-patron"
|
||||
<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->IsPatron){ ?>checked="checked"<? } ?>
|
||||
<? if($ebook?->EbookPlaceholder?->IsPatron){ ?>checked="checked"<? } ?>
|
||||
/>
|
||||
</label>
|
||||
<label class="icon meter">
|
||||
|
@ -188,18 +200,9 @@ $ebook = $ebook ?? new Ebook();
|
|||
<span>
|
||||
<select name="ebook-placeholder-difficulty">
|
||||
<option value=""></option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Beginner->value ?>"<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->Difficulty == Enums\EbookPlaceholderDifficulty::Beginner){ ?> selected="selected"<? } ?>>Beginner</option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Intermediate->value ?>"<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->Difficulty == Enums\EbookPlaceholderDifficulty::Intermediate){ ?> selected="selected"<? } ?>>Intermediate</option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Advanced->value ?>"<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->Difficulty == Enums\EbookPlaceholderDifficulty::Advanced){ ?> selected="selected"<? } ?>>Advanced</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<label class="icon hourglass">
|
||||
<span>Wanted list status</span>
|
||||
<span>
|
||||
<select name="ebook-placeholder-status">
|
||||
<option value="<?= Enums\EbookPlaceholderStatus::Wanted->value ?>"<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->Status == Enums\EbookPlaceholderStatus::Wanted){ ?> selected="selected"<? } ?>>Wanted</option>
|
||||
<option value="<?= Enums\EbookPlaceholderStatus::InProgress->value ?>"<? if(isset($ebook->EbookPlaceholder) && $ebook->EbookPlaceholder->Status == Enums\EbookPlaceholderStatus::InProgress){ ?> selected="selected"<? } ?>>In progress</option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Beginner->value ?>"<? if($ebook?->EbookPlaceholder?->Difficulty == Enums\EbookPlaceholderDifficulty::Beginner){ ?> selected="selected"<? } ?>>Beginner</option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Intermediate->value ?>"<? if($ebook?->EbookPlaceholder?->Difficulty == Enums\EbookPlaceholderDifficulty::Intermediate){ ?> selected="selected"<? } ?>>Intermediate</option>
|
||||
<option value="<?= Enums\EbookPlaceholderDifficulty::Advanced->value ?>"<? if($ebook?->EbookPlaceholder?->Difficulty == Enums\EbookPlaceholderDifficulty::Advanced){ ?> selected="selected"<? } ?>>Advanced</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
|
@ -208,13 +211,13 @@ $ebook = $ebook ?? new Ebook();
|
|||
<input
|
||||
type="url"
|
||||
name="ebook-placeholder-transcription-url"
|
||||
value="<? if(isset($ebook->EbookPlaceholder)){ ?><?= Formatter::EscapeHtml($ebook->EbookPlaceholder->TranscriptionUrl) ?><? } ?>"
|
||||
value="<?= Formatter::EscapeHtml($ebook?->EbookPlaceholder?->TranscriptionUrl) ?>"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Notes</span>
|
||||
<span>Markdown accepted.</span>
|
||||
<textarea maxlength="1024" name="ebook-placeholder-notes"><? if(isset($ebook->EbookPlaceholder)){ ?><?= Formatter::EscapeHtml($ebook->EbookPlaceholder->Notes) ?><? } ?></textarea>
|
||||
<textarea maxlength="1024" name="ebook-placeholder-notes"><?= Formatter::EscapeHtml($ebook?->EbookPlaceholder?->Notes) ?></textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
|
|
@ -78,7 +78,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
|
||||
<section class="placeholder-details">
|
||||
<? if($ebook->EbookPlaceholder->IsPublicDomain){ ?>
|
||||
<? if($ebook->EbookPlaceholder->Status == \Enums\EbookPlaceholderStatus::InProgress){ ?>
|
||||
<? if($ebook->EbookPlaceholder->IsInProgress){ ?>
|
||||
<p>We don’t have this ebook in our catalog yet, but someone is working on it now! We hope to have it available for you to read very soon.</p>
|
||||
<? }else{ ?>
|
||||
<p>We don’t have this ebook in our catalog yet, but it’s <? if($ebook->EbookPlaceholder->IsWanted){ ?>on our <a href="/contribute/wanted-ebooks">Wanted Ebooks list</a><? }else{ ?>in the U.S. public domain<? } ?>!</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue