From 811e144e9e4656525d9c0c01ca55153e5eee102c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2022 07:03:55 -0400 Subject: [PATCH 1/4] Move viewcontact_template and contact_template to contact/ folder --- mod/match.php | 2 +- mod/suggest.php | 2 +- src/Module/BaseSearch.php | 2 +- src/Module/Conversation/Network.php | 2 +- view/templates/{contact_template.tpl => contact/entry.tpl} | 0 view/templates/{viewcontact_template.tpl => contact/list.tpl} | 2 +- .../templates/{contact_template.tpl => contact/entry.tpl} | 0 .../templates/{viewcontact_template.tpl => contact/list.tpl} | 2 +- view/theme/frio/templates/contact_drop_confirm.tpl | 2 +- view/theme/frio/templates/contacts-template.tpl | 4 ++-- view/theme/frio/templates/directory_header.tpl | 4 ++-- view/theme/frio/templates/groupeditor.tpl | 4 ++-- view/theme/frio/templates/profile/contacts.tpl | 2 +- .../templates/{contact_template.tpl => contact/entry.tpl} | 0 .../templates/{contact_template.tpl => contact/entry.tpl} | 0 15 files changed, 14 insertions(+), 14 deletions(-) rename view/templates/{contact_template.tpl => contact/entry.tpl} (100%) rename view/templates/{viewcontact_template.tpl => contact/list.tpl} (85%) rename view/theme/frio/templates/{contact_template.tpl => contact/entry.tpl} (100%) rename view/theme/frio/templates/{viewcontact_template.tpl => contact/list.tpl} (89%) rename view/theme/quattro/templates/{contact_template.tpl => contact/entry.tpl} (100%) rename view/theme/vier/templates/{contact_template.tpl => contact/entry.tpl} (100%) diff --git a/mod/match.php b/mod/match.php index e8a0a6605..ea59d7ee6 100644 --- a/mod/match.php +++ b/mod/match.php @@ -93,7 +93,7 @@ function match_content(App $a) DI::sysmsg()->addInfo(DI::l10n()->t('No matches')); } - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); + $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); $o = Renderer::replaceMacros($tpl, [ '$title' => DI::l10n()->t('Profile Match'), '$contacts' => array_slice($entries, 0, $limit), diff --git a/mod/suggest.php b/mod/suggest.php index 9ad11f745..41fa1b06b 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -49,7 +49,7 @@ function suggest_content(App $a) $entries[] = ModuleContact::getContactTemplateVars($contact); } - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); + $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); return Renderer::replaceMacros($tpl,[ '$title' => DI::l10n()->t('Friend Suggestions'), diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php index b0f03c17d..2eace38bf 100644 --- a/src/Module/BaseSearch.php +++ b/src/Module/BaseSearch.php @@ -132,7 +132,7 @@ class BaseSearch extends BaseModule } } - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); + $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); return Renderer::replaceMacros($tpl, [ 'title' => $header, '$contacts' => $entries, diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index ce2afbfc7..72c4f67cf 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -178,7 +178,7 @@ class Network extends BaseModule } elseif (self::$forumContactId) { $contact = Contact::getById(self::$forumContactId); if (DBA::isResult($contact)) { - $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('viewcontact_template.tpl'), [ + $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('contact/list.tpl'), [ 'contacts' => [ModuleContact::getContactTemplateVars($contact)], 'id' => DI::args()->get(0), ]) . $o; diff --git a/view/templates/contact_template.tpl b/view/templates/contact/entry.tpl similarity index 100% rename from view/templates/contact_template.tpl rename to view/templates/contact/entry.tpl diff --git a/view/templates/viewcontact_template.tpl b/view/templates/contact/list.tpl similarity index 85% rename from view/templates/viewcontact_template.tpl rename to view/templates/contact/list.tpl index 562270e35..ec77fd521 100644 --- a/view/templates/viewcontact_template.tpl +++ b/view/templates/contact/list.tpl @@ -5,7 +5,7 @@
{{foreach $contacts as $contact}} - {{include file="contact_template.tpl"}} + {{include file="contact/entry.tpl"}} {{/foreach}}
diff --git a/view/theme/frio/templates/contact_template.tpl b/view/theme/frio/templates/contact/entry.tpl similarity index 100% rename from view/theme/frio/templates/contact_template.tpl rename to view/theme/frio/templates/contact/entry.tpl diff --git a/view/theme/frio/templates/viewcontact_template.tpl b/view/theme/frio/templates/contact/list.tpl similarity index 89% rename from view/theme/frio/templates/viewcontact_template.tpl rename to view/theme/frio/templates/contact/list.tpl index 90f286558..5a1ac026b 100644 --- a/view/theme/frio/templates/viewcontact_template.tpl +++ b/view/theme/frio/templates/contact/list.tpl @@ -8,7 +8,7 @@ at the suggest page and also at many other places *}}
diff --git a/view/theme/frio/templates/contact_drop_confirm.tpl b/view/theme/frio/templates/contact_drop_confirm.tpl index a0ac15cf6..e4c0a3563 100644 --- a/view/theme/frio/templates/contact_drop_confirm.tpl +++ b/view/theme/frio/templates/contact_drop_confirm.tpl @@ -1,7 +1,7 @@

{{$l10n.header}}

- {{include file="contact_template.tpl" no_contacts_checkbox=True}} + {{include file="contact/entry.tpl" no_contacts_checkbox=True}} {{include file="confirm.tpl"}} diff --git a/view/theme/frio/templates/contacts-template.tpl b/view/theme/frio/templates/contacts-template.tpl index f13f10834..5c41c74e2 100644 --- a/view/theme/frio/templates/contacts-template.tpl +++ b/view/theme/frio/templates/contacts-template.tpl @@ -49,10 +49,10 @@
- {{* format each contact with the contact_template.tpl *}} + {{* format each contact with the contact/entry.tpl *}}
    {{foreach $contacts as $contact}} -
  • {{include file="contact_template.tpl"}}
  • +
  • {{include file="contact/entry.tpl"}}
  • {{/foreach}}
diff --git a/view/theme/frio/templates/directory_header.tpl b/view/theme/frio/templates/directory_header.tpl index cef6208ad..2c271ffea 100644 --- a/view/theme/frio/templates/directory_header.tpl +++ b/view/theme/frio/templates/directory_header.tpl @@ -28,10 +28,10 @@
- {{* format each contact with the contact_template.tpl *}} + {{* format each contact with the contact/entry.tpl *}} diff --git a/view/theme/frio/templates/groupeditor.tpl b/view/theme/frio/templates/groupeditor.tpl index 8d1db5b22..5ec157114 100644 --- a/view/theme/frio/templates/groupeditor.tpl +++ b/view/theme/frio/templates/groupeditor.tpl @@ -6,12 +6,12 @@ {{* The contacts who are already members of the contact group *}} {{foreach $groupeditor.members as $contact}} -
  • {{include file="contact_template.tpl"}}
  • +
  • {{include file="contact/entry.tpl"}}
  • {{/foreach}} {{* The contacts who are not members of the contact group *}} {{foreach $groupeditor.contacts as $contact}} -
  • {{include file="contact_template.tpl"}}
  • +
  • {{include file="contact/entry.tpl"}}
  • {{/foreach}} diff --git a/view/theme/frio/templates/profile/contacts.tpl b/view/theme/frio/templates/profile/contacts.tpl index 513223f31..4a313e774 100644 --- a/view/theme/frio/templates/profile/contacts.tpl +++ b/view/theme/frio/templates/profile/contacts.tpl @@ -10,7 +10,7 @@ {{if $contacts}} {{else}} diff --git a/view/theme/quattro/templates/contact_template.tpl b/view/theme/quattro/templates/contact/entry.tpl similarity index 100% rename from view/theme/quattro/templates/contact_template.tpl rename to view/theme/quattro/templates/contact/entry.tpl diff --git a/view/theme/vier/templates/contact_template.tpl b/view/theme/vier/templates/contact/entry.tpl similarity index 100% rename from view/theme/vier/templates/contact_template.tpl rename to view/theme/vier/templates/contact/entry.tpl From 8ec5d10bf4385f3012aa5a885009ebed61d0dc3b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2022 07:57:00 -0400 Subject: [PATCH 2/4] Add new Contact/Suggestions module class --- src/Module/Contact/Suggestions.php | 77 +++++++++++++++++++ static/routes.config.php | 35 +++++---- .../frio/templates/widget/peoplefind.tpl | 2 +- 3 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 src/Module/Contact/Suggestions.php diff --git a/src/Module/Contact/Suggestions.php b/src/Module/Contact/Suggestions.php new file mode 100644 index 000000000..86e3f6cc8 --- /dev/null +++ b/src/Module/Contact/Suggestions.php @@ -0,0 +1,77 @@ +. + * + */ + +namespace Friendica\Module\Contact; + +use Friendica\App; +use Friendica\Core\L10n; +use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Module\Response; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; +use Friendica\Content\Widget; +use Friendica\Core\Renderer; +use Friendica\Model\Contact; +use Friendica\Module\Contact as ModuleContact; +use Friendica\Network\HTTPException; + +class Suggestions extends \Friendica\BaseModule +{ + /** @var IHandleUserSessions */ + private $session; + /** @var App\Page */ + private $page; + + public function __construct(App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->session = $session; + $this->page = $page; + } + + protected function content(array $request = []): string + { + if (!$this->session->getLocalUserId()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); + } + + $this->page['aside'] .= Widget::findPeople(); + $this->page['aside'] .= Widget::follow(); + + $contacts = Contact\Relation::getSuggestions($this->session->getLocalUserId()); + if (!$contacts) { + return $this->t('No suggestions available. If this is a new site, please try again in 24 hours.'); + } + + $entries = []; + foreach ($contacts as $contact) { + $entries[] = ModuleContact::getContactTemplateVars($contact); + } + + $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); + + return Renderer::replaceMacros($tpl, [ + '$title' => $this->t('Friend Suggestions'), + '$contacts' => $entries, + ]); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index ef4b1345c..85171d2b7 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -373,25 +373,26 @@ return [ '/compose[/{type}]' => [Module\Item\Compose::class, [R::GET, R::POST]], '/contact' => [ - '[/]' => [Module\Contact::class, [R::GET]], - '/{id:\d+}[/]' => [Module\Contact\Profile::class, [R::GET, R::POST]], + '[/]' => [Module\Contact::class, [R::GET]], + '/{id:\d+}[/]' => [Module\Contact\Profile::class, [R::GET, R::POST]], '/{id:\d+}/{action:block|ignore|update|updateprofile}' - => [Module\Contact\Profile::class, [R::GET]], - '/{id:\d+}/advanced' => [Module\Contact\Advanced::class, [R::GET, R::POST]], + => [Module\Contact\Profile::class, [R::GET]], + '/{id:\d+}/advanced' => [Module\Contact\Advanced::class, [R::GET, R::POST]], '/{id:\d+}/conversations' => [Module\Contact\Conversations::class, [R::GET]], - '/{id:\d+}/contacts[/{type}]' => [Module\Contact\Contacts::class, [R::GET]], - '/{id:\d+}/media' => [Module\Contact\Media::class, [R::GET]], - '/{id:\d+}/posts' => [Module\Contact\Posts::class, [R::GET]], - '/{id:\d+}/revoke' => [Module\Contact\Revoke::class, [R::GET, R::POST]], - '/archived' => [Module\Contact::class, [R::GET]], - '/batch' => [Module\Contact::class, [R::GET, R::POST]], - '/pending' => [Module\Contact::class, [R::GET]], - '/blocked' => [Module\Contact::class, [R::GET]], - '/hidden' => [Module\Contact::class, [R::GET]], - '/ignored' => [Module\Contact::class, [R::GET]], - '/hovercard' => [Module\Contact\Hovercard::class, [R::GET]], - '/follow' => [Module\Contact\Follow::class, [R::GET, R::POST]], - '/unfollow' => [Module\Contact\Unfollow::class, [R::GET, R::POST]], + '/{id:\d+}/contacts[/{type}]' => [Module\Contact\Contacts::class, [R::GET]], + '/{id:\d+}/media' => [Module\Contact\Media::class, [R::GET]], + '/{id:\d+}/posts' => [Module\Contact\Posts::class, [R::GET]], + '/{id:\d+}/revoke' => [Module\Contact\Revoke::class, [R::GET, R::POST]], + '/archived' => [Module\Contact::class, [R::GET]], + '/batch' => [Module\Contact::class, [R::GET, R::POST]], + '/blocked' => [Module\Contact::class, [R::GET]], + '/follow' => [Module\Contact\Follow::class, [R::GET, R::POST]], + '/hidden' => [Module\Contact::class, [R::GET]], + '/hovercard' => [Module\Contact\Hovercard::class, [R::GET]], + '/ignored' => [Module\Contact::class, [R::GET]], + '/pending' => [Module\Contact::class, [R::GET]], + '/suggestions' => [Module\Contact\Suggestions::class, [R::GET]], + '/unfollow' => [Module\Contact\Unfollow::class, [R::GET, R::POST]], ], '/credits' => [Module\Credits::class, [R::GET]], diff --git a/view/theme/frio/templates/widget/peoplefind.tpl b/view/theme/frio/templates/widget/peoplefind.tpl index 7c69e6bff..11168eca0 100644 --- a/view/theme/frio/templates/widget/peoplefind.tpl +++ b/view/theme/frio/templates/widget/peoplefind.tpl @@ -15,7 +15,7 @@ {{* Additional links *}} - + {{if $nv.inv}} From 55744b6ccbc94ca936b27f1daa9c361e528b6a02 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2022 07:57:37 -0400 Subject: [PATCH 3/4] Remove mod/suggest.php file --- mod/suggest.php | 58 ------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 mod/suggest.php diff --git a/mod/suggest.php b/mod/suggest.php deleted file mode 100644 index 41fa1b06b..000000000 --- a/mod/suggest.php +++ /dev/null @@ -1,58 +0,0 @@ -. - * - */ - -use Friendica\App; -use Friendica\Content\Widget; -use Friendica\Core\Renderer; -use Friendica\Database\DBA; -use Friendica\DI; -use Friendica\Model\Contact; -use Friendica\Module\Contact as ModuleContact; -use Friendica\Network\HTTPException; - -function suggest_content(App $a) -{ - if (!DI::userSession()->getLocalUserId()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); - } - - $_SESSION['return_path'] = DI::args()->getCommand(); - - DI::page()['aside'] .= Widget::findPeople(); - DI::page()['aside'] .= Widget::follow(); - - $contacts = Contact\Relation::getSuggestions(DI::userSession()->getLocalUserId()); - if (!DBA::isResult($contacts)) { - return DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.'); - } - - $entries = []; - foreach ($contacts as $contact) { - $entries[] = ModuleContact::getContactTemplateVars($contact); - } - - $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); - - return Renderer::replaceMacros($tpl,[ - '$title' => DI::l10n()->t('Friend Suggestions'), - '$contacts' => $entries, - ]); -} From f50368c9cbb48dd4b996cce9de503268ca615666 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2022 11:29:39 -0400 Subject: [PATCH 4/4] Update main translation file after mving strings --- view/lang/C/messages.po | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 53a7373fd..35b7f879d 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2022.12-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-03 22:30-0400\n" +"POT-Creation-Date: 2022-11-04 08:00-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -105,10 +105,10 @@ msgstr "" #: mod/item.php:870 mod/message.php:69 mod/message.php:114 mod/notes.php:44 #: mod/ostatus_subscribe.php:33 mod/photos.php:159 mod/photos.php:886 #: mod/repair_ostatus.php:31 mod/settings.php:40 mod/settings.php:50 -#: mod/settings.php:156 mod/suggest.php:34 src/Module/Attach.php:56 -#: src/Module/BaseApi.php:94 src/Module/BaseNotifications.php:98 -#: src/Module/Contact/Advanced.php:60 src/Module/Contact/Follow.php:86 -#: src/Module/Contact/Follow.php:158 src/Module/Contact/Unfollow.php:66 +#: mod/settings.php:156 src/Module/Attach.php:56 src/Module/BaseApi.php:94 +#: src/Module/BaseNotifications.php:98 src/Module/Contact/Advanced.php:60 +#: src/Module/Contact/Follow.php:86 src/Module/Contact/Follow.php:158 +#: src/Module/Contact/Suggestions.php:54 src/Module/Contact/Unfollow.php:66 #: src/Module/Contact/Unfollow.php:80 src/Module/Contact/Unfollow.php:112 #: src/Module/Delegation.php:118 src/Module/FollowConfirm.php:38 #: src/Module/FriendSuggest.php:57 src/Module/Group.php:40 @@ -1323,16 +1323,6 @@ msgstr "" msgid "Move to folder:" msgstr "" -#: mod/suggest.php:44 -msgid "" -"No suggestions available. If this is a new site, please try again in 24 " -"hours." -msgstr "" - -#: mod/suggest.php:55 src/Content/Widget.php:83 view/theme/vier/theme.php:201 -msgid "Friend Suggestions" -msgstr "" - #: src/App.php:490 msgid "No system theme config value set." msgstr "" @@ -2529,6 +2519,11 @@ msgstr "" msgid "Find" msgstr "" +#: src/Content/Widget.php:83 src/Module/Contact/Suggestions.php:73 +#: view/theme/vier/theme.php:201 +msgid "Friend Suggestions" +msgstr "" + #: src/Content/Widget.php:84 view/theme/vier/theme.php:202 msgid "Similar Interests" msgstr "" @@ -7106,6 +7101,12 @@ msgstr "" msgid "Yes" msgstr "" +#: src/Module/Contact/Suggestions.php:62 +msgid "" +"No suggestions available. If this is a new site, please try again in 24 " +"hours." +msgstr "" + #: src/Module/Contact/Unfollow.php:98 src/Module/Contact/Unfollow.php:167 msgid "You aren't following this contact." msgstr ""