diff --git a/files_opds/ajax/admin.php b/files_opds/ajax/admin.php
index 75f99d7..f1ab21a 100644
--- a/files_opds/ajax/admin.php
+++ b/files_opds/ajax/admin.php
@@ -12,8 +12,8 @@
namespace OCA\Files_Opds;
-\OCP\JSON::callCheck();
-\OCP\JSON::checkLoggedIn();
+\OC_JSON::callCheck();
+\OC_JSON::checkLoggedIn();
$defaults = new \OC_Defaults();
$l = \OC::$server->getL10N('files_opds');
@@ -53,7 +53,7 @@ if (isset($_POST['opdsCoverX'])) {
Config::setPreview('OC\Preview\MSOffice2007',$opdsPreviewMsOffice);
}
-\OCP\JSON::success(
+\OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
diff --git a/files_opds/ajax/clear_bookshelf.php b/files_opds/ajax/clear_bookshelf.php
index 0ba1604..727a76a 100644
--- a/files_opds/ajax/clear_bookshelf.php
+++ b/files_opds/ajax/clear_bookshelf.php
@@ -14,8 +14,8 @@ namespace OCA\Files_Opds;
$l = \OC::$server->getL10N('files_opds');
-\OCP\JSON::checkLoggedIn();
-\OCP\JSON::callCheck();
+\OC_JSON::checkLoggedIn();
+\OC_JSON::callCheck();
Bookshelf::clear();
-\OCP\JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared"))));
+\OC_JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared"))));
diff --git a/files_opds/ajax/personal.php b/files_opds/ajax/personal.php
index 2d019b8..eda2c47 100644
--- a/files_opds/ajax/personal.php
+++ b/files_opds/ajax/personal.php
@@ -12,8 +12,8 @@
namespace OCA\Files_Opds;
-\OCP\JSON::callCheck();
-\OCP\JSON::checkLoggedIn();
+\OC_JSON::callCheck();
+\OC_JSON::checkLoggedIn();
$l = \OC::$server->getL10N('files_opds');
@@ -21,12 +21,12 @@ $opdsEnable = isset($_POST['opdsEnable']) ? $_POST['opdsEnable'] : 'false';
$rootPath = isset($_POST['rootPath']) ? $_POST['rootPath'] : '/Library';
$fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
-$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
+$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OC_User::getDisplayName());
if (!strlen($rootPath) ||
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
\OC\Files\Filesystem::file_exists($rootPath) === false ) {
- \OCP\JSON::error(
+ \OC_JSON::error(
array(
'data' => array('message'=> $l->t('Directory does not exist!'))
)
@@ -39,7 +39,7 @@ if (!strlen($rootPath) ||
Config::set('feed_title', $feedTitle);
Config::set('id', Util::genUuid());
- \OCP\JSON::success(
+ \OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
diff --git a/files_opds/ajax/schedule_rescan.php b/files_opds/ajax/schedule_rescan.php
index 0f266c3..5d91c3e 100644
--- a/files_opds/ajax/schedule_rescan.php
+++ b/files_opds/ajax/schedule_rescan.php
@@ -14,8 +14,8 @@ namespace OCA\Files_Opds;
$l = \OC::$server->getL10N('files_opds');
-\OCP\JSON::checkLoggedIn();
-\OCP\JSON::callCheck();
+\OC_JSON::checkLoggedIn();
+\OC_JSON::callCheck();
Meta::rescan();
-\OCP\JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled"))));
+\OC_JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled"))));
diff --git a/files_opds/appinfo/info.xml b/files_opds/appinfo/info.xml
index 699df24..5bbcc92 100644
--- a/files_opds/appinfo/info.xml
+++ b/files_opds/appinfo/info.xml
@@ -37,10 +37,13 @@ See [README] for more information on (mis)features of this app.
sqlite
mysql
-
+
- OCA\Files_Opds\Settings\Admin
+ OCA\Files_Opds\Settings\Admin
+ OCA\Files_Opds\Settings\AdminSection
+ OCA\Files_Opds\Settings\Personal
+ OCA\Files_Opds\Settings\PersonalSection
168132
diff --git a/files_opds/lib/Settings/PersonalSection.php b/files_opds/lib/Settings/PersonalSection.php
new file mode 100644
index 0000000..878a6ed
--- /dev/null
+++ b/files_opds/lib/Settings/PersonalSection.php
@@ -0,0 +1,89 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\File_Opds\Settings;
+
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\Settings\IIconSection;
+
+class PersonalSection implements IIconSection {
+
+ /** @var IL10N */
+ private $l;
+
+ /** @var IURLGenerator */
+ private $url;
+
+ /**
+ * @param IURLGenerator $url
+ * @param IL10N $l
+ */
+ public function __construct(IURLGenerator $url, IL10N $l) {
+ $this->url = $url;
+ $this->l = $l;
+ }
+
+ /**
+ * returns the relative path to an 16*16 icon describing the section.
+ * e.g. '/core/img/places/files.svg'
+ *
+ * @returns string
+ * @since 16.0
+ */
+ public function getIcon() {
+ return $this->url->imagePath('files_opds', 'files_opds-dark.svg');
+ }
+
+ /**
+ * returns the ID of the section. It is supposed to be a lower case string,
+ * e.g. 'ldap'
+ *
+ * @returns string
+ * @since 16.0
+ */
+ public function getID() {
+ return 'files_opds';
+ }
+
+ /**
+ * returns the translated name as it should be displayed, e.g. 'LDAP / AD
+ * integration'. Use the L10N service to translate it.
+ *
+ * @return string
+ * @since 16.0
+ */
+ public function getName() {
+ return $this->l->t('OPDS Library');
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the settings navigation. The sections are arranged in ascending order of
+ * the priority values. It is required to return a value between 0 and 99.
+ *
+ * E.g.: 70
+ * @since 16.0
+ */
+ public function getPriority() {
+ return 10;
+ }
+}
diff --git a/files_opds/lib/config.php b/files_opds/lib/config.php
index 6e84a54..708567f 100644
--- a/files_opds/lib/config.php
+++ b/files_opds/lib/config.php
@@ -25,7 +25,7 @@ class Config
* @return string retrieved value or default
*/
public static function get($key, $default) {
- return \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_opds', $key, $default);
+ return \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'files_opds', $key, $default);
}
/**
@@ -36,7 +36,7 @@ class Config
* @return bool success
*/
public static function set($key, $value) {
- return \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_opds', $key, $value);
+ return \OC::$server->getConfig()->setUserValue(\OC_User::getUser(), 'files_opds', $key, $value);
}
/**
@@ -47,7 +47,7 @@ class Config
* @return string retrieved value or default
*/
public static function getApp($key, $default) {
- return \OCP\Config::getAppValue('files_opds', $key, $default);
+ return \OC::$server->getConfig()->getAppValue('files_opds', $key, $default);
}
/**
@@ -58,7 +58,7 @@ class Config
* @return bool success
*/
public static function setApp($key, $value) {
- return \OCP\Config::setAppValue('files_opds', $key, $value);
+ return \OC::$server->getConfig()->setAppValue('files_opds', $key, $value);
}
/**
@@ -68,7 +68,7 @@ class Config
* @return bool (true = enabled, false = disabled)
*/
public static function getPreview($format) {
- $enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null);
+ $enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if (!($enablePreviewProviders === null)) {
return in_array($format, $enablePreviewProviders);
}
@@ -83,7 +83,7 @@ class Config
* @return bool
*/
public static function setPreview($format, $enable = 'false') {
- $enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null);
+ $enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if ($enable == 'true') {
if ($enablePreviewProviders === null) {
// set up default providers
@@ -103,8 +103,8 @@ class Config
}
}
- if (!(\OCP\Config::setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
- logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
+ if (!(\OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
+ Util::logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
return true;
}
}
diff --git a/files_opds/lib/feed.php b/files_opds/lib/feed.php
index 493764c..77a866b 100644
--- a/files_opds/lib/feed.php
+++ b/files_opds/lib/feed.php
@@ -34,7 +34,7 @@ class Feed
* @param int $id file id
*/
public static function serveFile($path, $id) {
- \OCP\User::checkLoggedIn();
+ \OC_JSON::checkLoggedIn();
\OC::$server->getSession()->close();
Bookshelf::add($id);
$dirName = dirname($path);
@@ -66,8 +66,8 @@ class Feed
$tmpl->assign('id', $id);
$tmpl->assign('type', $type);
$tmpl->assign('dir', $dir);
- $tmpl->assign('user', \OCP\User::getDisplayName());
- $tmpl->assign('feed_title', Config::get('feed_title',\OCP\User::getDisplayName() . "'s Library"));
+ $tmpl->assign('user', \OC_User::getDisplayName());
+ $tmpl->assign('feed_title', Config::get('feed_title',\OC_User::getDisplayName() . "'s Library"));
$tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
$tmpl->assign('feed_updated', time());
$tmpl->printPage();
@@ -82,7 +82,7 @@ class Feed
* @param string type type of preview requested
*/
public static function servePreview($path, $type) {
- \OCP\User::checkLoggedIn();
+ \OC_Join::checkLoggedIn();
\OC::$server->getSession()->close();
$i = \OC\Files\Filesystem::getFileInfo($path,false);
diff --git a/files_opds/lib/meta.php b/files_opds/lib/meta.php
index a3c12cb..e868b15 100644
--- a/files_opds/lib/meta.php
+++ b/files_opds/lib/meta.php
@@ -11,6 +11,7 @@
*/
namespace OCA\Files_Opds;
+use OCP\ILogger;
/**
* Meta (data) class for OPDS
@@ -61,13 +62,13 @@ class Meta
*
* @return array or false
*/
- protected static function load($id) {
+ protected static function xload($id) {
$sql = 'SELECT * FROM `*PREFIX*opds_metadata` WHERE id = ?';
$args = array($id);
- $query = \OCP\DB::prepare($sql);
+ $query = \OC_DB::prepare($sql);
$result = $query->execute($args);
- return ($row = $result->fetchRow()) ? $row : false;
+ return ($row = $result->fetch()) ? $row : false;
}
/**
@@ -79,9 +80,9 @@ class Meta
protected static function save($meta) {
$sql = "SELECT `id` FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($meta['id']);
- $query = \OCP\DB::prepare($sql);
+ $query = \OC_DB::prepare($sql);
$result = $query->execute($args);
- $data = $result->fetchRow();
+ $data = $result->fetch();
if (isset($data['id'])) {
$sql = "UPDATE *PREFIX*opds_metadata SET `updated`=?, `date`=?, `author`=?, `title`=?, `language`=?, `publisher`=?, `isbn`=?, `copyright`=?, `description`=?, `subjects`=?, `cover`=?, `rescan`=? WHERE id=?";
$args = array(
@@ -99,7 +100,6 @@ class Meta
$meta['rescan'],
$meta['id']
);
-
} else {
$sql = "INSERT INTO *PREFIX*opds_metadata (`id`, `updated`, `date`, `author`, `title`, `language`, `publisher`, `isbn`, `copyright`, `description`, `subjects`, `cover`, `rescan`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
$args = array(
@@ -117,8 +117,9 @@ class Meta
$meta['cover'],
$meta['rescan']
);
+
}
- $query = \OCP\DB::prepare($sql);
+ $query = \OC_DB::prepare($sql);
return $query->execute($args);
}
@@ -132,7 +133,7 @@ class Meta
* @return array of metadata
*/
public static function get($id) {
- if (!($meta = self::load($id)) || (isset($meta['rescan']) && time() > strtotime($meta['rescan']))) {
+ if (!($meta = self::xload($id)) || (isset($meta['rescan']) && time() > strtotime($meta['rescan']))) {
if(isset($meta['rescan'])) {
$meta['rescan'] = null;
}
@@ -150,7 +151,7 @@ class Meta
public static function remove($id) {
$sql = "DELETE FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($id);
- $query = \OCP\DB::prepare($sql);
+ $query = \OC_DB::prepare($sql);
return $query->execute($args);
}
@@ -162,7 +163,7 @@ class Meta
public static function rescan() {
$sql = "UPDATE *PREFIX*opds_metadata SET `rescan`=?";
$args = array(date("Y-m-d H:i:s"));
- $query = \OCP\DB::prepare($sql);
+ $query = \OC_DB::prepare($sql);
$result = $query->execute($args);
}
@@ -229,7 +230,7 @@ class Meta
$meta['subjects'] = json_encode($epub->Subjects());
}
} catch (\Exception $e) {
- \OCP\Util::writeLog(get_class(), $e->getMessage(), \OCP\Util::ERROR);
+ \OCP\Util::writeLog(get_class(), $e->getMessage(), ILogger::ERROR);
}
}
@@ -257,7 +258,7 @@ class Meta
$meta['subjects'] = json_encode($fb2->Subjects());
}
} catch (\Exception $e) {
- \OCP\Util::writeLog(get_class(), $e->getMessage(), \OCP\Util::ERROR);
+ \OCP\Util::writeLog(get_class(), $e->getMessage(), ILogger::ERROR);
}
}
diff --git a/files_opds/lib/util.php b/files_opds/lib/util.php
index b33cafe..0951839 100644
--- a/files_opds/lib/util.php
+++ b/files_opds/lib/util.php
@@ -14,6 +14,7 @@ namespace OCA\Files_Opds;
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
use OC\User\LoginException;
+use OCP\ILogger;
/**
* Utility class for OPDS
@@ -113,7 +114,7 @@ class Util
*/
public static function genUuid() {
$defaults = new \OC_Defaults();
- $hash = md5(\OCP\User::getDisplayName() . $defaults->getBaseUrl());
+ $hash = md5(\OC_User::getDisplayName() . $defaults->getBaseUrl());
$hash = substr($hash, 0, 8 ) .'-'.
substr($hash, 8, 4) .'-3'.
substr($hash, 13, 3) .'-9'.
@@ -127,6 +128,6 @@ class Util
* @param string message to write to log
*/
public static function logWarn($msg) {
- \OCP\Util::writeLog('files_opds', $msg, \OCP\Util::WARN);
+ \OCP\Util::writeLog('files_opds', $msg, ILogger::WARN);
}
}
diff --git a/files_opds/personal.php b/files_opds/personal.php
index 5fac311..4a482af 100644
--- a/files_opds/personal.php
+++ b/files_opds/personal.php
@@ -14,7 +14,7 @@ use OCP\Util;
$l = \OC::$server->getL10N('files_opds');
-#\OCP\Util::addScript('files_opds', 'personal');
+\OCP\Util::addScript('files_opds', 'personal');
$tmpl = new \OCP\Template('files_opds', 'personal');
$opdsEnable = Config::get('enable', false);
@@ -23,7 +23,7 @@ $tmpl->assign('opdsEnable-value', ($opdsEnable === 'true') ? '1' : '0');
$tmpl->assign('rootPath', Config::get('root_path', '/Library'));
$tmpl->assign('fileTypes', Config::get('file_types', ''));
$tmpl->assign('skipList', Config::get('skip_list', 'metadata.opf,cover.jpg'));
-$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OCP\User::getDisplayName())));
+$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OC_User::getDisplayName())));
$tmpl->assign('bookshelf-count', Bookshelf::count());
$tmpl->assign('feedUrl', Util::linkToAbsolute('','index.php') . '/apps/files_opds/');
diff --git a/files_opds/templates/feed.php b/files_opds/templates/feed.php
index 1704d39..6487677 100644
--- a/files_opds/templates/feed.php
+++ b/files_opds/templates/feed.php
@@ -48,7 +48,7 @@ switch ($_['type']) {
case 'bookshelf':
foreach ($_['bookshelf'] as $file) {
- print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
+ print_unescaped($this->inc('part.feed.acquisition', [ 'xfile' => $file ]));
}
break;
@@ -61,9 +61,9 @@ switch ($_['type']) {
default:
foreach ($_['files'] as $file) {
if ($file['type'] == 'dir') {
- print_unescaped($this->inc('part.feed.navigation', [ 'file' => $file ]));
+ print_unescaped($this->inc('part.feed.navigation', [ 'xfile' => $file ]));
} else {
- print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
+ print_unescaped($this->inc('part.feed.acquisition', [ 'xfile' => $file ]));
}
}
break;
diff --git a/files_opds/templates/part.feed.acquisition.php b/files_opds/templates/part.feed.acquisition.php
index ab7aae0..ffb5d75 100644
--- a/files_opds/templates/part.feed.acquisition.php
+++ b/files_opds/templates/part.feed.acquisition.php
@@ -1,38 +1,38 @@
-
+
- id:
-
-
+ id:
+
+
-
- urn:isbn:
+
+ urn:isbn:
-
-
+
+
-
-
+
+
-
-
+
-
+
-
+
-
-
-
+
+
-
+
diff --git a/files_opds/templates/part.feed.navigation.php b/files_opds/templates/part.feed.navigation.php
index 70568b2..38e1d04 100644
--- a/files_opds/templates/part.feed.navigation.php
+++ b/files_opds/templates/part.feed.navigation.php
@@ -1,12 +1,12 @@
-
+
- id:
+ id:
+ href="?id="/>
+ href="?id="/>