Merge pull request #2640 from rabuzarus/2506_micropro

move html from function micropro() to own templates
This commit is contained in:
Tobias Diekershoff 2016-06-25 19:47:23 +02:00 committed by GitHub
commit ce06b3ae4a
3 changed files with 45 additions and 28 deletions

View file

@ -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 array $contact Array with contacts which contains an array with
* @param boolean $redirect * int 'id' => The ID of the contact
* @param string $class * int 'uid' => The user ID of the user who owns this data
* @param boolean $textmode * string 'name' => The name of the contact
* @return string #FIXME: remove html * 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) { function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($class) // Use the contact URL if no address is available
$class = ' ' . $class;
if ($contact["addr"] == "") if ($contact["addr"] == "")
$contact["addr"] = $contact["url"]; $contact["addr"] = $contact["url"];
@ -933,26 +941,23 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
else else
$url = zrl($url); $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 = ''; $url = '';
if($textmode) {
return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
. (($click) ? ' fakelink' : '') . '" ' '$click' => (($contact['click']) ? $contact['click'] : ''),
. (($redir) ? ' target="redir" ' : '') '$class' => $class,
. (($url) ? ' href="' . $url . '"' : '') . $click '$url' => $url,
. '" title="' . $contact['name'] . ' [' . $contact['addr'] . ']" alt="' . $contact['name'] '$photo' => proxy_url($contact['micro'], false, PROXY_SIZE_THUMB),
. '" >'. $contact['name'] . '</a></div>' . "\r\n"; '$name' => $contact['name'],
'title' => $contact['name'] . ' [' . $contact['addr'] . ']',
'$parkle' => $sparkle,
'$redir' => $redir,
));
} }
else {
return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle
. (($click) ? ' fakelink' : '') . '" '
. (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="'
. proxy_url($contact['micro'], false, PROXY_SIZE_THUMB) . '" title="' . $contact['name'] . ' [' . $contact['addr'] . ']" alt="' . $contact['name']
. '" /></a></div>' . "\r\n";
}
}}

View file

@ -0,0 +1,6 @@
<div class="contact-block-div {{if $class}}{{$class}}{{/if}}">
<a class="contact-block-link {{if $class}}{{$class }}{{/if}} {{if $sparkle}}sparkle{{/if}} {{if $click}}fakelink{{/if}}" {{if $redir}}target="redir"{{/if}} {{if $url}}href="{{$url}}"{{/if}} {{if $click}}onclick="{{$click}}"{{/if}} >
<img class="contact-block-img {{if $class}}{{$class }}{{/if}} {{if $sparkle}}sparkle{{/if}}" src="{{$photo}}" title="{{$title}}" alt="{{$name}}" />
</a>
</div>

View file

@ -0,0 +1,6 @@
<div class="contact-block-textdiv {{if $class}}{{$class}}{{/if}}">
<a class="contact-block-link {{if $class}}{{$class }}{{/if}} {{if $sparkle}}sparkle{{/if}} {{if $click}}fakelink{{/if}}" {{if $redir}}target="redir"{{/if}} {{if $url}}href="{{$url}}"{{/if}} {{if $click}}onclick="{{$click}}"{{/if}} title="{{$title}}" alt="{{$name}}" />
{{$name}}
</a>
</div>