84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
<?php
|
|
|
|
class MDFCollectionItem extends model implements FilesItemInterface {
|
|
|
|
const DB_TABLE = 'mdf_collection';
|
|
|
|
use FilesItemTypeTrait;
|
|
use FilesItemSizeTrait;
|
|
|
|
public int $id;
|
|
public int $issue;
|
|
public string $path;
|
|
public string $date;
|
|
public int $volume;
|
|
public int $pageFrom;
|
|
public int $pageTo;
|
|
public int $pdfPages;
|
|
public int $size;
|
|
|
|
public function isAvailable(): bool { return true; }
|
|
|
|
public function getTitleHtml(): ?string { return null; }
|
|
|
|
public function getTitle(): string {
|
|
return "№{$this->issue}, {$this->getHumanFriendlyDate()}";
|
|
}
|
|
|
|
public function getHumanFriendlyDate(): string {
|
|
$dt = new DateTime($this->date);
|
|
return $dt->format('j M Y');
|
|
}
|
|
|
|
public function isTargetBlank(): bool { return true; }
|
|
public function getId(): string { return $this->id; }
|
|
public function getUrl(): string {
|
|
global $config;
|
|
return 'https://'.$config['files_domain'].'/Mercure-de-France-OCR/'.$this->path;
|
|
}
|
|
|
|
public function getMeta(?string $hl_matched = null): array {
|
|
return [
|
|
'inline' => true,
|
|
'items' => [
|
|
'Vol. '.$this->getRomanVolume(),
|
|
'pp. '.$this->pageFrom.'-'.$this->pageTo,
|
|
sizeString($this->size),
|
|
'PDF'
|
|
]
|
|
];
|
|
}
|
|
|
|
public function getRomanVolume(): string {
|
|
$number = $this->volume;
|
|
$map = [
|
|
1000 => 'M',
|
|
900 => 'CM',
|
|
500 => 'D',
|
|
400 => 'CD',
|
|
100 => 'C',
|
|
90 => 'XC',
|
|
50 => 'L',
|
|
40 => 'XL',
|
|
10 => 'X',
|
|
9 => 'IX',
|
|
5 => 'V',
|
|
4 => 'IV',
|
|
1 => 'I',
|
|
];
|
|
$result = '';
|
|
foreach ($map as $arabic => $roman) {
|
|
while ($number >= $arabic) {
|
|
$result .= $roman;
|
|
$number -= $arabic;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function getSubtitle(): ?string {
|
|
return null;
|
|
//return 'Vol. '.$this->getRomanVolume().', pp. '.$this->pageFrom.'-'.$this->pageTo;
|
|
}
|
|
}
|