3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Calendar;
25 use Friendica\BaseModule;
26 use Friendica\Content\Nav;
27 use Friendica\Content\Widget;
28 use Friendica\Core\L10n;
29 use Friendica\Core\Renderer;
30 use Friendica\Core\Session\Capability\IHandleUserSessions;
31 use Friendica\Core\Theme;
32 use Friendica\Model\Event;
33 use Friendica\Module\BaseProfile;
34 use Friendica\Module\Response;
35 use Friendica\Module\Security\Login;
36 use Friendica\Navigation\SystemMessages;
37 use Friendica\Util\Profiler;
38 use Psr\Log\LoggerInterface;
40 class Show extends BaseModule
42 /** @var IHandleUserSessions */
44 /** @var SystemMessages */
45 protected $sysMessages;
51 public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, SystemMessages $sysMessages, App\Page $page, App $app, array $server, array $parameters = [])
53 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
55 $this->session = $session;
56 $this->sysMessages = $sysMessages;
61 protected function content(array $request = []): string
63 if (!$this->session->getLocalUserId()) {
64 $this->sysMessages->addNotice($this->t('Permission denied.'));
68 // get the translation strings for the calendar
69 $i18n = Event::getStrings();
71 $this->page->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
72 $this->page->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
73 $this->page->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
74 $this->page->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
76 $htpl = Renderer::getMarkupTemplate('calendar/calendar_head.tpl');
77 $this->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
78 '$calendar_api' => $this->baseUrl . '/calendar/api/get' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
79 '$event_api' => $this->baseUrl . '/calendar/event/show' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
86 if (empty($this->parameters['nickname'])) {
87 if ($this->app->getThemeInfoValue('events_in_profile')) {
88 Nav::setSelected('home');
90 Nav::setSelected('calendar');
94 if ($this->app->getThemeInfoValue('events_in_profile')) {
95 $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', true, $this->app->getLoggedInUserNickname(), false);
98 $this->page['aside'] .= Widget\CalendarExport::getHTML($this->session->getLocalUserId());
100 $owner = Event::getOwnerForNickname($this->parameters['nickname'], true);
102 Nav::setSelected('calendar');
104 // get the tab navigation bar
105 $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', false, $owner['nickname'], $owner['hide-friends']);
107 $this->page['aside'] .= Widget\VCard::getHTML($owner);
108 $this->page['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);
111 // ACL blocks are loaded in modals in frio
112 $this->page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
113 $this->page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
114 $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
115 $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
117 $tpl = Renderer::getMarkupTemplate("calendar/calendar.tpl");
118 $o = Renderer::replaceMacros($tpl, [
120 '$title' => $this->t('Events'),
121 '$view' => $this->t('View'),
122 '$new_event' => [$this->baseUrl . '/calendar/event/new', $this->t('Create New Event'), '', ''],
124 '$today' => $this->t('today'),
125 '$month' => $this->t('month'),
126 '$week' => $this->t('week'),
127 '$day' => $this->t('day'),
128 '$list' => $this->t('list'),