diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 67195775a2..cfebc08f36 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -289,7 +289,7 @@ class Nav $nav['community'] = ['community', $this->l10n->t('Community'), '', $this->l10n->t('Conversations on this and other servers')]; } - $nav['channel'] = ['channel', $this->l10n->t('Channel'), '', $this->l10n->t('Current posts, filtered by several rules')]; + $nav['channel'] = ['channel', $this->l10n->t('Channels'), '', $this->l10n->t('Current posts, filtered by several rules')]; if ($this->session->getLocalUserId()) { $nav['calendar'] = ['calendar', $this->l10n->t('Calendar'), '', $this->l10n->t('Calendar')]; diff --git a/src/Model/User.php b/src/Model/User.php index 774549d0a0..d6dfa35253 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -537,7 +537,7 @@ class User * Fetch the language code from the given user. If the code is invalid, return the system language * * @param integer $uid User-Id - * @param boolean $short If true, return the short form g.g. "en", otherwise the long form e.g. "en_UK" + * @param boolean $short If true, return the short form g.g. "en", otherwise the long form e.g. "en-gb" * @return string */ public static function getLanguageCode(int $uid, bool $short): string diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 2c834452f9..31414ddc56 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -45,6 +45,7 @@ use Friendica\Module\Security\Login; use Friendica\Network\HTTPException; use Friendica\Core\Session\Model\UserSession; use Friendica\Database\Database; +use Friendica\Model\Item; use Friendica\Module\Response; use Friendica\Navigation\SystemMessages; use Friendica\Util\Profiler; @@ -59,7 +60,6 @@ class Channel extends BaseModule const VIDEO = 'video'; const AUDIO = 'audio'; const LANGUAGE = 'language'; - const HOTLANG = 'hotlang'; protected static $content; protected static $accountTypeString; @@ -182,6 +182,7 @@ class Channel extends BaseModule $language = User::getLanguageCode($this->session->getLocalUserId(), false); $languages = $this->l10n->getAvailableLanguages(); + $tabs[] = [ 'label' => $languages[$language], 'url' => 'channel/' . self::LANGUAGE, @@ -191,15 +192,6 @@ class Channel extends BaseModule 'accesskey' => 'g' ]; - $tabs[] = [ - 'label' => $this->l10n->t('What`s Hot (%s)', $languages[$language]), - 'url' => 'channel/' . self::HOTLANG, - 'sel' => self::$content == self::HOTLANG ? 'active' : '', - 'title' => $this->l10n->t('Posts in %s with a lot of interactions', $languages[$language]), - 'id' => 'channel-hotlang-tab', - 'accesskey' => 'o' - ]; - $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); @@ -287,7 +279,7 @@ class Channel extends BaseModule self::$content = self::FORYOU; } - if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS, self::IMAGE, self::VIDEO, self::AUDIO, self::LANGUAGE, self::HOTLANG])) { + if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS, self::IMAGE, self::VIDEO, self::AUDIO, self::LANGUAGE])) { throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.')); } @@ -335,6 +327,8 @@ 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()); @@ -353,14 +347,6 @@ class Channel extends BaseModule $condition = ["`media-type` & ?", 4]; } elseif (self::$content == self::LANGUAGE) { $condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", User::getLanguageCode($this->session->getLocalUserId(), true)]; - } elseif (self::$content == self::HOTLANG) { - if (!is_null(self::$accountType)) { - $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ? AND JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", - $this->getMedianComments(4), $this->getMedianActivities(4), self::$accountType, User::getLanguageCode($this->session->getLocalUserId(), true)]; - } else { - $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ? AND JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", - $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY, User::getLanguageCode($this->session->getLocalUserId(), true)]; - } } $condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))"; @@ -399,7 +385,6 @@ class Channel extends BaseModule } $items = $this->database->selectToArray('post-engagement', ['uri-id', 'created'], $condition, $params); - if (empty($items)) { return []; } @@ -409,9 +394,25 @@ class Channel extends BaseModule $items = array_reverse($items); } + Item::update(['unseen' => false], ['unseen' => true, 'uid' => $this->session->getLocalUserId(), 'uri-id' => array_column($items, 'uri-id')]); + return $items; } + private function addLanguageCondition(array $condition): array + { + $conditions = []; + $languages = $this->pConfig->get($this->session->getLocalUserId(), 'channel', 'languages', [User::getLanguageCode($this->session->getLocalUserId(), false)]); + foreach ($languages as $language) { + $conditions[] = "JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?"; + $condition[] = substr($language, 0, 2); + } + if (!empty($conditions)) { + $condition[0] .= " AND (`language` IS NULL OR " . implode(' OR ', $conditions) . ")"; + } + return $condition; + } + private function getMedianComments(int $divider): int { $cache_key = 'Channel:getMedianComments:' . $divider; diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index d24a8e10d4..b870c91ac0 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -76,6 +76,7 @@ class Display extends BaseSettings $theme = !empty($request['theme']) ? trim($request['theme']) : $user['theme']; $mobile_theme = !empty($request['mobile_theme']) ? trim($request['mobile_theme']) : ''; $enable_smile = !empty($request['enable_smile']) ? intval($request['enable_smile']) : 0; + $channel_languages = !empty($request['channel_languages']) ? $request['channel_languages'] : []; $first_day_of_week = !empty($request['first_day_of_week']) ? intval($request['first_day_of_week']) : 0; $calendar_default_view = !empty($request['calendar_default_view']) ? trim($request['calendar_default_view']) : 'month'; $infinite_scroll = !empty($request['infinite_scroll']) ? intval($request['infinite_scroll']) : 0; @@ -120,8 +121,10 @@ class Display extends BaseSettings $this->pConfig->set($uid, 'system', 'stay_local' , $stay_local); $this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode); + $this->pConfig->set($uid, 'channel', 'languages' , $channel_languages); + $this->pConfig->set($uid, 'calendar', 'first_day_of_week' , $first_day_of_week); - $this->pConfig->set($uid, 'calendar', 'default_view' , $calendar_default_view); + $this->pConfig->set($uid, 'calendar', 'default_view' , $calendar_default_view); if (in_array($theme, Theme::getAllowedList())) { if ($theme == $user['theme']) { @@ -215,6 +218,8 @@ class Display extends BaseSettings BBCode::PREVIEW_LARGE => $this->t('Large Image'), ]; + $channel_languages = $this->pConfig->get($uid, 'channel', 'languages', [User::getLanguageCode($uid, false)]); + $languages = $this->l10n->getAvailableLanguages(); $first_day_of_week = $this->pConfig->get($uid, 'calendar', 'first_day_of_week', 0); $weekdays = [ @@ -249,6 +254,7 @@ class Display extends BaseSettings '$d_ctset' => $this->t('Custom Theme Settings'), '$d_cset' => $this->t('Content Settings'), '$stitle' => $this->t('Theme settings'), + '$channel_title' => $this->t('Channels'), '$calendar_title' => $this->t('Calendar'), '$form_security_token' => self::getFormSecurityToken('settings_display'), @@ -269,6 +275,8 @@ class Display extends BaseSettings '$stay_local' => ['stay_local' , $this->t('Stay local'), $stay_local, $this->t("Don't go to a remote system when following a contact link.")], '$preview_mode' => ['preview_mode' , $this->t('Link preview mode'), $preview_mode, $this->t('Appearance of the link preview that is added to each post with a link.'), $preview_modes, false], + '$channel_languages' => ['channel_languages[]', $this->t('Channel languages:'), $channel_languages, $this->t('Select all languages that you want to see in your channels.'), $languages, 'multiple'], + '$first_day_of_week' => ['first_day_of_week' , $this->t('Beginning of week:') , $first_day_of_week , '', $weekdays , false], '$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false], ]); diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index ee89453b33..1a9fcb6d82 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2023.09-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-03 08:52+0000\n" +"POT-Creation-Date: 2023-09-03 12:48+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -69,7 +69,7 @@ msgstr "" #: src/Module/Register.php:245 src/Module/Search/Directory.php:37 #: src/Module/Settings/Account.php:50 src/Module/Settings/Account.php:408 #: src/Module/Settings/Delegation.php:41 src/Module/Settings/Delegation.php:71 -#: src/Module/Settings/Display.php:69 src/Module/Settings/Display.php:151 +#: src/Module/Settings/Display.php:69 src/Module/Settings/Display.php:154 #: src/Module/Settings/Profile/Photo/Crop.php:165 #: src/Module/Settings/Profile/Photo/Index.php:111 #: src/Module/Settings/RemoveMe.php:117 src/Module/Settings/UserExport.php:80 @@ -1812,7 +1812,7 @@ msgstr "" #: src/Content/Nav.php:233 src/Content/Nav.php:295 #: src/Module/BaseProfile.php:85 src/Module/BaseProfile.php:88 #: src/Module/BaseProfile.php:96 src/Module/BaseProfile.php:99 -#: src/Module/Settings/Display.php:252 view/theme/frio/theme.php:236 +#: src/Module/Settings/Display.php:258 view/theme/frio/theme.php:236 #: view/theme/frio/theme.php:240 msgid "Calendar" msgstr "" @@ -1899,8 +1899,8 @@ msgstr "" msgid "Conversations on this and other servers" msgstr "" -#: src/Content/Nav.php:292 -msgid "Channel" +#: src/Content/Nav.php:292 src/Module/Settings/Display.php:257 +msgid "Channels" msgstr "" #: src/Content/Nav.php:292 @@ -2710,37 +2710,37 @@ msgid "Could not connect to database." msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:430 -#: src/Module/Settings/Display.php:222 +#: src/Module/Settings/Display.php:227 msgid "Monday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:431 -#: src/Module/Settings/Display.php:223 +#: src/Module/Settings/Display.php:228 msgid "Tuesday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:432 -#: src/Module/Settings/Display.php:224 +#: src/Module/Settings/Display.php:229 msgid "Wednesday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:433 -#: src/Module/Settings/Display.php:225 +#: src/Module/Settings/Display.php:230 msgid "Thursday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:434 -#: src/Module/Settings/Display.php:226 +#: src/Module/Settings/Display.php:231 msgid "Friday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:435 -#: src/Module/Settings/Display.php:227 +#: src/Module/Settings/Display.php:232 msgid "Saturday" msgstr "" #: src/Core/L10n.php:408 src/Model/Event.php:429 -#: src/Module/Settings/Display.php:221 +#: src/Module/Settings/Display.php:226 msgid "Sunday" msgstr "" @@ -3185,17 +3185,17 @@ msgid "today" msgstr "" #: src/Model/Event.php:463 src/Module/Calendar/Show.php:129 -#: src/Module/Settings/Display.php:232 src/Util/Temporal.php:353 +#: src/Module/Settings/Display.php:237 src/Util/Temporal.php:353 msgid "month" msgstr "" #: src/Model/Event.php:464 src/Module/Calendar/Show.php:130 -#: src/Module/Settings/Display.php:233 src/Util/Temporal.php:354 +#: src/Module/Settings/Display.php:238 src/Util/Temporal.php:354 msgid "week" msgstr "" #: src/Model/Event.php:465 src/Module/Calendar/Show.php:131 -#: src/Module/Settings/Display.php:234 src/Util/Temporal.php:355 +#: src/Module/Settings/Display.php:239 src/Util/Temporal.php:355 msgid "day" msgstr "" @@ -3818,7 +3818,7 @@ msgstr "" #: src/Module/Settings/Account.php:561 src/Module/Settings/Addons.php:78 #: src/Module/Settings/Connectors.php:160 #: src/Module/Settings/Connectors.php:246 -#: src/Module/Settings/Delegation.php:171 src/Module/Settings/Display.php:247 +#: src/Module/Settings/Delegation.php:171 src/Module/Settings/Display.php:252 #: src/Module/Settings/Features.php:76 msgid "Save Settings" msgstr "" @@ -4178,11 +4178,11 @@ msgstr "" msgid "%s is no valid input for maximum image size" msgstr "" -#: src/Module/Admin/Site.php:313 src/Module/Settings/Display.php:169 +#: src/Module/Admin/Site.php:313 src/Module/Settings/Display.php:172 msgid "No special theme for mobile devices" msgstr "" -#: src/Module/Admin/Site.php:330 src/Module/Settings/Display.php:179 +#: src/Module/Admin/Site.php:330 src/Module/Settings/Display.php:182 #, php-format msgid "%s - (Experimental)" msgstr "" @@ -5787,7 +5787,7 @@ msgstr "" msgid "Create New Event" msgstr "" -#: src/Module/Calendar/Show.php:132 src/Module/Settings/Display.php:235 +#: src/Module/Calendar/Show.php:132 src/Module/Settings/Display.php:240 msgid "list" msgstr "" @@ -6570,43 +6570,33 @@ msgstr "" msgid "Posts with audio" msgstr "" -#: src/Module/Conversation/Channel.php:189 +#: src/Module/Conversation/Channel.php:190 #, php-format msgid "Posts in %s" msgstr "" -#: src/Module/Conversation/Channel.php:195 -#, php-format -msgid "What`s Hot (%s)" -msgstr "" - -#: src/Module/Conversation/Channel.php:198 -#, php-format -msgid "Posts in %s with a lot of interactions" -msgstr "" - -#: src/Module/Conversation/Channel.php:230 +#: src/Module/Conversation/Channel.php:222 #: src/Module/Conversation/Community.php:134 msgid "Own Contacts" msgstr "" -#: src/Module/Conversation/Channel.php:234 +#: src/Module/Conversation/Channel.php:226 #: src/Module/Conversation/Community.php:138 msgid "Include" msgstr "" -#: src/Module/Conversation/Channel.php:235 +#: src/Module/Conversation/Channel.php:227 #: src/Module/Conversation/Community.php:139 msgid "Hide" msgstr "" -#: src/Module/Conversation/Channel.php:251 +#: src/Module/Conversation/Channel.php:243 #: src/Module/Conversation/Community.php:157 src/Module/Search/Index.php:152 #: src/Module/Search/Index.php:194 msgid "No results." msgstr "" -#: src/Module/Conversation/Channel.php:291 +#: src/Module/Conversation/Channel.php:283 msgid "Channel not available." msgstr "" @@ -10088,142 +10078,150 @@ msgstr "" msgid "No entries." msgstr "" -#: src/Module/Settings/Display.php:137 +#: src/Module/Settings/Display.php:140 msgid "The theme you chose isn't available." msgstr "" -#: src/Module/Settings/Display.php:177 +#: src/Module/Settings/Display.php:180 #, php-format msgid "%s - (Unsupported)" msgstr "" -#: src/Module/Settings/Display.php:212 +#: src/Module/Settings/Display.php:215 msgid "No preview" msgstr "" -#: src/Module/Settings/Display.php:213 +#: src/Module/Settings/Display.php:216 msgid "No image" msgstr "" -#: src/Module/Settings/Display.php:214 +#: src/Module/Settings/Display.php:217 msgid "Small Image" msgstr "" -#: src/Module/Settings/Display.php:215 +#: src/Module/Settings/Display.php:218 msgid "Large Image" msgstr "" -#: src/Module/Settings/Display.php:246 +#: src/Module/Settings/Display.php:251 msgid "Display Settings" msgstr "" -#: src/Module/Settings/Display.php:248 +#: src/Module/Settings/Display.php:253 msgid "General Theme Settings" msgstr "" -#: src/Module/Settings/Display.php:249 +#: src/Module/Settings/Display.php:254 msgid "Custom Theme Settings" msgstr "" -#: src/Module/Settings/Display.php:250 +#: src/Module/Settings/Display.php:255 msgid "Content Settings" msgstr "" -#: src/Module/Settings/Display.php:251 view/theme/duepuntozero/config.php:86 +#: src/Module/Settings/Display.php:256 view/theme/duepuntozero/config.php:86 #: view/theme/frio/config.php:172 view/theme/quattro/config.php:88 #: view/theme/vier/config.php:136 msgid "Theme settings" msgstr "" -#: src/Module/Settings/Display.php:257 +#: src/Module/Settings/Display.php:263 msgid "Display Theme:" msgstr "" -#: src/Module/Settings/Display.php:258 +#: src/Module/Settings/Display.php:264 msgid "Mobile Theme:" msgstr "" -#: src/Module/Settings/Display.php:261 +#: src/Module/Settings/Display.php:267 msgid "Number of items to display per page:" msgstr "" -#: src/Module/Settings/Display.php:261 src/Module/Settings/Display.php:262 +#: src/Module/Settings/Display.php:267 src/Module/Settings/Display.php:268 msgid "Maximum of 100 items" msgstr "" -#: src/Module/Settings/Display.php:262 +#: src/Module/Settings/Display.php:268 msgid "Number of items to display per page when viewed from mobile device:" msgstr "" -#: src/Module/Settings/Display.php:263 +#: src/Module/Settings/Display.php:269 msgid "Update browser every xx seconds" msgstr "" -#: src/Module/Settings/Display.php:263 +#: src/Module/Settings/Display.php:269 msgid "Minimum of 10 seconds. Enter -1 to disable it." msgstr "" -#: src/Module/Settings/Display.php:264 +#: src/Module/Settings/Display.php:270 msgid "Display emoticons" msgstr "" -#: src/Module/Settings/Display.php:264 +#: src/Module/Settings/Display.php:270 msgid "When enabled, emoticons are replaced with matching symbols." msgstr "" -#: src/Module/Settings/Display.php:265 +#: src/Module/Settings/Display.php:271 msgid "Infinite scroll" msgstr "" -#: src/Module/Settings/Display.php:265 +#: src/Module/Settings/Display.php:271 msgid "Automatic fetch new items when reaching the page end." msgstr "" -#: src/Module/Settings/Display.php:266 +#: src/Module/Settings/Display.php:272 msgid "Enable Smart Threading" msgstr "" -#: src/Module/Settings/Display.php:266 +#: src/Module/Settings/Display.php:272 msgid "Enable the automatic suppression of extraneous thread indentation." msgstr "" -#: src/Module/Settings/Display.php:267 +#: src/Module/Settings/Display.php:273 msgid "Display the Dislike feature" msgstr "" -#: src/Module/Settings/Display.php:267 +#: src/Module/Settings/Display.php:273 msgid "Display the Dislike button and dislike reactions on posts and comments." msgstr "" -#: src/Module/Settings/Display.php:268 +#: src/Module/Settings/Display.php:274 msgid "Display the resharer" msgstr "" -#: src/Module/Settings/Display.php:268 +#: src/Module/Settings/Display.php:274 msgid "Display the first resharer as icon and text on a reshared item." msgstr "" -#: src/Module/Settings/Display.php:269 +#: src/Module/Settings/Display.php:275 msgid "Stay local" msgstr "" -#: src/Module/Settings/Display.php:269 +#: src/Module/Settings/Display.php:275 msgid "Don't go to a remote system when following a contact link." msgstr "" -#: src/Module/Settings/Display.php:270 +#: src/Module/Settings/Display.php:276 msgid "Link preview mode" msgstr "" -#: src/Module/Settings/Display.php:270 +#: src/Module/Settings/Display.php:276 msgid "Appearance of the link preview that is added to each post with a link." msgstr "" -#: src/Module/Settings/Display.php:272 +#: src/Module/Settings/Display.php:278 +msgid "Channel languages:" +msgstr "" + +#: src/Module/Settings/Display.php:278 +msgid "Select all languages that you want to see in your channels." +msgstr "" + +#: src/Module/Settings/Display.php:280 msgid "Beginning of week:" msgstr "" -#: src/Module/Settings/Display.php:273 +#: src/Module/Settings/Display.php:281 msgid "Default calendar view:" msgstr "" diff --git a/view/templates/field_select.tpl b/view/templates/field_select.tpl index 9336ce3cc7..187852e032 100644 --- a/view/templates/field_select.tpl +++ b/view/templates/field_select.tpl @@ -3,7 +3,11 @@ {{if $field.3}} diff --git a/view/templates/settings/display.tpl b/view/templates/settings/display.tpl index 4aab6721b6..bc3107e6a9 100644 --- a/view/templates/settings/display.tpl +++ b/view/templates/settings/display.tpl @@ -21,6 +21,9 @@ {{include file="field_checkbox.tpl" field=$stay_local}} {{include file="field_select.tpl" field=$preview_mode}} +

{{$channel_title}}

+ {{include file="field_select.tpl" field=$channel_languages}} +

{{$calendar_title}}

{{include file="field_select.tpl" field=$first_day_of_week}} {{include file="field_select.tpl" field=$calendar_default_view}} diff --git a/view/theme/frio/templates/field_select.tpl b/view/theme/frio/templates/field_select.tpl index d5bcfdad61..87cc27254b 100644 --- a/view/theme/frio/templates/field_select.tpl +++ b/view/theme/frio/templates/field_select.tpl @@ -3,7 +3,11 @@ {{if $field.3}} diff --git a/view/theme/frio/templates/settings/display.tpl b/view/theme/frio/templates/settings/display.tpl index 09f23d32af..f76dd7a0c9 100644 --- a/view/theme/frio/templates/settings/display.tpl +++ b/view/theme/frio/templates/settings/display.tpl @@ -74,6 +74,24 @@ +
+ +
+
+ {{include file="field_select.tpl" field=$channel_languages}} +
+ +
+
+