mirror of
https://github.com/friendica/friendica
synced 2025-04-30 00:24:24 +02:00
Merge remote-tracking branch 'upstream/develop' into share-rework
This commit is contained in:
commit
1a0b63659b
176 changed files with 6001 additions and 5369 deletions
|
@ -32,8 +32,8 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -80,22 +80,25 @@ class Conversation
|
|||
private $mode;
|
||||
/** @var IHandleSessions */
|
||||
private $session;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleSessions $session)
|
||||
public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleSessions $session, IHandleUserSessions $userSession)
|
||||
{
|
||||
$this->activity = $activity;
|
||||
$this->item = $item;
|
||||
$this->config = $config;
|
||||
$this->mode = $mode;
|
||||
$this->baseURL = $baseURL;
|
||||
$this->profiler = $profiler;
|
||||
$this->logger = $logger;
|
||||
$this->l10n = $l10n;
|
||||
$this->args = $args;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->page = $page;
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$this->activity = $activity;
|
||||
$this->item = $item;
|
||||
$this->config = $config;
|
||||
$this->mode = $mode;
|
||||
$this->baseURL = $baseURL;
|
||||
$this->profiler = $profiler;
|
||||
$this->logger = $logger;
|
||||
$this->l10n = $l10n;
|
||||
$this->args = $args;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->page = $page;
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +175,7 @@ class Conversation
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Session::getPublicContact() == $activity['author-id']) {
|
||||
if ($this->userSession->getPublicContactId() == $activity['author-id']) {
|
||||
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
|
||||
}
|
||||
|
||||
|
@ -297,7 +300,7 @@ class Conversation
|
|||
$x['bang'] = $x['bang'] ?? '';
|
||||
$x['visitor'] = $x['visitor'] ?? 'block';
|
||||
$x['is_owner'] = $x['is_owner'] ?? true;
|
||||
$x['profile_uid'] = $x['profile_uid'] ?? Session::getLocalUser();
|
||||
$x['profile_uid'] = $x['profile_uid'] ?? $this->userSession->getLocalUserId();
|
||||
|
||||
|
||||
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
|
||||
|
@ -360,7 +363,7 @@ class Conversation
|
|||
'$title' => $x['title'] ?? '',
|
||||
'$placeholdertitle' => $this->l10n->t('Set title'),
|
||||
'$category' => $x['category'] ?? '',
|
||||
'$placeholdercategory' => Feature::isEnabled(Session::getLocalUser(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
||||
'$placeholdercategory' => Feature::isEnabled($this->userSession->getLocalUserId(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
||||
'$scheduled_at' => Temporal::getDateTimeField(
|
||||
new \DateTime(),
|
||||
new \DateTime('now + 6 months'),
|
||||
|
@ -398,7 +401,7 @@ class Conversation
|
|||
'$browser' => $this->l10n->t('Browser'),
|
||||
|
||||
'$compose_link_title' => $this->l10n->t('Open Compose page'),
|
||||
'$always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose', false),
|
||||
'$always_open_compose' => $this->pConfig->get($this->userSession->getLocalUserId(), 'frio', 'always_open_compose', false),
|
||||
]);
|
||||
|
||||
|
||||
|
@ -437,7 +440,7 @@ class Conversation
|
|||
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
||||
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
|
||||
|
||||
$ssl_state = (bool)Session::getLocalUser();
|
||||
$ssl_state = (bool)$this->userSession->getLocalUserId();
|
||||
|
||||
$live_update_div = '';
|
||||
|
||||
|
@ -489,11 +492,11 @@ class Conversation
|
|||
}
|
||||
}
|
||||
} elseif ($mode === 'notes') {
|
||||
$items = $this->addChildren($items, false, $order, Session::getLocalUser(), $mode);
|
||||
$items = $this->addChildren($items, false, $order, $this->userSession->getLocalUserId(), $mode);
|
||||
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = " . Session::getLocalUser()
|
||||
. "<script> var profile_uid = " . $this->userSession->getLocalUserId()
|
||||
. "; var netargs = '/?f='; </script>\r\n";
|
||||
}
|
||||
} elseif ($mode === 'display') {
|
||||
|
@ -527,7 +530,7 @@ class Conversation
|
|||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||
}
|
||||
|
||||
$page_dropping = Session::getLocalUser() && Session::getLocalUser() == $uid;
|
||||
$page_dropping = $this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $uid;
|
||||
|
||||
if (!$update) {
|
||||
$_SESSION['return_path'] = $this->args->getQueryString();
|
||||
|
@ -547,7 +550,7 @@ class Conversation
|
|||
'announce' => [],
|
||||
];
|
||||
|
||||
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
||||
if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||
unset($conv_responses['dislike']);
|
||||
}
|
||||
|
||||
|
@ -565,7 +568,7 @@ class Conversation
|
|||
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!$this->userSession->getLocalUserId()) {
|
||||
$writable = false;
|
||||
}
|
||||
|
||||
|
@ -598,7 +601,7 @@ class Conversation
|
|||
$threadsid++;
|
||||
|
||||
// prevent private email from leaking.
|
||||
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
|
||||
if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -642,17 +645,17 @@ class Conversation
|
|||
'announce' => null,
|
||||
];
|
||||
|
||||
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
||||
if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||
unset($likebuttons['dislike']);
|
||||
}
|
||||
|
||||
$body_html = ItemModel::prepareBody($item, true, $preview);
|
||||
|
||||
[$categories, $folders] = $this->item->determineCategoriesTerms($item, Session::getLocalUser());
|
||||
[$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->userSession->getLocalUserId());
|
||||
|
||||
if (!empty($item['title'])) {
|
||||
$title = $item['title'];
|
||||
} elseif (!empty($item['content-warning']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
|
||||
} elseif (!empty($item['content-warning']) && $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'disable_cw', false)) {
|
||||
$title = ucfirst($item['content-warning']);
|
||||
} else {
|
||||
$title = '';
|
||||
|
@ -746,7 +749,7 @@ class Conversation
|
|||
$this->builtinActivityPuller($item, $conv_responses);
|
||||
|
||||
// Only add what is visible
|
||||
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
|
||||
if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -791,11 +794,11 @@ class Conversation
|
|||
|
||||
private function getBlocklist(): array
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!$this->userSession->getLocalUserId()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(Session::getLocalUser(), 'system', 'blocked'));
|
||||
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'blocked'));
|
||||
if (empty($str_blocked)) {
|
||||
return [];
|
||||
}
|
||||
|
@ -865,7 +868,7 @@ class Conversation
|
|||
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
|
||||
break;
|
||||
case ItemModel::PR_ANNOUNCEMENT:
|
||||
if (!empty($row['causer-id']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'display_resharer')) {
|
||||
if (!empty($row['causer-id']) && $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'display_resharer')) {
|
||||
$row['owner-id'] = $row['causer-id'];
|
||||
$row['owner-link'] = $row['causer-link'];
|
||||
$row['owner-avatar'] = $row['causer-avatar'];
|
||||
|
@ -1217,7 +1220,7 @@ class Conversation
|
|||
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
|
||||
}
|
||||
|
||||
if (!$this->pConfig->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0)) {
|
||||
if (!$this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'no_smart_threading', 0)) {
|
||||
foreach ($parents as $i => $parent) {
|
||||
$parents[$i] = $this->smartFlattenConversation($parent);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Content;
|
|||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -224,7 +223,7 @@ class ForumManager
|
|||
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
|
||||
AND `contact`.`uid` = ?
|
||||
GROUP BY `contact`.`id`",
|
||||
Session::getLocalUser(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, Session::getLocalUser()
|
||||
DI::userSession()->getLocalUserId(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, DI::userSession()->getLocalUserId()
|
||||
);
|
||||
|
||||
return DBA::toArray($stmtContacts);
|
||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -53,12 +53,15 @@ class Item
|
|||
private $l10n;
|
||||
/** @var Profiler */
|
||||
private $profiler;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(Profiler $profiler, Activity $activity, L10n $l10n)
|
||||
public function __construct(Profiler $profiler, Activity $activity, L10n $l10n, IHandleUserSessions $userSession)
|
||||
{
|
||||
$this->profiler = $profiler;
|
||||
$this->activity = $activity;
|
||||
$this->l10n = $l10n;
|
||||
$this->profiler = $profiler;
|
||||
$this->activity = $activity;
|
||||
$this->l10n = $l10n;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +113,7 @@ class Item
|
|||
$categories[] = [
|
||||
'name' => $savedFolderName,
|
||||
'url' => $url,
|
||||
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
|
@ -121,12 +124,12 @@ class Item
|
|||
$categories[count($categories) - 1]['last'] = true;
|
||||
}
|
||||
|
||||
if (Session::getLocalUser() == $uid) {
|
||||
if ($this->userSession->getLocalUserId() == $uid) {
|
||||
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
|
||||
$folders[] = [
|
||||
'name' => $savedFolderName,
|
||||
'url' => "#",
|
||||
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
|
@ -332,7 +335,7 @@ class Item
|
|||
$sub_link = $contact_url = $pm_url = $status_link = '';
|
||||
$photos_link = $posts_link = $block_link = $ignore_link = '';
|
||||
|
||||
if (Session::getLocalUser() && Session::getLocalUser() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||
if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
|
||||
}
|
||||
|
||||
|
@ -349,7 +352,7 @@ class Item
|
|||
$pcid = $item['author-id'];
|
||||
$network = '';
|
||||
$rel = 0;
|
||||
$condition = ['uid' => Session::getLocalUser(), 'uri-id' => $item['author-uri-id']];
|
||||
$condition = ['uid' => $this->userSession->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
|
||||
if (DBA::isResult($contact)) {
|
||||
$cid = $contact['id'];
|
||||
|
@ -379,7 +382,7 @@ class Item
|
|||
}
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if ($this->userSession->getLocalUserId()) {
|
||||
$menu = [
|
||||
$this->l10n->t('Follow Thread') => $sub_link,
|
||||
$this->l10n->t('View Status') => $status_link,
|
||||
|
@ -440,7 +443,7 @@ class Item
|
|||
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
|
||||
$item['object-type'] === Activity\ObjectType::NOTE &&
|
||||
empty($item['self']) &&
|
||||
$item['uid'] == Session::getLocalUser())
|
||||
$item['uid'] == $this->userSession->getLocalUserId())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Content;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -127,7 +126,7 @@ class Nav
|
|||
|
||||
//Don't populate apps_menu if apps are private
|
||||
$privateapps = DI::config()->get('config', 'private_addons', false);
|
||||
if (Session::getLocalUser() || !$privateapps) {
|
||||
if (DI::userSession()->getLocalUserId() || !$privateapps) {
|
||||
$arr = ['app_menu' => self::$app_menu];
|
||||
|
||||
Hook::callAll('app_menu', $arr);
|
||||
|
@ -149,7 +148,7 @@ class Nav
|
|||
*/
|
||||
private static function getInfo(App $a): array
|
||||
{
|
||||
$ssl_state = (bool) Session::getLocalUser();
|
||||
$ssl_state = (bool) DI::userSession()->getLocalUserId();
|
||||
|
||||
/*
|
||||
* Our network is distributed, and as you visit friends some of the
|
||||
|
@ -182,7 +181,7 @@ class Nav
|
|||
$userinfo = null;
|
||||
|
||||
// nav links: array of array('href', 'text', 'extra css classes', 'title')
|
||||
if (Session::isAuthenticated()) {
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$nav['logout'] = ['logout', DI::l10n()->t('Logout'), '', DI::l10n()->t('End this session')];
|
||||
} else {
|
||||
$nav['login'] = ['login', DI::l10n()->t('Login'), (DI::args()->getModuleName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')];
|
||||
|
@ -211,11 +210,11 @@ class Nav
|
|||
$homelink = DI::session()->get('visitor_home', '');
|
||||
}
|
||||
|
||||
if ((DI::args()->getModuleName() != 'home') && (! (Session::getLocalUser()))) {
|
||||
if (DI::args()->getModuleName() != 'home' && ! DI::userSession()->getLocalUserId()) {
|
||||
$nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')];
|
||||
}
|
||||
|
||||
if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !Session::isAuthenticated()) {
|
||||
if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !DI::userSession()->isAuthenticated()) {
|
||||
$nav['register'] = ['register', DI::l10n()->t('Register'), '', DI::l10n()->t('Create an account')];
|
||||
}
|
||||
|
||||
|
@ -229,7 +228,7 @@ class Nav
|
|||
$nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')];
|
||||
}
|
||||
|
||||
if (Session::getLocalUser() || !DI::config()->get('system', 'local_search')) {
|
||||
if (DI::userSession()->getLocalUserId() || !DI::config()->get('system', 'local_search')) {
|
||||
$nav['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')];
|
||||
|
||||
$nav['searchoption'] = [
|
||||
|
@ -252,12 +251,12 @@ class Nav
|
|||
}
|
||||
}
|
||||
|
||||
if ((Session::getLocalUser() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
|
||||
if ((DI::userSession()->getLocalUserId() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
|
||||
!(DI::config()->get('system', 'community_page_style') == Community::DISABLED)) {
|
||||
$nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')];
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$nav['events'] = ['events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
|
||||
}
|
||||
|
||||
|
@ -270,7 +269,7 @@ class Nav
|
|||
}
|
||||
|
||||
// The following nav links are only show to logged in users
|
||||
if (Session::getLocalUser() && !empty($a->getLoggedInUserNickname())) {
|
||||
if (DI::userSession()->getLocalUserId() && !empty($a->getLoggedInUserNickname())) {
|
||||
$nav['network'] = ['network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
|
||||
|
||||
$nav['home'] = ['profile/' . $a->getLoggedInUserNickname(), DI::l10n()->t('Home'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
|
@ -288,7 +287,7 @@ class Nav
|
|||
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
|
||||
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
|
||||
|
||||
if (User::hasIdentities(DI::session()->get('submanage') ?: Session::getLocalUser())) {
|
||||
if (User::hasIdentities(DI::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId())) {
|
||||
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
|
||||
}
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ class OEmbed
|
|||
* @param string $title Optional title (default: what comes from OEmbed object)
|
||||
* @return string Formatted HTML
|
||||
*/
|
||||
public static function getHTML(string $url, string $title = '')
|
||||
public static function getHTML(string $url, string $title = ''): string
|
||||
{
|
||||
$o = self::fetchURL($url, !self::isAllowedURL($url));
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -214,7 +213,7 @@ class Smilies
|
|||
public static function replaceFromArray(string $text, array $smilies, bool $no_images = false): string
|
||||
{
|
||||
if (intval(DI::config()->get('system', 'no_smilies'))
|
||||
|| (Session::getLocalUser() && intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies')))
|
||||
|| (DI::userSession()->getLocalUserId() && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smilies')))
|
||||
) {
|
||||
return $text;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Core\Cache\Enum\Duration;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -67,7 +66,7 @@ class Widget
|
|||
$global_dir = Search::getGlobalDirectory();
|
||||
|
||||
if (DI::config()->get('system', 'invitation_only')) {
|
||||
$x = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining'));
|
||||
$x = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining'));
|
||||
if ($x || DI::app()->isSiteAdmin()) {
|
||||
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
|
||||
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
|
||||
|
@ -196,7 +195,7 @@ class Widget
|
|||
*/
|
||||
public static function groups(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -205,7 +204,7 @@ class Widget
|
|||
'ref' => $group['id'],
|
||||
'name' => $group['name']
|
||||
];
|
||||
}, Group::getByUserId(Session::getLocalUser()));
|
||||
}, Group::getByUserId(DI::userSession()->getLocalUserId()));
|
||||
|
||||
return self::filter(
|
||||
'group',
|
||||
|
@ -228,7 +227,7 @@ class Widget
|
|||
*/
|
||||
public static function contactRels(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -259,13 +258,13 @@ class Widget
|
|||
*/
|
||||
public static function networks(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$networks = self::unavailableNetworks();
|
||||
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
||||
$condition = array_merge([$query], array_merge([Session::getLocalUser()], $networks));
|
||||
$condition = array_merge([$query], array_merge([DI::userSession()->getLocalUserId()], $networks));
|
||||
|
||||
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
|
||||
|
||||
|
@ -300,12 +299,12 @@ class Widget
|
|||
*/
|
||||
public static function fileAs(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$terms = [];
|
||||
foreach (Post\Category::getArray(Session::getLocalUser(), Post\Category::FILE) as $savedFolderName) {
|
||||
foreach (Post\Category::getArray(DI::userSession()->getLocalUserId(), Post\Category::FILE) as $savedFolderName) {
|
||||
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
|
||||
}
|
||||
|
||||
|
@ -362,11 +361,11 @@ class Widget
|
|||
*/
|
||||
public static function commonFriendsVisitor(int $uid, string $nickname): string
|
||||
{
|
||||
if (Session::getLocalUser() == $uid) {
|
||||
if (DI::userSession()->getLocalUserId() == $uid) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$visitorPCid = Session::getLocalUser() ? Contact::getPublicIdByUserId(Session::getLocalUser()) : Session::getRemoteUser();
|
||||
$visitorPCid = DI::userSession()->getPublicContactId() ?: DI::userSession()->getRemoteUserId();
|
||||
if (!$visitorPCid) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -34,12 +34,14 @@ class CalendarExport
|
|||
{
|
||||
/**
|
||||
* Get the events widget.
|
||||
*
|
||||
* @param int $uid
|
||||
*
|
||||
* @return string Formated HTML of the calendar widget.
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getHTML(int $uid = 0) {
|
||||
public static function getHTML(int $uid = 0): string
|
||||
{
|
||||
if (empty($uid)) {
|
||||
return '';
|
||||
}
|
||||
|
@ -49,11 +51,11 @@ class CalendarExport
|
|||
return '';
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("widget/events.tpl");
|
||||
$tpl = Renderer::getMarkupTemplate('widget/events.tpl');
|
||||
$return = Renderer::replaceMacros($tpl, [
|
||||
'$etitle' => DI::l10n()->t("Export"),
|
||||
'$export_ical' => DI::l10n()->t("Export calendar as ical"),
|
||||
'$export_csv' => DI::l10n()->t("Export calendar as csv"),
|
||||
'$etitle' => DI::l10n()->t('Export'),
|
||||
'$export_ical' => DI::l10n()->t('Export calendar as ical'),
|
||||
'$export_csv' => DI::l10n()->t('Export calendar as csv'),
|
||||
'$user' => $user['nickname']
|
||||
]);
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ class ContactBlock
|
|||
*
|
||||
* @template widget/contacts.tpl
|
||||
* @hook contact_block_end (contacts=>array, output=>string)
|
||||
* @return string
|
||||
* @return string Formatted HTML code or empty string
|
||||
*/
|
||||
public static function getHTML(array $profile, int $visitor_uid = null)
|
||||
public static function getHTML(array $profile, int $visitor_uid = null): string
|
||||
{
|
||||
$o = '';
|
||||
|
||||
|
@ -66,13 +66,13 @@ class ContactBlock
|
|||
$contacts = [];
|
||||
|
||||
$total = DBA::count('contact', [
|
||||
'uid' => $profile['uid'],
|
||||
'self' => false,
|
||||
'uid' => $profile['uid'],
|
||||
'self' => false,
|
||||
'blocked' => false,
|
||||
'pending' => false,
|
||||
'hidden' => false,
|
||||
'hidden' => false,
|
||||
'archive' => false,
|
||||
'failed' => false,
|
||||
'failed' => false,
|
||||
'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::FEED],
|
||||
]);
|
||||
|
||||
|
@ -89,15 +89,17 @@ class ContactBlock
|
|||
}
|
||||
|
||||
$personal_contacts = DBA::selectToArray('contact', ['uri-id'], [
|
||||
'uid' => $profile['uid'],
|
||||
'self' => false,
|
||||
'uid' => $profile['uid'],
|
||||
'self' => false,
|
||||
'blocked' => false,
|
||||
'pending' => false,
|
||||
'hidden' => false,
|
||||
'hidden' => false,
|
||||
'archive' => false,
|
||||
'rel' => $rel,
|
||||
'rel' => $rel,
|
||||
'network' => Protocol::FEDERATED,
|
||||
], ['limit' => $shown]);
|
||||
], [
|
||||
'limit' => $shown,
|
||||
]);
|
||||
|
||||
$contact_uriids = array_column($personal_contacts, 'uri-id');
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Content\Widget;
|
|||
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -35,10 +34,10 @@ class SavedSearches
|
|||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getHTML($return_url, $search = '')
|
||||
public static function getHTML(string $return_url, string $search = ''): string
|
||||
{
|
||||
$saved = [];
|
||||
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => Session::getLocalUser()]);
|
||||
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
while ($saved_search = DBA::fetch($saved_searches)) {
|
||||
$saved[] = [
|
||||
'id' => $saved_search['id'],
|
||||
|
|
|
@ -46,7 +46,7 @@ class TagCloud
|
|||
* @return string HTML formatted output.
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = Tag::HASHTAG)
|
||||
public static function getHTML(int $uid, int $count = 0, int $owner_id = 0, string $flags = '', int $type = Tag::HASHTAG): string
|
||||
{
|
||||
$o = '';
|
||||
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
|
||||
|
@ -56,17 +56,17 @@ class TagCloud
|
|||
|
||||
$tags = [];
|
||||
foreach ($r as $rr) {
|
||||
$tag['level'] = $rr[2];
|
||||
$tag['url'] = $url . '?tag=' . urlencode($rr[0]);
|
||||
$tag['name'] = $rr[0];
|
||||
|
||||
$tags[] = $tag;
|
||||
$tags[] = [
|
||||
'level' => $rr[2],
|
||||
'url' => $url . '?tag=' . urlencode($rr[0]),
|
||||
'name' => $rr[0],
|
||||
];
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->t('Tags'),
|
||||
'$tags' => $tags
|
||||
'$tags' => $tags
|
||||
]);
|
||||
}
|
||||
return $o;
|
||||
|
|
|
@ -35,10 +35,11 @@ class TrendingTags
|
|||
/**
|
||||
* @param string $content 'global' (all posts) or 'local' (this node's posts only)
|
||||
* @param int $period Period in hours to consider posts
|
||||
* @return string
|
||||
*
|
||||
* @return string Formatted HTML code
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getHTML($content = 'global', int $period = 24)
|
||||
public static function getHTML(string $content = 'global', int $period = 24): string
|
||||
{
|
||||
if ($content == 'local') {
|
||||
$tags = Tag::getLocalTrendingHashtags($period, 20);
|
||||
|
@ -49,8 +50,8 @@ class TrendingTags
|
|||
$tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period),
|
||||
'$more' => DI::l10n()->t('More Trending Tags'),
|
||||
'$tags' => $tags,
|
||||
'$more' => DI::l10n()->t('More Trending Tags'),
|
||||
'$tags' => $tags,
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -45,7 +44,7 @@ class VCard
|
|||
* @template widget/vcard.tpl
|
||||
* @return string
|
||||
*/
|
||||
public static function getHTML(array $contact)
|
||||
public static function getHTML(array $contact): string
|
||||
{
|
||||
if (!isset($contact['network']) || !isset($contact['id'])) {
|
||||
Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
|
||||
|
@ -65,13 +64,13 @@ class VCard
|
|||
|
||||
$photo = Contact::getPhoto($contact);
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
if ($contact['uid']) {
|
||||
$id = $contact['id'];
|
||||
$rel = $contact['rel'];
|
||||
$pending = $contact['pending'];
|
||||
} else {
|
||||
$pcontact = Contact::selectFirst([], ['uid' => Session::getLocalUser(), 'uri-id' => $contact['uri-id']]);
|
||||
$pcontact = Contact::selectFirst([], ['uid' => DI::userSession()->getLocalUserId(), 'uri-id' => $contact['uri-id']]);
|
||||
|
||||
$id = $pcontact['id'] ?? 0;
|
||||
$rel = $pcontact['rel'] ?? Contact::NOTHING;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue