From 8b46767d30192d7743e64b27d0bc5064998213f0 Mon Sep 17 00:00:00 2001 From: Saiwal K Date: Sat, 17 Jan 2026 11:44:54 +0000 Subject: [PATCH] move channel-activities header to its tpl --- Zotlabs/Widget/Channel_activities.php | 45 +++++++++++++------------- view/tpl/channel_activities_widget.tpl | 13 ++++++++ 2 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 view/tpl/channel_activities_widget.tpl diff --git a/Zotlabs/Widget/Channel_activities.php b/Zotlabs/Widget/Channel_activities.php index 2677f82c3..c2184301e 100644 --- a/Zotlabs/Widget/Channel_activities.php +++ b/Zotlabs/Widget/Channel_activities.php @@ -25,10 +25,6 @@ class Channel_activities { self::$uid = local_channel(); self::$channel = App::get_channel(); - $o = '
'; - $o .= '

' . t('Welcome') . ' ' . self::$channel['channel_name'] . '!

'; - //$o .= 'Last login date: ' . get_pconfig(self::$uid, 'system', 'stored_login_date') . ' from ' . get_pconfig(self::$uid, 'system', 'stored_login_addr'); - self::get_photos_activity(); self::get_files_activity(); self::get_webpages_activity(); @@ -42,28 +38,33 @@ class Channel_activities { call_hooks('channel_activities_widget', $hookdata); - if (!$hookdata['activities']) { - $o .= '

' . t('No recent activities') . '

'; - $o .= '
'; - return $o; + if ($hookdata['activities']) { + $keys = array_column($hookdata['activities'], 'date'); + array_multisort($keys, SORT_DESC, $hookdata['activities']); + + foreach ($hookdata['activities'] as $a) { + $activity_html .= replace_macros( + get_markup_template($a['tpl']), + [ + '$url' => $a['url'], + '$icon' => $a['icon'], + '$label' => $a['label'], + '$items' => $a['items'] + ] + ); + } } - $keys = array_column($hookdata['activities'], 'date'); + $tpl = get_markup_template('channel_activities_widget.tpl'); - array_multisort($keys, SORT_DESC, $hookdata['activities']); + return replace_macros($tpl, [ + '$welcome' => t('Welcome'), + '$channel_name' => self::$channel['channel_name'], + '$no_activities' => t('No recent activities'), + '$activities' => $hookdata['activities'], + '$activity_html' => $activity_html + ]); - foreach($hookdata['activities'] as $a) { - $o .= replace_macros(get_markup_template($a['tpl']), [ - '$url' => $a['url'], - '$icon' => $a['icon'], - '$label' => $a['label'], - '$items' => $a['items'] - ]); - } - - $o .= ''; - - return $o; } private static function get_photos_activity() { diff --git a/view/tpl/channel_activities_widget.tpl b/view/tpl/channel_activities_widget.tpl new file mode 100644 index 000000000..a43b243c4 --- /dev/null +++ b/view/tpl/channel_activities_widget.tpl @@ -0,0 +1,13 @@ +
+ +

+ {{$welcome}} {{$channel_name}}! +

+ + {{if !$activities}} +

{{$no_activities}}

+ {{else}} + {{$activity_html}} + {{/if}} + +