Menu option to display the search text

This commit is contained in:
Michael 2024-04-05 07:35:21 +00:00
parent 44344af055
commit 50b1de5959
9 changed files with 152 additions and 44 deletions

View file

@ -443,6 +443,8 @@ class Item
$menu[$this->l10n->t('Languages')] = 'javascript:alert(\'' . ItemModel::getLanguageMessage($item) . '\');'; $menu[$this->l10n->t('Languages')] = 'javascript:alert(\'' . ItemModel::getLanguageMessage($item) . '\');';
} }
$menu[$this->l10n->t('Search Text')] = 'javascript:displaySearchText(' . $item['uri-id'] . ');';
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) && if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
in_array($item['network'], Protocol::FEDERATED) in_array($item['network'], Protocol::FEDERATED)
) { ) {

View file

@ -418,4 +418,12 @@ class Engagement
} }
return $fullTextSearch; return $fullTextSearch;
} }
public static function unescapeKeywords(string $fullTextSearch): string
{
foreach (self::KEYWORDS as $keyword) {
$fullTextSearch = preg_replace('~(' . $keyword . ')_(.[\w\*@\.-]+)~', '$1:$2', $fullTextSearch);
}
return $fullTextSearch;
}
} }

View file

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (C) 2010-2024, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Module\Item;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\DBA;
use Friendica\Model\Post;
use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
/**
* Return the search text of a given item id
*/
class Searchtext extends BaseModule
{
/** @var IHandleUserSessions */
private $session;
public function __construct(IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->session = $session;
}
protected function rawContent(array $request = [])
{
if (!$this->session->isAuthenticated()) {
throw new HttpException\ForbiddenException($this->l10n->t('Access denied.'));
}
if (empty($this->parameters['id'])) {
throw new HTTPException\BadRequestException();
}
$item = Post::selectFirstForUser($this->session->getLocalUserId(), ['uri-id'], ['uid' => [0, $this->session->getLocalUserId()], 'uri-id' => $this->parameters['id']]);
if (empty($item)) {
throw new HTTPException\NotFoundException();
}
$search = DBA::selectFirst('post-searchindex', [], ['uri-id' => $item['uri-id']]);
if (empty($search)) {
throw new HTTPException\NotFoundException();
}
$this->httpExit(Post\Engagement::unescapeKeywords($search['searchtext']));
}
}

View file

@ -600,6 +600,7 @@ class Post
'tagger' => $tagger, 'tagger' => $tagger,
'filer' => $filer, 'filer' => $filer,
'language' => $languages, 'language' => $languages,
'searchtext' => DI::l10n()->t('Search Text'),
'drop' => $drop, 'drop' => $drop,
'block' => $block, 'block' => $block,
'ignore_author' => $ignore, 'ignore_author' => $ignore,

View file

@ -390,6 +390,8 @@ return [
'/event/{mode:edit|copy}/{id:\d+}' => [Module\Calendar\Event\Form::class, [R::GET ]], '/event/{mode:edit|copy}/{id:\d+}' => [Module\Calendar\Event\Form::class, [R::GET ]],
], ],
// '/callback/searchtext',
'/channel[/{content}]' => [Module\Conversation\Channel::class, [R::GET]], '/channel[/{content}]' => [Module\Conversation\Channel::class, [R::GET]],
'/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]], '/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],
@ -482,6 +484,7 @@ return [
'/ignore' => [Module\Item\Ignore::class, [ R::POST]], '/ignore' => [Module\Item\Ignore::class, [ R::POST]],
'/pin' => [Module\Item\Pin::class, [ R::POST]], '/pin' => [Module\Item\Pin::class, [ R::POST]],
'/star' => [Module\Item\Star::class, [ R::POST]], '/star' => [Module\Item\Star::class, [ R::POST]],
'/searchtext' => [Module\Item\Searchtext::class, [R::GET]],
], ],
'/localtime' => [Module\Debug\Localtime::class, [R::GET, R::POST]], '/localtime' => [Module\Debug\Localtime::class, [R::GET, R::POST]],

View file

@ -797,6 +797,12 @@ function getPosition(e) {
return cursor; return cursor;
} }
function displaySearchText(id) {
$.get('item/' + id + '/searchtext', function(data) {
alert(data);
});
}
var lockvisible = false; var lockvisible = false;
function lockview(event, type, id) { function lockview(event, type, id) {

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2024.06-dev\n" "Project-Id-Version: 2024.06-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-03 07:49+0000\n" "POT-Creation-Date: 2024-04-05 07:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -292,7 +292,7 @@ msgstr ""
#: mod/message.php:201 mod/message.php:357 mod/photos.php:1297 #: mod/message.php:201 mod/message.php:357 mod/photos.php:1297
#: src/Content/Conversation.php:400 src/Content/Conversation.php:1583 #: src/Content/Conversation.php:400 src/Content/Conversation.php:1583
#: src/Module/Item/Compose.php:206 src/Module/Post/Edit.php:145 #: src/Module/Item/Compose.php:206 src/Module/Post/Edit.php:145
#: src/Object/Post.php:624 #: src/Object/Post.php:625
msgid "Please wait" msgid "Please wait"
msgstr "" msgstr ""
@ -314,7 +314,7 @@ msgstr ""
#: src/Module/Moderation/Report/Create.php:263 #: src/Module/Moderation/Report/Create.php:263
#: src/Module/Profile/Profile.php:274 src/Module/Settings/Profile/Index.php:257 #: src/Module/Profile/Profile.php:274 src/Module/Settings/Profile/Index.php:257
#: src/Module/Settings/Server/Action.php:79 src/Module/User/Delegation.php:189 #: src/Module/Settings/Server/Action.php:79 src/Module/User/Delegation.php:189
#: src/Object/Post.php:1169 view/theme/duepuntozero/config.php:85 #: src/Object/Post.php:1170 view/theme/duepuntozero/config.php:85
#: view/theme/frio/config.php:150 view/theme/quattro/config.php:87 #: view/theme/frio/config.php:150 view/theme/quattro/config.php:87
#: view/theme/vier/config.php:135 #: view/theme/vier/config.php:135
msgid "Submit" msgid "Submit"
@ -599,25 +599,25 @@ msgstr ""
#: mod/photos.php:1135 mod/photos.php:1191 mod/photos.php:1271 #: mod/photos.php:1135 mod/photos.php:1191 mod/photos.php:1271
#: src/Module/Contact.php:618 src/Module/Item/Compose.php:188 #: src/Module/Contact.php:618 src/Module/Item/Compose.php:188
#: src/Object/Post.php:1166 #: src/Object/Post.php:1167
msgid "This is you" msgid "This is you"
msgstr "" msgstr ""
#: mod/photos.php:1137 mod/photos.php:1193 mod/photos.php:1273 #: mod/photos.php:1137 mod/photos.php:1193 mod/photos.php:1273
#: src/Module/Moderation/Reports.php:95 src/Object/Post.php:618 #: src/Module/Moderation/Reports.php:95 src/Object/Post.php:619
#: src/Object/Post.php:1168 #: src/Object/Post.php:1169
msgid "Comment" msgid "Comment"
msgstr "" msgstr ""
#: mod/photos.php:1139 mod/photos.php:1195 mod/photos.php:1275 #: mod/photos.php:1139 mod/photos.php:1195 mod/photos.php:1275
#: src/Content/Conversation.php:414 src/Module/Calendar/Event/Form.php:248 #: src/Content/Conversation.php:414 src/Module/Calendar/Event/Form.php:248
#: src/Module/Item/Compose.php:201 src/Module/Post/Edit.php:165 #: src/Module/Item/Compose.php:201 src/Module/Post/Edit.php:165
#: src/Object/Post.php:1182 #: src/Object/Post.php:1183
msgid "Preview" msgid "Preview"
msgstr "" msgstr ""
#: mod/photos.php:1140 src/Content/Conversation.php:368 #: mod/photos.php:1140 src/Content/Conversation.php:368
#: src/Module/Post/Edit.php:130 src/Object/Post.php:1170 #: src/Module/Post/Edit.php:130 src/Object/Post.php:1171
msgid "Loading..." msgid "Loading..."
msgstr "" msgstr ""
@ -1244,7 +1244,7 @@ msgid "Visible to <strong>everybody</strong>"
msgstr "" msgstr ""
#: src/Content/Conversation.php:338 src/Module/Item/Compose.php:200 #: src/Content/Conversation.php:338 src/Module/Item/Compose.php:200
#: src/Object/Post.php:1181 #: src/Object/Post.php:1182
msgid "Please enter a image/video/audio/webpage URL:" msgid "Please enter a image/video/audio/webpage URL:"
msgstr "" msgstr ""
@ -1289,52 +1289,52 @@ msgid "attach file"
msgstr "" msgstr ""
#: src/Content/Conversation.php:373 src/Module/Item/Compose.php:190 #: src/Content/Conversation.php:373 src/Module/Item/Compose.php:190
#: src/Module/Post/Edit.php:171 src/Object/Post.php:1171 #: src/Module/Post/Edit.php:171 src/Object/Post.php:1172
msgid "Bold" msgid "Bold"
msgstr "" msgstr ""
#: src/Content/Conversation.php:374 src/Module/Item/Compose.php:191 #: src/Content/Conversation.php:374 src/Module/Item/Compose.php:191
#: src/Module/Post/Edit.php:172 src/Object/Post.php:1172 #: src/Module/Post/Edit.php:172 src/Object/Post.php:1173
msgid "Italic" msgid "Italic"
msgstr "" msgstr ""
#: src/Content/Conversation.php:375 src/Module/Item/Compose.php:192 #: src/Content/Conversation.php:375 src/Module/Item/Compose.php:192
#: src/Module/Post/Edit.php:173 src/Object/Post.php:1173 #: src/Module/Post/Edit.php:173 src/Object/Post.php:1174
msgid "Underline" msgid "Underline"
msgstr "" msgstr ""
#: src/Content/Conversation.php:376 src/Module/Item/Compose.php:193 #: src/Content/Conversation.php:376 src/Module/Item/Compose.php:193
#: src/Module/Post/Edit.php:174 src/Object/Post.php:1175 #: src/Module/Post/Edit.php:174 src/Object/Post.php:1176
msgid "Quote" msgid "Quote"
msgstr "" msgstr ""
#: src/Content/Conversation.php:377 src/Module/Item/Compose.php:194 #: src/Content/Conversation.php:377 src/Module/Item/Compose.php:194
#: src/Module/Post/Edit.php:175 src/Object/Post.php:1176 #: src/Module/Post/Edit.php:175 src/Object/Post.php:1177
msgid "Add emojis" msgid "Add emojis"
msgstr "" msgstr ""
#: src/Content/Conversation.php:378 src/Module/Item/Compose.php:195 #: src/Content/Conversation.php:378 src/Module/Item/Compose.php:195
#: src/Object/Post.php:1174 #: src/Object/Post.php:1175
msgid "Content Warning" msgid "Content Warning"
msgstr "" msgstr ""
#: src/Content/Conversation.php:379 src/Module/Item/Compose.php:196 #: src/Content/Conversation.php:379 src/Module/Item/Compose.php:196
#: src/Module/Post/Edit.php:176 src/Object/Post.php:1177 #: src/Module/Post/Edit.php:176 src/Object/Post.php:1178
msgid "Code" msgid "Code"
msgstr "" msgstr ""
#: src/Content/Conversation.php:380 src/Module/Item/Compose.php:197 #: src/Content/Conversation.php:380 src/Module/Item/Compose.php:197
#: src/Object/Post.php:1178 #: src/Object/Post.php:1179
msgid "Image" msgid "Image"
msgstr "" msgstr ""
#: src/Content/Conversation.php:381 src/Module/Item/Compose.php:198 #: src/Content/Conversation.php:381 src/Module/Item/Compose.php:198
#: src/Module/Post/Edit.php:177 src/Object/Post.php:1179 #: src/Module/Post/Edit.php:177 src/Object/Post.php:1180
msgid "Link" msgid "Link"
msgstr "" msgstr ""
#: src/Content/Conversation.php:382 src/Module/Item/Compose.php:199 #: src/Content/Conversation.php:382 src/Module/Item/Compose.php:199
#: src/Module/Post/Edit.php:178 src/Object/Post.php:1180 #: src/Module/Post/Edit.php:178 src/Object/Post.php:1181
msgid "Link or Media" msgid "Link or Media"
msgstr "" msgstr ""
@ -1887,7 +1887,7 @@ msgstr ""
msgid "View Status" msgid "View Status"
msgstr "" msgstr ""
#: src/Content/Item.php:431 src/Content/Item.php:452 src/Model/Contact.php:1177 #: src/Content/Item.php:431 src/Content/Item.php:454 src/Model/Contact.php:1177
#: src/Model/Contact.php:1233 src/Model/Contact.php:1243 #: src/Model/Contact.php:1233 src/Model/Contact.php:1243
#: src/Module/Directory.php:157 src/Module/Settings/Profile/Index.php:259 #: src/Module/Directory.php:157 src/Module/Settings/Profile/Index.php:259
msgid "View Profile" msgid "View Profile"
@ -1942,13 +1942,17 @@ msgstr ""
msgid "Languages" msgid "Languages"
msgstr "" msgstr ""
#: src/Content/Item.php:449 src/Content/Widget.php:80 #: src/Content/Item.php:446 src/Object/Post.php:603
msgid "Search Text"
msgstr ""
#: src/Content/Item.php:451 src/Content/Widget.php:80
#: src/Model/Contact.php:1236 src/Model/Contact.php:1248 #: src/Model/Contact.php:1236 src/Model/Contact.php:1248
#: src/Module/Contact/Follow.php:167 view/theme/vier/theme.php:195 #: src/Module/Contact/Follow.php:167 view/theme/vier/theme.php:195
msgid "Connect/Follow" msgid "Connect/Follow"
msgstr "" msgstr ""
#: src/Content/Item.php:883 #: src/Content/Item.php:885
msgid "Unable to fetch user." msgid "Unable to fetch user."
msgstr "" msgstr ""
@ -6653,7 +6657,8 @@ msgstr[1] ""
#: src/Module/Item/Display.php:96 src/Module/Item/Feed.php:59 #: src/Module/Item/Display.php:96 src/Module/Item/Feed.php:59
#: src/Module/Item/Follow.php:41 src/Module/Item/Ignore.php:41 #: src/Module/Item/Follow.php:41 src/Module/Item/Ignore.php:41
#: src/Module/Item/Pin.php:41 src/Module/Item/Pin.php:56 #: src/Module/Item/Pin.php:41 src/Module/Item/Pin.php:56
#: src/Module/Item/Star.php:42 src/Module/Update/Display.php:37 #: src/Module/Item/Searchtext.php:53 src/Module/Item/Star.php:42
#: src/Module/Update/Display.php:37
msgid "Access denied." msgid "Access denied."
msgstr "" msgstr ""
@ -12466,101 +12471,101 @@ msgstr ""
msgid "via Wall-To-Wall:" msgid "via Wall-To-Wall:"
msgstr "" msgstr ""
#: src/Object/Post.php:619 #: src/Object/Post.php:620
#, php-format #, php-format
msgid "Reply to %s" msgid "Reply to %s"
msgstr "" msgstr ""
#: src/Object/Post.php:622 #: src/Object/Post.php:623
msgid "More" msgid "More"
msgstr "" msgstr ""
#: src/Object/Post.php:641 #: src/Object/Post.php:642
msgid "Notifier task is pending" msgid "Notifier task is pending"
msgstr "" msgstr ""
#: src/Object/Post.php:642 #: src/Object/Post.php:643
msgid "Delivery to remote servers is pending" msgid "Delivery to remote servers is pending"
msgstr "" msgstr ""
#: src/Object/Post.php:643 #: src/Object/Post.php:644
msgid "Delivery to remote servers is underway" msgid "Delivery to remote servers is underway"
msgstr "" msgstr ""
#: src/Object/Post.php:644 #: src/Object/Post.php:645
msgid "Delivery to remote servers is mostly done" msgid "Delivery to remote servers is mostly done"
msgstr "" msgstr ""
#: src/Object/Post.php:645 #: src/Object/Post.php:646
msgid "Delivery to remote servers is done" msgid "Delivery to remote servers is done"
msgstr "" msgstr ""
#: src/Object/Post.php:667 #: src/Object/Post.php:668
#, php-format #, php-format
msgid "%d comment" msgid "%d comment"
msgid_plural "%d comments" msgid_plural "%d comments"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Object/Post.php:668 #: src/Object/Post.php:669
msgid "Show more" msgid "Show more"
msgstr "" msgstr ""
#: src/Object/Post.php:669 #: src/Object/Post.php:670
msgid "Show fewer" msgid "Show fewer"
msgstr "" msgstr ""
#: src/Object/Post.php:706 #: src/Object/Post.php:707
#, php-format #, php-format
msgid "Reshared by: %s" msgid "Reshared by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:711 #: src/Object/Post.php:712
#, php-format #, php-format
msgid "Viewed by: %s" msgid "Viewed by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:716 #: src/Object/Post.php:717
#, php-format #, php-format
msgid "Read by: %s" msgid "Read by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:721 #: src/Object/Post.php:722
#, php-format #, php-format
msgid "Liked by: %s" msgid "Liked by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:726 #: src/Object/Post.php:727
#, php-format #, php-format
msgid "Disliked by: %s" msgid "Disliked by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:731 #: src/Object/Post.php:732
#, php-format #, php-format
msgid "Attended by: %s" msgid "Attended by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:736 #: src/Object/Post.php:737
#, php-format #, php-format
msgid "Maybe attended by: %s" msgid "Maybe attended by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:741 #: src/Object/Post.php:742
#, php-format #, php-format
msgid "Not attended by: %s" msgid "Not attended by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:746 #: src/Object/Post.php:747
#, php-format #, php-format
msgid "Commented by: %s" msgid "Commented by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:751 #: src/Object/Post.php:752
#, php-format #, php-format
msgid "Reacted with %s by: %s" msgid "Reacted with %s by: %s"
msgstr "" msgstr ""
#: src/Object/Post.php:774 #: src/Object/Post.php:775
#, php-format #, php-format
msgid "Quote shared by: %s" msgid "Quote shared by: %s"
msgstr "" msgstr ""

View file

@ -225,6 +225,10 @@
</li> </li>
{{/if}} {{/if}}
<li role="menuitem">
<a id="searchtext-{{$item.id}}" href="javascript:displaySearchText({{$item.uriid}});" class="btn-link filer-item search-icon" title="{{$item.searchtext}}"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;{{$item.searchtext}}</a>
</li>
{{if $item.browsershare}} {{if $item.browsershare}}
<li role="menuitem" class="button-browser-share"> <li role="menuitem" class="button-browser-share">
<a id="browser-share-{{$item.id}}" href="javascript:navigator.share({url: '{{$item.plink.orig}}'});" class="btn-link button-browser-share" title="{{$item.browsershare.1}}"><i class="fa fa-share-alt" aria-hidden="true"></i>&nbsp;{{$item.browsershare.0}}</a> <a id="browser-share-{{$item.id}}" href="javascript:navigator.share({url: '{{$item.plink.orig}}'});" class="btn-link button-browser-share" title="{{$item.browsershare.1}}"><i class="fa fa-share-alt" aria-hidden="true"></i>&nbsp;{{$item.browsershare.0}}</a>

View file

@ -437,6 +437,10 @@ as the value of $top_child_total (this is done at the end of this file)
</li> </li>
{{/if}} {{/if}}
<li role="menuitem">
<a id="searchtext-{{$item.id}}" href="javascript:displaySearchText({{$item.uriid}});" class="btn-link filer-item search-icon" title="{{$item.searchtext}}"><i class="fa fa-search" aria-hidden="true"></i>&ensp;{{$item.searchtext}}</a>
</li>
{{if $item.browsershare}} {{if $item.browsershare}}
<li role="menuitem" class="button-browser-share"> <li role="menuitem" class="button-browser-share">
<a id="browser-share-{{$item.id}}" href="javascript:navigator.share({url: '{{$item.plink.orig}}'})" class="btn-link button-browser-share" title="{{$item.browsershare.1}}"><i class="fa fa-share-alt" aria-hidden="true"></i>&ensp;{{$item.browsershare.0}}</a> <a id="browser-share-{{$item.id}}" href="javascript:navigator.share({url: '{{$item.plink.orig}}'})" class="btn-link button-browser-share" title="{{$item.browsershare.1}}"><i class="fa fa-share-alt" aria-hidden="true"></i>&ensp;{{$item.browsershare.0}}</a>
@ -620,6 +624,9 @@ as the value of $top_child_total (this is done at the end of this file)
</li> </li>
{{/if}} {{/if}}
<li role="menuitem">
<a id="searchtext-{{$item.id}}" href="javascript:displaySearchText({{$item.uriid}});" class="btn-link filer-item search-icon" title="{{$item.searchtext}}"><i class="fa fa-search" aria-hidden="true"></i>&ensp;{{$item.searchtext}}</a>
</li>
{{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread) && ($item.ignore || ($item.drop && $item.drop.dropping))}} {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread) && ($item.ignore || ($item.drop && $item.drop.dropping))}}
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>