From 522cc7bb1775bfd9a7f3577922ecc31f97331be3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 14 Jan 2018 22:22:37 -0500 Subject: [PATCH 1/2] Fix display issues - Add baseurl to widgets search links - Add aside to search page - Fix number of available profiles in country widgets --- include/widget.php | 23 +++++++++------- index.php | 2 +- mod/directory.php | 5 ++-- mod/search.php | 11 ++++++++ src/templates/view/directory.php | 45 ++++++++++++++++---------------- src/templates/view/search.php | 33 ++++++++++++----------- 6 files changed, 68 insertions(+), 51 deletions(-) diff --git a/include/widget.php b/include/widget.php index 65c793b5..4a9624a7 100644 --- a/include/widget.php +++ b/include/widget.php @@ -1,6 +1,8 @@ ' . t('Trending Interests') . ''; $o .= ''; } return $o; } -function country_widget() +function country_widget(App $a) { $o = ''; - $r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`" - . " FROM `profile`" - . " WHERE `country-name` != ''" - . " GROUP BY `country-name`" - . " ORDER BY COUNT(`country-name`) DESC" - . " LIMIT 20"); + $r = q("SELECT `country-name`, COUNT(`country-name`) AS `total` + FROM `profile` + WHERE `country-name` != '' + AND `available` + GROUP BY `country-name` + ORDER BY COUNT(`country-name`) DESC + LIMIT 20"); if (count($r)) { $o .= '
'; $o .= '

' . t('Locations') . '

'; $o .= '
'; } diff --git a/index.php b/index.php index b574ee31..1a53c184 100644 --- a/index.php +++ b/index.php @@ -22,7 +22,7 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data); $a->init_pagehead(); -$a->page['aside'] = '
Your friends. Your web.
'; +$a->page['aside'] = ''; session_start(); diff --git a/mod/directory.php b/mod/directory.php index a1081b35..c444d8a5 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -11,8 +11,8 @@ function directory_init(App $a) { $a->set_pager_itemspage(30); - $a->page['aside'] .= tags_widget(); - $a->page['aside'] .= country_widget(); + $a->page['aside'] .= tags_widget($a); + $a->page['aside'] .= country_widget($a); } function directory_content(App $a) @@ -82,6 +82,7 @@ function directory_content(App $a) $view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl')); $view->output(array( + 'aside' => $a->page['aside'], 'total' => number_format($total), 'results' => $r, 'filter' => $filter, diff --git a/mod/search.php b/mod/search.php index ad07863b..225f7fc8 100644 --- a/mod/search.php +++ b/mod/search.php @@ -5,6 +5,16 @@ use Friendica\Directory\Rendering\View; use Friendica\Directory\Helper\Search as SearchHelper; use Friendica\Directory\Helper\Profile as ProfileHelper; +require_once 'include/widget.php'; + +function search_init(App $a) +{ + $a->set_pager_itemspage(30); + + $a->page['aside'] .= tags_widget($a); + $a->page['aside'] .= country_widget($a); +} + function search_content(App $a) { //Filters @@ -89,6 +99,7 @@ function search_content(App $a) $view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl')); $view->output(array( + 'aside' => $a->page['aside'], 'total' => number_format($total), 'results' => $r, 'filter' => $filter, diff --git a/src/templates/view/directory.php b/src/templates/view/directory.php index e83ab895..cef1052f 100644 --- a/src/templates/view/directory.php +++ b/src/templates/view/directory.php @@ -1,33 +1,32 @@
- -
-
- + +
+
+ - view('_profile', array('profile' => $profile)); - } - ?> + view('_profile', ['profile' => $profile]); + } + ?> - + -

There were no results

+

There were no results

- + -
- paginate();?> -
+
+ paginate(); ?> +
diff --git a/src/templates/view/search.php b/src/templates/view/search.php index f3cc544d..50a9094c 100644 --- a/src/templates/view/search.php +++ b/src/templates/view/search.php @@ -6,24 +6,27 @@ -
-

Results for "" ()

-
- - - + +
+

Results for "" ()

+
+ + view('_profile', array('profile' => $profile)); - } - ?> + echo $this->view('_profile', ['profile' => $profile]); + } + ?> + - +

There were no results

-

There were no results

- - -
- paginate();?> + +
+ paginate(); ?> +
From e24172ab05a9d2910d1535b8518f62d58ddfe50c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 14 Jan 2018 22:24:12 -0500 Subject: [PATCH 2/2] Fix tag insertion/update - Delete all tags related to a specific profile on submit - Add tags only if the profile is available --- include/submit.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/submit.php b/include/submit.php index da083c96..a61e7fb5 100644 --- a/include/submit.php +++ b/include/submit.php @@ -39,6 +39,9 @@ function run_submit($url) `updated` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id) ); + $r = q("DELETE FROM `tag` WHERE `nurl` = '%s'", + dbesc($r[0]['nurl']) + ); } //Remove duplicates. @@ -185,16 +188,10 @@ function run_submit($url) $t = substr($t, 0, 254); if (strlen($t)) { - $r = q("SELECT `id` FROM `tag` WHERE `term` = '%s' and `nurl` = '%s' LIMIT 1", + $r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ", dbesc($t), dbesc($nurl) ); - if (!count($r)) { - $r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ", - dbesc($t), - dbesc($nurl) - ); - } } } }