tabs and total count for contacts page

This commit is contained in:
friendica 2012-02-13 20:38:00 -08:00
parent 94c7289a3f
commit d75b6a00d4
3 changed files with 63 additions and 26 deletions

View file

@ -366,37 +366,58 @@ function contacts_content(&$a) {
} }
$blocked = false; $blocked = false;
$hidden = false;
$all = false;
$_SESSION['return_url'] = $a->query_string; $_SESSION['return_url'] = $a->query_string;
if(($a->argc == 2) && ($a->argv[1] === 'all')) if(($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = ''; $sql_extra = '';
else { $all = true;
if(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
}
else
$sql_extra = " AND `blocked` = 0 ";
} }
elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
}
elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
}
else
$sql_extra = " AND `blocked` = 0 ";
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : ''); $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : ''); $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
$tpl = get_markup_template("contacts-top.tpl"); $tabs = array(
$o .= replace_macros($tpl,array( array(
'$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), 'label' => t('All Contacts'),
'$hide_url' => (($blocked) ? 'contacts' : 'contacts/blocked'), 'url' => $a->get_baseurl() . '/contacts/all',
'$hide_text' => (($blocked) ? t('Show Unblocked Contacts') : t('Show Blocked Contacts')), 'sel' => ($all) ? 'active' : '',
'$all_url' => 'contacts/all', ),
'$all_text' => t('Show All Contacts'), array(
'$search' => $search, 'label' => t('Unblocked Contacts'),
'$desc' => t('Search your contacts'), 'url' => $a->get_baseurl() . '/contacts',
'$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""), 'sel' => ((! $all) && (! $blocked) && (! $hidden)) ? 'active' : '',
'$submit' => t('Find'), ),
'$cmd' => $a->cmd
array(
'label' => t('Blocked Contacts'),
'url' => $a->get_baseurl() . '/contacts/blocked',
'sel' => ($blocked) ? 'active' : '',
),
array(
'label' => t('Hidden Contacts'),
'url' => $a->get_baseurl() . '/contacts/hidden',
'sel' => ($hidden) ? 'active' : '',
),
);
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
));
if($search) if($search)
$search = dbesc($search.'*'); $search = dbesc($search.'*');
@ -414,6 +435,21 @@ function contacts_content(&$a) {
if(count($r)) if(count($r))
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$tpl = get_markup_template("contacts-top.tpl");
$o .= replace_macros($tpl,array(
'$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
'$tabs' => $t,
'$total' => $r[0]['total'],
'$search' => $search,
'$desc' => t('Search your contacts'),
'$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
'$submit' => t('Find'),
'$cmd' => $a->cmd
));
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ",
intval($_SESSION['uid']), intval($_SESSION['uid']),
intval($a->pager['start']), intval($a->pager['start']),

View file

@ -1,7 +1,9 @@
<h1>$header</h1> <h1>$header{{ if $total }} ($total){{ endif }}</h1>
$finding $finding
$tabs
<div id="contacts-search-wrapper"> <div id="contacts-search-wrapper">
<form id="contacts-search-form" action="$cmd" method="get" > <form id="contacts-search-form" action="$cmd" method="get" >
<span class="contacts-search-desc">$desc</span> <span class="contacts-search-desc">$desc</span>
@ -13,7 +15,3 @@ $finding
<div id="contacts-main" >
<a href="$hide_url" id="contacts-show-hide-link">$hide_text</a><br />
<a href="$all_url" id="contacts-show-all-link">$all_text</a><br />
</div>

View file

@ -809,6 +809,9 @@ input#dfrn-url {
width: 120px; width: 120px;
height: 120px; height: 120px;
} }
#contacts-search-end {
margin-bottom: 10px;
}
.contact-entry-direction-icon { .contact-entry-direction-icon {
margin-top: 24px; margin-top: 24px;