Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2019-09-04 02:41:36 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2019-09-04 02:41:36 +0300
commite3f891f604987ceac0928a30034e92fd5d848496 (patch)
tree1f6cc804c7b5b5a69302a83e6fcaa34a1a239191 /libraries/classes/SqlQueryForm.php
parentfc606d27460df0c6c2e575414175b0ad7eeb1940 (diff)
Refactor SqlQueryForm::getHtml
Move insert and page templates into page template Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries/classes/SqlQueryForm.php')
-rw-r--r--libraries/classes/SqlQueryForm.php100
1 files changed, 29 insertions, 71 deletions
diff --git a/libraries/classes/SqlQueryForm.php b/libraries/classes/SqlQueryForm.php
index fd2e108c14..4b2a5b2032 100644
--- a/libraries/classes/SqlQueryForm.php
+++ b/libraries/classes/SqlQueryForm.php
@@ -79,31 +79,49 @@ class SqlQueryForm
$goto = empty($GLOBALS['goto']) ? Url::getFromRoute('/table/sql') : $GLOBALS['goto'];
}
- $insert = '';
if ($display_tab === 'full' || $display_tab === 'sql') {
- $insert = $this->getHtmlForInsert(
- $query,
- $delimiter
- );
+ list($legend, $query, $columns_list) = $this->init($query);
}
- $bookmark = '';
+ $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
+
+ $bookmarks = [];
if ($display_tab === 'full') {
- $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
if ($cfgBookmark) {
- $bookmark = $this->getHtmlForBookmark();
+ $bookmark_list = Bookmark::getList(
+ $GLOBALS['dbi'],
+ $GLOBALS['cfg']['Server']['user'],
+ $GLOBALS['db']
+ );
+
+ foreach ($bookmark_list as $bookmarkItem) {
+ $bookmarks[] = [
+ 'id' => $bookmarkItem->getId(),
+ 'variable_count' => $bookmarkItem->getVariableCount(),
+ 'label' => $bookmarkItem->getLabel(),
+ 'is_shared' => empty($bookmarkItem->getUser()),
+ ];
+ }
}
}
- return $this->template->render('sql/query/page', [
+ return $this->template->render('sql/query', [
+ 'legend' => $legend ?? '',
+ 'textarea_cols' => $GLOBALS['cfg']['TextareaCols'],
+ 'textarea_rows' => $GLOBALS['cfg']['TextareaRows'],
+ 'textarea_auto_select' => $GLOBALS['cfg']['TextareaAutoSelect'],
+ 'columns_list' => $columns_list ?? [],
+ 'codemirror_enable' => $GLOBALS['cfg']['CodemirrorEnable'],
+ 'has_bookmark' => $cfgBookmark,
+ 'delimiter' => $delimiter,
+ 'retain_query_box' => $GLOBALS['cfg']['RetainQueryBox'] !== false,
'is_upload' => $GLOBALS['is_upload'],
'db' => $db,
'table' => $table,
'goto' => $goto,
'query' => $query,
'display_tab' => $display_tab,
- 'insert' => $insert,
- 'bookmark' => $bookmark,
+ 'bookmarks' => $bookmarks,
'can_convert_kanji' => Encoding::canConvertKanji(),
]);
}
@@ -180,64 +198,4 @@ class SqlQueryForm
$columns_list,
];
}
-
- /**
- * return HTML for Sql Query Form Insert
- *
- * @param string $query query to display in the textarea
- * @param string $delimiter default delimiter to use
- *
- * @return string
- */
- public function getHtmlForInsert(
- $query = '',
- $delimiter = ';'
- ) {
- list($legend, $query, $columns_list) = $this->init($query);
- $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
-
- return $this->template->render('sql/query/insert', [
- 'legend' => $legend,
- 'textarea_cols' => $GLOBALS['cfg']['TextareaCols'],
- 'textarea_rows' => $GLOBALS['cfg']['TextareaRows'],
- 'textarea_auto_select' => $GLOBALS['cfg']['TextareaAutoSelect'],
- 'query' => $query,
- 'columns_list' => $columns_list,
- 'codemirror_enable' => $GLOBALS['cfg']['CodemirrorEnable'],
- 'has_bookmark' => $cfgBookmark,
- 'delimiter' => $delimiter,
- 'retain_query_box' => $GLOBALS['cfg']['RetainQueryBox'] !== false,
- ]);
- }
-
- /**
- * return HTML for sql Query Form Bookmark
- *
- * @return string|null
- */
- public function getHtmlForBookmark()
- {
- $bookmark_list = Bookmark::getList(
- $GLOBALS['dbi'],
- $GLOBALS['cfg']['Server']['user'],
- $GLOBALS['db']
- );
- if (empty($bookmark_list) || count($bookmark_list) < 1) {
- return null;
- }
-
- $bookmarks = [];
- foreach ($bookmark_list as $bookmark) {
- $bookmarks[] = [
- 'id' => $bookmark->getId(),
- 'variable_count' => $bookmark->getVariableCount(),
- 'label' => $bookmark->getLabel(),
- 'is_shared' => empty($bookmark->getUser()),
- ];
- }
-
- return $this->template->render('sql/query/bookmark', [
- 'bookmarks' => $bookmarks,
- ]);
- }
}