mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 04:16:38 -04:00
Change 'timestamp' properties on objects to more descriptive names
This commit is contained in:
parent
18f761929a
commit
dbefba6b94
32 changed files with 74 additions and 74 deletions
|
@ -21,7 +21,7 @@ class AtomFeed extends Feed{
|
|||
|
||||
protected function GetXmlString(): string{
|
||||
if($this->XmlString === null){
|
||||
$feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updatedTimestamp' => $this->Updated, 'entries' => $this->Entries]);
|
||||
$feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updated' => $this->Updated, 'entries' => $this->Entries]);
|
||||
|
||||
$this->XmlString = $this->CleanXmlString($feed);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class AtomFeed extends Feed{
|
|||
foreach($this->Entries as $entry){
|
||||
$obj = new StdClass();
|
||||
if(is_a($entry, 'Ebook')){
|
||||
$obj->Updated = $entry->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z');
|
||||
$obj->Updated = $entry->Modified->format('Y-m-d\TH:i:s\Z');
|
||||
$obj->Id = SITE_URL . $entry->Url;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -53,8 +53,8 @@ class Ebook{
|
|||
public $Contributors = []; // Array of Contributors
|
||||
public $ContributorsHtml;
|
||||
public $TitleWithCreditsHtml = '';
|
||||
public $Timestamp;
|
||||
public $ModifiedTimestamp;
|
||||
public $Created;
|
||||
public $Modified;
|
||||
public $TextUrl;
|
||||
public $TextSinglePageUrl;
|
||||
public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise
|
||||
|
@ -151,7 +151,7 @@ class Ebook{
|
|||
if(stripos($this->RepoFilesystemPath, '.git') === false){
|
||||
$gitFolderPath = $gitFolderPath . '/.git';
|
||||
}
|
||||
$hash = substr(sha1($this->GitCommits[0]->Timestamp->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8);
|
||||
$hash = substr(sha1($this->GitCommits[0]->Created->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8);
|
||||
$this->CoverImageUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.jpg';
|
||||
if(file_exists(WEB_ROOT . '/images/covers/' . $this->UrlSafeIdentifier . '-cover.avif')){
|
||||
$this->CoverImageAvifUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.avif';
|
||||
|
@ -186,12 +186,12 @@ class Ebook{
|
|||
|
||||
$date = $xml->xpath('/package/metadata/dc:date');
|
||||
if($date !== false && sizeof($date) > 0){
|
||||
$this->Timestamp = new DateTime((string)$date[0]);
|
||||
$this->Created = new DateTime((string)$date[0]);
|
||||
}
|
||||
|
||||
$modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]');
|
||||
if($modifiedDate !== false && sizeof($modifiedDate) > 0){
|
||||
$this->ModifiedTimestamp = new DateTime((string)$modifiedDate[0]);
|
||||
$this->Modified = new DateTime((string)$modifiedDate[0]);
|
||||
}
|
||||
|
||||
// Get SE tags
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
use Safe\DateTimeImmutable;
|
||||
|
||||
class GitCommit{
|
||||
public $Timestamp;
|
||||
public $Created;
|
||||
public $Message;
|
||||
public $Hash;
|
||||
|
||||
public function __construct(string $unixTimestamp, string $hash, string $message){
|
||||
$this->Timestamp = new DateTimeImmutable('@' . $unixTimestamp);
|
||||
$this->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
||||
$this->Message = $message;
|
||||
$this->Hash = $hash;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ class Library{
|
|||
|
||||
case SORT_NEWEST:
|
||||
usort($matches, function($a, $b){
|
||||
if($a->Timestamp < $b->Timestamp){
|
||||
if($a->Created < $b->Created){
|
||||
return -1;
|
||||
}
|
||||
elseif($a->Timestamp == $b->Timestamp){
|
||||
elseif($a->Created == $b->Created){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -11,7 +11,7 @@ class NewsletterSubscriber extends PropertiesBase{
|
|||
public $IsConfirmed = false;
|
||||
public $IsSubscribedToSummary = true;
|
||||
public $IsSubscribedToNewsletter = true;
|
||||
public $Timestamp;
|
||||
public $Created;
|
||||
protected $Url = null;
|
||||
|
||||
protected function GetUrl(): string{
|
||||
|
@ -27,10 +27,10 @@ class NewsletterSubscriber extends PropertiesBase{
|
|||
|
||||
$uuid = Uuid::uuid4();
|
||||
$this->Uuid = $uuid->toString();
|
||||
$this->Timestamp = new DateTime();
|
||||
$this->Created = new DateTime();
|
||||
|
||||
try{
|
||||
Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Timestamp) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Timestamp]);
|
||||
Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Created) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Created]);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
if($ex->errorInfo[1] == 1062){
|
||||
|
|
|
@ -11,7 +11,7 @@ class OpdsAcquisitionFeed extends OpdsFeed{
|
|||
|
||||
protected function GetXmlString(): string{
|
||||
if($this->XmlString === null){
|
||||
$this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
|
||||
$this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
|
||||
}
|
||||
|
||||
return $this->XmlString;
|
||||
|
|
|
@ -11,24 +11,24 @@ class OpdsFeed extends AtomFeed{
|
|||
$this->Stylesheet = '/feeds/opds/style';
|
||||
}
|
||||
|
||||
protected function SaveUpdatedTimestamp(string $entryId, DateTime $updatedTimestamp): void{
|
||||
protected function SaveUpdated(string $entryId, DateTime $updated): void{
|
||||
// Only save the updated timestamp for the given entry ID in this file
|
||||
foreach($this->Entries as $entry){
|
||||
if(is_a($entry, 'OpdsNavigationEntry')){
|
||||
if($entry->Id == SITE_URL . $entryId){
|
||||
$entry->Updated = $updatedTimestamp;
|
||||
$entry->Updated = $updated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->Updated = $updatedTimestamp;
|
||||
$this->Updated = $updated;
|
||||
|
||||
$this->XmlString = null;
|
||||
file_put_contents($this->Path, $this->GetXmlString());
|
||||
|
||||
// Do we have any parents of our own to update?
|
||||
if($this->Parent !== null){
|
||||
$this->Parent->SaveUpdatedTimestamp($this->Id, $updatedTimestamp);
|
||||
$this->Parent->SaveUpdated($this->Id, $updated);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class OpdsFeed extends AtomFeed{
|
|||
$this->Updated = new DateTime();
|
||||
|
||||
if($this->Parent !== null){
|
||||
$this->Parent->SaveUpdatedTimestamp($this->Id, $this->Updated);
|
||||
$this->Parent->SaveUpdated($this->Id, $this->Updated);
|
||||
}
|
||||
|
||||
// Save our own file
|
||||
|
|
|
@ -31,7 +31,7 @@ class OpdsNavigationFeed extends OpdsFeed{
|
|||
|
||||
protected function GetXmlString(): string{
|
||||
if($this->XmlString === null){
|
||||
$this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
|
||||
$this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
|
||||
}
|
||||
|
||||
return $this->XmlString;
|
||||
|
|
|
@ -7,8 +7,8 @@ class Patron extends PropertiesBase{
|
|||
public $IsAnonymous;
|
||||
public $AlternateName;
|
||||
public $IsSubscribedToEmail;
|
||||
public $Timestamp = null;
|
||||
public $DeactivatedTimestamp = null;
|
||||
public $Created = null;
|
||||
public $Ended = null;
|
||||
|
||||
public static function Get(?int $userId): Patron{
|
||||
$result = Db::Query('SELECT * from Patrons where UserId = ?', [$userId], 'Patron');
|
||||
|
@ -31,9 +31,9 @@ class Patron extends PropertiesBase{
|
|||
}
|
||||
|
||||
public function Create(bool $sendEmail = true): void{
|
||||
$this->Timestamp = new DateTime();
|
||||
$this->Created = new DateTime();
|
||||
|
||||
Db::Query('INSERT into Patrons (Timestamp, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Timestamp, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]);
|
||||
Db::Query('INSERT into Patrons (Created, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Created, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]);
|
||||
|
||||
if($sendEmail){
|
||||
$this->SendWelcomeEmail();
|
||||
|
@ -41,9 +41,9 @@ class Patron extends PropertiesBase{
|
|||
}
|
||||
|
||||
public function Reactivate(bool $sendEmail = true): void{
|
||||
Db::Query('UPDATE Patrons set Timestamp = utc_timestamp(), DeactivatedTimestamp = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]);
|
||||
$this->Timestamp = new DateTime();
|
||||
$this->DeactivatedTimestamp = null;
|
||||
Db::Query('UPDATE Patrons set Created = utc_timestamp(), Ended = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]);
|
||||
$this->Created = new DateTime();
|
||||
$this->Ended = null;
|
||||
|
||||
if($sendEmail){
|
||||
$this->SendWelcomeEmail();
|
||||
|
|
|
@ -4,7 +4,7 @@ class Payment extends PropertiesBase{
|
|||
public $PaymentId;
|
||||
protected $User = null;
|
||||
public $UserId = null;
|
||||
public $Timestamp;
|
||||
public $Created;
|
||||
public $ChannelId;
|
||||
public $TransactionId;
|
||||
public $Amount;
|
||||
|
@ -33,7 +33,7 @@ class Payment extends PropertiesBase{
|
|||
}
|
||||
|
||||
try{
|
||||
Db::Query('INSERT into Payments (UserId, Timestamp, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Timestamp, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]);
|
||||
Db::Query('INSERT into Payments (UserId, Created, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Created, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
if($ex->errorInfo[1] == 1062){
|
||||
|
|
|
@ -15,7 +15,7 @@ class RssFeed extends Feed{
|
|||
|
||||
protected function GetXmlString(): string{
|
||||
if($this->XmlString === null){
|
||||
$feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updatedTimestamp' => (new DateTime())->format('r')]);
|
||||
$feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updated' => (new DateTime())->format('r')]);
|
||||
|
||||
$this->XmlString = $this->CleanXmlString($feed);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class User extends PropertiesBase{
|
|||
protected $DisplayName = null;
|
||||
public $Email;
|
||||
protected $DisplayEmail;
|
||||
public $Timestamp;
|
||||
public $Created;
|
||||
public $Uuid;
|
||||
|
||||
public static function Get(?int $userId): User{
|
||||
|
@ -46,10 +46,10 @@ class User extends PropertiesBase{
|
|||
public function Create(): void{
|
||||
$uuid = Uuid::uuid4();
|
||||
$this->Uuid = $uuid->toString();
|
||||
$this->Timestamp = new DateTime();
|
||||
$this->Created = new DateTime();
|
||||
|
||||
try{
|
||||
Db::Query('INSERT into Users (Email, Name, Uuid, Timestamp) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Timestamp]);
|
||||
Db::Query('INSERT into Users (Email, Name, Uuid, Created) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Created]);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
if($ex->errorInfo[1] == 1062){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue