Improve collection title for collections with diacritics

This commit is contained in:
Alex Cabal 2019-02-27 13:26:52 -06:00
parent f8c21adaff
commit 75bfec619e

View file

@ -40,6 +40,12 @@ try{
elseif($collection !== null){
$collection = strtolower(str_replace('-', ' ', Formatter::RemoveDiacritics($collection)));
$ebooks = Library::GetEbooksByCollection($collection);
// Get the *actual* name of the collection, in case there are accent marks (like "Arsène Lupin")
foreach($ebooks[0]->Collections as $c){
if($collection == strtolower(str_replace('-', ' ', Formatter::RemoveDiacritics($c->Name)))){
$collection = (string)$c->Name; // Explicit typecast to string to satisfy PHPStan
}
}
$collectionName = ucwords(preg_replace('/^The /ius', '', $collection) ?? '');
$pageTitle = 'Browse ebooks in the ' . Formatter::ToPlainText($collectionName) . ' collection';
$pageDescription = 'A list of ebooks in the ' . Formatter::ToPlainText($collectionName) . ' collection';