2018-03-16 21:22:19 -04:00
|
|
|
<?php
|
2020-02-09 16:34:23 +01:00
|
|
|
/**
|
2021-03-29 08:40:20 +02:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 16:34:23 +01:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2018-03-16 21:22:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Content\Widget;
|
|
|
|
|
2018-03-17 16:42:28 -04:00
|
|
|
use Friendica\Content\Feature;
|
2018-10-31 10:35:50 -04:00
|
|
|
use Friendica\Core\Renderer;
|
2020-01-04 23:42:01 +01:00
|
|
|
use Friendica\DI;
|
2018-03-16 21:22:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TagCloud widget
|
|
|
|
*
|
|
|
|
* @author Rabuzarus
|
|
|
|
*/
|
|
|
|
class CalendarExport
|
|
|
|
{
|
|
|
|
/**
|
2020-01-19 06:05:23 +00:00
|
|
|
* Get the events widget.
|
2018-03-16 21:22:19 -04:00
|
|
|
*
|
|
|
|
* @return string Formated HTML of the calendar widget.
|
2019-01-06 16:06:53 -05:00
|
|
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
2018-03-16 21:22:19 -04:00
|
|
|
*/
|
|
|
|
public static function getHTML() {
|
2020-01-04 23:42:01 +01:00
|
|
|
$a = DI::app();
|
2018-03-16 21:22:19 -04:00
|
|
|
|
2018-08-11 23:05:42 +02:00
|
|
|
if (empty($a->data['user'])) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-15 21:46:55 -04:00
|
|
|
$owner_uid = intval($a->data['user']['uid']);
|
2018-03-17 16:42:28 -04:00
|
|
|
|
|
|
|
// The permission testing is a little bit tricky because we have to respect many cases.
|
|
|
|
|
|
|
|
// It's not the private events page (we don't get the $owner_uid for /events).
|
|
|
|
if (!local_user() && !$owner_uid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-16 21:22:19 -04:00
|
|
|
// $a->data is only available if the profile page is visited. If the visited page is not part
|
|
|
|
// of the profile page it should be the personal /events page. So we can use $a->user.
|
2019-10-16 08:35:14 -04:00
|
|
|
$user = ($a->data['user']['nickname'] ?? '') ?: $a->user['nickname'];
|
2018-03-16 21:22:19 -04:00
|
|
|
|
2019-05-18 11:33:35 -04:00
|
|
|
$tpl = Renderer::getMarkupTemplate("widget/events.tpl");
|
2018-10-31 10:35:50 -04:00
|
|
|
$return = Renderer::replaceMacros($tpl, [
|
2020-01-18 20:52:34 +01:00
|
|
|
'$etitle' => DI::l10n()->t("Export"),
|
|
|
|
'$export_ical' => DI::l10n()->t("Export calendar as ical"),
|
|
|
|
'$export_csv' => DI::l10n()->t("Export calendar as csv"),
|
2018-03-16 21:22:19 -04:00
|
|
|
'$user' => $user
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
}
|