1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-02 14:49:17 +02:00

fix-appinfo

This commit is contained in:
noci2012 2019-11-24 16:39:56 +01:00
commit 2c9ebed8b9
14 changed files with 96 additions and 71 deletions

View file

@ -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,11 +53,10 @@ 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.'))
)
);
exit();

View file

@ -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"))));

View file

@ -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,25 +21,27 @@ $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());
$opdsoldMime = isset($_POST['opdsoldMime']) ? $_POST['opdsoldMime'] : '';
if (!strlen($rootPath) ||
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
\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!'))
)
);
} else {
Config::set('root_path', $rootPath);
Config::set('enable', $opdsEnable);
Config::set('file_types', $fileTypes);
Config::set('skip_list', $skipList);
Config::set('feed_title', $feedTitle);
Config::set('enable', $opdsEnable);
Config::set('file_types', $fileTypes);
Config::set('skip_list', $skipList);
Config::set('feed_title', $feedTitle);
Config::set('old_mime', $opdsoldMime);
Config::set('id', Util::genUuid());
\OCP\JSON::success(
\OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
@ -47,4 +49,3 @@ if (!strlen($rootPath) ||
}
exit();

View file

@ -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"))));

View file

@ -39,8 +39,10 @@ $(document).ready(function(){
var opdsSettings = {
save : function() {
var opdsEnable = document.getElementById('opds-enable').checked ? 'true' : 'false';
var opdsoldMime = document.getElementById('opds-oldmime').checked ? 'true' : 'false';
var data = {
opdsEnable : opdsEnable,
opdsoldMime : opdsoldMime,
rootPath : $('#opds-root-path').val(),
fileTypes : $('#opds-file-types').val(),
skipList : $('#opds-skip-list').val(),
@ -61,5 +63,6 @@ $(document).ready(function(){
}
});
$('#opds-enable').on("change", opdsSettings.save);
$('#opds-oldmime').on("change", opdsSettings.save);
});

View file

@ -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::$server->getUserSession()->getUser()->getUID(), '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::$server->getUserSession()->getUser()->getUID(), '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,17 +58,17 @@ 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);
}
/**
* @brief get preview status
*
*
* @param string format
* @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,7 +103,7 @@ class Config
}
}
if (!(\OCP\Config::setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
if (!(\OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
return true;
}

View file

@ -24,7 +24,7 @@ class Feed
* @return string feed id
*/
public static function getFeedId() {
return Config::get('id', '');
return Config::get('id', '');
}
/**
@ -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();

View file

@ -64,7 +64,7 @@ class Meta
protected static function load($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;
@ -79,7 +79,7 @@ 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();
if (isset($data['id'])) {
@ -118,7 +118,7 @@ class Meta
$meta['rescan']
);
}
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);
return $query->execute($args);
}
@ -150,7 +150,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 +162,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);
}

View file

@ -113,7 +113,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'.

View file

@ -18,14 +18,17 @@ $l = \OC::$server->getL10N('files_opds');
$tmpl = new \OCP\Template('files_opds', 'personal');
$opdsEnable = Config::get('enable', false);
$opdsoldMime = Config::get('old_mime', false);
$tmpl->assign('opdsEnable-checked', ($opdsEnable === 'true') ? 'checked="checked"' : '');
$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/');
$tmpl->assign('opdsoldMime-checked', ($opdsoldMime === 'true') ? 'checked="checked"' : '');
$tmpl->assign('opdsoldMime-value', ($opdsoldMime === 'true') ? '1' : '0');
return $tmpl->fetchPage();

View file

@ -48,7 +48,9 @@ switch ($_['type']) {
case 'bookshelf':
foreach ($_['bookshelf'] as $file) {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
foreach( $file as $key => $value )
$newfile["file_".$key] = $value;
print_unescaped($this->inc('part.feed.acquisition', $newfile ));
}
break;
@ -60,10 +62,13 @@ switch ($_['type']) {
case 'directory':
default:
foreach ($_['files'] as $file) {
foreach( $file as $key => $value )
$newfile["file_".$key] = $value;
if ($file['type'] == 'dir') {
print_unescaped($this->inc('part.feed.navigation', [ 'file' => $file ]));
print_unescaped($this->inc('part.feed.navigation', $newfile ));
} else {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
print_unescaped($this->inc('part.feed.acquisition', $newfile ));
}
}
break;

View file

@ -1,38 +1,47 @@
<entry>
<title><?php p($_['file']['meta']['title']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file']['meta']['updated']))); ?></updated>
<id>id:<?php p($_['file']['id']); ?></id>
<dcterms:extent><?php p($_['file']['humansize']); ?></dcterms:extent>
<?php $authors = json_decode($_['file']['meta']['author'],true); if(is_array($authors)): foreach ($authors as $author): ?>
<?php
namespace OCA\Files_Opds;
if ( Config::get('old_mime', 'false') !== 'false' && strpos($_['file_mimetype'],'comicbook') !== false){
$mime = 'application/x-cbr';
} else {
$mime = $_['file_mimetype'];
}
?>
<entry>
<title><?php p($_['file_meta']['title']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file_meta']['updated']))); ?></updated>
<id>id:<?php p($_['file_id']); ?></id>
<dcterms:extent><?php p($_['file_humansize']); ?></dcterms:extent>
<?php $authors = json_decode($_['file_meta']['author'],true); if(is_array($authors)): foreach ($authors as $author): ?>
<author>
<name><?php p($author); ?></name>
</author>
<?php endforeach; endif; ?>
<?php if($_['file']['meta']['isbn']): ?>
<dc:identifier>urn:isbn:<?php p($_['file']['meta']['isbn']); ?></dc:identifier>
<?php if($_['file_meta']['isbn']): ?>
<dc:identifier>urn:isbn:<?php p($_['file_meta']['isbn']); ?></dc:identifier>
<?php endif; ?>
<?php if($_['file']['meta']['publisher']): ?>
<dc:publisher><?php p($_['file']['meta']['publisher']); ?></dc:publisher>
<?php if($_['file_meta']['publisher']): ?>
<dc:publisher><?php p($_['file_meta']['publisher']); ?></dc:publisher>
<?php endif; ?>
<?php if($_['file']['meta']['language']): ?>
<dc:language><?php p($_['file']['meta']['language']); ?></dc:language>
<?php if($_['file_meta']['language']): ?>
<dc:language><?php p($_['file_meta']['language']); ?></dc:language>
<?php endif; ?>
<dc:issued><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file']['meta']['date']))); ?></dc:issued>
<link type="<?php p($_['file']['mimetype']); ?>"
<dc:issued><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file_meta']['date']))); ?></dc:issued>
<link type="<?php p($mime); ?>"
rel="alternate"
href="?id=<?php p($_['file']['id']); ?>"/>
<link type="<?php p($_['file']['mimetype']); ?>"
href="?id=<?php p($_['file_id']); ?>"/>
<link type="<?php p($mime); ?>"
rel="http://opds-spec.org/acquisition/open-access"
href="?id=<?php p($_['file']['id']); ?>"/>
<link href="?pid=<?php p($_['file']['id']); ?>"
href="?id=<?php p($_['file_id']); ?>"/>
<link href="?pid=<?php p($_['file_id']); ?>"
rel="http://opds-spec.org/image"
type="image/jpeg" />
<link href="?tid=<?php p($_['file']['id']); ?>"
<link href="?tid=<?php p($_['file_id']); ?>"
rel="http://opds-spec.org/image/thumbnail"
type="image/jpeg" />
<?php if ($_['file']['meta']['description']): ?>
<content type="text"><?php p($_['file']['meta']['description']); p("\n\n"); ?><?php p(formatMetadata($_['file']['humansize'],$_['file']['mimetype'],$_['file']['name'])); ?></content>
<?php if ($_['file_meta']['description']): ?>
<content type="text"><?php p($_['file_meta']['description']); p("\n\n"); ?><?php p(formatMetadata($_['file_humansize'],$mime,$_['file_name'])); ?></content>
<?php else: ?>
<summary type="text"><?php p(formatMetadata($_['file']['humansize'],$_['file']['mimetype'],$_['file']['name'])); ?></summary>
<summary type="text"><?php p(formatMetadata($_['file_humansize'],$mime,$_['file_name'])); ?></summary>
<?php endif; ?>
</entry>

View file

@ -1,12 +1,12 @@
<entry>
<title><?php p($_['file']['name']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP", $_['file']['mtime'])); ?></updated>
<id>id:<?php p($_['file']['id']); ?></id>
<title><?php p($_['file_name']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP", $_['file_mtime'])); ?></updated>
<id>id:<?php p($_['file_id']); ?></id>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation"
rel="alternate"
href="?id=<?php p($_['file']['id']); ?>"/>
href="?id=<?php p($_['file_id']); ?>"/>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation"
rel="subsection"
href="?id=<?php p($_['file']['id']); ?>"/>
href="?id=<?php p($_['file_id']); ?>"/>
<content type="text"></content>
</entry>

View file

@ -23,7 +23,8 @@ style('files_opds', 'settings');
</table>
<div>
<input id="opds-enable" name="opds-enable" value="<?php p($_['opdsEnable-value']) ?>" <?php p($_['opdsEnable-checked']) ?> type="checkbox" class="checkbox">
<label for="opds-enable"><?php p($l->t('enable OPDS catalog')) ?></label>
<label for="opds-enable"><?php p($l->t('enable OPDS catalog')) ?></label>
</div>
<br>
<table>
@ -43,6 +44,10 @@ style('files_opds', 'settings');
<td><label for="opds-skip-list"><?php p($l->t('Skip these filenames:')) ?></label></td>
<td><input type="text" id="opds-skip-list" title="<?php p($l->t("Enter list of comma-separated file names which should be skipped. Leave blank to use the default skip list.")); ?>" value="<?php p($_['skipList']) ?>" /></td>
</tr>
<tr>
<td><label for="opds-oldmime"><?php p($l->t('Use alternative Mimetypes for Comicbook:')) ?></label></td>
<td><input id="opds-oldmime" name="opds-oldmime" value="<?php p($_['opdsoldMime-value']) ?>" <?php p($_['opdsoldMime-checked']) ?> type="checkbox" title="For example use application/x-cbr instead of application/comicbook+rar"/></td>
</tr>
</table>
<br>
<div>