Use the router for view_create.php
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
40ed155775
commit
ba6bad9533
@ -271,6 +271,11 @@ if (isset($_GET['route']) || isset($_POST['route'])) {
|
||||
$routes->addRoute(['GET', 'POST'], '/version_check', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/version_check.php';
|
||||
});
|
||||
$routes->addGroup('/view', function (RouteCollector $routes) {
|
||||
$routes->addRoute(['GET', 'POST'], '/create', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/view/create.php';
|
||||
});
|
||||
});
|
||||
});
|
||||
$routeInfo = $dispatcher->dispatch(
|
||||
$_SERVER['REQUEST_METHOD'],
|
||||
|
||||
@ -4564,7 +4564,7 @@ Functions.createViewDialog = function ($this) {
|
||||
codeMirrorEditor.save();
|
||||
}
|
||||
$msg = Functions.ajaxShowMessage();
|
||||
$.post('view_create.php', $('#createViewDialog').find('form').serialize(), function (data) {
|
||||
$.post('index.php?route=/view/create', $('#createViewDialog').find('form').serialize(), function (data) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
$('#createViewDialog').dialog('close');
|
||||
|
||||
@ -1276,14 +1276,6 @@ class StructureController extends AbstractController
|
||||
'DistinctValues' => Util::getIcon('b_browse', __('Distinct values')),
|
||||
];
|
||||
|
||||
$edit_view_url = '';
|
||||
if ($this->_tbl_is_view && ! $this->_db_is_system_schema) {
|
||||
$edit_view_url = Url::getCommon([
|
||||
'db' => $this->db,
|
||||
'table' => $this->table,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays Space usage and row statistics
|
||||
*/
|
||||
@ -1371,7 +1363,6 @@ class StructureController extends AbstractController
|
||||
'tbl_storage_engine' => $this->_tbl_storage_engine,
|
||||
'primary' => $primary_index,
|
||||
'columns_with_unique_index' => $columns_with_unique_index,
|
||||
'edit_view_url' => $edit_view_url,
|
||||
'columns_list' => $columns_list,
|
||||
'table_stats' => isset($tablestats) ? $tablestats : null,
|
||||
'fields' => $fields,
|
||||
|
||||
@ -4768,8 +4768,8 @@ class Results
|
||||
/**
|
||||
* Generates HTML to display the Create view in span tag
|
||||
*
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param string $url_query String with URL Parameters
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param array $params Array with URL Parameters
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
@ -4777,13 +4777,13 @@ class Results
|
||||
*
|
||||
* @see _getResultsOperations()
|
||||
*/
|
||||
private function _getLinkForCreateView(array $analyzed_sql_results, $url_query)
|
||||
private function _getLinkForCreateView(array $analyzed_sql_results, array $params): string
|
||||
{
|
||||
$results_operations_html = '';
|
||||
if (empty($analyzed_sql_results['procedure'])) {
|
||||
$results_operations_html .= '<span>'
|
||||
. Util::linkOrButton(
|
||||
'view_create.php' . $url_query,
|
||||
Url::getFromRoute('/view/create', $params),
|
||||
Util::getIcon(
|
||||
'b_view_add',
|
||||
__('Create view'),
|
||||
@ -4892,7 +4892,7 @@ class Results
|
||||
'printview' => '1',
|
||||
'sql_query' => $this->__get('sql_query'),
|
||||
];
|
||||
$url_query = Url::getCommon($_url_params);
|
||||
$params = $_url_params;
|
||||
|
||||
if (! $header_shown) {
|
||||
$results_operations_html .= $header;
|
||||
@ -4903,7 +4903,7 @@ class Results
|
||||
if ($only_view) {
|
||||
$results_operations_html .= $this->_getLinkForCreateView(
|
||||
$analyzed_sql_results,
|
||||
$url_query
|
||||
$params
|
||||
);
|
||||
|
||||
if ($header_shown) {
|
||||
@ -5016,7 +5016,7 @@ class Results
|
||||
|
||||
$results_operations_html .= $this->_getLinkForCreateView(
|
||||
$analyzed_sql_results,
|
||||
$url_query
|
||||
$params
|
||||
);
|
||||
|
||||
if ($header_shown) {
|
||||
|
||||
@ -50,10 +50,12 @@ class NodeViewContainer extends NodeDatabaseChildContainer
|
||||
$new->isNew = true;
|
||||
$new->icon = Util::getImage('b_view_add', $newLabel);
|
||||
$new->links = [
|
||||
'text' => 'view_create.php?server=' . $GLOBALS['server']
|
||||
. '&db=%2$s',
|
||||
'icon' => 'view_create.php?server=' . $GLOBALS['server']
|
||||
. '&db=%2$s',
|
||||
'text' => Url::getFromRoute('/view/create', [
|
||||
'server' => $GLOBALS['server'],
|
||||
]) . '&db=%2$s',
|
||||
'icon' => Url::getFromRoute('/view/create', [
|
||||
'server' => $GLOBALS['server'],
|
||||
]) . '&db=%2$s',
|
||||
];
|
||||
$new->classes = 'new_view italics';
|
||||
$this->addChild($new);
|
||||
|
||||
@ -17,13 +17,12 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $containerBuilder, $text_dir;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
@ -33,7 +32,7 @@ $response = $containerBuilder->get(Response::class);
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
$url_params['goto'] = Url::getFromRoute('/table/structure');
|
||||
$url_params['back'] = 'view_create.php';
|
||||
$url_params['back'] = Url::getFromRoute('/view/create');
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
@ -62,10 +62,10 @@
|
||||
</td>
|
||||
{% if table_is_view %}
|
||||
<td class="center print_ignore">
|
||||
<a href="view_create.php{{- get_common({
|
||||
'db': db,
|
||||
'table': current_table['TABLE_NAME']
|
||||
}) }}">{{ titles['Edit']|raw }}</a>
|
||||
<a href="{{ url('/view/create', {
|
||||
'db': db,
|
||||
'table': current_table['TABLE_NAME']
|
||||
}) }}">{{ titles['Edit']|raw }}</a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="center print_ignore">
|
||||
|
||||
@ -374,9 +374,8 @@
|
||||
{# Work on the table #}
|
||||
<div id="structure-action-links">
|
||||
{% if tbl_is_view and not db_is_system_schema %}
|
||||
{% set edit_view_url = 'view_create.php' ~ edit_view_url %}
|
||||
{{ link_or_button(
|
||||
edit_view_url,
|
||||
url('/view/create', {'db': db, 'table': table}),
|
||||
get_icon('b_edit', 'Edit view'|trans, true)
|
||||
) }}
|
||||
{% endif %}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!-- CREATE VIEW options -->
|
||||
<div id="div_view_options">
|
||||
<form method="post" action="view_create.php">
|
||||
<form method="post" action="{{ url('/view/create') }}">
|
||||
{{ get_hidden_inputs(url_params) }}
|
||||
<fieldset>
|
||||
<legend>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user