X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FDebug%2FItemBody.php;h=55abc894ed736d263bb0399ea41fb58ec98e635b;hb=7921766c59c1050737ff7fed7c242257e866d149;hp=f166fb0a2782a9f62b51a9e6ad15a33313f12452;hpb=f2c31ef1c0e92208b58d22791fc72d0ad3e3d6ae;p=friendica.git
diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php
index f166fb0a27..55abc894ed 100644
--- a/src/Module/Debug/ItemBody.php
+++ b/src/Module/Debug/ItemBody.php
@@ -1,10 +1,29 @@
.
+ *
+ */
namespace Friendica\Module\Debug;
use Friendica\BaseModule;
-use Friendica\Core\L10n;
-use Friendica\Model\Item;
+use Friendica\DI;
+use Friendica\Model\Post;
use Friendica\Network\HTTPException;
/**
@@ -12,32 +31,29 @@ use Friendica\Network\HTTPException;
*/
class ItemBody extends BaseModule
{
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
if (!local_user()) {
- throw new HTTPException\UnauthorizedException(L10n::t('Access denied.'));
+ throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
}
- $app = self::getApp();
-
- // @TODO: Replace with parameter from router
- $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
-
- if (!$itemId) {
- throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
+ if (empty($this->parameters['item'])) {
+ throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
}
- $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
+ $itemId = intval($this->parameters['item']);
+
+ $item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]);
if (!empty($item)) {
- if ($app->isAjax()) {
+ if (DI::mode()->isAjax()) {
echo str_replace("\n", '
', $item['body']);
exit();
} else {
return str_replace("\n", '
', $item['body']);
}
} else {
- throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
+ throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
}
}
}