mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
The data for the language display is now fetched on demand
This commit is contained in:
parent
50b1de5959
commit
b40687081e
7 changed files with 80 additions and 8 deletions
|
@ -440,7 +440,7 @@ class Item
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($item['language'])) {
|
if (!empty($item['language'])) {
|
||||||
$menu[$this->l10n->t('Languages')] = 'javascript:alert(\'' . ItemModel::getLanguageMessage($item) . '\');';
|
$menu[$this->l10n->t('Languages')] = 'javascript:displayLanguage(' . $item['uri-id'] . ');';
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu[$this->l10n->t('Search Text')] = 'javascript:displaySearchText(' . $item['uri-id'] . ');';
|
$menu[$this->l10n->t('Search Text')] = 'javascript:displaySearchText(' . $item['uri-id'] . ');';
|
||||||
|
|
67
src/Module/Item/Language.php
Normal file
67
src/Module/Item/Language.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (C) 2010-2024, the Friendica project
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Module\Item;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
|
use Friendica\Module\Api\ApiResponse;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
|
use Friendica\Util\Profiler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the language of a given item uri-id
|
||||||
|
*/
|
||||||
|
class Language extends BaseModule
|
||||||
|
{
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $session;
|
||||||
|
|
||||||
|
public function __construct(IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
|
$this->session = $session;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function rawContent(array $request = [])
|
||||||
|
{
|
||||||
|
if (!$this->session->isAuthenticated()) {
|
||||||
|
throw new HttpException\ForbiddenException($this->l10n->t('Access denied.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->parameters['id'])) {
|
||||||
|
throw new HTTPException\BadRequestException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = Post::selectFirstForUser($this->session->getLocalUserId(), ['language'], ['uid' => [0, $this->session->getLocalUserId()], 'uri-id' => $this->parameters['id']]);
|
||||||
|
if (empty($item)) {
|
||||||
|
throw new HTTPException\NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->httpExit(Item::getLanguageMessage($item));
|
||||||
|
}
|
||||||
|
}
|
|
@ -521,7 +521,7 @@ class Post
|
||||||
|
|
||||||
$languages = [];
|
$languages = [];
|
||||||
if (!empty($item['language'])) {
|
if (!empty($item['language'])) {
|
||||||
$languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)];
|
$languages = DI::l10n()->t('Languages');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) {
|
if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) {
|
||||||
|
|
|
@ -390,8 +390,6 @@ return [
|
||||||
'/event/{mode:edit|copy}/{id:\d+}' => [Module\Calendar\Event\Form::class, [R::GET ]],
|
'/event/{mode:edit|copy}/{id:\d+}' => [Module\Calendar\Event\Form::class, [R::GET ]],
|
||||||
],
|
],
|
||||||
|
|
||||||
// '/callback/searchtext',
|
|
||||||
|
|
||||||
'/channel[/{content}]' => [Module\Conversation\Channel::class, [R::GET]],
|
'/channel[/{content}]' => [Module\Conversation\Channel::class, [R::GET]],
|
||||||
'/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],
|
'/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],
|
||||||
|
|
||||||
|
@ -482,9 +480,10 @@ return [
|
||||||
'/activity/{verb}' => [Module\Item\Activity::class, [ R::POST]],
|
'/activity/{verb}' => [Module\Item\Activity::class, [ R::POST]],
|
||||||
'/follow' => [Module\Item\Follow::class, [ R::POST]],
|
'/follow' => [Module\Item\Follow::class, [ R::POST]],
|
||||||
'/ignore' => [Module\Item\Ignore::class, [ R::POST]],
|
'/ignore' => [Module\Item\Ignore::class, [ R::POST]],
|
||||||
|
'/language' => [Module\Item\Language::class, [R::GET]],
|
||||||
'/pin' => [Module\Item\Pin::class, [ R::POST]],
|
'/pin' => [Module\Item\Pin::class, [ R::POST]],
|
||||||
'/star' => [Module\Item\Star::class, [ R::POST]],
|
|
||||||
'/searchtext' => [Module\Item\Searchtext::class, [R::GET]],
|
'/searchtext' => [Module\Item\Searchtext::class, [R::GET]],
|
||||||
|
'/star' => [Module\Item\Star::class, [ R::POST]],
|
||||||
],
|
],
|
||||||
|
|
||||||
'/localtime' => [Module\Debug\Localtime::class, [R::GET, R::POST]],
|
'/localtime' => [Module\Debug\Localtime::class, [R::GET, R::POST]],
|
||||||
|
|
|
@ -803,6 +803,12 @@ function displaySearchText(id) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayLanguage(id) {
|
||||||
|
$.get('item/' + id + '/language', function(data) {
|
||||||
|
alert(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var lockvisible = false;
|
var lockvisible = false;
|
||||||
|
|
||||||
function lockview(event, type, id) {
|
function lockview(event, type, id) {
|
||||||
|
|
|
@ -221,7 +221,7 @@
|
||||||
|
|
||||||
{{if $item.language}}
|
{{if $item.language}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="language-{{$item.id}}" href="javascript:alert('{{$item.language.1}}');" class="btn-link filer-item language-icon" title="{{$item.language.0}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language.0}}</a>
|
<a id="language-{{$item.id}}" href="javascript:displayLanguage({{$item.uriid}});" class="btn-link filer-item language-icon" title="{{$item.language}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
|
|
||||||
{{if $item.language}}
|
{{if $item.language}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="language-{{$item.id}}" href="javascript:alert('{{$item.language.1}}');" class="btn-link filer-item language-icon" title="{{$item.language.0}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language.0}}</a>
|
<a id="language-{{$item.id}}" href="javascript:displayLanguage({{$item.uriid}});" class="btn-link filer-item language-icon" title="{{$item.language}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
|
|
||||||
{{if $item.language}}
|
{{if $item.language}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="language-{{$item.id}}" href="javascript:alert('{{$item.language.1}}');" class="btn-link filer-item language-icon" title="{{$item.language.0}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language.0}}</a>
|
<a id="language-{{$item.id}}" href="javascript:displayLanguage({{$item.uriid}});" class="btn-link filer-item language-icon" title="{{$item.language}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue