From d8630dbdd8217ff31581bc521ceb1cd6be9b999c Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 1 Nov 2010 23:42:26 -0700 Subject: [PATCH] infrastructure for swat0 (#fsw) --- include/items.php | 4 +- mod/item.php | 6 +- mod/photos.php | 131 ++++++++++++++++++++++++++++++----- util/strings.php | 24 +++++-- view/photo_edit.tpl | 4 +- view/tag_slap.tpl | 30 ++++++++ view/theme/default/style.css | 7 +- 7 files changed, 172 insertions(+), 34 deletions(-) create mode 100644 view/tag_slap.tpl diff --git a/include/items.php b/include/items.php index 62f0876ad8..da85ed331d 100644 --- a/include/items.php +++ b/include/items.php @@ -1023,7 +1023,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { $a = get_app(); - $o = "\r\n"; + $o = "\r\n\r\n\r\n"; if(is_array($author)) $o .= atom_author('author',$author['name'],$author['url'],80,80,$author['thumb']); @@ -1033,7 +1033,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); if($item['parent'] != $item['id']) - $o .= '' . "\r\n"; + $o .= '' . "\r\n"; $o .= '' . xmlify($item['uri']) . '' . "\r\n"; $o .= '' . xmlify($item['title']) . '' . "\r\n"; diff --git a/mod/item.php b/mod/item.php index 703267992d..0389788ec9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -119,13 +119,13 @@ function item_post(&$a) { $tags = get_tags($body); - if($tags) { + if(count($tags)) { foreach($tags as $tag) { if(strpos($tag,'@') === 0) { $name = substr($tag,1); - if(strpos($name,'@')) { + if((strpos($name,'@')) || (strpos($name,'http://'))) { $newname = $name; - $links = @webfinger($name); + $links = @lrdd($name); if(count($links)) { foreach($links as $link) { if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') diff --git a/mod/photos.php b/mod/photos.php index c1027fa22e..28cc805add 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -3,6 +3,7 @@ require_once('Photo.php'); require_once('include/items.php'); require_once('view/acl_selectors.php'); +require_once('include/bbcode.php'); function photos_init(&$a) { @@ -179,19 +180,18 @@ function photos_post(&$a) { return; // NOTREACHED } + if(($a->argc > 1) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false))) { - - if(($a->argc > 1) && (x($_POST,'desc') !== false)) { - $desc = notags(trim($_POST['desc'])); - $tags = notags(trim($_POST['tags'])); - $item_id = intval($_POST['item_id']); + $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : ''); + $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); + $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); $resource_id = $a->argv[1]; $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC", dbesc($resource_id), intval(local_user()) ); - if(count($r)) { + if((count($p)) && ($p[0]['desc'] !== $desc)) { $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d", dbesc($desc), dbesc($resource_id), @@ -200,10 +200,11 @@ function photos_post(&$a) { } if(! $item_id) { + // Create item container + $title = ''; $basename = basename($filename); $uri = item_new_uri($a->get_hostname(),local_user()); - // Create item container $arr = array(); @@ -231,14 +232,100 @@ function photos_post(&$a) { } - $r = q("UPDATE `item` SET `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", - dbesc($tags), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item_id), - intval(local_user()) - ); + if($item_id) { + $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($item_id), + intval(local_user()) + ); + } + if(count($r)) { + $old_tag = $r[0]['tag']; + $old_inform = $r[0]['inform']; + } + if(strlen($rawtags)) { + + $str_tags = ''; + $inform = ''; + + // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag + + $x = substr($rawtags,0,1); + if($x !== '@' && $x !== '#') + $rawtags = '#' . $rawtags; + + $tags = get_tags($rawtags); + + if(count($tags)) { + foreach($tags as $tag) { + if(strpos($tag,'@') === 0) { + $name = substr($tag,1); + if((strpos($name,'@')) || (strpos($name,'http://'))) { + $newname = $name; + $links = @lrdd($name); + if(count($links)) { + foreach($links as $link) { + if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') + $profile = $link['@attributes']['href']; + if($link['@attributes']['rel'] === 'salmon') { + if(strlen($inform)) + $inform .= ','; + $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']); + } + } + } + } + else { + $newname = $name; + if(strstr($name,'_')) { + $newname = str_replace('_',' ',$name); + $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", + dbesc($newname), + intval(local_user()) + ); + } + else { + $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", + dbesc($name), + intval(local_user()) + ); + } + if(count($r)) { + $profile = $r[0]['url']; + if(strlen($inform)) + $inform .= ','; + $inform .= 'cid:' . $r[0]['id']; + } + } + if($profile) { + if(strlen($str_tags)) + $str_tags .= ','; + $profile = str_replace(',','%2c',$profile); + $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'; + } + } + } + } + + $newtag = $old_tag; + if(strlen($newtag) && strlen($str_tags)) + $newtag .= ','; + $newtag .= $str_tags; + + $newinform = $old_inform; + if(strlen($newinform) && strlen($inform)) + $newinform .= ','; + $newinform .= $inform; + + $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc($newtag), + dbesc($newinform), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item_id), + intval(local_user()) + ); + } goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); return; // NOTREACHED } @@ -656,9 +743,17 @@ function photos_content(&$a) { $o .= '
' . $ph[0]['desc'] . '
'; if(count($i1) && strlen($i1[0]['tag'])) { + $arr = explode(',',$i1[0]['tag']); // parse tags and add links - $o .= '
' . t('In this photo: ') . '
'; - $o .= '
' . $i1[0]['tag'] . '
'; + $o .= '
' . t('Tags: ') . '
'; + $o .= '
'; + $tag_str = ''; + foreach($arr as $t) { + if(strlen($tag_str)) + $tag_str .= ', '; + $tag_str .= bbcode($t); + } + $o .= $tag_str . '
'; } if($cmd === 'edit') { @@ -668,8 +763,9 @@ function photos_content(&$a) { '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => $ph[0]['desc'], - '$tag_label' => t('Tags'), + '$tag_label' => t('Add a Tag'), '$tags' => $i1[0]['tag'], + '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), '$item_id' => ((count($i1)) ? $i1[0]['id'] : 0), '$submit' => t('Submit'), '$delete' => t('Delete Photo') @@ -678,7 +774,6 @@ function photos_content(&$a) { } if(count($i1)) { - // pull out how many people like the photo $cmnt_tpl = load_view_file('view/comment_item.tpl'); $tpl = load_view_file('view/photo_item.tpl'); diff --git a/util/strings.php b/util/strings.php index 82897a3a17..43a751dc21 100644 --- a/util/strings.php +++ b/util/strings.php @@ -18,6 +18,9 @@ $a->strings[' other people'] = ' other people'; $a->strings[' like this.'] = ' like this.'; $a->strings[' don\'t like this.'] = ' don\'t like this.'; $a->strings["Invite Friends"] = "Invite Friends"; +$a->strings['Connect/Follow [profile address]'] = 'Connect/Follow [profile address]'; +$a->strings['Example: bob@example.com, http://example.com/barbara'] = 'Example: bob@example.com, http://example.com/barbara'; +$a->strings['Follow'] = 'Follow'; $a->strings['Could not access contact record.'] = 'Could not access contact record.'; $a->strings['Could not locate selected profile.'] = 'Could not locate selected profile.'; $a->strings['Contact updated.'] = 'Contact updated.'; @@ -46,13 +49,13 @@ $a->strings['Find'] = 'Find'; $a->strings['Visit '] = 'Visit '; $a->strings['\'s profile'] = '\'s profile'; $a->strings['Edit contact'] = 'Edit contact'; +$a->strings['Profile not found.'] = 'Profile not found.'; $a->strings['Response from remote site was not understood.'] = 'Response from remote site was not understood.'; $a->strings['Unexpected response from remote site: '] = 'Unexpected response from remote site: '; $a->strings["Confirmation completed successfully."] = "Confirmation completed successfully."; $a->strings['Remote site reported: '] = 'Remote site reported: '; $a->strings["Temporary failure. Please wait and try again."] = "Temporary failure. Please wait and try again."; $a->strings["Introduction failed or was revoked."] = "Introduction failed or was revoked."; -$a->strings['Contact Photos'] = 'Contact Photos'; $a->strings['Unable to set contact photo.'] = 'Unable to set contact photo.'; $a->strings['No user record found for '] = 'No user record found for '; $a->strings['Our site encryption key is apparently messed up.'] = 'Our site encryption key is apparently messed up.'; @@ -81,6 +84,7 @@ $a->strings['Profile unavailable.'] = 'Profile unavailable.'; $a->strings["Invalid locator"] = "Invalid locator"; $a->strings["Unable to resolve your name at the provided location."] = "Unable to resolve your name at the provided location."; $a->strings['You have already introduced yourself here.'] = 'You have already introduced yourself here.'; +$a->strings['Apparently you are already friends with .'] = 'Apparently you are already friends with .'; $a->strings['Invalid profile URL.'] = 'Invalid profile URL.'; $a->strings['Disallowed profile URL.'] = 'Disallowed profile URL.'; $a->strings['Your introduction has been sent.'] = 'Your introduction has been sent.'; @@ -92,6 +96,9 @@ $a->strings['Item not found.'] = 'Item not found.'; $a->strings['Private Message'] = 'Private Message'; $a->strings['This is you'] = 'This is you'; $a->strings['Item has been removed.'] = 'Item has been removed.'; +$a->strings['The profile address specified does not provide adequate information.'] = 'The profile address specified does not provide adequate information.'; +$a->strings['Unable to retrieve contact information.'] = 'Unable to retrieve contact information.'; +$a->strings['following'] = 'following'; $a->strings['Group created.'] = 'Group created.'; $a->strings['Could not create group.'] = 'Could not create group.'; $a->strings['Group not found.'] = 'Group not found.'; @@ -132,6 +139,7 @@ $a->strings['doesn\'t like'] = 'doesn\'t like'; $a->strings['\'s'] = '\'s'; $a->strings['Visible to:'] = 'Visible to:'; $a->strings['No recipient selected.'] = 'No recipient selected.'; +$a->strings['[no subject]'] = '[no subject]'; $a->strings['Unable to locate contact information.'] = 'Unable to locate contact information.'; $a->strings['Message sent.'] = 'Message sent.'; $a->strings['Message could not be sent.'] = 'Message could not be sent.'; @@ -159,10 +167,14 @@ $a->strings['Discard'] = 'Discard'; $a->strings['Ignore'] = 'Ignore'; $a->strings['Show Ignored Requests'] = 'Show Ignored Requests'; $a->strings['Hide Ignored Requests'] = 'Hide Ignored Requests'; +$a->strings['Claims to be known to you: '] = 'Claims to be known to you: '; $a->strings['yes'] = 'yes'; $a->strings['no'] = 'no'; +$a->strings['Friend/Connect Request'] = 'Friend/Connect Request'; +$a->strings['New Follower'] = 'New Follower'; $a->strings['No notifications.'] = 'No notifications.'; $a->strings['Photo Albums'] = 'Photo Albums'; +$a->strings['Contact Photos'] = 'Contact Photos'; $a->strings['Profile Photos'] = 'Profile Photos'; $a->strings['Album not found.'] = 'Album not found.'; $a->strings['Delete Album'] = 'Delete Album'; @@ -181,9 +193,10 @@ $a->strings['View Photo'] = 'View Photo'; $a->strings['Photo not available'] = 'Photo not available'; $a->strings['Edit photo'] = 'Edit photo'; $a->strings['View Full Size'] = 'View Full Size'; -$a->strings['In this photo: '] = 'In this photo: '; +$a->strings['Tags: '] = 'Tags: '; $a->strings['Caption'] = 'Caption'; -$a->strings['Tags'] = 'Tags'; +$a->strings['Add a Tag'] = 'Add a Tag'; +$a->strings['Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'] = 'Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'; $a->strings['Recent Photos'] = 'Recent Photos'; $a->strings['Upload New Photos'] = 'Upload New Photos'; $a->strings['View Album'] = 'View Album'; @@ -194,7 +207,6 @@ $a->strings['Image size reduction [80] failed.'] = 'Image size reduction [80] fa $a->strings['Unable to process image'] = 'Unable to process image'; $a->strings['Image uploaded successfully.'] = 'Image uploaded successfully.'; $a->strings['Image size reduction [640] failed.'] = 'Image size reduction [640] failed.'; -$a->strings['Profile not found.'] = 'Profile not found.'; $a->strings['Profile Name is required.'] = 'Profile Name is required.'; $a->strings['Profile updated.'] = 'Profile updated.'; $a->strings['Profile deleted.'] = 'Profile deleted.'; @@ -210,7 +222,6 @@ $a->strings[' Name too short.'] = ' Name too short.'; $a->strings[' That doesn\'t appear to be your full name.'] = ' That doesn\'t appear to be your full name.'; $a->strings[' Not valid email.'] = ' Not valid email.'; $a->strings[' Your email domain is not among those allowed on this site.'] = ' Your email domain is not among those allowed on this site.'; -$a->strings[' Your email address is already registered on this system.'] = ' Your email address is already registered on this system.'; $a->strings[' Nickname must start with a letter and contain only letters, numbers, dashes, or underscore.'] = ' Nickname must start with a letter and contain only letters, numbers, dashes, or underscore.'; $a->strings[' Nickname is already registered. Please choose another.'] = ' Nickname is already registered. Please choose another.'; $a->strings['An error occurred during registration. Please try again.'] = 'An error occurred during registration. Please try again.'; @@ -229,9 +240,8 @@ $a->strings['Passwords do not match. Password unchanged.'] = 'Passwords do not m $a->strings['Empty passwords are not allowed. Password unchanged.'] = 'Empty passwords are not allowed. Password unchanged.'; $a->strings['Password changed.'] = 'Password changed.'; $a->strings['Password update failed. Please try again.'] = 'Password update failed. Please try again.'; -$a->strings[' This email address is already registered.'] = ' This email address is already registered.'; $a->strings['Settings updated.'] = 'Settings updated.'; -$a->strings['Profile is not published.'] = 'Profile is not published.'; +$a->strings['Profile is not published.'] = 'Profile is not published.'; $a->strings['Default Post Permissions'] = 'Default Post Permissions'; $a->strings['View Contacts'] = 'View Contacts'; $a->strings['No contacts.'] = 'No contacts.'; diff --git a/view/photo_edit.tpl b/view/photo_edit.tpl index 176ad3244a..4fdc230e7f 100644 --- a/view/photo_edit.tpl +++ b/view/photo_edit.tpl @@ -8,8 +8,8 @@
- - + +
diff --git a/view/tag_slap.tpl b/view/tag_slap.tpl new file mode 100644 index 0000000000..6449df4967 --- /dev/null +++ b/view/tag_slap.tpl @@ -0,0 +1,30 @@ + + + $name + $profile_page + + + + + $item_id + $title + $published + $content + + + http://activitystrea.ms/schema/1.0/person + $profile_page + + + + $nick + $name + + $verb + + + + + + + diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 17e619dea2..da10e9da9a 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -1680,9 +1680,9 @@ a.mail-list-link:hover { float: left; width: 150px; } -#photo-edit-caption, #photo-edit-tags-textarea { +#photo-edit-caption, #photo-edit-newtag { float: left; - margin-bottom: 15px; + margin-bottom: 25px; } #photo-edit-caption-end, #photo-edit-tags-end { @@ -1692,6 +1692,9 @@ a.mail-list-link:hover { #photo-edit-delete-button { margin-left: 200px; } +#photo-edit-end { + margin-bottom: 35px; +} #photo-caption { font-size: 110%; font-weight: bold;