From 18c23df20f2507a67131ee880bbc35ec29cfeec4 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Nov 2018 16:44:50 +0100 Subject: [PATCH] Issue #13032 - fix designer on QA_4_8 Used cherry-pick : Merge pull request #14376 from williamdes/issue-13032-designer Cherry-picked-from: cb2dae58be530cc8d3f64adfb8d871eff6b73fb3 Issue #13032 - fix designer Signed-off-by: William Desportes --- js/designer/init.js | 17 ++++---- libraries/classes/Database/Designer.php | 16 ++++---- .../classes/Database/Designer/Common.php | 37 ++++++++++------- .../database/designer/database_tables.twig | 40 +++++++++---------- templates/database/designer/js_fields.twig | 10 ++--- templates/database/designer/table_list.twig | 6 +-- 6 files changed, 66 insertions(+), 60 deletions(-) diff --git a/js/designer/init.js b/js/designer/init.js index 4292069c85..13ee6145a1 100644 --- a/js/designer/init.js +++ b/js/designer/init.js @@ -23,17 +23,16 @@ AJAX.registerOnload('designer/init.js', function () { $('#ab').accordion('refresh'); return false; }); - var tables_data = JSON.parse($('#script_tables').html()); - j_tabs = tables_data.j_tabs; - h_tabs = tables_data.h_tabs; - contr = JSON.parse($('#script_contr').html()); - display_field = JSON.parse($('#script_display_field').html()); + j_tabs = designer_config.scriptTables.j_tabs; + h_tabs = designer_config.scriptTables.h_tabs; + contr = designer_config.scriptContr; + display_field = designer_config.scriptDisplayField; - server = $('#script_server').html(); - db = $('#script_db').html(); - selected_page = $('#script_display_page').html() === '' ? '-1' : $('#script_display_page').html(); - designer_tables_enabled = $('#designer_tables_enabled').html() === '1'; + server = designer_config.server; + db = designer_config.db; + selected_page = designer_config.displayPage; + designer_tables_enabled = designer_config.tablesEnabled; Main(); diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index 185f35cc37..b013990fa2 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -151,14 +151,16 @@ class Designer $display_page ) { $cfgRelation = $this->relation->getRelationsParam(); + $designerConfig = new \stdClass(); + $designerConfig->db = $_GET['db']; + $designerConfig->scriptTables = $script_tables; + $designerConfig->scriptContr = $script_contr; + $designerConfig->server = $GLOBALS['server']; + $designerConfig->scriptDisplayField = $script_display_field; + $designerConfig->displayPage = $display_page; + $designerConfig->tablesEnabled = $cfgRelation['pdfwork']; return Template::get('database/designer/js_fields')->render([ - 'server' => $GLOBALS['server'], - 'db' => $_GET['db'], - 'script_tables' => json_encode($script_tables), - 'script_contr' => json_encode($script_contr), - 'script_display_field' => json_encode($script_display_field), - 'display_page' => $display_page, - 'relation_pdfwork' => $cfgRelation['pdfwork'], + 'designer_config' => json_encode($designerConfig) ]); } diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 70ecaed7f8..562d35d1df 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -45,7 +45,15 @@ class Common $GLOBALS['designer']['TABLE_NAME'] = array();// that foreach no error $GLOBALS['designer']['OWNER'] = array(); $GLOBALS['designer']['TABLE_NAME_SMALL'] = array(); + $GLOBALS['designer']['TABLE_TYPE'] = array(); + $GLOBALS['designer_url']['TABLE_NAME'] = array(); + $GLOBALS['designer_url']['OWNER'] = array(); + $GLOBALS['designer_url']['TABLE_NAME_SMALL'] = array(); + + $GLOBALS['designer_out']['TABLE_NAME'] = array(); + $GLOBALS['designer_out']['OWNER'] = array(); + $GLOBALS['designer_out']['TABLE_NAME_SMALL'] = array(); $tables = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']); // seems to be needed later $GLOBALS['dbi']->selectDb($GLOBALS['db']); @@ -80,7 +88,8 @@ class Common $DF = $this->relation->getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']); if ($DF != '') { - $retval[$GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i]] = $DF; + $DF = rawurlencode((string)$DF); + $retval[rawurlencode($GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i])] = $DF; } $i++; @@ -144,12 +153,12 @@ class Common if ($row !== false) { foreach ($row as $field => $value) { $con['C_NAME'][$i] = ''; - $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]); - $con['DCN'][$i] = urlencode($field); - $con['STN'][$i] = urlencode( + $con['DTN'][$i] = rawurlencode($GLOBALS['db'] . "." . $val[0]); + $con['DCN'][$i] = rawurlencode($field); + $con['STN'][$i] = rawurlencode( $value['foreign_db'] . "." . $value['foreign_table'] ); - $con['SCN'][$i] = urlencode($value['foreign_field']); + $con['SCN'][$i] = rawurlencode($value['foreign_field']); $i++; } } @@ -158,15 +167,15 @@ class Common if ($row !== false) { foreach ($row['foreign_keys_data'] as $one_key) { foreach ($one_key['index_list'] as $index => $one_field) { - $con['C_NAME'][$i] = $one_key['constraint']; - $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]); - $con['DCN'][$i] = urlencode($one_field); - $con['STN'][$i] = urlencode( + $con['C_NAME'][$i] = rawurlencode($one_key['constraint']); + $con['DTN'][$i] = rawurlencode($GLOBALS['db'] . "." . $val[0]); + $con['DCN'][$i] = rawurlencode($one_field); + $con['STN'][$i] = rawurlencode( (isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $GLOBALS['db']) . "." . $one_key['ref_table_name'] ); - $con['SCN'][$i] = urlencode($one_key['ref_index_list'][$index]); + $con['SCN'][$i] = rawurlencode($one_key['ref_index_list'][$index]); $i++; } } @@ -180,8 +189,8 @@ class Common $dtn_i = $con['DTN'][$i]; $retval[$ti] = array(); $retval[$ti][$c_name_i] = array(); - if (in_array($dtn_i, $GLOBALS['designer_url']["TABLE_NAME"]) - && in_array($con['STN'][$i], $GLOBALS['designer_url']["TABLE_NAME"]) + if (in_array(rawurldecode($dtn_i), $GLOBALS['designer_url']["TABLE_NAME"]) + && in_array(rawurldecode($con['STN'][$i]), $GLOBALS['designer_url']["TABLE_NAME"]) ) { $retval[$ti][$c_name_i][$dtn_i] = array(); $retval[$ti][$c_name_i][$dtn_i][$con['DCN'][$i]] = array( @@ -248,8 +257,8 @@ class Common if (Util::isForeignKeySupported($GLOBALS['designer']['TABLE_TYPE'][$i])) { $j = 1; } - $retval['j_tabs'][$GLOBALS['designer_url']['TABLE_NAME'][$i]] = $j; - $retval['h_tabs'][$GLOBALS['designer_url']['TABLE_NAME'][$i]] = 1; + $retval['j_tabs'][\rawurlencode($GLOBALS['designer_url']['TABLE_NAME'][$i])] = $j; + $retval['h_tabs'][\rawurlencode($GLOBALS['designer_url']['TABLE_NAME'][$i])] = 1; } return $retval; } diff --git a/templates/database/designer/database_tables.twig b/templates/database/designer/database_tables.twig index ba00b3a786..64a63a8058 100644 --- a/templates/database/designer/database_tables.twig +++ b/templates/database/designer/database_tables.twig @@ -1,11 +1,11 @@ -{% for i in 0..table_names|length - 1 %} - {% set t_n = table_names[i] %} +{% for t_n in table_names %} + {% set i = loop.index0 %} {% set t_n_url = table_names_url[i] %} - - - - - + + + +
{% endif %} - {% if has_query %} {% endif %} - {% set display_field = Relation_getDisplayField(get_db, table_names_small[i]) %} {% for j in 0..tab_column[t_n]['COLUMN_ID']|length - 1 %} @@ -78,9 +78,9 @@ {% if has_query %} {% endif %} -
+ id="id_hide_tbody_{{ t_n_url|url_encode }}" + table_name="{{ t_n_url|url_encode }}"> {{ tab_pos[t_n] is not defined or tab_pos[t_n]['V'] is not empty ? 'v' : '>' }} {{ owner_out[i]|raw }} @@ -49,13 +49,13 @@ + id="id_zag_{{ t_n_url|url_encode }}_2" + table_name="{{ t_n_url|url_encode }}">