directory.php - code beautification (PSR)

This commit is contained in:
rabuzarus 2018-03-03 14:40:16 +01:00
parent 2efd4ba780
commit c78572bf47

View file

@ -12,12 +12,12 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
function directory_init(App $a) { function directory_init(App $a)
{
$a->set_pager_itemspage(60); $a->set_pager_itemspage(60);
if (local_user()) { if (local_user()) {
$a->page['aside'] .= Widget::findPeople(); $a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow(); $a->page['aside'] .= Widget::follow();
} else { } else {
unset($_SESSION['theme']); unset($_SESSION['theme']);
@ -25,16 +25,20 @@ function directory_init(App $a) {
} }
} }
function directory_post(App $a) { function directory_post(App $a)
if(x($_POST,'search')) {
if (x($_POST, 'search')) {
$a->data['search'] = $_POST['search']; $a->data['search'] = $_POST['search'];
} }
}
function directory_content(App $a) { function directory_content(App $a)
{
require_once("mod/proxy.php"); require_once("mod/proxy.php");
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user()) || if ((Config::get('system', 'block_public') && !local_user() && !remote_user())
(Config::get('system','block_local_dir')) && (! local_user()) && (! remote_user())) { || (Config::get('system', 'block_local_dir') && !local_user() && !remote_user())
) {
notice(L10n::t('Public access denied.') . EOL); notice(L10n::t('Public access denied.') . EOL);
return; return;
} }
@ -42,10 +46,11 @@ function directory_content(App $a) {
$o = ''; $o = '';
Nav::setSelected('directory'); Nav::setSelected('directory');
if(x($a->data,'search')) if (x($a->data, 'search')) {
$search = notags(trim($a->data['search'])); $search = notags(trim($a->data['search']));
else } else {
$search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
}
$gdirpath = ''; $gdirpath = '';
$dirurl = Config::get('system', 'directory'); $dirurl = Config::get('system', 'directory');
@ -76,11 +81,13 @@ function directory_content(App $a) {
$publish = ((Config::get('system', 'publish_all')) ? '' : " AND `publish` = 1 " ); $publish = ((Config::get('system', 'publish_all')) ? '' : " AND `publish` = 1 " );
$r = q("SELECT COUNT(*) AS `total` FROM `profile` $total = q("SELECT COUNT(*) AS `total` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "); WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "
if (DBM::is_result($r)) );
$a->set_pager_total($r[0]['total']); if (DBM::is_result($total)) {
$a->set_pager_total($total[0]['total']);
}
$order = " ORDER BY `name` ASC "; $order = " ORDER BY `name` ASC ";
@ -90,18 +97,16 @@ function directory_content(App $a) {
`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile` `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid` LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit); WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit
);
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
if (in_array('small', $a->argv)) { if (in_array('small', $a->argv)) {
$photo = 'thumb'; $photo = 'thumb';
} } else {
else {
$photo = 'photo'; $photo = 'photo';
} }
while ($rr = dba::fetch($r)) { while ($rr = dba::fetch($r)) {
$itemurl= ''; $itemurl= '';
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']); $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@ -111,16 +116,19 @@ function directory_content(App $a) {
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : ''); $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = ''; $details = '';
if(strlen($rr['locality'])) if (strlen($rr['locality'])) {
$details .= $rr['locality']; $details .= $rr['locality'];
}
if (strlen($rr['region'])) { if (strlen($rr['region'])) {
if(strlen($rr['locality'])) if (strlen($rr['locality'])) {
$details .= ', '; $details .= ', ';
}
$details .= $rr['region']; $details .= $rr['region'];
} }
if (strlen($rr['country-name'])) { if (strlen($rr['country-name'])) {
if(strlen($details)) if (strlen($details)) {
$details .= ', '; $details .= ', ';
}
$details .= $rr['country-name']; $details .= $rr['country-name'];
} }
// if(strlen($rr['dob'])) { // if(strlen($rr['dob'])) {
@ -136,16 +144,15 @@ function directory_content(App $a) {
|| (x($profile, 'locality') == 1) || (x($profile, 'locality') == 1)
|| (x($profile, 'region') == 1) || (x($profile, 'region') == 1)
|| (x($profile, 'postal-code') == 1) || (x($profile, 'postal-code') == 1)
|| (x($profile,'country-name') == 1)) || (x($profile, 'country-name') == 1)
) {
$location = L10n::t('Location:'); $location = L10n::t('Location:');
}
$gender = ((x($profile,'gender') == 1) ? L10n::t('Gender:') : False); $gender = ((x($profile, 'gender') == 1) ? L10n::t('Gender:') : false);
$marital = ((x($profile, 'marital') == 1) ? L10n::t('Status:') : 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);
$homepage = ((x($profile,'homepage') == 1) ? L10n::t('Homepage:') : False);
$about = ((x($profile,'about') == 1) ? L10n::t('About:') : False);
$location_e = $location; $location_e = $location;