Enforce coding standards in include/directory.php
This commit is contained in:
parent
34a5adb9e9
commit
5fb56281d0
1 changed files with 97 additions and 98 deletions
|
@ -1,24 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('include/widget.php');
|
require_once 'include/widget.php';
|
||||||
|
|
||||||
function directory_init(&$a) {
|
function directory_init(App $a)
|
||||||
|
{
|
||||||
$a->set_pager_itemspage(80);
|
$a->set_pager_itemspage(80);
|
||||||
|
|
||||||
$a->page['aside'] .= tags_widget();
|
$a->page['aside'] .= tags_widget();
|
||||||
$a->page['aside'] .= country_widget();
|
$a->page['aside'] .= country_widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
function directory_content(&$a) {
|
function directory_content(App $a)
|
||||||
|
{
|
||||||
$forums = false;
|
$forums = false;
|
||||||
if($a->argc == 2 && $a->argv[1] === 'forum')
|
if ($a->argc == 2 && $a->argv[1] === 'forum') {
|
||||||
$forums = true;
|
$forums = true;
|
||||||
|
}
|
||||||
|
|
||||||
$alpha = false;
|
$alpha = false;
|
||||||
if($_GET['alpha'] == 1)
|
if ($_GET['alpha'] == 1) {
|
||||||
$alpha = true;
|
$alpha = true;
|
||||||
|
}
|
||||||
|
|
||||||
$search = ((x($_GET, 'search')) ? notags(trim($_GET['search'])) : '');
|
$search = ((x($_GET, 'search')) ? notags(trim($_GET['search'])) : '');
|
||||||
|
|
||||||
|
@ -26,9 +28,9 @@ function directory_content(&$a) {
|
||||||
goaway($a->get_baseurl());
|
goaway($a->get_baseurl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if($search)
|
if ($search) {
|
||||||
$alpha = true;
|
$alpha = true;
|
||||||
|
}
|
||||||
|
|
||||||
$tpl .= file_get_contents('view/directory_header.tpl');
|
$tpl .= file_get_contents('view/directory_header.tpl');
|
||||||
|
|
||||||
|
@ -45,25 +47,28 @@ function directory_content(&$a) {
|
||||||
'$finding' => (strlen($search) ? '<h4>' . t('Search for: ') . "'" . $search . "'" . '</h4>' : "")
|
'$finding' => (strlen($search) ? '<h4>' . t('Search for: ') . "'" . $search . "'" . '</h4>' : "")
|
||||||
));
|
));
|
||||||
|
|
||||||
if($search)
|
if ($search) {
|
||||||
$search = dbesc($search . '*');
|
$search = dbesc($search . '*');
|
||||||
|
}
|
||||||
$sql_extra = ((strlen($search)) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `tags` )
|
$sql_extra = ((strlen($search)) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `tags` )
|
||||||
AGAINST ('$search' IN BOOLEAN MODE) " : "");
|
AGAINST ('$search' IN BOOLEAN MODE) " : "");
|
||||||
|
|
||||||
if($forums)
|
if ($forums) {
|
||||||
$sql_extra .= " and comm = 1 ";
|
$sql_extra .= " and comm = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
$sql_extra = str_replace('%', '%%', $sql_extra);
|
$sql_extra = str_replace('%', '%%', $sql_extra);
|
||||||
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra ");
|
$r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra ");
|
||||||
if(count($r))
|
if (count($r)) {
|
||||||
$a->set_pager_total($r[0]['total']);
|
$a->set_pager_total($r[0]['total']);
|
||||||
|
}
|
||||||
|
|
||||||
if($alpha)
|
if ($alpha) {
|
||||||
$order = " order by name asc ";
|
$order = " order by name asc ";
|
||||||
else
|
} else {
|
||||||
$order = " order by updated desc, id desc ";
|
$order = " order by updated desc, id desc ";
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ",
|
$r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ",
|
||||||
intval($a->pager['start']),
|
intval($a->pager['start']),
|
||||||
|
@ -71,53 +76,47 @@ function directory_content(&$a) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r)) {
|
if (count($r)) {
|
||||||
|
|
||||||
$tpl = file_get_contents('view/directory_item.tpl');
|
$tpl = file_get_contents('view/directory_item.tpl');
|
||||||
|
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
|
|
||||||
$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'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$o .= replace_macros($tpl, array(
|
$o .= replace_macros($tpl, array(
|
||||||
'$id' => $rr['id'],
|
'$id' => $rr['id'],
|
||||||
'$mod' => '<div class="moderate"><a href="flag/' . $rr['id'] . '" title="' . t('Flag this entry') . '" ><img src="images/shield_2_16.png" alt="' . t('Flag this entry') . '" title="' . t('Flag this entry') . '"></a></div>',
|
'$mod' => '<div class="moderate"><a href="flag/' . $rr['id'] . '" title="' . t('Flag this entry') . '" ><img src="images/shield_2_16.png" alt="' . t('Flag this entry') . '" title="' . t('Flag this entry') . '"></a></div>',
|
||||||
'$star' => (($rr['tags']) ? '<div class="star" title="' . strip_tags($rr['tags']) . '"></div>' : ''),
|
'$star' => (($rr['tags']) ? '<div class="star" title="' . strip_tags($rr['tags']) . '"></div>' : ''),
|
||||||
'$profile-link' => zrl($rr['homepage']),
|
'$profile-link' => zrl($rr['homepage']),
|
||||||
'$photo' => $a->get_baseurl() . '/photo/' . $rr['id'],
|
'$photo' => $a->get_baseurl() . '/photo/' . $rr['id'],
|
||||||
|
|
||||||
// '$photo' => (($rr['photo']) ? $rr['photo'] : $a->get_baseurl() . '/photo/' . $rr['id']),
|
|
||||||
'$alt-text' => $rr['name'] . ' ' . '(' . $rr['homepage'] . ')',
|
'$alt-text' => $rr['name'] . ' ' . '(' . $rr['homepage'] . ')',
|
||||||
'$name' => $rr['name'],
|
'$name' => $rr['name'],
|
||||||
'$pclass' => (($rr['comm']) ? ' group' : ''),
|
'$pclass' => (($rr['comm']) ? ' group' : ''),
|
||||||
'$pgroup' => (($rr['comm']) ? '<div class="directory-group">' . t('[Public Group]') . '</div>' : ''),
|
'$pgroup' => (($rr['comm']) ? '<div class="directory-group">' . t('[Public Group]') . '</div>' : ''),
|
||||||
'$details' => $pdesc . $details
|
'$details' => $pdesc . $details
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
$o .= "<div class=\"directory-end\" ></div>\r\n";
|
|
||||||
|
$o .= '<div class="directory-end" ></div>' . PHP_EOL;
|
||||||
$o .= paginate($a);
|
$o .= paginate($a);
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
notice(t('No matching entries.') . EOL);
|
notice(t('No matching entries.') . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
Loading…
Reference in a new issue