This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/lib/Controller/BookmarkController.php

97 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2020-04-21 20:37:42 +00:00
<?php
/**
* @author Frank de Lange
* @copyright 2017 Frank de Lange
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Epubreader\Controller;
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
use OCA\Epubreader\Service\BookmarkService;
2020-04-21 20:37:42 +00:00
use OCP\AppFramework\Controller;
2023-06-16 19:20:03 +00:00
use OCP\AppFramework\Http\JSONResponse;
2023-06-16 14:58:23 +00:00
use OCP\IRequest;
2020-04-21 20:37:42 +00:00
2023-08-02 20:04:03 +00:00
class BookmarkController extends Controller
{
2023-06-16 19:20:03 +00:00
private BookmarkService $bookmarkService;
2020-04-21 20:37:42 +00:00
2023-06-16 19:20:03 +00:00
public function __construct(
string $AppName,
2023-06-16 14:58:23 +00:00
IRequest $request,
2023-06-16 19:20:03 +00:00
BookmarkService $bookmarkService
) {
2023-06-16 14:58:23 +00:00
parent::__construct($AppName, $request);
$this->bookmarkService = $bookmarkService;
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief return bookmark
*
* @NoAdminRequired
* @NoCSRFRequired
2020-04-21 20:37:42 +00:00
*/
2023-08-02 20:04:03 +00:00
public function get(int $fileId, ?string $name = null, ?string $type = null): JSONResponse
{
2023-06-16 19:20:03 +00:00
return new JSONResponse($this->bookmarkService->get($fileId, $name, $type));
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief write bookmark
*
* @NoAdminRequired
* @NoCSRFRequired
2020-04-21 20:37:42 +00:00
*/
2023-08-02 20:04:03 +00:00
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): JSONResponse
{
2023-06-16 19:20:03 +00:00
return new JSONResponse($this->bookmarkService->set($fileId, $name, $value, $type, $content));
2020-04-21 20:37:42 +00:00
}
/**
2023-06-16 14:58:23 +00:00
* @brief return cursor for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
2020-04-21 20:37:42 +00:00
*/
2023-08-02 20:04:03 +00:00
public function getCursor(int $fileId): JSONResponse
{
2023-06-16 19:20:03 +00:00
return new JSONResponse($this->bookmarkService->getCursor($fileId));
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief write cursor for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
2020-04-21 20:37:42 +00:00
*/
2023-08-02 20:04:03 +00:00
public function setCursor(int $fileId, string $value): JSONResponse
{
2023-06-16 19:20:03 +00:00
return new JSONResponse($this->bookmarkService->setCursor($fileId, $value));
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
/**
* @brief delete bookmark
*
* @NoAdminRequired
* @NoCSRFRequired
*/
2023-08-02 20:04:03 +00:00
public function delete(int $fileId, string $name): void
{
2023-06-16 19:20:03 +00:00
$this->bookmarkService->delete($fileId, $name);
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
/**
* @brief delete cursor
*
* @NoAdminRequired
* @NoCSRFRequired
*/
2023-08-02 20:04:03 +00:00
public function deleteCursor(int $fileId): void
{
2023-06-16 19:20:03 +00:00
$this->bookmarkService->deleteCursor($fileId);
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
}