54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
class WFFCollectionItem extends model implements FilesItemInterface {
|
|
|
|
const DB_TABLE = 'wff_collection';
|
|
|
|
use FilesItemTypeTrait;
|
|
use FilesItemSizeTrait;
|
|
|
|
public int $id;
|
|
public int $parentId;
|
|
public string $title;
|
|
public string $documentId;
|
|
public string $path;
|
|
public int $filesCount;
|
|
|
|
public function getTitleHtml(): ?string { return null; }
|
|
public function getId(): string { return (string)$this->id; }
|
|
public function isAvailable(): bool { return true; }
|
|
public function getTitle(): string { return $this->title; }
|
|
public function getDocumentId(): string { return $this->isFolder() ? str_replace('_', ' ', basename($this->path)) : $this->documentId; }
|
|
public function isTargetBlank(): bool { return $this->isFile(); }
|
|
public function getSubtitle(): ?string { return null; }
|
|
|
|
public function getUrl(): string {
|
|
global $config;
|
|
return $this->isFolder()
|
|
? "/files/wff/{$this->id}/"
|
|
: "https://{$config['files_domain']}/NSA Friedman Documents/{$this->path}";
|
|
}
|
|
|
|
public function getMeta(?string $hl_matched = null): array {
|
|
if ($this->isFolder()) {
|
|
if (!$this->parentId)
|
|
return [];
|
|
return [
|
|
'items' => [
|
|
highlightSubstring($this->getDocumentId(), $hl_matched),
|
|
langNum('files_count', $this->filesCount)
|
|
]
|
|
];
|
|
}
|
|
return [
|
|
'inline' => false,
|
|
'items' => [
|
|
highlightSubstring('Document '.$this->documentId),
|
|
sizeString($this->size),
|
|
'PDF'
|
|
]
|
|
];
|
|
}
|
|
|
|
}
|