From d75b6a00d44c769991c0a7e40bd4a4021db340c6 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 13 Feb 2012 20:38:00 -0800 Subject: tabs and total count for contacts page --- mod/contacts.php | 78 ++++++++++++++++++++++++++++----------- view/contacts-top.tpl | 8 ++-- view/theme/duepuntozero/style.css | 3 ++ 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index ef77366da..c93b37bd8 100755 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -366,37 +366,58 @@ function contacts_content(&$a) { } $blocked = false; + $hidden = false; + $all = false; $_SESSION['return_url'] = $a->query_string; - if(($a->argc == 2) && ($a->argv[1] === 'all')) + if(($a->argc == 2) && ($a->argv[1] === 'all')) { $sql_extra = ''; - else { - if(($a->argc == 2) && ($a->argv[1] === 'blocked')) { - $sql_extra = " AND `blocked` = 1 "; - $blocked = true; - } - else - $sql_extra = " AND `blocked` = 0 "; + $all = true; + } + 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'])) : ''); $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : ''); - $tpl = get_markup_template("contacts-top.tpl"); - $o .= replace_macros($tpl,array( - '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), - '$hide_url' => (($blocked) ? 'contacts' : 'contacts/blocked'), - '$hide_text' => (($blocked) ? t('Show Unblocked Contacts') : t('Show Blocked Contacts')), - '$all_url' => 'contacts/all', - '$all_text' => t('Show All Contacts'), - '$search' => $search, - '$desc' => t('Search your contacts'), - '$finding' => (strlen($search) ? '

' . t('Finding: ') . "'" . $search . "'" . '

' : ""), - '$submit' => t('Find'), - '$cmd' => $a->cmd + $tabs = array( + array( + 'label' => t('All Contacts'), + 'url' => $a->get_baseurl() . '/contacts/all', + 'sel' => ($all) ? 'active' : '', + ), + array( + 'label' => t('Unblocked Contacts'), + 'url' => $a->get_baseurl() . '/contacts', + 'sel' => ((! $all) && (! $blocked) && (! $hidden)) ? 'active' : '', + ), + + 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) $search = dbesc($search.'*'); @@ -414,6 +435,21 @@ function contacts_content(&$a) { if(count($r)) $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) ? '

' . t('Finding: ') . "'" . $search . "'" . '

' : ""), + '$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 ", intval($_SESSION['uid']), intval($a->pager['start']), diff --git a/view/contacts-top.tpl b/view/contacts-top.tpl index b8972834c..09421a1d3 100755 --- a/view/contacts-top.tpl +++ b/view/contacts-top.tpl @@ -1,7 +1,9 @@ -

$header

+

$header{{ if $total }} ($total){{ endif }}

$finding +$tabs +
$desc @@ -13,7 +15,3 @@ $finding - diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 60fe4fb28..fbbcaab68 100755 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -809,6 +809,9 @@ input#dfrn-url { width: 120px; height: 120px; } +#contacts-search-end { + margin-bottom: 10px; +} .contact-entry-direction-icon { margin-top: 24px; -- cgit v1.2.3