Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--appinfo/application.php3
-rw-r--r--controller/pagecontroller.php27
-rw-r--r--css/public.css39
-rw-r--r--environment/environment.php14
-rw-r--r--js/gallery.js64
-rw-r--r--js/galleryview.js2
-rw-r--r--templates/public.php33
7 files changed, 167 insertions, 15 deletions
diff --git a/appinfo/application.php b/appinfo/application.php
index 17b9a62b..538890af 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -68,7 +68,8 @@ class Application extends App {
$c->query('Request'),
$c->query('Environment'),
$c->query('OCP\IURLGenerator'),
- $c->query('DownloadService')
+ $c->query('DownloadService'),
+ $c->query('OCP\IConfig')
);
}
);
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php
index d60dce66..a3f3149d 100644
--- a/controller/pagecontroller.php
+++ b/controller/pagecontroller.php
@@ -16,6 +16,7 @@ namespace OCA\GalleryPlus\Controller;
use OCP\IURLGenerator;
use OCP\IRequest;
+use OCP\IConfig;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
@@ -47,6 +48,10 @@ class PageController extends Controller {
* @var DownloadService
*/
private $downloadService;
+ /**
+ * @var IConfig
+ */
+ private $appConfig;
/**
* Constructor
@@ -56,19 +61,22 @@ class PageController extends Controller {
* @param Environment $environment
* @param IURLGenerator $urlGenerator
* @param DownloadService $downloadService
+ * @param IConfig $appConfig
*/
public function __construct(
$appName,
IRequest $request,
Environment $environment,
IURLGenerator $urlGenerator,
- DownloadService $downloadService
+ DownloadService $downloadService,
+ IConfig $appConfig
) {
parent::__construct($appName, $request);
$this->environment = $environment;
$this->urlGenerator = $urlGenerator;
$this->downloadService = $downloadService;
+ $this->appConfig = $appConfig;
}
/**
@@ -122,13 +130,22 @@ class PageController extends Controller {
$appName = $this->appName;
$displayName = $this->environment->getDisplayName();
$albumName = $this->environment->getSharedFolderName();
+ $server2ServerSharing = $this->appConfig->getAppValue(
+ 'files_sharing', 'outgoing_server2server_share_enabled', 'yes'
+ );
+ $server2ServerSharing = ($server2ServerSharing === 'yes') ? true : false;
+ $protected = $this->environment->isShareProtected();
+ $protected = ($protected) ? 'true' : 'false';
// Parameters sent to the template
$params = [
- 'appName' => $appName,
- 'token' => $token,
- 'displayName' => $displayName,
- 'albumName' => $albumName
+ 'appName' => $appName,
+ 'token' => $token,
+ 'displayName' => $displayName,
+ 'albumName' => $albumName,
+ 'server2ServerSharing' => $server2ServerSharing,
+ 'protected' => $protected,
+ 'filename' => $albumName
];
// Will render the page using the template found in templates/public.php
diff --git a/css/public.css b/css/public.css
index 149841cd..62913cc0 100644
--- a/css/public.css
+++ b/css/public.css
@@ -13,3 +13,42 @@ body {
height: 100%;
width: 100%;
}
+
+/* within #save */
+#save .save-form {
+ position: relative;
+}
+
+#remote_address {
+ margin: 0;
+ width: 130px;
+ height: 14px;
+ padding: 6px;
+ padding-right: 24px;
+}
+
+#save #save-button,
+#save #save-button-confirm {
+ margin: 0 5px;
+ height: 28px;
+ padding-bottom: 4px;
+ line-height: 14px;
+}
+
+#save-button-confirm {
+ position: absolute;
+ background-color: transparent;
+ border: none;
+ margin: 2px 4px !important;
+ right: 0;
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
+ filter: alpha(opacity=50);
+ opacity: .5;
+}
+
+#save-button-confirm:hover,
+#save-button-confirm:focus {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+ filter: alpha(opacity=100);
+ opacity: 1;
+} \ No newline at end of file
diff --git a/environment/environment.php b/environment/environment.php
index a5e3a8ff..d116b60a 100644
--- a/environment/environment.php
+++ b/environment/environment.php
@@ -79,6 +79,10 @@ class Environment {
* @var string
*/
private $folderName;
+ /**
+ * @var string
+ */
+ private $shareWith;
/***
* Constructor
@@ -123,6 +127,7 @@ class Environment {
$this->folderName = $linkItem['file_target'];
$this->userId = $rootLinkItem['uid_owner'];
+ $this->shareWith = $linkItem['share_with'];
}
/**
@@ -237,6 +242,15 @@ class Environment {
}
/**
+ * Returns if the share is protected (share_with === true)
+ *
+ * @return string
+ */
+ public function isShareProtected() {
+ return $this->shareWith;
+ }
+
+ /**
* Returns the path which goes from the file, up to the user folder, based on a node:
* parent_folder/current_folder/my_file
*
diff --git a/js/gallery.js b/js/gallery.js
index cfb11063..fb4079ed 100644
--- a/js/gallery.js
+++ b/js/gallery.js
@@ -241,6 +241,70 @@ Gallery.showInfo = function (event) {
};
/**
+ * Lets the user add the shared files to his ownCloud
+ *
+ * @param event
+ */
+Gallery.showSaveForm = function (event) {
+ $(this).hide();
+ $('.save-form').css('display', 'inline');
+ $('#remote_address').focus();
+};
+
+/**
+ * Sends the shared files to the viewer's ownCloud
+ *
+ * @param event
+ */
+Gallery.saveForm = function (event) {
+ event.preventDefault();
+
+ var saveElement = $('#save');
+ var remote = $(this).find('input[type="text"]').val();
+ var owner = saveElement.data('owner');
+ var name = saveElement.data('name');
+ var isProtected = saveElement.data('protected');
+ Gallery.saveToOwnCloud(remote, Gallery.token, owner, name, isProtected);
+};
+
+/**
+ * Saves the folder to a remote ownCloud installation
+ *
+ * Our location is the remote for the other server
+ *
+ * @param {string} remote
+ * @param {string}token
+ * @param {string}owner
+ * @param {string}name
+ * @param {bool} isProtected
+ */
+Gallery.saveToOwnCloud = function (remote, token, owner, name, isProtected) {
+ var location = window.location.protocol + '//' + window.location.host + OC.webroot;
+ var isProtectedInt = (isProtected) ? 1 : 0;
+ var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location)
+ + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) + "&name=" +
+ encodeURIComponent(name) + "&protected=" + isProtectedInt;
+
+ if (remote.indexOf('://') > 0) {
+ OC.redirect(url);
+ } else {
+ // if no protocol is specified, we automatically detect it by testing https and http
+ // this check needs to happen on the server due to the Content Security Policy directive
+ $.get(OC.generateUrl('apps/files_sharing/testremote'),
+ {remote: remote}).then(function (protocol) {
+ if (protocol !== 'http' && protocol !== 'https') {
+ OC.dialogs.alert(t('files_sharing',
+ 'No ownCloud installation (7 or higher) found at {remote}',
+ {remote: remote}),
+ t('files_sharing', 'Invalid ownCloud url'));
+ } else {
+ OC.redirect(protocol + '://' + url);
+ }
+ });
+ }
+};
+
+/**
* Hide the search button while we wait for core to fix the templates
*/
Gallery.hideSearch = function () {
diff --git a/js/galleryview.js b/js/galleryview.js
index 14ce832b..ca6f9d42 100644
--- a/js/galleryview.js
+++ b/js/galleryview.js
@@ -42,6 +42,8 @@
$('#album-info-button').click(Gallery.showInfo);
$('#sort-name-button').click(Gallery.sorter);
$('#sort-date-button').click(Gallery.sorter);
+ $('#save #save-button').click(Gallery.showSaveForm);
+ $('.save-form').submit(Gallery.saveForm);
}
this.viewAlbum(albumPath);
}
diff --git a/templates/public.php b/templates/public.php
index 32f59c5f..b3d7516f 100644
--- a/templates/public.php
+++ b/templates/public.php
@@ -53,22 +53,37 @@ style(
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<div class="header-right">
<span id="details">
- <span id="displayName">
- <?php p($l->t('shared by %s', $_['displayName'])); ?>
- </span>
- <a id="download" class="button">
- <img class="svg" src="<?php print_unescaped(
- image_path($_['appName'], "download.svg")
- ); ?>" alt=""/>
+ <?php
+ if ($_['server2ServerSharing']) {
+ ?>
+ <span id="save" data-protected="<?php p($_['protected']) ?>"
+ data-owner="<?php p($_['displayName']) ?>"
+ data-name="<?php p($_['filename']) ?>">
+ <button id="save-button"><?php p(
+ $l->t('Add to your ownCloud')
+ ) ?></button>
+ <form class="save-form hidden" action="#">
+ <input type="text" id="remote_address"
+ placeholder="example.com/owncloud"/>
+ <button id="save-button-confirm"
+ class="icon-confirm svg"></button>
+ </form>
+ </span>
+ <?php } ?>
+ <a id="download" class="button">
+ <img class="svg" src="<?php print_unescaped(
+ image_path($_['appName'], "download.svg")
+ ); ?>" alt=""/>
<span id="download-text"><?php p($l->t('Download')) ?>
</span>
- </a>
+ </a>
</span>
</div>
</div>
</header>
<div class="content-wrapper">
- <div id="content" class="app-<?php p($_['appName']) ?>" data-albumname="<?php p($_['albumName']) ?>">
+ <div id="content" class="app-<?php p($_['appName']) ?>"
+ data-albumname="<?php p($_['albumName']) ?>">
<div id="app">
<div id="controls">
<div id="breadcrumbs"></div>