--- /dev/null
+<?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;
+ }
+}
+++ /dev/null
-<?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;
- }
-}
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;
$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;
}
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;
$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'];
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.'));
}
*/
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
( `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;
}