diff --git a/config.sample.inc.php b/config.sample.inc.php index 4dc9a53c31..8e87694629 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -62,6 +62,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; +// $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; /* Contrib / Swekey authentication */ // $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf'; diff --git a/db_designer.php b/db_designer.php index 58217e5cd4..f8917608db 100644 --- a/db_designer.php +++ b/db_designer.php @@ -80,7 +80,30 @@ if (isset($_REQUEST['operation'])) { ); $response->isSuccess($success); $response->addJSON('message', $message); + } elseif ($_REQUEST['operation'] == 'save_setting_value') { + $cfgRelation = PMA_getRelationsParam(); + + $cfgDesigner = array( + 'user' => $GLOBALS['cfg']['Server']['user'], + 'db' => $cfgRelation['db'], + 'table' => $cfgRelation['designer_settings'] + ); + if (! empty($cfgDesigner['user']) + && ! empty($cfgDesigner['db']) + && ! empty($cfgDesigner['table']) + && $GLOBALS['cfgRelation']['designer_settingswork'] + ) { + $query = 'INSERT INTO ' . PMA_Util::backquote($cfgDesigner['db']) + . '.' . PMA_Util::backquote($cfgDesigner['table']) + . ' VALUES("' . $cfgDesigner['user'] . '", "' + . $_REQUEST['index'] . '", "' . $_REQUEST['value'] . '") ON DUPLICATE KEY ' + . 'UPDATE VALUE = "' . $_REQUEST['value'] . '";'; + + $success = $GLOBALS['dbi']->query($query); + $response->isSuccess($success); + } } + return; } @@ -89,6 +112,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(); $display_page = -1; $selected_page = null; @@ -137,9 +161,11 @@ $response->addHTML( ) ); $response->addHTML( - PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page) + PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page, $classes_side_menu) ); + + $response->addHTML('
'); $response->addHTML( '
' diff --git a/doc/config.rst b/doc/config.rst index deb9a449a2..3394fd4b27 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -782,6 +782,22 @@ Server connection settings * put the table name in :config:option:`$cfg['Servers'][$i]['central_columns']` (e.g. ``pma__central_columns``) +.. _designer_settings: +.. config:option:: $cfg['Servers'][$i]['designer_settings'] + + :type: string + :default: ``''`` + + Since release 4.5.0 your designer settings can be remembered. + Your choice regarding 'Angular/ Direct Links', 'Snap to Grid', 'Toggle Relation Lines', + 'Small/ Big all', 'Move menu' and 'Pin text' can be remembered persistently. + + To allow the usage of this functionality: + + * set up :config:option:`$cfg['Servers'][$i]['pmadb']` and the phpMyAdmin configuration storage + * put the table name in :config:option:`$cfg['Servers'][$i]['designer_settings']` (e.g. + ``pma__designer_settings``) + .. _savedsearches: .. config:option:: $cfg['Servers'][$i]['savedsearches'] diff --git a/examples/config.manyhosts.inc.php b/examples/config.manyhosts.inc.php index 751bd5b587..9c8c79b4b1 100644 --- a/examples/config.manyhosts.inc.php +++ b/examples/config.manyhosts.inc.php @@ -48,4 +48,5 @@ foreach ($hosts as $host) { $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; + $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; } diff --git a/js/pmd/move.js b/js/pmd/move.js index 77a8f28ab2..e2844f037b 100644 --- a/js/pmd/move.js +++ b/js/pmd/move.js @@ -249,6 +249,49 @@ function Osn_tab_pos() osn_tab_height = parseInt(document.getElementById('osn_tab').style.height, 10); } +function setDefaultValuesFromSavedState() +{ + if ($('#angular_direct_button').attr('class') === 'M_butt') { + ON_angular_direct = 0; + } else { + ON_angular_direct = 1; + } + Angular_direct(); + + if ($('#grid_button').attr('class') === 'M_butt') { + ON_grid = 1; + } else { + ON_grid = 0; + } + Grid(); + + if ($('#relLineInvert').attr('class') === 'M_butt') { + show_relation_lines = false; + $('#relLineInvert').attr('class', 'M_butt'); + } else { + show_relation_lines = true; + $('#relLineInvert').attr('class', 'M_butt_Selected_down'); + } + Relation_lines_invert(); + + if ($('#pin_Text').attr('class') === 'M_butt_Selected_down') { + always_show_text = true; + Show_text(); + } else { + always_show_text = false; + } + + if ($('#key_SB_all').attr('class') === 'M_butt_Selected_down') { + $('#key_SB_all').click(); + $('#key_SB_all').toggleClass('M_butt_Selected_down'); + $('#key_SB_all').toggleClass('M_butt'); + } + + if ($('#key_Left_Right').attr('class') === 'M_butt_Selected_down') { + $('#key_Left_Right').click(); + } + +} function Main() { @@ -262,6 +305,7 @@ function Main() Canvas_pos(); Small_tab_refresh(); Re_load(); + setDefaultValuesFromSavedState(); id_hint = document.getElementById('pmd_hint'); if (isIE) { General_scroll(); @@ -538,6 +582,7 @@ function Rect(x1, y1, w, h, color) //--------------------------- FULLSCREEN ------------------------------------- function Toggle_fullscreen() { + var value_sent = ''; var $img = $('#toggleFullscreen img'); var $span = $img.siblings('span'); if (! $.FullScreen.isFullScreen()) { @@ -548,10 +593,13 @@ function Toggle_fullscreen() .addClass('content_fullscreen') .css({'width': screen.width - 5, 'height': screen.height - 5}) .requestFullScreen(); + value_sent = 'on'; } if ($.FullScreen.isFullScreen()) { $.FullScreen.cancelFullScreen(); + value_sent = 'off'; } + saveValueInConfig('full_screen', value_sent); } // ------------------------------ NEW ------------------------------------------ @@ -1040,24 +1088,42 @@ function Grid() { if (!ON_grid) { ON_grid = 1; + value_sent = 'on'; document.getElementById('grid_button').className = 'M_butt_Selected_down'; } else { document.getElementById('grid_button').className = 'M_butt'; ON_grid = 0; + value_sent = 'off'; } + saveValueInConfig('snap_to_grid', value_sent); } function Angular_direct() { + var value_sent = ''; if (ON_angular_direct) { ON_angular_direct = 0; + value_sent = 'angular'; document.getElementById('angular_direct_button').className = 'M_butt_Selected_down'; } else { ON_angular_direct = 1; + value_sent = 'direct'; document.getElementById('angular_direct_button').className = 'M_butt'; } + saveValueInConfig('angular_direct', value_sent); Re_load(); } + +function saveValueInConfig(index_sent, value_sent) { + $.post('db_designer.php', + {operation: 'save_setting_value', index: index_sent, ajax_request: true, server: server, token: token, value: value_sent}, + function (data) { + if (data.success === false) { + PMA_ajaxShowMessage(data.error, false); + } + }); +} + //++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++ function Start_relation() { @@ -1186,6 +1252,7 @@ function Small_tab_all(id_this) // max/min all tables { var icon = id_this.childNodes[0]; var key; + var value_sent = ''; if (icon.alt == "v") { for (key in j_tabs) { if (document.getElementById('id_hide_tbody_' + key).innerHTML == "v") { @@ -1194,6 +1261,7 @@ function Small_tab_all(id_this) // max/min all tables } icon.alt = ">"; icon.src = icon.dataset.right; + value_sent = 'v'; } else { for (key in j_tabs) { if (document.getElementById('id_hide_tbody_' + key).innerHTML != "v") { @@ -1202,7 +1270,11 @@ function Small_tab_all(id_this) // max/min all tables } icon.alt = "v"; icon.src = icon.dataset.down; + value_sent = '>'; } + saveValueInConfig('small_big_all', value_sent); + $('#key_SB_all').toggleClass('M_butt_Selected_down'); + $('#key_SB_all').toggleClass('M_butt'); Re_load(); } @@ -1217,6 +1289,9 @@ function Small_tab_invert() // invert max/min all tables function Relation_lines_invert() { show_relation_lines = ! show_relation_lines; + saveValueInConfig('relation_lines', show_relation_lines); + $('#relLineInvert').toggleClass('M_butt_Selected_down'); + $('#relLineInvert').toggleClass('M_butt'); Re_load(); } @@ -1545,6 +1620,9 @@ function Side_menu_right(id_this) icon.attr('src', icon.attr('data-right')); icon.attr('data-right', current); menu_moved = !menu_moved; + saveValueInConfig('side_menu', $('#side_menu').hasClass('right')); + $('#key_Left_Right').toggleClass('M_butt_Selected_down'); + $('#key_Left_Right').toggleClass('M_butt'); } //------------------------------------------------------------------------------ function Show_text () { @@ -1558,6 +1636,8 @@ function Hide_text () { function Pin_text () { always_show_text = !always_show_text; $('#pin_Text').toggleClass('M_butt_Selected_down'); + $('#pin_Text').toggleClass('M_butt'); + saveValueInConfig('pin_text', always_show_text); } //------------------------------------------------------------------------------ function Start_display_field() diff --git a/libraries/config.default.php b/libraries/config.default.php index a22ac96022..8aebb25197 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -481,6 +481,15 @@ $cfg['Servers'][$i]['savedsearches'] = ''; */ $cfg['Servers'][$i]['central_columns'] = ''; +/** + * table to store designer settings + * - leave blank to disable the storage of designer settings + * SUGGESTED: 'pma__designer_settings' + * + * @global string $cfg['Servers'][$i]['designer_settings'] + */ +$cfg['Servers'][$i]['designer_settings'] = ''; + /** * Maximum number of records saved in $cfg['Servers'][$i]['table_uiprefs'] table. * diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 35a43448a2..af54ad52a3 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -83,6 +83,7 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array( 'pdf_pages' => 'pma__pdf_pages', 'savedsearches' => 'pma__savedsearches', 'central_columns' => 'pma__central_columns', + 'designer_settings' => 'pma__designer_settings', 'MaxTableUiprefs' => 100))); $forms['Servers']['Server_tracking'] = array('Servers' => array(1 => array( 'tracking_version_auto_create', diff --git a/libraries/db_designer.lib.php b/libraries/db_designer.lib.php index 9869f954f3..452bda2b32 100644 --- a/libraries/db_designer.lib.php +++ b/libraries/db_designer.lib.php @@ -156,20 +156,155 @@ function PMA_getHtmlForJSFields( * * @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) +function PMA_getDesignerPageMenu($visualBuilder, $selected_page, $params_array) { return PMA\Template::get('designer/side_menu') ->render( array( 'visualBuilder' => $visualBuilder, - 'selected_page' => $selected_page + '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 = PMA_getRelationsParam(); + + if ($GLOBALS['cfgRelation']['designer_settingswork']) { + // angular_direct + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "angular_direct"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['angular_direct'] = $result['value']; + + // snap_to_grid + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "snap_to_grid"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['snap_to_grid'] = $result['value']; + + // small_big_all + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "small_big_all"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['small_big_all'] = $result['value']; + + // relation_lines + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "relation_lines"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['relation_lines'] = $result['value']; + + // full_screen + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "full_screen"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['full_screen'] = $result['value']; + + // side_menu + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "side_menu"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['side_menu'] = $result['value']; + + // pin_text + $query = 'SELECT `value` FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' + . PMA_Util::backquote($cfgRelation['designer_settings']) . ' WHERE ' . PMA_Util::backquote('user') . ' = "' + . $GLOBALS['cfg']['Server']['user'] . '" AND ' . PMA_Util::backquote('index') . ' = "pin_text"'; + + $result = $GLOBALS['dbi']->fetchSingleRow($query); + $params['pin_text'] = $result['value']; + } + + 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 * diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 206655fba9..c483dd5317 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -314,6 +314,17 @@ function PMA_getRelationsParamDiagnostic($cfgRelation) 'central_columnswork', $messages ); + $retval .= PMA_getDiagMessageForParameter( + 'designer_settings', + isset($cfgRelation['designer_settings']), + $messages, + 'designer_settings' + ); + $retval .= PMA_getDiagMessageForFeature( + __('Remembering Designer Settings'), + 'designer_settingswork', + $messages + ); $retval .= '' . "\n"; if (! $cfgRelation['allworks']) { @@ -440,6 +451,7 @@ function PMA_checkRelationsParam() $cfgRelation['allworks'] = false; $cfgRelation['savedsearcheswork'] = false; $cfgRelation['central_columnswork'] = false; + $cfgRelation['designer_settingswork'] = false; $cfgRelation['user'] = null; $cfgRelation['db'] = null; @@ -513,6 +525,8 @@ function PMA_checkRelationsParam() $cfgRelation['savedsearches'] = $curr_table[0]; } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['central_columns']) { $cfgRelation['central_columns'] = $curr_table[0]; + } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['designer_settings']) { + $cfgRelation['designer_settings'] = $curr_table[0]; } } // end while $GLOBALS['dbi']->freeResult($tab_rs); @@ -579,6 +593,10 @@ function PMA_checkRelationsParam() $cfgRelation['central_columnswork'] = true; } + if (isset($cfgRelation['designer_settings'])) { + $cfgRelation['designer_settingswork'] = true; + } + if ($cfgRelation['relwork'] && $cfgRelation['displaywork'] && $cfgRelation['pdfwork'] && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfgRelation['historywork'] @@ -587,6 +605,7 @@ function PMA_checkRelationsParam() && $cfgRelation['bookmarkwork'] && $cfgRelation['central_columnswork'] && $cfgRelation['menuswork'] && $cfgRelation['navwork'] && $cfgRelation['savedsearcheswork'] && $cfgRelation['favoritework'] + && $cfgRelation['designer_settingswork'] ) { $cfgRelation['allworks'] = true; } @@ -1801,7 +1820,8 @@ function PMA_fixPMATables($db, $create = true) 'pma__usergroups' => 'usergroups', 'pma__navigationhiding' => 'navigationhiding', 'pma__savedsearches' => 'savedsearches', - 'pma__central_columns' => 'central_columns' + 'pma__central_columns' => 'central_columns', + 'pma__designer_settings' => 'designer_settings' ); $existingTables = $GLOBALS['dbi']->getTables($db, $GLOBALS['controllink']); diff --git a/sql/create_tables.sql b/sql/create_tables.sql index e11bf019b6..e8d39edd89 100644 --- a/sql/create_tables.sql +++ b/sql/create_tables.sql @@ -321,3 +321,18 @@ CREATE TABLE IF NOT EXISTS `pma__central_columns` ( ) COMMENT='Central list of columns' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `pma__designer_settings` +-- + +CREATE TABLE IF NOT EXISTS `pma__designer_settings` ( + `user` varchar(64) NOT NULL, + `index` varchar(64) NOT NULL, + `value` varchar(64) NOT NULL, + PRIMARY KEY (`user`,`index`) +) + COMMENT='Settings related to Designer' + DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; diff --git a/sql/create_tables_drizzle.sql b/sql/create_tables_drizzle.sql index 4bce72f2d8..e80b8b72e6 100644 --- a/sql/create_tables_drizzle.sql +++ b/sql/create_tables_drizzle.sql @@ -273,3 +273,18 @@ CREATE TABLE IF NOT EXISTS `pma__savedsearches` ( ) COMMENT='Saved searches' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `pma__designer_settings` +-- + +CREATE TABLE IF NOT EXISTS `pma__designer_settings` ( + `user` varchar(64) NOT NULL, + `index` varchar(64) NOT NULL, + `value` varchar(64) NOT NULL, + PRIMARY KEY (`user`,`index`) +) + COMMENT='Settings related to Designer' + DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; diff --git a/templates/designer/side_menu.phtml b/templates/designer/side_menu.phtml index dee4508aa9..80bed0bdf5 100755 --- a/templates/designer/side_menu.phtml +++ b/templates/designer/side_menu.phtml @@ -111,20 +111,20 @@ function getImg($path) - + / - + - + v - + @@ -169,7 +169,7 @@ function getImg($path) - + > @@ -177,7 +177,7 @@ function getImg($path) - + >redefineRelation(); }