2019-05-05 17:15:33 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2023-01-01 14:36:24 +00:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2020-02-09 14:45:36 +00: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/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-05-05 17:15:33 +00:00
|
|
|
|
2019-05-19 01:02:58 +00:00
|
|
|
namespace Friendica\Module\Debug;
|
2019-05-05 17:15:33 +00:00
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
2022-05-18 02:13:54 +00:00
|
|
|
use Friendica\Core\System;
|
2019-12-15 21:34:11 +00:00
|
|
|
use Friendica\DI;
|
2021-01-16 04:16:09 +00:00
|
|
|
use Friendica\Model\Post;
|
2019-05-05 17:15:33 +00:00
|
|
|
use Friendica\Network\HTTPException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print the body of an Item
|
|
|
|
*/
|
|
|
|
class ItemBody extends BaseModule
|
|
|
|
{
|
2021-11-20 14:38:03 +00:00
|
|
|
protected function content(array $request = []): string
|
2019-05-05 17:15:33 +00:00
|
|
|
{
|
2022-10-20 20:59:12 +00:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2020-01-18 19:52:34 +00:00
|
|
|
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
|
2019-05-05 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 22:19:25 +00:00
|
|
|
if (empty($this->parameters['item'])) {
|
2020-01-18 19:52:34 +00:00
|
|
|
throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
|
2019-05-05 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 22:19:25 +00:00
|
|
|
$itemId = intval($this->parameters['item']);
|
2021-07-25 15:23:37 +00:00
|
|
|
|
2022-10-20 20:59:12 +00:00
|
|
|
$item = Post::selectFirst(['body'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $itemId]);
|
2019-05-05 17:15:33 +00:00
|
|
|
|
|
|
|
if (!empty($item)) {
|
2019-12-15 23:30:39 +00:00
|
|
|
if (DI::mode()->isAjax()) {
|
2019-05-05 17:15:33 +00:00
|
|
|
echo str_replace("\n", '<br />', $item['body']);
|
2022-05-18 02:13:54 +00:00
|
|
|
System::exit();
|
2019-05-05 17:15:33 +00:00
|
|
|
} else {
|
|
|
|
return str_replace("\n", '<br />', $item['body']);
|
|
|
|
}
|
|
|
|
} else {
|
2020-01-18 19:52:34 +00:00
|
|
|
throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
|
2019-05-05 17:15:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|