Refacto all project
This commit is contained in:
parent
ba42ac92af
commit
e896016ff9
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
.idea
|
||||
*.iml
|
||||
/vendor/
|
||||
/build/
|
||||
node_modules/
|
||||
/.php-cs-fixer.cache
|
||||
js/*hot-update.*
|
18
.php-cs-fixer.dist.php
Normal file
18
.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once './vendor/autoload.php';
|
||||
|
||||
use Nextcloud\CodingStandard\Config;
|
||||
|
||||
$config = new Config();
|
||||
$config
|
||||
->getFinder()
|
||||
->ignoreVCSIgnored(true)
|
||||
->notPath('build')
|
||||
->notPath('l10n')
|
||||
->notPath('src')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__);
|
||||
return $config;
|
@ -12,7 +12,6 @@
|
||||
|
||||
namespace OCA\Epubreader\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\Util;
|
||||
|
||||
$l = \OC::$server->getL10N('epubreader');
|
||||
|
@ -29,7 +29,7 @@ See [README] for more exhaustive information on features and potential misfeatur
|
||||
[README]: https://github.com/e-alfred/epubreader/blob/master/epubreader/README.md
|
||||
]]>
|
||||
</description>
|
||||
<version>1.4.7</version>
|
||||
<version>1.4.8</version>
|
||||
<licence>agpl</licence>
|
||||
<author>Frank de Lange</author>
|
||||
<author>e-alfred</author>
|
||||
@ -46,7 +46,7 @@ See [README] for more exhaustive information on features and potential misfeatur
|
||||
<screenshot>https://github.com/e-alfred/epubreader/blob/master/screenshots/photo_2017-03-15_17-22-00.jpg?raw=true</screenshot>
|
||||
<screenshot>https://github.com/e-alfred/epubreader/blob/master/screenshots/photo_2017-03-15_17-22-02.jpg?raw=true</screenshot>
|
||||
<dependencies>
|
||||
<nextcloud min-version="21" max-version="23"/>
|
||||
<nextcloud min-version="21" max-version="27"/>
|
||||
</dependencies>
|
||||
<settings>
|
||||
<personal>OCA\Epubreader\Settings\Personal</personal>
|
||||
|
@ -11,31 +11,30 @@
|
||||
*/
|
||||
|
||||
return ['routes' => [
|
||||
// Page
|
||||
['name' => 'page#showReader', 'url' => '/', 'verb' => 'GET'],
|
||||
// Page
|
||||
['name' => 'page#showReader', 'url' => '/', 'verb' => 'GET'],
|
||||
|
||||
// Bookmarks
|
||||
['name' => 'bookmark#get_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'GET'],
|
||||
['name' => 'bookmark#set_cursor', 'url' => '/bookmark/cursor', 'verb' => 'POST'],
|
||||
['name' => 'bookmark#delete_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'DELETE'],
|
||||
['name' => 'bookmark#get', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'bookmark#get', 'url' => '/bookmark/{fileId}/{type}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'bookmark#set', 'url' => '/bookmark', 'verb' => 'POST'],
|
||||
['name' => 'bookmark#delete', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'DELETE'],
|
||||
// Bookmarks
|
||||
['name' => 'bookmark#get_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'GET'],
|
||||
['name' => 'bookmark#set_cursor', 'url' => '/bookmark/cursor', 'verb' => 'POST'],
|
||||
['name' => 'bookmark#delete_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'DELETE'],
|
||||
['name' => 'bookmark#get', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'bookmark#get', 'url' => '/bookmark/{fileId}/{type}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'bookmark#set', 'url' => '/bookmark', 'verb' => 'POST'],
|
||||
['name' => 'bookmark#delete', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'DELETE'],
|
||||
|
||||
// Metadata
|
||||
['name' => 'metadata#get', 'url' => '/metadata/{fileId}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'metadata#set', 'url' => '/metadata/{fileId}/{name}/{value}', 'verb' => 'POST'],
|
||||
// Metadata
|
||||
['name' => 'metadata#get', 'url' => '/metadata/{fileId}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'metadata#set', 'url' => '/metadata/{fileId}/{name}/{value}', 'verb' => 'POST'],
|
||||
|
||||
// Preferences
|
||||
['name' => 'preference#get_default', 'url' => '/preference/default/{scope}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'preference#set_default', 'url' => '/preference/default', 'verb' => 'POST'],
|
||||
['name' => 'preference#delete_default', 'url' => '/preference/default/{scope}/{name}', 'verb' => 'DELETE'],
|
||||
['name' => 'preference#get', 'url' => '/preference/{fileId}/{scope}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'preference#set', 'url' => '/preference', 'verb' => 'POST'],
|
||||
['name' => 'preference#delete', 'url' => '/preference/{fileId}/{scope}/{name}', 'verb' => 'DELETE'],
|
||||
// Preferences
|
||||
['name' => 'preference#get_default', 'url' => '/preference/default/{scope}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'preference#set_default', 'url' => '/preference/default', 'verb' => 'POST'],
|
||||
['name' => 'preference#delete_default', 'url' => '/preference/default/{scope}/{name}', 'verb' => 'DELETE'],
|
||||
['name' => 'preference#get', 'url' => '/preference/{fileId}/{scope}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||
['name' => 'preference#set', 'url' => '/preference', 'verb' => 'POST'],
|
||||
['name' => 'preference#delete', 'url' => '/preference/{fileId}/{scope}/{name}', 'verb' => 'DELETE'],
|
||||
|
||||
// User Settings
|
||||
['name' => 'settings#setPreference', 'url' => '/settings/set', 'verb' => 'POST'],
|
||||
]];
|
||||
|
||||
|
30
composer.json
Normal file
30
composer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nextcloud/epubreader",
|
||||
"description": "EPUB/CBZ/PDF ebook reader",
|
||||
"version": "1.4.8",
|
||||
"type": "project",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"require-dev": {
|
||||
"nextcloud/ocp": "^21.0.0",
|
||||
"psalm/phar": "^5.12.0",
|
||||
"nextcloud/coding-standard": "^1.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
|
||||
"cs:check": "php-cs-fixer fix --dry-run --diff",
|
||||
"cs:fix": "php-cs-fixer fix",
|
||||
"psalm": "psalm.phar --threads=1 --no-cache",
|
||||
"psalm:fix": "psalm.phar --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OCA\\Epubreader\\": "lib/",
|
||||
"OC\\": "stubs/oc/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.4"
|
||||
}
|
||||
}
|
||||
}
|
189
composer.lock
generated
Normal file
189
composer.lock
generated
Normal file
@ -0,0 +1,189 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6684feffdd51c1ea6c0f31066f3e5560",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "nextcloud/coding-standard",
|
||||
"version": "v1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nextcloud/coding-standard.git",
|
||||
"reference": "55def702fb9a37a219511e1d8c6fe8e37164c1fb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/55def702fb9a37a219511e1d8c6fe8e37164c1fb",
|
||||
"reference": "55def702fb9a37a219511e1d8c6fe8e37164c1fb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3|^8.0",
|
||||
"php-cs-fixer/shim": "^3.17"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Nextcloud\\CodingStandard\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christoph Wurst",
|
||||
"email": "christoph@winzerhof-wurst.at"
|
||||
}
|
||||
],
|
||||
"description": "Nextcloud coding standards for the php cs fixer",
|
||||
"support": {
|
||||
"issues": "https://github.com/nextcloud/coding-standard/issues",
|
||||
"source": "https://github.com/nextcloud/coding-standard/tree/v1.1.1"
|
||||
},
|
||||
"time": "2023-06-01T12:05:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nextcloud/ocp",
|
||||
"version": "v21.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nextcloud-deps/ocp.git",
|
||||
"reference": "41e1476b4aed5bce7371895054049eca353729c5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/41e1476b4aed5bce7371895054049eca353729c5",
|
||||
"reference": "41e1476b4aed5bce7371895054049eca353729c5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3 || ~8.0.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "21.0.0-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"AGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christoph Wurst",
|
||||
"email": "christoph@winzerhof-wurst.at"
|
||||
}
|
||||
],
|
||||
"description": "Composer package containing Nextcloud's public API (classes, interfaces)",
|
||||
"support": {
|
||||
"source": "https://github.com/nextcloud-deps/ocp/tree/v21.0.0"
|
||||
},
|
||||
"time": "2021-03-01T08:42:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-cs-fixer/shim",
|
||||
"version": "v3.17.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/shim.git",
|
||||
"reference": "f51b4aed90565c447136f1d015798f6f7c82490f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/f51b4aed90565c447136f1d015798f6f7c82490f",
|
||||
"reference": "f51b4aed90565c447136f1d015798f6f7c82490f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"php": "^7.4 || ^8.0"
|
||||
},
|
||||
"replace": {
|
||||
"friendsofphp/php-cs-fixer": "self.version"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "For handling output formats in XML",
|
||||
"ext-mbstring": "For handling non-UTF8 characters."
|
||||
},
|
||||
"bin": [
|
||||
"php-cs-fixer",
|
||||
"php-cs-fixer.phar"
|
||||
],
|
||||
"type": "application",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Dariusz Rumiński",
|
||||
"email": "dariusz.ruminski@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A tool to automatically fix PHP code style",
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/shim/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.17.0"
|
||||
},
|
||||
"time": "2023-05-22T20:00:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psalm/phar",
|
||||
"version": "5.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/psalm/phar.git",
|
||||
"reference": "e7f9306ec83c706b4dba451f6adfb865ce4688e4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/psalm/phar/zipball/e7f9306ec83c706b4dba451f6adfb865ce4688e4",
|
||||
"reference": "e7f9306ec83c706b4dba451f6adfb865ce4688e4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"vimeo/psalm": "*"
|
||||
},
|
||||
"bin": [
|
||||
"psalm.phar"
|
||||
],
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Composer-based Psalm Phar",
|
||||
"support": {
|
||||
"issues": "https://github.com/psalm/phar/issues",
|
||||
"source": "https://github.com/psalm/phar/tree/5.12.0"
|
||||
},
|
||||
"time": "2023-05-22T21:30:41+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"platform-overrides": {
|
||||
"php": "7.4"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
@ -10,115 +10,114 @@
|
||||
|
||||
namespace OCA\Epubreader\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
||||
|
||||
use OCA\Epubreader\Service\BookmarkService;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
|
||||
use OCP\IRequest;
|
||||
|
||||
class BookmarkController extends Controller {
|
||||
|
||||
private $bookmarkService;
|
||||
private $bookmarkService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param BookmarkService $bookmarkService
|
||||
* @param BookmarkService $bookmarkService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
BookmarkService $bookmarkService ) {
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
BookmarkService $bookmarkService) {
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
$this->bookmarkService = $bookmarkService;
|
||||
}
|
||||
parent::__construct($AppName, $request);
|
||||
$this->bookmarkService = $bookmarkService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @brief return bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function get($fileId, $name, $type=null) {
|
||||
return $this->bookmarkService->get($fileId, $name, $type);
|
||||
}
|
||||
public function get($fileId, $name, $type = null) {
|
||||
return $this->bookmarkService->get($fileId, $name, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function set($fileId, $name, $value, $type=null, $content=null) {
|
||||
return $this->bookmarkService->set($fileId, $name, $value, $type, $content);
|
||||
public function set($fileId, $name, $value, $type = null, $content = null) {
|
||||
return $this->bookmarkService->set($fileId, $name, $value, $type, $content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief return cursor for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
* @brief return cursor for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function getCursor($fileId) {
|
||||
return $this->bookmarkService->getCursor($fileId);
|
||||
}
|
||||
public function getCursor($fileId) {
|
||||
return $this->bookmarkService->getCursor($fileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write cursor for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write cursor for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function setCursor($fileId, $value) {
|
||||
return $this->bookmarkService->setCursor($fileId, $value);
|
||||
}
|
||||
public function setCursor($fileId, $value) {
|
||||
return $this->bookmarkService->setCursor($fileId, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string name
|
||||
*
|
||||
*/
|
||||
public function delete($fileId, $name) {
|
||||
return $this->bookmarkService->delete($fileId, $name);
|
||||
}
|
||||
/**
|
||||
* @brief delete bookmark
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string name
|
||||
*
|
||||
*/
|
||||
public function delete($fileId, $name) {
|
||||
return $this->bookmarkService->delete($fileId, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete cursor
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
*/
|
||||
public function deleteCursor($fileId) {
|
||||
return $this->bookmarkService->deleteCursor($fileId);
|
||||
}
|
||||
/**
|
||||
* @brief delete cursor
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
*/
|
||||
public function deleteCursor($fileId) {
|
||||
return $this->bookmarkService->deleteCursor($fileId);
|
||||
}
|
||||
}
|
||||
|
@ -10,71 +10,71 @@
|
||||
|
||||
namespace OCA\Epubreader\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCA\Epubreader\Service\MetadataService;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
use OCA\Epubreader\Service\MetadataService;
|
||||
use OCP\IRequest;
|
||||
|
||||
class MetadataController extends Controller {
|
||||
|
||||
private $metadataService;
|
||||
private $metadataService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param MetadataService $metadataService
|
||||
* @param MetadataService $metadataService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
MetadataService $metadataService ) {
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
MetadataService $metadataService) {
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
$this->metadataService = $metadataService;
|
||||
}
|
||||
$this->metadataService = $metadataService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief write metadata
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write metadata
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function setAll($fileId, $value) {
|
||||
return $this->metadataService->setAll($fileId, $value);
|
||||
}
|
||||
public function setAll($fileId, $value) {
|
||||
return $this->metadataService->setAll($fileId, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return metadata item
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @brief return metadata item
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function get($fileId, $name) {
|
||||
return $this->metadataService->get($fileId, $name);
|
||||
}
|
||||
public function get($fileId, $name) {
|
||||
return $this->metadataService->get($fileId, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write metadata item
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write metadata item
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function set($fileId, $name, $value) {
|
||||
return $this->metadataService->set($fileId, $name, $value);
|
||||
public function set($fileId, $name, $value) {
|
||||
return $this->metadataService->set($fileId, $name, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,104 +10,102 @@
|
||||
|
||||
namespace OCA\Epubreader\Controller;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
||||
use OCA\Epubreader\Service\BookmarkService;
|
||||
use OCA\Epubreader\Service\MetadataService;
|
||||
use OCA\Epubreader\Service\PreferenceService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Share\IManager;
|
||||
|
||||
class PageController extends Controller {
|
||||
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
private $shareManager;
|
||||
private $userId;
|
||||
private $bookmarkService;
|
||||
private $metadataService;
|
||||
private $preferenceService;
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
private $shareManager;
|
||||
private $userId;
|
||||
private $bookmarkService;
|
||||
private $metadataService;
|
||||
private $preferenceService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param IManager $shareManager
|
||||
* @param string $UserId
|
||||
* @param BookmarkService $bookmarkService
|
||||
* @param PreferenceService $preferenceService
|
||||
* @param MetadataService $metadataService
|
||||
*/
|
||||
public function __construct(
|
||||
$AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
IRootFolder $rootFolder,
|
||||
IManager $shareManager,
|
||||
$UserId,
|
||||
BookmarkService $bookmarkService,
|
||||
PreferenceService $preferenceService,
|
||||
MetadataService $metadataService) {
|
||||
parent::__construct($AppName, $request);
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->shareManager = $shareManager;
|
||||
$this->userId = $UserId;
|
||||
$this->bookmarkService = $bookmarkService;
|
||||
$this->metadataService = $metadataService;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param IManager $shareManager
|
||||
* @param string $UserId
|
||||
* @param BookmarkService $bookmarkService
|
||||
* @param PreferenceService $preferenceService
|
||||
* @param MetadataService $metadataService
|
||||
*/
|
||||
public function __construct(
|
||||
$AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
IRootFolder $rootFolder,
|
||||
IManager $shareManager,
|
||||
$UserId,
|
||||
BookmarkService $bookmarkService,
|
||||
PreferenceService $preferenceService,
|
||||
MetadataService $metadataService) {
|
||||
parent::__construct($AppName, $request);
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->shareManager = $shareManager;
|
||||
$this->userId = $UserId;
|
||||
$this->bookmarkService = $bookmarkService;
|
||||
$this->metadataService = $metadataService;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function showReader() {
|
||||
$templates= [
|
||||
'application/epub+zip' => 'epubreader',
|
||||
'application/x-cbr' => 'cbreader',
|
||||
'application/pdf' => 'pdfreader'
|
||||
];
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function showReader() {
|
||||
$templates = [
|
||||
'application/epub+zip' => 'epubreader',
|
||||
'application/x-cbr' => 'cbreader',
|
||||
'application/pdf' => 'pdfreader'
|
||||
];
|
||||
|
||||
/**
|
||||
* $fileInfo = [
|
||||
* fileId => null,
|
||||
* fileName => null,
|
||||
* fileType => null
|
||||
* ];
|
||||
*/
|
||||
$fileInfo = $this->getFileInfo($this->request->get['file']);
|
||||
$fileId = $fileInfo['fileId'];
|
||||
$type = $this->request->get["type"];
|
||||
$scope = $template = $templates[$type];
|
||||
/**
|
||||
* $fileInfo = [
|
||||
* fileId => null,
|
||||
* fileName => null,
|
||||
* fileType => null
|
||||
* ];
|
||||
*/
|
||||
$fileInfo = $this->getFileInfo($this->request->getParam('file'));
|
||||
$fileId = $fileInfo['fileId'];
|
||||
$type = $this->request->getParam('type');
|
||||
$scope = $template = $templates[$type];
|
||||
|
||||
$params = [
|
||||
'urlGenerator' => $this->urlGenerator,
|
||||
'downloadLink' => $this->request->get['file'],
|
||||
'scope' => $scope,
|
||||
'fileId' => $fileInfo['fileId'],
|
||||
'fileName' => $fileInfo['fileName'],
|
||||
'fileType' => $fileInfo['fileType'],
|
||||
'cursor' => $this->toJson($this->bookmarkService->getCursor($fileId)),
|
||||
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
||||
'preferences' => $this->toJson($this->preferenceService->get($scope, $fileId)),
|
||||
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
||||
'metadata' => $this->toJson($this->metadataService->get($fileId)),
|
||||
'annotations' => $this->toJson($this->bookmarkService->get($fileId))
|
||||
];
|
||||
$params = [
|
||||
'urlGenerator' => $this->urlGenerator,
|
||||
'downloadLink' => $this->request->getParam('file'),
|
||||
'scope' => $scope,
|
||||
'fileId' => $fileInfo['fileId'],
|
||||
'fileName' => $fileInfo['fileName'],
|
||||
'fileType' => $fileInfo['fileType'],
|
||||
'cursor' => $this->toJson($this->bookmarkService->getCursor($fileId)),
|
||||
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
||||
'preferences' => $this->toJson($this->preferenceService->get($scope, $fileId)),
|
||||
'metadata' => $this->toJson($this->metadataService->get($fileId)),
|
||||
'annotations' => $this->toJson($this->bookmarkService->get($fileId))
|
||||
];
|
||||
|
||||
$policy = new ContentSecurityPolicy();
|
||||
$policy = new ContentSecurityPolicy();
|
||||
$policy->addAllowedStyleDomain('\'self\'');
|
||||
$policy->addAllowedStyleDomain('blob:');
|
||||
$policy->addAllowedScriptDomain('\'self\'');
|
||||
@ -118,60 +116,59 @@ class PageController extends Controller {
|
||||
$policy->addAllowedFontDomain('blob:');
|
||||
$policy->addAllowedImageDomain('blob:');
|
||||
|
||||
$response = new TemplateResponse($this->appName, $template, $params, 'blank');
|
||||
$response = new TemplateResponse($this->appName, $template, $params, 'blank');
|
||||
$response->setContentSecurityPolicy($policy);
|
||||
|
||||
return $response;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sharing-aware file info retriever
|
||||
*
|
||||
* Work around the differences between normal and shared file access
|
||||
* (this should be abstracted away in OC/NC IMnsHO)
|
||||
*
|
||||
* @param string $path path-fragment from url
|
||||
* @return array
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
private function getFileInfo($path) {
|
||||
$count = 0;
|
||||
$shareToken = preg_replace("/(?:\/index\.php)?\/s\/([A-Za-z0-9]{15,32})\/download.*/", "$1", $path, 1,$count);
|
||||
/**
|
||||
* @brief sharing-aware file info retriever
|
||||
*
|
||||
* Work around the differences between normal and shared file access
|
||||
* (this should be abstracted away in OC/NC IMnsHO)
|
||||
*
|
||||
* @param string $path path-fragment from url
|
||||
* @return array
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
private function getFileInfo($path) {
|
||||
$count = 0;
|
||||
$shareToken = preg_replace("/(?:\/index\.php)?\/s\/([A-Za-z0-9]{15,32})\/download.*/", "$1", $path, 1, $count);
|
||||
|
||||
if ($count === 1) {
|
||||
if ($count === 1) {
|
||||
|
||||
/* shared file or directory */
|
||||
$node = $this->shareManager->getShareByToken($shareToken)->getNode();
|
||||
$type = $node->getType();
|
||||
/* shared file or directory */
|
||||
$node = $this->shareManager->getShareByToken($shareToken)->getNode();
|
||||
$type = $node->getType();
|
||||
|
||||
/* shared directory, need file path to continue, */
|
||||
if ($type == \OCP\Files\FileInfo::TYPE_FOLDER) {
|
||||
$query = [];
|
||||
parse_str(parse_url($path, PHP_URL_QUERY), $query);
|
||||
if (isset($query['path']) && isset($query['files'])) {
|
||||
$node = $node->get($query['path'])->get($query['files']);
|
||||
} else {
|
||||
throw new NotFoundException('Shared file path or name not set');
|
||||
}
|
||||
}
|
||||
$filePath = $node->getPath();
|
||||
$fileId = $node->getId();
|
||||
} else {
|
||||
$filePath = $path;
|
||||
$fileId = $this->rootFolder->getUserFolder($this->userId)
|
||||
->get(preg_replace("/.*\/remote.php\/webdav(.*)/", "$1", rawurldecode($this->request->get['file'])))
|
||||
->getFileInfo()
|
||||
->getId();
|
||||
}
|
||||
/* shared directory, need file path to continue, */
|
||||
if ($type == \OCP\Files\FileInfo::TYPE_FOLDER) {
|
||||
$query = [];
|
||||
parse_str(parse_url($path, PHP_URL_QUERY), $query);
|
||||
if (isset($query['path']) && isset($query['files'])) {
|
||||
$node = $node->get($query['path'])->get($query['files']);
|
||||
} else {
|
||||
throw new NotFoundException('Shared file path or name not set');
|
||||
}
|
||||
}
|
||||
$filePath = $node->getPath();
|
||||
$fileId = $node->getId();
|
||||
} else {
|
||||
$filePath = $path;
|
||||
$fileId = $this->rootFolder->getUserFolder($this->userId)
|
||||
->get(preg_replace("/.*\/remote.php\/webdav(.*)/", "$1", rawurldecode($this->request->getParam('file'))))
|
||||
->getId();
|
||||
}
|
||||
|
||||
return [
|
||||
'fileName' => pathInfo($filePath, PATHINFO_FILENAME),
|
||||
'fileType' => strtolower(pathInfo($filePath, PATHINFO_EXTENSION)),
|
||||
'fileId' => $fileId
|
||||
];
|
||||
}
|
||||
return [
|
||||
'fileName' => pathInfo($filePath, PATHINFO_FILENAME),
|
||||
'fileType' => strtolower(pathInfo($filePath, PATHINFO_EXTENSION)),
|
||||
'fileId' => $fileId
|
||||
];
|
||||
}
|
||||
|
||||
private function toJson($value) {
|
||||
return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
private function toJson($value) {
|
||||
return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
@ -10,119 +10,118 @@
|
||||
|
||||
namespace OCA\Epubreader\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
use OCA\Epubreader\Service\PreferenceService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class PreferenceController extends Controller {
|
||||
|
||||
private $urlGenerator;
|
||||
private $preferenceService;
|
||||
private $urlGenerator;
|
||||
private $preferenceService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param PreferenceService $preferenceService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
PreferenceService $preferenceService ) {
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param PreferenceService $preferenceService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
PreferenceService $preferenceService) {
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return preference for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name if null, return all preferences for $scope + $fileId
|
||||
*
|
||||
* @brief return preference for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name if null, return all preferences for $scope + $fileId
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function get($scope, $fileId, $name) {
|
||||
return $this->preferenceService->get($scope, $fileId, $name);
|
||||
}
|
||||
public function get($scope, $fileId, $name) {
|
||||
return $this->preferenceService->get($scope, $fileId, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write preference for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write preference for $fileId
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
return $this->preferenceService->set($scope, $fileId, $name, $value);
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
return $this->preferenceService->set($scope, $fileId, $name, $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief return default preference
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name if null, return all default preferences for scope
|
||||
*
|
||||
* @brief return default preference
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name if null, return all default preferences for scope
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function getDefault($scope, $name) {
|
||||
return $this->preferenceService->getDefault($scope, $name);
|
||||
}
|
||||
public function getDefault($scope, $name) {
|
||||
return $this->preferenceService->getDefault($scope, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write default preference
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @brief write default preference
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function setDefault($scope, $name, $value) {
|
||||
return $this->preferenceService->setDefault($scope, $name, $value);
|
||||
}
|
||||
public function setDefault($scope, $name, $value) {
|
||||
return $this->preferenceService->setDefault($scope, $name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($scope, $fileId, $name) {
|
||||
return $this->preferenceService->delete($scope, $fileId, $name);
|
||||
}
|
||||
/**
|
||||
* @brief delete preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($scope, $fileId, $name) {
|
||||
return $this->preferenceService->delete($scope, $fileId, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete default preference
|
||||
*
|
||||
* @param $scope
|
||||
* @param $name
|
||||
*
|
||||
*/
|
||||
public function deleteDefault($scope, $name) {
|
||||
return $this->preferenceService->deleteDefault($scope, $name);
|
||||
}
|
||||
/**
|
||||
* @brief delete default preference
|
||||
*
|
||||
* @param $scope
|
||||
* @param $name
|
||||
*
|
||||
*/
|
||||
public function deleteDefault($scope, $name) {
|
||||
return $this->preferenceService->deleteDefault($scope, $name);
|
||||
}
|
||||
}
|
||||
|
@ -11,47 +11,47 @@
|
||||
*/
|
||||
|
||||
namespace OCA\Epubreader\Controller;
|
||||
|
||||
use OCA\Epubreader\Config;
|
||||
use OCA\Epubreader\Service\PreferenceService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCA\Epubreader\Service\PreferenceService;
|
||||
use OCA\Epubreader\Config;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
private $urlGenerator;
|
||||
private $preferenceService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param PreferenceService $preferenceService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
PreferenceService $preferenceService ) {
|
||||
private $urlGenerator;
|
||||
private $preferenceService;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param PreferenceService $preferenceService
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IURLGenerator $urlGenerator,
|
||||
PreferenceService $preferenceService) {
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->preferenceService = $preferenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set preference for file type association
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $EpubEnable
|
||||
* @param int $EpubEnable
|
||||
* @param int $CbxEnable
|
||||
*
|
||||
* @brief set preference for file type association
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $EpubEnable
|
||||
* @param int $PdfEnable
|
||||
* @param int $CbxEnable
|
||||
*
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function setPreference(string $EpubEnable, string $PdfEnable, string $CbxEnable) {
|
||||
public function setPreference(int $EpubEnable, int $PdfEnable, int $CbxEnable) {
|
||||
|
||||
$l = \OC::$server->getL10N('epubreader');
|
||||
|
||||
@ -60,10 +60,10 @@ class SettingsController extends Controller {
|
||||
Config::set('cbx_enable', $CbxEnable);
|
||||
|
||||
$response = array(
|
||||
'data' => array('message'=> $l->t('Settings updated successfully.')),
|
||||
'status' => 'success'
|
||||
);
|
||||
'data' => array('message' => $l->t('Settings updated successfully.')),
|
||||
'status' => 'success'
|
||||
);
|
||||
|
||||
return new JSONResponse($response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,39 +10,92 @@
|
||||
|
||||
namespace OCA\Epubreader\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Bookmark extends ReaderEntity implements \JsonSerializable {
|
||||
|
||||
protected $userId; // user
|
||||
protected $fileId; // book (identified by fileId) for which this mark is valid
|
||||
protected $type; // type, defaults to "bookmark"
|
||||
protected $name; // name, defaults to $location
|
||||
protected $value; // bookmark value (format-specific, eg. page number for PDF, CFI for epub, etc)
|
||||
protected $content; // bookmark content (annotations etc), can be empty
|
||||
protected $lastModified; // modification timestamp
|
||||
protected $userId; // user
|
||||
protected $fileId; // book (identified by fileId) for which this mark is valid
|
||||
protected $type; // type, defaults to "bookmark"
|
||||
protected $name; // name, defaults to $location
|
||||
protected $value; // bookmark value (format-specific, eg. page number for PDF, CFI for epub, etc)
|
||||
protected $content; // bookmark content (annotations etc), can be empty
|
||||
protected $lastModified; // modification timestamp
|
||||
|
||||
public function jsonSerialize() {
|
||||
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()
|
||||
];
|
||||
}
|
||||
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()
|
||||
];
|
||||
}
|
||||
|
||||
public function toService() {
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'type' => $this->getType(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
'content' => $this->conditional_json_decode($this->getContent()),
|
||||
'lastModified' => $this->getLastModified(),
|
||||
];
|
||||
}
|
||||
public function toService() {
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'type' => $this->getType(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
'content' => $this->conditional_json_decode($this->getContent()),
|
||||
'lastModified' => $this->getLastModified(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getUserId() {
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function setUserId($userId) {
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function getFileId() {
|
||||
return $this->fileId;
|
||||
}
|
||||
|
||||
public function setFileId($fileId) {
|
||||
$this->fileId = $fileId;
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent($content) {
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function getLastModified() {
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function setLastModified($lastModified) {
|
||||
$this->lastModified = $lastModified;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,115 +10,91 @@
|
||||
|
||||
namespace OCA\Epubreader\Db;
|
||||
|
||||
use OCA\Epubreader\Utility\Time;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
|
||||
use OCA\Epubreader\Utility\Time;
|
||||
|
||||
class BookmarkMapper extends ReaderMapper {
|
||||
|
||||
private $userId;
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @param IDbConnection $db
|
||||
* @param $UserId
|
||||
* @param Time $time
|
||||
*/
|
||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
||||
parent::__construct($db, 'reader_bookmarks', Bookmark::class, $time);
|
||||
/** @var int $UserId */
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
/**
|
||||
* @param IDbConnection $db
|
||||
* @param $UserId
|
||||
* @param Time $time
|
||||
*/
|
||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
||||
parent::__construct($db, 'reader_bookmarks', Bookmark::class, $time);
|
||||
/** @var int $UserId */
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get bookmarks for $fileId+$userId(+$name)
|
||||
* @param $fileId
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name, $type = null) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->getTableName())
|
||||
->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
||||
/**
|
||||
* @brief get bookmarks for $fileId+$userId(+$name)
|
||||
* @param $fileId
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get(int $fileId, $name, $type = null) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->getTableName())
|
||||
->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
||||
|
||||
if ($type !== null) {
|
||||
$query->andWhere($query->expr()->eq('type', $query->createNamedParameter($type)));
|
||||
}
|
||||
if ($type !== null) {
|
||||
$query->andWhere($query->expr()->eq('type', $query->createNamedParameter($type)));
|
||||
}
|
||||
|
||||
if ($name !== null) {
|
||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||
}
|
||||
if ($name !== null) {
|
||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||
}
|
||||
|
||||
return $this->findEntities($query);
|
||||
}
|
||||
return $this->findEntities($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write bookmark to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return Bookmark the newly created or updated bookmark
|
||||
*/
|
||||
public function set($fileId, $name, $value, $type, $content=null) {
|
||||
/**
|
||||
* @brief write bookmark to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return Bookmark the newly created or updated bookmark
|
||||
*/
|
||||
public function set($fileId, $name, $value, $type, $content = null) {
|
||||
|
||||
$result = $this->get($fileId, $name);
|
||||
$result = $this->get($fileId, $name);
|
||||
|
||||
if(empty($result)) {
|
||||
if(empty($result)) {
|
||||
|
||||
// anonymous bookmarks are named after their contents
|
||||
if (null === $name) {
|
||||
$name = $value;
|
||||
}
|
||||
// anonymous bookmarks are named after their contents
|
||||
if (null === $name) {
|
||||
$name = $value;
|
||||
}
|
||||
|
||||
// default type is "bookmark"
|
||||
if (null === $type) {
|
||||
$type = "bookmark";
|
||||
}
|
||||
// default type is "bookmark"
|
||||
if (null === $type) {
|
||||
$type = "bookmark";
|
||||
}
|
||||
|
||||
$bookmark = new Bookmark();
|
||||
$bookmark->setFileId($fileId);
|
||||
$bookmark->setUserId($this->userId);
|
||||
$bookmark->setType($type);
|
||||
$bookmark->setName($name);
|
||||
$bookmark->setValue($value);
|
||||
$bookmark->setContent($content);
|
||||
$bookmark = new Bookmark();
|
||||
$bookmark->setFileId($fileId);
|
||||
$bookmark->setUserId($this->userId);
|
||||
$bookmark->setType($type);
|
||||
$bookmark->setName($name);
|
||||
$bookmark->setValue($value);
|
||||
$bookmark->setContent($content);
|
||||
|
||||
$this->insert($bookmark);
|
||||
} else {
|
||||
$bookmark = $result[0];
|
||||
$bookmark->setValue($value);
|
||||
$bookmark->setContent($content);
|
||||
$this->insert($bookmark);
|
||||
} else {
|
||||
$bookmark = $result[0];
|
||||
$bookmark->setValue($value);
|
||||
$bookmark->setContent($content);
|
||||
|
||||
$this->update($bookmark);
|
||||
}
|
||||
$this->update($bookmark);
|
||||
}
|
||||
|
||||
return $bookmark;
|
||||
}
|
||||
|
||||
/* currently not used */
|
||||
public function deleteForFileId($fileId) {
|
||||
$sql = "SELECT * FROM `*PREFIX*reader_bookmarks` WHERE file_id=?";
|
||||
$args = [ $fileId ];
|
||||
array_map(
|
||||
function($entity) {
|
||||
$this->delete($entity);
|
||||
}, $this->findEntities($sql, $args)
|
||||
);
|
||||
}
|
||||
|
||||
/* currently not used */
|
||||
public function deleteForUserId($userId) {
|
||||
$sql = "SELECT * FROM `*PREFIX*reader_bookmarks` WHERE user_id=?";
|
||||
$args = [ $userId ];
|
||||
array_map(
|
||||
function($entity) {
|
||||
$this->delete($entity);
|
||||
}, $this->findEntities($sql, $args)
|
||||
);
|
||||
}
|
||||
return $bookmark;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,33 +10,78 @@
|
||||
|
||||
namespace OCA\Epubreader\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Preference extends ReaderEntity implements \JsonSerializable {
|
||||
|
||||
protected $userId; // user for whom this preference is valid
|
||||
protected $scope; // scope (default or specific renderer)
|
||||
protected $fileId; // file for which this preference is set
|
||||
protected $name; // preference name
|
||||
protected $value; // preference value
|
||||
protected $lastModified; // modification timestamp
|
||||
protected $userId; // user for whom this preference is valid
|
||||
protected $scope; // scope (default or specific renderer)
|
||||
protected $fileId; // file for which this preference is set
|
||||
protected $name; // preference name
|
||||
protected $value; // preference value
|
||||
protected $lastModified; // modification timestamp
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'scope' => $this->getScope(),
|
||||
'fileId' => $this->getFileId(),
|
||||
'name' => $this->getName(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
'lastModified' => $this->getLastModified(),
|
||||
];
|
||||
}
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'scope' => $this->getScope(),
|
||||
'fileId' => $this->getFileId(),
|
||||
'name' => $this->getName(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
'lastModified' => $this->getLastModified(),
|
||||
];
|
||||
}
|
||||
|
||||
public function toService() {
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
];
|
||||
}
|
||||
public function toService() {
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
];
|
||||
}
|
||||
|
||||
public function getUserId() {
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function setUserId($userId) {
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function getScope() {
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function setScope($scope) {
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
public function getFileId() {
|
||||
return $this->fileId;
|
||||
}
|
||||
|
||||
public function setFileId($fileId) {
|
||||
$this->fileId = $fileId;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getLastModified() {
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function setLastModified($lastModified) {
|
||||
$this->lastModified = $lastModified;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,93 +10,72 @@
|
||||
|
||||
namespace OCA\Epubreader\Db;
|
||||
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCA\Epubreader\Utility\Time;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class PreferenceMapper extends ReaderMapper {
|
||||
|
||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
||||
parent::__construct($db, 'reader_prefs', Preference::class, $time);
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @brief get preferences for $scope+$fileId+$userId(+$name)
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get($scope, $fileId, $name=null) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->getTableName())
|
||||
->where($query->expr()->eq('scope', $query->createNamedParameter($scope)))
|
||||
->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
||||
parent::__construct($db, 'reader_prefs', Preference::class, $time);
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||
}
|
||||
/**
|
||||
* @brief get preferences for $scope+$fileId+$userId(+$name)
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get($scope, $fileId, $name = null) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->getTableName())
|
||||
->where($query->expr()->eq('scope', $query->createNamedParameter($scope)))
|
||||
->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
||||
|
||||
return $this->findEntities($query);
|
||||
}
|
||||
if (!empty($name)) {
|
||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write preference to database
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return Preference the newly created or updated preference
|
||||
*/
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
return $this->findEntities($query);
|
||||
}
|
||||
|
||||
$result = $this->get($scope, $fileId, $name);
|
||||
/**
|
||||
* @brief write preference to database
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return Preference the newly created or updated preference
|
||||
*/
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
|
||||
if(empty($result)) {
|
||||
$result = $this->get($scope, $fileId, $name);
|
||||
|
||||
$preference = new Preference();
|
||||
$preference->setScope($scope);
|
||||
$preference->setFileId($fileId);
|
||||
$preference->setUserId($this->userId);
|
||||
$preference->setName($name);
|
||||
$preference->setValue($value);
|
||||
if(empty($result)) {
|
||||
|
||||
$this->insert($preference);
|
||||
} else {
|
||||
$preference = $result[0];
|
||||
$preference->setValue($value);
|
||||
$preference = new Preference();
|
||||
$preference->setScope($scope);
|
||||
$preference->setFileId($fileId);
|
||||
$preference->setUserId($this->userId);
|
||||
$preference->setName($name);
|
||||
$preference->setValue($value);
|
||||
|
||||
$this->update($preference);
|
||||
}
|
||||
$this->insert($preference);
|
||||
} else {
|
||||
$preference = $result[0];
|
||||
$preference->setValue($value);
|
||||
|
||||
return $preference;
|
||||
}
|
||||
$this->update($preference);
|
||||
}
|
||||
|
||||
/* currently not used*/
|
||||
public function deleteForFileId($fileId) {
|
||||
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE file_id=?";
|
||||
$args = [ $fileId ];
|
||||
array_map(
|
||||
function($entity) {
|
||||
$this->delete($entity);
|
||||
}, $this->findEntities($sql, $args)
|
||||
);
|
||||
}
|
||||
|
||||
/* currently not used*/
|
||||
public function deleteForUserId($userId) {
|
||||
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE user_id=?";
|
||||
$args = [ $userId ];
|
||||
array_map(
|
||||
function($entity) {
|
||||
$this->delete($entity);
|
||||
}, $this->findEntities($sql, $args)
|
||||
);
|
||||
}
|
||||
return $preference;
|
||||
}
|
||||
}
|
||||
|
@ -14,26 +14,24 @@ use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class ReaderEntity extends Entity {
|
||||
|
||||
/* returns decoded json if input is json, otherwise returns input */
|
||||
public static function conditional_json_decode($el) {
|
||||
$result = json_decode($el);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
return $result;
|
||||
} else {
|
||||
return $el;
|
||||
}
|
||||
}
|
||||
private $lastModified;
|
||||
|
||||
/* returns decoded json if input is json, otherwise returns input */
|
||||
public static function conditional_json_decode($el) {
|
||||
$result = json_decode($el);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
return $result;
|
||||
} else {
|
||||
return $el;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastModified() {
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function setLastModified($lastModified) {
|
||||
$this->lastModified = $lastModified;
|
||||
}
|
||||
|
||||
/*
|
||||
public function toService() {
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'type' => $this->getType(),
|
||||
'value' => $this->conditional_json_decode($this->getValue()),
|
||||
'content' => $this->conditional_json_decode($this->getContent()),
|
||||
'lastModified' => $this->getLastModified(),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -10,31 +10,34 @@
|
||||
|
||||
namespace OCA\Epubreader\Db;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
use OCA\Epubreader\Utility\Time;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
|
||||
/**
|
||||
* @template-extends QBMapper<ReaderEntity>
|
||||
*/
|
||||
abstract class ReaderMapper extends QBMapper {
|
||||
|
||||
/**
|
||||
* @var Time
|
||||
*/
|
||||
private $time;
|
||||
/**
|
||||
* @var Time
|
||||
*/
|
||||
private $time;
|
||||
|
||||
public function __construct(IDBConnection $db, $table, $entity, Time $time) {
|
||||
parent::__construct($db, $table, $entity);
|
||||
$this->time = $time;
|
||||
}
|
||||
public function __construct(IDBConnection $db, $table, $entity, Time $time) {
|
||||
parent::__construct($db, $table, $entity);
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
public function update(Entity $entity): Entity {
|
||||
$entity->setLastModified($this->time->getMicroTime());
|
||||
return parent::update($entity);
|
||||
}
|
||||
public function update(Entity $entity): Entity {
|
||||
$entity->setLastModified($this->time->getMicroTime());
|
||||
return parent::update($entity);
|
||||
}
|
||||
|
||||
public function insert(Entity $entity): Entity {
|
||||
$entity->setLastModified($this->time->getMicroTime());
|
||||
return parent::insert($entity);
|
||||
}
|
||||
}
|
||||
public function insert(Entity $entity): Entity {
|
||||
$entity->setLastModified($this->time->getMicroTime());
|
||||
return parent::insert($entity);
|
||||
}
|
||||
}
|
||||
|
@ -10,61 +10,60 @@
|
||||
|
||||
namespace OCA\Epubreader;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IUser;
|
||||
use OCP\Util;
|
||||
use \OC\User\User as User;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Util;
|
||||
|
||||
class Hooks {
|
||||
|
||||
public static function register() {
|
||||
Util::connectHook('\OCP\Config', 'js', 'OCA\Epubreader\Hooks', 'announce_settings');
|
||||
public static function register() {
|
||||
Util::connectHook('\OCP\Config', 'js', 'OCA\Epubreader\Hooks', 'announce_settings');
|
||||
|
||||
\OC::$server->getRootFolder()->listen('\OC\Files', 'preDelete', function (Node $node) {
|
||||
$fileId = $node->getId();
|
||||
$connection = \OC::$server->getDatabaseConnection();
|
||||
self::deleteFile($connection, $fileId);
|
||||
});
|
||||
\OC::$server->getUserManager()->listen('\OC\User', 'preDelete', function (User $user) {
|
||||
$userId = $user->getUID();
|
||||
$connection = \OC::$server->getDatabaseConnection();
|
||||
self::deleteUser($connection, $userId);
|
||||
});
|
||||
}
|
||||
\OC::$server->getRootFolder()->listen('\OC\Files', 'preDelete', function (Node $node) {
|
||||
$fileId = $node->getId();
|
||||
$connection = \OC::$server->getDatabaseConnection();
|
||||
self::deleteFile($connection, $fileId);
|
||||
});
|
||||
\OC::$server->getUserManager()->listen('\OC\User', 'preDelete', function (User $user) {
|
||||
$userId = $user->getUID();
|
||||
$connection = \OC::$server->getDatabaseConnection();
|
||||
self::deleteUser($connection, $userId);
|
||||
});
|
||||
}
|
||||
|
||||
public static function announce_settings(array $settings) {
|
||||
// Nextcloud encodes this as JSON, Owncloud does not (yet) (#75)
|
||||
// TODO: rmeove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties
|
||||
$isJson = self::isJson($settings['array']['oc_appconfig']);
|
||||
$array = ($isJson) ? json_decode($settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig'];
|
||||
$array['filesReader']['enableEpub'] = Config::get('epub_enable', 'true');
|
||||
$array['filesReader']['enablePdf'] = Config::get('pdf_enable', 'true');
|
||||
$array['filesReader']['enableCbx'] = Config::get('cbx_enable', 'true');
|
||||
$settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array;
|
||||
}
|
||||
public static function announce_settings(array $settings) {
|
||||
// Nextcloud encodes this as JSON, Owncloud does not (yet) (#75)
|
||||
// TODO: rmeove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties
|
||||
$isJson = self::isJson($settings['array']['oc_appconfig']);
|
||||
$array = ($isJson) ? json_decode($settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig'];
|
||||
$array['filesReader']['enableEpub'] = Config::get('epub_enable', 'true');
|
||||
$array['filesReader']['enablePdf'] = Config::get('pdf_enable', 'true');
|
||||
$array['filesReader']['enableCbx'] = Config::get('cbx_enable', 'true');
|
||||
$settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array;
|
||||
}
|
||||
|
||||
protected static function deleteFile(IDBConnection $connection, $fileId) {
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||
$queryBuilder->execute();
|
||||
protected static function deleteFile(IDBConnection $connection, $fileId) {
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||
$queryBuilder->execute();
|
||||
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_prefs')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||
$queryBuilder->execute();
|
||||
}
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_prefs')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||
$queryBuilder->execute();
|
||||
}
|
||||
|
||||
protected static function deleteUser(IDBConnection $connection, $userId) {
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||
$queryBuilder->execute();
|
||||
protected static function deleteUser(IDBConnection $connection, $userId) {
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||
$queryBuilder->execute();
|
||||
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_prefs')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||
$queryBuilder->execute();
|
||||
}
|
||||
$queryBuilder = $connection->getQueryBuilder();
|
||||
$queryBuilder->delete('reader_prefs')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||
$queryBuilder->execute();
|
||||
}
|
||||
|
||||
private static function isJson($string) {
|
||||
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
|
||||
}
|
||||
private static function isJson($string) {
|
||||
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
|
||||
}
|
||||
}
|
||||
|
@ -10,104 +10,102 @@
|
||||
|
||||
namespace OCA\Epubreader\Service;
|
||||
|
||||
|
||||
use OCA\Epubreader\Db\BookmarkMapper;
|
||||
|
||||
class BookmarkService extends Service {
|
||||
|
||||
// "bookmark" name to use for the cursor (current reading position)
|
||||
const CURSOR = '__CURSOR__';
|
||||
const bookmark_type = 'bookmark';
|
||||
// "bookmark" name to use for the cursor (current reading position)
|
||||
public const CURSOR = '__CURSOR__';
|
||||
public const bookmark_type = 'bookmark';
|
||||
|
||||
private $bookmarkMapper;
|
||||
private $userId;
|
||||
private $bookmarkMapper;
|
||||
private $userId;
|
||||
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, $UserId) {
|
||||
parent::__construct($bookmarkMapper);
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, $UserId) {
|
||||
parent::__construct($bookmarkMapper);
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get bookmark
|
||||
*
|
||||
* bookmark type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name=null, $type=null) {
|
||||
$result = $this->bookmarkMapper->get($fileId, $name, $type);
|
||||
return array_map(
|
||||
function($entity) {
|
||||
return $entity->toService();
|
||||
}, $result);
|
||||
}
|
||||
/**
|
||||
* @brief get bookmark
|
||||
*
|
||||
* bookmark type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name = null, $type = null) {
|
||||
$result = $this->bookmarkMapper->get($fileId, $name, $type);
|
||||
return array_map(
|
||||
function ($entity) {
|
||||
return $entity->toService();
|
||||
}, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write bookmark
|
||||
*
|
||||
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($fileId, $name, $value, $type=null, $content=null) {
|
||||
return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content);
|
||||
}
|
||||
/**
|
||||
* @brief write bookmark
|
||||
*
|
||||
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($fileId, $name, $value, $type = null, $content = null) {
|
||||
return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get cursor (current position in book)
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCursor($fileId) {
|
||||
$result = $this->get($fileId, static::CURSOR);
|
||||
if (count($result) === 1) {
|
||||
return $result[0];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief get cursor (current position in book)
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCursor($fileId) {
|
||||
$result = $this->get($fileId, static::CURSOR);
|
||||
if (count($result) === 1) {
|
||||
return $result[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set cursor (current position in book)
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setCursor($fileId, $value) {
|
||||
return $this->bookmarkMapper->set($fileId, static::CURSOR, $value, static::bookmark_type);
|
||||
}
|
||||
/**
|
||||
* @brief set cursor (current position in book)
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setCursor($fileId, $value) {
|
||||
return $this->bookmarkMapper->set($fileId, static::CURSOR, $value, static::bookmark_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete bookmark
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($fileId, $name, $type=null) {
|
||||
foreach ($this->bookmarkMapper->get($fileId, $name, $type) as $bookmark) {
|
||||
$this->bookmarkMapper->delete($bookmark);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief delete bookmark
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($fileId, $name, $type = null) {
|
||||
foreach ($this->bookmarkMapper->get($fileId, $name, $type) as $bookmark) {
|
||||
$this->bookmarkMapper->delete($bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete cursor
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
*/
|
||||
public function deleteCursor($fileId) {
|
||||
$this->delete($fileId, static::CURSOR, static::bookmark_type);
|
||||
}
|
||||
/**
|
||||
* @brief delete cursor
|
||||
*
|
||||
* @param int $fileId
|
||||
*
|
||||
*/
|
||||
public function deleteCursor($fileId) {
|
||||
$this->delete($fileId, static::CURSOR, static::bookmark_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,62 +14,51 @@ use OCP\App\IAppManager;
|
||||
|
||||
class MetadataService {
|
||||
|
||||
private $appManager;
|
||||
private $appManager;
|
||||
|
||||
/**
|
||||
* @param IAppManager $appManager
|
||||
*/
|
||||
public function __construct(IAppManager $appManager) {
|
||||
$this->appManager = $appManager;
|
||||
}
|
||||
/**
|
||||
* @param IAppManager $appManager
|
||||
*/
|
||||
public function __construct(IAppManager $appManager) {
|
||||
$this->appManager = $appManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get metadata item(s)
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name=null) {
|
||||
if ($this->appManager->isInstalled('files_opds')) {
|
||||
if ($meta = \OCA\Files_Opds\Meta::get($fileId)) {
|
||||
if (!empty($name) && array_key_exists($name, $meta)) {
|
||||
return [$item => $meta[$name]];
|
||||
} else {
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief get metadata item(s)
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name = null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* @brief write metadata to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param array $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setAll($fileId, $value) {
|
||||
// no-op for now
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write metadata to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param array $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setAll($fileId, $value) {
|
||||
// no-op for now
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write metadata item to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param array $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($fileId, $name, $value) {
|
||||
// no-op for now
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* @brief write metadata item to database
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param array $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($fileId, $name, $value) {
|
||||
// no-op for now
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,104 +14,104 @@ use OCA\Epubreader\Db\PreferenceMapper;
|
||||
|
||||
class PreferenceService extends Service {
|
||||
|
||||
// (ab)use the fact that $fileId never goes below 1 by using the
|
||||
// value 0 to indicate a default preference
|
||||
const DEFAULTS = 0;
|
||||
// (ab)use the fact that $fileId never goes below 1 by using the
|
||||
// value 0 to indicate a default preference
|
||||
public const DEFAULTS = 0;
|
||||
|
||||
private $preferenceMapper;
|
||||
private $preferenceMapper;
|
||||
|
||||
/**
|
||||
* @param PreferenceMapper $preferenceMapper
|
||||
*/
|
||||
public function __construct(PreferenceMapper $preferenceMapper) {
|
||||
parent::__construct($preferenceMapper);
|
||||
$this->preferenceMapper = $preferenceMapper;
|
||||
}
|
||||
/**
|
||||
* @param PreferenceMapper $preferenceMapper
|
||||
*/
|
||||
public function __construct(PreferenceMapper $preferenceMapper) {
|
||||
parent::__construct($preferenceMapper);
|
||||
$this->preferenceMapper = $preferenceMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get preference
|
||||
*
|
||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
||||
* preference type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($scope, $fileId, $name=null) {
|
||||
$result = $this->preferenceMapper->get($scope, $fileId, $name);
|
||||
return array_map(
|
||||
function($entity) {
|
||||
return $entity->toService();
|
||||
}, $result);
|
||||
}
|
||||
/**
|
||||
* @brief get preference
|
||||
*
|
||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
||||
* preference type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($scope, $fileId, $name = null) {
|
||||
$result = $this->preferenceMapper->get($scope, $fileId, $name);
|
||||
return array_map(
|
||||
function ($entity) {
|
||||
return $entity->toService();
|
||||
}, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief write preference
|
||||
*
|
||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
||||
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
return $this->preferenceMapper->set($scope, $fileId, $name, $value);
|
||||
}
|
||||
/**
|
||||
* @brief write preference
|
||||
*
|
||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
||||
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set($scope, $fileId, $name, $value) {
|
||||
return $this->preferenceMapper->set($scope, $fileId, $name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get default preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefault($scope, $name=null) {
|
||||
return $this->get($scope, static::DEFAULTS, $name);
|
||||
}
|
||||
/**
|
||||
* @brief get default preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefault($scope, $name = null) {
|
||||
return $this->get($scope, static::DEFAULTS, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set default preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefault($scope, $name, $value) {
|
||||
return $this->preferenceMapper->set($scope, static::DEFAULTS, $name, $value);
|
||||
}
|
||||
/**
|
||||
* @brief set default preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefault($scope, $name, $value) {
|
||||
return $this->preferenceMapper->set($scope, static::DEFAULTS, $name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($scope, $fileId, $name) {
|
||||
foreach($this->preferenceMapper->get($scope, $fileId, $name) as $preference) {
|
||||
$this->preferenceMapper->delete($preference);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief delete preference
|
||||
*
|
||||
* @param string $scope
|
||||
* @param int $fileId
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function delete($scope, $fileId, $name) {
|
||||
foreach($this->preferenceMapper->get($scope, $fileId, $name) as $preference) {
|
||||
$this->preferenceMapper->delete($preference);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete default
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function deleteDefault($scope, $name) {
|
||||
$this->delete($scope, static::DEFAULTS, $name);
|
||||
}
|
||||
/**
|
||||
* @brief delete default
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
*
|
||||
*/
|
||||
public function deleteDefault($scope, $name) {
|
||||
$this->delete($scope, static::DEFAULTS, $name);
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,9 @@ use OCA\Epubreader\Db\ReaderMapper;
|
||||
|
||||
abstract class Service {
|
||||
|
||||
protected $mapper;
|
||||
protected $mapper;
|
||||
|
||||
public function __construct(ReaderMapper $mapper){
|
||||
$this->mapper = $mapper;
|
||||
}
|
||||
public function __construct(ReaderMapper $mapper) {
|
||||
$this->mapper = $mapper;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -12,78 +12,71 @@
|
||||
namespace OCA\Epubreader\Settings;
|
||||
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\IConfig;
|
||||
use OCP\Settings\ISettings;
|
||||
|
||||
class Personal implements ISettings
|
||||
{
|
||||
class Personal implements ISettings {
|
||||
|
||||
private $userId;
|
||||
private $configManager;
|
||||
private $userId;
|
||||
private $configManager;
|
||||
|
||||
public function __construct(
|
||||
$userId,
|
||||
IConfig $configManager
|
||||
)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
$this->configManager = $configManager;
|
||||
}
|
||||
public function __construct(
|
||||
$userId,
|
||||
IConfig $configManager
|
||||
) {
|
||||
$this->userId = $userId;
|
||||
$this->configManager = $configManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getForm()
|
||||
{
|
||||
/**
|
||||
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getForm() {
|
||||
|
||||
$parameters = [
|
||||
'EpubEnable' => $this->configManager->getUserValue($this->userId, 'epubreader', 'epub_enable'),
|
||||
'PdfEnable' => $this->configManager->getUserValue($this->userId, 'epubreader', 'pdf_enable'),
|
||||
$parameters = [
|
||||
'EpubEnable' => $this->configManager->getUserValue($this->userId, 'epubreader', 'epub_enable'),
|
||||
'PdfEnable' => $this->configManager->getUserValue($this->userId, 'epubreader', 'pdf_enable'),
|
||||
'CbxEnable' => $this->configManager->getUserValue($this->userId, 'epubreader', 'cbx_enable'),
|
||||
];
|
||||
return new TemplateResponse('epubreader', 'settings-personal', $parameters, '');
|
||||
}
|
||||
];
|
||||
return new TemplateResponse('epubreader', 'settings-personal', $parameters, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Print config section (ownCloud 10)
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getPanel()
|
||||
{
|
||||
return $this->getForm();
|
||||
}
|
||||
/**
|
||||
* Print config section (ownCloud 10)
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getPanel() {
|
||||
return $this->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getSection()
|
||||
{
|
||||
return 'epubreader';
|
||||
}
|
||||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getSection() {
|
||||
return 'epubreader';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get section ID (ownCloud 10)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSectionID()
|
||||
{
|
||||
return 'epubreader';
|
||||
}
|
||||
/**
|
||||
* Get section ID (ownCloud 10)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSectionID() {
|
||||
return 'epubreader';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*
|
||||
* E.g.: 70
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*
|
||||
* E.g.: 70
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getPriority() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
@ -15,56 +15,50 @@ use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIconSection;
|
||||
|
||||
class PersonalSection implements IIconSection
|
||||
{
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
class PersonalSection implements IIconSection {
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
public function __construct(IURLGenerator $urlGenerator, IL10N $l)
|
||||
{
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->l = $l;
|
||||
}
|
||||
public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the relative path to an 16*16 icon describing the section.
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->urlGenerator->imagePath('epubreader', 'app.svg');
|
||||
}
|
||||
/**
|
||||
* returns the relative path to an 16*16 icon describing the section.
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getIcon() {
|
||||
return $this->urlGenerator->imagePath('epubreader', 'app.svg');
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the ID of the section. It is supposed to be a lower case string,
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getID()
|
||||
{
|
||||
return 'epubreader';
|
||||
}
|
||||
/**
|
||||
* returns the ID of the section. It is supposed to be a lower case string,
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getID() {
|
||||
return 'epubreader';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the translated name as it should be displayed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->l->t('EPUB/CBZ/PDF ebook reader');
|
||||
}
|
||||
/**
|
||||
* returns the translated name as it should be displayed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->l->t('EPUB/CBZ/PDF ebook reader');
|
||||
}
|
||||
|
||||
/**
|
||||
* returns priority for positioning
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* returns priority for positioning
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority() {
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,16 @@
|
||||
namespace OCA\Epubreader\Utility;
|
||||
|
||||
class Time {
|
||||
public function getTime() {
|
||||
return time();
|
||||
}
|
||||
public function getTime() {
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int the current unix time in miliseconds
|
||||
*/
|
||||
public function getMicroTime() {
|
||||
list($millisecs, $secs) = explode(" ", microtime());
|
||||
return $secs . substr($millisecs, 2, 6);
|
||||
}
|
||||
/**
|
||||
* @return string the current unix time in miliseconds
|
||||
*/
|
||||
public function getMicroTime(): string {
|
||||
list($millisecs, $secs) = explode(" ", microtime());
|
||||
return $secs . substr($millisecs, 2, 6);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ namespace OCA\Epubreader;
|
||||
/**
|
||||
* Config class for Reader
|
||||
*/
|
||||
class Config
|
||||
{
|
||||
class Config {
|
||||
/**
|
||||
* @brief get user config value
|
||||
*
|
||||
|
35
psalm.xml
Normal file
35
psalm.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="4"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib" />
|
||||
<directory name="stubs" />
|
||||
</projectFiles>
|
||||
<extraFiles>
|
||||
<directory name="vendor" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor/psalm" />
|
||||
</ignoreFiles>
|
||||
</extraFiles>
|
||||
<issueHandlers>
|
||||
<UndefinedDocblockClass>
|
||||
<errorLevel type="suppress">
|
||||
<referencedClass name="OC\AppFramework\OCS\BaseResponse" />
|
||||
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
|
||||
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
|
||||
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
|
||||
<referencedClass name="Doctrine\DBAL\Schema\Table" />
|
||||
</errorLevel>
|
||||
</UndefinedDocblockClass>
|
||||
<UndefinedClass>
|
||||
<errorLevel type="suppress">
|
||||
<referencedClass name="OC" />
|
||||
</errorLevel>
|
||||
</UndefinedClass>
|
||||
</issueHandlers>
|
||||
</psalm>
|
53
stubs/oc/Hooks\Emitter.php
Normal file
53
stubs/oc/Hooks\Emitter.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
namespace OC\Hooks;
|
||||
|
||||
/**
|
||||
* Class Emitter
|
||||
*
|
||||
* interface for all classes that are able to emit events
|
||||
*
|
||||
* @package OC\Hooks
|
||||
* @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service
|
||||
*/
|
||||
interface Emitter {
|
||||
/**
|
||||
* @param string $scope
|
||||
* @param string $method
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
* @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
|
||||
*/
|
||||
public function listen($scope, $method, callable $callback);
|
||||
|
||||
/**
|
||||
* @param string $scope optional
|
||||
* @param string $method optional
|
||||
* @param callable $callback optional
|
||||
* @return void
|
||||
* @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::removeListener
|
||||
*/
|
||||
public function removeListener($scope = null, $method = null, callable $callback = null);
|
||||
}
|
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0048';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0048';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPod'));
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPod'));
|
||||
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
@ -32,7 +32,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader',''));?>"> -->
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader', ''));?>"> -->
|
||||
<title>
|
||||
<?php p($title);?>
|
||||
</title>
|
||||
|
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0072';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0072';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPod'));
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPod'));
|
||||
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
@ -32,7 +32,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader',''));?>"> -->
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader', ''));?>"> -->
|
||||
<title>
|
||||
<?php p($title);?>
|
||||
</title>
|
||||
@ -113,21 +113,21 @@
|
||||
<div class="control-group">
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_family" name="font_family">
|
||||
<label for="custom_font_family"><?php print ($l->t ('custom font')); ?></label>
|
||||
<label for="custom_font_family"><?php print($l->t('custom font')); ?></label>
|
||||
<select id="font_family" disabled="">
|
||||
<option value="verdana, trebuchet, droid sans serif, sans, sans-serif"> sans </option>
|
||||
<option value="georgia, times new roman, droid serif, serif"> serif </option>
|
||||
<option value="monospace"><?php print ($l->t ('monospace')); ?> </option>
|
||||
<option value="monospace"><?php print($l->t('monospace')); ?> </option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_size" name="font_size">
|
||||
<label for="custom_font_size"><?php print ($l->t ('font size')); ?></label>
|
||||
<label for="custom_font_size"><?php print($l->t('font size')); ?></label>
|
||||
<input type="number" id="font_size" value="100" min="50" max="150" disabled=""> %
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_weight" name="font_weight">
|
||||
<label for="custom_font_weight"><?php print ($l->t ('font weight')); ?></label>
|
||||
<label for="custom_font_weight"><?php print($l->t('font weight')); ?></label>
|
||||
<select id="font_weight" disabled="">
|
||||
<option value="100">thin</option>
|
||||
<option value="200">extra light</option>
|
||||
@ -154,7 +154,7 @@
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="use_custom_colors" name="use_custom_colors">
|
||||
<label for="use_custom_colors">
|
||||
<?php print ($l->t ('Use custom colors')); ?>;
|
||||
<?php print($l->t('Use custom colors')); ?>;
|
||||
</label>
|
||||
<div class="center-box">
|
||||
<input type="color" id="day_color" value="#0a0a0a">
|
||||
@ -172,7 +172,7 @@
|
||||
<legend>night</legend>
|
||||
<div class="control-group">
|
||||
<div class="center-box nightshift">
|
||||
<?php print ($l->t ('night mode can be toggled by clicking the book title')); ?>;
|
||||
<?php print($l->t('night mode can be toggled by clicking the book title')); ?>;
|
||||
</div>
|
||||
<div class="center-box">
|
||||
<input type="color" id="night_color" value="#454545">
|
||||
@ -202,19 +202,19 @@
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">
|
||||
<label for="sidebarReflow">
|
||||
<?php print ($l->t ('reflow text when sidebars are open')); ?>;
|
||||
<?php print($l->t('reflow text when sidebars are open')); ?>;
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="touch_nav" name="touch_nav">
|
||||
<label for="touch_nav">
|
||||
<?php print ($l->t ('disable extra-wide page turn areas')); ?>;
|
||||
<?php print($l->t('disable extra-wide page turn areas')); ?>;
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="page_turn_arrows" name="page_turn_arrows">
|
||||
<label for="page_turn_arrows">
|
||||
<?php print ($l->t ('show page turn arrows')); ?>;
|
||||
<?php print($l->t('show page turn arrows')); ?>;
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0130';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($downloadLink));
|
||||
$revision = '0130';
|
||||
$version = \OC::$server->getAppManager()->getAppVersion('epubreader') . '.' . $revision;
|
||||
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPod'));
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'], 'iPod'));
|
||||
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
@ -32,7 +32,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader',''));?>"> -->
|
||||
<!-- <base href="<?php p($urlGenerator->linkTo('epubreader', ''));?>"> -->
|
||||
<title>
|
||||
<?php p($title);?>
|
||||
</title>
|
||||
|
@ -19,7 +19,9 @@ style('epubreader', 'settings');
|
||||
|
||||
<p>
|
||||
<input type="checkbox" name="EpubEnable" id="EpubEnable" class="checkbox"
|
||||
value="1" <?php if ($_['EpubEnable'] === "true") print_unescaped('checked="checked"'); ?> />
|
||||
value="1" <?php if ($_['EpubEnable'] === "true") {
|
||||
print_unescaped('checked="checked"');
|
||||
} ?> />
|
||||
<label for="EpubEnable">
|
||||
<?php p($l->t('Epub'));?>
|
||||
</label>
|
||||
@ -27,14 +29,18 @@ style('epubreader', 'settings');
|
||||
|
||||
<p>
|
||||
<input type="checkbox" name="PdfEnable" id="PdfEnable" class="checkbox"
|
||||
value="1" <?php if ($_['PdfEnable'] === "true") print_unescaped('checked="checked"'); ?> />
|
||||
value="1" <?php if ($_['PdfEnable'] === "true") {
|
||||
print_unescaped('checked="checked"');
|
||||
} ?> />
|
||||
<label for="PdfEnable">
|
||||
<?php p($l->t('PDF'));?>
|
||||
</label><br/>
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="CbxEnable" id="CbxEnable" class="checkbox"
|
||||
value="1" <?php if ($_['CbxEnable'] === "true") print_unescaped('checked="checked"'); ?> />
|
||||
value="1" <?php if ($_['CbxEnable'] === "true") {
|
||||
print_unescaped('checked="checked"');
|
||||
} ?> />
|
||||
<label for="CbxEnable">
|
||||
<?php p($l->t('CBR/CBZ'));?>
|
||||
</label><br/>
|
||||
|
Reference in New Issue
Block a user