diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index c6a35c4cf4..6594a727b9 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -32,13 +32,13 @@ class Designer */ public static function getHtmlForEditOrDeletePages($db, $operation) { - return Template::get('database/designer/edit_delete_pages') - ->render( - array( - 'db' => $db, - 'operation' => $operation - ) - ); + $cfgRelation = Relation::getRelationsParam(); + return Template::get('database/designer/edit_delete_pages')->render([ + 'db' => $db, + 'operation' => $operation, + 'pdfwork' => $cfgRelation['pdfwork'], + 'pages' => self::getPageIdsAndNames($db), + ]); } /** @@ -50,12 +50,12 @@ class Designer */ public static function getHtmlForPageSaveAs($db) { - return Template::get('database/designer/page_save_as') - ->render( - array( - 'db' => $db - ) - ); + $cfgRelation = Relation::getRelationsParam(); + return Template::get('database/designer/page_save_as')->render([ + 'db' => $db, + 'pdfwork' => $cfgRelation['pdfwork'], + 'pages' => self::getPageIdsAndNames($db), + ]); } /** @@ -148,22 +148,20 @@ class Designer * 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 + * @param string $selectedPage name of the selected page + * @param array $paramsArray array with class name for various buttons + * on side menu * * @return string html */ - public static function getPageMenu($visualBuilder, $selected_page, array $params_array) + public static function getPageMenu($visualBuilder, $selectedPage, array $paramsArray) { - return Template::get('database/designer/side_menu') - ->render( - array( - 'visualBuilder' => $visualBuilder, - 'selected_page' => $selected_page, - 'params_array' => $params_array - ) - ); + return Template::get('database/designer/side_menu')->render([ + 'visual_builder' => $visualBuilder, + 'selected_page' => $selectedPage, + 'params_array' => $paramsArray, + 'theme' => $GLOBALS['PMA_Theme'], + ]); } /** @@ -274,13 +272,15 @@ class Designer */ public static function getHtmlTableList(array $tab_pos, $display_page) { - return Template::get('database/designer/table_list') - ->render( - array( - 'tab_pos' => $tab_pos, - 'display_page' => $display_page - ) - ); + return Template::get('database/designer/table_list')->render([ + 'tab_pos' => $tab_pos, + 'display_page' => $display_page, + 'theme' => $GLOBALS['PMA_Theme'], + 'table_names' => $GLOBALS['PMD']['TABLE_NAME'], + 'table_names_url' => $GLOBALS['PMD_URL']['TABLE_NAME'], + 'table_names_small_url' => $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'], + 'table_names_out' => $GLOBALS['PMD_OUT']['TABLE_NAME'], + ]); } /** @@ -295,18 +295,30 @@ class Designer * @return string html */ public static function getDatabaseTables( - array $tab_pos, $display_page, array $tab_column, array $tables_all_keys, array $tables_pk_or_unique_keys + array $tab_pos, + $display_page, + array $tab_column, + array $tables_all_keys, + array $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 - ) - ); + return Template::get('database/designer/database_tables')->render([ + 'db' => $GLOBALS['db'], + 'get_db' => $_GET['db'], + 'query' => $_REQUEST['query'], + '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, + 'table_names' => $GLOBALS['PMD']['TABLE_NAME'], + 'table_names_url' => $GLOBALS['PMD_URL']['TABLE_NAME'], + 'table_names_small' => $GLOBALS['PMD']['TABLE_NAME_SMALL'], + 'table_names_small_url' => $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'], + 'table_names_small_out' => $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'], + 'table_types' => $GLOBALS['PMD']['TABLE_TYPE'], + 'owner_out' => $GLOBALS['PMD_OUT']['OWNER'], + 'theme' => $GLOBALS['PMA_Theme'], + ]); } /** diff --git a/libraries/classes/Twig/PhpFunctionsExtension.php b/libraries/classes/Twig/PhpFunctionsExtension.php index 78c77ecd25..0fc41329d3 100644 --- a/libraries/classes/Twig/PhpFunctionsExtension.php +++ b/libraries/classes/Twig/PhpFunctionsExtension.php @@ -28,6 +28,7 @@ class PhpFunctionsExtension extends Twig_Extension new Twig_SimpleFunction('array_search', 'array_search'), new Twig_SimpleFunction('md5', 'md5'), new Twig_SimpleFunction('preg_replace', 'preg_replace'), + new Twig_SimpleFunction('strstr', 'strstr'), ); } } diff --git a/libraries/classes/Twig/RelationExtension.php b/libraries/classes/Twig/RelationExtension.php index fd4c78acdc..38861ac8bf 100644 --- a/libraries/classes/Twig/RelationExtension.php +++ b/libraries/classes/Twig/RelationExtension.php @@ -30,6 +30,11 @@ class RelationExtension extends Twig_Extension 'PhpMyAdmin\Relation::foreignDropdown', array('is_safe' => array('html')) ), + new Twig_SimpleFunction( + 'Relation_getDisplayField', + 'PhpMyAdmin\Relation::getDisplayField', + array('is_safe' => array('html')) + ), new Twig_SimpleFunction( 'Relation_getForeignData', 'PhpMyAdmin\Relation::getForeignData' diff --git a/libraries/classes/Twig/UtilExtension.php b/libraries/classes/Twig/UtilExtension.php index 843971d2b6..000cc703ce 100644 --- a/libraries/classes/Twig/UtilExtension.php +++ b/libraries/classes/Twig/UtilExtension.php @@ -60,6 +60,11 @@ class UtilExtension extends Twig_Extension 'PhpMyAdmin\Util::getDivForSliderEffect', array('is_safe' => array('html')) ), + new Twig_SimpleFunction( + 'Util_getDocuLink', + 'PhpMyAdmin\Util::getDocuLink', + array('is_safe' => array('html')) + ), new Twig_SimpleFunction( 'Util_getDropdown', 'PhpMyAdmin\Util::getDropdown', @@ -103,6 +108,10 @@ class UtilExtension extends Twig_Extension 'PhpMyAdmin\Util::getSupportedDatatypes', array('is_safe' => array('html')) ), + new Twig_SimpleFunction( + 'Util_isForeignKeySupported', + 'PhpMyAdmin\Util::isForeignKeySupported' + ), new Twig_SimpleFunction( 'Util_linkOrButton', 'PhpMyAdmin\Util::linkOrButton', diff --git a/templates/database/designer/database_tables.phtml b/templates/database/designer/database_tables.phtml deleted file mode 100644 index f7ff9f0d56..0000000000 --- a/templates/database/designer/database_tables.phtml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - px; top:px; display:; z-index: 1;"> - - - - - - - - - - - - - - "> - - ." - - click_field_param=""> - - - - - - - - - - -
- - - - "> - - - - - - - -
- " - type="checkbox" - id="select_._" - style="margin: 0;" - title="select_" - store_column_param=",,"> - "> -
- - * - - * - - -
-
- -
- diff --git a/templates/database/designer/database_tables.twig b/templates/database/designer/database_tables.twig new file mode 100644 index 0000000000..e29522abaa --- /dev/null +++ b/templates/database/designer/database_tables.twig @@ -0,0 +1,128 @@ +{% for i in 0..table_names|length - 1 %} + {% set t_n = table_names[i] %} + {% set t_n_url = table_names_url[i] %} + + + + + + + + {% if query is defined %} + + {% endif %} + + + + {% if query is defined %} + + {% endif %} + + + + {% set display_field = Relation_getDisplayField(get_db, table_names_small[i]) %} + {% for j in 0..tab_column[t_n]['COLUMN_ID']|length - 1 %} + {% set tmp_column = t_n ~ '.' ~ tab_column[t_n]['COLUMN_NAME'][j] %} + {% set click_field_param = [ + table_names_small_url[i], + tab_column[t_n]['COLUMN_NAME'][j]|url_encode + ] %} + {% if not Util_isForeignKeySupported(table_types[i]) %} + {% set click_field_param = click_field_param|merge([tables_pk_or_unique_keys[tmp_column] is defined ? 1 : 0]) %} + {% else %} + {# if foreign keys are supported, it's not necessary that the + index is a primary key #} + {% set click_field_param = click_field_param|merge([tables_all_keys[tmp_column] is defined ? 1 : 0]) %} + {% endif %} + {% set click_field_param = click_field_param|merge([db]) %} + + {% if query is defined %} + + {% endif %} + + {% if query is defined %} + + {% endif %} + + {% endfor %} + +
+ + + {{ tab_pos[t_n] is not defined or tab_pos[t_n]['V'] is not empty ? 'v' : '>' }} + + + + + {{ owner_out[i]|raw }} + + {{ table_names_small_out[i]|raw }} + +
+{% endfor %} diff --git a/templates/database/designer/edit_delete_pages.phtml b/templates/database/designer/edit_delete_pages.phtml deleted file mode 100644 index a8f8efd25a..0000000000 --- a/templates/database/designer/edit_delete_pages.phtml +++ /dev/null @@ -1,14 +0,0 @@ - -
- -
- - - render([ - 'pdfwork' => $cfgRelation['pdfwork'], - 'pages' => PhpMyAdmin\Database\Designer::getPageIdsAndNames($db), - ]); ?> -
-
diff --git a/templates/database/designer/edit_delete_pages.twig b/templates/database/designer/edit_delete_pages.twig new file mode 100644 index 0000000000..5efe362484 --- /dev/null +++ b/templates/database/designer/edit_delete_pages.twig @@ -0,0 +1,13 @@ +
+ {{ Url_getHiddenInputs(db) }} +
+ + + {% include 'database/designer/page_selector.twig' with { + 'pdfwork': pdfwork, + 'pages': pages + } only %} +
+
diff --git a/templates/database/designer/page_save_as.phtml b/templates/database/designer/page_save_as.phtml deleted file mode 100644 index b26be3a6d5..0000000000 --- a/templates/database/designer/page_save_as.phtml +++ /dev/null @@ -1,36 +0,0 @@ - __('Save to selected page'), - 'new' => __('Create a page and save to it') -); -?> -
- -
- - - - - - - - - - - - -
- - render([ - 'pdfwork' => $cfgRelation['pdfwork'], - 'pages' => PhpMyAdmin\Database\Designer::getPageIdsAndNames($db), - ]); ?> -
- -
- - -
-
-
diff --git a/templates/database/designer/page_save_as.twig b/templates/database/designer/page_save_as.twig new file mode 100644 index 0000000000..a3b6d63943 --- /dev/null +++ b/templates/database/designer/page_save_as.twig @@ -0,0 +1,37 @@ +
+ {{ Url_getHiddenInputs(db) }} +
+ + + + + + + + + + + + +
+ + {% include 'database/designer/page_selector.twig' with { + 'pdfwork': pdfwork, + 'pages': pages + } only %} +
+ {{ Util_getRadioFields( + 'save_page', + { + 'same': 'Save to selected page'|trans, + 'new': 'Create a page and save to it'|trans + }, + 'same', + true + ) }} +
+ + +
+
+
diff --git a/templates/database/designer/side_menu.phtml b/templates/database/designer/side_menu.phtml deleted file mode 100644 index d32d4b6f19..0000000000 --- a/templates/database/designer/side_menu.phtml +++ /dev/null @@ -1,195 +0,0 @@ -getImgPath($path); -} -?> - -
- - - - - - -
- -
- - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - > - - - - -
diff --git a/templates/database/designer/side_menu.twig b/templates/database/designer/side_menu.twig new file mode 100644 index 0000000000..ddcc158e47 --- /dev/null +++ b/templates/database/designer/side_menu.twig @@ -0,0 +1,189 @@ +{% if not visual_builder %} +
+ + {{ selected_page == null ? 'Untitled'|trans : selected_page }} + + + {{ selected_page == null ? '*' : '' }} + +
+{% endif %} +
+ + v + + {% trans 'Show/Hide tables list' %} + + + + + + {% trans 'View in fullscreen' %} + + + + + + {% trans 'Add tables from other databases' %} + + + {% if not visual_builder %} + + + + {% trans 'New page' %} + + + + + + {% trans 'Open page' %} + + + + + + {% trans 'Save page' %} + + + + + + {% trans 'Save page as' %} + + + + + + {% trans 'Delete pages' %} + + + + + + {% trans 'Create table' %} + + + + + + {% trans 'Create relationship' %} + + + + + + {% trans 'Choose column to display' %} + + + + + + {% trans 'Reload' %} + + + + + + {% trans 'Help' %} + + + {% endif %} + + + + {% trans 'Angular links' %} / {% trans 'Direct links' %} + + + + + + {% trans 'Snap to grid' %} + + + + v + + {% trans 'Small/Big All' %} + + + + + + {% trans 'Toggle small/big' %} + + + + + + {% trans 'Toggle relationship lines' %} + + + {% if not visual_builder %} + + + + {% trans 'Export schema' %} + + + {% else %} + + + + {% trans 'Build Query' %} + + + {% endif %} + + > + + {% trans 'Move Menu' %} + + + + > + + {% trans 'Pin text' %} + + +
diff --git a/templates/database/designer/table_list.phtml b/templates/database/designer/table_list.phtml deleted file mode 100644 index 2592ba2dd0..0000000000 --- a/templates/database/designer/table_list.phtml +++ /dev/null @@ -1,65 +0,0 @@ -
-
- - v - - - v - -
-
- - - - - - - - -
- - - " - style="margin:0;" - type="checkbox" - value="" - checked="checked" /> - - -
-
- -
- -
-
-
- -
-
-
- diff --git a/templates/database/designer/table_list.twig b/templates/database/designer/table_list.twig new file mode 100644 index 0000000000..17221a7fb0 --- /dev/null +++ b/templates/database/designer/table_list.twig @@ -0,0 +1,65 @@ +
+
+ + v + + + v + +
+
+ + {% for i in 0..table_names|length - 1 %} + + + + + + {% endfor %} +
+ + + + + {{ table_names_out[i]|raw }} +
+
+ {# end id_scroll_tab #} +
+ {% trans 'Number of tables:' %} {{ table_names|length }} +
+
+
+ +
+
+
+{# end layer_menu #}