photo tagging somewhat working - but can't remove photo tags until we update tagrm

This commit is contained in:
friendica 2014-02-03 20:44:42 -08:00
parent 9ce3dac479
commit 1572403e98
2 changed files with 27 additions and 7 deletions

View file

@ -763,7 +763,7 @@ function photos_content(&$a) {
/* Check again - this time without specifying permissions */
$ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'
$ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s'
and ( photo_flags = %d or photo_flags = %d )
LIMIT 1",
intval($owner_uid),
@ -875,6 +875,9 @@ function photos_content(&$a) {
if($linked_items) {
xchan_query($linked_items);
$linked_items = fetch_post_tags($linked_items,true);
$link_item = $linked_items[0];
$r = q("select * from item where parent_mid = '%s'
@ -890,6 +893,21 @@ function photos_content(&$a) {
$r = conv_sort($r,'commented');
}
$tags = array();
if($link_item['term']) {
$cnt = 0;
foreach($link_item['term'] as $t)
$tags[$cnt] = array(0 => format_term_for_display($t));
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tags[$cnt][1] = 'tagrm?f=&item=' . $link_item['id'];
$tags[$cnt][2] = t('Remove');
}
$cnt ++;
}
if((local_user()) && (local_user() == $link_item['uid'])) {
q("UPDATE `item` SET item_flags = (item_flags ^ %d) WHERE parent = %d and uid = %d and (item_flags & %d)",
intval(ITEM_UNSEEN),
@ -925,7 +943,6 @@ function photos_content(&$a) {
'capt_label' => t('Caption'),
'caption' => $caption_e,
'tag_label' => t('Add a Tag'),
'tags' => $link_item['tag'],
'permissions' => t('Permissions'),
'aclselect' => $aclselect_e,
'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
@ -1067,10 +1084,10 @@ function photos_content(&$a) {
}
$album_e = array($album_link,$ph[0]['album']);
$tags_e = $tags;
$like_e = $like;
$dislike_e = $dislike;
$photo_tpl = get_markup_template('photo_view.tpl');
$o .= replace_macros($photo_tpl, array(
'$id' => $ph[0]['id'],
@ -1081,7 +1098,8 @@ function photos_content(&$a) {
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
'$desc' => $ph[0]['description'],
'$tags' => $tags_e,
'$tag_hdr' => t('In This Photo:'),
'$tags' => $tags,
'$edit' => $edit,
'$likebuttons' => $likebuttons,
'$like' => $like_e,

View file

@ -14,10 +14,12 @@
<div id="photo-photo-end"></div>
<div id="photo-caption">{{$desc}}</div>
{{if $tags}}
<div id="in-this-photo-text">{{$tags.0}}</div>
<div id="in-this-photo">{{$tags.1}}</div>
<div id="in-this-photo-text">{{$tag_hdr}}</div>
{{foreach $tags as $t}}
<div id="in-this-photo">{{$t.0}}</div>
{{if $edit}}<div id="tag-remove"><a href="{{$t.1}}">{{$t.2}}</a></div>{{/if}}
{{/foreach}}
{{/if}}
{{if $tags.2}}<div id="tag-remove"><a href="{{$tags.2}}">{{$tags.3}}</a></div>{{/if}}
{{if $edit}}
<div id="photo-edit-edit-wrapper" class="fakelink" onclick="openClose('photo-edit-edit');">{{$edit.edit}}</div>