Setting to select your network tabs

This commit is contained in:
Michael 2023-09-09 17:38:09 +00:00
parent 113436afd5
commit d395de3aa1
9 changed files with 241 additions and 140 deletions

View file

@ -280,12 +280,30 @@ class Network extends Timeline
// @todo user confgurable selection of tabs
$tabs = $this->getTabArray($this->timeline->getNetworkFeeds($this->args->getCommand()), 'network');
$network_timelines = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'network_timelines', []);
if (!empty($network_timelines)) {
$tabs = array_merge($tabs, $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'network', 'channel'));
$tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'network', 'channel'));
}
$arr = ['tabs' => $tabs];
Hook::callAll('network_tabs', $arr);
if (!empty($network_timelines)) {
$tabs = [];
foreach (array_keys($arr['tabs']) as $tab) {
if (in_array($tab, $network_timelines)) {
$tabs[] = $arr['tabs'][$tab];
}
}
} else {
$tabs = $arr['tabs'];
}
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs]);
}
protected function parseRequest(array $request)
@ -302,7 +320,6 @@ class Network extends Timeline
throw new HTTPException\BadRequestException($this->l10n->t('Network feed not available.'));
}
if (!empty($request['star'])) {
$this->selectedTab = TimelineEntity::STAR;
$this->star = true;

View file

@ -97,7 +97,7 @@ class Timeline extends BaseModule
protected function parseRequest(array $request)
{
$this->logger->debug('Got request', $request);
$this->selectedTab = $this->parameters['content'] ?? '';
$this->selectedTab = $this->parameters['content'] ?? $request['channel'] ?? '';
$this->accountTypeString = $request['accounttype'] ?? $this->parameters['accounttype'] ?? '';
$this->accountType = User::getAccountTypeByString($this->accountTypeString);
@ -159,14 +159,19 @@ class Timeline extends BaseModule
]);
}
protected function getTabArray(Timelines $timelines, string $prefix): array
protected function getTabArray(Timelines $timelines, string $prefix, string $parameter = ''): array
{
$tabs = [];
foreach ($timelines as $tab) {
$tabs[] = [
if (is_null($tab->path) && !empty($parameter)) {
$path = $prefix . '?' . http_build_query([$parameter => $tab->code]);
} else {
$path = $tab->path ?? $prefix . '/' . $tab->code;
}
$tabs[$tab->code] = [
'label' => $tab->label,
'url' => $tab->path ?? $prefix . '/' . $tab->code,
'url' => $path,
'sel' => $this->selectedTab == $tab->code ? 'active' : '',
'title' => $tab->description,
'id' => $prefix . '-' . $tab->code . '-tab',