]> git.mxchange.org Git - friendica.git/commitdiff
Move mod/fbrowser to src\Modules\Attachment|Photos\Browser
authorPhilipp <admin@philipp.info>
Fri, 25 Nov 2022 22:43:07 +0000 (23:43 +0100)
committerPhilipp <admin@philipp.info>
Sat, 26 Nov 2022 21:26:30 +0000 (22:26 +0100)
26 files changed:
src/App/Arguments.php
src/App/Page.php
src/App/Router.php
src/Model/Photo.php
src/Module/Attach.php
src/Module/Profile/Attachment/Browser.php [new file with mode: 0644]
src/Module/Profile/Photos/Browser.php [new file with mode: 0644]
static/routes.config.php
view/global.css
view/js/filebrowser.js
view/js/main.js
view/templates/filebrowser.tpl [deleted file]
view/templates/jot-header.tpl
view/templates/profile/filebrowser.tpl [new file with mode: 0644]
view/theme/frio/css/style.css
view/theme/frio/js/filebrowser.js
view/theme/frio/js/modal.js
view/theme/frio/templates/filebrowser.tpl [deleted file]
view/theme/frio/templates/jot-header.tpl
view/theme/frio/templates/js_strings.tpl
view/theme/frio/templates/profile/filebrowser.tpl [new file with mode: 0644]
view/theme/quattro/dark/style.css
view/theme/quattro/green/style.css
view/theme/quattro/lilac/style.css
view/theme/quattro/quattro.less
view/theme/vier/style.css

index 6dfdcb560fc9d453d069f9ab779697f7dff51c16..5d30f9bd2ba0cd6fb9e83771639eaa0fa5f0712e 100644 (file)
@@ -85,6 +85,8 @@ class Arguments
 
        /**
         * @return string The module name based on the arguments
+        * @deprecated 2022.12 - With the new (sub-)routes, it's no more trustworthy, use the ModuleClass instead
+        * @see Router::getModuleClass()
         */
        public function getModuleName(): string
        {
index 37141426c36a269f05c65564d515e10229ed2297..afc94fbdf03d8fb3eadcc026b453b13dc1ba1086 100644 (file)
@@ -241,6 +241,7 @@ class Page implements ArrayAccess
                 * being first
                 */
                $this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
+                       '$local_nickname'  => $app->getLoggedInUserNickname(),
                        '$local_user'      => $localUID,
                        '$generator'       => 'Friendica' . ' ' . App::VERSION,
                        '$delitem'         => $l10n->t('Delete this item?'),
index 4e5f29521a822a9bf20a1bdd93914bc4b5994283..b6fd1098f5c91bdd6fda6d3b6e239f49e27e5bee 100644 (file)
@@ -266,7 +266,7 @@ class Router
         * @throws HTTPException\MethodNotAllowedException    If a rule matched but the method didn't
         * @throws HTTPException\NotFoundException            If no rule matched
         */
-       private function getModuleClass(): string
+       public function getModuleClass(): string
        {
                $cmd = $this->args->getCommand();
                $cmd = '/' . ltrim($cmd, '/');
index 7c620b0ad45bb6afc9e95119bf518c788c0353a5..a139ba715fe1828ff79cc51b056f595568faabfd 100644 (file)
@@ -173,6 +173,59 @@ class Photo
                return $photo;
        }
 
+       /**
+        * Returns all browsable albums for a given user
+        *
+        * @param int $uid The given user
+        *
+        * @return array An array of albums
+        * @throws \Exception
+        */
+       public static function getBrowsableAlbumsForUser(int $uid): array
+       {
+               $photos = DBA::toArray(
+                       DBA::p(
+                               "SELECT DISTINCT(`album`) AS `albume` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)",
+                               $uid,
+                               static::CONTACT_AVATAR,
+                               static::CONTACT_BANNER
+                       )
+               );
+
+               return array_column($photos, 'album');
+       }
+
+       /**
+        * Returns browsable photos for a given user (optional and a given album)
+        *
+        * @param int         $uid   The given user id
+        * @param string|null $album (optional) The given album
+        *
+        * @return array All photos of the user/album
+        * @throws \Exception
+        */
+       public static function getBrowsablePhotosForUser(int $uid, string $album = null): array
+       {
+               if (!empty($album)) {
+                       $sqlExtra  = sprintf("AND `album` = '%S' ", DBA::escape($album));
+                       $sqlExtra2 = "";
+               } else {
+                       $sqlExtra  = '';
+                       $sqlExtra2 = ' ORDER BY created DESC LIMIT 0, 10';
+               }
+
+               return DBA::toArray(
+                       DBA::p(
+                               "SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
+                                       min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created`
+                                       FROM `photo` WHERE `uid` = ? $sqlExtra AND NOT `photo-type` IN (?, ?)
+                                       GROUP BY `resource-id` $sqlExtra2",
+                               $uid,
+                               Photo::CONTACT_AVATAR,
+                               Photo::CONTACT_BANNER
+                       ));
+       }
+
        /**
         * Check if photo with given conditions exists
         *
index a73beb2b8dd03585c1e4c498a196bf0a2ccbb2a0..17b2d6e9083ffff62b56bb3577db736a10c61bbd 100644 (file)
@@ -37,7 +37,6 @@ class Attach extends BaseModule
         */
        protected function rawContent(array $request = [])
        {
-               $a = DI::app();
                if (empty($this->parameters['item'])) {
                        throw new \Friendica\Network\HTTPException\BadRequestException();
                }
diff --git a/src/Module/Profile/Attachment/Browser.php b/src/Module/Profile/Attachment/Browser.php
new file mode 100644 (file)
index 0000000..09429bf
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+namespace Friendica\Module\Profile\Attachment;
+
+use Friendica\App;
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
+use Friendica\Core\System;
+use Friendica\Model\Attach;
+use Friendica\Module\Response;
+use Friendica\Util\Profiler;
+use Friendica\Util\Strings;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Browser for Attachments
+ */
+class Browser extends BaseModule
+{
+       /** @var IHandleUserSessions */
+       protected $session;
+       /** @var App */
+       protected $app;
+
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, App $app, array $server, array $parameters = [])
+       {
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+               $this->session = $session;
+               $this->app     = $app;
+       }
+
+       protected function content(array $request = []): string
+       {
+               if (!$this->session->getLocalUserId()) {
+                       $this->baseUrl->redirect();
+               }
+
+               // Needed to match the correct template in a module that uses a different theme than the user/site/default
+               $theme = Strings::sanitizeFilePathItem($request['theme'] ?? '');
+               if ($theme && is_file("view/theme/$theme/config.php")) {
+                       $this->app->setCurrentTheme($theme);
+               }
+
+               $files = Attach::selectToArray(['id', 'filename', 'filetype'], ['uid' => $this->session->getLocalUserId()]);
+
+
+               $fileArray = array_map([$this, 'map_files'], $files);
+
+               $tpl    = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
+               $output = Renderer::replaceMacros($tpl, [
+                       '$type'     => 'attachment',
+                       '$path'     => ['' => $this->t('Files')],
+                       '$folders'  => false,
+                       '$files'    => $fileArray,
+                       '$cancel'   => $this->t('Cancel'),
+                       '$nickname' => $this->app->getLoggedInUserNickname(),
+                       '$upload'   => $this->t('Upload'),
+               ]);
+
+               if (empty($request['mode'])) {
+                       System::httpExit($output);
+               }
+
+               return $output;
+       }
+
+       protected function map_files(array $record): array
+       {
+               [$m1, $m2] = explode('/', $record['filetype']);
+               $filetype   = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'zip');
+
+               return [
+                       sprintf('%s/attach/%s', $this->baseUrl, $record['id']),
+                       $record['filename'],
+                       sprintf('%s/images/icon/16/%s.png', $this->baseUrl, $filetype),
+               ];
+       }
+}
diff --git a/src/Module/Profile/Photos/Browser.php b/src/Module/Profile/Photos/Browser.php
new file mode 100644 (file)
index 0000000..1e8a28b
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+
+namespace Friendica\Module\Profile\Photos;
+
+use Friendica\App;
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
+use Friendica\Core\System;
+use Friendica\Model\Photo;
+use Friendica\Module\Response;
+use Friendica\Util\Images;
+use Friendica\Util\Profiler;
+use Friendica\Util\Strings;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Browser for Photos
+ */
+class Browser extends BaseModule
+{
+       /** @var IHandleUserSessions */
+       protected $session;
+       /** @var App */
+       protected $app;
+
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, App $app, array $server, array $parameters = [])
+       {
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+               $this->session = $session;
+               $this->app     = $app;
+       }
+
+       protected function content(array $request = []): string
+       {
+               if (!$this->session->getLocalUserId()) {
+                       $this->baseUrl->redirect();
+               }
+
+               // Needed to match the correct template in a module that uses a different theme than the user/site/default
+               $theme = Strings::sanitizeFilePathItem($request['theme'] ?? '');
+               if ($theme && is_file("view/theme/$theme/config.php")) {
+                       $this->app->setCurrentTheme($theme);
+               }
+
+               $album = $this->parameters['album'] ?? null;
+
+               $photos = Photo::getBrowsablePhotosForUser($this->session->getLocalUserId(), $album);
+               $albums = $album ? false : Photo::getBrowsableAlbumsForUser($this->session->getLocalUserId());
+
+               $path = [
+                       '' => $this->t('Photos'),
+               ];
+               if (!empty($album)) {
+                       $path[$album] = $album;
+               }
+
+               $photosArray = array_map([$this, 'map_files'], $photos);
+
+               $tpl    = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
+               $output = Renderer::replaceMacros($tpl, [
+                       '$type'     => 'photos',
+                       '$path'     => $path,
+                       '$folders'  => $albums,
+                       '$files'    => $photosArray,
+                       '$cancel'   => $this->t('Cancel'),
+                       '$nickname' => $this->app->getLoggedInUserNickname(),
+                       '$upload'   => $this->t('Upload'),
+               ]);
+
+               if (empty($request['mode'])) {
+                       System::httpExit($output);
+               }
+
+               return $output;
+       }
+
+       protected function map_files(array $record): array
+       {
+               $types      = Images::supportedTypes();
+               $ext        = $types[$record['type']];
+               $filename_e = $record['filename'];
+
+               // Take the largest picture that is smaller or equal 640 pixels
+               $photo = Photo::selectFirst(
+                       ['scale'],
+                       [
+                               "`resource-id` = ? AND `height` <= ? AND `width` <= ?",
+                               $record['resource-id'],
+                               640,
+                               640
+                       ],
+                       ['order' => ['scale']]);
+               $scale = $photo['scale'] ?? $record['loq'];
+
+               return [
+                       sprintf('%s/photos/%s/image/%s', $this->baseUrl, $this->app->getLoggedInUserNickname(), $record['resource-id']),
+                       $filename_e,
+                       sprintf('%s/photo/%s-%s.%s', $this->baseUrl, $record['resource-id'], $scale, $ext),
+                       $record['desc'],
+               ];
+       }
+}
index ae575571177ddedf24972d8be38259d94f70a920..794f705e409aa34f4a30c93182d2596631610953 100644 (file)
@@ -31,18 +31,20 @@ use Friendica\App\Router as R;
 use Friendica\Module;
 
 $profileRoutes = [
-       ''                                         => [Module\Profile\Index::class,             [R::GET]],
-       '/attachment/upload'                       => [Module\Profile\Attachment\Upload::class, [        R::POST]],
-       '/contacts/common'                         => [Module\Profile\Common::class,            [R::GET]],
-       '/contacts[/{type}]'                       => [Module\Profile\Contacts::class,          [R::GET]],
-       '/media'                                   => [Module\Profile\Media::class,             [R::GET]],
-       '/photos'                                  => [Module\Profile\Photos\Index::class,      [R::GET         ]],
-       '/photos/upload'                           => [Module\Profile\Photos\Upload::class,     [        R::POST]],
-       '/profile'                                 => [Module\Profile\Profile::class,           [R::GET]],
-       '/remote_follow'                           => [Module\Profile\RemoteFollow::class,      [R::GET, R::POST]],
-       '/schedule'                                => [Module\Profile\Schedule::class,          [R::GET, R::POST]],
-       '/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class,            [R::GET]],
-       '/unkmail'                                 => [Module\Profile\UnkMail::class,           [R::GET, R::POST]],
+       ''                                         => [Module\Profile\Index::class,              [R::GET]],
+       '/attachment/upload'                       => [Module\Profile\Attachment\Upload::class,  [        R::POST]],
+       '/attachment/browser'                      => [Module\Profile\Attachment\Browser::class, [R::GET]],
+       '/contacts/common'                         => [Module\Profile\Common::class,             [R::GET]],
+       '/contacts[/{type}]'                       => [Module\Profile\Contacts::class,           [R::GET]],
+       '/media'                                   => [Module\Profile\Media::class,              [R::GET]],
+       '/photos'                                  => [Module\Profile\Photos\Index::class,       [R::GET         ]],
+       '/photos/browser[/{album}]'                => [Module\Profile\Photos\Browser::class,     [R::GET]],
+       '/photos/upload'                           => [Module\Profile\Photos\Upload::class,      [        R::POST]],
+       '/profile'                                 => [Module\Profile\Profile::class,            [R::GET]],
+       '/remote_follow'                           => [Module\Profile\RemoteFollow::class,       [R::GET, R::POST]],
+       '/schedule'                                => [Module\Profile\Schedule::class,           [R::GET, R::POST]],
+       '/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class,             [R::GET]],
+       '/unkmail'                                 => [Module\Profile\UnkMail::class,            [R::GET, R::POST]],
 ];
 
 $apiRoutes = [
index 800a3ea34de78d3443ac6f2722eb33c7819ccb68..f09d959391b5e3536c3fc4c0ed0af0bb1a34a9ec 100644 (file)
@@ -345,12 +345,12 @@ img.acpopup-img {
 .fbrowser .path a:before, .fbrowser .path .btn-link:before { content: "/"; padding-right: 5px;}
 .fbrowser .folders ul { list-style-type: none; padding-left: 10px;}
 .fbrowser .list { height: auto; overflow-y: hidden; margin: 10px 0px; }
-.fbrowser.image .photo-album-image-wrapper { float: left; }
-.fbrowser.image a img, .fbrowser.image .btn-link img { height: 48px; }
-.fbrowser.image a p, .fbrowser.image .btn-link p { display: none;}
-.fbrowser.file .photo-album-image-wrapper { float:none;  white-space: nowrap; }
-.fbrowser.file img { display: inline; }
-.fbrowser.file p  { display: inline; white-space: nowrap; }
+.fbrowser.photos .photo-album-image-wrapper { float: left; }
+.fbrowser.photos a img, .fbrowser.photos .btn-link img { height: 48px; }
+.fbrowser.photos a p, .fbrowser.photos .btn-link p { display: none;}
+.fbrowser.attachment .photo-album-image-wrapper { float:none;  white-space: nowrap; }
+.fbrowser.attachment img { display: inline; }
+.fbrowser.attachment p  { display: inline; white-space: nowrap; }
 .fbrowser .upload { clear: both; padding-top: 1em;}
 .fbrowser .error { background: #ffeeee; border: 1px solid #994444; color: #994444; padding: 0.5em;}
 .fbrowser .error .close { float: right; font-weight: bold; }
index e5bd2730c40a9faa52f097d8a1cbea7fe7b2269d..1b8a4d51fb18737eebe0f56c622dd30098f46a02 100644 (file)
@@ -33,7 +33,7 @@
  * <type> will be one of "image" or "file", and the event handler will
  * get the following params:
  *
- *             filemane: filename of item choosed by user
+ *             filename: filename of item chosen by user
  *             embed: bbcode to embed element into posts
  *             id: id from caller code
  *
  *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
  *                     // close colorbox
  *                     $.colorbox.close();
- *                     // replace textxarea text with bbcode
+ *                     // replace textarea text with bbcode
  *                     $(id).value = bbcode;
  *             });
  **/
+const FileBrowser = {
+       nickname: '',
+       type: '',
+       event: '',
+       id: null,
 
-var FileBrowser = {
-       nickname : "",
-       type : "",
-       event: "",
-       id : null,
-
-       init: function(nickname, type) {
+       init: function (nickname, type) {
                FileBrowser.nickname = nickname;
                FileBrowser.type = type;
-               FileBrowser.event = "fbrowser."+type;
-               if (location['hash']!=="") {
-                       var h = location['hash'].replace("#","");
+               FileBrowser.event = "fbrowser." + type;
+               if (location['hash'] !== "") {
+                       const h = location['hash'].replace('#', '');
                        FileBrowser.event = FileBrowser.event + "." + h.split("-")[0];
                        FileBrowser.id = h.split("-")[1];
                }
 
-               console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id );
+               console.log('FileBrowser:', nickname, type, FileBrowser.event, FileBrowser.id);
 
-               $(".error a.close").on("click", function(e) {
+               $('.error a.close').on('click', function (e) {
                        e.preventDefault();
-                       $(".error").addClass("hidden");
+                       $('.error').addClass('hidden');
                });
 
-               $(".folders a, .path a").on("click", function(e){
+               $('.folders a, .path a').on('click', function (e) {
                        e.preventDefault();
-                       location.href = baseurl + "/fbrowser/" + FileBrowser.type + "/" + encodeURIComponent(this.dataset.folder) + "?mode=minimal" + location['hash'];
+                       location.href = FileBrowser._getUrl("minimal", location['hash'], this.dataset.folder);
+                       location.reload();
                });
 
-               $(".photo-album-photo-link").on('click', function(e){
+               $(".photo-album-photo-link").on('click', function (e) {
                        e.preventDefault();
 
-                       var embed = "";
-                       if (FileBrowser.type == "image") {
-                               embed = "[url="+this.dataset.link+"][img="+this.dataset.img+"]"+this.dataset.alt+"[/img][/url]";
+                       let embed = '';
+                       if (FileBrowser.type === "photos") {
+                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
                        }
-                       if (FileBrowser.type=="file") {
-                               // attachment links are "baseurl/attach/id"; we need id
-                               embed = "[attachment]"+this.dataset.link.split("/").pop()+"[/attachment]";
+                       if (FileBrowser.type === "attachment") {
+                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
                        }
                        console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
-                       parent.$("body").trigger(FileBrowser.event, [
+                       parent.$('body').trigger(FileBrowser.event, [
                                this.dataset.filename,
                                embed,
                                FileBrowser.id
@@ -100,45 +99,63 @@ var FileBrowser = {
 
                });
 
-               if ($("#upload-image").length)
-                       var image_uploader = new window.AjaxUpload(
-                               'upload-image',
-                               { action: 'profile/' + FileBrowser.nickname + '/photos/upload?response=json',
+               if ($('#upload-photos').length)
+               {
+                       new window.AjaxUpload(
+                               'upload-photos',
+                               {
+                                       action: 'profile/' + FileBrowser.nickname + '/photos/upload?response=json',
                                        name: 'userfile',
                                        responseType: 'json',
-                                       onSubmit: function(file,ext) { $('#profile-rotator').show(); $(".error").addClass('hidden'); },
-                                       onComplete: function(file,response) {
-                                               if (response['error']!= undefined) {
-                                                       $(".error span").html(response['error']);
-                                                       $(".error").removeClass('hidden');
+                                       onSubmit: function (file, ext) {
+                                               $('#profile-rotator').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
                                                        $('#profile-rotator').hide();
                                                        return;
                                                }
-                                               location = baseurl + "/fbrowser/image/?mode=minimal"+location['hash'];
-                                               location.reload(true);
+                                               location.href = FileBrowser._getUrl("minimal", location['hash']);
+                                               location.reload();
                                        }
                                }
                        );
+               }
 
-               if ($("#upload-file").length)
-                       var file_uploader = new window.AjaxUpload(
-                               'upload-file',
-                               { action: 'profile/' + FileBrowser.nickname + '/attachment/upload?response=json',
+               if ($('#upload-attachment').length)
+               {
+                       new window.AjaxUpload(
+                               'upload-attachment',
+                               {
+                                       action: 'profile/' + FileBrowser.nickname + '/attachment/upload?response=json',
                                        name: 'userfile',
                                        responseType: 'json',
-                                       onSubmit: function(file,ext) { $('#profile-rotator').show(); $(".error").addClass('hidden'); },
-                                       onComplete: function(file,response) {
-                                               if (response['error']!= undefined) {
-                                                       $(".error span").html(response['error']);
-                                                       $(".error").removeClass('hidden');
+                                       onSubmit: function (file, ext) {
+                                               $('#profile-rotator').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
                                                        $('#profile-rotator').hide();
                                                        return;
                                                }
-                                               location = baseurl + "/fbrowser/file/?mode=minimal"+location['hash'];
-                                               location.reload(true);
+                                               location.href = FileBrowser._getUrl("minimal", location['hash']);
+                                               location.reload();
                                        }
                                }
-               );
+                               );
+                       }
+       },
+
+       _getUrl: function (mode, hash, folder) {
+               let folderValue = folder !== undefined ? folder : FileBrowser.folder;
+               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
+               return 'profile/' + FileBrowser.nickname + '/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
        }
 };
 // @license-end
index 93340dc37f6fdcb6ba58321489de3c93caf97977..3ba8240fedec23ede480d3a46f860b7aeb937a81 100644 (file)
@@ -166,7 +166,7 @@ $(function() {
 
        /* event from comment textarea button popups */
        /* insert returned bbcode at cursor position or replace selected text */
-       $("body").on("fbrowser.image.comment", function(e, filename, bbcode, id) {
+       $("body").on("fbrowser.photos.comment", function(e, filename, bbcode, id) {
                $.colorbox.close();
                var textarea = document.getElementById("comment-edit-text-" +id);
                var start = textarea.selectionStart;
@@ -1069,7 +1069,7 @@ var Dialog = {
         * to the event handler
         */
        doImageBrowser : function (name, id) {
-               var url = Dialog._get_url("image",name,id);
+               var url = Dialog._get_url("photos",name,id);
                return Dialog.show(url);
        },
 
@@ -1086,7 +1086,7 @@ var Dialog = {
         * to the event handler
         */
        doFileBrowser : function (name, id) {
-               var url = Dialog._get_url("file",name,id);
+               var url = Dialog._get_url("attachment",name,id);
                return Dialog.show(url);
        },
 
@@ -1095,7 +1095,7 @@ var Dialog = {
                if (id !== undefined) {
                        hash = hash + "-" + id;
                }
-               return baseurl + "/fbrowser/"+type+"/?mode=minimal#"+hash;
+               return '/profile/' + localNickname + '/' + type + '/browser?mode=minimal#' + hash;
        },
 
        _get_size: function() {
diff --git a/view/templates/filebrowser.tpl b/view/templates/filebrowser.tpl
deleted file mode 100644 (file)
index 09bf563..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<!--
-       This is the template used by mod/fbrowser.php
--->
-<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-<script type="text/javascript" src="{{$baseurl}}/view/js/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-<script>
-       $(function() {
-               FileBrowser.init("{{$nickname}}", "{{$type}}");
-       });
-</script>
-<div class="fbrowser {{$type}}">
-       <div class="error hidden">
-               <span></span> <a href="#" class='close'>X</a>
-       </div>
-
-       <div class="path">
-               {{foreach $path as $folder => $name}}
-                       <a href="#" data-folder="{{$folder}}">{{$name}}</a>
-               {{/foreach}}
-       </div>
-
-       {{if $folders }}
-       <div class="folders">
-               <ul>
-               {{foreach $folders as $folder}}
-                       <li><a href="#" data-folder="{{$folder}}">{{$folder}}</a></li>
-               {{/foreach}}
-               </ul>
-       </div>
-       {{/if}}
-
-       <div class="list">
-               {{foreach $files as $f}}
-               <div class="photo-album-image-wrapper">
-                       <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
-                               <img src="{{$f.2}}">
-                               <p>{{$f.1}}</p>
-                       </a>
-               </div>
-               {{/foreach}}
-       </div>
-
-       <div class="upload">
-               <button id="upload-{{$type}}"><img id="profile-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" /> {{$upload}}</button>
-       </div>
-</div>
-
-
-       </body>
-
-</html>
index a67f9c3f0c35ef0bdea97a1f6061c5c3cf4b3210..2a81db6dd1b4840140c052df4c25e3ee71e8d461 100644 (file)
@@ -61,11 +61,11 @@ function enableOnUser(){
                 **/
 
                /* callback */
-               $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
+               $('body').on('fbrowser.photos.main', function(e, filename, embedcode, id) {
                        $.colorbox.close();
                        addeditortext(embedcode);
                });
-               $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
+               $('body').on('fbrowser.photos.main', function(e, filename, embedcode, id) {
                        $.colorbox.close();
                        addeditortext(embedcode);
                });
diff --git a/view/templates/profile/filebrowser.tpl b/view/templates/profile/filebrowser.tpl
new file mode 100644 (file)
index 0000000..ff25741
--- /dev/null
@@ -0,0 +1,51 @@
+<!--
+       This is the template used by mod/fbrowser.php
+-->
+<script type="text/javascript" src="view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
+<script type="text/javascript" src="view/js/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
+<script>
+       $(function() {
+               FileBrowser.init("{{$nickname}}", "{{$type}}");
+       });
+</script>
+<div class="fbrowser {{$type}}">
+       <div class="error hidden">
+               <span></span> <a href="#" class='close'>X</a>
+       </div>
+
+       <div class="path">
+               {{foreach $path as $folder => $name}}
+                       <a href="#" data-folder="{{$folder}}">{{$name}}</a>
+               {{/foreach}}
+       </div>
+
+       {{if $folders }}
+       <div class="folders">
+               <ul>
+               {{foreach $folders as $folder}}
+                       <li><a href="#" data-folder="{{$folder}}">{{$folder}}</a></li>
+               {{/foreach}}
+               </ul>
+       </div>
+       {{/if}}
+
+       <div class="list">
+               {{foreach $files as $f}}
+               <div class="photo-album-image-wrapper">
+                       <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
+                               <img alt="{{$f.3}}" src="{{$f.1}}">
+                               <p>{{$f.1}}</p>
+                       </a>
+               </div>
+               {{/foreach}}
+       </div>
+
+       <div class="upload">
+               <button id="upload-{{$type}}"><img id="profile-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" /> {{$upload}}</button>
+       </div>
+</div>
+
+
+       </body>
+
+</html>
index b3250d805578e1734da1c6a8f6e9565d94da1023..0e54d1cf978cb80d12f3f14cbb2e07d04b0da8ed 100644 (file)
@@ -1563,10 +1563,10 @@ textarea.comment-edit-text:focus + .comment-edit-form .preview {
                max-height: calc(100vh - 220px);
        }
 }
-.fbrowser.image .photo-album-image-wrapper {
+.fbrowser.photos .photo-album-image-wrapper {
        box-shadow: 2px 2px 5px 0px rgba(0, 0, 0, 0.2);
 }
-.fbrowser.image .photo-album-image-wrapper .caption {
+.fbrowser.photos .photo-album-image-wrapper .caption {
        pointer-events: none;
 }
 .fbrowser .profile-rotator-wrapper {
index 67d3b7923e8e046d0e12bda0f52f6573c35681a3..d7217fdbc67dc438c06ca8ba1a75b40c2b27b2f5 100644 (file)
@@ -9,7 +9,7 @@
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * This code handle user interaction for image/file upload/browser dialog.
+ * This code handle user interaction for photo/file upload/browser dialog.
  * Is loaded from filebrowser_plain.tpl
  *
  * To load filebrowser in colorbox, call
@@ -33,7 +33,7 @@
  * <type> will be one of "image" or "file", and the event handler will
  * get the following params:
  *
- *             filemane: filename of item choosed by user
+ *             filename: filename of item chosen by user
  *             embed: bbcode to embed element into posts
  *             id: id from caller code
  *
@@ -47,7 +47,7 @@
  *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
  *                     // close colorbox
  *                     $.colorbox.close();
- *                     // replace textxarea text with bbcode
+ *                     // replace textarea text with bbcode
  *                     $(id).value = bbcode;
  *             });
  **/
  *  This is a modified version to work with
  *  the frio theme.and bootstrap modals
  *
- *  The origninal file is under:
+ *  The original file is under:
  *  js/filebrowser.js
  *
  */
 
 var FileBrowser = {
-       nickname: "",
-       type: "",
-       event: "",
-       folder: "",
+       nickname: '',
+       type: '',
+       event: '',
+       folder: '',
        id: null,
 
        init: function (nickname, type, hash) {
                FileBrowser.nickname = nickname;
                FileBrowser.type = type;
-               FileBrowser.event = "fbrowser." + type;
-
-               if (hash !== "") {
-                       var h = hash.replace("#", "");
-                       var destination = h.split("-")[0];
-                       FileBrowser.id = h.split("-")[1];
-                       FileBrowser.event = FileBrowser.event + "." + destination;
-                       if (destination === "comment") {
-                               // Get the comment textimput field
-                               var commentElm = document.getElementById("comment-edit-text-" + FileBrowser.id);
+               FileBrowser.event = 'fbrowser.' + type;
+
+               if (hash !== '') {
+                       const h = hash.replace('#', '');
+                       const destination = h.split('-')[0];
+                       FileBrowser.id = h.split('-')[1];
+                       FileBrowser.event = FileBrowser.event + '.' + destination;
+                       if (destination === 'comment') {
+                               // Get the comment textinput field
+                               var commentElm = document.getElementById('comment-edit-text-' + FileBrowser.id);
                        }
                }
 
-               console.log("FileBrowser: " + nickname, type, FileBrowser.event, FileBrowser.id);
+               console.log('FileBrowser: ' + nickname, type, FileBrowser.event, FileBrowser.id);
 
                FileBrowser.postLoad();
 
-               $(".error .close").on("click", function (e) {
+               $('.error .close').on('click', function (e) {
                        e.preventDefault();
-                       $(".error").addClass("hidden");
+                       $('.error').addClass('hidden');
                });
 
                // Click on album link
-               $(".fbrowser").on("click", ".folders button, .path button", function (e) {
+               $('.fbrowser').on('click', '.folders button, .path button', function (e) {
                        e.preventDefault();
-                       var url =
-                               baseurl +
-                               "/fbrowser/" +
-                               FileBrowser.type +
-                               "/" +
-                               encodeURIComponent(this.dataset.folder) +
-                               "?mode=none&theme=frio";
+                       let url = FileBrowser._getUrl("none", this.dataset.folder);
                        FileBrowser.folder = this.dataset.folder;
 
                        FileBrowser.loadContent(url);
                });
 
                //Embed on click
-               $(".fbrowser").on("click", ".photo-album-photo-link", function (e) {
+               $('.fbrowser').on('click', '.photo-album-photo-link', function (e) {
                        e.preventDefault();
 
-                       var embed = "";
-                       if (FileBrowser.type === "image") {
-                               embed = "[url=" + this.dataset.link + "][img=" + this.dataset.img + "]" + this.dataset.alt + "[/img][/url]";
+                       let embed = '';
+                       if (FileBrowser.type === 'photos') {
+                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
                        }
-                       if (FileBrowser.type === "file") {
+                       if (FileBrowser.type === 'attachment') {
                                // attachment links are "baseurl/attach/id"; we need id
-                               embed = "[attachment]" + this.dataset.link.split("/").pop() + "[/attachment]";
+                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
                        }
 
                        // Delete prefilled Text of the comment input
                        // Note: not the best solution but function commentOpenUI don't
                        // work as expected (we need a way to wait until commentOpenUI would be finished).
                        // As for now we insert pieces of this function here
-                       if (commentElm !== null && typeof commentElm !== "undefined") {
-                               if (commentElm.value === "") {
-                                       $("#comment-edit-text-" + FileBrowser.id)
-                                               .addClass("comment-edit-text-full")
-                                               .removeClass("comment-edit-text-empty");
-                                       $("#comment-edit-submit-wrapper-" + FileBrowser.id).show();
-                                       $("#comment-edit-text-" + FileBrowser.id).attr("tabindex", "9");
-                                       $("#comment-edit-submit-" + FileBrowser.id).attr("tabindex", "10");
+                       if (commentElm !== null && typeof commentElm !== 'undefined') {
+                               if (commentElm.value === '') {
+                                       $('#comment-edit-text-' + FileBrowser.id)
+                                               .addClass('comment-edit-text-full')
+                                               .removeClass('comment-edit-text-empty');
+                                       $('#comment-edit-submit-wrapper-' + FileBrowser.id).show();
+                                       $('#comment-edit-text-' + FileBrowser.id).attr('tabindex', '9');
+                                       $('#comment-edit-submit-' + FileBrowser.id).attr('tabindex', '10');
                                }
                        }
 
                        console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
 
-                       $("body").trigger(FileBrowser.event, [this.dataset.filename, embed, FileBrowser.id, this.dataset.img]);
+                       $('body').trigger(FileBrowser.event, [this.dataset.filename, embed, FileBrowser.id, this.dataset.img]);
 
                        // Close model
-                       $("#modal").modal("hide");
+                       $('#modal').modal('hide');
                        // Update autosize for this textarea
-                       autosize.update($(".text-autosize"));
+                       autosize.update($('.text-autosize'));
                });
 
-               // EventListener for switching between image and file mode
-               $(".fbrowser").on("click", ".fbswitcher .btn", function (e) {
+               // EventListener for switching between photo and file mode
+               $('.fbrowser').on('click', '.fbswitcher .btn', function (e) {
                        e.preventDefault();
-                       FileBrowser.type = this.getAttribute("data-mode");
-                       $(".fbrowser")
+                       FileBrowser.type = this.getAttribute('data-mode');
+                       $('.fbrowser')
                                .removeClass()
-                               .addClass("fbrowser " + FileBrowser.type);
-                       url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";
+                               .addClass('fbrowser ' + FileBrowser.type);
 
-                       FileBrowser.loadContent(url);
+                       FileBrowser.loadContent(FileBrowser._getUrl("none"));
                });
        },
 
        // Initialize the AjaxUpload for the upload buttons
        uploadButtons: function () {
-               if ($("#upload-image").length) {
-                       //AjaxUpload for images
-                       var image_uploader = new window.AjaxUpload("upload-image", {
-                               action:
-                                       "profile/" +
-                                       FileBrowser.nickname +
-                                       "/photos/upload?response=json&album=" +
-                                       encodeURIComponent(FileBrowser.folder),
-                               name: "userfile",
-                               responseType: "json",
-                               onSubmit: function (file, ext) {
-                                       $(".fbrowser-content").hide();
-                                       $(".fbrowser .profile-rotator-wrapper").show();
-                                       $(".error").addClass("hidden");
-                               },
-                               onComplete: function (file, response) {
-                                       if (response["error"] != undefined) {
-                                               $(".error span").html(response["error"]);
-                                               $(".error").removeClass("hidden");
-                                               $(".fbrowser .profile-rotator-wrapper").hide();
-                                               $(".fbrowser-content").show();
-                                               return;
-                                       }
-
-                                       // load new content to fbrowser window
-                                       FileBrowser.loadContent(
-                                               baseurl +
-                                                       "/fbrowser/" +
-                                                       FileBrowser.type +
-                                                       "/" +
-                                                       encodeURIComponent(FileBrowser.folder) +
-                                                       "?mode=none&theme=frio",
-                                       );
-                               },
-                       });
+               if ($('#upload-photos').length) {
+                       //AjaxUpload for photos
+                       new window.AjaxUpload(
+                               'upload-photos',
+                               {
+                                       action: 'profile/' + FileBrowser.nickname + '/photos/upload?response=json&album=' + encodeURIComponent(FileBrowser.folder),
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('.fbrowser-content').hide();
+                                               $('.fbrowser .profile-rotator-wrapper').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('.fbrowser .profile-rotator-wrapper').hide();
+                                                       $('.fbrowser-content').show();
+                                                       return;
+                                               }
+                                               // load new content to fbrowser window
+                                               FileBrowser.loadContent(FileBrowser._getUrl("none"));
+                                       },
+                               });
                }
 
-               if ($("#upload-file").length) {
+               if ($('#upload-attachment').length) {
                        //AjaxUpload for files
-                       var file_uploader = new window.AjaxUpload("upload-file", {
-                               action: "profile/" + FileBrowser.nickname + "/attachment/upload?response=json",
-                               name: "userfile",
-                               responseType: "json",
-                               onSubmit: function (file, ext) {
-                                       $(".fbrowser-content").hide();
-                                       $(".fbrowser .profile-rotator-wrapper").show();
-                                       $(".error").addClass("hidden");
-                               },
-                               onComplete: function (file, response) {
-                                       if (response["error"] != undefined) {
-                                               $(".error span").html(response["error"]);
-                                               $(".error").removeClass("hidden");
-                                               $(".fbrowser .profile-rotator-wrapper").hide();
-                                               $(".fbrowser-content").show();
-                                               return;
-                                       }
-
-                                       var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";
-                                       // Load new content to fbrowser window
-                                       FileBrowser.loadContent(url);
-                               },
-                       });
+                       new window.AjaxUpload(
+                               'upload-attachment',
+                               {
+                                       action: 'profile/' + FileBrowser.nickname + '/attachment/upload?response=json',
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('.fbrowser-content').hide();
+                                               $('.fbrowser .profile-rotator-wrapper').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response["error"] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('.fbrowser .profile-rotator-wrapper').hide();
+                                                       $('.fbrowser-content').show();
+                                                       return;
+                                               }
+                                               // Load new content to fbrowser window
+                                               FileBrowser.loadContent(FileBrowser._getUrl("none"));
+                                       },
+                               });
                }
        },
 
-       // Stuff which should be executed if ne content was loaded
+       // Stuff which should be executed if no content was loaded
        postLoad: function () {
                FileBrowser.initGallery();
-               $(".fbrowser .fbswitcher .btn").removeClass("active");
-               $(".fbrowser .fbswitcher [data-mode=" + FileBrowser.type + "]").addClass("active");
+               $('.fbrowser .fbswitcher .btn').removeClass('active');
+               $('.fbrowser .fbswitcher [data-mode=' + FileBrowser.type + ']').addClass('active');
                // We need to add the AjaxUpload to the button
                FileBrowser.uploadButtons();
        },
 
        // Load new content (e.g. change photo album)
        loadContent: function (url) {
-               $(".fbrowser-content").hide();
-               $(".fbrowser .profile-rotator-wrapper").show();
+               $('.fbrowser-content').hide();
+               $('.fbrowser .profile-rotator-wrapper').show();
 
                // load new content to fbrowser window
-               $(".fbrowser").load(url, function (responseText, textStatus) {
-                       $(".profile-rotator-wrapper").hide();
-                       if (textStatus === "success") {
+               $('.fbrowser').load(url, function (responseText, textStatus) {
+                       $('.profile-rotator-wrapper').hide();
+                       if (textStatus === 'success') {
                                $(".fbrowser_content").show();
                                FileBrowser.postLoad();
                        }
@@ -254,11 +237,17 @@ var FileBrowser = {
 
        // Initialize justified Gallery
        initGallery: function () {
-               $(".fbrowser.image .fbrowser-content-container").justifiedGallery({
+               $('.fbrowser.photos .fbrowser-content-container').justifiedGallery({
                        rowHeight: 80,
                        margins: 4,
                        border: 0,
                });
        },
+
+       _getUrl: function (mode, folder) {
+               let folderValue = folder !== undefined ? folder : FileBrowser.folder;
+               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
+               return 'profile/' + FileBrowser.nickname + '/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
+       }
 };
 // @license-end
index eaf41eeb87b8c50a2609298094125aa594c78ac7..5e21a0b0bdb9ac9ce1d37c5f247ffcfce6aa2bf4 100644 (file)
@@ -82,7 +82,7 @@ $(document).ready(function () {
        });
 
        // Insert filebrowser images into the input field (field_fileinput.tpl).
-       $("body").on("fbrowser.image.input", function (e, filename, embedcode, id, img) {
+       $("body").on("fbrowser.photos.input", function (e, filename, embedcode, id, img) {
                // Select the clicked button by it's attribute.
                var elm = $("[image-input='select']");
                // Select the input field which belongs to this button.
@@ -132,12 +132,12 @@ Dialog.show = function (url, title) {
 Dialog._get_url = function (type, name, id) {
        var hash = name;
        if (id !== undefined) hash = hash + "-" + id;
-       return "fbrowser/" + type + "/?mode=none&theme=frio#" + hash;
+       return "profile/" + localNickname + "/" + type + "/browser?mode=none&theme=frio#" + hash;
 };
 
 // Does load the filebrowser into the jot modal.
 Dialog.showJot = function () {
-       var type = "image";
+       var type = "photos";
        var name = "main";
 
        var url = Dialog._get_url(type, name);
@@ -159,7 +159,7 @@ Dialog._load = function (url) {
        let filebrowser = document.getElementById("filebrowser");
 
        // Try to fetch the hash form the url.
-       let match = url.match(/fbrowser\/[a-z]+\/.*(#.*)/);
+       let match = url.match(/profile\/[a-z]+\/.*(#.*)/);
        if (!filebrowser || match === null) {
                return; //not fbrowser
        }
diff --git a/view/theme/frio/templates/filebrowser.tpl b/view/theme/frio/templates/filebrowser.tpl
deleted file mode 100644 (file)
index 13c4790..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-<!--
-       This is the template used by mod/fbrowser.php
--->
-<div id="filebrowser" class="fbrowser {{$type}}" data-nickname="{{$nickname}}" data-type="{{$type}}">
-       <div class="fbrowser-content">
-               <div class="error hidden">
-                       <span></span> <button type="button" class="btn btn-link close" aria-label="Close">X</button>
-               </div>
-
-               {{* The breadcrumb navigation *}}
-               <ol class="path breadcrumb" aria-label="Breadcrumb" role="menu">
-               {{foreach $path as $folder => $name}}
-                       <li role="presentation">
-                               <button type="button" class="btn btn-link" data-folder="{{$folder}}" role="menuitem">{{$name}}</button>
-                       </li>
-               {{/foreach}}
-
-                       {{* Switch between image and file mode *}}
-                       <div class="fbswitcher btn-group btn-group-xs pull-right" aria-label="Switch between image and file mode">
-                               <button type="button" class="btn btn-default" data-mode="image" aria-label="Image Mode"><i class="fa fa-picture-o" aria-hidden="true"></i></button>
-                               <button type="button" class="btn btn-default" data-mode="file" aria-label="File Mode"><i class="fa fa-file-o" aria-hidden="true"></i></button>
-                       </div>
-               </ol>
-
-               <div class="media">
-
-                       {{* List of photo albums *}}
-                       {{if $folders }}
-                       <div class="folders media-left" role="navigation" aria-label="Album Navigation">
-                               <ul role="menu">
-                                       {{foreach $folders as $folder}}
-                                       <li role="presentation">
-                                               <button type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button>
-                                       </li>
-                                       {{/foreach}}
-                               </ul>
-                       </div>
-                       {{/if}}
-
-                       {{* The main content (images or files) *}}
-                       <div class="list {{$type}} media-body" role="main" aria-label="Browser Content">
-                               <div class="fbrowser-content-container">
-                                       {{foreach $files as $f}}
-                                       <div class="photo-album-image-wrapper">
-                                               <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
-                                                       <img src="{{$f.2}}" alt="{{$f.1}}">
-                                                       <p>{{$f.1}}</p>
-                                               </a>
-                                       </div>
-                                       {{/foreach}}
-                               </div>
-                       </div>
-               </div>
-
-               <div class="upload">
-                       <button id="upload-{{$type}}" type="button" class="btn btn-primary">{{$upload}}</button>
-               </div>
-       </div>
-
-       {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
-       <div class="profile-rotator-wrapper" aria-hidden="true" style="display: none;">
-               <i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>
-       </div>
-</div>
index 25a02b9b6095909134bf256fc03f13432ec34e72..61f92ff73c123cacd90970e617a5944801bbfd61 100644 (file)
                 **/
 
                /* callback */
-               $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
+               $('body').on('fbrowser.photos.main', function(e, filename, embedcode, id) {
                        ///@todo this part isn't ideal and need to be done in a better way
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                        jotActive();
                        addeditortext(embedcode);
                })
-               .on('fbrowser.file.main', function(e, filename, embedcode, id) {
+               .on('fbrowser.attachment.main', function(e, filename, embedcode, id) {
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                        jotActive();
                        addeditortext(embedcode);
index 066e4bd58525521a8c543ba1cea23d50b7ddc20c..c422648a21dd4b6364306ee069b536c3e9aefafb 100644 (file)
@@ -5,6 +5,7 @@ They are loaded into the html <head> so that js functions can use them *}}
        var updateInterval = {{$update_interval}};
 
        var localUser = {{if $local_user}}{{$local_user}}{{else}}false{{/if}};
+       var localNickname = {{if $local_nickname}}"{{$local_nickname|escape:'javascript' nofilter}}"{{else}}false{{/if}};
        var aStr = {
                'delitem'     : "{{$delitem|escape:'javascript' nofilter}}",
                'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}",
diff --git a/view/theme/frio/templates/profile/filebrowser.tpl b/view/theme/frio/templates/profile/filebrowser.tpl
new file mode 100644 (file)
index 0000000..7b24537
--- /dev/null
@@ -0,0 +1,64 @@
+<!--
+       This is the template used by mod/fbrowser.php
+-->
+<div id="filebrowser" class="fbrowser {{$type}}" data-nickname="{{$nickname}}" data-type="{{$type}}">
+       <div class="fbrowser-content">
+               <div class="error hidden">
+                       <span></span> <button type="button" class="btn btn-link close" aria-label="Close">X</button>
+               </div>
+
+               {{* The breadcrumb navigation *}}
+               <ol class="path breadcrumb" aria-label="Breadcrumb" role="menu">
+               {{foreach $path as $folder => $name}}
+                       <li role="presentation">
+                               <button type="button" class="btn btn-link" data-folder="{{$folder}}" role="menuitem">{{$name}}</button>
+                       </li>
+               {{/foreach}}
+
+                       {{* Switch between image and file mode *}}
+                       <div class="fbswitcher btn-group btn-group-xs pull-right" aria-label="Switch between photo and attachment mode">
+                               <button type="button" class="btn btn-default" data-mode="photos" aria-label="Photo Mode"><i class="fa fa-picture-o" aria-hidden="true"></i></button>
+                               <button type="button" class="btn btn-default" data-mode="attachment" aria-label="Attachment Mode"><i class="fa fa-file-o" aria-hidden="true"></i></button>
+                       </div>
+               </ol>
+
+               <div class="media">
+
+                       {{* List of photo albums *}}
+                       {{if $folders }}
+                       <div class="folders media-left" role="navigation" aria-label="Album Navigation">
+                               <ul role="menu">
+                                       {{foreach $folders as $folder}}
+                                       <li role="presentation">
+                                               <button type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button>
+                                       </li>
+                                       {{/foreach}}
+                               </ul>
+                       </div>
+                       {{/if}}
+
+                       {{* The main content (images or files) *}}
+                       <div class="list {{$type}} media-body" role="main" aria-label="Browser Content">
+                               <div class="fbrowser-content-container">
+                                       {{foreach $files as $f}}
+                                       <div class="photo-album-image-wrapper">
+                                               <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
+                                                       <img src="{{$f.2}}" alt="{{$f.1}}">
+                                                       <p>{{$f.1}}</p>
+                                               </a>
+                                       </div>
+                                       {{/foreach}}
+                               </div>
+                       </div>
+               </div>
+
+               <div class="upload">
+                       <button id="upload-{{$type}}" type="button" class="btn btn-primary">{{$upload}}</button>
+               </div>
+       </div>
+
+       {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
+       <div class="profile-rotator-wrapper" aria-hidden="true" style="display: none;">
+               <i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>
+       </div>
+</div>
index e4f7fb3b9592642fa14e9f2a2c1bcbec2aef0c50..30271c49b24592d1dcfd55765a4137ce522921d7 100644 (file)
@@ -2517,29 +2517,29 @@ footer {
 .fbrowser .list {
   padding: 10px;
 }
-.fbrowser.image .photo-album-image-wrapper {
+.fbrowser.photos .photo-album-image-wrapper {
   width: 48px;
   height: 48px;
 }
-.fbrowser.image a img {
+.fbrowser.photos a img {
   width: auto;
   height: 48px;
 }
-.fbrowser.image a p {
+.fbrowser.photos a p {
   display: none;
 }
-.fbrowser.file .photo-album-image-wrapper {
+.fbrowser.attachment .photo-album-image-wrapper {
   float: none;
   white-space: nowrap;
   width: 100%;
   height: auto;
 }
-.fbrowser.file img {
+.fbrowser.attachment img {
   display: inline;
   width: 16px;
   height: 16px;
 }
-.fbrowser.file p {
+.fbrowser.attachment p {
   display: inline;
   white-space: nowrap;
 }
index 3ab55fbaff327955b0b287024c14f7bc86da0756..574f9c5318c32499ae7468d802efe781be9f1bbc 100644 (file)
@@ -2516,29 +2516,29 @@ footer {
 .fbrowser .list {
   padding: 10px;
 }
-.fbrowser.image .photo-album-image-wrapper {
+.fbrowser.photos .photo-album-image-wrapper {
   width: 48px;
   height: 48px;
 }
-.fbrowser.image a img {
+.fbrowser.photos a img {
   width: auto;
   height: 48px;
 }
-.fbrowser.image a p {
+.fbrowser.photos a p {
   display: none;
 }
-.fbrowser.file .photo-album-image-wrapper {
+.fbrowser.attachment .photo-album-image-wrapper {
   float: none;
   white-space: nowrap;
   width: 100%;
   height: auto;
 }
-.fbrowser.file img {
+.fbrowser.attachment img {
   display: inline;
   width: 16px;
   height: 16px;
 }
-.fbrowser.file p {
+.fbrowser.attachment p {
   display: inline;
   white-space: nowrap;
 }
index 7adf87ad930c6ebe95f59e109533a02cafe90663..6a4afb89cecb5eab536b8947b39503aa83ad04f3 100644 (file)
@@ -2516,29 +2516,29 @@ footer {
 .fbrowser .list {
   padding: 10px;
 }
-.fbrowser.image .photo-album-image-wrapper {
+.fbrowser.photos .photo-album-image-wrapper {
   width: 48px;
   height: 48px;
 }
-.fbrowser.image a img {
+.fbrowser.photos a img {
   width: auto;
   height: 48px;
 }
-.fbrowser.image a p {
+.fbrowser.photos a p {
   display: none;
 }
-.fbrowser.file .photo-album-image-wrapper {
+.fbrowser.attachment .photo-album-image-wrapper {
   float: none;
   white-space: nowrap;
   width: 100%;
   height: auto;
 }
-.fbrowser.file img {
+.fbrowser.attachment img {
   display: inline;
   width: 16px;
   height: 16px;
 }
-.fbrowser.file p {
+.fbrowser.attachment p {
   display: inline;
   white-space: nowrap;
 }
index 9a990557e4aa115597b10ef8ca7897636a7c975e..e6a953e483173ef4e9e7a95a97e219c8a3f11506 100644 (file)
@@ -1673,11 +1673,11 @@ footer { height: 100px; display: table-row; }
 }
 .fbrowser .folders ul { list-style: url("icons/folder.png"); padding-left: 22px;}
 .fbrowser .list { padding: 10px; }
-.fbrowser.image .photo-album-image-wrapper { width: 48px; height: 48px; }
-.fbrowser.image a img { width: auto; height: 48px; }
-.fbrowser.image a p { display: none;}
-.fbrowser.file .photo-album-image-wrapper { float:none;  white-space: nowrap; width: 100%; height: auto; }
-.fbrowser.file img { display: inline; width: 16px; height: 16px}
-.fbrowser.file p  { display: inline; white-space: nowrap; }
+.fbrowser.photos .photo-album-image-wrapper { width: 48px; height: 48px; }
+.fbrowser.photos a img { width: auto; height: 48px; }
+.fbrowser.photos a p { display: none;}
+.fbrowser.attachment .photo-album-image-wrapper { float:none;  white-space: nowrap; width: 100%; height: auto; }
+.fbrowser.attachment img { display: inline; width: 16px; height: 16px}
+.fbrowser.attachment p  { display: inline; white-space: nowrap; }
 
 .fbrowser .upload { clear: both; padding-top: 1em;}
index 9054f62f7d2f00e4bcf780d6ec3e4a08e67e366a..c156534d313656fdcfe1e18ef7f142afb18daa68 100644 (file)
@@ -3261,7 +3261,7 @@ img.photo-album-photo {
 }
 
 /* upload/select popup */
-fbrowser.image .photo-album-image-wrapper { margin-left: 10px; }
+fbrowser.photos .photo-album-image-wrapper { margin-left: 10px; }
 #message-preview { margin-top: 15px; }
 #message-preview span { width: 100%; }
 #message-preview .mail-count, #message-preview .mail-delete { display:none; }