From 8c386191fab9f2e53aa51733a6ba6b6d99fa49c7 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 29 Jan 2026 11:17:49 +0000 Subject: [PATCH] move html from search module to tpl (cherry picked from commit a0cb5fcb3f6bc28ec5904e1268138f3894162c4b) Co-authored-by: SK --- Zotlabs/Module/Search.php | 39 ++++++++++++++++++++++++++------------- view/tpl/search.tpl | 15 +++++++++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 view/tpl/search.tpl diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 8da362561..8cb66daf8 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -42,9 +42,7 @@ class Search extends Controller { $observer = App::get_observer(); $observer_hash = (($observer) ? $observer['xchan_hash'] : ''); - $o = '
' . "\r\n"; - - $o .= '

' . t('Search') . '

'; + $title = t('Search'); if (x(App::$data, 'search')) $search = trim(App::$data['search']); @@ -57,7 +55,7 @@ class Search extends Controller { $search = ((x($_GET, 'tag')) ? trim(escape_tags(rawurldecode($_GET['tag']))) : ''); } - $o .= search($search, 'search-box', '/search', ((local_channel()) ? true : false)); + $searchbox = search($search, 'search-box', '/search', ((local_channel()) ? true : false)); if (local_channel() && str_starts_with($search, 'https://') && !$update && !$load) { @@ -121,8 +119,17 @@ class Search extends Controller { goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search); } - if (!$search) - return $o; + if (!$search) { + $tpl = get_markup_template('search.tpl'); + + return replace_macros($tpl, [ + '$title' => $title, + '$searchbox' => $searchbox, + '$livesearch' => '', + '$results_header' => '', + '$conversation' => '', + ]); + } if ($tag) { $wildtag = str_replace('*', '%', $search); @@ -149,8 +156,8 @@ class Search extends Controller { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, // because browser prefetching might change it on us. We have to deliver it with the page. - $o .= '' . "\r\n"; - $o .= "\r\n"; App::$page['htmlhead'] = replace_macros(get_markup_template("build_query.tpl"), [ @@ -254,15 +261,21 @@ class Search extends Controller { } if ($tag) - $o .= '

' . sprintf(t('Items tagged with: %s'), $search) . '

'; + $results_header = sprintf(t('Items tagged with: %s'), $search); else - $o .= '

' . sprintf(t('Search results for: %s'), $search) . '

'; + $results_header = sprintf(t('Search results for: %s'), $search); - $o .= conversation($items, 'search', $update, 'client'); + $conversation = conversation($items, 'search', $update, 'client'); - $o .= '
'; + $tpl = get_markup_template('search.tpl'); - return $o; + return replace_macros($tpl, [ + '$title' => $title, + '$searchbox' => $searchbox, + '$livesearch' => $livesearch, + '$results_header' => $results_header ?? '', + '$conversation' => $conversation, + ]); } diff --git a/view/tpl/search.tpl b/view/tpl/search.tpl new file mode 100644 index 000000000..210082d64 --- /dev/null +++ b/view/tpl/search.tpl @@ -0,0 +1,15 @@ +
+ +

{{$title}}

+ + {{$searchbox}} + + {{$livesearch}} + + {{if $results_header}} +

{{$results_header}}

+ {{/if}} + + {{$conversation}} + +