]> git.mxchange.org Git - friendica.git/commitdiff
Timeline classes are split into multiple classes
authorMichael <heluecht@pirati.ca>
Thu, 5 Oct 2023 05:36:12 +0000 (05:36 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 5 Oct 2023 05:36:12 +0000 (05:36 +0000)
19 files changed:
src/Content/Conversation/Entity/Channel.php [new file with mode: 0644]
src/Content/Conversation/Entity/Community.php [new file with mode: 0644]
src/Content/Conversation/Entity/Network.php [new file with mode: 0644]
src/Content/Conversation/Entity/Timeline.php
src/Content/Conversation/Entity/UserDefinedChannel.php [new file with mode: 0644]
src/Content/Conversation/Factory/Channel.php [new file with mode: 0644]
src/Content/Conversation/Factory/Community.php [new file with mode: 0644]
src/Content/Conversation/Factory/Network.php [new file with mode: 0644]
src/Content/Conversation/Factory/Timeline.php
src/Content/Conversation/Repository/Channel.php
src/Content/Widget.php
src/DI.php
src/Module/Conversation/Channel.php
src/Module/Conversation/Community.php
src/Module/Conversation/Network.php
src/Module/Conversation/Timeline.php
src/Module/Settings/Display.php
src/Module/Update/Channel.php
src/Module/Update/Network.php

diff --git a/src/Content/Conversation/Entity/Channel.php b/src/Content/Conversation/Entity/Channel.php
new file mode 100644 (file)
index 0000000..669309c
--- /dev/null
@@ -0,0 +1,39 @@
+<?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\Entity;
+
+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';
+
+       public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null)
+       {
+               parent::__construct($code, $label, $description, $accessKey, $path, $uid, $includeTags, $excludeTags, $fullTextSearch, $mediaType, $circle);
+       }
+}
diff --git a/src/Content/Conversation/Entity/Community.php b/src/Content/Conversation/Entity/Community.php
new file mode 100644 (file)
index 0000000..f7faf28
--- /dev/null
@@ -0,0 +1,33 @@
+<?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\Entity;
+
+final class Community extends Timeline
+{
+       const LOCAL  = 'local';
+       const GLOBAL = 'global';
+
+       public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null)
+       {
+               parent::__construct($code, $label, $description, $accessKey, $path, $uid, $includeTags, $excludeTags, $fullTextSearch, $mediaType, $circle);
+       }
+}
diff --git a/src/Content/Conversation/Entity/Network.php b/src/Content/Conversation/Entity/Network.php
new file mode 100644 (file)
index 0000000..a212b97
--- /dev/null
@@ -0,0 +1,36 @@
+<?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\Entity;
+
+final class Network extends Timeline
+{
+       const STAR      = 'star';
+       const MENTION   = 'mention';
+       const RECEIVED  = 'received';
+       const COMMENTED = 'commented';
+       const CREATED   = 'created';
+
+       public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null)
+       {
+               parent::__construct($code, $label, $description, $accessKey, $path, $uid, $includeTags, $excludeTags, $fullTextSearch, $mediaType, $circle);
+       }
+}
index 40a39cbb10899a88c4b8e5a2fbcc8f0f912601d0..20223d51821f77daec2a62b88e539816c7159935 100644 (file)
@@ -31,25 +31,11 @@ namespace Friendica\Content\Conversation\Entity;
  * @property-read string $includeTags    The tags to include in the channel
  * @property-read string $excludeTags    The tags to exclude in the channel
  * @property-read string $fullTextSearch full text search pattern
+ * @property-read int    $mediaType      Media types that are included in the channel
+ * @property-read int    $circle         Circle or timeline this channel is based on
  */
-final class Timeline extends \Friendica\BaseEntity
+class Timeline extends \Friendica\BaseEntity
 {
-       const WHATSHOT         = 'whatshot';
-       const FORYOU           = 'foryou';
-       const FOLLOWERS        = 'followers';
-       const SHARERSOFSHARERS = 'sharersofsharers';
-       const IMAGE            = 'image';
-       const VIDEO            = 'video';
-       const AUDIO            = 'audio';
-       const LANGUAGE         = 'language';
-       const LOCAL            = 'local';
-       const GLOBAL           = 'global';
-       const STAR             = 'star';
-       const MENTION          = 'mention';
-       const RECEIVED         = 'received';
-       const COMMENTED        = 'commented';
-       const CREATED          = 'created';
-
        /** @var string */
        protected $code;
        /** @var string */
diff --git a/src/Content/Conversation/Entity/UserDefinedChannel.php b/src/Content/Conversation/Entity/UserDefinedChannel.php
new file mode 100644 (file)
index 0000000..9912408
--- /dev/null
@@ -0,0 +1,30 @@
+<?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\Entity;
+
+class UserDefinedChannel extends Channel
+{
+       public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null)
+       {
+               parent::__construct($code, $label, $description, $accessKey, $path, $uid, $includeTags, $excludeTags, $fullTextSearch, $mediaType, $circle);
+       }
+}
diff --git a/src/Content/Conversation/Factory/Channel.php b/src/Content/Conversation/Factory/Channel.php
new file mode 100644 (file)
index 0000000..e151c99
--- /dev/null
@@ -0,0 +1,93 @@
+<?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\Factory;
+
+use Friendica\Content\Conversation\Collection\Timelines;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
+use Friendica\Model\User;
+use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Repository\Channel as ChannelRepository;
+use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\L10n;
+use Psr\Log\LoggerInterface;
+
+class Channel extends Timeline
+{
+       public function __construct(ChannelRepository $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config)
+       {
+               parent::__construct($channel, $l10n, $logger, $config);
+       }
+
+       public function createFromTableRow(array $row): TimelineEntity
+       {
+               return new TimelineEntity(
+                       $row['id'] ?? null,
+                       $row['label'],
+                       $row['description'] ?? null,
+                       $row['access-key'] ?? null,
+                       null,
+                       $row['uid'],
+                       $row['include-tags'] ?? null,
+                       $row['exclude-tags'] ?? null,
+                       $row['full-text-search'] ?? null,
+                       $row['media-type'] ?? null,
+                       $row['circle'] ?? null,
+               );
+       }
+
+       /**
+        * List of available channels
+        *
+        * @param integer $uid
+        * @return Timelines
+        */
+       public function getForUser(int $uid): Timelines
+       {
+               $language  = User::getLanguageCode($uid);
+               $languages = $this->l10n->getAvailableLanguages(true);
+
+               $tabs = [
+                       new ChannelEntity(ChannelEntity::FORYOU, $this->l10n->t('For you'), $this->l10n->t('Posts from contacts you interact with and who interact with you'), 'y'),
+                       new ChannelEntity(ChannelEntity::WHATSHOT, $this->l10n->t('What\'s Hot'), $this->l10n->t('Posts with a lot of interactions'), 'h'),
+                       new ChannelEntity(ChannelEntity::LANGUAGE, $languages[$language], $this->l10n->t('Posts in %s', $languages[$language]), 'g'),
+                       new ChannelEntity(ChannelEntity::FOLLOWERS, $this->l10n->t('Followers'), $this->l10n->t('Posts from your followers that you don\'t follow'), 'f'),
+                       new ChannelEntity(ChannelEntity::SHARERSOFSHARERS, $this->l10n->t('Sharers of sharers'), $this->l10n->t('Posts from accounts that are followed by accounts that you follow'), 'r'),
+                       new ChannelEntity(ChannelEntity::IMAGE, $this->l10n->t('Images'), $this->l10n->t('Posts with images'), 'i'),
+                       new ChannelEntity(ChannelEntity::AUDIO, $this->l10n->t('Audio'), $this->l10n->t('Posts with audio'), 'd'),
+                       new ChannelEntity(ChannelEntity::VIDEO, $this->l10n->t('Videos'), $this->l10n->t('Posts with videos'), 'v'),
+               ];
+
+               foreach ($this->channel->selectByUid($uid) as $channel) {
+                       $tabs[] = $channel;
+               }
+
+               return new Timelines($tabs);
+       }
+
+       public function isTimeline(string $selectedTab, int $uid): bool
+       {
+               if (is_numeric($selectedTab) && $uid && $this->channel->existsById($selectedTab, $uid)) {
+                       return true;
+               }
+               return in_array($selectedTab, [ChannelEntity::WHATSHOT, ChannelEntity::FORYOU, ChannelEntity::FOLLOWERS, ChannelEntity::SHARERSOFSHARERS, ChannelEntity::IMAGE, ChannelEntity::VIDEO, ChannelEntity::AUDIO, ChannelEntity::LANGUAGE]);
+       }
+}
diff --git a/src/Content/Conversation/Factory/Community.php b/src/Content/Conversation/Factory/Community.php
new file mode 100644 (file)
index 0000000..a21eb8d
--- /dev/null
@@ -0,0 +1,86 @@
+<?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\Factory;
+
+use Friendica\Content\Conversation\Collection\Timelines;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
+use Friendica\Content\Conversation\Entity\Community as CommunityEntity;
+use Friendica\Content\Conversation\Entity\Network;
+use Friendica\Model\User;
+use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\L10n;
+use Friendica\Module\Conversation\Community as CommunityModule;
+use Psr\Log\LoggerInterface;
+
+class Community extends Timeline
+{
+       public function __construct(Channel $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config)
+       {
+               parent::__construct($channel, $l10n, $logger, $config);
+       }
+
+       public function createFromTableRow(array $row): TimelineEntity
+       {
+               return new TimelineEntity(
+                       $row['id'] ?? null,
+                       $row['label'],
+                       $row['description'] ?? null,
+                       $row['access-key'] ?? null,
+                       null,
+                       $row['uid'],
+                       $row['include-tags'] ?? null,
+                       $row['exclude-tags'] ?? null,
+                       $row['full-text-search'] ?? null,
+                       $row['media-type'] ?? null,
+                       $row['circle'] ?? null,
+               );
+       }
+
+       /**
+        * List of available communities
+        *
+        * @param boolean $authenticated
+        * @return Timelines
+        */
+       public function getTimelines(bool $authenticated): Timelines
+       {
+               $page_style = $this->config->get('system', 'community_page_style');
+
+               $tabs = [];
+
+               if (($authenticated || in_array($page_style, [CommunityModule::LOCAL_AND_GLOBAL, CommunityModule::LOCAL])) && empty($this->config->get('system', 'singleuser'))) {
+                       $tabs[] = new CommunityEntity(CommunityEntity::LOCAL, $this->l10n->t('Local Community'), $this->l10n->t('Posts from local users on this server'), 'l');
+               }
+
+               if ($authenticated || in_array($page_style, [CommunityModule::LOCAL_AND_GLOBAL, CommunityModule::GLOBAL])) {
+                       $tabs[] = new CommunityEntity(CommunityEntity::GLOBAL, $this->l10n->t('Global Community'), $this->l10n->t('Posts from users of the whole federated network'), 'g');
+               }
+               return new Timelines($tabs);
+       }
+
+       public function isTimeline(string $selectedTab): bool
+       {
+               return in_array($selectedTab, [CommunityEntity::LOCAL, CommunityEntity::GLOBAL]);
+       }
+}
diff --git a/src/Content/Conversation/Factory/Network.php b/src/Content/Conversation/Factory/Network.php
new file mode 100644 (file)
index 0000000..873cb15
--- /dev/null
@@ -0,0 +1,77 @@
+<?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\Factory;
+
+use Friendica\Content\Conversation\Collection\Timelines;
+use Friendica\Content\Conversation\Entity\Network as NetworkEntity;
+use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\L10n;
+use Psr\Log\LoggerInterface;
+
+final class Network extends Timeline
+{
+       public function __construct(Channel $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config)
+       {
+               parent::__construct($channel, $l10n, $logger, $config);
+       }
+
+       public function createFromTableRow(array $row): NetworkEntity
+       {
+               return new NetworkEntity(
+                       $row['id'] ?? null,
+                       $row['label'],
+                       $row['description'] ?? null,
+                       $row['access-key'] ?? null,
+                       null,
+                       $row['uid'],
+                       $row['include-tags'] ?? null,
+                       $row['exclude-tags'] ?? null,
+                       $row['full-text-search'] ?? null,
+                       $row['media-type'] ?? null,
+                       $row['circle'] ?? null,
+               );
+       }
+
+       /**
+        * List of available network timelines
+        *
+        * @param string $command
+        * @return Timelines
+        */
+       public function getTimelines(string $command): Timelines
+       {
+               $tabs = [
+                       new NetworkEntity(NetworkEntity::COMMENTED, $this->l10n->t('Latest Activity'), $this->l10n->t('Sort by latest activity'), 'e', $command . '?' . http_build_query(['order' => 'commented'])),
+                       new NetworkEntity(NetworkEntity::RECEIVED, $this->l10n->t('Latest Posts'), $this->l10n->t('Sort by post received date'), 't', $command . '?' . http_build_query(['order' => 'received'])),
+                       new NetworkEntity(NetworkEntity::CREATED, $this->l10n->t('Latest Creation'), $this->l10n->t('Sort by post creation date'), 'q', $command . '?' . http_build_query(['order' => 'created'])),
+                       new NetworkEntity(NetworkEntity::MENTION, $this->l10n->t('Personal'), $this->l10n->t('Posts that mention or involve you'), 'r', $command . '?' . http_build_query(['mention' => true])),
+                       new NetworkEntity(NetworkEntity::STAR, $this->l10n->t('Starred'), $this->l10n->t('Favourite Posts'), 'm', $command . '?' . http_build_query(['star' => true])),
+               ];
+               return new Timelines($tabs);
+       }
+
+       public function isTimeline(string $selectedTab): bool
+       {
+               return in_array($selectedTab, [NetworkEntity::COMMENTED, NetworkEntity::RECEIVED, NetworkEntity::CREATED, NetworkEntity::MENTION, NetworkEntity::STAR]);
+       }
+}
index 459f061b12c5e732d284076e547ea584461c380c..eb40100819ffd9b7346b947d69ad61d057c686b9 100644 (file)
 namespace Friendica\Content\Conversation\Factory;
 
 use Friendica\Capabilities\ICanCreateFromTableRow;
-use Friendica\Content\Conversation\Collection\Timelines;
-use Friendica\Model\User;
 use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
 use Friendica\Content\Conversation\Repository\Channel;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\L10n;
-use Friendica\Module\Conversation\Community;
 use Psr\Log\LoggerInterface;
 
-final class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTableRow
+class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTableRow
 {
        /** @var L10n */
        protected $l10n;
@@ -65,91 +62,4 @@ final class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTab
                        $row['circle'] ?? null,
                );
        }
-
-       /**
-        * List of available channels
-        *
-        * @param integer $uid
-        * @return Timelines
-        */
-       public function getChannelsForUser(int $uid): Timelines
-       {
-               $language  = User::getLanguageCode($uid);
-               $languages = $this->l10n->getAvailableLanguages(true);
-
-               $tabs = [
-                       new TimelineEntity(TimelineEntity::FORYOU, $this->l10n->t('For you'), $this->l10n->t('Posts from contacts you interact with and who interact with you'), 'y'),
-                       new TimelineEntity(TimelineEntity::WHATSHOT, $this->l10n->t('What\'s Hot'), $this->l10n->t('Posts with a lot of interactions'), 'h'),
-                       new TimelineEntity(TimelineEntity::LANGUAGE, $languages[$language], $this->l10n->t('Posts in %s', $languages[$language]), 'g'),
-                       new TimelineEntity(TimelineEntity::FOLLOWERS, $this->l10n->t('Followers'), $this->l10n->t('Posts from your followers that you don\'t follow'), 'f'),
-                       new TimelineEntity(TimelineEntity::SHARERSOFSHARERS, $this->l10n->t('Sharers of sharers'), $this->l10n->t('Posts from accounts that are followed by accounts that you follow'), 'r'),
-                       new TimelineEntity(TimelineEntity::IMAGE, $this->l10n->t('Images'), $this->l10n->t('Posts with images'), 'i'),
-                       new TimelineEntity(TimelineEntity::AUDIO, $this->l10n->t('Audio'), $this->l10n->t('Posts with audio'), 'd'),
-                       new TimelineEntity(TimelineEntity::VIDEO, $this->l10n->t('Videos'), $this->l10n->t('Posts with videos'), 'v'),
-               ];
-
-               foreach ($this->channel->selectByUid($uid) as $channel) {
-                       $tabs[] = $channel;
-               }
-
-               return new Timelines($tabs);
-       }
-
-       /**
-        * List of available communities
-        *
-        * @param boolean $authenticated
-        * @return Timelines
-        */
-       public function getCommunities(bool $authenticated): Timelines
-       {
-               $page_style = $this->config->get('system', 'community_page_style');
-
-               $tabs = [];
-
-               if (($authenticated || in_array($page_style, [Community::LOCAL_AND_GLOBAL, Community::LOCAL])) && empty($this->config->get('system', 'singleuser'))) {
-                       $tabs[] = new TimelineEntity(TimelineEntity::LOCAL, $this->l10n->t('Local Community'), $this->l10n->t('Posts from local users on this server'), 'l');
-               }
-
-               if ($authenticated || in_array($page_style, [Community::LOCAL_AND_GLOBAL, Community::GLOBAL])) {
-                       $tabs[] = new TimelineEntity(TimelineEntity::GLOBAL, $this->l10n->t('Global Community'), $this->l10n->t('Posts from users of the whole federated network'), 'g');
-               }
-               return new Timelines($tabs);
-       }
-
-       /**
-        * List of available network feeds
-        *
-        * @param string $command
-        * @return Timelines
-        */
-       public function getNetworkFeeds(string $command): Timelines
-       {
-               $tabs = [
-                       new TimelineEntity(TimelineEntity::COMMENTED, $this->l10n->t('Latest Activity'), $this->l10n->t('Sort by latest activity'), 'e', $command . '?' . http_build_query(['order' => 'commented'])),
-                       new TimelineEntity(TimelineEntity::RECEIVED, $this->l10n->t('Latest Posts'), $this->l10n->t('Sort by post received date'), 't', $command . '?' . http_build_query(['order' => 'received'])),
-                       new TimelineEntity(TimelineEntity::CREATED, $this->l10n->t('Latest Creation'), $this->l10n->t('Sort by post creation date'), 'q', $command . '?' . http_build_query(['order' => 'created'])),
-                       new TimelineEntity(TimelineEntity::MENTION, $this->l10n->t('Personal'), $this->l10n->t('Posts that mention or involve you'), 'r', $command . '?' . http_build_query(['mention' => true])),
-                       new TimelineEntity(TimelineEntity::STAR, $this->l10n->t('Starred'), $this->l10n->t('Favourite Posts'), 'm', $command . '?' . http_build_query(['star' => true])),
-               ];
-               return new Timelines($tabs);
-       }
-
-       public function isNetwork(string $selectedTab): bool
-       {
-               return in_array($selectedTab, [TimelineEntity::COMMENTED, TimelineEntity::RECEIVED, TimelineEntity::CREATED, TimelineEntity::MENTION, TimelineEntity::STAR]);
-       }
-
-       public function isCommunity(string $selectedTab): bool
-       {
-               return in_array($selectedTab, [TimelineEntity::LOCAL, TimelineEntity::GLOBAL]);
-       }
-
-       public function isChannel(string $selectedTab, int $uid): bool
-       {
-               if (is_numeric($selectedTab) && $uid && $this->channel->existsById($selectedTab, $uid)) {
-                       return true;
-               }
-               return in_array($selectedTab, [TimelineEntity::WHATSHOT, TimelineEntity::FORYOU, TimelineEntity::FOLLOWERS, TimelineEntity::SHARERSOFSHARERS, TimelineEntity::IMAGE, TimelineEntity::VIDEO, TimelineEntity::AUDIO, TimelineEntity::LANGUAGE]);
-       }
 }
index 2c5bb31799639cb6e4a22784f6e7615c57e063e0..19defd59d32f4510cc426e4b304a789654d2db9b 100644 (file)
@@ -22,7 +22,7 @@
 namespace Friendica\Content\Conversation\Repository;
 
 use Friendica\BaseCollection;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Entity\UserDefinedChannel;
 use Friendica\Content\Conversation\Factory\Timeline;
 use Friendica\Database\Database;
 use Psr\Log\LoggerInterface;
@@ -41,10 +41,10 @@ class Channel extends \Friendica\BaseRepository
         *
         * @param int $id  The id of the user defined channel
         * @param int $uid The user that this channel belongs to. (Not part of the primary key)
-        * @return TimelineEntity
+        * @return UserDefinedChannel
         * @throws \Friendica\Network\HTTPException\NotFoundException
         */
-       public function selectById(int $id, int $uid): TimelineEntity
+       public function selectById(int $id, int $uid): UserDefinedChannel
        {
                return $this->_selectOne(['id' => $id, 'uid' => $uid]);
        }
@@ -84,7 +84,7 @@ class Channel extends \Friendica\BaseRepository
                return $this->_select(['uid' => $uid]);
        }
 
-       public function save(TimelineEntity $Channel): TimelineEntity
+       public function save(UserDefinedChannel $Channel): UserDefinedChannel
        {
                $fields = [
                        'label'            => $Channel->label,
index 7078c4fe06b7d5b173c1b5ab45c9163028460e66..d69467ebcd291f36f25a23221aef7725b757cec1 100644 (file)
@@ -562,19 +562,19 @@ class Widget
 
                $enabled = DI::pConfig()->get($uid, 'system', 'enabled_timelines', []);
 
-               foreach (DI::TimelineFactory()->getNetworkFeeds('') as $channel) {
+               foreach (DI::NetworkFactory()->getTimelines('') as $channel) {
                        if (empty($enabled) || in_array($channel->code, $enabled)) {
                                $channels[] = ['ref' => $channel->code, 'name' => $channel->label];
                        }
                }
 
-               foreach (DI::TimelineFactory()->getChannelsForUser($uid) as $channel) {
+               foreach (DI::ChannelFactory()->getForUser($uid) as $channel) {
                        if (empty($enabled) || in_array($channel->code, $enabled)) {
                                $channels[] = ['ref' => $channel->code, 'name' => $channel->label];
                        }
                }
 
-               foreach (DI::TimelineFactory()->getCommunities(true) as $community) {
+               foreach (DI::CommunityFactory()->getTimelines(true) as $community) {
                        if (empty($enabled) || in_array($community->code, $enabled)) {
                                $channels[] = ['ref' => $community->code, 'name' => $community->label];
                        }
index 5ffce5175283c487788c44ae7b4f7787894a59d9..22dec89dbac3524bd2ab671e3ee39a58ec067aeb 100644 (file)
@@ -555,6 +555,30 @@ abstract class DI
                return self::$dice->create(Content\Conversation\Factory\Timeline::class);
        }
 
+       /**
+        * @return Content\Conversation\Factory\Community
+        */
+       public static function CommunityFactory()
+       {
+               return self::$dice->create(Content\Conversation\Factory\Community::class);
+       }
+
+       /**
+        * @return Content\Conversation\Factory\Channel
+        */
+       public static function ChannelFactory()
+       {
+               return self::$dice->create(Content\Conversation\Factory\Channel::class);
+       }
+
+       /**
+        * @return Content\Conversation\Factory\Network
+        */
+       public static function NetworkFactory()
+       {
+               return self::$dice->create(Content\Conversation\Factory\Network::class);
+       }
+
        /**
         * @return Contact\Introduction\Repository\Introduction
         */
index 3affa1a156f3feea1b8f4b36a266284af5e8d939..20b0187804eb5e918b3d3cdf43ec0c621f32728f 100644 (file)
@@ -25,9 +25,12 @@ use Friendica\App;
 use Friendica\App\Mode;
 use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
 use Friendica\Content\Conversation\Repository\Channel as ChannelRepository;
+use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
+use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
+use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
 use Friendica\Content\Text\HTML;
@@ -57,8 +60,14 @@ class Channel extends Timeline
        protected $page;
        /** @var SystemMessages */
        protected $systemMessages;
-
-       public function __construct(ChannelRepository $channel, TimelineFactory $timeline, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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 = [])
+       /** @var ChannelFactory */
+       protected $channel;
+       /** @var CommunityFactory */
+       protected $community;
+       /** @var NetworkFactory */
+       protected $networkFactory;
+
+       public function __construct(NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, ChannelRepository $channel, TimelineFactory $timeline, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
@@ -66,6 +75,9 @@ class Channel extends Timeline
                $this->conversation   = $conversation;
                $this->page           = $page;
                $this->systemMessages = $systemMessages;
+               //$this->channel        = $channelFactory;
+               $this->community      = $community;
+               $this->networkFactory = $network;
        }
 
        protected function content(array $request = []): string
@@ -88,8 +100,8 @@ class Channel extends Timeline
                }
 
                if (empty($request['mode']) || ($request['mode'] != 'raw')) {
-                       $tabs = $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'channel');
-                       $tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'channel'));
+                       $tabs = $this->getTabArray($this->channel->getForUser($this->session->getLocalUserId()), 'channel');
+                       $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel'));
 
                        $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
                        $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
@@ -98,7 +110,7 @@ class Channel extends Timeline
 
                        $this->page['aside'] .= Widget::accountTypes('channel/' . $this->selectedTab, $this->accountTypeString);
 
-                       if (!in_array($this->selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
+                       if (!in_array($this->selectedTab, [ChannelEntity::FOLLOWERS, ChannelEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
                                $this->page['aside'] .= $this->getNoSharerWidget('channel');
                        }
 
@@ -110,7 +122,7 @@ class Channel extends Timeline
                        $o .= $this->conversation->statusEditor([], 0, true);
                }
 
-               if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
+               if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
                        $items = $this->getChannelItems();
                        $order = 'created';
                } else {
@@ -153,10 +165,10 @@ class Channel extends Timeline
                parent::parseRequest($request);
 
                if (!$this->selectedTab) {
-                       $this->selectedTab = TimelineEntity::FORYOU;
+                       $this->selectedTab = ChannelEntity::FORYOU;
                }
 
-               if (!$this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) && !$this->timeline->isCommunity($this->selectedTab)) {
+               if (!$this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
                }
 
index 75f937d3511b8f0281b75a0cb0affed0a93b883b..89af00043f928315ce5806ae9c89204b239f66ac 100644 (file)
@@ -26,8 +26,8 @@ use Friendica\App;
 use Friendica\App\Mode;
 use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
-use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
+use Friendica\Content\Conversation\Entity\Community as CommunityEntity;
+use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
 use Friendica\Content\Conversation\Repository\Channel;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
@@ -61,8 +61,8 @@ class Community extends Timeline
 
        protected $pageStyle;
 
-       /** @var TimelineFactory */
-       protected $timeline;
+       /** @var CommunityFactory */
+       protected $community;
        /** @var Conversation */
        protected $conversation;
        /** @var App\Page */
@@ -70,11 +70,11 @@ class Community extends Timeline
        /** @var SystemMessages */
        protected $systemMessages;
 
-       public function __construct(Channel $channel, TimelineFactory $timeline, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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 = [])
+       public function __construct(Channel $channel, CommunityFactory $community, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->timeline       = $timeline;
+               $this->community      = $community;
                $this->conversation   = $conversation;
                $this->page           = $page;
                $this->systemMessages = $systemMessages;
@@ -88,7 +88,7 @@ class Community extends Timeline
                $o = Renderer::replaceMacros($t, [
                        '$content' => '',
                        '$header' => '',
-                       '$show_global_community_hint' => ($this->selectedTab == TimelineEntity::GLOBAL) && $this->config->get('system', 'show_global_community_hint'),
+                       '$show_global_community_hint' => ($this->selectedTab == CommunityEntity::GLOBAL) && $this->config->get('system', 'show_global_community_hint'),
                        '$global_community_hint' => $this->l10n->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
                ]);
 
@@ -98,7 +98,7 @@ class Community extends Timeline
                }
 
                if (empty($request['mode']) || ($request['mode'] != 'raw')) {
-                       $tabs    = $this->getTabArray($this->timeline->getCommunities($this->session->isAuthenticated()), 'community');
+                       $tabs    = $this->getTabArray($this->community->getTimelines($this->session->isAuthenticated()), 'community');
                        $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
                        $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
 
@@ -169,14 +169,14 @@ class Community extends Timeline
                if (!$this->selectedTab) {
                        if (!empty($this->config->get('system', 'singleuser'))) {
                                // On single user systems only the global page does make sense
-                               $this->selectedTab = TimelineEntity::GLOBAL;
+                               $this->selectedTab = CommunityEntity::GLOBAL;
                        } else {
                                // When only the global community is allowed, we use this as default
-                               $this->selectedTab = $this->pageStyle == self::GLOBAL ? TimelineEntity::GLOBAL : TimelineEntity::LOCAL;
+                               $this->selectedTab = $this->pageStyle == self::GLOBAL ? CommunityEntity::GLOBAL : CommunityEntity::LOCAL;
                        }
                }
 
-               if (!$this->timeline->isCommunity($this->selectedTab)) {
+               if (!$this->community->isTimeline($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Community option not available.'));
                }
 
@@ -185,11 +185,11 @@ class Community extends Timeline
                        $available = $this->pageStyle == self::LOCAL_AND_GLOBAL;
 
                        if (!$available) {
-                               $available = ($this->pageStyle == self::LOCAL) && ($this->selectedTab == TimelineEntity::LOCAL);
+                               $available = ($this->pageStyle == self::LOCAL) && ($this->selectedTab == CommunityEntity::LOCAL);
                        }
 
                        if (!$available) {
-                               $available = ($this->pageStyle == self::GLOBAL) && ($this->selectedTab == TimelineEntity::GLOBAL);
+                               $available = ($this->pageStyle == self::GLOBAL) && ($this->selectedTab == CommunityEntity::GLOBAL);
                        }
 
                        if (!$available) {
index 40a1b731b6472f88956f505c655eccea456d2078..656c4410c34854c275fbc7f336b8d5b687284145 100644 (file)
@@ -25,9 +25,12 @@ use Friendica\App;
 use Friendica\App\Mode;
 use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Entity\Network as NetworkEntity;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
 use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
+use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
+use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
 use Friendica\Content\Feature;
 use Friendica\Content\GroupManager;
 use Friendica\Content\Nav;
@@ -96,8 +99,14 @@ class Network extends Timeline
        protected $database;
        /** @var TimelineFactory */
        protected $timeline;
-
-       public function __construct(Channel $channel, App $app, 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 = [])
+       /** @var ChannelFactory */
+       protected $channel;
+       /** @var CommunityFactory */
+       protected $community;
+       /** @var NetworkFactory */
+       protected $networkFactory;
+
+       public function __construct(NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, Channel $channel, App $app, 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($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
@@ -106,6 +115,9 @@ class Network extends Timeline
                $this->systemMessages = $systemMessages;
                $this->conversation   = $conversation;
                $this->page           = $page;
+               $this->channel        = $channelFactory;
+               $this->community      = $community;
+               $this->networkFactory = $network;
        }
 
        protected function content(array $request = []): string
@@ -123,9 +135,9 @@ class Network extends Timeline
 
                $o = '';
 
-               if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
+               if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
                        $items = $this->getChannelItems();
-               } elseif ($this->timeline->isCommunity($this->selectedTab)) {
+               } elseif ($this->community->isTimeline($this->selectedTab)) {
                        $items = $this->getCommunityItems();
                } else {
                        $items = $this->getItems();
@@ -266,12 +278,12 @@ class Network extends Timeline
         */
        private function getTabsHTML()
        {
-               $tabs = $this->getTabArray($this->timeline->getNetworkFeeds($this->args->getCommand()), 'network');
+               $tabs = $this->getTabArray($this->networkFactory->getTimelines($this->args->getCommand()), 'network');
 
                $network_timelines = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'network_timelines', []);
                if (!empty($network_timelines)) {
-                       $tabs = array_merge($tabs, $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'network', 'channel'));
-                       $tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'network', 'channel'));
+                       $tabs = array_merge($tabs, $this->getTabArray($this->channel->getForUser($this->session->getLocalUserId()), 'network', 'channel'));
+                       $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'network', 'channel'));
                }
 
                $arr = ['tabs' => $tabs];
@@ -304,26 +316,26 @@ class Network extends Timeline
 
                if (!$this->selectedTab) {
                        $this->selectedTab = self::getTimelineOrderBySession($this->session, $this->pConfig);
-               } elseif (!$this->timeline->isNetwork($this->selectedTab) && !$this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) && !$this->timeline->isCommunity($this->selectedTab)) {
+               } elseif (!$this->networkFactory->isTimeline($this->selectedTab) && !$this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Network feed not available.'));
                }
 
-               if (($this->network || $this->circleId || $this->groupContactId) && ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) || $this->timeline->isCommunity($this->selectedTab))) {
-                       $this->selectedTab = TimelineEntity::RECEIVED;
+               if (($this->network || $this->circleId || $this->groupContactId) && ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) || $this->community->isTimeline($this->selectedTab))) {
+                       $this->selectedTab = NetworkEntity::RECEIVED;
                }
 
                if (!empty($request['star'])) {
-                       $this->selectedTab = TimelineEntity::STAR;
+                       $this->selectedTab = NetworkEntity::STAR;
                        $this->star = true;
                } else {
-                       $this->star = $this->selectedTab == TimelineEntity::STAR;
+                       $this->star = $this->selectedTab == NetworkEntity::STAR;
                }
 
                if (!empty($request['mention'])) {
-                       $this->selectedTab = TimelineEntity::MENTION;
+                       $this->selectedTab = NetworkEntity::MENTION;
                        $this->mention = true;
                } else {
-                       $this->mention = $this->selectedTab == TimelineEntity::MENTION;
+                       $this->mention = $this->selectedTab == NetworkEntity::MENTION;
                }
 
                if (!empty($request['order'])) {
@@ -331,9 +343,9 @@ class Network extends Timeline
                        $this->order = $request['order'];
                        $this->star = false;
                        $this->mention = false;
-               } elseif (in_array($this->selectedTab, [TimelineEntity::RECEIVED, TimelineEntity::STAR]) || $this->timeline->isCommunity($this->selectedTab)) {
+               } elseif (in_array($this->selectedTab, [NetworkEntity::RECEIVED, NetworkEntity::STAR]) || $this->community->isTimeline($this->selectedTab)) {
                        $this->order = 'received';
-               } elseif (($this->selectedTab == TimelineEntity::CREATED) || $this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
+               } elseif (($this->selectedTab == NetworkEntity::CREATED) || $this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
                        $this->order = 'created';
                } else {
                        $this->order = 'commented';
@@ -343,16 +355,16 @@ class Network extends Timeline
 
                // Upon updates in the background and order by last comment we order by received date,
                // since otherwise the feed will optically jump, when some already visible thread has been updated.
-               if ($this->update && ($this->selectedTab == TimelineEntity::COMMENTED)) {
+               if ($this->update && ($this->selectedTab == NetworkEntity::COMMENTED)) {
                        $this->order = 'received';
                        $request['last_received']  = $request['last_commented'] ?? null;
                        $request['first_received'] = $request['first_commented'] ?? null;
                }
 
                // Prohibit combined usage of "star" and "mention"
-               if ($this->selectedTab == TimelineEntity::STAR) {
+               if ($this->selectedTab == NetworkEntity::STAR) {
                        $this->mention = false;
-               } elseif ($this->selectedTab == TimelineEntity::MENTION) {
+               } elseif ($this->selectedTab == NetworkEntity::MENTION) {
                        $this->star = false;
                }
 
index 2ee98527b26f6932674d1d483d612a7109a1e7ae..3f7f3ef759498176dc8cbf7b446b3263d7939eb2 100644 (file)
@@ -25,7 +25,7 @@ use Friendica\App;
 use Friendica\App\Mode;
 use Friendica\BaseModule;
 use Friendica\Content\Conversation\Collection\Timelines;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
 use Friendica\Content\Conversation\Repository\Channel;
 use Friendica\Core\Cache\Capability\ICanCache;
 use Friendica\Core\Cache\Enum\Duration;
@@ -269,13 +269,13 @@ class Timeline extends BaseModule
        {
                $uid = $this->session->getLocalUserId();
 
-               if ($this->selectedTab == TimelineEntity::WHATSHOT) {
+               if ($this->selectedTab == ChannelEntity::WHATSHOT) {
                        if (!is_null($this->accountType)) {
                                $condition = ["(`comments` > ? OR `activities` > ?) AND `contact-type` = ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), $this->accountType];
                        } else {
                                $condition = ["(`comments` > ? OR `activities` > ?) AND `contact-type` != ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), Contact::TYPE_COMMUNITY];
                        }
-               } elseif ($this->selectedTab == TimelineEntity::FORYOU) {
+               } elseif ($this->selectedTab == ChannelEntity::FORYOU) {
                        $cid = Contact::getPublicIdByUserId($uid);
 
                        $condition = [
@@ -285,9 +285,9 @@ class Timeline extends BaseModule
                                $cid, $this->getMedianRelationThreadScore($cid, 4), $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), $cid,
                                $uid, Contact\User::FREQUENCY_ALWAYS
                        ];
-               } elseif ($this->selectedTab == TimelineEntity::FOLLOWERS) {
+               } elseif ($this->selectedTab == ChannelEntity::FOLLOWERS) {
                        $condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", $uid, Contact::FOLLOWER];
-               } elseif ($this->selectedTab == TimelineEntity::SHARERSOFSHARERS) {
+               } elseif ($this->selectedTab == ChannelEntity::SHARERSOFSHARERS) {
                        $cid = Contact::getPublicIdByUserId($uid);
 
                        // @todo Suggest posts from contacts that are followed most by our followers
@@ -297,19 +297,19 @@ class Timeline extends BaseModule
                                AND NOT `cid` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `relation-cid` = ?))",
                                DateTimeFormat::utc('now - ' . $this->config->get('channel', 'sharer_interaction_days') . ' day'), $cid, $this->getMedianRelationThreadScore($cid, 4), $cid
                        ];
-               } elseif ($this->selectedTab == TimelineEntity::IMAGE) {
+               } elseif ($this->selectedTab == ChannelEntity::IMAGE) {
                        $condition = ["`media-type` & ?", 1];
-               } elseif ($this->selectedTab == TimelineEntity::VIDEO) {
+               } elseif ($this->selectedTab == ChannelEntity::VIDEO) {
                        $condition = ["`media-type` & ?", 2];
-               } elseif ($this->selectedTab == TimelineEntity::AUDIO) {
+               } elseif ($this->selectedTab == ChannelEntity::AUDIO) {
                        $condition = ["`media-type` & ?", 4];
-               } elseif ($this->selectedTab == TimelineEntity::LANGUAGE) {
+               } elseif ($this->selectedTab == ChannelEntity::LANGUAGE) {
                        $condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", $this->l10n->convertCodeForLanguageDetection(User::getLanguageCode($uid))];
                } elseif (is_numeric($this->selectedTab)) {
                        $condition = $this->getUserChannelConditions($this->selectedTab, $this->session->getLocalUserId());
                }
 
-               if ($this->selectedTab != TimelineEntity::LANGUAGE) {
+               if ($this->selectedTab != ChannelEntity::LANGUAGE) {
                        $condition = $this->addLanguageCondition($uid, $condition);
                }
 
@@ -317,7 +317,7 @@ class Timeline extends BaseModule
 
                $condition = DBA::mergeConditions($condition, ["NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed` OR `is-blocked` OR `channel-frequency` = ?))", $uid, Contact\User::FREQUENCY_NEVER]);
 
-               if (($this->selectedTab != TimelineEntity::WHATSHOT) && !is_null($this->accountType)) {
+               if (($this->selectedTab != ChannelEntity::WHATSHOT) && !is_null($this->accountType)) {
                        $condition = DBA::mergeConditions($condition, ['contact-type' => $this->accountType]);
                }
 
index 44be88ec1518745cf0f7a3ab654157b90be5a879..3c5311482f6dd8237fa10ca678003a9944ac6d2d 100644 (file)
@@ -24,6 +24,9 @@ namespace Friendica\Module\Settings;
 use Friendica\App;
 use Friendica\Content\Conversation\Collection\Timelines;
 use Friendica\Content\Text\BBCode;
+use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
+use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
+use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Hook;
@@ -53,10 +56,16 @@ class Display extends BaseSettings
        private $app;
        /** @var SystemMessages */
        private $systemMessages;
+       /** @var ChannelFactory */
+       protected $channel;
+       /** @var CommunityFactory */
+       protected $community;
+       /** @var NetworkFactory */
+       protected $network;
        /** @var TimelineFactory */
        protected $timeline;
 
-       public function __construct(TimelineFactory $timeline, SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(NetworkFactory $network, CommunityFactory $community, ChannelFactory $channel, TimelineFactory $timeline, SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
@@ -65,6 +74,9 @@ class Display extends BaseSettings
                $this->app            = $app;
                $this->systemMessages = $systemMessages;
                $this->timeline       = $timeline;
+               $this->channel        = $channel;
+               $this->community      = $community;
+               $this->network        = $network;
        }
 
        protected function post(array $request = [])
@@ -329,7 +341,7 @@ class Display extends BaseSettings
        {
                $timelines = [];
 
-               foreach ($this->timeline->getNetworkFeeds('') as $channel) {
+               foreach ($this->network->getTimelines('') as $channel) {
                        $timelines[] = $channel;
                }
 
@@ -337,11 +349,11 @@ class Display extends BaseSettings
                        return new Timelines($timelines);
                }
 
-               foreach ($this->timeline->getChannelsForUser($uid) as $channel) {
+               foreach ($this->channel->getForUser($uid) as $channel) {
                        $timelines[] = $channel;
                }
 
-               foreach ($this->timeline->getCommunities(true) as $community) {
+               foreach ($this->community->getTimelines(true) as $community) {
                        $timelines[] = $community;
                }
 
index 0abe036d6fe83569b92d83e922dc43771429775c..2cff3258509e9865ca4c3109590c652405af4a73 100644 (file)
@@ -38,7 +38,7 @@ class Channel extends ChannelModule
 
                $o = '';
                if ($this->update || $this->force) {
-                       if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
+                       if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
                                $items = $this->getChannelItems();
                        } else {
                                $items = $this->getCommunityItems();
index 612d4079c8cb73654e9ab9b518a3e4c2c248af85..140900876d41efd6a70bbe99e3ca0be09baf0df1 100644 (file)
@@ -41,9 +41,9 @@ class Network extends NetworkModule
                        System::htmlUpdateExit($o);
                }
 
-               if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
+               if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
                        $items = $this->getChannelItems();
-               } elseif ($this->timeline->isCommunity($this->selectedTab)) {
+               } elseif ($this->community->isTimeline($this->selectedTab)) {
                        $items = $this->getCommunityItems();
                } else {
                        $items = $this->getItems();