Improved timeline menu

This commit is contained in:
Michael 2023-09-21 20:43:14 +00:00
parent 073da9735d
commit fac76a33df
4 changed files with 74 additions and 22 deletions

View file

@ -560,17 +560,25 @@ class Widget
{ {
$channels = []; $channels = [];
$enabled = DI::pConfig()->get($uid, 'system', 'enabled_timelines', []);
foreach (DI::TimelineFactory()->getNetworkFeeds('') as $channel) { foreach (DI::TimelineFactory()->getNetworkFeeds('') as $channel) {
if (empty($enabled) || in_array($channel->code, $enabled)) {
$channels[] = ['ref' => $channel->code, 'name' => $channel->label]; $channels[] = ['ref' => $channel->code, 'name' => $channel->label];
} }
}
foreach (DI::TimelineFactory()->getChannelsForUser($uid) as $channel) { foreach (DI::TimelineFactory()->getChannelsForUser($uid) as $channel) {
if (empty($enabled) || in_array($channel->code, $enabled)) {
$channels[] = ['ref' => $channel->code, 'name' => $channel->label]; $channels[] = ['ref' => $channel->code, 'name' => $channel->label];
} }
}
foreach (DI::TimelineFactory()->getCommunities(true) as $community) { foreach (DI::TimelineFactory()->getCommunities(true) as $community) {
if (empty($enabled) || in_array($community->code, $enabled)) {
$channels[] = ['ref' => $community->code, 'name' => $community->label]; $channels[] = ['ref' => $community->code, 'name' => $community->label];
} }
}
return self::filter( return self::filter(
'channel', 'channel',

View file

@ -118,25 +118,14 @@ class Network extends Timeline
$module = 'network'; $module = 'network';
$this->page['aside'] .= Widget::channels($module, $this->selectedTab, $this->session->getLocalUserId());
$this->page['aside'] .= Widget::accountTypes($module, $this->accountTypeString);
$arr = ['query' => $this->args->getQueryString()]; $arr = ['query' => $this->args->getQueryString()];
Hook::callAll('network_content_init', $arr); Hook::callAll('network_content_init', $arr);
$o = ''; $o = '';
if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) { if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
if (!in_array($this->selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
$this->page['aside'] .= $this->getNoSharerWidget($module);
}
$items = $this->getChannelItems(); $items = $this->getChannelItems();
} elseif ($this->timeline->isCommunity($this->selectedTab)) { } elseif ($this->timeline->isCommunity($this->selectedTab)) {
if ($this->session->getLocalUserId() && $this->config->get('system', 'community_no_sharer')) {
$this->page['aside'] .= $this->getNoSharerWidget($module);
}
$items = $this->getCommunityItems(); $items = $this->getCommunityItems();
} else { } else {
$items = $this->getItems(); $items = $this->getItems();
@ -146,6 +135,8 @@ class Network extends Timeline
$this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId); $this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId);
$this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false); $this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false);
$this->page['aside'] .= Widget::networks($module, !$this->groupContactId ? $this->network : ''); $this->page['aside'] .= Widget::networks($module, !$this->groupContactId ? $this->network : '');
$this->page['aside'] .= Widget::accountTypes($module, $this->accountTypeString);
$this->page['aside'] .= Widget::channels($module, $this->selectedTab, $this->session->getLocalUserId());
$this->page['aside'] .= Widget\SavedSearches::getHTML($this->args->getQueryString()); $this->page['aside'] .= Widget\SavedSearches::getHTML($this->args->getQueryString());
$this->page['aside'] .= Widget::fileAs('filed', ''); $this->page['aside'] .= Widget::fileAs('filed', '');

View file

@ -80,7 +80,8 @@ class Display extends BaseSettings
$theme = !empty($request['theme']) ? trim($request['theme']) : $user['theme']; $theme = !empty($request['theme']) ? trim($request['theme']) : $user['theme'];
$mobile_theme = !empty($request['mobile_theme']) ? trim($request['mobile_theme']) : ''; $mobile_theme = !empty($request['mobile_theme']) ? trim($request['mobile_theme']) : '';
$enable_smile = !empty($request['enable_smile']) ? intval($request['enable_smile']) : 0; $enable_smile = !empty($request['enable_smile']) ? intval($request['enable_smile']) : 0;
$network_timelines = !empty($request['network_timelines']) ? $request['network_timelines'] : []; $enable = !empty($request['enable']) ? $request['enable'] : [];
$bookmark = !empty($request['bookmark']) ? $request['bookmark'] : [];
$channel_languages = !empty($request['channel_languages']) ? $request['channel_languages'] : []; $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; $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'; $calendar_default_view = !empty($request['calendar_default_view']) ? trim($request['calendar_default_view']) : 'month';
@ -98,6 +99,20 @@ class Display extends BaseSettings
} }
} }
$enabled_timelines = [];
foreach ($enable as $code => $enabled) {
if ($enabled) {
$enabled_timelines[] = $code;
}
}
$network_timelines = [];
foreach ($bookmark as $code => $bookmarked) {
if ($bookmarked) {
$network_timelines[] = $code;
}
}
$itemspage_network = !empty($request['itemspage_network']) ? $itemspage_network = !empty($request['itemspage_network']) ?
intval($request['itemspage_network']) : intval($request['itemspage_network']) :
$this->config->get('system', 'itemspage_network'); $this->config->get('system', 'itemspage_network');
@ -127,6 +142,7 @@ class Display extends BaseSettings
$this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode); $this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode);
$this->pConfig->set($uid, 'system', 'network_timelines' , $network_timelines); $this->pConfig->set($uid, 'system', 'network_timelines' , $network_timelines);
$this->pConfig->set($uid, 'system', 'enabled_timelines' , $enabled_timelines);
$this->pConfig->set($uid, 'channel', 'languages' , $channel_languages); $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', 'first_day_of_week' , $first_day_of_week);
@ -224,10 +240,21 @@ class Display extends BaseSettings
BBCode::PREVIEW_LARGE => $this->t('Large Image'), BBCode::PREVIEW_LARGE => $this->t('Large Image'),
]; ];
$network_timelines = $this->pConfig->get($uid, 'system', 'network_timelines', array_keys($this->getAvailableTimelines($uid, true))); $bookmarked_timelines = $this->pConfig->get($uid, 'system', 'network_timelines', array_keys($this->getAvailableTimelines($uid, true)));
$enabled_timelines = $this->pConfig->get($uid, 'system', 'enabled_timelines', array_keys($this->getAvailableTimelines($uid, false)));
$channel_languages = $this->pConfig->get($uid, 'channel', 'languages', [User::getLanguageCode($uid)]); $channel_languages = $this->pConfig->get($uid, 'channel', 'languages', [User::getLanguageCode($uid)]);
$languages = $this->l10n->getAvailableLanguages(true); $languages = $this->l10n->getAvailableLanguages(true);
$timelines = $this->getAvailableTimelines($uid);
$timelines = [];
foreach ($this->getAvailableTimelines($uid) as $code => $timeline) {
$timelines[] = [
'label' => $timeline['label'],
'description' => $timeline['description'],
'enable' => ["enable[$code]", '', in_array($code, $enabled_timelines)],
'bookmark' => ["bookmark[$code]", '', in_array($code, $bookmarked_timelines)],
];
}
$first_day_of_week = $this->pConfig->get($uid, 'calendar', 'first_day_of_week', 0); $first_day_of_week = $this->pConfig->get($uid, 'calendar', 'first_day_of_week', 0);
$weekdays = [ $weekdays = [
@ -284,7 +311,13 @@ 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.")], '$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], '$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],
'$network_timelines' => ['network_timelines[]', $this->t('Timelines for the network page:'), $network_timelines, $this->t('Select all the timelines that you want to see on your network page.'), $timelines, 'multiple'], '$timeline_label' => $this->t('Label'),
'$timeline_descriptiom' => $this->t('Description'),
'$timeline_enable' => $this->t('Enable'),
'$timeline_bookmark' => $this->t('Bookmark'),
'$timelines' => $timelines,
'$timeline_explanation' => $this->t('Enable timelines that you want to see in the channels widget. Bookmark timelines that you want to see in the top menu.'),
'$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'], '$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], '$first_day_of_week' => ['first_day_of_week' , $this->t('Beginning of week:') , $first_day_of_week , '', $weekdays , false],
@ -297,7 +330,7 @@ class Display extends BaseSettings
$timelines = []; $timelines = [];
foreach ($this->timeline->getNetworkFeeds('') as $channel) { foreach ($this->timeline->getNetworkFeeds('') as $channel) {
$timelines[$channel->code] = $this->t('%s: %s', $channel->label, $channel->description); $timelines[$channel->code] = ['label' => $channel->label, 'description' => $channel->description];
} }
if ($only_network) { if ($only_network) {
@ -305,11 +338,11 @@ class Display extends BaseSettings
} }
foreach ($this->timeline->getChannelsForUser($uid) as $channel) { foreach ($this->timeline->getChannelsForUser($uid) as $channel) {
$timelines[$channel->code] = $this->t('%s: %s', $channel->label, $channel->description); $timelines[$channel->code] = ['label' => $channel->label, 'description' => $channel->description];
} }
foreach ($this->timeline->getCommunities(true) as $community) { foreach ($this->timeline->getCommunities(true) as $community) {
$timelines[$community->code] = $this->t('%s: %s', $community->label, $community->description); $timelines[$community->code] = ['label' => $community->label, 'description' => $community->description];
} }
return $timelines; return $timelines;

View file

@ -84,7 +84,27 @@
</div> </div>
<div id="timeline-settings-content" class="panel-collapse collapse{{if !$theme && !$mobile_theme && !$theme_config}} in{{/if}}" role="tabpanel" aria-labelledby="timeline-settings"> <div id="timeline-settings-content" class="panel-collapse collapse{{if !$theme && !$mobile_theme && !$theme_config}} in{{/if}}" role="tabpanel" aria-labelledby="timeline-settings">
<div class="panel-body"> <div class="panel-body">
{{include file="field_select.tpl" field=$network_timelines}} {{$timeline_explanation}}
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th>{{$timeline_label}}</th>
<th>{{$timeline_descriptiom}}</th>
<th>{{$timeline_enable}}</th>
<th>{{$timeline_bookmark}}</th>
</tr>
</thead>
<tbody>
{{foreach $timelines as $t}}
<tr>
<td>{{$t.label}}</td>
<td>{{$t.description}}</td>
<td>{{include file="field_checkbox.tpl" field=$t.enable}}</td>
<td>{{include file="field_checkbox.tpl" field=$t.bookmark}}</td>
</tr>
{{/foreach}}
</tbody>
</table>
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button> <button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button>