From 647311db3eab87cfe15747765485df782abfa657 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Sat, 6 Dec 2014 14:55:23 +0100 Subject: Directory sorting as a dropdown, forum filter as checkbox, option to sort oldest first --- include/dir_fns.php | 17 +++++++++++++++++ mod/directory.php | 2 -- mod/dirsearch.php | 6 ++++-- view/tpl/dir_sort_links.tpl | 13 +++++++------ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/include/dir_fns.php b/include/dir_fns.php index 909005bbb..8bec974fb 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -51,13 +51,30 @@ function check_upstream_directory() { } function dir_sort_links() { + // Build urls without order and pubforums so it's easy to tack on the changed value + // Probably there's an easier way to do this + $url = 'directory?'; + $tmp = $_REQUEST; + unset($tmp['order']); + $sorturl = $url . http_build_query($tmp); + $tmp = $_REQUEST; + + unset($tmp['pubforums']); + $forumsurl = $url . http_build_query($tmp); $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( '$header' => t('Directory Options'), '$normal' => t('Alphabetic'), '$reverse' => t('Reverse Alphabetic'), '$date' => t('Newest to Oldest'), + '$reversedate' => t('Oldest to Newest'), '$pubforums' => t('Public Forums Only'), + '$pubforumsonly' => x($_REQUEST,'pubforums') ? $_REQUEST['pubforums'] : '', + '$sort' => t('Sort'), + '$selected_sort' => x($_REQUEST,'order') ? $_REQUEST['order'] : 'normal', + '$sorturl' => $sorturl, + '$forumsurl' => $forumsurl, + )); return $o; } diff --git a/mod/directory.php b/mod/directory.php index c06a14d9e..47849e6ba 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -100,8 +100,6 @@ function directory_content(&$a) { $query .= '&pubforums=' . intval($pubforums); $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); - if($pubforums) - $sort_order = 'normal'; if($sort_order) $query .= '&order=' . urlencode($sort_order); diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 1ecf33393..a88db0a2c 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -64,7 +64,7 @@ function dirsearch_content(&$a) { $agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 ); $agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 ); $kw = ((x($_REQUEST,'kw')) ? intval($_REQUEST['kw']) : 0 ); - $forums = ((array_key_exists('pubforums',$_REQUEST)) ? intval($_REQUEST['pubforums']) : null); + $forums = ((array_key_exists('pubforums',$_REQUEST)) ? intval($_REQUEST['pubforums']) : 0); @@ -111,7 +111,7 @@ function dirsearch_content(&$a) { if($keywords) $sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords); - if(! is_null($forums)) + if($forums) $sql_extra .= dir_flag_build($joiner,'xprof_flags',XCHAN_FLAGS_PUBFORUM, $forums); @@ -183,6 +183,8 @@ function dirsearch_content(&$a) { $order = " order by xchan_name asc "; elseif($sort_order == 'reverse') $order = " order by xchan_name desc "; + elseif($sort_order == 'reversedate') + $order = " order by xchan_name_date asc "; else $order = " order by xchan_name_date desc "; diff --git a/view/tpl/dir_sort_links.tpl b/view/tpl/dir_sort_links.tpl index 2fcf0c13a..d9ecd22c6 100644 --- a/view/tpl/dir_sort_links.tpl +++ b/view/tpl/dir_sort_links.tpl @@ -1,9 +1,10 @@ -- cgit v1.2.3