From e03fc64e6c494e64a3076401594e067e1643c383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Wed, 25 Jul 2018 02:34:52 +0200 Subject: [PATCH 1/4] Rewrite: - moved PAGE_* constants to class Friendica\Model\Profile --- forumdirectory/forumdirectory.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index d3e724c1..52352ca0 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -159,11 +159,11 @@ function forumdirectory_content(&$a) } switch ($rr['page-flags']) { - case PAGE_NORMAL : $page_type = "Personal Profile"; break; - case PAGE_SOAPBOX : $page_type = "Fan Page" ; break; - case PAGE_COMMUNITY: $page_type = "Community Forum" ; break; - case PAGE_FREELOVE : $page_type = "Open Forum" ; break; - case PAGE_PRVGROUP : $page_type = "Private Group" ; break; + case Profile::PAGE_NORMAL : $page_type = "Personal Profile"; break; + case Profile::PAGE_SOAPBOX : $page_type = "Fan Page" ; break; + case Profile::PAGE_COMMUNITY: $page_type = "Community Forum" ; break; + case Profile::PAGE_FREELOVE : $page_type = "Open Forum" ; break; + case Profile::PAGE_PRVGROUP : $page_type = "Private Group" ; break; } $profile = $rr; -- 2.43.0 From 3b9cd2f0a3e3eeebbb2296e58037be2a7cdce0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Wed, 25 Jul 2018 02:38:04 +0200 Subject: [PATCH 2/4] Rewrites: - added type-hint `App` - added type-hint `array` to $b - used empty() instead of deprecated x() --- forumdirectory/forumdirectory.php | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index 52352ca0..3a24249f 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -6,6 +6,7 @@ * Author: Thomas Willingham */ +use Friendica\App; use Friendica\Content\Nav; use Friendica\Content\Widget; use Friendica\Core\Addon; @@ -34,12 +35,12 @@ function forumdirectory_module() return; } -function forumdirectory_app_menu($a, &$b) +function forumdirectory_app_menu(App $a, array &$b) { $b['app_menu'][] = ''; } -function forumdirectory_init(&$a) +function forumdirectory_init(App $a) { $a->page['htmlhead'] .= ''; @@ -52,14 +53,14 @@ function forumdirectory_init(&$a) } } -function forumdirectory_post(&$a) +function forumdirectory_post(App $a) { - if (x($_POST, 'search')) { + if (!empty($_POST['search'])) { $a->data['search'] = $_POST['search']; } } -function forumdirectory_content(&$a) +function forumdirectory_content(App $a) { if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) { notice(L10n::t('Public access denied.') . EOL); @@ -69,10 +70,10 @@ function forumdirectory_content(&$a) $o = ''; Nav::setSelected('directory'); - if (x($a->data, 'search')) { + if (!empty($a->data['search'])) { $search = notags(trim($a->data['search'])); } else { - $search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); + $search = ((!empty($_GET['search'])) ? notags(trim(rawurldecode($_GET['search']))) : ''); } $tpl = get_markup_template('directory_header.tpl'); @@ -169,19 +170,19 @@ function forumdirectory_content(&$a) $profile = $rr; $location = ''; - if (x($profile, 'address') == 1 - || x($profile, 'locality') == 1 - || x($profile, 'region') == 1 - || x($profile, 'postal-code') == 1 - || x($profile, 'country-name') == 1 + if (!empty($profile['address']) == 1 + || !empty($profile['locality']) == 1 + || !empty($profile['region']) == 1 + || !empty($profile['postal-code']) == 1 + || !empty($profile['country-name']) == 1 ) { $location = L10n::t('Location:'); } - $gender = x($profile, 'gender') == 1 ? L10n::t('Gender:') : false; - $marital = x($profile, 'marital') == 1 ? L10n::t('Status:') : false; - $homepage = x($profile, 'homepage') == 1 ? L10n::t('Homepage:') : false; - $about = x($profile, 'about') == 1 ? L10n::t('About:') : false; + $gender = !empty($profile['gender']) == 1 ? L10n::t('Gender:') : false; + $marital = !empty($profile['marital']) == 1 ? L10n::t('Status:') : false; + $homepage = !empty($profile['homepage']) == 1 ? L10n::t('Homepage:') : false; + $about = !empty($profile['about']) == 1 ? L10n::t('About:') : false; $tpl = get_markup_template('forumdirectory_item.tpl', 'addon/forumdirectory/'); -- 2.43.0 From e879c320d563264026f4945afc0bd23ee5f3a9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Fri, 27 Jul 2018 02:05:52 +0200 Subject: [PATCH 3/4] [forumdirectory] CR request: - moved constants PAGE_* from Profile to Contact class --- forumdirectory/forumdirectory.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index 3a24249f..768c4bb7 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -13,6 +13,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Database\DBA; +use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Util\Temporal; @@ -160,11 +161,11 @@ function forumdirectory_content(App $a) } switch ($rr['page-flags']) { - case Profile::PAGE_NORMAL : $page_type = "Personal Profile"; break; - case Profile::PAGE_SOAPBOX : $page_type = "Fan Page" ; break; - case Profile::PAGE_COMMUNITY: $page_type = "Community Forum" ; break; - case Profile::PAGE_FREELOVE : $page_type = "Open Forum" ; break; - case Profile::PAGE_PRVGROUP : $page_type = "Private Group" ; break; + case Contact::PAGE_NORMAL : $page_type = "Personal Profile"; break; + case Contact::PAGE_SOAPBOX : $page_type = "Fan Page" ; break; + case Contact::PAGE_COMMUNITY: $page_type = "Community Forum" ; break; + case Contact::PAGE_FREELOVE : $page_type = "Open Forum" ; break; + case Contact::PAGE_PRVGROUP : $page_type = "Private Group" ; break; } $profile = $rr; -- 2.43.0 From 2562aee59d9c894c69364f82e3df2f687df0af58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Sat, 28 Jul 2018 02:32:27 +0200 Subject: [PATCH 4/4] [forumdirectory] CR request: Removed superfluous == 1 --- forumdirectory/forumdirectory.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index 768c4bb7..9f7dd877 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -171,19 +171,19 @@ function forumdirectory_content(App $a) $profile = $rr; $location = ''; - if (!empty($profile['address']) == 1 - || !empty($profile['locality']) == 1 - || !empty($profile['region']) == 1 - || !empty($profile['postal-code']) == 1 - || !empty($profile['country-name']) == 1 + if (!empty($profile['address']) + || !empty($profile['locality']) + || !empty($profile['region']) + || !empty($profile['postal-code']) + || !empty($profile['country-name']) ) { $location = L10n::t('Location:'); } - $gender = !empty($profile['gender']) == 1 ? L10n::t('Gender:') : false; - $marital = !empty($profile['marital']) == 1 ? L10n::t('Status:') : false; - $homepage = !empty($profile['homepage']) == 1 ? L10n::t('Homepage:') : false; - $about = !empty($profile['about']) == 1 ? L10n::t('About:') : false; + $gender = !empty($profile['gender']) ? L10n::t('Gender:') : false; + $marital = !empty($profile['marital']) ? L10n::t('Status:') : false; + $homepage = !empty($profile['homepage']) ? L10n::t('Homepage:') : false; + $about = !empty($profile['about']) ? L10n::t('About:') : false; $tpl = get_markup_template('forumdirectory_item.tpl', 'addon/forumdirectory/'); -- 2.43.0