2020-04-21 20:37:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Frank de Lange
|
|
|
|
* @copyright 2015 Frank de Lange
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2020-04-21 21:45:26 +00:00
|
|
|
namespace OCA\Epubreader\Db;
|
2020-04-21 20:37:42 +00:00
|
|
|
|
|
|
|
class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
protected string $userId; // user
|
|
|
|
protected int $fileId; // book (identified by fileId) for which this mark is valid
|
|
|
|
protected string $type; // type, defaults to "bookmark"
|
|
|
|
protected string $name; // name, defaults to $location
|
|
|
|
protected string $value; // bookmark value (format-specific, eg. page number for PDF, CFI for epub, etc)
|
|
|
|
protected string $content; // bookmark content (annotations etc), can be empty
|
2023-06-16 14:58:23 +00:00
|
|
|
|
|
|
|
public function jsonSerialize(): array {
|
|
|
|
return [
|
|
|
|
'id' => $this->getId(),
|
|
|
|
'userId' => $this->getUserId(),
|
|
|
|
'fileId' => $this->getFileId(),
|
|
|
|
'type' => $this->getType(),
|
|
|
|
'name' => $this->getName(),
|
|
|
|
'value' => static::conditional_json_decode($this->getValue()),
|
|
|
|
'content' => static::conditional_json_decode($this->getContent()),
|
|
|
|
'lastModified' => $this->getLastModified()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function toService(): array {
|
2023-06-16 14:58:23 +00:00
|
|
|
return [
|
|
|
|
'name' => $this->getName(),
|
|
|
|
'type' => $this->getType(),
|
|
|
|
'value' => $this->conditional_json_decode($this->getValue()),
|
|
|
|
'content' => $this->conditional_json_decode($this->getContent()),
|
|
|
|
'lastModified' => $this->getLastModified(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getUserId(): string {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setUserId(string $userId): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->userId = $userId;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getFileId(): int {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->fileId;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setFileId(int $fileId): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->fileId = $fileId;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getType(): string {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->type;
|
|
|
|
}
|
2020-04-21 20:37:42 +00:00
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setType(string $type): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->type = $type;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getName(): string {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setName(string $name): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getValue(): string {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setValue(string $value): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->value = $value;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function getContent(): string {
|
2023-06-16 14:58:23 +00:00
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2023-06-16 19:20:03 +00:00
|
|
|
public function setContent(string $content): void {
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->content = $content;
|
|
|
|
}
|
|
|
|
}
|