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 = [];
|
$params = [];
|
||||||
$tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']);
|
$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['s'] = $tags;
|
||||||
$params['n'] = 100;
|
$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 = [];
|
$entries = [];
|
||||||
$paginate = '';
|
foreach ([Search::getGlobalDirectory(), DI::baseUrl()] as $server) {
|
||||||
|
if (empty($server)) {
|
||||||
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())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = Contact::getByURLForUser($profile->url, local_user());
|
$msearch = json_decode(DI::httpRequest()->post($server . '/msearch', $params)->getBody());
|
||||||
if (!empty($contact)) {
|
if (!empty($msearch)) {
|
||||||
$entries[] = ModuleContact::getContactTemplateVars($contact);
|
$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)) {
|
if (empty($entries)) {
|
||||||
info(DI::l10n()->t('No matches'));
|
info(DI::l10n()->t('No matches'));
|
||||||
}
|
}
|
||||||
|
@ -123,9 +96,37 @@ function match_content(App $a)
|
||||||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
'$title' => DI::l10n()->t('Profile Match'),
|
'$title' => DI::l10n()->t('Profile Match'),
|
||||||
'$contacts' => $entries,
|
'$contacts' => array_slice($entries, 0, $limit),
|
||||||
'$paginate' => $paginate
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $o;
|
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 ""
|
msgstr ""
|
||||||
"Project-Id-Version: 2021.06-rc\n"
|
"Project-Id-Version: 2021.06-rc\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"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"
|
||||||
|
@ -1599,19 +1599,11 @@ msgstr ""
|
||||||
msgid "No keywords to match. Please add keywords to your profile."
|
msgid "No keywords to match. Please add keywords to your profile."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: mod/match.php:105 src/Content/Pager.php:216
|
#: mod/match.php:93 src/Module/BaseSearch.php:117
|
||||||
msgid "first"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/match.php:110 src/Content/Pager.php:276
|
|
||||||
msgid "next"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: mod/match.php:120 src/Module/BaseSearch.php:117
|
|
||||||
msgid "No matches"
|
msgid "No matches"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: mod/match.php:125
|
#: mod/match.php:98
|
||||||
msgid "Profile Match"
|
msgid "Profile Match"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -3626,10 +3618,18 @@ msgstr ""
|
||||||
msgid "Embedded content"
|
msgid "Embedded content"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Content/Pager.php:216
|
||||||
|
msgid "first"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Content/Pager.php:221
|
#: src/Content/Pager.php:221
|
||||||
msgid "prev"
|
msgid "prev"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Content/Pager.php:276
|
||||||
|
msgid "next"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/Content/Pager.php:281
|
#: src/Content/Pager.php:281
|
||||||
msgid "last"
|
msgid "last"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -4489,33 +4489,33 @@ msgstr ""
|
||||||
msgid "Done. You can now login with your username and password"
|
msgid "Done. You can now login with your username and password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:64
|
#: src/Database/DBStructure.php:65
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "The database version had been set to %s."
|
msgid "The database version had been set to %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:77
|
#: src/Database/DBStructure.php:78
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"The post update is at version %d, it has to be at %d to safely drop the "
|
"The post update is at version %d, it has to be at %d to safely drop the "
|
||||||
"tables."
|
"tables."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:89
|
#: src/Database/DBStructure.php:90
|
||||||
msgid "No unused tables found."
|
msgid "No unused tables found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:94
|
#: src/Database/DBStructure.php:95
|
||||||
msgid ""
|
msgid ""
|
||||||
"These tables are not used for friendica and will be deleted when you execute "
|
"These tables are not used for friendica and will be deleted when you execute "
|
||||||
"\"dbstructure drop -e\":"
|
"\"dbstructure drop -e\":"
|
||||||
msgstr ""
|
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."
|
msgid "There are no tables on MyISAM or InnoDB with the Antelope file format."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:156
|
#: src/Database/DBStructure.php:157
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -4523,20 +4523,20 @@ msgid ""
|
||||||
"%s\n"
|
"%s\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:159
|
#: src/Database/DBStructure.php:160
|
||||||
msgid "Errors encountered performing database changes: "
|
msgid "Errors encountered performing database changes: "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:445
|
#: src/Database/DBStructure.php:550
|
||||||
msgid "Another database update is currently running."
|
msgid "Another database update is currently running."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:449
|
#: src/Database/DBStructure.php:554
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s: Database update"
|
msgid "%s: Database update"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Database/DBStructure.php:749
|
#: src/Database/DBStructure.php:854
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s: updating %s table."
|
msgid "%s: updating %s table."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
Loading…
Reference in a new issue