Moved popup logic in boot.php, added 'item_photo_menu' hook

This commit is contained in:
Fabio Comuni 2011-03-31 16:52:51 +02:00
parent 3f94721d62
commit fe67c346e5
7 changed files with 72 additions and 12 deletions

View File

@ -2669,3 +2669,55 @@ function extract_item_authors($arr,$uid) {
} }
return array(); return array();
}} }}
if(! function_exists('item_photo_menu')){
function item_photo_menu($item){
$a = get_app();
if (!isset($a->autors)){
$rr = q("SELECT id, network, url FROM contact WHERE uid=%d AND self!=1", intval(local_user()));
$authors = array();
foreach($rr as $r) $authors[$r['url']]= $r;
$a->authors = $authors;
}
$contact_url="";
$pm_url="";
$profile_link = ((strlen($item['author-link'])) ? $item['author-link']."?tab=profile" : $item['url']);
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
if(strlen($item['author-link'])) {
if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
$profile_link = $redirect_url;
$pm_url = $a->get_baseurl() . '/message/new/' . $item['cid'] ;
$contact_url = $item['self']?"":$a->get_baseurl() . '/contacts/' . $item['cid'] ;
}
elseif(isset($a->authors[$item['author-link']])) {
$profile_link = $a->get_baseurl() . '/redir/' . $a->authors[$item['author-link']]['id'];
if ($a->authors[$item['author-link']]['network']==='dfrn'){
$pm_url = $a->get_baseurl() . '/message/new/' . $a->authors[$item['author-link']]['id'];
}
$contact_url = $item['self']?"":$a->get_baseurl() . '/contacts/' . $a->authors[$item['author-link']]['id'] ;
}
}
$menu = Array(
t("View profile") => $profile_link,
t("Edit contact") => $contact_url,
t("Send PM") => $pm_url
);
$args = array($item, &$menu);
call_hooks('item_photo_menu', $args);
$o = "";
foreach($menu as $k=>$v){
if ($v!="") $o .= "<li><a href='$v'>$k</a></li>\n";
}
return $o;
}}

View File

@ -209,6 +209,7 @@ function network_content(&$a, $update = 0) {
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
} }
else { else {
@ -320,6 +321,7 @@ function network_content(&$a, $update = 0) {
'$id' => $item['item_id'], '$id' => $item['item_id'],
'$linktitle' => t('View $name\'s profile'), '$linktitle' => t('View $name\'s profile'),
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
'$name' => $profile_name, '$name' => $profile_name,
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
'$lock' => $lock, '$lock' => $lock,
@ -543,7 +545,6 @@ function network_content(&$a, $update = 0) {
$indent .= ' shiny'; $indent .= ' shiny';
$contact_url = $a->get_baseurl()."/contacts/".$item['cid'];
// Build the HTML // Build the HTML
@ -555,9 +556,7 @@ function network_content(&$a, $update = 0) {
'$wall' => t('Wall-to-Wall'), '$wall' => t('Wall-to-Wall'),
'$vwall' => t('via Wall-To-Wall:'), '$vwall' => t('via Wall-To-Wall:'),
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$profile_tab_url' => $profile_link."?tab=profile", //don't work with secure redirects '$item_photo_menu' => item_photo_menu($item),
'$contact_url' => $contact_url,
'$pm_url' => "",
'$name' => $profile_name, '$name' => $profile_name,
'$thumb' => $profile_avatar, '$thumb' => $profile_avatar,
'$osparkle' => $osparkle, '$osparkle' => $osparkle,

View File

@ -454,10 +454,12 @@ function profile_content(&$a, $update = 0) {
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$indent .= ' shiny'; $indent .= ' shiny';
$tmp_item = replace_macros($template,array( $tmp_item = replace_macros($template,array(
'$id' => $item['item_id'], '$id' => $item['item_id'],
'$linktitle' => t('View $name\'s profile'), '$linktitle' => t('View $name\'s profile'),
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
'$name' => $profile_name, '$name' => $profile_name,
'$thumb' => $profile_avatar, '$thumb' => $profile_avatar,
'$sparkle' => $sparkle, '$sparkle' => $sparkle,

View File

@ -115,6 +115,7 @@ function search_content(&$a) {
'$id' => $item['item_id'], '$id' => $item['item_id'],
'$linktitle' => t('View $name\'s profile'), '$linktitle' => t('View $name\'s profile'),
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
'$name' => $profile_name, '$name' => $profile_name,
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
'$lock' => $lock, '$lock' => $lock,

View File

@ -1,9 +1,17 @@
<div class="wall-item-outside-wrapper$indent" id="wall-item-outside-wrapper-$id" > <div class="wall-item-outside-wrapper$indent" id="wall-item-outside-wrapper-$id" >
<div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" > <div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" >
<span class="wall-item-info" id="wall-item-info-$id"> <span class="wall-item-info" id="wall-item-info-$id">
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" > <div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id"
onmouseover="if (typeof t$id != 'undefined') clearTimeout(t$id); openMenu('wall-item-photo-menu-button-$id')"
onmouseout="t$id=setTimeout('closeMenu(\'wall-item-photo-menu-button-$id\'); closeMenu(\'wall-item-photo-menu-$id\');',200)">
<a href="$profile_url" title="$linktitle" class="wall-item-photo-link" id="wall-item-photo-link-$id"> <a href="$profile_url" title="$linktitle" class="wall-item-photo-link" id="wall-item-photo-link-$id">
<img src="$thumb" class="wall-item-photo$sparkle" id="wall-item-photo-$id" height="80" width="80" alt="$name" /></a> <img src="$thumb" class="wall-item-photo$sparkle" id="wall-item-photo-$id" height="80" width="80" alt="$name" /></a>
<span onclick="openClose('wall-item-photo-menu-$id');" class="fakelink wall-item-photo-menu-button" id="wall-item-photo-menu-button-$id">menu</span>
<div class="wall-item-photo-menu" id="wall-item-photo-menu-$id">
<ul>
$item_photo_menu
</ul>
</div>
</div> </div>
<div class="wall-item-photo-end"></div> <div class="wall-item-photo-end"></div>
<div class="wall-item-wrapper" id="wall-item-wrapper-$id" > <div class="wall-item-wrapper" id="wall-item-wrapper-$id" >

View File

@ -882,7 +882,7 @@ input#dfrn-url {
} }
.wall-item-photo-menu { .wall-item-photo-menu {
width: 90px; width: auto;
border: 2px solid #444444; border: 2px solid #444444;
background: #FFFFFF; background: #FFFFFF;
position: absolute; position: absolute;
@ -892,7 +892,6 @@ input#dfrn-url {
.wall-item-photo-menu ul { margin:0px; padding: 0px; list-style: none } .wall-item-photo-menu ul { margin:0px; padding: 0px; list-style: none }
.wall-item-photo-menu li a { display: block; padding: 2px; } .wall-item-photo-menu li a { display: block; padding: 2px; }
.wall-item-photo-menu li a:hover { color: #FFFFFF; background: #3465A4; text-decoration: none; } .wall-item-photo-menu li a:hover { color: #FFFFFF; background: #3465A4; text-decoration: none; }
.wall-item-photo-menu li a[href=""] { display: none }
.comment .wall-item-photo-menu-button { top: 44px;} .comment .wall-item-photo-menu-button { top: 44px;}

View File

@ -2,16 +2,15 @@
<div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" > <div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" >
<span class="wall-item-info" id="wall-item-info-$id"> <span class="wall-item-info" id="wall-item-info-$id">
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" <div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id"
onmouseover="openMenu('wall-item-photo-menu-button-$id')" onmouseout="if (document.getElementById('wall-item-photo-menu-$id').style.display!='block')closeMenu('wall-item-photo-menu-button-$id');"> onmouseover="if (typeof t$id != 'undefined') clearTimeout(t$id); openMenu('wall-item-photo-menu-button-$id')"
onmouseout="t$id=setTimeout('closeMenu(\'wall-item-photo-menu-button-$id\'); closeMenu(\'wall-item-photo-menu-$id\');',200)">
<a href="$profile_url" title="$linktitle" class="wall-item-photo-link" id="wall-item-photo-link-$id"> <a href="$profile_url" title="$linktitle" class="wall-item-photo-link" id="wall-item-photo-link-$id">
<img src="$thumb" class="wall-item-photo$sparkle" id="wall-item-photo-$id" height="80" width="80" alt="$name" /> <img src="$thumb" class="wall-item-photo$sparkle" id="wall-item-photo-$id" height="80" width="80" alt="$name" />
</a> </a>
<span onclick="openClose('wall-item-photo-menu-$id');" class="fakelink wall-item-photo-menu-button" id="wall-item-photo-menu-button-$id">menu</span> <span onclick="openClose('wall-item-photo-menu-$id');" class="fakelink wall-item-photo-menu-button" id="wall-item-photo-menu-button-$id">menu</span>
<div class="wall-item-photo-menu" id="wall-item-photo-menu-$id"> <div class="wall-item-photo-menu" id="wall-item-photo-menu-$id">
<ul> <ul>
<li><a href='$profile_tab_url'>View profile</a></li> $item_photo_menu
<li><a href='$contact_url'>Edit contact</a></li>
<li><a href='$pm_url'>Send PM</a></li>
</ul> </ul>
</div> </div>
</div> </div>