Browse Source

Refactor deprecated App::isAjax() to DI::mode()->isAjax()

pull/8019/head
nupplaPhil 1 year ago
parent
commit
8b6e123b3f
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
7 changed files with 12 additions and 17 deletions
  1. +2
    -2
      mod/item.php
  2. +0
    -9
      src/App.php
  3. +6
    -2
      src/App/Authentication.php
  4. +1
    -1
      src/Module/Admin/Themes/Details.php
  5. +1
    -1
      src/Module/Admin/Themes/Embed.php
  6. +1
    -1
      src/Module/Debug/ItemBody.php
  7. +1
    -1
      src/Module/Group.php

+ 2
- 2
mod/item.php View File

@ -878,7 +878,7 @@ function item_content(App $a)
$o = '';
if (($a->argc >= 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
$o = Item::deleteForUser(['id' => $a->argv[2]], local_user());
} else {
if (!empty($a->argv[3])) {
@ -889,7 +889,7 @@ function item_content(App $a)
}
}
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode([intval($a->argv[2]), intval($o)]);
exit();


+ 0
- 9
src/App.php View File

@ -543,15 +543,6 @@ class App
return Core\Theme::getStylesheetPath($this->getCurrentTheme());
}
/**
* @deprecated 2019.09 - use App\Mode->isAjax() instead
* @see App\Mode::isAjax()
*/
public function isAjax()
{
return $this->mode->isAjax();
}
/**
* @deprecated use Arguments->get() instead
*


+ 6
- 2
src/App/Authentication.php View File

@ -31,6 +31,8 @@ class Authentication
{
/** @var Configuration */
private $config;
/** @var App\Mode */
private $mode;
/** @var App\BaseURL */
private $baseUrl;
/** @var L10n */
@ -48,6 +50,7 @@ class Authentication
* Authentication constructor.
*
* @param Configuration $config
* @param App\Mode $mode
* @param App\BaseURL $baseUrl
* @param L10n $l10n
* @param Database $dba
@ -55,9 +58,10 @@ class Authentication
* @param User\Cookie $cookie
* @param Session\ISession $session
*/
public function __construct(Configuration $config, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
public function __construct(Configuration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
{
$this->config = $config;
$this->mode = $mode;
$this->baseUrl = $baseUrl;
$this->l10n = $l10n;
$this->dba = $dba;
@ -404,7 +408,7 @@ class Authentication
}
// Case 2: No valid 2FA session: redirect to code verification page
if ($a->isAjax()) {
if ($this->mode->isAjax()) {
throw new HTTPException\ForbiddenException();
} else {
$this->baseUrl->redirect('2fa');


+ 1
- 1
src/Module/Admin/Themes/Details.php View File

@ -32,7 +32,7 @@ class Details extends BaseAdminModule
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
return;
}


+ 1
- 1
src/Module/Admin/Themes/Embed.php View File

@ -46,7 +46,7 @@ class Embed extends BaseAdminModule
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
return;
}


+ 1
- 1
src/Module/Debug/ItemBody.php View File

@ -31,7 +31,7 @@ class ItemBody extends BaseModule
$item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
if (!empty($item)) {
if ($app->isAjax()) {
if (DI::mode()->isAjax()) {
echo str_replace("\n", '<br />', $item['body']);
exit();
} else {


+ 1
- 1
src/Module/Group.php View File

@ -24,7 +24,7 @@ class Group extends BaseModule
{
$a = DI::app();
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
self::ajaxPost();
}


Loading…
Cancel
Save