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');
78 $this->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
79 '$calendar_api' => 'calendar/api/get' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
80 '$event_api' => 'calendar/event/show' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
87 if (empty($this->parameters['nickname'])) {
88 if ($this->app->getThemeInfoValue('events_in_profile')) {
89 Nav::setSelected('home');
91 Nav::setSelected('calendar');
95 if ($this->app->getThemeInfoValue('events_in_profile')) {
96 $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', true, $this->app->getLoggedInUserNickname(), false);
99 $this->page['aside'] .= Widget\CalendarExport::getHTML($this->session->getLocalUserId());
101 $owner = Event::getOwnerForNickname($this->parameters['nickname'], true);
103 Nav::setSelected('calendar');
105 // get the tab navigation bar
106 $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', false, $owner['nickname'], $owner['hide-friends']);
108 $this->page['aside'] .= Widget\VCard::getHTML($owner);
109 $this->page['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);
112 // ACL blocks are loaded in modals in frio
113 $this->page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
114 $this->page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
115 $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
116 $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
118 $tpl = Renderer::getMarkupTemplate("calendar/calendar.tpl");
119 $o = Renderer::replaceMacros($tpl, [
121 '$title' => $this->t('Events'),
122 '$view' => $this->t('View'),
123 '$new_event' => ['calendar/event/new', $this->t('Create New Event'), '', ''],
125 '$today' => $this->t('today'),
126 '$month' => $this->t('month'),
127 '$week' => $this->t('week'),
128 '$day' => $this->t('day'),
129 '$list' => $this->t('list'),