forumdirectory: some polishing

This commit is contained in:
rabuzarus 2019-02-18 13:03:21 +01:00
parent 85f0508494
commit 2b7c331afb
3 changed files with 66 additions and 68 deletions

View file

@ -144,87 +144,87 @@ function directory_content(App $a)
* Format contact/profile/user data from the database into an usable * Format contact/profile/user data from the database into an usable
* array for displaying directory entries. * array for displaying directory entries.
* *
* @param type $r The directory entry from the database. * @param type $arr The directory entry from the database.
* @param string $photo_size Avatar size (thumb, photo or micro). * @param string $photo_size Avatar size (thumb, photo or micro).
* *
* @return array * @return array
*/ */
function format_directory_entry($arr, $photo_size = 'photo') function format_directory_entry(array $arr, $photo_size = 'photo')
{ {
$itemurl = (($arr['addr'] != "") ? $arr['addr'] : $arr['profile_url']); $itemurl = (($arr['addr'] != "") ? $arr['addr'] : $arr['profile_url']);
$profile_link = $arr['profile_url']; $profile_link = $arr['profile_url'];
$pdesc = (($arr['pdesc']) ? $arr['pdesc'] . '<br />' : ''); $pdesc = (($arr['pdesc']) ? $arr['pdesc'] . '<br />' : '');
$details = ''; $details = '';
if (strlen($arr['locality'])) { if (strlen($arr['locality'])) {
$details .= $arr['locality']; $details .= $arr['locality'];
} }
if (strlen($arr['region'])) { if (strlen($arr['region'])) {
if (strlen($arr['locality'])) { if (strlen($arr['locality'])) {
$details .= ', '; $details .= ', ';
} }
$details .= $arr['region']; $details .= $arr['region'];
} }
if (strlen($arr['country-name'])) { if (strlen($arr['country-name'])) {
if (strlen($details)) { if (strlen($details)) {
$details .= ', '; $details .= ', ';
} }
$details .= $arr['country-name']; $details .= $arr['country-name'];
} }
$profile = $arr; $profile = $arr;
if (!empty($profile['address']) if (!empty($profile['address'])
|| !empty($profile['locality']) || !empty($profile['locality'])
|| !empty($profile['region']) || !empty($profile['region'])
|| !empty($profile['postal-code']) || !empty($profile['postal-code'])
|| !empty($profile['country-name']) || !empty($profile['country-name'])
) { ) {
$location = L10n::t('Location:'); $location = L10n::t('Location:');
} else { } else {
$location = ''; $location = '';
} }
$gender = (!empty($profile['gender']) ? L10n::t('Gender:') : false); $gender = (!empty($profile['gender']) ? L10n::t('Gender:') : false);
$marital = (!empty($profile['marital']) ? L10n::t('Status:') : false); $marital = (!empty($profile['marital']) ? L10n::t('Status:') : false);
$homepage = (!empty($profile['homepage']) ? L10n::t('Homepage:') : false); $homepage = (!empty($profile['homepage']) ? L10n::t('Homepage:') : false);
$about = (!empty($profile['about']) ? L10n::t('About:') : false); $about = (!empty($profile['about']) ? L10n::t('About:') : false);
$location_e = $location; $location_e = $location;
$photo_menu = [ $photo_menu = [
'profile' => [L10n::t("View Profile"), Contact::magicLink($profile_link)] 'profile' => [L10n::t("View Profile"), Contact::magicLink($profile_link)]
]; ];
$entry = [ $entry = [
'id' => $arr['id'], 'id' => $arr['id'],
'url' => Contact::magicLInk($profile_link), 'url' => Contact::magicLInk($profile_link),
'itemurl' => $itemurl, 'itemurl' => $itemurl,
'thumb' => ProxyUtils::proxifyUrl($arr[$photo_size], false, ProxyUtils::SIZE_THUMB), 'thumb' => ProxyUtils::proxifyUrl($arr[$photo_size], false, ProxyUtils::SIZE_THUMB),
'img_hover' => $arr['name'], 'img_hover' => $arr['name'],
'name' => $arr['name'], 'name' => $arr['name'],
'details' => $details, 'details' => $details,
'account_type' => Contact::getAccountType($arr), 'account_type' => Contact::getAccountType($arr),
'profile' => $profile, 'profile' => $profile,
'location' => $location_e, 'location' => $location_e,
'tags' => $arr['pub_keywords'], 'tags' => $arr['pub_keywords'],
'gender' => $gender, 'gender' => $gender,
'pdesc' => $pdesc, 'pdesc' => $pdesc,
'marital' => $marital, 'marital' => $marital,
'homepage' => $homepage, 'homepage' => $homepage,
'about' => $about, 'about' => $about,
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
]; ];
$hook = ['contact' => $arr, 'entry' => $entry]; $hook = ['contact' => $arr, 'entry' => $entry];
Hook::callAll('directory_item', $hook); Hook::callAll('directory_item', $hook);
unset($profile); unset($profile);
unset($location); unset($location);
return $hook['entry']; return $hook['entry'];
} }

View file

@ -7,7 +7,6 @@
</ul> </ul>
{{/if}} {{/if}}
<div id="directory-search-wrapper"> <div id="directory-search-wrapper">
<form id="directory-search-form" action="{{$search_mod}}" method="get" > <form id="directory-search-form" action="{{$search_mod}}" method="get" >
<span class="dirsearch-desc">{{$desc nofilter}}</span> <span class="dirsearch-desc">{{$desc nofilter}}</span>

View file

@ -8,7 +8,6 @@
{{include file="section_title.tpl"}} {{include file="section_title.tpl"}}
{{* The search input field to search for contacts *}} {{* The search input field to search for contacts *}}
<div id="directory-search-wrapper"> <div id="directory-search-wrapper">
<form id="directory-search-form" class="navbar-form" role="search" action="{{$search_mod}}" method="get" > <form id="directory-search-form" class="navbar-form" role="search" action="{{$search_mod}}" method="get" >
@ -39,4 +38,4 @@
<div class="directory-end" ></div> <div class="directory-end" ></div>
{{$paginate nofilter}} {{$paginate nofilter}}
</div> </div>