From da05b9736ec0f2712d1a6828ff819aa12dd9e391 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 2 Jul 2013 16:37:33 -0700 Subject: some work on issue #62 (comments collapsing on liveupdate), but still a work in progress some work on photo consolidated "view/edit", but still a work in progress --- include/items.php | 3 -- js/main.js | 37 ++++++++----- mod/photos.php | 134 ++++++++++++++++++++---------------------------- version.inc | 2 +- view/tpl/photo_edit.tpl | 55 -------------------- view/tpl/photo_view.tpl | 55 ++++++++++++++++++-- 6 files changed, 133 insertions(+), 153 deletions(-) delete mode 100755 view/tpl/photo_edit.tpl diff --git a/include/items.php b/include/items.php index c4ffcbca6..a3d591899 100755 --- a/include/items.php +++ b/include/items.php @@ -1858,9 +1858,6 @@ function tag_deliver($uid,$item_id) { // See if we are the owner of the parent item and have given permission to tag our posts. // If so tag the parent post. - // FIXME --- If the item is deleted, remove the tag from the parent. - // (First ensure that deleted items use this function, or else do that part separately.) - logger('tag_deliver: community tag activity received'); if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { diff --git a/js/main.js b/js/main.js index 8b1114d19..c8c3ea48d 100644 --- a/js/main.js +++ b/js/main.js @@ -355,14 +355,22 @@ function updateConvItems(mode,data) { $('img',this).each(function() { $(this).attr('src',$(this).attr('dst')); }); -// expanded_comments = false; -// $('.collapsed-comments',this).each(function() { -// if($(this).is(':visible')) -// expanded_comments = this; -// }); + + // FIXME this doesn't work at all to prevent open comments from + // collapsing on update - but I'm leaving this experimental code here until + // I have time to dig into it again. Ideally we want to find + // the expanded comments div on the page and then expand the one we received + // over the wire (in the data variable) before placing the thread on the page, + // as then it won't blink. + + expanded_comments = false; + $('.collapsed-comments',this).each(function() { + if($('.thread-wrapper',this).is(':visible')) + expanded_comments = this; + }); $('#' + prev).after($(this)); -// if(expanded_comments) -// $(expanded_comments).show(); + if(expanded_comments) + $(expanded_comments).show(); $(".autotime").timeago(); // divgrow doesn't prevent itself from attaching a second (or 500th) // "show more" div to a content region - it also has a few other @@ -374,14 +382,15 @@ function updateConvItems(mode,data) { $('img',this).each(function() { $(this).attr('src',$(this).attr('dst')); }); -// expanded_comments = false; -// $('.collapsed-comments',this).each(function() { -// if($(this).is(':visible')) -// expanded_comments = this; -// }); + // more FIXME related to expanded comments + expanded_comments = false; + $('.collapsed-comments',this).each(function() { + if($('.thread-wrapper',this).is(':visible')) + expanded_comments = $(this); + }); $('#' + ident).replaceWith($(this)); -// if(expanded_comments) -// $(expanded_comments).show(); + if(expanded_comments) + $(expanded_comments).show(); $(".autotime").timeago(); // $("div.wall-item-body").divgrow({ initialHeight: 400 }); diff --git a/mod/photos.php b/mod/photos.php index 65bf866f1..f0b2b882e 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -633,6 +633,9 @@ function photos_content(&$a) { // dispatch request // + /** + * Display upload form + */ if($datatype === 'upload') { if(! ($can_post)) { @@ -640,12 +643,8 @@ function photos_content(&$a) { return; } - $selname = (($datum) ? hex2bin($datum) : ''); - - $albumselect = '
'; + /* Show space usage */ $r = q("select sum(size) as total from photo where uid = %d and scale = 0 ", intval($a->data['channel']['channel_id']) @@ -687,15 +687,8 @@ function photos_content(&$a) { $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 ); } - - if($a->get_template_engine() === 'internal') { - $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); - } - else { - $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); - } + $albumselect_e = $albumselect; + $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); $tpl = get_markup_template('photos_upload.tpl'); $o .= replace_macros($tpl,array( @@ -718,6 +711,10 @@ function photos_content(&$a) { return $o; } + /* + * Display a single photo album + */ + if($datatype === 'album') { $album = hex2bin($datum); @@ -793,6 +790,7 @@ function photos_content(&$a) { if(count($r)) $twist = 'rotright'; foreach($r as $rr) { + if($twist == 'rotright') $twist = 'rotleft'; else @@ -839,12 +837,12 @@ function photos_content(&$a) { } + /** + * Display one photo + */ if($datatype === 'image') { - - - //$o = ''; // fetch image, item containing image, then comments $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' @@ -853,13 +851,16 @@ function photos_content(&$a) { dbesc($datum) ); - if(! count($ph)) { + if(! $ph) { + + /* Check again - this time without specifying permissions */ + $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' LIMIT 1", intval($owner_uid), dbesc($datum) ); - if(count($ph)) + if($ph) notice( t('Permission denied. Access to this item may be restricted.')); else notice( t('Photo not available') . EOL ); @@ -893,9 +894,9 @@ function photos_content(&$a) { break; } } - $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); - $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); - $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + + $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } @@ -918,7 +919,6 @@ function photos_content(&$a) { if($can_post && ($ph[0]['uid'] == $owner_uid)) { $tools = array( - 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')), ); @@ -931,7 +931,7 @@ function photos_content(&$a) { } - if(! $cmd !== 'edit') { + if(! $can_post) { $a->page['htmlhead'] .= '