]> git.mxchange.org Git - friendica.git/blob - src/Module/Debug/ItemBody.php
Move L10n::t() calls to DI::l10n()->t() calls
[friendica.git] / src / Module / Debug / ItemBody.php
1 <?php
2
3 namespace Friendica\Module\Debug;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\DI;
8 use Friendica\Model\Item;
9 use Friendica\Network\HTTPException;
10
11 /**
12  * Print the body of an Item
13  */
14 class ItemBody extends BaseModule
15 {
16         public static function content(array $parameters = [])
17         {
18                 if (!local_user()) {
19                         throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
20                 }
21
22                 $app = DI::app();
23
24                 // @TODO: Replace with parameter from router
25                 $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
26
27                 if (!$itemId) {
28                         throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
29                 }
30
31                 $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
32
33                 if (!empty($item)) {
34                         if (DI::mode()->isAjax()) {
35                                 echo str_replace("\n", '<br />', $item['body']);
36                                 exit();
37                         } else {
38                                 return str_replace("\n", '<br />', $item['body']);
39                         }
40                 } else {
41                         throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
42                 }
43         }
44 }