Move FileBrowser to own namespace & Bugfix album usage
This commit is contained in:
parent
3607aa32ca
commit
051253a745
12 changed files with 38 additions and 34 deletions
|
@ -241,7 +241,6 @@ class Page implements ArrayAccess
|
||||||
* being first
|
* being first
|
||||||
*/
|
*/
|
||||||
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
|
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
|
||||||
'$local_nickname' => $app->getLoggedInUserNickname(),
|
|
||||||
'$local_user' => $localUID,
|
'$local_user' => $localUID,
|
||||||
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
||||||
'$delitem' => $l10n->t('Delete this item?'),
|
'$delitem' => $l10n->t('Delete this item?'),
|
||||||
|
|
|
@ -207,7 +207,7 @@ class Photo
|
||||||
public static function getBrowsablePhotosForUser(int $uid, string $album = null): array
|
public static function getBrowsablePhotosForUser(int $uid, string $album = null): array
|
||||||
{
|
{
|
||||||
if (!empty($album)) {
|
if (!empty($album)) {
|
||||||
$sqlExtra = sprintf("AND `album` = '%S' ", DBA::escape($album));
|
$sqlExtra = sprintf("AND `album` = '%s' ", DBA::escape($album));
|
||||||
$sqlExtra2 = "";
|
$sqlExtra2 = "";
|
||||||
} else {
|
} else {
|
||||||
$sqlExtra = '';
|
$sqlExtra = '';
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module\Profile\Attachment;
|
namespace Friendica\Module\Media;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Attach;
|
use Friendica\Model\Attach;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
@ -36,7 +37,7 @@ use Psr\Log\LoggerInterface;
|
||||||
/**
|
/**
|
||||||
* Browser for Attachments
|
* Browser for Attachments
|
||||||
*/
|
*/
|
||||||
class Browser extends BaseModule
|
class AttachmentBrowser extends BaseModule
|
||||||
{
|
{
|
||||||
/** @var IHandleUserSessions */
|
/** @var IHandleUserSessions */
|
||||||
protected $session;
|
protected $session;
|
||||||
|
@ -54,7 +55,7 @@ class Browser extends BaseModule
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!$this->session->getLocalUserId()) {
|
if (!$this->session->getLocalUserId()) {
|
||||||
$this->baseUrl->redirect();
|
throw new UnauthorizedException($this->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed to match the correct template in a module that uses a different theme than the user/site/default
|
// Needed to match the correct template in a module that uses a different theme than the user/site/default
|
||||||
|
@ -68,7 +69,7 @@ class Browser extends BaseModule
|
||||||
|
|
||||||
$fileArray = array_map([$this, 'map_files'], $files);
|
$fileArray = array_map([$this, 'map_files'], $files);
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
|
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
|
||||||
$output = Renderer::replaceMacros($tpl, [
|
$output = Renderer::replaceMacros($tpl, [
|
||||||
'$type' => 'attachment',
|
'$type' => 'attachment',
|
||||||
'$path' => ['' => $this->t('Files')],
|
'$path' => ['' => $this->t('Files')],
|
||||||
|
@ -88,8 +89,8 @@ class Browser extends BaseModule
|
||||||
|
|
||||||
protected function map_files(array $record): array
|
protected function map_files(array $record): array
|
||||||
{
|
{
|
||||||
list($m1, $m2) = explode('/', $record['filetype']);
|
[$m1, $m2] = explode('/', $record['filetype']);
|
||||||
$filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'zip');
|
$filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'text');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf('%s/attach/%s', $this->baseUrl, $record['id']),
|
sprintf('%s/attach/%s', $this->baseUrl, $record['id']),
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module\Profile\Photos;
|
namespace Friendica\Module\Media;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -37,7 +38,7 @@ use Psr\Log\LoggerInterface;
|
||||||
/**
|
/**
|
||||||
* Browser for Photos
|
* Browser for Photos
|
||||||
*/
|
*/
|
||||||
class Browser extends BaseModule
|
class PhotosBrowser extends BaseModule
|
||||||
{
|
{
|
||||||
/** @var IHandleUserSessions */
|
/** @var IHandleUserSessions */
|
||||||
protected $session;
|
protected $session;
|
||||||
|
@ -55,7 +56,7 @@ class Browser extends BaseModule
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!$this->session->getLocalUserId()) {
|
if (!$this->session->getLocalUserId()) {
|
||||||
$this->baseUrl->redirect();
|
throw new UnauthorizedException($this->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed to match the correct template in a module that uses a different theme than the user/site/default
|
// Needed to match the correct template in a module that uses a different theme than the user/site/default
|
||||||
|
@ -78,7 +79,7 @@ class Browser extends BaseModule
|
||||||
|
|
||||||
$photosArray = array_map([$this, 'map_files'], $photos);
|
$photosArray = array_map([$this, 'map_files'], $photos);
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
|
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
|
||||||
$output = Renderer::replaceMacros($tpl, [
|
$output = Renderer::replaceMacros($tpl, [
|
||||||
'$type' => 'photos',
|
'$type' => 'photos',
|
||||||
'$path' => $path,
|
'$path' => $path,
|
|
@ -33,12 +33,10 @@ use Friendica\Module;
|
||||||
$profileRoutes = [
|
$profileRoutes = [
|
||||||
'' => [Module\Profile\Index::class, [R::GET]],
|
'' => [Module\Profile\Index::class, [R::GET]],
|
||||||
'/attachment/upload' => [Module\Profile\Attachment\Upload::class, [ R::POST]],
|
'/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/common' => [Module\Profile\Common::class, [R::GET]],
|
||||||
'/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
|
'/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
|
||||||
'/media' => [Module\Profile\Media::class, [R::GET]],
|
'/media' => [Module\Profile\Media::class, [R::GET]],
|
||||||
'/photos' => [Module\Profile\Photos\Index::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]],
|
'/photos/upload' => [Module\Profile\Photos\Upload::class, [ R::POST]],
|
||||||
'/profile' => [Module\Profile\Profile::class, [R::GET]],
|
'/profile' => [Module\Profile\Profile::class, [R::GET]],
|
||||||
'/remote_follow' => [Module\Profile\RemoteFollow::class, [R::GET, R::POST]],
|
'/remote_follow' => [Module\Profile\RemoteFollow::class, [R::GET, R::POST]],
|
||||||
|
@ -471,6 +469,12 @@ return [
|
||||||
'/magic' => [Module\Magic::class, [R::GET]],
|
'/magic' => [Module\Magic::class, [R::GET]],
|
||||||
'/manifest' => [Module\Manifest::class, [R::GET]],
|
'/manifest' => [Module\Manifest::class, [R::GET]],
|
||||||
'/friendica.webmanifest' => [Module\Manifest::class, [R::GET]],
|
'/friendica.webmanifest' => [Module\Manifest::class, [R::GET]],
|
||||||
|
|
||||||
|
'/media' => [
|
||||||
|
'/attachment/browser' => [Module\Media\AttachmentBrowser::class, [R::GET]],
|
||||||
|
'/photos/browser[/{album}]' => [Module\Media\PhotosBrowser::class, [R::GET]],
|
||||||
|
],
|
||||||
|
|
||||||
'/moderation' => [
|
'/moderation' => [
|
||||||
'[/]' => [Module\Moderation\Summary::class, [R::GET]],
|
'[/]' => [Module\Moderation\Summary::class, [R::GET]],
|
||||||
|
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ var Dialog = {
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
hash = hash + "-" + id;
|
hash = hash + "-" + id;
|
||||||
}
|
}
|
||||||
return '/profile/' + localNickname + '/' + type + '/browser?mode=minimal#' + hash;
|
return 'media/' + type + '/browser?mode=minimal#' + hash;
|
||||||
},
|
},
|
||||||
|
|
||||||
_get_size: function() {
|
_get_size: function() {
|
||||||
|
|
|
@ -155,7 +155,7 @@ const FileBrowser = {
|
||||||
_getUrl: function (mode, hash, folder) {
|
_getUrl: function (mode, hash, folder) {
|
||||||
let folderValue = folder !== undefined ? folder : FileBrowser.folder;
|
let folderValue = folder !== undefined ? folder : FileBrowser.folder;
|
||||||
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
|
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
|
||||||
return 'profile/' + FileBrowser.nickname + '/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
|
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// @license-end
|
// @license-end
|
|
@ -2,7 +2,7 @@
|
||||||
This is the template used by mod/fbrowser.php
|
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/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
|
||||||
<script type="text/javascript" src="view/js/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
|
<script type="text/javascript" src="view/js/module/media/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
FileBrowser.init("{{$nickname}}", "{{$type}}");
|
FileBrowser.init("{{$nickname}}", "{{$type}}");
|
|
@ -132,7 +132,7 @@ Dialog.show = function (url, title) {
|
||||||
Dialog._get_url = function (type, name, id) {
|
Dialog._get_url = function (type, name, id) {
|
||||||
var hash = name;
|
var hash = name;
|
||||||
if (id !== undefined) hash = hash + "-" + id;
|
if (id !== undefined) hash = hash + "-" + id;
|
||||||
return 'profile/' + localNickname + '/' + type + '/browser?mode=none&theme=frio#' + hash;
|
return 'media/' + type + '/browser?mode=none&theme=frio#' + hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Does load the filebrowser into the jot modal.
|
// Does load the filebrowser into the jot modal.
|
||||||
|
@ -159,14 +159,14 @@ Dialog._load = function (url) {
|
||||||
let filebrowser = document.getElementById("filebrowser");
|
let filebrowser = document.getElementById("filebrowser");
|
||||||
|
|
||||||
// Try to fetch the hash form the url.
|
// Try to fetch the hash form the url.
|
||||||
let match = url.match(/profile\/[a-z]+\/.*(#.*)/);
|
let match = url.match(/media\/[a-z]+\/.*(#.*)/);
|
||||||
if (!filebrowser || match === null) {
|
if (!filebrowser || match === null) {
|
||||||
return; //not fbrowser
|
return; //not fbrowser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the filebrowser.
|
// Initialize the filebrowser.
|
||||||
loadScript("view/js/ajaxupload.js");
|
loadScript("view/js/ajaxupload.js");
|
||||||
loadScript("view/theme/frio/js/filebrowser.js", function () {
|
loadScript("view/theme/frio/js/module/media/filebrowser.js", function () {
|
||||||
FileBrowser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]);
|
FileBrowser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -246,7 +246,7 @@ var FileBrowser = {
|
||||||
_getUrl: function (mode, folder) {
|
_getUrl: function (mode, folder) {
|
||||||
let folderValue = folder !== undefined ? folder : FileBrowser.folder;
|
let folderValue = folder !== undefined ? folder : FileBrowser.folder;
|
||||||
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
|
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
|
||||||
return 'profile/' + FileBrowser.nickname + '/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
|
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// @license-end
|
// @license-end
|
|
@ -5,7 +5,6 @@ They are loaded into the html <head> so that js functions can use them *}}
|
||||||
var updateInterval = {{$update_interval}};
|
var updateInterval = {{$update_interval}};
|
||||||
|
|
||||||
var localUser = {{if $local_user}}{{$local_user}}{{else}}false{{/if}};
|
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 = {
|
var aStr = {
|
||||||
'delitem' : "{{$delitem|escape:'javascript' nofilter}}",
|
'delitem' : "{{$delitem|escape:'javascript' nofilter}}",
|
||||||
'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}",
|
'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}",
|
||||||
|
|
Loading…
Reference in a new issue