From: Michael Date: Tue, 5 Sep 2023 05:08:19 +0000 (+0000) Subject: Classes and constants moved X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8b4309f1170e963ce462f78ba50a4d01fdc688bb;p=friendica.git Classes and constants moved --- diff --git a/src/Content/Conversation/Entity/Channel.php b/src/Content/Conversation/Entity/Channel.php new file mode 100644 index 0000000000..8d1e899acf --- /dev/null +++ b/src/Content/Conversation/Entity/Channel.php @@ -0,0 +1,56 @@ +. + * + */ + +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 index 0462755e03..0000000000 --- a/src/Content/Entity/Conversation/Channel.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - */ - -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; - } -} diff --git a/src/Model/Channel.php b/src/Model/Channel.php index 52634aaa30..d6d4eaa55c 100644 --- a/src/Model/Channel.php +++ b/src/Model/Channel.php @@ -22,21 +22,13 @@ 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; } diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 186413c3b7..3b85f7fb94 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -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; }