From fd72f36ffe8b3a2f470c8cc0243f05adc260e358 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 25 Jun 2016 18:46:47 +0200 Subject: [PATCH] move html from function micropro() to own templates --- include/text.php | 61 ++++++++++++++++++--------------- view/templates/micropro_img.tpl | 6 ++++ view/templates/micropro_txt.tpl | 6 ++++ 3 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 view/templates/micropro_img.tpl create mode 100644 view/templates/micropro_txt.tpl 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 '
' . "\r\n"; - } - else { - return '' . "\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 @@ + +