From a0956ee9556d4daffdd3dff7eee408dc412bcb90 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 23:01:38 -0700 Subject: [PATCH] some w3c validation issues --- boot.php | 4 +- include/conversation.php | 94 ++++++++++++------ mod/profile.php | 200 ++------------------------------------- view/wall_item.tpl | 4 +- 4 files changed, 76 insertions(+), 226 deletions(-) diff --git a/boot.php b/boot.php index 92741eaee8..5d8417bd22 100644 --- a/boot.php +++ b/boot.php @@ -2301,9 +2301,9 @@ function profile_sidebar($profile) { $pubkey = ((x($profile,'pubkey') == 1) ? '' : ''); - $marital = ((x($profile,'marital') == 1) ? '
' . t('Status:') . ' ' . $profile['marital'] . '
' : ''); + $marital = ((x($profile,'marital') == 1) ? '
' . t('Status:') . ' ' . $profile['marital'] . '
' : ''); - $homepage = ((x($profile,'homepage') == 1) ? '
' . t('Homepage:') . ' ' . linkify($profile['homepage']) . '
' : ''); + $homepage = ((x($profile,'homepage') == 1) ? '
' . t('Homepage:') . ' ' . linkify($profile['homepage']) . '
' : ''); $tpl = load_view_file('view/profile_vcard.tpl'); diff --git a/include/conversation.php b/include/conversation.php index 943ebfeba6..52c11fff5b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -5,6 +5,21 @@ function conversation(&$a,$r, $mode, $update) { require_once('bbcode.php'); + $profile_owner = 0; + $writable = false; + + if($mode === 'network') { + $profile_owner = local_user(); + $writable = true; + } + + if($mode === 'profile') { + $profile_owner = $a->profile['profile_uid']; + $writable = can_write_wall($a,$profile_owner); + } + + + // find all the authors involved in remote conversations // We will use a local profile photo if they are one of our contacts // otherwise we have to get the photo from the item owner's site @@ -64,12 +79,22 @@ function conversation(&$a,$r, $mode, $update) { $location = '' . $coord . ''; } + $drop = ''; + $dropping = false; + + if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) + $dropping = true; + + $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete'))); + + + $drop = replace_macros($droptpl,array('$id' => $item['id'])); $lock = '
'; $o .= replace_macros($tpl,array( '$id' => $item['item_id'], - '$linktitle' => sprintf( t('View %s\s profile'), $profile_name), + '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name), '$profile_url' => $profile_link, '$item_photo_menu' => item_photo_menu($item), '$name' => $profile_name, @@ -192,7 +217,7 @@ function conversation(&$a,$r, $mode, $update) { $osparkle = ''; - if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + if(($item['parent'] == $item['item_id']) && (! $item['self']) && ($mode !== 'profile')) { if($item['type'] === 'wall') { // I do. Put me on the left of the wall-to-wall notice. @@ -224,35 +249,38 @@ function conversation(&$a,$r, $mode, $update) { $return_url = $_SESSION['return_url'] = $a->cmd; $likebuttons = ''; - if($item['id'] == $item['parent']) { - $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array( - '$id' => $item['id'], - '$likethis' => t("I like this \x28toggle\x29"), - '$nolike' => t("I don't like this \x28toggle\x29"), - '$share' => t('Share'), - '$wait' => t('Please wait') - )); - } - if($item['last-child']) { - $comment = replace_macros($cmnt_tpl,array( - '$return_path' => '', - '$jsreload' => '', // $_SESSION['return_url'], - '$type' => 'net-comment', - '$id' => $item['item_id'], - '$parent' => $item['parent'], - '$profile_uid' => $_SESSION['uid'], - '$mylink' => $a->contact['url'], - '$mytitle' => t('This is you'), - '$myphoto' => $a->contact['thumb'], - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$ww' => $commentww - )); + if($writable) { + if($item['id'] == $item['parent']) { + $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array( + '$id' => $item['id'], + '$likethis' => t("I like this \x28toggle\x29"), + '$nolike' => t("I don't like this \x28toggle\x29"), + '$share' => t('Share'), + '$wait' => t('Please wait') + )); + } + + if($item['last-child']) { + $comment = replace_macros($cmnt_tpl,array( + '$return_path' => '', + '$jsreload' => '', // $_SESSION['return_url'], + '$type' => 'net-comment', + '$id' => $item['item_id'], + '$parent' => $item['parent'], + '$profile_uid' => $profile_owner, + '$mylink' => $a->contact['url'], + '$mytitle' => t('This is you'), + '$myphoto' => $a->contact['thumb'], + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$ww' => $commentww + )); + } } $edpost = ''; - if(($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + if(($profile_owner == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) $edpost = ''; $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete'))); @@ -266,7 +294,17 @@ function conversation(&$a,$r, $mode, $update) { $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb); - if(strlen($item['author-link'])) { + if($mode === 'profile') { + if(local_user() && ($item['contact-uid'] == local_user()) && ($item['network'] === 'dfrn') && (! $item['self'] )) { + $profile_link = $redirect_url; + $sparkle = ' sparkle'; + } + else { + $profile_link = $item['url']; + $sparkle = ''; + } + } + elseif(strlen($item['author-link'])) { $profile_link = $item['author-link']; if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) { $profile_link = $redirect_url; diff --git a/mod/profile.php b/mod/profile.php index 88e23a8a46..f98c28f8fc 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -288,205 +288,17 @@ function profile_content(&$a, $update = 0) { if($is_owner && ! $update) $o .= get_birthdays(); - $cmnt_tpl = load_view_file('view/comment_item.tpl'); - $like_tpl = load_view_file('view/like.tpl'); - $noshare_tpl = load_view_file('view/like_noshare.tpl'); + require_once('include/conversation.php'); - $tpl = load_view_file('view/wall_item.tpl'); - - $droptpl = load_view_file('view/wall_item_drop.tpl'); - $fakedrop = load_view_file('view/wall_fake_drop.tpl'); - - if($update) - $return_url = $_SESSION['return_url']; - else - $return_url = $_SESSION['return_url'] = $a->cmd; - - $alike = array(); - $dlike = array(); - - if($r !== false && count($r)) { - - $comments = array(); - foreach($r as $rr) { - if(intval($rr['gravity']) == 6) { - if(! x($comments,$rr['parent'])) - $comments[$rr['parent']] = 1; - else - $comments[$rr['parent']] += 1; - } - } - - foreach($r as $item) { - like_puller($a,$item,$alike,'like'); - like_puller($a,$item,$dlike,'dislike'); - } - - $comments_collapsed = false; - - foreach($r as $item) { - - $sparkle = ''; - $comment = ''; - $likebuttons = ''; - - $template = $tpl; - - $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; - - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) - && ($item['id'] != $item['parent'])) - continue; - - if($item['id'] == $item['parent']) { - $comments_seen = 0; - $comments_collapsed = false; - } - else - $comments_seen ++; + $o .= conversation($a,$r,'profile',$display); - if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { - if(! $comments_collapsed) { - $o .= ''; - $o .= ''; - } - - $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) - || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) - ? '
' . t('Private Message') . '
' - : '
'); - - if(can_write_wall($a,$a->profile['profile_uid'])) { - if($item['id'] == $item['parent']) { - $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array( - '$id' => $item['id'], - '$likethis' => t("I like this \x28toggle\x29"), - '$nolike' => t("I don't like this \x28toggle\x29"), - '$share' => t('Share'), - '$wait' => t('Please wait') - )); - } - if($item['last-child']) { - $comment = replace_macros($cmnt_tpl,array( - '$return_path' => '', - '$jsreload' => '', // $_SESSION['return_url'], - '$type' => 'wall-comment', - '$id' => $item['item_id'], - '$parent' => $item['parent'], - '$profile_uid' => $a->profile['profile_uid'], - '$mylink' => $contact['url'], - '$mytitle' => t('This is you'), - '$myphoto' => $contact['thumb'], - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$ww' => '' - )); - } - } - - - $profile_url = $item['url']; - - // This is my profile page but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend, - // I can go directly to their profile as an authenticated guest. - - if(local_user() && ($item['contact-uid'] == local_user()) - && ($item['network'] === 'dfrn') && (! $item['self'] )) { - $profile_url = $redirect_url; - $sparkle = ' sparkle'; - } - else - $sparkle = ''; - - - $edpost = ''; - if((local_user()) && ($a->profile['profile_uid'] == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) - $edpost = ''; - - - // We would prefer to use our own avatar link for this item because the one in the author-avatar might reference a - // remote site (which could be down). We will use author-avatar if we haven't got something stored locally. - // We use this same logic block in mod/network.php to determine it this is a third party post and we don't have any - // local contact info at all. In this module you should never encounter a third-party author, but we still will do - // the right thing if you ever do. - - $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); - - $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']); - - $profile_link = $profile_url; - - $drop = ''; - $dropping = false; - - if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; - - $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete'))); - - - $like = ((isset($alike[$item['id']])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : ''); - $dislike = ((isset($dlike[$item['id']])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : ''); - $location = (($item['location']) ? '' . $item['location'] . '' : ''); - $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); - if($coord) { - if($location) - $location .= '
(' . $coord . ')'; - else - $location = '' . $coord . ''; - } - - $indent = (($item['parent'] != $item['item_id']) ? ' comment' : ''); - - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) - $indent .= ' shiny'; - - - $tmp_item = replace_macros($template,array( - '$id' => $item['item_id'], - '$linktitle' => t('View $name\'s profile'), - '$profile_url' => $profile_link, - '$item_photo_menu' => item_photo_menu($item), - '$name' => $profile_name, - '$thumb' => $profile_avatar, - '$sparkle' => $sparkle, - '$title' => $item['title'], - '$body' => smilies(bbcode($item['body'])), - '$ago' => relative_date($item['created']), - '$lock' => $lock, - '$location' => $location, - '$indent' => $indent, - '$plink' => get_plink($item), - '$edpost' => $edpost, - '$drop' => $drop, - '$like' => $like, - '$vote' => $likebuttons, - '$dislike' => $dislike, - '$comment' => $comment - )); - - $arr = array('item' => $item, 'output' => $tmp_item); - call_hooks('display_item', $arr); - - $o .= $arr['output']; - - } - } - - if($update) { - return $o; - } + if(! $update) { - $o .= paginate($a); - $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; + $o .= paginate($a); + $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; + } return $o; } diff --git a/view/wall_item.tpl b/view/wall_item.tpl index 8934832590..e17b63e5ae 100644 --- a/view/wall_item.tpl +++ b/view/wall_item.tpl @@ -1,6 +1,6 @@
- +
@@ -19,7 +19,7 @@ $lock
$location
- +
$name
$ago