Revert "Replace Module::init() with Constructors"

This commit is contained in:
Hypolite Petovan 2021-11-19 07:23:23 -05:00 committed by GitHub
parent 0b6e0566d7
commit 89d6c89b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 921 additions and 1225 deletions

View file

@ -21,43 +21,36 @@
namespace Friendica\Module\Filer;
use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
use Friendica\Util\XML;
use Psr\Log\LoggerInterface;
/**
* Shows a dialog for adding tags to a file
*/
class SaveTag extends BaseModule
{
/** @var LoggerInterface */
protected $logger;
public function __construct(LoggerInterface $logger, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
public function init()
{
parent::__construct($l10n, $parameters);
$this->logger = $logger;
if (!local_user()) {
notice($this->t('You must be logged in to use this module'));
$baseUrl->redirect();
notice(DI::l10n()->t('You must be logged in to use this module'));
DI::baseUrl()->redirect();
}
}
public function rawContent()
{
$logger = DI::logger();
$term = XML::unescape(trim($_GET['term'] ?? ''));
$item_id = $this->parameters['id'] ?? 0;
$this->logger->info('filer', ['tag' => $term, 'item' => $item_id]);
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);
if ($item_id && strlen($term)) {
$item = Model\Post::selectFirst(['uri-id'], ['id' => $item_id]);
@ -72,8 +65,8 @@ class SaveTag extends BaseModule
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [
'$field' => ['term', $this->t("Save to Folder:"), '', '', $filetags, $this->t('- select -')],
'$submit' => $this->t('Save'),
'$field' => ['term', DI::l10n()->t("Save to Folder:"), '', '', $filetags, DI::l10n()->t('- select -')],
'$submit' => DI::l10n()->t('Save'),
]);
exit;