diff --git a/include/text.php b/include/text.php index 9b34b0884a..13397c2ea0 100644 --- a/include/text.php +++ b/include/text.php @@ -901,20 +901,28 @@ function contact_block() { }} -if(! function_exists('micropro')) { /** + * @brief Format contacts as picture links or as texxt links * - * @param array $contact - * @param boolean $redirect - * @param string $class - * @param boolean $textmode - * @return string #FIXME: remove html + * @param array $contact Array with contacts which contains an array with + * int 'id' => The ID of the contact + * int 'uid' => The user ID of the user who owns this data + * string 'name' => The name of the contact + * string 'url' => The url to the profile page of the contact + * string 'addr' => The webbie of the contact (e.g.) username@friendica.com + * string 'network' => The network to which the contact belongs to + * string 'micro' => The contact picture + * string 'click' => js code which is performed when clicking on the contact + * @param boolean $redirect If true try to use the redir url if it's possible + * @param string $class CSS class for the + * @param boolean $textmode If true display the contacts as text links + * if false display the contacts as picture links + + * @return string Formatted html */ function micropro($contact, $redirect = false, $class = '', $textmode = false) { - if($class) - $class = ' ' . $class; - + // Use the contact URL if no address is available if ($contact["addr"] == "") $contact["addr"] = $contact["url"]; @@ -933,26 +941,23 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { else $url = zrl($url); } - $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); - if($click) + + // If there is some js available we don't need the url + if(x($contact,'click')) $url = ''; - if($textmode) { - return '
'. $contact['name'] . '
' . "\r\n"; - } - else { - return '
' . $contact['name']
-			. '
' . "\r\n"; - } -}} + + return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array( + '$click' => (($contact['click']) ? $contact['click'] : ''), + '$class' => $class, + '$url' => $url, + '$photo' => proxy_url($contact['micro'], false, PROXY_SIZE_THUMB), + '$name' => $contact['name'], + 'title' => $contact['name'] . ' [' . $contact['addr'] . ']', + '$parkle' => $sparkle, + '$redir' => $redir, + + )); +} diff --git a/view/templates/micropro_img.tpl b/view/templates/micropro_img.tpl new file mode 100644 index 0000000000..ff0ff15e67 --- /dev/null +++ b/view/templates/micropro_img.tpl @@ -0,0 +1,6 @@ + +
+ + {{$name}} + +
diff --git a/view/templates/micropro_txt.tpl b/view/templates/micropro_txt.tpl new file mode 100644 index 0000000000..27657ad63d --- /dev/null +++ b/view/templates/micropro_txt.tpl @@ -0,0 +1,6 @@ + +
+ + {{$name}} + +