Merge pull request #10402 from annando/issue-10386
Issue 10386: Reworked match
This commit is contained in:
commit
fb741c5646
|
@ -66,56 +66,29 @@ function match_content(App $a)
|
|||
$params = [];
|
||||
$tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']);
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
$params['s'] = $tags;
|
||||
$params['n'] = 100;
|
||||
|
||||
if (strlen(DI::config()->get('system', 'directory'))) {
|
||||
$host = Search::getGlobalDirectory();
|
||||
} else {
|
||||
$host = DI::baseUrl();
|
||||
}
|
||||
|
||||
$msearch_json = DI::httpRequest()->post($host . '/msearch', $params)->getBody();
|
||||
|
||||
$msearch = json_decode($msearch_json);
|
||||
|
||||
$start = $_GET['start'] ?? 0;
|
||||
$entries = [];
|
||||
$paginate = '';
|
||||
|
||||
if (!empty($msearch->results)) {
|
||||
for ($i = $start;count($entries) < 10 && $i < $msearch->total; $i++) {
|
||||
$profile = $msearch->results[$i];
|
||||
|
||||
// Already known contact
|
||||
if (!$profile || Contact::getIdForURL($profile->url, local_user())) {
|
||||
foreach ([Search::getGlobalDirectory(), DI::baseUrl()] as $server) {
|
||||
if (empty($server)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contact = Contact::getByURLForUser($profile->url, local_user());
|
||||
if (!empty($contact)) {
|
||||
$entries[] = ModuleContact::getContactTemplateVars($contact);
|
||||
$msearch = json_decode(DI::httpRequest()->post($server . '/msearch', $params)->getBody());
|
||||
if (!empty($msearch)) {
|
||||
$entries = match_get_contacts($msearch, $entries, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'class' => 'pager',
|
||||
'first' => [
|
||||
'url' => 'match',
|
||||
'text' => DI::l10n()->t('first'),
|
||||
'class' => 'previous' . ($start == 0 ? 'disabled' : '')
|
||||
],
|
||||
'next' => [
|
||||
'url' => 'match?start=' . $i,
|
||||
'text' => DI::l10n()->t('next'),
|
||||
'class' => 'next' . ($i >= $msearch->total ? ' disabled' : '')
|
||||
]
|
||||
];
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('paginate.tpl');
|
||||
$paginate = Renderer::replaceMacros($tpl, ['pager' => $data]);
|
||||
}
|
||||
|
||||
if (empty($entries)) {
|
||||
info(DI::l10n()->t('No matches'));
|
||||
}
|
||||
|
@ -123,9 +96,37 @@ function match_content(App $a)
|
|||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->t('Profile Match'),
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $paginate
|
||||
'$contacts' => array_slice($entries, 0, $limit),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function match_get_contacts($msearch, $entries, $limit)
|
||||
{
|
||||
if (empty($msearch->results)) {
|
||||
return $entries;
|
||||
}
|
||||
|
||||
foreach ($msearch->results as $profile) {
|
||||
if (!$profile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Already known contact
|
||||
$contact = Contact::getByURL($profile->url, null, ['rel'], local_user());
|
||||
if (!empty($contact) && in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contact = Contact::getByURLForUser($profile->url, local_user());
|
||||
if (!empty($contact)) {
|
||||
$entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact);
|
||||
}
|
||||
|
||||
if (count($entries) == $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $entries;
|
||||
}
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: 2021.06-rc\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-06-13 11:02+0000\n"
|
||||
"POT-Creation-Date: 2021-06-15 17:22+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -1599,19 +1599,11 @@ msgstr ""
|
|||
msgid "No keywords to match. Please add keywords to your profile."
|
||||
msgstr ""
|
||||
|
||||
#: mod/match.php:105 src/Content/Pager.php:216
|
||||
msgid "first"
|
||||
msgstr ""
|
||||
|
||||
#: mod/match.php:110 src/Content/Pager.php:276
|
||||
msgid "next"
|
||||
msgstr ""
|
||||
|
||||
#: mod/match.php:120 src/Module/BaseSearch.php:117
|
||||
#: mod/match.php:93 src/Module/BaseSearch.php:117
|
||||
msgid "No matches"
|
||||
msgstr ""
|
||||
|
||||
#: mod/match.php:125
|
||||
#: mod/match.php:98
|
||||
msgid "Profile Match"
|
||||
msgstr ""
|
||||
|
||||
|
@ -3626,10 +3618,18 @@ msgstr ""
|
|||
msgid "Embedded content"
|
||||
msgstr ""
|
||||
|
||||
#: src/Content/Pager.php:216
|
||||
msgid "first"
|
||||
msgstr ""
|
||||
|
||||
#: src/Content/Pager.php:221
|
||||
msgid "prev"
|
||||
msgstr ""
|
||||
|
||||
#: src/Content/Pager.php:276
|
||||
msgid "next"
|
||||
msgstr ""
|
||||
|
||||
#: src/Content/Pager.php:281
|
||||
msgid "last"
|
||||
msgstr ""
|
||||
|
@ -4489,33 +4489,33 @@ msgstr ""
|
|||
msgid "Done. You can now login with your username and password"
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:64
|
||||
#: src/Database/DBStructure.php:65
|
||||
#, php-format
|
||||
msgid "The database version had been set to %s."
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:77
|
||||
#: src/Database/DBStructure.php:78
|
||||
#, php-format
|
||||
msgid ""
|
||||
"The post update is at version %d, it has to be at %d to safely drop the "
|
||||
"tables."
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:89
|
||||
#: src/Database/DBStructure.php:90
|
||||
msgid "No unused tables found."
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:94
|
||||
#: src/Database/DBStructure.php:95
|
||||
msgid ""
|
||||
"These tables are not used for friendica and will be deleted when you execute "
|
||||
"\"dbstructure drop -e\":"
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:132
|
||||
#: src/Database/DBStructure.php:133
|
||||
msgid "There are no tables on MyISAM or InnoDB with the Antelope file format."
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:156
|
||||
#: src/Database/DBStructure.php:157
|
||||
#, php-format
|
||||
msgid ""
|
||||
"\n"
|
||||
|
@ -4523,20 +4523,20 @@ msgid ""
|
|||
"%s\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:159
|
||||
#: src/Database/DBStructure.php:160
|
||||
msgid "Errors encountered performing database changes: "
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:445
|
||||
#: src/Database/DBStructure.php:550
|
||||
msgid "Another database update is currently running."
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:449
|
||||
#: src/Database/DBStructure.php:554
|
||||
#, php-format
|
||||
msgid "%s: Database update"
|
||||
msgstr ""
|
||||
|
||||
#: src/Database/DBStructure.php:749
|
||||
#: src/Database/DBStructure.php:854
|
||||
#, php-format
|
||||
msgid "%s: updating %s table."
|
||||
msgstr ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user