Restructured code

This commit is contained in:
Michael 2020-09-27 05:46:07 +00:00
parent 08016710d4
commit 9586577c5a

View file

@ -48,11 +48,16 @@ class Community extends BaseModule
public static function content(array $parameters = [])
{
// Rawmode is used for fetching new content at the end of the page
$rawmode = (isset($_GET['mode']) AND ($_GET['mode'] == 'raw'));
self::parseRequest($parameters);
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
$tabs = [];
if ((Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(DI::config()->get('system', 'singleuser'))) {
@ -77,60 +82,11 @@ class Community extends BaseModule
];
}
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
if (!$rawmode) {
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
}
Nav::setSelected('community');
$items = self::getItems();
if (!DBA::isResult($items)) {
notice(DI::l10n()->t('No results.'));
return $o;
}
// We need the editor here to be able to reshare an item.
if (Session::isAuthenticated()) {
$x = [
'is_owner' => true,
'allow_location' => DI::app()->user['allow_location'],
'default_location' => DI::app()->user['default-location'],
'nickname' => DI::app()->user['nickname'],
'lockstate' => (is_array(DI::app()->user) && (strlen(DI::app()->user['allow_cid']) || strlen(DI::app()->user['allow_gid']) || strlen(DI::app()->user['deny_cid']) || strlen(DI::app()->user['deny_gid'])) ? 'lock' : 'unlock'),
'acl' => ACL::getFullSelectorHTML(DI::page(), DI::app()->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
];
$o .= status_editor(DI::app(), $x, 0, true);
}
$o .= conversation(DI::app(), $items, 'community', false, false, 'commented', local_user());
$pager = new BoundariesPager(
DI::l10n(),
DI::args()->getQueryString(),
$items[0]['commented'],
$items[count($items) - 1]['commented'],
self::$itemsPerPage
);
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
}
if (!$rawmode) {
DI::page()['aside'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/community_accounts.tpl'), [
'$title' => DI::l10n()->t('Accounts'),
'$content' => self::$content,
@ -141,9 +97,8 @@ class Community extends BaseModule
'$news' => DI::l10n()->t('News'),
'$community' => DI::l10n()->t('Forums'),
]);
}
if (!$rawmode && local_user() && DI::config()->get('system', 'community_no_sharer')) {
if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content . ($parameters['accounttype'] ? '/' . $parameters['accounttype'] : '');
$query_parameters = [];
@ -169,10 +124,50 @@ class Community extends BaseModule
]);
}
if (!$rawmode && Feature::isEnabled(local_user(), 'trending_tags')) {
if (Feature::isEnabled(local_user(), 'trending_tags')) {
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
}
// We need the editor here to be able to reshare an item.
if (Session::isAuthenticated()) {
$x = [
'is_owner' => true,
'allow_location' => DI::app()->user['allow_location'],
'default_location' => DI::app()->user['default-location'],
'nickname' => DI::app()->user['nickname'],
'lockstate' => (is_array(DI::app()->user) && (strlen(DI::app()->user['allow_cid']) || strlen(DI::app()->user['allow_gid']) || strlen(DI::app()->user['deny_cid']) || strlen(DI::app()->user['deny_gid'])) ? 'lock' : 'unlock'),
'acl' => ACL::getFullSelectorHTML(DI::page(), DI::app()->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
];
$o .= status_editor(DI::app(), $x, 0, true);
}
}
$items = self::getItems();
if (!DBA::isResult($items)) {
notice(DI::l10n()->t('No results.'));
return $o;
}
$o .= conversation(DI::app(), $items, 'community', false, false, 'commented', local_user());
$pager = new BoundariesPager(
DI::l10n(),
DI::args()->getQueryString(),
$items[0]['commented'],
$items[count($items) - 1]['commented'],
self::$itemsPerPage
);
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
}
$t = Renderer::getMarkupTemplate("community.tpl");
return Renderer::replaceMacros($t, [
'$content' => $o,