Use language filtering on all channels, rearranged channels

This commit is contained in:
Michael 2023-09-03 14:01:46 +00:00
parent e5978d74c7
commit d3231c7a7d
1 changed files with 40 additions and 38 deletions

View File

@ -135,15 +135,6 @@ class Channel extends BaseModule
'accesskey' => 'y'
];
$tabs[] = [
'label' => $this->l10n->t('Followers'),
'url' => 'channel/' . self::FOLLOWERS,
'sel' => self::$content == self::FOLLOWERS ? 'active' : '',
'title' => $this->l10n->t('Posts from your followers that you don\'t follow'),
'id' => 'channel-followers-tab',
'accesskey' => 'f'
];
$tabs[] = [
'label' => $this->l10n->t('What\'s Hot'),
'url' => 'channel/' . self::WHATSHOT,
@ -153,33 +144,6 @@ class Channel extends BaseModule
'accesskey' => 'h'
];
$tabs[] = [
'label' => $this->l10n->t('Images'),
'url' => 'channel/' . self::IMAGE,
'sel' => self::$content == self::IMAGE ? 'active' : '',
'title' => $this->l10n->t('Posts with images'),
'id' => 'channel-image-tab',
'accesskey' => 'i'
];
$tabs[] = [
'label' => $this->l10n->t('Videos'),
'url' => 'channel/' . self::VIDEO,
'sel' => self::$content == self::VIDEO ? 'active' : '',
'title' => $this->l10n->t('Posts with videos'),
'id' => 'channel-video-tab',
'accesskey' => 'v'
];
$tabs[] = [
'label' => $this->l10n->t('Audio'),
'url' => 'channel/' . self::AUDIO,
'sel' => self::$content == self::AUDIO ? 'active' : '',
'title' => $this->l10n->t('Posts with audio'),
'id' => 'channel-audio-tab',
'accesskey' => 'd'
];
$language = User::getLanguageCode($this->session->getLocalUserId(), false);
$languages = $this->l10n->getAvailableLanguages();
@ -192,6 +156,42 @@ class Channel extends BaseModule
'accesskey' => 'g'
];
$tabs[] = [
'label' => $this->l10n->t('Followers'),
'url' => 'channel/' . self::FOLLOWERS,
'sel' => self::$content == self::FOLLOWERS ? 'active' : '',
'title' => $this->l10n->t('Posts from your followers that you don\'t follow'),
'id' => 'channel-followers-tab',
'accesskey' => 'f'
];
$tabs[] = [
'label' => $this->l10n->t('Images'),
'url' => 'channel/' . self::IMAGE,
'sel' => self::$content == self::IMAGE ? 'active' : '',
'title' => $this->l10n->t('Posts with images'),
'id' => 'channel-image-tab',
'accesskey' => 'i'
];
$tabs[] = [
'label' => $this->l10n->t('Audio'),
'url' => 'channel/' . self::AUDIO,
'sel' => self::$content == self::AUDIO ? 'active' : '',
'title' => $this->l10n->t('Posts with audio'),
'id' => 'channel-audio-tab',
'accesskey' => 'd'
];
$tabs[] = [
'label' => $this->l10n->t('Videos'),
'url' => 'channel/' . self::VIDEO,
'sel' => self::$content == self::VIDEO ? 'active' : '',
'title' => $this->l10n->t('Posts with videos'),
'id' => 'channel-video-tab',
'accesskey' => 'v'
];
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
@ -327,8 +327,6 @@ class Channel extends BaseModule
} else {
$condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY];
}
$condition = $this->addLanguageCondition($condition);
} elseif (self::$content == self::FORYOU) {
$cid = Contact::getPublicIdByUserId($this->session->getLocalUserId());
@ -349,6 +347,10 @@ class Channel extends BaseModule
$condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", User::getLanguageCode($this->session->getLocalUserId(), true)];
}
if (self::$content != self::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();