]> git.mxchange.org Git - friendica.git/commitdiff
Classes and constants moved
authorMichael <heluecht@pirati.ca>
Tue, 5 Sep 2023 05:08:19 +0000 (05:08 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 Sep 2023 05:08:19 +0000 (05:08 +0000)
src/Content/Conversation/Entity/Channel.php [new file with mode: 0644]
src/Content/Entity/Conversation/Channel.php [deleted file]
src/Model/Channel.php
src/Module/Conversation/Channel.php

diff --git a/src/Content/Conversation/Entity/Channel.php b/src/Content/Conversation/Entity/Channel.php
new file mode 100644 (file)
index 0000000..8d1e899
--- /dev/null
@@ -0,0 +1,56 @@
+<?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;
+
+/**
+ * @property-read string $code        Channel code
+ * @property-read string $label       Channel label
+ * @property-read string $description Channel description
+ * @property-read string $accessKey   Access key
+ */
+final class Channel extends \Friendica\BaseEntity
+{
+       const WHATSHOT  = 'whatshot';
+       const FORYOU    = 'foryou';
+       const FOLLOWERS = 'followers';
+       const IMAGE     = 'image';
+       const VIDEO     = 'video';
+       const AUDIO     = 'audio';
+       const LANGUAGE  = 'language';
+
+       /** @var string */
+       protected $code;
+       /** @var string */
+       protected $label;
+       /** @var string */
+       protected $description;
+       /** @var string */
+       protected $accessKey;
+
+       public function __construct(string $code, string $label, string $description, string $accessKey)
+       {
+               $this->code        = $code;
+               $this->label       = $label;
+               $this->description = $description;
+               $this->accessKey   = $accessKey;
+       }
+}
diff --git a/src/Content/Entity/Conversation/Channel.php b/src/Content/Entity/Conversation/Channel.php
deleted file mode 100644 (file)
index 0462755..0000000
+++ /dev/null
@@ -1,48 +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\Entity\Conversation;
-
-/**
- * @property-read string $code        Channel code
- * @property-read string $label       Channel label
- * @property-read string $description Channel description
- * @property-read string $accessKey   Access key
- */
-final class Channel extends \Friendica\BaseEntity
-{
-       /** @var string */
-       protected $code;
-       /** @var string */
-       protected $label;
-       /** @var string */
-       protected $description;
-       /** @var string */
-       protected $accessKey;
-
-       public function __construct(string $code, string $label, string $description, string $accessKey)
-       {
-               $this->code        = $code;
-               $this->label       = $label;
-               $this->description = $description;
-               $this->accessKey   = $accessKey;
-       }
-}
index 52634aaa302d1f18b9e6f66dbddb80fa6eb88e63..d6d4eaa55c8d5a0b49b32f9a206b3db11e04c00a 100644 (file)
  namespace Friendica\Model;
 
 use Friendica\Model\User;
-use Friendica\Content\Entity\Conversation\Channel as ChannelEntity;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
 use Friendica\Core\L10n;
 use Friendica\Database\Database;
 use Psr\Log\LoggerInterface;
 
 final class Channel extends \Friendica\BaseModel
 {
-       const WHATSHOT  = 'whatshot';
-       const FORYOU    = 'foryou';
-       const FOLLOWERS = 'followers';
-       const IMAGE     = 'image';
-       const VIDEO     = 'video';
-       const AUDIO     = 'audio';
-       const LANGUAGE  = 'language';
-
        /** @var L10n */
        protected $l10n;
 
@@ -59,13 +51,13 @@ final class Channel extends \Friendica\BaseModel
                $languages = $this->l10n->getAvailableLanguages(true);
 
                $tabs = [
-                       new ChannelEntity(self::FORYOU, $this->l10n->t('For you'), $this->l10n->t('Posts from contacts you interact with and who interact with you'), 'y'),
-                       new ChannelEntity(self::WHATSHOT, $this->l10n->t('What\'s Hot'), $this->l10n->t('Posts with a lot of interactions'), 'h'),
-                       new ChannelEntity(self::LANGUAGE, $languages[$language], $this->l10n->t('Posts in %s', $languages[$language]), 'g'),
-                       new ChannelEntity(self::FOLLOWERS, $this->l10n->t('Followers'), $this->l10n->t('Posts from your followers that you don\'t follow'), 'f'),
-                       new ChannelEntity(self::IMAGE, $this->l10n->t('Images'), $this->l10n->t('Posts with images'), 'i'),
-                       new ChannelEntity(self::AUDIO, $this->l10n->t('Audio'), $this->l10n->t('Posts with audio'), 'd'),
-                       new ChannelEntity(self::VIDEO, $this->l10n->t('Videos'), $this->l10n->t('Posts with videos'), 'v'),
+                       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::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'),
                ];
                return $tabs;
        }
index 186413c3b7bf729e5b247b7941107cd12cd168d4..3b85f7fb94f10a38a31ea311edab101913766042 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\App\Mode;
 use Friendica\BaseModule;
 use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
+use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
 use Friendica\Content\Text\HTML;
@@ -140,7 +141,7 @@ class Channel extends BaseModule
 
                        $this->page['aside'] .= Widget::accountTypes('channel/' . self::$content, self::$accountTypeString);
 
-                       if (!in_array(self::$content, [ChannelModel::FOLLOWERS, ChannelModel::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
+                       if (!in_array(self::$content, [ChannelEntity::FOLLOWERS, ChannelEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
                                $path = self::$content;
                                if (!empty($this->parameters['accounttype'])) {
                                        $path .= '/' . $this->parameters['accounttype'];
@@ -217,10 +218,10 @@ class Channel extends BaseModule
 
                self::$content = $this->parameters['content'] ?? '';
                if (!self::$content) {
-                       self::$content = ChannelModel::FORYOU;
+                       self::$content = ChannelEntity::FORYOU;
                }
 
-               if (!in_array(self::$content, [ChannelModel::WHATSHOT, ChannelModel::FORYOU, ChannelModel::FOLLOWERS, ChannelModel::IMAGE, ChannelModel::VIDEO, ChannelModel::AUDIO, ChannelModel::LANGUAGE])) {
+               if (!in_array(self::$content, [ChannelEntity::WHATSHOT, ChannelEntity::FORYOU, ChannelEntity::FOLLOWERS, ChannelEntity::IMAGE, ChannelEntity::VIDEO, ChannelEntity::AUDIO, ChannelEntity::LANGUAGE])) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
                }
 
@@ -262,13 +263,13 @@ class Channel extends BaseModule
         */
        protected function getItems(array $request)
        {
-               if (self::$content == ChannelModel::WHATSHOT) {
+               if (self::$content == ChannelEntity::WHATSHOT) {
                        if (!is_null(self::$accountType)) {
                                $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ?", $this->getMedianComments(4), $this->getMedianActivities(4), self::$accountType];
                        } else {
                                $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY];
                        }
-               } elseif (self::$content == ChannelModel::FORYOU) {
+               } elseif (self::$content == ChannelEntity::FORYOU) {
                        $cid = Contact::getPublicIdByUserId($this->session->getLocalUserId());
 
                        $condition = ["(`owner-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
@@ -276,26 +277,26 @@ class Channel extends BaseModule
                                ( `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
                                $cid, $this->getMedianThreadScore($cid, 4), $this->getMedianComments(4), $this->getMedianActivities(4), $this->session->getLocalUserId(), Contact::FRIEND, Contact::SHARING,
                                $this->session->getLocalUserId(), Contact::FRIEND, Contact::SHARING];
-               } elseif (self::$content == ChannelModel::FOLLOWERS) {
+               } elseif (self::$content == ChannelEntity::FOLLOWERS) {
                        $condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", $this->session->getLocalUserId(), Contact::FOLLOWER];
-               } elseif (self::$content == ChannelModel::IMAGE) {
+               } elseif (self::$content == ChannelEntity::IMAGE) {
                        $condition = ["`media-type` & ?", 1];
-               } elseif (self::$content == ChannelModel::VIDEO) {
+               } elseif (self::$content == ChannelEntity::VIDEO) {
                        $condition = ["`media-type` & ?", 2];
-               } elseif (self::$content == ChannelModel::AUDIO) {
+               } elseif (self::$content == ChannelEntity::AUDIO) {
                        $condition = ["`media-type` & ?", 4];
-               } elseif (self::$content == ChannelModel::LANGUAGE) {
+               } elseif (self::$content == ChannelEntity::LANGUAGE) {
                        $condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", $this->l10n->convertCodeForLanguageDetection(User::getLanguageCode($this->session->getLocalUserId()))];
                }
 
-               if (self::$content != ChannelModel::LANGUAGE) {
+               if (self::$content != ChannelEntity::LANGUAGE) {
                        $condition = $this->addLanguageCondition($condition);
                }
 
                $condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))";
                $condition[] = $this->session->getLocalUserId();
 
-               if ((self::$content != ChannelModel::WHATSHOT) && !is_null(self::$accountType)) {
+               if ((self::$content != ChannelEntity::WHATSHOT) && !is_null(self::$accountType)) {
                        $condition[0] .= " AND `contact-type` = ?";
                        $condition[] = self::$accountType;
                }