Skip to content

Commit

Permalink
Extract HTML from user settings page header
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 7, 2020
1 parent 6152315 commit 3a9b762
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 296 deletions.
10 changes: 8 additions & 2 deletions libraries/classes/Controllers/Preferences/ExportController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
10 changes: 8 additions & 2 deletions libraries/classes/Controllers/Preferences/FeaturesController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
10 changes: 8 additions & 2 deletions libraries/classes/Controllers/Preferences/ImportController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
19 changes: 16 additions & 3 deletions libraries/classes/Controllers/Preferences/ManageController.php
Expand Up @@ -67,7 +67,7 @@ public function __construct(
public function index(): void
{
global $cf, $error, $filename, $import_handle, $json, $PMA_Config, $lang, $max_upload_size;
global $new_config, $config, $return_url, $form_display, $all_ok, $params, $query;
global $new_config, $config, $return_url, $form_display, $all_ok, $params, $query, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -153,7 +153,13 @@ public function index(): void
}
if (! $all_ok) {
// mimic original form and post json in a hidden field
echo UserPreferencesHeader::getContent($this->template, $this->relation);
$cfgRelation = $this->relation->getRelationsParam();

echo $this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]);

echo $this->template->render('preferences/manage/error', [
'form_errors' => $form_display->displayErrors(),
Expand Down Expand Up @@ -224,7 +230,14 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

echo UserPreferencesHeader::getContent($this->template, $this->relation);
$cfgRelation = $this->relation->getRelationsParam();

echo $this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]);

if ($error) {
if (! $error instanceof Message) {
$error = Message::error($error);
Expand Down
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
10 changes: 8 additions & 2 deletions libraries/classes/Controllers/Preferences/SqlController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(
public function index(): void
{
global $cfg, $cf, $error, $tabHash, $hash;
global $server, $PMA_Config;
global $server, $PMA_Config, $route;

$cf = new ConfigFile($PMA_Config->base_settings);
$this->userPreferences->pageInit($cf);
Expand Down Expand Up @@ -90,7 +90,13 @@ public function index(): void
$scripts = $header->getScripts();
$scripts->addFile('config.js');

$this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation));
$cfgRelation = $this->relation->getRelationsParam();

$this->response->addHTML($this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]));

if ($formDisplay->hasErrors()) {
$formErrors = $formDisplay->displayErrors();
Expand Down
Expand Up @@ -32,9 +32,15 @@ public function __construct($response, $dbi, Template $template, Relation $relat

public function index(): void
{
global $cfg;
global $cfg, $route;

echo UserPreferencesHeader::getContent($this->template, $this->relation);
$cfgRelation = $this->relation->getRelationsParam();

echo $this->template->render('preferences/header', [
'route' => $route,
'is_saved' => ! empty($_GET['saved']),
'has_config_storage' => $cfgRelation['userconfigwork'],
]);

$twoFactor = new TwoFactor($cfg['Server']['user']);

Expand Down
165 changes: 0 additions & 165 deletions libraries/classes/UserPreferencesHeader.php

This file was deleted.

0 comments on commit 3a9b762

Please sign in to comment.