mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Rename Created
and Updated
in PHP code to EbookCreated
and EbookUpdated
to match the schema
This commit is contained in:
parent
ac7db8d375
commit
f605a4df60
6 changed files with 19 additions and 19 deletions
|
@ -56,7 +56,7 @@ class AtomFeed extends Feed{
|
||||||
foreach($this->Entries as $entry){
|
foreach($this->Entries as $entry){
|
||||||
$obj = new StdClass();
|
$obj = new StdClass();
|
||||||
if($entry instanceof Ebook){
|
if($entry instanceof Ebook){
|
||||||
$obj->Updated = $entry->Updated->format('Y-m-d\TH:i:s\Z');
|
$obj->Updated = $entry->EbookUpdated->format('Y-m-d\TH:i:s\Z');
|
||||||
$obj->Id = SITE_URL . $entry->Url;
|
$obj->Id = SITE_URL . $entry->Url;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -82,12 +82,12 @@ class Ebook{
|
||||||
public $Contributors = [];
|
public $Contributors = [];
|
||||||
public ?string $ContributorsHtml = null;
|
public ?string $ContributorsHtml = null;
|
||||||
public string $TitleWithCreditsHtml = '';
|
public string $TitleWithCreditsHtml = '';
|
||||||
public DateTimeImmutable $Created;
|
|
||||||
public DateTimeImmutable $Updated;
|
|
||||||
public ?string $TextUrl;
|
public ?string $TextUrl;
|
||||||
public ?string $TextSinglePageUrl;
|
public ?string $TextSinglePageUrl;
|
||||||
public ?string $TextSinglePageSizeNumber = null;
|
public ?string $TextSinglePageSizeNumber = null;
|
||||||
public ?string $TextSinglePageSizeUnit = null;
|
public ?string $TextSinglePageSizeUnit = null;
|
||||||
|
public DateTimeImmutable $EbookCreated;
|
||||||
|
public DateTimeImmutable $EbookUpdated;
|
||||||
public ?int $TextSinglePageByteCount = null;
|
public ?int $TextSinglePageByteCount = null;
|
||||||
/** @var ?array<string> $TocEntries */
|
/** @var ?array<string> $TocEntries */
|
||||||
public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise
|
public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise
|
||||||
|
@ -296,13 +296,13 @@ class Ebook{
|
||||||
$date = $xml->xpath('/package/metadata/dc:date') ?: [];
|
$date = $xml->xpath('/package/metadata/dc:date') ?: [];
|
||||||
if($date !== false && sizeof($date) > 0){
|
if($date !== false && sizeof($date) > 0){
|
||||||
/** @throws void */
|
/** @throws void */
|
||||||
$this->Created = new DateTimeImmutable((string)$date[0]);
|
$this->EbookCreated = new DateTimeImmutable((string)$date[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]') ?: [];
|
$modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]') ?: [];
|
||||||
if($modifiedDate !== false && sizeof($modifiedDate) > 0){
|
if($modifiedDate !== false && sizeof($modifiedDate) > 0){
|
||||||
/** @throws void */
|
/** @throws void */
|
||||||
$this->Updated = new DateTimeImmutable((string)$modifiedDate[0]);
|
$this->EbookUpdated = new DateTimeImmutable((string)$modifiedDate[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get SE tags
|
// Get SE tags
|
||||||
|
@ -722,12 +722,12 @@ class Ebook{
|
||||||
$error->Add(new Exceptions\StringTooLongException('Ebook WikipediaUrl'));
|
$error->Add(new Exceptions\StringTooLongException('Ebook WikipediaUrl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Created > $now || $this->Created < EBOOK_EARLIEST_CREATION_DATE){
|
if($this->EbookCreated > $now || $this->EbookCreated < EBOOK_EARLIEST_CREATION_DATE){
|
||||||
$error->Add(new Exceptions\InvalidEbookCreatedDatetimeException($this->Created));
|
$error->Add(new Exceptions\InvalidEbookCreatedDatetimeException($this->EbookCreated));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Updated > $now || $this->Updated < EBOOK_EARLIEST_CREATION_DATE){
|
if($this->EbookUpdated > $now || $this->EbookUpdated < EBOOK_EARLIEST_CREATION_DATE){
|
||||||
$error->Add(new Exceptions\InvalidEbookUpdatedDatetimeException($this->Updated));
|
$error->Add(new Exceptions\InvalidEbookUpdatedDatetimeException($this->EbookUpdated));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,7 +1144,7 @@ class Ebook{
|
||||||
$this->AdvancedEpubUrl, $this->KepubUrl, $this->Azw3Url, $this->DistCoverUrl, $this->Title,
|
$this->AdvancedEpubUrl, $this->KepubUrl, $this->Azw3Url, $this->DistCoverUrl, $this->Title,
|
||||||
$this->FullTitle, $this->AlternateTitle, $this->Description, $this->LongDescription,
|
$this->FullTitle, $this->AlternateTitle, $this->Description, $this->LongDescription,
|
||||||
$this->Language, $this->WordCount, $this->ReadingEase, $this->GitHubUrl, $this->WikipediaUrl,
|
$this->Language, $this->WordCount, $this->ReadingEase, $this->GitHubUrl, $this->WikipediaUrl,
|
||||||
$this->Created, $this->Updated, $this->TextSinglePageByteCount, $this->IndexableText]);
|
$this->EbookCreated, $this->EbookUpdated, $this->TextSinglePageByteCount, $this->IndexableText]);
|
||||||
|
|
||||||
$this->EbookId = Db::GetLastInsertedId();
|
$this->EbookId = Db::GetLastInsertedId();
|
||||||
|
|
||||||
|
@ -1198,7 +1198,7 @@ class Ebook{
|
||||||
$this->AdvancedEpubUrl, $this->KepubUrl, $this->Azw3Url, $this->DistCoverUrl, $this->Title,
|
$this->AdvancedEpubUrl, $this->KepubUrl, $this->Azw3Url, $this->DistCoverUrl, $this->Title,
|
||||||
$this->FullTitle, $this->AlternateTitle, $this->Description, $this->LongDescription,
|
$this->FullTitle, $this->AlternateTitle, $this->Description, $this->LongDescription,
|
||||||
$this->Language, $this->WordCount, $this->ReadingEase, $this->GitHubUrl, $this->WikipediaUrl,
|
$this->Language, $this->WordCount, $this->ReadingEase, $this->GitHubUrl, $this->WikipediaUrl,
|
||||||
$this->Created, $this->Updated, $this->TextSinglePageByteCount, $this->IndexableText,
|
$this->EbookCreated, $this->EbookUpdated, $this->TextSinglePageByteCount, $this->IndexableText,
|
||||||
$this->EbookId]);
|
$this->EbookId]);
|
||||||
|
|
||||||
$this->DeleteTags();
|
$this->DeleteTags();
|
||||||
|
|
|
@ -59,10 +59,10 @@ class Library{
|
||||||
|
|
||||||
case EbookSortType::Newest:
|
case EbookSortType::Newest:
|
||||||
usort($matches, function($a, $b){
|
usort($matches, function($a, $b){
|
||||||
if($a->Created < $b->Created){
|
if($a->EbookCreated < $b->EbookCreated){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
elseif($a->Created == $b->Created){
|
elseif($a->EbookCreated == $b->EbookCreated){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -105,8 +105,8 @@ function CreateZip(string $filePath, array $ebooks, string $type, string $webRoo
|
||||||
|
|
||||||
// Iterate over all ebooks and arrange them by publication month
|
// Iterate over all ebooks and arrange them by publication month
|
||||||
foreach(Library::GetEbooksFromFilesystem($webRoot) as $ebook){
|
foreach(Library::GetEbooksFromFilesystem($webRoot) as $ebook){
|
||||||
$timestamp = $ebook->Created->format('Y-m');
|
$timestamp = $ebook->EbookCreated->format('Y-m');
|
||||||
$updatedTimestamp = $ebook->Updated->getTimestamp();
|
$updatedTimestamp = $ebook->EbookUpdated->getTimestamp();
|
||||||
|
|
||||||
// Add to the 'ebooks by month' list
|
// Add to the 'ebooks by month' list
|
||||||
if(!isset($ebooksByGroup['months'][$timestamp])){
|
if(!isset($ebooksByGroup['months'][$timestamp])){
|
||||||
|
|
|
@ -10,7 +10,7 @@ use function Safe\mkdir;
|
||||||
use function Safe\preg_replace;
|
use function Safe\preg_replace;
|
||||||
|
|
||||||
function SortByUpdatedDesc(Ebook $a, Ebook $b): int{
|
function SortByUpdatedDesc(Ebook $a, Ebook $b): int{
|
||||||
return $b->Updated <=> $a->Updated;
|
return $b->EbookUpdated <=> $a->EbookUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SaveFeed(Feed $feed, bool $force, ?string $label = null, ?string $labelSort = null, DateTimeImmutable $now = null): void{
|
function SaveFeed(Feed $feed, bool $force, ?string $label = null, ?string $labelSort = null, DateTimeImmutable $now = null): void{
|
||||||
|
@ -111,7 +111,7 @@ foreach(Library::GetEbooksFromFilesystem($webRoot) as $ebook){
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($allEbooks, 'SortByUpdatedDesc');
|
usort($allEbooks, 'SortByUpdatedDesc');
|
||||||
usort($newestEbooks, function($a, $b){ return $b->Created <=> $a->Created; });
|
usort($newestEbooks, function($a, $b){ return $b->EbookCreated <=> $a->EbookCreated; });
|
||||||
$newestEbooks = array_slice($newestEbooks, 0, $ebooksPerNewestEbooksFeed);
|
$newestEbooks = array_slice($newestEbooks, 0, $ebooksPerNewestEbooksFeed);
|
||||||
|
|
||||||
// Create OPDS feeds.
|
// Create OPDS feeds.
|
||||||
|
|
|
@ -198,8 +198,8 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
<meta property="schema:image" content="<?= Formatter::EscapeHtml(SITE_URL . $ebook->DistCoverUrl) ?>"/>
|
<meta property="schema:image" content="<?= Formatter::EscapeHtml(SITE_URL . $ebook->DistCoverUrl) ?>"/>
|
||||||
<meta property="schema:thumbnailUrl" content="<?= Formatter::EscapeHtml(SITE_URL . $ebook->Url . '/downloads/cover-thumbnail.jpg') ?>"/>
|
<meta property="schema:thumbnailUrl" content="<?= Formatter::EscapeHtml(SITE_URL . $ebook->Url . '/downloads/cover-thumbnail.jpg') ?>"/>
|
||||||
<meta property="schema:inLanguage" content="<?= Formatter::EscapeHtml($ebook->Language) ?>"/>
|
<meta property="schema:inLanguage" content="<?= Formatter::EscapeHtml($ebook->Language) ?>"/>
|
||||||
<meta property="schema:datePublished" content="<?= Formatter::EscapeHtml($ebook->Created->format('Y-m-d')) ?>"/>
|
<meta property="schema:datePublished" content="<?= Formatter::EscapeHtml($ebook->EbookCreated->format('Y-m-d')) ?>"/>
|
||||||
<meta property="schema:dateModified" content="<?= Formatter::EscapeHtml($ebook->Updated->format('Y-m-d')) ?>"/>
|
<meta property="schema:dateModified" content="<?= Formatter::EscapeHtml($ebook->EbookUpdated->format('Y-m-d')) ?>"/>
|
||||||
<div property="schema:potentialAction" typeof="http://schema.org/ReadAction">
|
<div property="schema:potentialAction" typeof="http://schema.org/ReadAction">
|
||||||
<meta property="schema:actionStatus" content="http://schema.org/PotentialActionStatus"/>
|
<meta property="schema:actionStatus" content="http://schema.org/PotentialActionStatus"/>
|
||||||
<div property="schema:target" typeof="schema:EntryPoint">
|
<div property="schema:target" typeof="schema:EntryPoint">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue