mirror of
https://github.com/friendica/friendica
synced 2025-04-20 13:50:16 +00:00
Revert "Replace Module::init() with Constructors"
This commit is contained in:
parent
0b6e0566d7
commit
89d6c89b67
43 changed files with 921 additions and 1225 deletions
|
@ -21,32 +21,18 @@
|
|||
|
||||
namespace Friendica\Module\Admin\Themes;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
class Embed extends BaseAdmin
|
||||
{
|
||||
/** @var App */
|
||||
protected $app;
|
||||
/** @var App\BaseURL */
|
||||
protected $baseUrl;
|
||||
/** @var App\Mode */
|
||||
protected $mode;
|
||||
|
||||
public function __construct(App $app, App\BaseURL $baseUrl, App\Mode $mode, L10n $l10n, array $parameters = [])
|
||||
public function init()
|
||||
{
|
||||
parent::__construct($l10n, $parameters);
|
||||
|
||||
$this->app = $app;
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->mode = $mode;
|
||||
|
||||
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$this->app->setCurrentTheme($theme);
|
||||
DI::app()->setCurrentTheme($theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,15 +45,15 @@ class Embed extends BaseAdmin
|
|||
require_once "view/theme/$theme/config.php";
|
||||
if (function_exists('theme_admin_post')) {
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
|
||||
theme_admin_post($this->app);
|
||||
theme_admin_post(DI::app());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->mode->isAjax()) {
|
||||
if (DI::mode()->isAjax()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->baseUrl->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
||||
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -76,7 +62,7 @@ class Embed extends BaseAdmin
|
|||
|
||||
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||
if (!is_dir("view/theme/$theme")) {
|
||||
notice($this->t('Unknown theme.'));
|
||||
notice(DI::l10n()->t('Unknown theme.'));
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -85,7 +71,7 @@ class Embed extends BaseAdmin
|
|||
require_once "view/theme/$theme/config.php";
|
||||
|
||||
if (function_exists('theme_admin')) {
|
||||
$admin_form = theme_admin($this->app);
|
||||
$admin_form = theme_admin(DI::app());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,30 +21,12 @@
|
|||
|
||||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
|
||||
class Tos extends BaseAdmin
|
||||
{
|
||||
/** @var \Friendica\Module\Tos */
|
||||
protected $tos;
|
||||
/** @var IManageConfigValues */
|
||||
protected $config;
|
||||
/** @var BaseURL */
|
||||
protected $baseUrl;
|
||||
|
||||
public function __construct(\Friendica\Module\Tos $tos, IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $parameters);
|
||||
|
||||
$this->tos = $tos;
|
||||
$this->config = $config;
|
||||
$this->baseUrl = $baseUrl;
|
||||
}
|
||||
|
||||
public function post()
|
||||
{
|
||||
self::checkAdminAccess();
|
||||
|
@ -59,28 +41,29 @@ class Tos extends BaseAdmin
|
|||
$displayprivstatement = !empty($_POST['displayprivstatement']);
|
||||
$tostext = (!empty($_POST['tostext']) ? strip_tags(trim($_POST['tostext'])) : '');
|
||||
|
||||
$this->config->set('system', 'tosdisplay', $displaytos);
|
||||
$this->config->set('system', 'tosprivstatement', $displayprivstatement);
|
||||
$this->config->set('system', 'tostext', $tostext);
|
||||
DI::config()->set('system', 'tosdisplay', $displaytos);
|
||||
DI::config()->set('system', 'tosprivstatement', $displayprivstatement);
|
||||
DI::config()->set('system', 'tostext', $tostext);
|
||||
|
||||
$this->baseUrl->redirect('admin/tos');
|
||||
DI::baseUrl()->redirect('admin/tos');
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
$tos = new \Friendica\Module\Tos($this->parameters);
|
||||
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
|
||||
return Renderer::replaceMacros($t, [
|
||||
'$title' => $this->t('Administration'),
|
||||
'$page' => $this->t('Terms of Service'),
|
||||
'$displaytos' => ['displaytos', $this->t('Display Terms of Service'), $this->config->get('system', 'tosdisplay'), $this->t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
|
||||
'$displayprivstatement' => ['displayprivstatement', $this->t('Display Privacy Statement'), $this->config->get('system', 'tosprivstatement'), $this->t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank" rel="noopener noreferrer">EU-GDPR</a>.', 'https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
|
||||
'$preview' => $this->t('Privacy Statement Preview'),
|
||||
'$privtext' => $this->tos->privacy_complete,
|
||||
'$tostext' => ['tostext', $this->t('The Terms of Service'), $this->config->get('system', 'tostext'), $this->t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Terms of Service'),
|
||||
'$displaytos' => ['displaytos', DI::l10n()->t('Display Terms of Service'), DI::config()->get('system', 'tosdisplay'), DI::l10n()->t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
|
||||
'$displayprivstatement' => ['displayprivstatement', DI::l10n()->t('Display Privacy Statement'), DI::config()->get('system', 'tosprivstatement'), DI::l10n()->t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank" rel="noopener noreferrer">EU-GDPR</a>.', 'https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
|
||||
'$preview' => DI::l10n()->t('Privacy Statement Preview'),
|
||||
'$privtext' => $tos->privacy_complete,
|
||||
'$tostext' => ['tostext', DI::l10n()->t('The Terms of Service'), DI::config()->get('system', 'tostext'), DI::l10n()->t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_tos'),
|
||||
'$submit' => $this->t('Save Settings'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue