Move FileBrowser to own namespace & Bugfix album usage
parent
3607aa32ca
commit
051253a745
|
@ -241,7 +241,6 @@ 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?'),
|
||||
|
|
|
@ -207,7 +207,7 @@ class Photo
|
|||
public static function getBrowsablePhotosForUser(int $uid, string $album = null): array
|
||||
{
|
||||
if (!empty($album)) {
|
||||
$sqlExtra = sprintf("AND `album` = '%S' ", DBA::escape($album));
|
||||
$sqlExtra = sprintf("AND `album` = '%s' ", DBA::escape($album));
|
||||
$sqlExtra2 = "";
|
||||
} else {
|
||||
$sqlExtra = '';
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Profile\Attachment;
|
||||
namespace Friendica\Module\Media;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
|
@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Model\Attach;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -36,7 +37,7 @@ use Psr\Log\LoggerInterface;
|
|||
/**
|
||||
* Browser for Attachments
|
||||
*/
|
||||
class Browser extends BaseModule
|
||||
class AttachmentBrowser extends BaseModule
|
||||
{
|
||||
/** @var IHandleUserSessions */
|
||||
protected $session;
|
||||
|
@ -54,7 +55,7 @@ class Browser extends BaseModule
|
|||
protected function content(array $request = []): string
|
||||
{
|
||||
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
|
||||
|
@ -68,7 +69,7 @@ class Browser extends BaseModule
|
|||
|
||||
$fileArray = array_map([$this, 'map_files'], $files);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
|
||||
$output = Renderer::replaceMacros($tpl, [
|
||||
'$type' => 'attachment',
|
||||
'$path' => ['' => $this->t('Files')],
|
||||
|
@ -88,8 +89,8 @@ class Browser extends BaseModule
|
|||
|
||||
protected function map_files(array $record): array
|
||||
{
|
||||
list($m1, $m2) = explode('/', $record['filetype']);
|
||||
$filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'zip');
|
||||
[$m1, $m2] = explode('/', $record['filetype']);
|
||||
$filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'text');
|
||||
|
||||
return [
|
||||
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\BaseModule;
|
||||
|
@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -37,7 +38,7 @@ use Psr\Log\LoggerInterface;
|
|||
/**
|
||||
* Browser for Photos
|
||||
*/
|
||||
class Browser extends BaseModule
|
||||
class PhotosBrowser extends BaseModule
|
||||
{
|
||||
/** @var IHandleUserSessions */
|
||||
protected $session;
|
||||
|
@ -55,7 +56,7 @@ class Browser extends BaseModule
|
|||
protected function content(array $request = []): string
|
||||
{
|
||||
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
|
||||
|
@ -78,7 +79,7 @@ class Browser extends BaseModule
|
|||
|
||||
$photosArray = array_map([$this, 'map_files'], $photos);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
|
||||
$output = Renderer::replaceMacros($tpl, [
|
||||
'$type' => 'photos',
|
||||
'$path' => $path,
|
|
@ -31,20 +31,18 @@ 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]],
|
||||
'/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]],
|
||||
'' => [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]],
|
||||
];
|
||||
|
||||
$apiRoutes = [
|
||||
|
@ -471,6 +469,12 @@ return [
|
|||
'/magic' => [Module\Magic::class, [R::GET]],
|
||||
'/manifest' => [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' => [
|
||||
'[/]' => [Module\Moderation\Summary::class, [R::GET]],
|
||||
|
||||
|
|
|
@ -1095,7 +1095,7 @@ var Dialog = {
|
|||
if (id !== undefined) {
|
||||
hash = hash + "-" + id;
|
||||
}
|
||||
return '/profile/' + localNickname + '/' + type + '/browser?mode=minimal#' + hash;
|
||||
return 'media/' + type + '/browser?mode=minimal#' + hash;
|
||||
},
|
||||
|
||||
_get_size: function() {
|
||||
|
|
|
@ -155,7 +155,7 @@ const FileBrowser = {
|
|||
_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;
|
||||
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
|
||||
}
|
||||
};
|
||||
// @license-end
|
|
@ -2,7 +2,7 @@
|
|||
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 type="text/javascript" src="view/js/module/media/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
FileBrowser.init("{{$nickname}}", "{{$type}}");
|
|
@ -132,7 +132,7 @@ Dialog.show = function (url, title) {
|
|||
Dialog._get_url = function (type, name, id) {
|
||||
var hash = name;
|
||||
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.
|
||||
|
@ -159,14 +159,14 @@ Dialog._load = function (url) {
|
|||
let filebrowser = document.getElementById("filebrowser");
|
||||
|
||||
// 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) {
|
||||
return; //not fbrowser
|
||||
}
|
||||
|
||||
// Initialize the filebrowser.
|
||||
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]);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -246,7 +246,7 @@ var FileBrowser = {
|
|||
_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";
|
||||
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
|
||||
}
|
||||
};
|
||||
// @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 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}}",
|
||||
|
|
Loading…
Reference in New Issue