From b6b6d691582a22437b4f96e1c9f5915635dc4815 Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Sun, 17 Jun 2012 20:22:01 +0200
Subject: [PATCH] Moved parsing to the controller and js to contacts.js.

---
 apps/contacts/templates/part.contacts.php | 32 +++++------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php
index 6c1252debc..d23a249b98 100644
--- a/apps/contacts/templates/part.contacts.php
+++ b/apps/contacts/templates/part.contacts.php
@@ -1,28 +1,10 @@
 <?php
-foreach($_['contacts'] as $category => $contacts):
-	echo '<h3 class="addressbookname">'.$category.'</h3>';
-	echo '<div>';
-	echo '<ul class="contacts">';
-	foreach($contacts as $contact):
-		$display = trim($contact['fullname']);
-		if(!$display) {
-			$vcard = OC_Contacts_App::getContactVCard($contact['id']);
-			if(!is_null($vcard)) {
-				$struct = OC_Contacts_VCard::structureContact($vcard);
-				$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
-			}
-		}
-		echo '<li role="button" book-id="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'">'.htmlspecialchars($display).'</a></li>';
-	endforeach;
+foreach($_['books'] as $id => $addressbook) {
+	echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
+	echo '<ul class="contacts hidden">';
+	foreach($addressbook['contacts'] as $contact) {
+		echo '<li role="button" book-id="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'">'.$contact['displayname'].'</a></li>';
+	}
 	echo '</ul>';
-	echo '</div>';
-endforeach;
+}
 ?>
-<script language="Javascript">
-$(document).ready(function() {
-	$('#leftcontent .addressbookname').click(function(event) {
-		$(this).next().toggle('slow');
-		return false;
-	}).next().hide();
-});
-</script>
-- 
GitLab