]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
Indentation
[friendica.git] / mod / photos.php
index 03b78e0e19f6b6cb2316832efe85b91ad424c7da..1a16f68026ffd39b50bd499bde525fe2231070fc 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\Content\Nav;
 use Friendica\Content\Pager;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\ACL;
+use Friendica\Core\Addon;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
@@ -36,6 +37,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Photo;
 use Friendica\Model\Profile;
+use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Module\BaseProfile;
 use Friendica\Network\Probe;
@@ -45,7 +47,7 @@ use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Util\Map;
-use Friendica\Util\Security;
+use Friendica\Security\Security;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 use Friendica\Util\XML;
@@ -81,7 +83,7 @@ function photos_init(App $a) {
                        '$photo' => $profile['photo'],
                        '$addr' => $profile['addr'] ?? '',
                        '$account_type' => $account_type,
-                       '$about' => BBCode::convert($profile['about'] ?? ''),
+                       '$about' => BBCode::convert($profile['about']),
                ]);
 
                $albums = Photo::getAlbums($a->data['user']['uid']);
@@ -174,14 +176,14 @@ function photos_post(App $a)
        }
 
        if (!$can_post) {
-               notice(DI::l10n()->t('Permission denied.') . EOL);
+               notice(DI::l10n()->t('Permission denied.'));
                exit();
        }
 
        $owner_record = User::getOwnerDataById($page_owner_uid);
 
        if (!$owner_record) {
-               notice(DI::l10n()->t('Contact information unavailable') . EOL);
+               notice(DI::l10n()->t('Contact information unavailable'));
                Logger::log('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
                exit();
        }
@@ -192,7 +194,7 @@ function photos_post(App $a)
                }
                $album = hex2bin($a->argv[3]);
 
-               if ($album === DI::l10n()->t('Profile Photos') || $album === 'Contact Photos' || $album === DI::l10n()->t('Contact Photos')) {
+               if ($album === DI::l10n()->t('Profile Photos') || $album === Photo::CONTACT_PHOTOS || $album === DI::l10n()->t(Photo::CONTACT_PHOTOS)) {
                        DI::baseUrl()->redirect($_SESSION['photo_return']);
                        return; // NOTREACHED
                }
@@ -203,14 +205,14 @@ function photos_post(App $a)
                );
 
                if (!DBA::isResult($r)) {
-                       notice(DI::l10n()->t('Album not found.') . EOL);
-                       DI::baseUrl()->redirect($_SESSION['photo_return']);
+                       notice(DI::l10n()->t('Album not found.'));
+                       DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
                        return; // NOTREACHED
                }
 
                // Check if the user has responded to a delete confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       DI::baseUrl()->redirect($_SESSION['photo_return']);
+                       DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album/' . $a->argv[3]);
                }
 
                // RENAME photo album
@@ -267,7 +269,7 @@ function photos_post(App $a)
                        }
                }
 
-               DI::baseUrl()->redirect('photos/' . $a->argv[1]);
+               DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
        }
 
        if ($a->argc > 3 && $a->argv[2] === 'image') {
@@ -294,9 +296,8 @@ function photos_post(App $a)
 
                                // Update the photo albums cache
                                Photo::clearAlbumCache($page_owner_uid);
-                               notice('Successfully deleted the photo.');
                        } else {
-                               notice('Failed to delete the photo.');
+                               notice(DI::l10n()->t('Failed to delete the photo.'));
                                DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
                        }
 
@@ -309,7 +310,7 @@ function photos_post(App $a)
                $desc        = !empty($_POST['desc'])      ? Strings::escapeTags(trim($_POST['desc']))      : '';
                $rawtags     = !empty($_POST['newtag'])    ? Strings::escapeTags(trim($_POST['newtag']))    : '';
                $item_id     = !empty($_POST['item_id'])   ? intval($_POST['item_id'])                      : 0;
-               $albname     = !empty($_POST['albname'])   ? Strings::escapeTags(trim($_POST['albname']))   : '';
+               $albname     = !empty($_POST['albname'])   ? trim($_POST['albname'])                        : '';
                $origaname   = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : '';
 
                $aclFormatter = DI::aclFormatter();
@@ -394,7 +395,6 @@ function photos_post(App $a)
                        $arr['guid']          = System::createUUID();
                        $arr['uid']           = $page_owner_uid;
                        $arr['uri']           = $uri;
-                       $arr['parent-uri']    = $uri;
                        $arr['post-type']     = Item::PT_IMAGE;
                        $arr['wall']          = 1;
                        $arr['resource-id']   = $photo['resource-id'];
@@ -421,16 +421,14 @@ function photos_post(App $a)
                }
 
                if ($item_id) {
-                       $item = Item::selectFirst(['tag', 'inform'], ['id' => $item_id, 'uid' => $page_owner_uid]);
+                       $item = Item::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]);
 
                        if (DBA::isResult($item)) {
-                               $old_tag    = $item['tag'];
                                $old_inform = $item['inform'];
                        }
                }
 
                if (strlen($rawtags)) {
-                       $str_tags = '';
                        $inform   = '';
 
                        // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
@@ -510,38 +508,33 @@ function photos_post(App $a)
 
                                                if ($profile) {
                                                        if (!empty($contact)) {
-                                                               $taginfo[] = [$newname, $profile, $notify, $contact, '@[url=' . str_replace(',', '%2c', $profile) . ']' . $newname . '[/url]'];
+                                                               $taginfo[] = [$newname, $profile, $notify, $contact];
                                                        } else {
-                                                               $taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'];
-                                                       }
-
-                                                       if (strlen($str_tags)) {
-                                                               $str_tags .= ',';
+                                                               $taginfo[] = [$newname, $profile, $notify, null];
                                                        }
 
                                                        $profile = str_replace(',', '%2c', $profile);
-                                                       $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
+
+                                                       if (!empty($item['uri-id'])) {
+                                                               Tag::store($item['uri-id'], Tag::MENTION, $newname, $profile);
+                                                       }       
                                                }
                                        } elseif (strpos($tag, '#') === 0) {
                                                $tagname = substr($tag, 1);
-                                               $str_tags .= '#[url=' . DI::baseUrl() . "/search?tag=" . $tagname . ']' . $tagname . '[/url],';
+                                               if (!empty($item['uri-id'])) {
+                                                       Tag::store($item['uri-id'], Tag::HASHTAG, $tagname);
+                                               }
                                        }
                                }
                        }
 
-                       $newtag = $old_tag ?? '';
-                       if (strlen($newtag) && strlen($str_tags)) {
-                               $newtag .= ',';
-                       }
-                       $newtag .= $str_tags;
-
                        $newinform = $old_inform ?? '';
                        if (strlen($newinform) && strlen($inform)) {
                                $newinform .= ',';
                        }
                        $newinform .= $inform;
 
-                       $fields = ['tag' => $newtag, 'inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
+                       $fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
                        $condition = ['id' => $item_id];
                        Item::update($fields, $condition);
 
@@ -566,7 +559,6 @@ function photos_post(App $a)
                                        $arr['guid']          = System::createUUID();
                                        $arr['uid']           = $page_owner_uid;
                                        $arr['uri']           = $uri;
-                                       $arr['parent-uri']    = $uri;
                                        $arr['wall']          = 1;
                                        $arr['contact-id']    = $owner_record['id'];
                                        $arr['owner-name']    = $owner_record['name'];
@@ -585,7 +577,6 @@ function photos_post(App $a)
                                        $arr['gravity']       = GRAVITY_PARENT;
                                        $arr['object-type']   = Activity\ObjectType::PERSON;
                                        $arr['target-type']   = Activity\ObjectType::IMAGE;
-                                       $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
                                        $arr['origin']        = 1;
                                        $arr['body']          = DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
@@ -615,10 +606,10 @@ function photos_post(App $a)
        Hook::callAll('photo_post_init', $_POST);
 
        // Determine the album to use
-       $album    = !empty($_REQUEST['album'])    ? Strings::escapeTags(trim($_REQUEST['album']))    : '';
-       $newalbum = !empty($_REQUEST['newalbum']) ? Strings::escapeTags(trim($_REQUEST['newalbum'])) : '';
+       $album    = trim($_REQUEST['album'] ?? '');
+       $newalbum = trim($_REQUEST['newalbum'] ?? '');
 
-       Logger::log('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , Logger::DEBUG);
+       Logger::info('album= ' . $album . ' newalbum= ' . $newalbum);
 
        if (!strlen($album)) {
                if (strlen($newalbum)) {
@@ -683,21 +674,21 @@ function photos_post(App $a)
        if ($error !== UPLOAD_ERR_OK) {
                switch ($error) {
                        case UPLOAD_ERR_INI_SIZE:
-                               notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
+                               notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
                                break;
                        case UPLOAD_ERR_FORM_SIZE:
-                               notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL);
+                               notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
                                break;
                        case UPLOAD_ERR_PARTIAL:
-                               notice(DI::l10n()->t('Image upload didn\'t complete, please try again') . EOL);
+                               notice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
                                break;
                        case UPLOAD_ERR_NO_FILE:
-                               notice(DI::l10n()->t('Image file is missing') . EOL);
+                               notice(DI::l10n()->t('Image file is missing'));
                                break;
                        case UPLOAD_ERR_NO_TMP_DIR:
                        case UPLOAD_ERR_CANT_WRITE:
                        case UPLOAD_ERR_EXTENSION:
-                               notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator') . EOL);
+                               notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
                                break;
                }
                @unlink($src);
@@ -706,16 +697,14 @@ function photos_post(App $a)
                return;
        }
 
-       if ($type == "") {
-               $type = Images::guessType($filename);
-       }
+       $type = Images::getMimeTypeBySource($src, $filename, $type);
 
        Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', Logger::DEBUG);
 
        $maximagesize = DI::config()->get('system', 'maximagesize');
 
        if ($maximagesize && ($filesize > $maximagesize)) {
-               notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL);
+               notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
                @unlink($src);
                $foo = 0;
                Hook::callAll('photo_post_end', $foo);
@@ -723,7 +712,7 @@ function photos_post(App $a)
        }
 
        if (!$filesize) {
-               notice(DI::l10n()->t('Image file is empty.') . EOL);
+               notice(DI::l10n()->t('Image file is empty.'));
                @unlink($src);
                $foo = 0;
                Hook::callAll('photo_post_end', $foo);
@@ -738,7 +727,7 @@ function photos_post(App $a)
 
        if (!$image->isValid()) {
                Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG);
-               notice(DI::l10n()->t('Unable to process image.') . EOL);
+               notice(DI::l10n()->t('Unable to process image.'));
                @unlink($src);
                $foo = 0;
                Hook::callAll('photo_post_end',$foo);
@@ -767,7 +756,7 @@ function photos_post(App $a)
 
        if (!$r) {
                Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
-               notice(DI::l10n()->t('Image upload failed.') . EOL);
+               notice(DI::l10n()->t('Image upload failed.'));
                return;
        }
 
@@ -787,7 +776,7 @@ function photos_post(App $a)
 
        // Create item container
        $lat = $lon = null;
-       if ($exif && $exif['GPS'] && Feature::isEnabled($page_owner_uid, 'photo_location')) {
+       if (!empty($exif['GPS']) && Feature::isEnabled($page_owner_uid, 'photo_location')) {
                $lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
                $lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
        }
@@ -800,7 +789,6 @@ function photos_post(App $a)
        $arr['guid']          = System::createUUID();
        $arr['uid']           = $page_owner_uid;
        $arr['uri']           = $uri;
-       $arr['parent-uri']    = $uri;
        $arr['type']          = 'photo';
        $arr['wall']          = 1;
        $arr['resource-id']   = $resource_id;
@@ -850,12 +838,12 @@ function photos_content(App $a)
        // photos/name/image/xxxxx/drop
 
        if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
-               notice(DI::l10n()->t('Public access denied.') . EOL);
+               notice(DI::l10n()->t('Public access denied.'));
                return;
        }
 
        if (empty($a->data['user'])) {
-               notice(DI::l10n()->t('No photos selected') . EOL);
+               notice(DI::l10n()->t('No photos selected'));
                return;
        }
 
@@ -921,7 +909,7 @@ function photos_content(App $a)
        }
 
        if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
-               notice(DI::l10n()->t('Access to this item is restricted.') . EOL);
+               notice(DI::l10n()->t('Access to this item is restricted.'));
                return;
        }
 
@@ -947,7 +935,7 @@ function photos_content(App $a)
                $albumselect .= '<option value="" ' . (!$selname ? ' selected="selected" ' : '') . '>&lt;current year&gt;</option>';
                if (!empty($a->data['albums'])) {
                        foreach ($a->data['albums'] as $album) {
-                               if (($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === DI::l10n()->t('Contact Photos'))) {
+                               if (($album['album'] === '') || ($album['album'] === Photo::CONTACT_PHOTOS) || ($album['album'] === DI::l10n()->t(Photo::CONTACT_PHOTOS))) {
                                        continue;
                                }
                                $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
@@ -997,8 +985,6 @@ function photos_content(App $a)
                        '$uploadurl' => $ret['post_url'],
 
                        // ACL permissions box
-                       '$group_perms' => DI::l10n()->t('Show to Groups'),
-                       '$contact_perms' => DI::l10n()->t('Show to Contacts'),
                        '$return_path' => DI::args()->getQueryString(),
                ]);
 
@@ -1050,7 +1036,6 @@ function photos_content(App $a)
                        return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
                                '$method' => 'post',
                                '$message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
-                               '$extra_inputs' => [],
                                '$confirm' => DI::l10n()->t('Delete Album'),
                                '$confirm_url' => $drop_url,
                                '$confirm_name' => 'dropalbum',
@@ -1060,7 +1045,7 @@ function photos_content(App $a)
 
                // edit album name
                if ($cmd === 'edit') {
-                       if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== DI::l10n()->t('Contact Photos'))) {
+                       if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS))) {
                                if ($can_post) {
                                        $edit_tpl = Renderer::getMarkupTemplate('album_edit.tpl');
 
@@ -1077,7 +1062,7 @@ function photos_content(App $a)
                                }
                        }
                } else {
-                       if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== DI::l10n()->t('Contact Photos')) && $can_post) {
+                       if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS)) && $can_post) {
                                $edit = [DI::l10n()->t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'];
                                $drop = [DI::l10n()->t('Drop Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/drop'];
                        }
@@ -1146,7 +1131,7 @@ function photos_content(App $a)
                        if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
                                notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.'));
                        } else {
-                               notice(DI::l10n()->t('Photo not available') . EOL);
+                               notice(DI::l10n()->t('Photo not available'));
                        }
                        return;
                }
@@ -1157,7 +1142,6 @@ function photos_content(App $a)
                        return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
                                '$method' => 'post',
                                '$message' => DI::l10n()->t('Do you really want to delete this photo?'),
-                               '$extra_inputs' => [],
                                '$confirm' => DI::l10n()->t('Delete Photo'),
                                '$confirm_url' => $drop_url,
                                '$confirm_name' => 'delete',
@@ -1296,7 +1280,7 @@ function photos_content(App $a)
                }
 
                if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
-                       $condition = ["`parent` = ? AND `parent` != `id`",  $link_item['parent']];
+                       $condition = ["`parent` = ? AND `gravity` != ?",  $link_item['parent'], GRAVITY_PARENT];
                        $total = DBA::count('item', $condition);
 
                        $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
@@ -1316,8 +1300,9 @@ function photos_content(App $a)
 
                $tags = null;
 
-               if (!empty($link_item['id']) && !empty($link_item['tag'])) {
-                       $arr = explode(',', $link_item['tag']);
+               if (!empty($link_item['id'])) {
+                       $tag_text = Tag::getCSVByURIId($link_item['uri-id']);
+                       $arr = explode(',', $tag_text);
                        // parse tags and add links
                        $tag_arr = [];
                        foreach ($arr as $tag) {
@@ -1361,8 +1346,6 @@ function photos_content(App $a)
                                '$delete' => DI::l10n()->t('Delete Photo'),
 
                                // ACL permissions box
-                               '$group_perms' => DI::l10n()->t('Show to Groups'),
-                               '$contact_perms' => DI::l10n()->t('Show to Contacts'),
                                '$return_path' => DI::args()->getQueryString(),
                        ]);
                }
@@ -1372,26 +1355,24 @@ function photos_content(App $a)
                $likebuttons = '';
                $comments = '';
                $paginate = '';
-               $responses = '';
 
                if (!empty($link_item['id']) && !empty($link_item['uri'])) {
                        $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
                        $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
                        $return_path = DI::args()->getCommand();
 
-                       if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
-                               $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
-                               $likebuttons = Renderer::replaceMacros($like_tpl, [
-                                       '$id' => $link_item['id'],
-                                       '$likethis' => DI::l10n()->t("I like this \x28toggle\x29"),
-                                       '$nolike' => DI::l10n()->t("I don't like this \x28toggle\x29"),
-                                       '$wait' => DI::l10n()->t('Please wait'),
-                                       '$return_path' => DI::args()->getQueryString(),
-                               ]);
-                       }
-
                        if (!DBA::isResult($items)) {
                                if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+                                       /*
+                                        * Hmmm, code depending on the presence of a particular addon?
+                                        * This should be better if done by a hook
+                                        */
+                                       $qcomment = null;
+                                       if (Addon::isEnabled('qcomment')) {
+                                               $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+                                               $qcomment = $words ? explode("\n", $words) : [];
+                                       }
+
                                        $comments .= Renderer::replaceMacros($cmnt_tpl, [
                                                '$return_path' => '',
                                                '$jsreload' => $return_path,
@@ -1406,17 +1387,24 @@ function photos_content(App $a)
                                                '$preview' => DI::l10n()->t('Preview'),
                                                '$loading' => DI::l10n()->t('Loading...'),
                                                '$sourceapp' => DI::l10n()->t($a->sourcename),
-                                               '$ww' => '',
+                                               '$qcomment' => $qcomment,
                                                '$rand_num' => Crypto::randomDigits(12)
                                        ]);
                                }
                        }
 
                        $conv_responses = [
-                               'like' => ['title' => DI::l10n()->t('Likes','title')],'dislike' => ['title' => DI::l10n()->t('Dislikes','title')],
-                               'attendyes' => ['title' => DI::l10n()->t('Attending','title')], 'attendno' => ['title' => DI::l10n()->t('Not attending','title')], 'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')]
+                               'like'        => [],
+                               'dislike'     => [],
+                               'attendyes'   => [],
+                               'attendno'    => [],
+                               'attendmaybe' => []
                        ];
 
+                       if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
+                               unset($conv_responses['dislike']);
+                       }
+
                        // display comments
                        if (DBA::isResult($items)) {
                                foreach ($items as $item) {
@@ -1424,14 +1412,24 @@ function photos_content(App $a)
                                }
 
                                if (!empty($conv_responses['like'][$link_item['uri']])) {
-                                       $like = format_like($conv_responses['like'][$link_item['uri']], $conv_responses['like'][$link_item['uri'] . '-l'], 'like', $link_item['id']);
+                                       $like = format_activity($conv_responses['like'][$link_item['uri']]['links'], 'like', $link_item['id']);
                                }
 
                                if (!empty($conv_responses['dislike'][$link_item['uri']])) {
-                                       $dislike = format_like($conv_responses['dislike'][$link_item['uri']], $conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike', $link_item['id']);
+                                       $dislike = format_activity($conv_responses['dislike'][$link_item['uri']]['links'], 'dislike', $link_item['id']);
                                }
 
                                if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+                                       /*
+                                        * Hmmm, code depending on the presence of a particular addon?
+                                        * This should be better if done by a hook
+                                        */
+                                       $qcomment = null;
+                                       if (Addon::isEnabled('qcomment')) {
+                                               $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+                                               $qcomment = $words ? explode("\n", $words) : [];
+                                       }
+
                                        $comments .= Renderer::replaceMacros($cmnt_tpl,[
                                                '$return_path' => '',
                                                '$jsreload' => $return_path,
@@ -1445,7 +1443,7 @@ function photos_content(App $a)
                                                '$submit' => DI::l10n()->t('Submit'),
                                                '$preview' => DI::l10n()->t('Preview'),
                                                '$sourceapp' => DI::l10n()->t($a->sourcename),
-                                               '$ww' => '',
+                                               '$qcomment' => $qcomment,
                                                '$rand_num' => Crypto::randomDigits(12)
                                        ]);
                                }
@@ -1453,13 +1451,12 @@ function photos_content(App $a)
                                foreach ($items as $item) {
                                        $comment = '';
                                        $template = $tpl;
-                                       $sparkle = '';
 
                                        $activity = DI::activity();
 
                                        if (($activity->match($item['verb'], Activity::LIKE) ||
                                             $activity->match($item['verb'], Activity::DISLIKE)) &&
-                                           ($item['id'] != $item['parent'])) {
+                                           ($item['gravity'] != GRAVITY_PARENT)) {
                                                continue;
                                        }
 
@@ -1496,6 +1493,16 @@ function photos_content(App $a)
                                        ]);
 
                                        if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+                                               /*
+                                                * Hmmm, code depending on the presence of a particular addon?
+                                                * This should be better if done by a hook
+                                                */
+                                               $qcomment = null;
+                                               if (Addon::isEnabled('qcomment')) {
+                                                       $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+                                                       $qcomment = $words ? explode("\n", $words) : [];
+                                               }
+
                                                $comments .= Renderer::replaceMacros($cmnt_tpl, [
                                                        '$return_path' => '',
                                                        '$jsreload' => $return_path,
@@ -1509,15 +1516,34 @@ function photos_content(App $a)
                                                        '$submit' => DI::l10n()->t('Submit'),
                                                        '$preview' => DI::l10n()->t('Preview'),
                                                        '$sourceapp' => DI::l10n()->t($a->sourcename),
-                                                       '$ww' => '',
+                                                       '$qcomment' => $qcomment,
                                                        '$rand_num' => Crypto::randomDigits(12)
                                                ]);
                                        }
                                }
                        }
-                       $response_verbs = ['like'];
-                       $response_verbs[] = 'dislike';
-                       $responses = get_responses($conv_responses, $response_verbs, $link_item);
+
+                       $responses = [];
+                       foreach ($conv_responses as $verb => $activity) {
+                               if (isset($activity[$link_item['uri']])) {
+                                       $responses[$verb] = $activity[$link_item['uri']];
+                               }
+                       }
+
+                       if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
+                               $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
+                               $likebuttons = Renderer::replaceMacros($like_tpl, [
+                                       '$id' => $link_item['id'],
+                                       '$like' => DI::l10n()->t('Like'),
+                                       '$like_title' => DI::l10n()->t('I like this (toggle)'),
+                                       '$dislike' => DI::l10n()->t('Dislike'),
+                                       '$wait' => DI::l10n()->t('Please wait'),
+                                       '$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
+                                       '$hide_dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike'),
+                                       '$responses' => $responses,
+                                       '$return_path' => DI::args()->getQueryString(),
+                               ]);
+                       }
 
                        $paginate = $pager->renderFull($total);
                }
@@ -1538,7 +1564,6 @@ function photos_content(App $a)
                        '$likebuttons' => $likebuttons,
                        '$like' => $like,
                        '$dislike' => $dislike,
-                       'responses' => $responses,
                        '$comments' => $comments,
                        '$paginate' => $paginate,
                ]);
@@ -1558,8 +1583,8 @@ function photos_content(App $a)
        $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
                $sql_extra GROUP BY `resource-id`",
                intval($a->data['user']['uid']),
-               DBA::escape('Contact Photos'),
-               DBA::escape(DI::l10n()->t('Contact Photos'))
+               DBA::escape(Photo::CONTACT_PHOTOS),
+               DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS))
        );
        if (DBA::isResult($r)) {
                $total = count($r);
@@ -1573,8 +1598,8 @@ function photos_content(App $a)
                WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
                $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
                intval($a->data['user']['uid']),
-               DBA::escape('Contact Photos'),
-               DBA::escape(DI::l10n()->t('Contact Photos')),
+               DBA::escape(Photo::CONTACT_PHOTOS),
+               DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)),
                $pager->getStart(),
                $pager->getItemsPerPage()
        );