63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
class BaconianaCollectionItem extends model implements FilesItemInterface {
|
|
|
|
const DB_TABLE = 'baconiana_collection';
|
|
|
|
use FilesItemTypeTrait;
|
|
use FilesItemSizeTrait;
|
|
|
|
public int $id;
|
|
public int $parentId;
|
|
public int $year;
|
|
public string $issues;
|
|
public string $path;
|
|
public bool $jobc; // Journal of the Bacon Society
|
|
public string $title; // Only for folders
|
|
|
|
public function isAvailable(): bool { return true; }
|
|
|
|
public function getTitleHtml(): ?string { return null; }
|
|
|
|
public function getTitle(): string {
|
|
if ($this->title !== '')
|
|
return $this->title;
|
|
|
|
return ($this->jobc ? lang('baconiana_old_name') : lang('baconiana')).' №'.$this->issues;
|
|
}
|
|
|
|
public function isTargetBlank(): bool { return $this->isFile(); }
|
|
public function getId(): string { return $this->id; }
|
|
|
|
public function getUrl(): string {
|
|
if ($this->isFolder()) {
|
|
return '/files/'.FilesCollection::Baconiana->value.'/'.$this->id.'/';
|
|
}
|
|
global $config;
|
|
return 'https://'.$config['files_domain'].'/'.$this->path;
|
|
}
|
|
|
|
public function getMeta(?string $hl_matched = null): array {
|
|
$items = [];
|
|
if ($this->isFolder())
|
|
return $items;
|
|
|
|
if ($this->year >= 2007)
|
|
$items = array_merge($items, ['Online Edition']);
|
|
|
|
$items = array_merge($items, [
|
|
sizeString($this->size),
|
|
'PDF'
|
|
]);
|
|
|
|
return [
|
|
'inline' => false,
|
|
'items' => $items
|
|
];
|
|
}
|
|
|
|
public function getSubtitle(): ?string {
|
|
return $this->year > 0 ? '('.$this->year.')' : null;
|
|
}
|
|
}
|