]> git.mxchange.org Git - friendica.git/blob - src/Module/Calendar/Show.php
Removed redundant maximagesize = INF statements
[friendica.git] / src / Module / Calendar / Show.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
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.
11  *
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.
16  *
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/>.
19  *
20  */
21
22 namespace Friendica\Module\Calendar;
23
24 use Friendica\App;
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;
39
40 class Show extends BaseModule
41 {
42         /** @var IHandleUserSessions */
43         protected $session;
44         /** @var SystemMessages */
45         protected $sysMessages;
46         /** @var App\Page */
47         protected $page;
48         /** @var App */
49         protected $app;
50
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 = [])
52         {
53                 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
54
55                 $this->session     = $session;
56                 $this->sysMessages = $sysMessages;
57                 $this->page        = $page;
58                 $this->app         = $app;
59         }
60
61         protected function content(array $request = []): string
62         {
63                 if (!$this->session->getLocalUserId()) {
64                         $this->sysMessages->addNotice($this->t('Permission denied.'));
65                         return Login::form();
66                 }
67
68                 // get the translation strings for the calendar
69                 $i18n = Event::getStrings();
70
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');
75
76                 $htpl = Renderer::getMarkupTemplate('calendar/calendar_head.tpl');
77
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'] : ''),
81                         '$modparams'    => 2,
82                         '$i18n'         => $i18n,
83                 ]);
84
85                 $tabs = '';
86
87                 if (empty($this->parameters['nickname'])) {
88                         if ($this->app->getThemeInfoValue('events_in_profile')) {
89                                 Nav::setSelected('home');
90                         } else {
91                                 Nav::setSelected('calendar');
92                         }
93
94                         // tabs
95                         if ($this->app->getThemeInfoValue('events_in_profile')) {
96                                 $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', true, $this->app->getLoggedInUserNickname(), false);
97                         }
98
99                         $this->page['aside'] .= Widget\CalendarExport::getHTML($this->session->getLocalUserId());
100                 } else {
101                         $owner = Event::getOwnerForNickname($this->parameters['nickname'], true);
102
103                         Nav::setSelected('calendar');
104
105                         // get the tab navigation bar
106                         $tabs = BaseProfile::getTabsHTML($this->app, 'calendar', false, $owner['nickname'], $owner['hide-friends']);
107
108                         $this->page['aside'] .= Widget\VCard::getHTML($owner);
109                         $this->page['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);
110                 }
111
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'));
117
118                 $tpl = Renderer::getMarkupTemplate("calendar/calendar.tpl");
119                 $o   = Renderer::replaceMacros($tpl, [
120                         '$tabs'      => $tabs,
121                         '$title'     => $this->t('Events'),
122                         '$view'      => $this->t('View'),
123                         '$new_event' => ['calendar/event/new', $this->t('Create New Event'), '', ''],
124
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'),
130                 ]);
131
132                 return $o;
133         }
134 }