template-rework:make use of get_contact_details_by_url()

This commit is contained in:
rabuzarus 2015-11-03 14:31:15 +01:00
parent f196389580
commit e785759a8b
12 changed files with 111 additions and 40 deletions

View file

@ -245,7 +245,7 @@ function get_contact_details_by_url($url, $uid = -1) {
$profile["keywords"] = $r[0]["keywords"]; $profile["keywords"] = $r[0]["keywords"];
if (isset($r[0]["gender"]) AND $r[0]["gender"]) if (isset($r[0]["gender"]) AND $r[0]["gender"])
$profile["gender"] = $r[0]["gender"]; $profile["gender"] = $r[0]["gender"];
if (isset($r[0]["forum"]) AND isset($r[0]["prv"])) if (isset($r[0]["forum"]) OR isset($r[0]["prv"]))
$profile["community"] = ($r[0]["forum"] OR $r[0]["prv"]); $profile["community"] = ($r[0]["forum"] OR $r[0]["prv"]);
if (isset($r[0]["network"]) AND $r[0]["network"]) if (isset($r[0]["network"]) AND $r[0]["network"])
$profile["network"] = $r[0]["network"]; $profile["network"] = $r[0]["network"];

View file

@ -1,6 +1,8 @@
<?php <?php
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
function allfriends_content(&$a) { function allfriends_content(&$a) {
@ -16,6 +18,8 @@ function allfriends_content(&$a) {
if(! $cid) if(! $cid)
return; return;
$uid = $a->user[uid];
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid), intval($cid),
intval(local_user()) intval(local_user())
@ -46,14 +50,38 @@ function allfriends_content(&$a) {
foreach($r as $rr) { foreach($r as $rr) {
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid);
$photo_menu = '';
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
if ($rr[cid]) {
$rr[id] = $rr[cid];
$photo_menu = contact_photo_menu ($rr);
}
else {
$connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
$photo_menu = array(array(t("View Profile"), zrl($rr['url'])));
$photo_menu[] = array(t("Connect/Follow"), $connlnk);
}
$entry = array( $entry = array(
'url' => $rr['url'], 'url' => $rr['url'],
'itemurl' => $rr['url'], 'itemurl' => $rr['url'],
'name' => htmlentities($rr['name']), 'name' => htmlentities($rr['name']),
'thumb' => $rr['photo'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB),
'img_hover' => htmlentities($rr['name']), 'img_hover' => htmlentities($rr['name']),
'tags' => '', 'details' => $contact_details['location'],
'id' => ++$id, 'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;
} }

View file

@ -1,6 +1,8 @@
<?php <?php
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
function common_content(&$a) { function common_content(&$a) {
@ -11,8 +13,14 @@ function common_content(&$a) {
$cid = intval($a->argv[3]); $cid = intval($a->argv[3]);
$zcid = 0; $zcid = 0;
if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
if($cmd !== 'loc' && $cmd != 'rem') if($cmd !== 'loc' && $cmd != 'rem')
return; return;
if(! $uid) if(! $uid)
return; return;
@ -93,14 +101,28 @@ function common_content(&$a) {
foreach($r as $rr) { foreach($r as $rr) {
// $rr[id] is needed to use contact_photo_menu()
$rr[id] = $rr[cid];
$photo_menu = '';
$photo_menu = contact_photo_menu ($rr);
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid);
$entry = array( $entry = array(
'url' => $rr['url'], 'url' => $rr['url'],
'itemurl' => $rr['url'], 'itemurl' => $rr['url'],
'name' => htmlentities($rr['name']), 'name' => $rr['name'],
'thumb' => $rr['photo'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB),
'img_hover' => htmlentities($rr['name']), 'img_hover' => htmlentities($rr['name']),
'tags' => '', 'details' => $contact_details['location'],
'id' => ++$id, 'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;
} }

View file

@ -30,11 +30,16 @@
</div> </div>
<div class="contact-entry-desc"> <div class="contact-entry-desc">
<div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >{{$contact.name}}</div> <div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >
{{$contact.name}}
{{if $contact.account_type}} <span class="contact-entry-details" id="contact-entry-accounttype-{{$contact.id}}">({{$contact.account_type}})</span>{{/if}}
</div>
{{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}} {{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}}
{{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}} {{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}} {{if $contact.tags}}<div class="contact-entry-details" id="contact-entry-tags-{{$contact.id}}" >{{$contact.tags}}</div>{{/if}}
{{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}} {{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}}
</div> </div>
<div class="contact-entry-end" ></div> <div class="contact-entry-end" ></div>

View file

@ -13,28 +13,32 @@
{{if $contact.photo_menu}} {{if $contact.photo_menu}}
{{*<!-- <span onclick="openClose('contact-photo-menu-{{$contact.id}}');" class="fakelink contact-photo-menu-button" id="contact-photo-menu-button-{{$contact.id}}">menu</span>-->*}} {{*<!-- <span onclick="openClose('contact-photo-menu-{{$contact.id}}');" class="fakelink contact-photo-menu-button" id="contact-photo-menu-button-{{$contact.id}}">menu</span>-->*}}
<div class="contact-photo-menu" id="contact-photo-menu-{{$contact.id}}"> <div class="contact-photo-menu" id="contact-photo-menu-{{$contact.id}}">
<ul> <ul>
{{foreach $contact.photo_menu as $c}} {{foreach $contact.photo_menu as $c}}
{{if $c.2}} {{if $c.2}}
<li><a target="redir" href="{{$c.1}}">{{$c.0}}</a></li> <li><a target="redir" href="{{$c.1}}">{{$c.0}}</a></li>
{{else}} {{else}}
<li><a href="{{$c.1}}">{{$c.0}}</a></li> <li><a href="{{$c.1}}">{{$c.0}}</a></li>
{{/if}} {{/if}}
{{/foreach}} {{/foreach}}
</ul> </ul>
</div> </div>
{{/if}} {{/if}}
</div> </div>
</div> </div>
<div class="contact-entry-desc"> <div class="contact-entry-desc">
<div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >{{$contact.name}}</div> <div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >
{{$contact.name}}
{{if $contact.account_type}} <span class="contact-entry-details" id="contact-entry-accounttype-{{$contact.id}}">({{$contact.account_type}})</span>{{/if}}
</div>
{{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}} {{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}}
{{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}} {{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-network" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}} {{if $contact.tags}}<div class="contact-entry-details" id="contact-entry-tags-{{$contact.id}}" >{{$contact.tags}}</div>{{/if}}
{{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}} {{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-network" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}}
</div> </div>
<div class="contact-entry-end" ></div> <div class="contact-entry-end" ></div>

View file

@ -27,11 +27,15 @@
</div> </div>
<div class="contact-entry-desc"> <div class="contact-entry-desc">
<div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >{{$contact.name}}</div> <div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >
{{$contact.name}}
{{if $contact.account_type}} <span class="contact-entry-details" id="contact-entry-accounttype-{{$contact.id}}">({{$contact.account_type}})</span>{{/if}}
</div>
{{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}} {{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}}
{{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}} {{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-network" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}} {{if $contact.tags}}<div class="contact-entry-details" id="contact-entry-tags-{{$contact.id}}" >{{$contact.tags}}</div>{{/if}}
{{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}} {{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-network" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}}
</div> </div>
<div class="contact-entry-end" ></div> <div class="contact-entry-end" ></div>

View file

@ -1583,7 +1583,7 @@ span[id^="showmore-wrap"] {
} }
.contact-name { .contact-name {
font-weight: bold; font-weight: bold;
padding-top: 15px; /* padding-top: 15px; */
} }
.contact-details { .contact-details {
color: #999999; color: #999999;

View file

@ -1583,7 +1583,7 @@ span[id^="showmore-wrap"] {
} }
.contact-name { .contact-name {
font-weight: bold; font-weight: bold;
padding-top: 15px; /* padding-top: 15px; */
} }
.contact-details { .contact-details {
color: #999999; color: #999999;

View file

@ -1583,7 +1583,7 @@ span[id^="showmore-wrap"] {
} }
.contact-name { .contact-name {
font-weight: bold; font-weight: bold;
padding-top: 15px; /* padding-top: 15px; */
} }
.contact-details { .contact-details {
color: #999999; color: #999999;

View file

@ -908,7 +908,7 @@ span[id^="showmore-wrap"] {
img { width: 175px; height: 175px; } img { width: 175px; height: 175px; }
} }
} }
.contact-name { font-weight: bold; padding-top: 15px; } .contact-name { font-weight: bold; /* padding-top: 15px; */}
.contact-details { .contact-details {
color: @Grey3; white-space: nowrap; color: @Grey3; white-space: nowrap;
overflow: hidden; overflow: hidden;

View file

@ -26,11 +26,15 @@
</div> </div>
</div> </div>
<div class="contact-name" id="contact-entry-name-{{$contact.id}}" >{{$contact.name}}</div> <div class="contact-name" id="contact-entry-name-{{$contact.id}}" >
{{$contact.name}}
{{if $contact.account_type}} <span class="contact-entry-details" id="contact-entry-accounttype-{{$contact.id}}">({{$contact.account_type}})</span>{{/if}}
</div>
{{if $contact.alt_text}}<div class="contact-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}} {{if $contact.alt_text}}<div class="contact-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}}
{{if $contact.itemurl}}<div class="contact-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}} {{if $contact.itemurl}}<div class="contact-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}}
{{if $contact.network}}<div class="contact-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}} {{if $contact.tags}}<div class="contact-details" id="contact-entry-tags-{{$contact.id}}" >{{$contact.tags}}</div>{{/if}}
{{if $contact.details}}<div class="contact-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}} {{if $contact.details}}<div class="contact-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}}
{{if $contact.network}}<div class="contact-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}}
{{if $contact.connlnk}} {{if $contact.connlnk}}
<div class="contact-entry-connect"><a href="{{$contact.connlnk}}" title="{{$contact.conntxt}}">{{$contact.conntxt}}</a></div> <div class="contact-entry-connect"><a href="{{$contact.connlnk}}" title="{{$contact.conntxt}}">{{$contact.conntxt}}</a></div>

View file

@ -31,11 +31,15 @@
<div class="contact-entry-photo-end" ></div> <div class="contact-entry-photo-end" ></div>
<div class="contact-entry-desc"> <div class="contact-entry-desc">
<div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >{{$contact.name}}</div> <div class="contact-entry-name" id="contact-entry-name-{{$contact.id}}" >
{{$contact.name}}
{{if $contact.account_type}} <span class="contact-entry-details" id="contact-entry-accounttype-{{$contact.id}}">({{$contact.account_type}})</span>{{/if}}
</div>
{{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}} {{if $contact.alt_text}}<div class="contact-entry-details" id="contact-entry-rel-{{$contact.id}}" >{{$contact.alt_text}}</div>{{/if}}
{{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}} {{if $contact.itemurl}}<div class="contact-entry-details" id="contact-entry-url-{{$contact.id}}" >{{$contact.itemurl}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}} {{if $contact.tags}}<div class="contact-entry-details" id="contact-entry-tags-{{$contact.id}}" >{{$contact.tags}}</div>{{/if}}
{{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}} {{if $contact.details}}<div class="contact-entry-details" id="contact-entry-details-{{$contact.id}}" >{{$contact.details}}</div>{{/if}}
{{if $contact.network}}<div class="contact-entry-details" id="contact-entry-network-{{$contact.id}}" >{{$contact.network}}</div>{{/if}}
</div> </div>