Refactor db_designer functions to static methods
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
5c15caf58d
commit
8079fd7009
@ -5,25 +5,25 @@
|
||||
*
|
||||
* @package PhpMyAdmin-Designer
|
||||
*/
|
||||
use PhpMyAdmin\Database\Designer;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/pmd_common.php';
|
||||
require_once 'libraries/db_designer.lib.php';
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
if (isset($_REQUEST['dialog'])) {
|
||||
|
||||
if ($_REQUEST['dialog'] == 'edit') {
|
||||
$html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
|
||||
$html = Designer::getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
|
||||
} else if ($_REQUEST['dialog'] == 'delete') {
|
||||
$html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
|
||||
$html = Designer::getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
|
||||
} else if ($_REQUEST['dialog'] == 'save_as') {
|
||||
$html = PMA_getHtmlForPageSaveAs($GLOBALS['db']);
|
||||
$html = Designer::getHtmlForPageSaveAs($GLOBALS['db']);
|
||||
} else if ($_REQUEST['dialog'] == 'export') {
|
||||
include_once 'libraries/plugin_interface.lib.php';
|
||||
$html = PMA_getHtmlForSchemaExport(
|
||||
$html = Designer::getHtmlForSchemaExport(
|
||||
$GLOBALS['db'], $_REQUEST['selected_page']
|
||||
);
|
||||
} else if ($_REQUEST['dialog'] == 'add_table') {
|
||||
@ -42,7 +42,7 @@ if (isset($_REQUEST['dialog'])) {
|
||||
$GLOBALS['PMD']['TABLE_TYPE'] = array($GLOBALS['PMD_URL']['TABLE_TYPE'][$req_key]);
|
||||
$GLOBALS['PMD_OUT']['OWNER'] = array($GLOBALS['PMD_OUT']['OWNER'][$req_key]);
|
||||
|
||||
$html = PMA_getDatabaseTables(
|
||||
$html = Designer::getDatabaseTables(
|
||||
array(), -1, $tab_column,
|
||||
$tables_all_keys, $tables_pk_or_unique_keys
|
||||
);
|
||||
@ -111,7 +111,7 @@ $tab_column = PMA_getColumnsInfo();
|
||||
$script_tables = PMA_getScriptTabs();
|
||||
$tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
|
||||
$tables_all_keys = PMA_getAllKeys();
|
||||
$classes_side_menu = PMA_returnClassNamesFromMenuButtons();
|
||||
$classes_side_menu = Designer::returnClassNamesFromMenuButtons();
|
||||
|
||||
$display_page = -1;
|
||||
$selected_page = null;
|
||||
@ -165,12 +165,12 @@ list(
|
||||
// Embed some data into HTML, later it will be read
|
||||
// by pmd/init.js and converted to JS variables.
|
||||
$response->addHTML(
|
||||
PMA_getHtmlForJSFields(
|
||||
Designer::getHtmlForJsFields(
|
||||
$script_tables, $script_contr, $script_display_field, $display_page
|
||||
)
|
||||
);
|
||||
$response->addHTML(
|
||||
PMA_getDesignerPageMenu(
|
||||
Designer::getPageMenu(
|
||||
isset($_REQUEST['query']),
|
||||
$selected_page,
|
||||
$classes_side_menu
|
||||
@ -184,11 +184,11 @@ $response->addHTML(
|
||||
'<form action="" id="container-form" method="post" name="form1">'
|
||||
);
|
||||
|
||||
$response->addHTML(PMA_getHTMLCanvas());
|
||||
$response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
|
||||
$response->addHTML(Designer::getHtmlCanvas());
|
||||
$response->addHTML(Designer::getHtmlTableList($tab_pos, $display_page));
|
||||
|
||||
$response->addHTML(
|
||||
PMA_getDatabaseTables(
|
||||
Designer::getDatabaseTables(
|
||||
$tab_pos, $display_page, $tab_column,
|
||||
$tables_all_keys, $tables_pk_or_unique_keys
|
||||
)
|
||||
@ -198,16 +198,16 @@ $response->addHTML('</div>'); // end canvas_outer
|
||||
|
||||
$response->addHTML('<div id="pmd_hint"></div>');
|
||||
|
||||
$response->addHTML(PMA_getNewRelationPanel());
|
||||
$response->addHTML(PMA_getDeleteRelationPanel());
|
||||
$response->addHTML(Designer::getNewRelationPanel());
|
||||
$response->addHTML(Designer::getDeleteRelationPanel());
|
||||
|
||||
if (isset($_REQUEST['query'])) {
|
||||
$response->addHTML(PMA_getOptionsPanel());
|
||||
$response->addHTML(PMA_getRenameToPanel());
|
||||
$response->addHTML(PMA_getHavingQueryPanel());
|
||||
$response->addHTML(PMA_getAggregateQueryPanel());
|
||||
$response->addHTML(PMA_getWhereQueryPanel());
|
||||
$response->addHTML(PMA_getQueryDetails());
|
||||
$response->addHTML(Designer::getOptionsPanel());
|
||||
$response->addHTML(Designer::getRenameToPanel());
|
||||
$response->addHTML(Designer::getHavingQueryPanel());
|
||||
$response->addHTML(Designer::getAggregateQueryPanel());
|
||||
$response->addHTML(Designer::getWhereQueryPanel());
|
||||
$response->addHTML(Designer::getQueryDetails());
|
||||
}
|
||||
|
||||
$response->addHTML('<div id="PMA_disable_floating_menubar"></div>');
|
||||
|
||||
414
libraries/classes/Database/Designer.php
Normal file
414
libraries/classes/Database/Designer.php
Normal file
@ -0,0 +1,414 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions related to designer
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
namespace PhpMyAdmin\Database;
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\Database\Designer class
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class Designer
|
||||
{
|
||||
/**
|
||||
* Function to get html to display a page selector
|
||||
*
|
||||
* @param array $cfgRelation information about the configuration storage
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
public static function getHtmlForPageSelector($cfgRelation, $db)
|
||||
{
|
||||
return Template::get('database/designer/page_selector')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'cfgRelation' => $cfgRelation
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the page edit/delete form
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $operation 'edit' or 'delete' depending on the operation
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
public static function getHtmlForEditOrDeletePages($db, $operation)
|
||||
{
|
||||
return Template::get('database/designer/edit_delete_pages')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'operation' => $operation
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the page save as form
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
public static function getHtmlForPageSaveAs($db)
|
||||
{
|
||||
return Template::get('database/designer/page_save_as')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve IDs and names of schema pages
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return array array of schema page id and names
|
||||
*/
|
||||
public static function getPageIdsAndNames($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$page_query = "SELECT `page_nr`, `page_descr` FROM "
|
||||
. Util::backquote($cfgRelation['db']) . "."
|
||||
. Util::backquote($cfgRelation['pdf_pages'])
|
||||
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'"
|
||||
. " ORDER BY `page_descr`";
|
||||
$page_rs = Relation::queryAsControlUser(
|
||||
$page_query, false, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
$result = array();
|
||||
while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
|
||||
$result[intval($curr_page['page_nr'])] = $curr_page['page_descr'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the schema export
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param int $page the page to be exported
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getHtmlForSchemaExport($db, $page)
|
||||
{
|
||||
/* Scan for schema plugins */
|
||||
/* @var $export_list SchemaPlugin[] */
|
||||
$export_list = PMA_getPlugins(
|
||||
"schema",
|
||||
'libraries/classes/Plugins/Schema/',
|
||||
null
|
||||
);
|
||||
|
||||
/* Fail if we didn't find any schema plugin */
|
||||
if (empty($export_list)) {
|
||||
return Message::error(
|
||||
__('Could not load schema plugins, please check your installation!')
|
||||
)->getDisplay();
|
||||
}
|
||||
|
||||
return Template::get('database/designer/schema_export')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'page' => $page,
|
||||
'export_list' => $export_list
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for including some variable to be accessed by JavaScript
|
||||
*
|
||||
* @param array $script_tables array on foreign key support for each table
|
||||
* @param array $script_contr initialization data array
|
||||
* @param array $script_display_field display fields of each table
|
||||
* @param int $display_page page number of the selected page
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getHtmlForJsFields(
|
||||
$script_tables, $script_contr, $script_display_field, $display_page
|
||||
) {
|
||||
return Template::get('database/designer/js_fields')
|
||||
->render(
|
||||
array(
|
||||
'script_tables' => $script_tables,
|
||||
'script_contr' => $script_contr,
|
||||
'script_display_field' => $script_display_field,
|
||||
'display_page' => $display_page
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the menu bar of the designer page
|
||||
*
|
||||
* @param boolean $visualBuilder whether this is visual query builder
|
||||
* @param string $selected_page name of the selected page
|
||||
* @param array $params_array array with class name for various buttons on side
|
||||
* menu
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getPageMenu($visualBuilder, $selected_page, $params_array)
|
||||
{
|
||||
return Template::get('database/designer/side_menu')
|
||||
->render(
|
||||
array(
|
||||
'visualBuilder' => $visualBuilder,
|
||||
'selected_page' => $selected_page,
|
||||
'params_array' => $params_array
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of stored values of Designer Settings
|
||||
*
|
||||
* @return array stored values
|
||||
*/
|
||||
public static function getSideMenuParamsArray()
|
||||
{
|
||||
$params = array();
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($GLOBALS['cfgRelation']['designersettingswork']) {
|
||||
|
||||
$query = 'SELECT `settings_data` FROM '
|
||||
. Util::backquote($cfgRelation['db']) . '.'
|
||||
. Util::backquote($cfgRelation['designer_settings'])
|
||||
. ' WHERE ' . Util::backquote('username') . ' = "'
|
||||
. $GLOBALS['cfg']['Server']['user'] . '";';
|
||||
|
||||
$result = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
|
||||
$params = json_decode($result['settings_data'], true);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns class names for various buttons on Designer Side Menu
|
||||
*
|
||||
* @return array class names of various buttons
|
||||
*/
|
||||
public static function returnClassNamesFromMenuButtons()
|
||||
{
|
||||
$classes_array = array();
|
||||
$params_array = self::getSideMenuParamsArray();
|
||||
|
||||
if (isset($params_array['angular_direct'])
|
||||
&& $params_array['angular_direct'] == 'angular'
|
||||
) {
|
||||
$classes_array['angular_direct'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['angular_direct'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['snap_to_grid'])
|
||||
&& $params_array['snap_to_grid'] == 'on'
|
||||
) {
|
||||
$classes_array['snap_to_grid'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['snap_to_grid'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['pin_text'])
|
||||
&& $params_array['pin_text'] == 'true'
|
||||
) {
|
||||
$classes_array['pin_text'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['pin_text'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['relation_lines'])
|
||||
&& $params_array['relation_lines'] == 'false'
|
||||
) {
|
||||
$classes_array['relation_lines'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['relation_lines'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['small_big_all'])
|
||||
&& $params_array['small_big_all'] == 'v'
|
||||
) {
|
||||
$classes_array['small_big_all'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['small_big_all'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['side_menu'])
|
||||
&& $params_array['side_menu'] == 'true'
|
||||
) {
|
||||
$classes_array['side_menu'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['side_menu'] = 'M_butt';
|
||||
}
|
||||
|
||||
return $classes_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the canvas element
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getHtmlCanvas()
|
||||
{
|
||||
return Template::get('database/designer/canvas')->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML for the table list
|
||||
*
|
||||
* @param array $tab_pos table positions
|
||||
* @param int $display_page page number of the selected page
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getHtmlTableList($tab_pos, $display_page)
|
||||
{
|
||||
return Template::get('database/designer/table_list')
|
||||
->render(
|
||||
array(
|
||||
'tab_pos' => $tab_pos,
|
||||
'display_page' => $display_page
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML to display tables on designer page
|
||||
*
|
||||
* @param array $tab_pos tables positions
|
||||
* @param int $display_page page number of the selected page
|
||||
* @param array $tab_column table column info
|
||||
* @param array $tables_all_keys all indices
|
||||
* @param array $tables_pk_or_unique_keys unique or primary indices
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getDatabaseTables(
|
||||
$tab_pos, $display_page, $tab_column, $tables_all_keys, $tables_pk_or_unique_keys
|
||||
) {
|
||||
return Template::get('database/designer/database_tables')
|
||||
->render(
|
||||
array(
|
||||
'tab_pos' => $tab_pos,
|
||||
'display_page' => $display_page,
|
||||
'tab_column' => $tab_column,
|
||||
'tables_all_keys' => $tables_all_keys,
|
||||
'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the new relations panel.
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getNewRelationPanel()
|
||||
{
|
||||
return Template::get('database/designer/new_relation_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the relations delete panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getDeleteRelationPanel()
|
||||
{
|
||||
return Template::get('database/designer/delete_relation_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the options panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getOptionsPanel()
|
||||
{
|
||||
return Template::get('database/designer/options_panel')->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for the 'rename to' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getRenameToPanel()
|
||||
{
|
||||
return Template::get('database/designer/rename_to_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'having' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getHavingQueryPanel()
|
||||
{
|
||||
return Template::get('database/designer/having_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'aggregate' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getAggregateQueryPanel()
|
||||
{
|
||||
return Template::get('database/designer/aggregate_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'where' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getWhereQueryPanel()
|
||||
{
|
||||
return Template::get('database/designer/where_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the query details panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public static function getQueryDetails()
|
||||
{
|
||||
return Template::get('database/designer/query_details')->render();
|
||||
}
|
||||
}
|
||||
@ -1,405 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions related to designer
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Relation;
|
||||
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html to display a page selector
|
||||
*
|
||||
* @param array $cfgRelation information about the configuration storage
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
function PMA_getHtmlForPageSelector($cfgRelation, $db)
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/page_selector')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'cfgRelation' => $cfgRelation
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the page edit/delete form
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $operation 'edit' or 'delete' depending on the operation
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
function PMA_getHtmlForEditOrDeletePages($db, $operation)
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/edit_delete_pages')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'operation' => $operation
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the page save as form
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return string html content
|
||||
*/
|
||||
function PMA_getHtmlForPageSaveAs($db)
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/page_save_as')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve IDs and names of schema pages
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return array array of schema page id and names
|
||||
*/
|
||||
function PMA_getPageIdsAndNames($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$page_query = "SELECT `page_nr`, `page_descr` FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db']) . "."
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['pdf_pages'])
|
||||
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'"
|
||||
. " ORDER BY `page_descr`";
|
||||
$page_rs = Relation::queryAsControlUser(
|
||||
$page_query, false, PhpMyAdmin\DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
$result = array();
|
||||
while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
|
||||
$result[intval($curr_page['page_nr'])] = $curr_page['page_descr'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the schema export
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param int $page the page to be exported
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForSchemaExport($db, $page)
|
||||
{
|
||||
/* Scan for schema plugins */
|
||||
/* @var $export_list SchemaPlugin[] */
|
||||
$export_list = PMA_getPlugins(
|
||||
"schema",
|
||||
'libraries/classes/Plugins/Schema/',
|
||||
null
|
||||
);
|
||||
|
||||
/* Fail if we didn't find any schema plugin */
|
||||
if (empty($export_list)) {
|
||||
return Message::error(
|
||||
__('Could not load schema plugins, please check your installation!')
|
||||
)->getDisplay();
|
||||
}
|
||||
|
||||
return PhpMyAdmin\Template::get('database/designer/schema_export')
|
||||
->render(
|
||||
array(
|
||||
'db' => $db,
|
||||
'page' => $page,
|
||||
'export_list' => $export_list
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for including some variable to be accessed by JavaScript
|
||||
*
|
||||
* @param array $script_tables array on foreign key support for each table
|
||||
* @param array $script_contr initialization data array
|
||||
* @param array $script_display_field display fields of each table
|
||||
* @param int $display_page page number of the selected page
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getHtmlForJSFields(
|
||||
$script_tables, $script_contr, $script_display_field, $display_page
|
||||
) {
|
||||
return PhpMyAdmin\Template::get('database/designer/js_fields')
|
||||
->render(
|
||||
array(
|
||||
'script_tables' => $script_tables,
|
||||
'script_contr' => $script_contr,
|
||||
'script_display_field' => $script_display_field,
|
||||
'display_page' => $display_page
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the menu bar of the designer page
|
||||
*
|
||||
* @param boolean $visualBuilder whether this is visual query builder
|
||||
* @param string $selected_page name of the selected page
|
||||
* @param array $params_array array with class name for various buttons on side
|
||||
* menu
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getDesignerPageMenu($visualBuilder, $selected_page, $params_array)
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/side_menu')
|
||||
->render(
|
||||
array(
|
||||
'visualBuilder' => $visualBuilder,
|
||||
'selected_page' => $selected_page,
|
||||
'params_array' => $params_array
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of stored values of Designer Settings
|
||||
*
|
||||
* @return array stored values
|
||||
*/
|
||||
function PMA_getSideMenuParamsArray()
|
||||
{
|
||||
$params = array();
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($GLOBALS['cfgRelation']['designersettingswork']) {
|
||||
|
||||
$query = 'SELECT `settings_data` FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db']) . '.'
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['designer_settings'])
|
||||
. ' WHERE ' . PhpMyAdmin\Util::backquote('username') . ' = "'
|
||||
. $GLOBALS['cfg']['Server']['user'] . '";';
|
||||
|
||||
$result = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
|
||||
$params = json_decode($result['settings_data'], true);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns class names for various buttons on Designer Side Menu
|
||||
*
|
||||
* @return array class names of various buttons
|
||||
*/
|
||||
function PMA_returnClassNamesFromMenuButtons()
|
||||
{
|
||||
$classes_array = array();
|
||||
$params_array = PMA_getSideMenuParamsArray();
|
||||
|
||||
if (isset($params_array['angular_direct'])
|
||||
&& $params_array['angular_direct'] == 'angular'
|
||||
) {
|
||||
$classes_array['angular_direct'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['angular_direct'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['snap_to_grid'])
|
||||
&& $params_array['snap_to_grid'] == 'on'
|
||||
) {
|
||||
$classes_array['snap_to_grid'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['snap_to_grid'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['pin_text'])
|
||||
&& $params_array['pin_text'] == 'true'
|
||||
) {
|
||||
$classes_array['pin_text'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['pin_text'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['relation_lines'])
|
||||
&& $params_array['relation_lines'] == 'false'
|
||||
) {
|
||||
$classes_array['relation_lines'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['relation_lines'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['small_big_all'])
|
||||
&& $params_array['small_big_all'] == 'v'
|
||||
) {
|
||||
$classes_array['small_big_all'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['small_big_all'] = 'M_butt';
|
||||
}
|
||||
|
||||
if (isset($params_array['side_menu'])
|
||||
&& $params_array['side_menu'] == 'true'
|
||||
) {
|
||||
$classes_array['side_menu'] = 'M_butt_Selected_down';
|
||||
} else {
|
||||
$classes_array['side_menu'] = 'M_butt';
|
||||
}
|
||||
|
||||
return $classes_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the canvas element
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getHTMLCanvas()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/canvas')->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML for the table list
|
||||
*
|
||||
* @param array $tab_pos table positions
|
||||
* @param int $display_page page number of the selected page
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getHTMLTableList($tab_pos, $display_page)
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/table_list')
|
||||
->render(
|
||||
array(
|
||||
'tab_pos' => $tab_pos,
|
||||
'display_page' => $display_page
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML to display tables on designer page
|
||||
*
|
||||
* @param array $tab_pos tables positions
|
||||
* @param int $display_page page number of the selected page
|
||||
* @param array $tab_column table column info
|
||||
* @param array $tables_all_keys all indices
|
||||
* @param array $tables_pk_or_unique_keys unique or primary indices
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getDatabaseTables(
|
||||
$tab_pos, $display_page, $tab_column, $tables_all_keys, $tables_pk_or_unique_keys
|
||||
) {
|
||||
return PhpMyAdmin\Template::get('database/designer/database_tables')
|
||||
->render(
|
||||
array(
|
||||
'tab_pos' => $tab_pos,
|
||||
'display_page' => $display_page,
|
||||
'tab_column' => $tab_column,
|
||||
'tables_all_keys' => $tables_all_keys,
|
||||
'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the new relations panel.
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getNewRelationPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/new_relation_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the relations delete panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getDeleteRelationPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/delete_relation_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the options panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getOptionsPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/options_panel')->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for the 'rename to' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getRenameToPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/rename_to_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'having' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getHavingQueryPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/having_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'aggregate' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getAggregateQueryPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/aggregate_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the 'where' panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getWhereQueryPanel()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/where_query_panel')
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the query details panel
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
function PMA_getQueryDetails()
|
||||
{
|
||||
return PhpMyAdmin\Template::get('database/designer/query_details')->render();
|
||||
}
|
||||
@ -6,6 +6,6 @@
|
||||
<label for="selected_page">
|
||||
<?= $operation == 'editPage' ? __("Page to open") : __("Page to delete"); ?>:
|
||||
</label>
|
||||
<?= PMA_getHtmlForPageSelector($cfgRelation, $db); ?>
|
||||
<?= PhpMyAdmin\Database\Designer::getHtmlForPageSelector($cfgRelation, $db); ?>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
@ -13,7 +13,7 @@ $choices = array(
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="operation" value="savePage" />
|
||||
<?= PMA_getHtmlForPageSelector($cfgRelation, $db); ?>
|
||||
<?= PhpMyAdmin\Database\Designer::getHtmlForPageSelector($cfgRelation, $db); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<select name="selected_page" id="selected_page">
|
||||
<option value="0">-- <?= __('Select page'); ?> --</option>
|
||||
<?php if ($cfgRelation['pdfwork']) : $pages = PMA_getPageIdsAndNames($db); ?>
|
||||
<?php if ($cfgRelation['pdfwork']) : $pages = PhpMyAdmin\Database\Designer::getPageIdsAndNames($db); ?>
|
||||
<?php foreach ($pages as $nr => $desc) : ?>
|
||||
<option value="<?= $nr; ?>">
|
||||
<?= htmlspecialchars($desc); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</select>
|
||||
|
||||
@ -1,22 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for libraries/db_designer.lib.php
|
||||
* Tests for PhpMyAdmin\Database\Designer
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
namespace PhpMyAdmin\Tests\Database;
|
||||
|
||||
use PhpMyAdmin\Database\Designer;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/db_designer.lib.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/plugin_interface.lib.php';
|
||||
|
||||
/**
|
||||
* Tests for libraries/db_designer.lib.php
|
||||
* Tests for PhpMyAdmin\Database\Designer
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
class DesignerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
@ -65,7 +69,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
"SELECT `page_nr`, `page_descr` FROM `pmadb`.`pdf_pages`"
|
||||
. " WHERE db_name = '" . $db . "' ORDER BY `page_descr`",
|
||||
2,
|
||||
PhpMyAdmin\DatabaseInterface::QUERY_STORE,
|
||||
DatabaseInterface::QUERY_STORE,
|
||||
false
|
||||
)
|
||||
->will($this->returnValue('dummyRS'));
|
||||
@ -86,7 +90,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getPageIdsAndNames()
|
||||
* Test for Designer::getPageIdsAndNames()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -95,7 +99,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
$db = 'db';
|
||||
$this->_mockDatabaseInteraction($db);
|
||||
|
||||
$result = PMA_getPageIdsAndNames($db);
|
||||
$result = Designer::getPageIdsAndNames($db);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
@ -107,7 +111,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForEditOrDeletePages()
|
||||
* Test for Designer::getHtmlForEditOrDeletePages()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -117,7 +121,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
$operation = 'edit';
|
||||
$this->_mockDatabaseInteraction($db);
|
||||
|
||||
$result = PMA_getHtmlForEditOrDeletePages($db, $operation);
|
||||
$result = Designer::getHtmlForEditOrDeletePages($db, $operation);
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="operation" value="' . $operation . '" />',
|
||||
$result
|
||||
@ -134,7 +138,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForPageSaveAs()
|
||||
* Test for Designer::getHtmlForPageSaveAs()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -143,7 +147,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
$db = 'db';
|
||||
$this->_mockDatabaseInteraction($db);
|
||||
|
||||
$result = PMA_getHtmlForPageSaveAs($db);
|
||||
$result = Designer::getHtmlForPageSaveAs($db);
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="operation" value="savePage" />',
|
||||
$result
|
||||
@ -174,7 +178,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForSchemaExport()
|
||||
* Test for Designer::getHtmlForSchemaExport()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -183,7 +187,7 @@ class PMA_DesignerTest extends PHPUnit_Framework_TestCase
|
||||
$db = 'db';
|
||||
$page = 2;
|
||||
|
||||
$result = PMA_getHtmlForSchemaExport($db, $page);
|
||||
$result = Designer::getHtmlForSchemaExport($db, $page);
|
||||
// export type
|
||||
$this->assertContains(
|
||||
'<select id="plugins" name="export_type">',
|
||||
Loading…
Reference in New Issue
Block a user