Refacto all project #1
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
/vendor/
|
||||||
|
/build/
|
||||||
|
node_modules/
|
||||||
|
/.php-cs-fixer.cache
|
||||||
|
js/*hot-update.*
|
91
.l10nignore
@ -1,91 +0,0 @@
|
|||||||
js/lib/typearray.js
|
|
||||||
js/lib/typearray.min.js
|
|
||||||
js/lib/wgxpath.install.js
|
|
||||||
vendor/bitjs/io/bytebuffer.js
|
|
||||||
vendor/bitjs/io/bytestream.js
|
|
||||||
vendor/bitjs/io/bitstream.js
|
|
||||||
vendor/bitjs/archive/unzip.js
|
|
||||||
vendor/bitjs/archive/untar.js
|
|
||||||
vendor/bitjs/archive/unrar.js
|
|
||||||
vendor/bitjs/archive/rarvm.js
|
|
||||||
vendor/bitjs/archive/archive.js
|
|
||||||
vendor/pixastic/pixastic_combined.js
|
|
||||||
vendor/pixastic/pixastic.worker.js
|
|
||||||
vendor/pixastic/pixastic.effects.js
|
|
||||||
vendor/pixastic/pixastic.worker.control.js
|
|
||||||
vendor/pixastic/pixastic.js
|
|
||||||
vendor/icomoon/style.css
|
|
||||||
vendor/icomoon/fonts/icomoon.svg
|
|
||||||
vendor/icomoon/fonts/icomoon.woff
|
|
||||||
vendor/icomoon/fonts/icomoon.ttf
|
|
||||||
vendor/icomoon/fonts/icomoon.eot
|
|
||||||
vendor/bartaz/jquery.highlight.js
|
|
||||||
vendor/sindresorhus/screenfull.js
|
|
||||||
vendor/jquery/put-delete.js
|
|
||||||
vendor/epubjs/libs/zip.min.js
|
|
||||||
vendor/epubjs/libs/jquery.min.js
|
|
||||||
vendor/epubjs/libs/screenfull.min.js
|
|
||||||
vendor/epubjs/hooks.min.map
|
|
||||||
vendor/epubjs/epub.min.js
|
|
||||||
vendor/epubjs/css/popup.css
|
|
||||||
vendor/epubjs/css/main.css
|
|
||||||
vendor/epubjs/css/normalize.css
|
|
||||||
vendor/epubjs/css/sidebar.css
|
|
||||||
vendor/epubjs/css/font/fontello.svg
|
|
||||||
vendor/epubjs/css/font/fontello.woff
|
|
||||||
vendor/epubjs/css/font/fontello.eot
|
|
||||||
vendor/epubjs/css/font/fontello.ttf
|
|
||||||
vendor/epubjs/css/annotations.css
|
|
||||||
vendor/epubjs/css/idevice.css
|
|
||||||
vendor/epubjs/epub.main.css
|
|
||||||
vendor/epubjs/reader.min.js
|
|
||||||
vendor/epubjs/epub.min.map
|
|
||||||
vendor/epubjs/hooks.min.js
|
|
||||||
vendor/epubjs/hooks/default/smartimages.js
|
|
||||||
vendor/epubjs/hooks/extensions/highlight.js
|
|
||||||
vendor/epubjs/reader.min.map
|
|
||||||
vendor/bgrins/spectrum.js
|
|
||||||
vendor/bgrins/spectrum.css
|
|
||||||
vendor/cbrjs/css/cbr.css
|
|
||||||
vendor/cbrjs/css/idevice.css
|
|
||||||
vendor/cbrjs/cbr.js
|
|
||||||
vendor/cbrjs/img/loading.gif
|
|
||||||
vendor/pdfjs/css/popup.css
|
|
||||||
vendor/pdfjs/css/main.css
|
|
||||||
vendor/pdfjs/css/annotation_layer_builder.css
|
|
||||||
vendor/pdfjs/css/normalize.css
|
|
||||||
vendor/pdfjs/css/sidebar.css
|
|
||||||
vendor/pdfjs/css/annotations.css
|
|
||||||
vendor/pdfjs/css/text_layer_builder.css
|
|
||||||
vendor/pdfjs/css/idevice.css
|
|
||||||
vendor/pdfjs/css/images/annotation-insert.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-newparagraph.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-key.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-check.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-paragraph.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-help.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-noicon.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-comment.svg
|
|
||||||
vendor/pdfjs/css/images/annotation-note.svg
|
|
||||||
vendor/pdfjs/pdf.reader.js
|
|
||||||
vendor/pdfjs/controllers/textlayer_controller.js
|
|
||||||
vendor/pdfjs/controllers/sidebar_controller.js
|
|
||||||
vendor/pdfjs/controllers/outline_controller.js
|
|
||||||
vendor/pdfjs/controllers/styles_controller.js
|
|
||||||
vendor/pdfjs/controllers/notes_controller.js
|
|
||||||
vendor/pdfjs/controllers/settings_controller.js
|
|
||||||
vendor/pdfjs/controllers/meta_controller.js
|
|
||||||
vendor/pdfjs/controllers/reader_controller.js
|
|
||||||
vendor/pdfjs/controllers/bookmarks_controller.js
|
|
||||||
vendor/pdfjs/controllers/progress_controller.js
|
|
||||||
vendor/pdfjs/controllers/toc_controller.js
|
|
||||||
vendor/pdfjs/controllers/search_controller.js
|
|
||||||
vendor/pdfjs/controllers/controls_controller.js
|
|
||||||
vendor/pdfjs/controllers/annotationlayer_controller.js
|
|
||||||
vendor/pdfjs/controllers/textlayer_controller.js.simple
|
|
||||||
vendor/pdfjs/services/eventbus_service.js
|
|
||||||
vendor/pdfjs/services/simple_link_service.js
|
|
||||||
vendor/pdfjs/services/link_service.js
|
|
||||||
vendor/pdfjs/lib/pdf.worker.js
|
|
||||||
vendor/pdfjs/lib/text_layer_builder.js
|
|
||||||
vendor/pdfjs/lib/pdf.js
|
|
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;
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ownCloud - Epubreader App
|
|
||||||
*
|
|
||||||
* @author Frank de Lange
|
|
||||||
* @copyright 2015 - 2017 Frank de Lange
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Epubreader\AppInfo;
|
|
||||||
|
|
||||||
use OCP\AppFramework\App;
|
|
||||||
use OCP\Util;
|
|
||||||
|
|
||||||
$l = \OC::$server->getL10N('epubreader');
|
|
||||||
|
|
||||||
\OCA\Epubreader\Hooks::register();
|
|
||||||
Util::addscript('epubreader', 'plugin');
|
|
@ -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
|
[README]: https://github.com/e-alfred/epubreader/blob/master/epubreader/README.md
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<version>1.4.7</version>
|
<version>1.4.8</version>
|
||||||
<licence>agpl</licence>
|
<licence>agpl</licence>
|
||||||
<author>Frank de Lange</author>
|
<author>Frank de Lange</author>
|
||||||
<author>e-alfred</author>
|
<author>e-alfred</author>
|
||||||
@ -46,10 +46,13 @@ 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-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>
|
<screenshot>https://github.com/e-alfred/epubreader/blob/master/screenshots/photo_2017-03-15_17-22-02.jpg?raw=true</screenshot>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<nextcloud min-version="21" max-version="23"/>
|
<nextcloud min-version="21" max-version="27"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<settings>
|
<settings>
|
||||||
<personal>OCA\Epubreader\Settings\Personal</personal>
|
<personal>OCA\Epubreader\Settings\Personal</personal>
|
||||||
<personal-section>OCA\Epubreader\Settings\PersonalSection</personal-section>
|
<personal-section>OCA\Epubreader\Settings\PersonalSection</personal-section>
|
||||||
</settings>
|
</settings>
|
||||||
|
<types>
|
||||||
|
<filesystem/>
|
||||||
|
</types>
|
||||||
</info>
|
</info>
|
||||||
|
@ -11,31 +11,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
return ['routes' => [
|
return ['routes' => [
|
||||||
// Page
|
// Page
|
||||||
['name' => 'page#showReader', 'url' => '/', 'verb' => 'GET'],
|
['name' => 'page#showReader', 'url' => '/', 'verb' => 'GET'],
|
||||||
|
|
||||||
// Bookmarks
|
// Bookmarks
|
||||||
['name' => 'bookmark#get_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'GET'],
|
['name' => 'bookmark#get_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'GET'],
|
||||||
['name' => 'bookmark#set_cursor', 'url' => '/bookmark/cursor', 'verb' => 'POST'],
|
['name' => 'bookmark#set_cursor', 'url' => '/bookmark/cursor', 'verb' => 'POST'],
|
||||||
['name' => 'bookmark#delete_cursor', 'url' => '/bookmark/cursor/{fileId}', 'verb' => 'DELETE'],
|
['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}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||||
['name' => 'bookmark#get', 'url' => '/bookmark/{fileId}/{type}/{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#set', 'url' => '/bookmark', 'verb' => 'POST'],
|
||||||
['name' => 'bookmark#delete', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'DELETE'],
|
['name' => 'bookmark#delete', 'url' => '/bookmark/{fileId}/{name}', 'verb' => 'DELETE'],
|
||||||
|
|
||||||
// Metadata
|
// Preferences
|
||||||
['name' => 'metadata#get', 'url' => '/metadata/{fileId}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
['name' => 'preference#get_default', 'url' => '/preference/default/{scope}/{name}', 'verb' => 'GET', 'defaults' => ['name' => '']],
|
||||||
['name' => 'metadata#set', 'url' => '/metadata/{fileId}/{name}/{value}', 'verb' => 'POST'],
|
['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
|
// User Settings
|
||||||
['name' => 'settings#setPreference', 'url' => '/settings/set', 'verb' => 'POST'],
|
['name' => 'settings#setPreference', 'url' => '/settings/set', 'verb' => 'POST'],
|
||||||
]];
|
]];
|
||||||
|
|
||||||
|
25
composer.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "nextcloud/epubreader",
|
||||||
|
"description": "EPUB/CBZ/PDF ebook reader",
|
||||||
|
"version": "1.4.8",
|
||||||
|
"type": "project",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/event-dispatcher": "^5.4.22",
|
||||||
|
"nextcloud/ocp": "^27.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:check": "psalm.phar --threads=1 --no-cache --show-info=true",
|
||||||
|
"psalm:fix": "psalm.phar --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"platform": {
|
||||||
|
"php": "7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
709
composer.lock
generated
Normal file
@ -0,0 +1,709 @@
|
|||||||
|
{
|
||||||
|
"_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": "72e9bc76d92d0e26e0b3af7ed7ce6a68",
|
||||||
|
"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": "v27.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nextcloud-deps/ocp.git",
|
||||||
|
"reference": "c374aa2d4c3491812c19a53ce14063127daea08e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/c374aa2d4c3491812c19a53ce14063127daea08e",
|
||||||
|
"reference": "c374aa2d4c3491812c19a53ce14063127daea08e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ~8.0 || ~8.1",
|
||||||
|
"psr/clock": "^1.0",
|
||||||
|
"psr/container": "^2.0.2",
|
||||||
|
"psr/event-dispatcher": "^1.0",
|
||||||
|
"psr/log": "^1.1.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-stable27": "27.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": {
|
||||||
|
"issues": "https://github.com/nextcloud-deps/ocp/issues",
|
||||||
|
"source": "https://github.com/nextcloud-deps/ocp/tree/v27.0.0"
|
||||||
|
},
|
||||||
|
"time": "2023-06-16T07:25:09+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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/clock",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/clock.git",
|
||||||
|
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
|
||||||
|
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.0 || ^8.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Clock\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "https://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interface for reading the clock.",
|
||||||
|
"homepage": "https://github.com/php-fig/clock",
|
||||||
|
"keywords": [
|
||||||
|
"clock",
|
||||||
|
"now",
|
||||||
|
"psr",
|
||||||
|
"psr-20",
|
||||||
|
"time"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-fig/clock/issues",
|
||||||
|
"source": "https://github.com/php-fig/clock/tree/1.0.0"
|
||||||
|
},
|
||||||
|
"time": "2022-11-25T14:36:26+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/container",
|
||||||
|
"version": "2.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/container.git",
|
||||||
|
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||||
|
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Container\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "https://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common Container Interface (PHP FIG PSR-11)",
|
||||||
|
"homepage": "https://github.com/php-fig/container",
|
||||||
|
"keywords": [
|
||||||
|
"PSR-11",
|
||||||
|
"container",
|
||||||
|
"container-interface",
|
||||||
|
"container-interop",
|
||||||
|
"psr"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-fig/container/issues",
|
||||||
|
"source": "https://github.com/php-fig/container/tree/2.0.2"
|
||||||
|
},
|
||||||
|
"time": "2021-11-05T16:47:00+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/event-dispatcher",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/event-dispatcher.git",
|
||||||
|
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
|
||||||
|
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\EventDispatcher\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Standard interfaces for event handling.",
|
||||||
|
"keywords": [
|
||||||
|
"events",
|
||||||
|
"psr",
|
||||||
|
"psr-14"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-fig/event-dispatcher/issues",
|
||||||
|
"source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
|
||||||
|
},
|
||||||
|
"time": "2019-01-08T18:20:26+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/log",
|
||||||
|
"version": "1.1.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/log.git",
|
||||||
|
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
||||||
|
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.1.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Log\\": "Psr/Log/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "https://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interface for logging libraries",
|
||||||
|
"homepage": "https://github.com/php-fig/log",
|
||||||
|
"keywords": [
|
||||||
|
"log",
|
||||||
|
"psr",
|
||||||
|
"psr-3"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||||
|
},
|
||||||
|
"time": "2021-05-03T11:20:27+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/deprecation-contracts",
|
||||||
|
"version": "v2.5.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||||
|
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
|
||||||
|
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "2.5-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/contracts",
|
||||||
|
"url": "https://github.com/symfony/contracts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"function.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A generic function and convention to trigger deprecation notices",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-01-02T09:53:40+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/event-dispatcher",
|
||||||
|
"version": "v5.4.22",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||||
|
"reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1df20e45d56da29a4b1d8259dd6e950acbf1b13f",
|
||||||
|
"reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.5",
|
||||||
|
"symfony/deprecation-contracts": "^2.1|^3",
|
||||||
|
"symfony/event-dispatcher-contracts": "^2|^3",
|
||||||
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/dependency-injection": "<4.4"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/event-dispatcher-implementation": "1.0",
|
||||||
|
"symfony/event-dispatcher-implementation": "2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"psr/log": "^1|^2|^3",
|
||||||
|
"symfony/config": "^4.4|^5.0|^6.0",
|
||||||
|
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
|
||||||
|
"symfony/error-handler": "^4.4|^5.0|^6.0",
|
||||||
|
"symfony/expression-language": "^4.4|^5.0|^6.0",
|
||||||
|
"symfony/http-foundation": "^4.4|^5.0|^6.0",
|
||||||
|
"symfony/service-contracts": "^1.1|^2|^3",
|
||||||
|
"symfony/stopwatch": "^4.4|^5.0|^6.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/dependency-injection": "",
|
||||||
|
"symfony/http-kernel": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\EventDispatcher\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/event-dispatcher/tree/v5.4.22"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-03-17T11:31:58+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/event-dispatcher-contracts",
|
||||||
|
"version": "v2.5.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
|
||||||
|
"reference": "f98b54df6ad059855739db6fcbc2d36995283fe1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1",
|
||||||
|
"reference": "f98b54df6ad059855739db6fcbc2d36995283fe1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.5",
|
||||||
|
"psr/event-dispatcher": "^1"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/event-dispatcher-implementation": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "2.5-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/contracts",
|
||||||
|
"url": "https://github.com/symfony/contracts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Contracts\\EventDispatcher\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Generic abstractions related to dispatching event",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"abstractions",
|
||||||
|
"contracts",
|
||||||
|
"decoupling",
|
||||||
|
"interfaces",
|
||||||
|
"interoperability",
|
||||||
|
"standards"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-01-02T09:53:40+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-php80",
|
||||||
|
"version": "v1.27.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||||
|
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
|
||||||
|
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.27-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Php80\\": ""
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"Resources/stubs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Ion Bazan",
|
||||||
|
"email": "ion.bazan@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-11-03T14:55:06+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"
|
||||||
|
}
|
20
js/ready.js
@ -1,4 +1,4 @@
|
|||||||
document.onreadystatechange = function () {
|
document.onreadystatechange = function () {
|
||||||
|
|
||||||
if (document.readyState == "complete") {
|
if (document.readyState == "complete") {
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ document.onreadystatechange = function () {
|
|||||||
return $.get(options.session.basePath + "bookmark/cursor/" + options.session.fileId);
|
return $.get(options.session.basePath + "bookmark/cursor/" + options.session.fileId);
|
||||||
};
|
};
|
||||||
options.session.setCursor = function(value) {
|
options.session.setCursor = function(value) {
|
||||||
return $.post(options.session.basePath + "bookmark/cursor",
|
return $.post(options.session.basePath + "bookmark/cursor",
|
||||||
{
|
{
|
||||||
"fileId": options.session.fileId,
|
"fileId": options.session.fileId,
|
||||||
"value": JSON.stringify(value)
|
"value": JSON.stringify(value)
|
||||||
@ -103,7 +103,7 @@ document.onreadystatechange = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// why is there no standard library function for this?
|
// why is there no standard library function for this?
|
||||||
function getUrlParameter (param) {
|
function getUrlParameter (param) {
|
||||||
var pattern = new RegExp('[?&]'+param+'((=([^&]*))|(?=(&|$)))','i');
|
var pattern = new RegExp('[?&]'+param+'((=([^&]*))|(?=(&|$)))','i');
|
||||||
var m = window.location.search.match(pattern);
|
var m = window.location.search.match(pattern);
|
||||||
@ -113,9 +113,9 @@ document.onreadystatechange = function () {
|
|||||||
// start epub.js renderer
|
// start epub.js renderer
|
||||||
function renderEpub(file, options) {
|
function renderEpub(file, options) {
|
||||||
|
|
||||||
// some parameters...
|
// some parameters...
|
||||||
EPUBJS.filePath = "vendor/epubjs/";
|
EPUBJS.filePath = "public/epubjs/";
|
||||||
EPUBJS.cssPath = "vendor/epubjs/css/";
|
EPUBJS.cssPath = "public/epubjs/css/";
|
||||||
EPUBJS.basePath = $('.session').data('basepath');
|
EPUBJS.basePath = $('.session').data('basepath');
|
||||||
EPUBJS.staticPath = $('.session').data('staticpath');
|
EPUBJS.staticPath = $('.session').data('staticpath');
|
||||||
|
|
||||||
@ -136,16 +136,16 @@ document.onreadystatechange = function () {
|
|||||||
|
|
||||||
// start cbr.js renderer
|
// start cbr.js renderer
|
||||||
function renderCbr(file, options) {
|
function renderCbr(file, options) {
|
||||||
CBRJS.filePath = "vendor/cbrjs/";
|
CBRJS.filePath = "public/cbrjs/";
|
||||||
|
|
||||||
var reader = cbReader(file, options);
|
var reader = cbReader(file, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start pdf.js renderer
|
// start pdf.js renderer
|
||||||
function renderPdf(file, options) {
|
function renderPdf(file, options) {
|
||||||
PDFJS.filePath = "vendor/pdfjs/";
|
PDFJS.filePath = "public/pdfjs/";
|
||||||
PDFJS.imageResourcesPath = "vendor/pdfjs/css/images/";
|
PDFJS.imageResourcesPath = "public/pdfjs/css/images/";
|
||||||
PDFJS.workerSrc = options.session.staticPath + 'vendor/pdfjs/lib/pdf.worker.js';
|
PDFJS.workerSrc = options.session.staticPath + 'public/pdfjs/lib/pdf.worker.js';
|
||||||
|
|
||||||
var reader = pdfReader(file, options);
|
var reader = pdfReader(file, options);
|
||||||
}
|
}
|
||||||
|
41
lib/AppInfo/Application.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ownCloud - Epubreader App
|
||||||
|
*
|
||||||
|
* @author Frank de Lange
|
||||||
|
* @copyright 2015 - 2017 Frank de Lange
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Epubreader\AppInfo;
|
||||||
|
|
||||||
|
use OCA\Epubreader\Hooks;
|
||||||
|
use OCP\AppFramework\App;
|
||||||
|
use OCP\Files\IRootFolder;
|
||||||
|
use OCP\IDBConnection;
|
||||||
|
use OCP\Util;
|
||||||
|
|
||||||
|
class Application extends App {
|
||||||
|
|
||||||
|
public const APP_ID = 'epubreader';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct(self::APP_ID);
|
||||||
|
|
||||||
|
/** @psalm-suppress DeprecatedInterface */
|
||||||
|
$container = $this->getContainer();
|
||||||
|
/** @var IRootFolder $rootFolder */
|
||||||
|
$rootFolder = $container->get(IRootFolder::class);
|
||||||
|
/** @var IDBConnection $dbConnection */
|
||||||
|
$dbConnection = $container->get(IDBConnection::class);
|
||||||
|
$hooks = new Hooks($rootFolder, $dbConnection);
|
||||||
|
$hooks->register();
|
||||||
|
|
||||||
|
/** @psalm-suppress DeprecatedMethod */
|
||||||
|
Util::connectHook('\OCP\Config', 'js', 'OCA\Epubreader\Hooks', 'announce_settings');
|
||||||
|
Util::addscript(self::APP_ID, 'plugin');
|
||||||
|
}
|
||||||
|
}
|
@ -10,115 +10,106 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Controller;
|
namespace OCA\Epubreader\Controller;
|
||||||
|
|
||||||
use OCP\IRequest;
|
|
||||||
use OCP\AppFramework\Controller;
|
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
|
||||||
|
|
||||||
|
|
||||||
use OCA\Epubreader\Service\BookmarkService;
|
use OCA\Epubreader\Service\BookmarkService;
|
||||||
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\IRequest;
|
||||||
|
|
||||||
class BookmarkController extends Controller {
|
class BookmarkController extends Controller {
|
||||||
|
|
||||||
private $bookmarkService;
|
private BookmarkService $bookmarkService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $AppName
|
* @param string $AppName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param BookmarkService $bookmarkService
|
* @param BookmarkService $bookmarkService
|
||||||
*/
|
*/
|
||||||
public function __construct($AppName,
|
public function __construct(
|
||||||
IRequest $request,
|
string $AppName,
|
||||||
BookmarkService $bookmarkService ) {
|
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
|
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
*
|
|
||||||
* @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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief return bookmark
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* @param int $fileId
|
||||||
|
* @param ?string $name
|
||||||
|
* @param ?string $type
|
||||||
|
*/
|
||||||
|
public function get(int $fileId, ?string $name = null, ?string $type = null): JSONResponse {
|
||||||
|
return new JSONResponse($this->bookmarkService->get($fileId, $name, $type));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief return cursor for $fileId
|
* @brief write bookmark
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
*
|
* @param string $name
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
* @param string $value
|
||||||
|
* @param ?string $type
|
||||||
|
* @param ?string $content
|
||||||
*/
|
*/
|
||||||
public function getCursor($fileId) {
|
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): JSONResponse {
|
||||||
return $this->bookmarkService->getCursor($fileId);
|
return new JSONResponse($this->bookmarkService->set($fileId, $name, $value, $type, $content));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write cursor for $fileId
|
* @brief return cursor for $fileId
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $value
|
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function setCursor($fileId, $value) {
|
public function getCursor(int $fileId): JSONResponse {
|
||||||
return $this->bookmarkService->setCursor($fileId, $value);
|
return new JSONResponse($this->bookmarkService->getCursor($fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete bookmark
|
* @brief write cursor for $fileId
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string name
|
* @param string $value
|
||||||
*
|
*/
|
||||||
*/
|
public function setCursor(int $fileId, string $value): JSONResponse {
|
||||||
public function delete($fileId, $name) {
|
return new JSONResponse($this->bookmarkService->setCursor($fileId, $value));
|
||||||
return $this->bookmarkService->delete($fileId, $name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete cursor
|
* @brief delete bookmark
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
*
|
* @param string name
|
||||||
*/
|
*/
|
||||||
public function deleteCursor($fileId) {
|
public function delete(int $fileId, string $name): void {
|
||||||
return $this->bookmarkService->deleteCursor($fileId);
|
$this->bookmarkService->delete($fileId, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief delete cursor
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* @param int $fileId
|
||||||
|
*/
|
||||||
|
public function deleteCursor(int $fileId): void {
|
||||||
|
$this->bookmarkService->deleteCursor($fileId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @author Frank de Lange
|
|
||||||
* @copyright 2017 Frank de Lange
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
* See the COPYING-README file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Epubreader\Controller;
|
|
||||||
|
|
||||||
use OCP\IRequest;
|
|
||||||
use OCP\AppFramework\Controller;
|
|
||||||
|
|
||||||
use OCA\Epubreader\Service\MetadataService;
|
|
||||||
|
|
||||||
class MetadataController extends Controller {
|
|
||||||
|
|
||||||
private $metadataService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $AppName
|
|
||||||
* @param IRequest $request
|
|
||||||
* @param MetadataService $metadataService
|
|
||||||
*/
|
|
||||||
public function __construct($AppName,
|
|
||||||
IRequest $request,
|
|
||||||
MetadataService $metadataService ) {
|
|
||||||
|
|
||||||
parent::__construct($AppName, $request);
|
|
||||||
$this->metadataService = $metadataService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -10,168 +10,167 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Controller;
|
namespace OCA\Epubreader\Controller;
|
||||||
|
|
||||||
|
use OCA\Epubreader\Service\BookmarkService;
|
||||||
|
use OCA\Epubreader\Service\PreferenceService;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
|
||||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||||
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\Files\FileInfo;
|
||||||
|
use OCP\Files\Folder;
|
||||||
|
use OCP\Files\InvalidPathException;
|
||||||
|
use OCP\Files\IRootFolder;
|
||||||
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\Files\IRootFolder;
|
|
||||||
use OCP\Share\IManager;
|
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;
|
|
||||||
|
|
||||||
class PageController extends Controller {
|
class PageController extends Controller {
|
||||||
|
|
||||||
/** @var IURLGenerator */
|
private IURLGenerator $urlGenerator;
|
||||||
private $urlGenerator;
|
private IRootFolder $rootFolder;
|
||||||
/** @var IRootFolder */
|
private IManager $shareManager;
|
||||||
private $rootFolder;
|
private string $userId;
|
||||||
private $shareManager;
|
private BookmarkService $bookmarkService;
|
||||||
private $userId;
|
private PreferenceService $preferenceService;
|
||||||
private $bookmarkService;
|
|
||||||
private $metadataService;
|
|
||||||
private $preferenceService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $AppName
|
* @param string $AppName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IURLGenerator $urlGenerator
|
* @param IURLGenerator $urlGenerator
|
||||||
* @param IRootFolder $rootFolder
|
* @param IRootFolder $rootFolder
|
||||||
* @param IManager $shareManager
|
* @param IManager $shareManager
|
||||||
* @param string $UserId
|
* @param string $UserId
|
||||||
* @param BookmarkService $bookmarkService
|
* @param BookmarkService $bookmarkService
|
||||||
* @param PreferenceService $preferenceService
|
* @param PreferenceService $preferenceService
|
||||||
* @param MetadataService $metadataService
|
*/
|
||||||
*/
|
public function __construct(
|
||||||
public function __construct(
|
string $AppName,
|
||||||
$AppName,
|
IRequest $request,
|
||||||
IRequest $request,
|
IURLGenerator $urlGenerator,
|
||||||
IURLGenerator $urlGenerator,
|
IRootFolder $rootFolder,
|
||||||
IRootFolder $rootFolder,
|
IManager $shareManager,
|
||||||
IManager $shareManager,
|
string $UserId,
|
||||||
$UserId,
|
BookmarkService $bookmarkService,
|
||||||
BookmarkService $bookmarkService,
|
PreferenceService $preferenceService,
|
||||||
PreferenceService $preferenceService,
|
) {
|
||||||
MetadataService $metadataService) {
|
parent::__construct($AppName, $request);
|
||||||
parent::__construct($AppName, $request);
|
$this->urlGenerator = $urlGenerator;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->rootFolder = $rootFolder;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->shareManager = $shareManager;
|
||||||
$this->shareManager = $shareManager;
|
$this->userId = $UserId;
|
||||||
$this->userId = $UserId;
|
$this->bookmarkService = $bookmarkService;
|
||||||
$this->bookmarkService = $bookmarkService;
|
$this->preferenceService = $preferenceService;
|
||||||
$this->metadataService = $metadataService;
|
}
|
||||||
$this->preferenceService = $preferenceService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*/
|
||||||
* @return TemplateResponse
|
public function showReader(): TemplateResponse {
|
||||||
*/
|
$templates = [
|
||||||
public function showReader() {
|
'application/epub+zip' => 'epubreader',
|
||||||
$templates= [
|
'application/x-cbr' => 'cbreader',
|
||||||
'application/epub+zip' => 'epubreader',
|
'application/pdf' => 'pdfreader'
|
||||||
'application/x-cbr' => 'cbreader',
|
];
|
||||||
'application/pdf' => 'pdfreader'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $fileInfo = [
|
* @var array{
|
||||||
* fileId => null,
|
* fileId: int,
|
||||||
* fileName => null,
|
* fileName: string,
|
||||||
* fileType => null
|
* fileType: string
|
||||||
* ];
|
* } $fileInfo
|
||||||
*/
|
*/
|
||||||
$fileInfo = $this->getFileInfo($this->request->get['file']);
|
$fileInfo = $this->getFileInfo((string) $this->request->getParam('file'));
|
||||||
$fileId = $fileInfo['fileId'];
|
$fileId = $fileInfo['fileId'];
|
||||||
$type = $this->request->get["type"];
|
$type = (string) $this->request->getParam('type');
|
||||||
$scope = $template = $templates[$type];
|
$scope = $template = $templates[$type];
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'urlGenerator' => $this->urlGenerator,
|
'urlGenerator' => $this->urlGenerator,
|
||||||
'downloadLink' => $this->request->get['file'],
|
'downloadLink' => $this->request->getParam('file'),
|
||||||
'scope' => $scope,
|
'scope' => $scope,
|
||||||
'fileId' => $fileInfo['fileId'],
|
'fileId' => $fileInfo['fileId'],
|
||||||
'fileName' => $fileInfo['fileName'],
|
'fileName' => $fileInfo['fileName'],
|
||||||
'fileType' => $fileInfo['fileType'],
|
'fileType' => $fileInfo['fileType'],
|
||||||
'cursor' => $this->toJson($this->bookmarkService->getCursor($fileId)),
|
'cursor' => $this->toJson($this->bookmarkService->getCursor($fileId)),
|
||||||
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
||||||
'preferences' => $this->toJson($this->preferenceService->get($scope, $fileId)),
|
'preferences' => $this->toJson($this->preferenceService->get($scope, $fileId)),
|
||||||
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
|
'metadata' => $this->toJson([]),
|
||||||
'metadata' => $this->toJson($this->metadataService->get($fileId)),
|
'annotations' => $this->toJson($this->bookmarkService->get($fileId))
|
||||||
'annotations' => $this->toJson($this->bookmarkService->get($fileId))
|
];
|
||||||
];
|
|
||||||
|
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
$policy->addAllowedStyleDomain('\'self\'');
|
$policy->addAllowedStyleDomain('\'self\'');
|
||||||
$policy->addAllowedStyleDomain('blob:');
|
$policy->addAllowedStyleDomain('blob:');
|
||||||
$policy->addAllowedScriptDomain('\'self\'');
|
$policy->addAllowedScriptDomain('\'self\'');
|
||||||
$policy->addAllowedFrameDomain('\'self\'');
|
$policy->addAllowedFrameDomain('\'self\'');
|
||||||
$policy->addAllowedChildSrcDomain('\'self\'');
|
|
||||||
$policy->addAllowedFontDomain('\'self\'');
|
$policy->addAllowedFontDomain('\'self\'');
|
||||||
$policy->addAllowedFontDomain('data:');
|
$policy->addAllowedFontDomain('data:');
|
||||||
$policy->addAllowedFontDomain('blob:');
|
$policy->addAllowedFontDomain('blob:');
|
||||||
$policy->addAllowedImageDomain('blob:');
|
$policy->addAllowedImageDomain('blob:');
|
||||||
|
|
||||||
$response = new TemplateResponse($this->appName, $template, $params, 'blank');
|
$response = new TemplateResponse($this->appName, $template, $params, 'blank');
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief sharing-aware file info retriever
|
* @brief sharing-aware file info retriever
|
||||||
*
|
*
|
||||||
* Work around the differences between normal and shared file access
|
* Work around the differences between normal and shared file access
|
||||||
* (this should be abstracted away in OC/NC IMnsHO)
|
* (this should be abstracted away in OC/NC IMnsHO)
|
||||||
*
|
*
|
||||||
* @param string $path path-fragment from url
|
* @param string $path path-fragment from url
|
||||||
* @return array
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException|InvalidPathException
|
||||||
*/
|
*/
|
||||||
private function getFileInfo($path) {
|
private function getFileInfo(string $path): array {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$shareToken = preg_replace("/(?:\/index\.php)?\/s\/([A-Za-z0-9]{15,32})\/download.*/", "$1", $path, 1,$count);
|
$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 */
|
/* shared directory, need file path to continue, */
|
||||||
$node = $this->shareManager->getShareByToken($shareToken)->getNode();
|
if ($type == FileInfo::TYPE_FOLDER && $node instanceof Folder) {
|
||||||
$type = $node->getType();
|
$query = [];
|
||||||
|
parse_str(parse_url($path, PHP_URL_QUERY), $query);
|
||||||
|
if (isset($query['path']) && is_string($query['path'])) {
|
||||||
|
$node = $node->get($query['path']);
|
||||||
|
} elseif (isset($query['files']) && is_string($query['files'])) {
|
||||||
|
$node = $node->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((string) $this->request->getParam('file'))))
|
||||||
|
->getId();
|
||||||
|
}
|
||||||
|
|
||||||
/* shared directory, need file path to continue, */
|
$pathInfo = pathInfo($filePath);
|
||||||
if ($type == \OCP\Files\FileInfo::TYPE_FOLDER) {
|
if (!is_array($pathInfo)) {
|
||||||
$query = [];
|
throw new InvalidPathException("Can not get info for $filePath");
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'fileName' => pathInfo($filePath, PATHINFO_FILENAME),
|
'fileName' => $pathInfo['filename'],
|
||||||
'fileType' => strtolower(pathInfo($filePath, PATHINFO_EXTENSION)),
|
'fileType' => strtolower($pathInfo['extension'] ?? ''),
|
||||||
'fileId' => $fileId
|
'fileId' => $fileId
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function toJson($value) {
|
/**
|
||||||
return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8');
|
* @param mixed $value
|
||||||
}
|
*/
|
||||||
|
private function toJson($value): string {
|
||||||
|
return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,119 +10,104 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Controller;
|
namespace OCA\Epubreader\Controller;
|
||||||
|
|
||||||
use OCP\IRequest;
|
|
||||||
use OCP\IURLGenerator;
|
|
||||||
use OCP\AppFramework\Http;
|
|
||||||
use OCP\AppFramework\Controller;
|
|
||||||
|
|
||||||
use OCA\Epubreader\Service\PreferenceService;
|
use OCA\Epubreader\Service\PreferenceService;
|
||||||
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\IRequest;
|
||||||
|
|
||||||
class PreferenceController extends Controller {
|
class PreferenceController extends Controller {
|
||||||
|
|
||||||
private $urlGenerator;
|
private PreferenceService $preferenceService;
|
||||||
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 PreferenceService $preferenceService
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
string $AppName,
|
||||||
|
IRequest $request,
|
||||||
|
PreferenceService $preferenceService
|
||||||
|
) {
|
||||||
parent::__construct($AppName, $request);
|
parent::__construct($AppName, $request);
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->preferenceService = $preferenceService;
|
||||||
$this->preferenceService = $preferenceService;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief return preference for $fileId
|
* @brief return preference for $fileId
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name if null, return all preferences for $scope + $fileId
|
* @param ?string $name if null, return all preferences for $scope + $fileId
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function get($scope, $fileId, $name) {
|
public function get(string $scope, int $fileId, ?string $name = null): JSONResponse {
|
||||||
return $this->preferenceService->get($scope, $fileId, $name);
|
return new JSONResponse($this->preferenceService->get($scope, $fileId, $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write preference for $fileId
|
* @brief write preference for $fileId
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function set($scope, $fileId, $name, $value) {
|
public function set(string $scope, int $fileId, string $name, string $value): JSONResponse {
|
||||||
return $this->preferenceService->set($scope, $fileId, $name, $value);
|
return new JSONResponse($this->preferenceService->set($scope, $fileId, $name, $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief return default preference
|
* @brief return default preference
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name if null, return all default preferences for scope
|
* @param string $name if null, return all default preferences for scope
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function getDefault($scope, $name) {
|
public function getDefault(string $scope, string $name): JSONResponse {
|
||||||
return $this->preferenceService->getDefault($scope, $name);
|
return new JSONResponse($this->preferenceService->getDefault($scope, $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write default preference
|
* @brief write default preference
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function setDefault($scope, $name, $value) {
|
public function setDefault(string $scope, string $name, string $value): JSONResponse {
|
||||||
return $this->preferenceService->setDefault($scope, $name, $value);
|
return new JSONResponse($this->preferenceService->setDefault($scope, $name, $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete preference
|
* @brief delete preference
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*/
|
||||||
*/
|
public function delete(string $scope, int $fileId, string $name): void {
|
||||||
public function delete($scope, $fileId, $name) {
|
$this->preferenceService->delete($scope, $fileId, $name);
|
||||||
return $this->preferenceService->delete($scope, $fileId, $name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete default preference
|
* @brief delete default preference
|
||||||
*
|
*
|
||||||
* @param $scope
|
* @param string $scope
|
||||||
* @param $name
|
* @param string $name
|
||||||
*
|
*/
|
||||||
*/
|
public function deleteDefault(string $scope, string $name): void {
|
||||||
public function deleteDefault($scope, $name) {
|
$this->preferenceService->deleteDefault($scope, $name);
|
||||||
return $this->preferenceService->deleteDefault($scope, $name);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,59 +11,52 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OCA\Epubreader\Controller;
|
namespace OCA\Epubreader\Controller;
|
||||||
use OCP\IRequest;
|
|
||||||
use OCP\IURLGenerator;
|
use OCA\Epubreader\AppInfo\Application;
|
||||||
use OCP\AppFramework\Http;
|
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCA\Epubreader\Service\PreferenceService;
|
|
||||||
use OCA\Epubreader\Config;
|
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
|
use OCP\IRequest;
|
||||||
|
|
||||||
class SettingsController extends Controller {
|
class SettingsController extends Controller {
|
||||||
|
|
||||||
private $urlGenerator;
|
|
||||||
private $preferenceService;
|
|
||||||
|
|
||||||
/**
|
private string $userId;
|
||||||
* @param string $AppName
|
private IL10N $l10n;
|
||||||
* @param IRequest $request
|
private IConfig $configManager;
|
||||||
* @param IURLGenerator $urlGenerator
|
|
||||||
* @param PreferenceService $preferenceService
|
public function __construct(
|
||||||
*/
|
string $appName,
|
||||||
public function __construct($AppName,
|
IRequest $request,
|
||||||
IRequest $request,
|
string $userId,
|
||||||
IURLGenerator $urlGenerator,
|
IL10N $l10n,
|
||||||
PreferenceService $preferenceService ) {
|
IConfig $configManager
|
||||||
|
) {
|
||||||
|
parent::__construct($appName, $request);
|
||||||
|
$this->userId = $userId;
|
||||||
|
$this->l10n = $l10n;
|
||||||
|
$this->configManager = $configManager;
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct($AppName, $request);
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
$this->preferenceService = $preferenceService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set preference for file type association
|
* @brief set preference for file type association
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
* @param int $EpubEnable
|
* @param string $EpubEnable
|
||||||
* @param int $EpubEnable
|
* @param string $PdfEnable
|
||||||
* @param int $CbxEnable
|
* @param string $CbxEnable
|
||||||
*
|
|
||||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
||||||
*/
|
*/
|
||||||
public function setPreference(string $EpubEnable, string $PdfEnable, string $CbxEnable) {
|
public function setPreference(string $EpubEnable, string $PdfEnable, string $CbxEnable): JSONResponse {
|
||||||
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'epub_enable', $EpubEnable);
|
||||||
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'pdf_enable', $PdfEnable);
|
||||||
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'cbx_enable', $CbxEnable);
|
||||||
|
|
||||||
$l = \OC::$server->getL10N('epubreader');
|
$response = [
|
||||||
|
'data' => ['message' => $this->l10n->t('Settings updated successfully.')],
|
||||||
Config::set('epub_enable', $EpubEnable);
|
'status' => 'success'
|
||||||
Config::set('pdf_enable', $PdfEnable);
|
];
|
||||||
Config::set('cbx_enable', $CbxEnable);
|
|
||||||
|
|
||||||
$response = array(
|
|
||||||
'data' => array('message'=> $l->t('Settings updated successfully.')),
|
|
||||||
'status' => 'success'
|
|
||||||
);
|
|
||||||
|
|
||||||
return new JSONResponse($response);
|
return new JSONResponse($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,39 +10,89 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Db;
|
namespace OCA\Epubreader\Db;
|
||||||
|
|
||||||
use OCP\AppFramework\Db\Entity;
|
|
||||||
|
|
||||||
class Bookmark extends ReaderEntity implements \JsonSerializable {
|
class Bookmark extends ReaderEntity implements \JsonSerializable {
|
||||||
|
|
||||||
protected $userId; // user
|
protected string $userId; // user
|
||||||
protected $fileId; // book (identified by fileId) for which this mark is valid
|
protected int $fileId; // book (identified by fileId) for which this mark is valid
|
||||||
protected $type; // type, defaults to "bookmark"
|
protected string $type; // type, defaults to "bookmark"
|
||||||
protected $name; // name, defaults to $location
|
protected string $name; // name, defaults to $location
|
||||||
protected $value; // bookmark value (format-specific, eg. page number for PDF, CFI for epub, etc)
|
protected string $value; // bookmark value (format-specific, eg. page number for PDF, CFI for epub, etc)
|
||||||
protected $content; // bookmark content (annotations etc), can be empty
|
protected string $content; // bookmark content (annotations etc), can be empty
|
||||||
protected $lastModified; // modification timestamp
|
|
||||||
|
|
||||||
public function jsonSerialize() {
|
public function jsonSerialize(): array {
|
||||||
return [
|
return [
|
||||||
'id' => $this->getId(),
|
'id' => $this->getId(),
|
||||||
'userId' => $this->getUserId(),
|
'userId' => $this->getUserId(),
|
||||||
'fileId' => $this->getFileId(),
|
'fileId' => $this->getFileId(),
|
||||||
'type' => $this->getType(),
|
'type' => $this->getType(),
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => static::conditional_json_decode($this->getValue()),
|
'value' => $this->conditional_json_decode($this->getValue()),
|
||||||
'content' => static::conditional_json_decode($this->getContent()),
|
'content' => $this->conditional_json_decode($this->getContent()),
|
||||||
'lastModified' => $this->getLastModified()
|
'lastModified' => $this->getLastModified()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toService() {
|
public function toService(): array {
|
||||||
return [
|
return [
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'type' => $this->getType(),
|
'type' => $this->getType(),
|
||||||
'value' => $this->conditional_json_decode($this->getValue()),
|
'value' => $this->conditional_json_decode($this->getValue()),
|
||||||
'content' => $this->conditional_json_decode($this->getContent()),
|
'content' => $this->conditional_json_decode($this->getContent()),
|
||||||
'lastModified' => $this->getLastModified(),
|
'lastModified' => $this->getLastModified(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserId(): string {
|
||||||
|
return $this->userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserId(string $userId): void {
|
||||||
|
$this->userId = $userId;
|
||||||
|
$this->markFieldUpdated('userId');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileId(): int {
|
||||||
|
return $this->fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFileId(int $fileId): void {
|
||||||
|
$this->fileId = $fileId;
|
||||||
|
$this->markFieldUpdated('fileId');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): string {
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(string $type): void {
|
||||||
|
$this->type = $type;
|
||||||
|
$this->markFieldUpdated('type');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): string {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): void {
|
||||||
|
$this->name = $name;
|
||||||
|
$this->markFieldUpdated('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): string {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(string $value): void {
|
||||||
|
$this->value = $value;
|
||||||
|
$this->markFieldUpdated('value');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContent(): string {
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setContent(string $content): void {
|
||||||
|
$this->content = $content;
|
||||||
|
$this->markFieldUpdated('content');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,115 +10,93 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Db;
|
namespace OCA\Epubreader\Db;
|
||||||
|
|
||||||
|
|
||||||
use OCP\IDBConnection;
|
|
||||||
|
|
||||||
use OCA\Epubreader\Utility\Time;
|
use OCA\Epubreader\Utility\Time;
|
||||||
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class BookmarkMapper extends ReaderMapper {
|
class BookmarkMapper extends ReaderMapper {
|
||||||
|
|
||||||
private $userId;
|
private string $userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IDbConnection $db
|
* @param IDbConnection $db
|
||||||
* @param $UserId
|
* @param string $UserId
|
||||||
* @param Time $time
|
* @param Time $time
|
||||||
*/
|
*/
|
||||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
public function __construct(IDBConnection $db, string $UserId, Time $time) {
|
||||||
parent::__construct($db, 'reader_bookmarks', Bookmark::class, $time);
|
parent::__construct($db, 'reader_bookmarks', Bookmark::class, $time);
|
||||||
/** @var int $UserId */
|
$this->userId = $UserId;
|
||||||
$this->userId = $UserId;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get bookmarks for $fileId+$userId(+$name)
|
* @brief get bookmarks for $fileId+$userId(+$name)
|
||||||
* @param $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
* @return array
|
* @param ?string $type
|
||||||
*/
|
*
|
||||||
public function get($fileId, $name, $type = null) {
|
* @return ReaderEntity[]
|
||||||
$query = $this->db->getQueryBuilder();
|
*/
|
||||||
$query->select('*')
|
public function get(int $fileId, ?string $name = null, ?string $type = null): array {
|
||||||
->from($this->getTableName())
|
$query = $this->db->getQueryBuilder();
|
||||||
->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
$query->select('*')
|
||||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
->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) {
|
if ($type !== null) {
|
||||||
$query->andWhere($query->expr()->eq('type', $query->createNamedParameter($type)));
|
$query->andWhere($query->expr()->eq('type', $query->createNamedParameter($type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name !== null) {
|
if ($name !== null) {
|
||||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->findEntities($query);
|
return $this->findEntities($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write bookmark to database
|
* @brief write bookmark to database
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
* @param ?string $type
|
||||||
* @return Bookmark the newly created or updated bookmark
|
* @param ?string $content
|
||||||
*/
|
*
|
||||||
public function set($fileId, $name, $value, $type, $content=null) {
|
* @return ReaderEntity the newly created or updated bookmark
|
||||||
|
*/
|
||||||
|
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity {
|
||||||
|
$result = $this->get($fileId, $name);
|
||||||
|
|
||||||
$result = $this->get($fileId, $name);
|
if(empty($result)) {
|
||||||
|
// anonymous bookmarks are named after their contents
|
||||||
|
if (empty($name)) {
|
||||||
|
$name = $value;
|
||||||
|
}
|
||||||
|
|
||||||
if(empty($result)) {
|
// default type is "bookmark"
|
||||||
|
if (null === $type) {
|
||||||
|
$type = "bookmark";
|
||||||
|
}
|
||||||
|
|
||||||
// anonymous bookmarks are named after their contents
|
$bookmark = new Bookmark();
|
||||||
if (null === $name) {
|
$bookmark->setFileId($fileId);
|
||||||
$name = $value;
|
$bookmark->setUserId($this->userId);
|
||||||
}
|
$bookmark->setType($type);
|
||||||
|
$bookmark->setName($name);
|
||||||
|
$bookmark->setValue($value);
|
||||||
|
$bookmark->setContent($content ?? '');
|
||||||
|
|
||||||
// default type is "bookmark"
|
$this->insert($bookmark);
|
||||||
if (null === $type) {
|
} elseif ($result[0] instanceof Bookmark) {
|
||||||
$type = "bookmark";
|
$bookmark = $result[0];
|
||||||
}
|
$bookmark->setValue($value);
|
||||||
|
$bookmark->setContent($content ?? '');
|
||||||
|
|
||||||
$bookmark = new Bookmark();
|
$this->update($bookmark);
|
||||||
$bookmark->setFileId($fileId);
|
} else {
|
||||||
$bookmark->setUserId($this->userId);
|
$bookmark = new Bookmark();
|
||||||
$bookmark->setType($type);
|
}
|
||||||
$bookmark->setName($name);
|
|
||||||
$bookmark->setValue($value);
|
|
||||||
$bookmark->setContent($content);
|
|
||||||
|
|
||||||
$this->insert($bookmark);
|
return $bookmark;
|
||||||
} else {
|
}
|
||||||
$bookmark = $result[0];
|
|
||||||
$bookmark->setValue($value);
|
|
||||||
$bookmark->setContent($content);
|
|
||||||
|
|
||||||
$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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,33 +10,74 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Db;
|
namespace OCA\Epubreader\Db;
|
||||||
|
|
||||||
use OCP\AppFramework\Db\Entity;
|
|
||||||
|
|
||||||
class Preference extends ReaderEntity implements \JsonSerializable {
|
class Preference extends ReaderEntity implements \JsonSerializable {
|
||||||
|
|
||||||
protected $userId; // user for whom this preference is valid
|
protected string $userId; // user for whom this preference is valid
|
||||||
protected $scope; // scope (default or specific renderer)
|
protected string $scope; // scope (default or specific renderer)
|
||||||
protected $fileId; // file for which this preference is set
|
protected int $fileId; // file for which this preference is set
|
||||||
protected $name; // preference name
|
protected string $name; // preference name
|
||||||
protected $value; // preference value
|
protected string $value; // preference value
|
||||||
protected $lastModified; // modification timestamp
|
|
||||||
|
|
||||||
public function jsonSerialize() {
|
public function jsonSerialize(): array {
|
||||||
return [
|
return [
|
||||||
'id' => $this->getId(),
|
'id' => $this->getId(),
|
||||||
'scope' => $this->getScope(),
|
'scope' => $this->getScope(),
|
||||||
'fileId' => $this->getFileId(),
|
'fileId' => $this->getFileId(),
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => $this->conditional_json_decode($this->getValue()),
|
'value' => $this->conditional_json_decode($this->getValue()),
|
||||||
'lastModified' => $this->getLastModified(),
|
'lastModified' => $this->getLastModified(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toService() {
|
public function toService(): array {
|
||||||
return [
|
return [
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => $this->conditional_json_decode($this->getValue()),
|
'value' => $this->conditional_json_decode($this->getValue()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserId(): string {
|
||||||
|
return $this->userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserId(string $userId): void {
|
||||||
|
$this->userId = $userId;
|
||||||
|
$this->markFieldUpdated('userId');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScope(): string {
|
||||||
|
return $this->scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setScope(string $scope): void {
|
||||||
|
$this->scope = $scope;
|
||||||
|
$this->markFieldUpdated('scope');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileId(): int {
|
||||||
|
return $this->fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFileId(int $fileId): void {
|
||||||
|
$this->fileId = $fileId;
|
||||||
|
$this->markFieldUpdated('fileId');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): string {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): void {
|
||||||
|
$this->name = $name;
|
||||||
|
$this->markFieldUpdated('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): string {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(string $value): void {
|
||||||
|
$this->value = $value;
|
||||||
|
$this->markFieldUpdated('value');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,93 +10,73 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Db;
|
namespace OCA\Epubreader\Db;
|
||||||
|
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
||||||
use OCA\Epubreader\Utility\Time;
|
use OCA\Epubreader\Utility\Time;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class PreferenceMapper extends ReaderMapper {
|
class PreferenceMapper extends ReaderMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
private string $userId;
|
||||||
parent::__construct($db, 'reader_prefs', Preference::class, $time);
|
|
||||||
$this->userId = $UserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public function __construct(IDBConnection $db, string $UserId, Time $time) {
|
||||||
* @brief get preferences for $scope+$fileId+$userId(+$name)
|
parent::__construct($db, 'reader_prefs', Preference::class, $time);
|
||||||
*
|
$this->userId = $UserId;
|
||||||
* @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)));
|
|
||||||
|
|
||||||
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 ReaderEntity[]
|
||||||
|
*/
|
||||||
|
public function get(string $scope, int $fileId, ?string $name = null): array {
|
||||||
|
$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)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return $this->findEntities($query);
|
||||||
* @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) {
|
|
||||||
|
|
||||||
$result = $this->get($scope, $fileId, $name);
|
/**
|
||||||
|
* @brief write preference to database
|
||||||
|
*
|
||||||
|
* @param string $scope
|
||||||
|
* @param int $fileId
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return ReaderEntity the newly created or updated preference
|
||||||
|
*/
|
||||||
|
public function set(string $scope, int $fileId, string $name, string $value): ReaderEntity {
|
||||||
|
$result = $this->get($scope, $fileId, $name);
|
||||||
|
|
||||||
if(empty($result)) {
|
if(empty($result)) {
|
||||||
|
$preference = new Preference();
|
||||||
|
$preference->setScope($scope);
|
||||||
|
$preference->setFileId($fileId);
|
||||||
|
$preference->setUserId($this->userId);
|
||||||
|
$preference->setName($name);
|
||||||
|
$preference->setValue($value);
|
||||||
|
|
||||||
$preference = new Preference();
|
$this->insert($preference);
|
||||||
$preference->setScope($scope);
|
} elseif ($result[0] instanceof Preference) {
|
||||||
$preference->setFileId($fileId);
|
$preference = $result[0];
|
||||||
$preference->setUserId($this->userId);
|
$preference->setValue($value);
|
||||||
$preference->setName($name);
|
|
||||||
$preference->setValue($value);
|
|
||||||
|
|
||||||
$this->insert($preference);
|
$this->update($preference);
|
||||||
} else {
|
} else {
|
||||||
$preference = $result[0];
|
$preference = new Preference();
|
||||||
$preference->setValue($value);
|
}
|
||||||
|
|
||||||
$this->update($preference);
|
return $preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,28 +12,44 @@ namespace OCA\Epubreader\Db;
|
|||||||
|
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
class ReaderEntity extends Entity {
|
/**
|
||||||
|
* @psalm-type SerializedEntity = array<string|int|array>
|
||||||
|
*/
|
||||||
|
abstract class ReaderEntity extends Entity {
|
||||||
|
|
||||||
/* returns decoded json if input is json, otherwise returns input */
|
protected int $lastModified; // modification timestamp
|
||||||
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 toService() {
|
* returns decoded json if input is json, otherwise returns input
|
||||||
return [
|
*
|
||||||
'name' => $this->getName(),
|
* @return string|array
|
||||||
'type' => $this->getType(),
|
*/
|
||||||
'value' => $this->conditional_json_decode($this->getValue()),
|
public function conditional_json_decode(string $el): mixed {
|
||||||
'content' => $this->conditional_json_decode($this->getContent()),
|
/** @var array $result */
|
||||||
'lastModified' => $this->getLastModified(),
|
$result = json_decode($el);
|
||||||
];
|
if (json_last_error() === JSON_ERROR_NONE) {
|
||||||
}
|
return $result;
|
||||||
*/
|
} else {
|
||||||
|
return $el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastModified(): int {
|
||||||
|
return $this->lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLastModified(int $lastModified): void {
|
||||||
|
$this->lastModified = $lastModified;
|
||||||
|
$this->markFieldUpdated('lastModified');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-return SerializedEntity
|
||||||
|
*/
|
||||||
|
abstract public function toService(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-return SerializedEntity
|
||||||
|
*/
|
||||||
|
abstract public function jsonSerialize(): array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,31 +10,36 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Db;
|
namespace OCA\Epubreader\Db;
|
||||||
|
|
||||||
use OCP\IDBConnection;
|
|
||||||
use OCP\AppFramework\Db\QBMapper;
|
|
||||||
use OCP\AppFramework\Db\Entity;
|
|
||||||
|
|
||||||
use OCA\Epubreader\Utility\Time;
|
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 {
|
abstract class ReaderMapper extends QBMapper {
|
||||||
|
|
||||||
/**
|
private Time $time;
|
||||||
* @var Time
|
|
||||||
*/
|
|
||||||
private $time;
|
|
||||||
|
|
||||||
public function __construct(IDBConnection $db, $table, $entity, Time $time) {
|
/**
|
||||||
parent::__construct($db, $table, $entity);
|
* @param IDBConnection $db Instance of the Db abstraction layer
|
||||||
$this->time = $time;
|
* @param string $table the name of the table. set this to allow entity
|
||||||
}
|
* @param class-string<ReaderEntity> $entity the name of the entity that the sql should be mapped to queries without using sql
|
||||||
|
* @param Time $time
|
||||||
|
*/
|
||||||
|
public function __construct(IDBConnection $db, string $table, string $entity, Time $time) {
|
||||||
|
parent::__construct($db, $table, $entity);
|
||||||
|
$this->time = $time;
|
||||||
|
}
|
||||||
|
|
||||||
public function update(Entity $entity): Entity {
|
public function update(Entity $entity): Entity {
|
||||||
$entity->setLastModified($this->time->getMicroTime());
|
$entity->setLastModified($this->time->getMicroTime());
|
||||||
return parent::update($entity);
|
return parent::update($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insert(Entity $entity): Entity {
|
public function insert(Entity $entity): Entity {
|
||||||
$entity->setLastModified($this->time->getMicroTime());
|
$entity->setLastModified($this->time->getMicroTime());
|
||||||
return parent::insert($entity);
|
return parent::insert($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
108
lib/Hooks.php
@ -10,61 +10,79 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader;
|
namespace OCA\Epubreader;
|
||||||
|
|
||||||
use OCP\IDBConnection;
|
use OCA\Epubreader\AppInfo\Application;
|
||||||
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\Node;
|
use OCP\Files\Node;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IDBConnection;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\Util;
|
use OCP\IUserSession;
|
||||||
use \OC\User\User as User;
|
use OCP\Server;
|
||||||
|
|
||||||
class Hooks {
|
class Hooks {
|
||||||
|
|
||||||
public static function register() {
|
private IRootFolder $rootFolder;
|
||||||
Util::connectHook('\OCP\Config', 'js', 'OCA\Epubreader\Hooks', 'announce_settings');
|
private IDBConnection $dbConnection;
|
||||||
|
|
||||||
\OC::$server->getRootFolder()->listen('\OC\Files', 'preDelete', function (Node $node) {
|
public function __construct(
|
||||||
$fileId = $node->getId();
|
IRootFolder $rootFolder,
|
||||||
$connection = \OC::$server->getDatabaseConnection();
|
IDBConnection $dbConnection,
|
||||||
self::deleteFile($connection, $fileId);
|
) {
|
||||||
});
|
$this->rootFolder = $rootFolder;
|
||||||
\OC::$server->getUserManager()->listen('\OC\User', 'preDelete', function (User $user) {
|
$this->dbConnection = $dbConnection;
|
||||||
$userId = $user->getUID();
|
}
|
||||||
$connection = \OC::$server->getDatabaseConnection();
|
|
||||||
self::deleteUser($connection, $userId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function announce_settings(array $settings) {
|
public function register(): void {
|
||||||
// Nextcloud encodes this as JSON, Owncloud does not (yet) (#75)
|
$this->rootFolder->listen('\OC\Files', 'preDelete', function (Node $node) {
|
||||||
// TODO: rmeove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties
|
$this->deleteFile($node->getId());
|
||||||
$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) {
|
$this->rootFolder->listen('\OC\User', 'preDelete', function (IUser $user) {
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$this->deleteUser($user->getUID());
|
||||||
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
});
|
||||||
$queryBuilder->execute();
|
}
|
||||||
|
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
public static function announce_settings(array $settings): void {
|
||||||
$queryBuilder->delete('reader_prefs')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
// Nextcloud encodes this as JSON, Owncloud does not (yet) (#75)
|
||||||
$queryBuilder->execute();
|
// TODO: remove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties
|
||||||
}
|
$user = Server::get(IUserSession::class)->getUser();
|
||||||
|
if ($user &&
|
||||||
|
is_array($settings['array']) &&
|
||||||
|
array_key_exists('oc_appconfig', $settings['array'])
|
||||||
|
) {
|
||||||
|
$isJson = self::isJson($settings['array']['oc_appconfig']);
|
||||||
|
/** @var array $array */
|
||||||
|
$array = ($isJson) ? json_decode((string) $settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig'];
|
||||||
|
$array['filesReader'] = [
|
||||||
|
'enableEpub' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'epub_enable', true),
|
||||||
|
'enablePdf' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'pdf_enable', true),
|
||||||
|
'enableCbx' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'cbx_enable', true),
|
||||||
|
];
|
||||||
|
$settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static function deleteUser(IDBConnection $connection, $userId) {
|
protected function deleteFile(int $fileId): void {
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$queryBuilder = $this->dbConnection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||||
$queryBuilder->execute();
|
$queryBuilder->executeStatement();
|
||||||
|
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$queryBuilder = $this->dbConnection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_prefs')->where('user_id = user_id')->setParameter('user_id', $userId);
|
$queryBuilder->delete('reader_prefs')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||||
$queryBuilder->execute();
|
$queryBuilder->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function isJson($string) {
|
protected function deleteUser(string $userId): void {
|
||||||
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
|
$queryBuilder = $this->dbConnection->getQueryBuilder();
|
||||||
}
|
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||||
|
$queryBuilder->executeStatement();
|
||||||
|
|
||||||
|
$queryBuilder = $this->dbConnection->getQueryBuilder();
|
||||||
|
$queryBuilder->delete('reader_prefs')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||||
|
$queryBuilder->executeStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function isJson(mixed $string): bool {
|
||||||
|
return is_string($string) && is_array(json_decode($string, true)) && json_last_error() == JSON_ERROR_NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,15 @@ class Version010404Date20201030180941 extends SimpleMigrationStep {
|
|||||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IOutput $output
|
* @param IOutput $output
|
||||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return null|ISchemaWrapper
|
|
||||||
*/
|
*/
|
||||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||||
/** @var ISchemaWrapper $schema */
|
/** @var ISchemaWrapper $schema */
|
||||||
$schema = $schemaClosure();
|
$schema = $schemaClosure();
|
||||||
|
|
||||||
@ -138,6 +137,6 @@ class Version010404Date20201030180941 extends SimpleMigrationStep {
|
|||||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,104 +10,103 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Service;
|
namespace OCA\Epubreader\Service;
|
||||||
|
|
||||||
|
|
||||||
use OCA\Epubreader\Db\BookmarkMapper;
|
use OCA\Epubreader\Db\BookmarkMapper;
|
||||||
|
use OCA\Epubreader\Db\ReaderEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-import-type SerializedEntity from ReaderEntity
|
||||||
|
*/
|
||||||
class BookmarkService extends Service {
|
class BookmarkService extends Service {
|
||||||
|
|
||||||
// "bookmark" name to use for the cursor (current reading position)
|
// "bookmark" name to use for the cursor (current reading position)
|
||||||
const CURSOR = '__CURSOR__';
|
private const CURSOR = '__CURSOR__';
|
||||||
const bookmark_type = 'bookmark';
|
private const BOOKMARK_TYPE = 'bookmark';
|
||||||
|
|
||||||
private $bookmarkMapper;
|
private BookmarkMapper $bookmarkMapper;
|
||||||
private $userId;
|
|
||||||
|
|
||||||
public function __construct(BookmarkMapper $bookmarkMapper, $UserId) {
|
public function __construct(BookmarkMapper $bookmarkMapper) {
|
||||||
parent::__construct($bookmarkMapper);
|
parent::__construct($bookmarkMapper);
|
||||||
$this->bookmarkMapper = $bookmarkMapper;
|
$this->bookmarkMapper = $bookmarkMapper;
|
||||||
$this->userId = $UserId;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get bookmark
|
* @brief get bookmark
|
||||||
*
|
*
|
||||||
* bookmark type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
* bookmark type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
* @param ?string $type
|
||||||
* @return array
|
*
|
||||||
*/
|
* @psalm-return SerializedEntity[]
|
||||||
public function get($fileId, $name=null, $type=null) {
|
*/
|
||||||
$result = $this->bookmarkMapper->get($fileId, $name, $type);
|
public function get($fileId, ?string $name = null, ?string $type = null): array {
|
||||||
return array_map(
|
$result = $this->bookmarkMapper->get($fileId, $name, $type);
|
||||||
function($entity) {
|
return array_map(
|
||||||
return $entity->toService();
|
function (ReaderEntity $entity): array {
|
||||||
}, $result);
|
return $entity->toService();
|
||||||
}
|
}, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write bookmark
|
* @brief write bookmark
|
||||||
*
|
*
|
||||||
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
* @param ?string $type
|
||||||
* @return array
|
* @param ?string $content
|
||||||
*/
|
*/
|
||||||
public function set($fileId, $name, $value, $type=null, $content=null) {
|
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity {
|
||||||
return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content);
|
return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get cursor (current position in book)
|
* @brief get cursor (current position in book)
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
*
|
*
|
||||||
* @return array
|
* @psalm-return SerializedEntity
|
||||||
*/
|
*/
|
||||||
public function getCursor($fileId) {
|
public function getCursor(int $fileId): array {
|
||||||
$result = $this->get($fileId, static::CURSOR);
|
$result = $this->get($fileId, self::CURSOR);
|
||||||
if (count($result) === 1) {
|
if (count($result) === 1) {
|
||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
}
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set cursor (current position in book)
|
* @brief set cursor (current position in book)
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
*/
|
||||||
* @return array
|
public function setCursor(int $fileId, string $value): ReaderEntity {
|
||||||
*/
|
return $this->bookmarkMapper->set($fileId, self::CURSOR, $value, self::BOOKMARK_TYPE);
|
||||||
public function setCursor($fileId, $value) {
|
}
|
||||||
return $this->bookmarkMapper->set($fileId, static::CURSOR, $value, static::bookmark_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete bookmark
|
* @brief delete bookmark
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
* @param ?string $type
|
||||||
*/
|
*/
|
||||||
public function delete($fileId, $name, $type=null) {
|
public function delete($fileId, ?string $name = null, ?string $type = null): void {
|
||||||
foreach ($this->bookmarkMapper->get($fileId, $name, $type) as $bookmark) {
|
foreach ($this->bookmarkMapper->get($fileId, $name, $type) as $bookmark) {
|
||||||
$this->bookmarkMapper->delete($bookmark);
|
$this->bookmarkMapper->delete($bookmark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete cursor
|
* @brief delete cursor
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
*
|
*/
|
||||||
*/
|
public function deleteCursor(int $fileId): void {
|
||||||
public function deleteCursor($fileId) {
|
$this->delete($fileId, self::CURSOR, self::BOOKMARK_TYPE);
|
||||||
$this->delete($fileId, static::CURSOR, static::bookmark_type);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @author Frank de Lange
|
|
||||||
* @copyright 2017 Frank de Lange
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
* See the COPYING-README file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Epubreader\Service;
|
|
||||||
|
|
||||||
use OCP\App\IAppManager;
|
|
||||||
|
|
||||||
class MetadataService {
|
|
||||||
|
|
||||||
private $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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,107 +11,105 @@
|
|||||||
namespace OCA\Epubreader\Service;
|
namespace OCA\Epubreader\Service;
|
||||||
|
|
||||||
use OCA\Epubreader\Db\PreferenceMapper;
|
use OCA\Epubreader\Db\PreferenceMapper;
|
||||||
|
use OCA\Epubreader\Db\ReaderEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-import-type SerializedEntity from ReaderEntity
|
||||||
|
*/
|
||||||
class PreferenceService extends Service {
|
class PreferenceService extends Service {
|
||||||
|
|
||||||
// (ab)use the fact that $fileId never goes below 1 by using the
|
// (ab)use the fact that $fileId never goes below 1 by using the
|
||||||
// value 0 to indicate a default preference
|
// value 0 to indicate a default preference
|
||||||
const DEFAULTS = 0;
|
private const DEFAULTS = 0;
|
||||||
|
|
||||||
private $preferenceMapper;
|
private PreferenceMapper $preferenceMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PreferenceMapper $preferenceMapper
|
* @param PreferenceMapper $preferenceMapper
|
||||||
*/
|
*/
|
||||||
public function __construct(PreferenceMapper $preferenceMapper) {
|
public function __construct(PreferenceMapper $preferenceMapper) {
|
||||||
parent::__construct($preferenceMapper);
|
parent::__construct($preferenceMapper);
|
||||||
$this->preferenceMapper = $preferenceMapper;
|
$this->preferenceMapper = $preferenceMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get preference
|
* @brief get preference
|
||||||
*
|
*
|
||||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
* 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
|
* preference type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
*
|
||||||
* @return array
|
* @psalm-return SerializedEntity
|
||||||
*/
|
*/
|
||||||
public function get($scope, $fileId, $name=null) {
|
public function get(string $scope, int $fileId, ?string $name = null): array {
|
||||||
$result = $this->preferenceMapper->get($scope, $fileId, $name);
|
$result = $this->preferenceMapper->get($scope, $fileId, $name);
|
||||||
return array_map(
|
return array_map(
|
||||||
function($entity) {
|
function (ReaderEntity $entity): array {
|
||||||
return $entity->toService();
|
return $entity->toService();
|
||||||
}, $result);
|
}, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write preference
|
* @brief write preference
|
||||||
*
|
*
|
||||||
* scope identifies preference source, i.e. which renderer the preference applies to
|
* 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
|
* position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
*/
|
||||||
* @return array
|
public function set(string $scope, int $fileId, string $name, string $value): ReaderEntity {
|
||||||
*/
|
return $this->preferenceMapper->set($scope, $fileId, $name, $value);
|
||||||
public function set($scope, $fileId, $name, $value) {
|
}
|
||||||
return $this->preferenceMapper->set($scope, $fileId, $name, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get default preference
|
* @brief get default preference
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
*/
|
||||||
* @return array
|
public function getDefault(string $scope, ?string $name = null): array {
|
||||||
*/
|
return $this->get($scope, self::DEFAULTS, $name);
|
||||||
public function getDefault($scope, $name=null) {
|
}
|
||||||
return $this->get($scope, static::DEFAULTS, $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set default preference
|
* @brief set default preference
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
*/
|
||||||
* @return array
|
public function setDefault($scope, $name, $value): ReaderEntity {
|
||||||
*/
|
return $this->preferenceMapper->set($scope, self::DEFAULTS, $name, $value);
|
||||||
public function setDefault($scope, $name, $value) {
|
}
|
||||||
return $this->preferenceMapper->set($scope, static::DEFAULTS, $name, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete preference
|
* @brief delete preference
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function delete($scope, $fileId, $name) {
|
public function delete(string $scope, int $fileId, ?string $name = null): void {
|
||||||
foreach($this->preferenceMapper->get($scope, $fileId, $name) as $preference) {
|
foreach($this->preferenceMapper->get($scope, $fileId, $name) as $preference) {
|
||||||
$this->preferenceMapper->delete($preference);
|
$this->preferenceMapper->delete($preference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete default
|
* @brief delete default
|
||||||
*
|
*
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name
|
* @param ?string $name
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function deleteDefault($scope, $name) {
|
public function deleteDefault(string $scope, ?string $name = null): void {
|
||||||
$this->delete($scope, static::DEFAULTS, $name);
|
$this->delete($scope, self::DEFAULTS, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,9 @@ namespace OCA\Epubreader\Service;
|
|||||||
use OCA\Epubreader\Db\ReaderMapper;
|
use OCA\Epubreader\Db\ReaderMapper;
|
||||||
|
|
||||||
abstract class Service {
|
abstract class Service {
|
||||||
|
protected ReaderMapper $mapper;
|
||||||
|
|
||||||
protected $mapper;
|
public function __construct(ReaderMapper $mapper) {
|
||||||
|
$this->mapper = $mapper;
|
||||||
public function __construct(ReaderMapper $mapper){
|
}
|
||||||
$this->mapper = $mapper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,79 +11,73 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Settings;
|
namespace OCA\Epubreader\Settings;
|
||||||
|
|
||||||
|
use OCA\Epubreader\AppInfo\Application;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Settings\ISettings;
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\Settings\ISettings;
|
||||||
|
|
||||||
class Personal implements ISettings
|
class Personal implements ISettings {
|
||||||
{
|
|
||||||
|
|
||||||
private $userId;
|
private string $userId;
|
||||||
private $configManager;
|
private IConfig $configManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$userId,
|
string $userId,
|
||||||
IConfig $configManager
|
IConfig $configManager
|
||||||
)
|
) {
|
||||||
{
|
$this->userId = $userId;
|
||||||
$this->userId = $userId;
|
$this->configManager = $configManager;
|
||||||
$this->configManager = $configManager;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
||||||
* @since 9.1
|
* @since 9.1
|
||||||
*/
|
*/
|
||||||
public function getForm()
|
public function getForm(): TemplateResponse {
|
||||||
{
|
$parameters = [
|
||||||
|
'EpubEnable' => $this->configManager->getUserValue($this->userId, Application::APP_ID, 'epub_enable', 'true'),
|
||||||
|
'PdfEnable' => $this->configManager->getUserValue($this->userId, Application::APP_ID, 'pdf_enable', 'true'),
|
||||||
|
'CbxEnable' => $this->configManager->getUserValue($this->userId, Application::APP_ID, 'cbx_enable', 'true'),
|
||||||
|
];
|
||||||
|
|
||||||
$parameters = [
|
return new TemplateResponse(Application::APP_ID, 'settings-personal', $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, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print config section (ownCloud 10)
|
* Print config section (ownCloud 10)
|
||||||
*
|
*
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse
|
||||||
*/
|
*/
|
||||||
public function getPanel()
|
public function getPanel(): TemplateResponse {
|
||||||
{
|
return $this->getForm();
|
||||||
return $this->getForm();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the section ID, e.g. 'sharing'
|
* @return string the section ID, e.g. 'sharing'
|
||||||
* @since 9.1
|
* @since 9.1
|
||||||
*/
|
*/
|
||||||
public function getSection()
|
public function getSection(): string {
|
||||||
{
|
return Application::APP_ID;
|
||||||
return 'epubreader';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get section ID (ownCloud 10)
|
* Get section ID (ownCloud 10)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSectionID()
|
public function getSectionID(): string {
|
||||||
{
|
return Application::APP_ID;
|
||||||
return 'epubreader';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int whether the form should be rather on the top or bottom of
|
* @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
|
* 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.
|
* priority values. It is required to return a value between 0 and 100.
|
||||||
*
|
*
|
||||||
* E.g.: 70
|
* E.g.: 70
|
||||||
* @since 9.1
|
* @since 9.1
|
||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority(): int {
|
||||||
{
|
return 10;
|
||||||
return 10;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,60 +11,54 @@
|
|||||||
|
|
||||||
namespace OCA\Epubreader\Settings;
|
namespace OCA\Epubreader\Settings;
|
||||||
|
|
||||||
|
use OCA\Epubreader\AppInfo\Application;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\Settings\IIconSection;
|
use OCP\Settings\IIconSection;
|
||||||
|
|
||||||
class PersonalSection implements IIconSection
|
class PersonalSection implements IIconSection {
|
||||||
{
|
|
||||||
/** @var IURLGenerator */
|
|
||||||
private $urlGenerator;
|
|
||||||
/** @var IL10N */
|
|
||||||
private $l;
|
|
||||||
|
|
||||||
public function __construct(IURLGenerator $urlGenerator, IL10N $l)
|
private IURLGenerator $urlGenerator;
|
||||||
{
|
private IL10N $l;
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
$this->l = $l;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
|
||||||
* returns the relative path to an 16*16 icon describing the section.
|
$this->urlGenerator = $urlGenerator;
|
||||||
*
|
$this->l = $l;
|
||||||
* @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 the relative path to an 16*16 icon describing the section.
|
||||||
*
|
*
|
||||||
* @returns string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getID()
|
public function getIcon(): string {
|
||||||
{
|
return $this->urlGenerator->imagePath(Application::APP_ID, 'app.svg');
|
||||||
return 'epubreader';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the translated name as it should be displayed
|
* returns the ID of the section. It is supposed to be a lower case string,
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getID(): string {
|
||||||
{
|
return Application::APP_ID;
|
||||||
return $this->l->t('EPUB/CBZ/PDF ebook reader');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns priority for positioning
|
* returns the translated name as it should be displayed
|
||||||
*
|
*
|
||||||
* @return int
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getName(): string {
|
||||||
{
|
return $this->l->t('EPUB/CBZ/PDF ebook reader');
|
||||||
return 20;
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* returns priority for positioning
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPriority(): int {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,17 +11,16 @@
|
|||||||
namespace OCA\Epubreader\Utility;
|
namespace OCA\Epubreader\Utility;
|
||||||
|
|
||||||
class Time {
|
class Time {
|
||||||
public function getTime() {
|
|
||||||
return time();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public function getTime(): int {
|
||||||
*
|
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 int the current unix time in miliseconds
|
||||||
|
*/
|
||||||
|
public function getMicroTime(): int {
|
||||||
|
list($millisecs, $secs) = explode(' ', microtime());
|
||||||
|
return (int) ($secs . substr($millisecs, 2, 6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ownCloud - Epubreader App
|
|
||||||
*
|
|
||||||
* @author Frank de Lange
|
|
||||||
* @copyright 2014,2018 Frank de Lange
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Epubreader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Config class for Reader
|
|
||||||
*/
|
|
||||||
class Config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @brief get user config value
|
|
||||||
*
|
|
||||||
* @param string $key value to retrieve
|
|
||||||
* @param string $default default value to use
|
|
||||||
* @return string retrieved value or default
|
|
||||||
*/
|
|
||||||
public static function get($key, $default) {
|
|
||||||
return \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'epubreader', $key, $default);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief set user config value
|
|
||||||
*
|
|
||||||
* @param string $key key for value to change
|
|
||||||
* @param string $value value to use
|
|
||||||
* @return bool success
|
|
||||||
*/
|
|
||||||
public static function set($key, $value) {
|
|
||||||
return \OC::$server->getConfig()->setUserValue(\OC_User::getUser(), 'epubreader', $key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief get app config value
|
|
||||||
*
|
|
||||||
* @param string $key value to retrieve
|
|
||||||
* @param string $default default value to use
|
|
||||||
* @return string retrieved value or default
|
|
||||||
*/
|
|
||||||
public static function getApp($key, $default) {
|
|
||||||
return \OC::$server->getConfig()->getAppValue('epubreader', $key, $default);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief set app config value
|
|
||||||
*
|
|
||||||
* @param string $key key for value to change
|
|
||||||
* @param string $value value to use
|
|
||||||
* @return bool success
|
|
||||||
*/
|
|
||||||
public static function setApp($key, $value) {
|
|
||||||
return \OC::$server->getConfig()->setAppValue('epubreader', $key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
36
psalm.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<psalm
|
||||||
|
errorLevel="2"
|
||||||
|
resolveFromConfigFile="true"
|
||||||
|
findUnusedBaselineEntry="true"
|
||||||
|
findUnusedCode="false"
|
||||||
|
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" />
|
||||||
|
<ignoreFiles>
|
||||||
|
<directory name="vendor" />
|
||||||
|
</ignoreFiles>
|
||||||
|
</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>
|
||||||
|
<PropertyNotSetInConstructor errorLevel="suppress" />
|
||||||
|
</issueHandlers>
|
||||||
|
</psalm>
|
@ -73,7 +73,7 @@ CBRJS.Reader = function(bookPath, _options) {
|
|||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
if ((this.status === 200) && this.response) {
|
if ((this.status === 200) && this.response) {
|
||||||
var done = false;
|
var done = false;
|
||||||
var ua = new bitjs.archive[archive_class](this.response, document.head.dataset.staticpath + 'vendor/bitjs/');
|
var ua = new bitjs.archive[archive_class](this.response, document.head.dataset.staticpath + 'public/bitjs/');
|
||||||
|
|
||||||
ua.addEventListener(bitjs.archive.UnarchiveEvent.Type.START, function (e) {
|
ua.addEventListener(bitjs.archive.UnarchiveEvent.Type.START, function (e) {
|
||||||
$progressbar.css('width', '0%');
|
$progressbar.css('width', '0%');
|
||||||
@ -276,7 +276,7 @@ ComicBook = (function ($) {
|
|||||||
70: 'toggleFullscreen', // f
|
70: 'toggleFullscreen', // f
|
||||||
27: 'closeSidebar' // esc
|
27: 'closeSidebar' // esc
|
||||||
},
|
},
|
||||||
vendorPath: document.head.dataset.staticpath + 'vendor/',
|
vendorPath: document.head.dataset.staticpath + 'public/',
|
||||||
forward_buffer: 3,
|
forward_buffer: 3,
|
||||||
session: {
|
session: {
|
||||||
getCursor: function() {},
|
getCursor: function() {},
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 415 B |
Before Width: | Height: | Size: 883 B After Width: | Height: | Size: 883 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |