From 1894d4e19fe7acb5fcd042b25abc2de9d8ee57fa Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 25 Jul 2008 11:21:03 +0000 Subject: Improved friend picker. git-svn-id: https://code.elgg.org/elgg/trunk@1526 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/friends/collection.php | 7 ++++--- views/default/friends/picker.php | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'views/default') diff --git a/views/default/friends/collection.php b/views/default/friends/collection.php index 4d08e5b06..b42b4467a 100644 --- a/views/default/friends/collection.php +++ b/views/default/friends/collection.php @@ -19,7 +19,7 @@ $coll = $vars['collection']; if (is_array($vars['collection']->entities)) { - $count = sizeof($vars['collection']->entities); + $count = sizeof($vars['collection']->members); } else { $count = 0; } @@ -35,8 +35,9 @@ echo " ({$count}) "; // Ben - this is where the friends picker view needs to go - if($members = $vars['collection']->entities){ - echo elgg_view('friends/picker',array('entities' => $members)); + if($friends = $vars['collection']->entities){ + $members = $vars['collection']->members; + echo elgg_view('friends/picker',array('entities' => $friends, 'value' => $members)); } // close friends_picker div and the accordian list item diff --git a/views/default/friends/picker.php b/views/default/friends/picker.php index a226f24e1..4be60b12e 100644 --- a/views/default/friends/picker.php +++ b/views/default/friends/picker.php @@ -20,6 +20,16 @@ } else { $internalname = $vars['internalname']; } + + // Initialise values + if (!isset($vars['value'])) { + $vars['value'] = array(); + } else { + if (!is_array($vars['value'])) { + $vars['value'] = (int) $vars['value']; + $vars['value'] = array($vars['value']); + } + } // We need to count the number of friends pickers on the page. global $friendspicker; @@ -27,6 +37,7 @@ $friendspicker++; $users = array(); + $activeletters = array(); // Sort users by letter if (is_array($vars['entities']) && sizeof($vars['entities'])) @@ -73,12 +84,19 @@ //echo "

" . $user->name . "

"; $label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny')); $options[$label] = $friend->getGUID(); + if (in_array($friend->getGUID(),$vars['value'])) { + $checked = "checked = \"checked\""; + if (!in_array($letter,$activeletters)) + $activeletters[] = $letter; + } else { + $checked = ""; + } ?> - + name="[]" value="" /> @@ -135,15 +153,13 @@ jQuery(window).bind("load", function() { // manually add class to corresponding tab for panels that have content - needs to be automated eventually 0) + if (sizeof($activeletters) > 0) $chararray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - foreach($users as $letter => $gumph) { + foreach($activeletters as $letter) { $tab = strpos($chararray, $letter) + 1; - if (is_array($gumph) && sizeof($gumph)) { ?> $("div#friendsPickerNavigation li.tab a").addClass("tabHasContent"); - -- cgit v1.2.3