prev-next navigation for mod_connedit

This commit is contained in:
zotlabs 2016-11-24 15:08:31 -08:00
parent 1596391a2e
commit 08a4bbb7d0
2 changed files with 46 additions and 3 deletions

View File

@ -41,11 +41,16 @@ class Connedit extends \Zotlabs\Web\Controller {
}
}
$channel = \App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
}
static public function xchan_name_sort($a,$b) {
return strcasecmp($a['xchan_name'],$b['xchan_name']);
}
/* @brief Evaluate posted values and set changes
*
@ -546,9 +551,34 @@ class Connedit extends \Zotlabs\Web\Controller {
if(\App::$poi) {
$abook_prev = 0;
$abook_next = 0;
$contact_id = \App::$poi['abook_id'];
$contact = \App::$poi;
$cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0",
intval(local_channel())
);
if($cn) {
usort($cn, '\\Zotlabs\\Module\\Connedit::xchan_name_sort');
$pntotal = count($cn);
for($x = 0; $x < $pntotal; $x ++) {
if($cn[$x]['abook_id'] == $contact_id) {
if($x === 0)
$abook_prev = 0;
else
$abook_prev = $cn[$x - 1]['abook_id'];
if($x === $pntotal)
$abook_next = 0;
else
$abook_next = $cn[$x +1]['abook_id'];
}
}
}
$tools = array(
'view' => array(
@ -615,8 +645,10 @@ class Connedit extends \Zotlabs\Web\Controller {
$self = false;
if(intval($contact['abook_self']))
if(intval($contact['abook_self'])) {
$self = true;
$abook_prev = $abook_next = 0;
}
$tpl = get_markup_template("abook_edit.tpl");
@ -792,7 +824,8 @@ class Connedit extends \Zotlabs\Web\Controller {
'$multiprofs' => $multiprofs,
'$contact_id' => $contact['abook_id'],
'$name' => $contact['xchan_name'],
'$abook_prev' => $abook_prev,
'$abook_next' => $abook_next
));
$arr = array('contact' => $contact,'output' => $o);

View File

@ -1,6 +1,16 @@
<div class="generic-content-wrapper">
<div class="section-title-wrapper">
{{if $notself}}
{{if $abook_prev || $abook_next}}
<div class="btn-group pull-right">
{{if $abook_prev}}
<a href="connedit/{{$abook_prev}}" class="btn btn-default btn-xs" ><i class="fa fa-backward"></i></a>
{{/if}}
{{if $abook_next}}
<a href="connedit/{{$abook_next}}" class="btn btn-default btn-xs" ><i class="fa fa-forward"></i></a>
{{/if}}
</div>
{{/if}}
<div class="dropdown pull-right">
<button id="connection-dropdown" class="btn btn-default btn-xs" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-caret-down"></i>&nbsp;{{$tools_label}}