mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 02:46:46 -04:00
Update PHPStan and Safe PHP, and review codebase for further type correctness
This commit is contained in:
parent
e2e14a3551
commit
9d1b66d19e
35 changed files with 301 additions and 169 deletions
|
@ -3,21 +3,14 @@
|
|||
* @var Artwork $artwork
|
||||
*/
|
||||
?>
|
||||
<? if($artwork !== null){ ?>
|
||||
<? if($artwork->Status !== null){ ?>
|
||||
<?= ucfirst($artwork->Status->value) ?>
|
||||
<? } ?>
|
||||
<? if($artwork->EbookUrl !== null){ ?>
|
||||
— in use
|
||||
<? if($artwork->EbookUrl !== null){ ?>
|
||||
by
|
||||
<? if($artwork->Ebook !== null && $artwork->Ebook->Url !== null){ ?>
|
||||
<i>
|
||||
<a href="<?= $artwork->Ebook->Url ?>"><?= Formatter::EscapeHtml($artwork->Ebook->Title) ?></a>
|
||||
</i><? if($artwork->Ebook->IsPlaceholder()){ ?>(unreleased)<? } ?>
|
||||
<? }else{ ?>
|
||||
<code><?= Formatter::EscapeHtml($artwork->EbookUrl) ?></code> (unreleased)
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
<?= ucfirst($artwork->Status->value) ?>
|
||||
<? if($artwork->EbookUrl !== null){ ?>
|
||||
— in use by
|
||||
<? if($artwork->Ebook !== null && $artwork->Ebook->Url !== null){ ?>
|
||||
<i>
|
||||
<a href="<?= $artwork->Ebook->Url ?>"><?= Formatter::EscapeHtml($artwork->Ebook->Title) ?></a>
|
||||
</i><? if($artwork->Ebook->IsPlaceholder()){ ?>(unreleased)<? } ?>
|
||||
<? }else{ ?>
|
||||
<code><?= Formatter::EscapeHtml($artwork->EbookUrl) ?></code> (unreleased)
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?
|
||||
// Hide this alert if...
|
||||
$donationDrive = DonationDrive::GetByIsRunning();
|
||||
|
||||
// Hide this alert if...
|
||||
if(
|
||||
Session::$User !== null // If a user is logged in.
|
||||
||
|
||||
|
@ -12,17 +12,17 @@ if(
|
|||
return;
|
||||
}
|
||||
|
||||
if(Session::$User === null){
|
||||
// The Kindle browsers renders `<aside>` as an undismissable popup. Serve a `<div>` to Kindle instead.
|
||||
// See <https://github.com/standardebooks/web/issues/204>.
|
||||
$element = 'aside';
|
||||
|
||||
if(stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'kindle') !== false){
|
||||
/** @var string $httpUserAgent */
|
||||
$httpUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
if(stripos($httpUserAgent, 'kindle') !== false){
|
||||
$element = 'div';
|
||||
}
|
||||
?>
|
||||
<<?= $element ?> class="donation">
|
||||
<p>We rely on your support to help us keep producing beautiful, free, and unrestricted editions of literature for the digital age.</p>
|
||||
<p>Will you <a href="/donate">support our efforts with a donation</a>?</p>
|
||||
</<?= $element ?>>
|
||||
<? } ?>
|
||||
<<?= $element ?> class="donation">
|
||||
<p>We rely on your support to help us keep producing beautiful, free, and unrestricted editions of literature for the digital age.</p>
|
||||
<p>Will you <a href="/donate">support our efforts with a donation</a>?</p>
|
||||
</<?= $element ?>>
|
||||
|
|
|
@ -19,7 +19,15 @@ $showPublicDomainDayBanner = PD_NOW > new DateTimeImmutable('January 1, 8:00 AM'
|
|||
// As of Sep. 2022, all versions of Safari have a bug where if the page is served as XHTML, then `<picture>` elements download all `<source>`s instead of the first supported match.
|
||||
// So, we try to detect Safari here, and don't use multiple `<source>` if we find Safari.
|
||||
// See <https://bugs.webkit.org/show_bug.cgi?id=245411>.
|
||||
$isSafari = stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'safari') !== false;
|
||||
/** @var string $httpUserAgent */
|
||||
$httpUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
$isSafari = stripos($httpUserAgent, 'safari') !== false;
|
||||
|
||||
if(!$isErrorPage){
|
||||
/** @var string $url */
|
||||
$url = $_SERVER['ORIG_PATH_INFO'] ?? $_SERVER['SCRIPT_URI'] ?? '';
|
||||
$pageUrl = SITE_URL . str_replace(SITE_URL, '', ($url));
|
||||
}
|
||||
|
||||
if(!$isXslt){
|
||||
if(!$isSafari){
|
||||
|
@ -84,7 +92,7 @@ if(!$isXslt){
|
|||
<meta content="#394451" name="theme-color"/>
|
||||
<meta content="<? if($title != ''){ ?><?= Formatter::EscapeHtml($title) ?><? }else{ ?>Standard Ebooks<? } ?>" property="og:title"/>
|
||||
<meta content="<?= $ogType ?? 'website' ?>" property="og:type"/>
|
||||
<meta content="<?= SITE_URL . str_replace(SITE_URL, '', ($_SERVER['ORIG_PATH_INFO'] ?? $_SERVER['SCRIPT_URI'] ?? '')) ?>" property="og:url"/>
|
||||
<meta content="<?= $pageUrl ?>" property="og:url"/>
|
||||
<meta content="<?= SITE_URL . ($coverUrl ?? '/images/logo.png') ?>" property="og:image"/>
|
||||
<meta content="summary_large_image" name="twitter:card"/>
|
||||
<meta content="@standardebooks" name="twitter:site"/>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @var string $id
|
||||
* @var string $url
|
||||
* @var string $parentUrl
|
||||
* @var ?string $parentUrl
|
||||
* @var string $title
|
||||
* @var ?string $subtitle
|
||||
* @var DateTimeImmutable $updated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue