]> git.mxchange.org Git - friendica.git/commitdiff
Network, Channels and Community are children of timeline
authorMichael <heluecht@pirati.ca>
Sat, 9 Sep 2023 09:14:36 +0000 (09:14 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 17 Jan 2024 00:03:08 +0000 (01:03 +0100)
src/Content/Conversation/Collection/Channels.php [deleted file]
src/Content/Nav.php
src/Module/Conversation/Channel.php
src/Module/Conversation/Network.php

diff --git a/src/Content/Conversation/Collection/Channels.php b/src/Content/Conversation/Collection/Channels.php
deleted file mode 100644 (file)
index a523cc7..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * @copyright Copyright (C) 2010-2023, 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\Content\Conversation\Collection;
-
-use Friendica\BaseCollection;
-
-class Channels extends BaseCollection
-{
-}
index a8f568630fcfdd093df66d89b34953a19961c583..fa8366ed0c63cd9b9ce3af8a697f3f88f4b9aecb 100644 (file)
@@ -284,12 +284,14 @@ class Nav
                        $gdirpath = Profile::zrl($this->config->get('system', 'directory'), true);
                }
 
-               if (($this->session->getLocalUserId() || $this->config->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
-                       !($this->config->get('system', 'community_page_style') == Community::DISABLED)) {
+               if ((!$this->session->isAuthenticated() && $this->config->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
+                       !($this->config->get('system', 'community_page_style') == Community::DISABLED)
+               ) {
                        $nav['community'] = ['community', $this->l10n->t('Community'), '', $this->l10n->t('Conversations on this and other servers')];
                }
 
                if ($this->session->getLocalUserId()) {
+                       $nav['channel'] = ['channel', $this->l10n->t('Channels'), '', $this->l10n->t('Current posts, filtered by several rules')];
                        $nav['calendar'] = ['calendar', $this->l10n->t('Calendar'), '', $this->l10n->t('Calendar')];
                }
 
index ee233bf75f1df7fbdcae28c252d7893aa803e181..95eb160155c9a14020f8fc20dd9e3b8c720646f7 100644 (file)
@@ -48,39 +48,13 @@ use Friendica\Network\HTTPException;
 use Friendica\Database\Database;
 use Friendica\Module\Response;
 use Friendica\Navigation\SystemMessages;
-use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
 
 class Channel extends Timeline
 {
-       const WHATSHOT  = 'whatshot';
-       const FORYOU    = 'foryou';
-       const FOLLOWERS = 'followers';
-       const SHARERSOFSHARERS = 'sharersofsharers';
-       const IMAGE     = 'image';
-       const VIDEO     = 'video';
-       const AUDIO     = 'audio';
-       const LANGUAGE  = 'language';
-
-       protected static $content;
-       protected static $accountTypeString;
-       protected static $accountType;
-       protected static $itemsPerPage;
-       protected static $min_id;
-       protected static $max_id;
-       protected static $item_id;
-
-       /** @var UserSession */
-       protected $session;
-       /** @var ICanCache */
-       protected $cache;
-       /** @var IManageConfigValues The config */
-       protected $config;
-       /** @var SystemMessages */
-       protected $systemMessages;
-       /** @var App\Page */
-       protected $page;
+       /** @var TimelineFactory */
+       protected $timeline;
        /** @var Conversation */
        protected $conversation;
        /** @var App\Page */
@@ -130,82 +104,8 @@ class Channel extends Timeline
                }
 
                if (empty($request['mode']) || ($request['mode'] != 'raw')) {
-                       $tabs = [];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('For you'),
-                               'url'       => 'channel/' . self::FORYOU,
-                               'sel'       => self::$content == self::FORYOU ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts from contacts you interact with and who interact with you'),
-                               'id'        => 'channel-foryou-tab',
-                               'accesskey' => 'y'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('What\'s Hot'),
-                               'url'       => 'channel/' . self::WHATSHOT,
-                               'sel'       => self::$content == self::WHATSHOT ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts with a lot of interactions'),
-                               'id'        => 'channel-whatshot-tab',
-                               'accesskey' => 'h'
-                       ];
-
-                       $language  = User::getLanguageCode($this->session->getLocalUserId());
-                       $languages = $this->l10n->getAvailableLanguages(true);
-
-                       $tabs[] = [
-                               'label'     => $languages[$language],
-                               'url'       => 'channel/' . self::LANGUAGE,
-                               'sel'       => self::$content == self::LANGUAGE ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts in %s', $languages[$language]),
-                               'id'        => 'channel-language-tab',
-                               'accesskey' => 'g'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('Followers'),
-                               'url'       => 'channel/' . self::FOLLOWERS,
-                               'sel'       => self::$content == self::FOLLOWERS ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts from your followers that you don\'t follow'),
-                               'id'        => 'channel-followers-tab',
-                               'accesskey' => 'f'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('Sharers of sharers'),
-                               'url'       => 'channel/' . self::SHARERSOFSHARERS,
-                               'sel'       => self::$content == self::SHARERSOFSHARERS ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts from accounts that are followed by accounts that you follow'),
-                               'id'        => 'channel-' . self::SHARERSOFSHARERS . '-tab',
-                               'accesskey' => 'f'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('Images'),
-                               'url'       => 'channel/' . self::IMAGE,
-                               'sel'       => self::$content == self::IMAGE ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts with images'),
-                               'id'        => 'channel-image-tab',
-                               'accesskey' => 'i'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('Audio'),
-                               'url'       => 'channel/' . self::AUDIO,
-                               'sel'       => self::$content == self::AUDIO ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts with audio'),
-                               'id'        => 'channel-audio-tab',
-                               'accesskey' => 'd'
-                       ];
-
-                       $tabs[] = [
-                               'label'     => $this->l10n->t('Videos'),
-                               'url'       => 'channel/' . self::VIDEO,
-                               'sel'       => self::$content == self::VIDEO ? 'active' : '',
-                               'title'     => $this->l10n->t('Posts with videos'),
-                               'id'        => 'channel-video-tab',
-                               'accesskey' => 'v'
-                       ];
+                       $tabs = $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'channel');
+                       $tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'channel'));
 
                        $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
                        $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
@@ -276,22 +176,6 @@ class Channel extends Timeline
                        throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
                }
 
-               if ($this->mode->isMobile()) {
-                       self::$itemsPerPage = $this->pConfig->get(
-                               $this->session->getLocalUserId(),
-                               'system',
-                               'itemspage_mobile_network',
-                               $this->config->get('system', 'itemspage_network_mobile')
-                       );
-               } else {
-                       self::$itemsPerPage = $this->pConfig->get(
-                               $this->session->getLocalUserId(),
-                               'system',
-                               'itemspage_network',
-                               $this->config->get('system', 'itemspage_network')
-                       );
-               }
-
                if (!empty($request['item'])) {
                        $item          = Post::selectFirst(['parent-uri-id'], ['id' => $request['item']]);
                        self::$item_id = $item['parent-uri-id'] ?? 0;
index 76d7704b66907c76fa122408538c97c28ebc1863..3093ec7649de3f6a9ee8cead97a5460f39882315 100644 (file)
@@ -118,6 +118,33 @@ class Network extends Timeline
                $this->userDefinedChannel = $userDefinedChannel;
        }
 
+       /** @var ICanCache */
+       protected $cache;
+       /** @var IManageConfigValues The config */
+       protected $config;
+       /** @var SystemMessages */
+       protected $systemMessages;
+       /** @var App\Page */
+       protected $page;
+       /** @var Conversation */
+       protected $conversation;
+       /** @var IManagePersonalConfigValues */
+       protected $pConfig;
+       /** @var Database */
+       protected $database;
+       /** @var TimelineFactory */
+       protected $timeline;
+
+       public function __construct(TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       {
+               parent::__construct($mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+               $this->timeline       = $timeline;
+               $this->systemMessages = $systemMessages;
+               $this->conversation   = $conversation;
+               $this->page           = $page;
+       }
+
        protected function content(array $request = []): string
        {
                if (!$this->session->getLocalUserId()) {
@@ -187,9 +214,9 @@ class Network extends Timeline
 
                        $x = [
                                'lockstate' => $this->circleId || $this->network || ACL::getLockstateForUserId($this->session->getLocalUserId()) ? 'lock' : 'unlock',
-                               'acl' => ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), true, $default_permissions),
-                               'bang' => (($this->circleId || $this->network) ? '!' : ''),
-                               'content' => $content,
+                               'acl'       => ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), true, $default_permissions),
+                               'bang'      => (($this->circleId || $this->network) ? '!' : ''),
+                               'content'   => $content,
                        ];
 
                        $o .= $this->conversation->statusEditor($x);