X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=311d2b1c14e9639c1cdf7e9ed4fac9035d863f47;hb=221a659abeaf3bda3cefd88c80d1b7814f168f3e;hp=03b78e0e19f6b6cb2316832efe85b91ad424c7da;hpb=da124af6edfd788877307decc187fe7f0ff2b4c7;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index 03b78e0e19..311d2b1c14 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -36,6 +36,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; @@ -204,13 +205,13 @@ function photos_post(App $a) if (!DBA::isResult($r)) { notice(DI::l10n()->t('Album not found.') . EOL); - DI::baseUrl()->redirect($_SESSION['photo_return']); + 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 +268,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') { @@ -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(); @@ -421,16 +422,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 @@ -512,36 +511,31 @@ function photos_post(App $a) if (!empty($contact)) { $taginfo[] = [$newname, $profile, $notify, $contact, '@[url=' . str_replace(',', '%2c', $profile) . ']' . $newname . '[/url]']; } else { - $taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]']; - } - - if (strlen($str_tags)) { - $str_tags .= ','; + $taginfo[] = [$newname, $profile, $notify, null, '@[url=' . $profile . ']' . $newname . '[/url]']; } $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); @@ -615,10 +609,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)) { @@ -706,9 +700,7 @@ 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); @@ -1316,8 +1308,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) { @@ -1372,7 +1365,6 @@ 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'); @@ -1384,7 +1376,7 @@ function photos_content(App $a) $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"), + '$dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike') ? '' : DI::l10n()->t("I don't like this \x28toggle\x29"), '$wait' => DI::l10n()->t('Please wait'), '$return_path' => DI::args()->getQueryString(), ]); @@ -1413,10 +1405,17 @@ function photos_content(App $a) } $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) { @@ -1453,7 +1452,6 @@ function photos_content(App $a) foreach ($items as $item) { $comment = ''; $template = $tpl; - $sparkle = ''; $activity = DI::activity(); @@ -1515,9 +1513,6 @@ function photos_content(App $a) } } } - $response_verbs = ['like']; - $response_verbs[] = 'dislike'; - $responses = get_responses($conv_responses, $response_verbs, $link_item); $paginate = $pager->renderFull($total); } @@ -1538,7 +1533,6 @@ function photos_content(App $a) '$likebuttons' => $likebuttons, '$like' => $like, '$dislike' => $dislike, - 'responses' => $responses, '$comments' => $comments, '$paginate' => $paginate, ]);