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] 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/');