From: Hypolite Petovan Date: Fri, 26 Apr 2019 02:06:27 +0000 (-0400) Subject: Ensure theme consistency when using filebrowser X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a88df9b25921fef25b5c9bb16347e98464d97c86;p=friendica.git Ensure theme consistency when using filebrowser - Send frio filebrowser result to current frame instead of parent one --- diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 559896acb1..faff17381b 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -11,6 +11,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Object\Image; +use Friendica\Util\Strings; /** * @param App $a @@ -27,6 +28,12 @@ function fbrowser_content(App $a) exit(); } + // Needed to match the correct template in a module that uses a different theme than the user/site/default + $theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null)); + if ($theme && is_file("view/theme/$theme/config.php")) { + $a->setCurrentTheme($theme); + } + $template_file = "filebrowser.tpl"; $o = ''; diff --git a/view/theme/frio/js/filebrowser.js b/view/theme/frio/js/filebrowser.js index 40c0fbb744..16d60b61d1 100644 --- a/view/theme/frio/js/filebrowser.js +++ b/view/theme/frio/js/filebrowser.js @@ -99,7 +99,7 @@ var FileBrowser = { // Click on album link $(".fbrowser").on("click", ".folders a, .path a", function(e) { e.preventDefault(); - var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none"; + var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none&theme=frio"; FileBrowser.folder = this.dataset.folder; FileBrowser.loadContent(url); @@ -134,7 +134,7 @@ var FileBrowser = { console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id); - parent.$("body").trigger(FileBrowser.event, [ + $("body").trigger(FileBrowser.event, [ this.dataset.filename, embed, FileBrowser.id, @@ -152,7 +152,7 @@ var FileBrowser = { e.preventDefault(); FileBrowser.type = this.getAttribute("data-mode"); $(".fbrowser").removeClass().addClass("fbrowser " + FileBrowser.type); - url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none"; + url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio"; FileBrowser.loadContent(url); }); @@ -183,10 +183,7 @@ var FileBrowser = { return; } -// location = baseurl + "/fbrowser/image/?mode=none"+location['hash']; -// location.reload(true); - - var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none"; + var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none&theme=frio"; // load new content to fbrowser window FileBrowser.loadContent(url); } @@ -214,10 +211,7 @@ var FileBrowser = { return; } -// location = baseurl + "/fbrowser/file/?mode=none"+location['hash']; -// location.reload(true); - - var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none"; + var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio"; // Load new content to fbrowser window FileBrowser.loadContent(url); } diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 1c5314c4b4..ab263bc2ab 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -120,7 +120,7 @@ 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#"+hash; + return "fbrowser/"+type+"/?mode=none&theme=frio#"+hash; }; // Does load the filebrowser into the jot modal. @@ -148,7 +148,7 @@ Dialog._load = function(url) { var type = $("#fb-type").attr("value"); // Try to fetch the hash form the url. - var match = url.match(/fbrowser\/[a-z]+\/\?mode=none(.*)/); + var match = url.match(/fbrowser\/[a-z]+\/.*(#.*)/); if (match===null) return; //not fbrowser var hash = match[1];