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 @@ - - - - - - -
| - - | - -- = (! isset($tab_pos[$t_n]) || ! empty($tab_pos[$t_n]["V"])) ? 'v' : '>'; ?> - | -">
-
- |
- - - = $GLOBALS['PMD_OUT']["OWNER"][$i]; ?> - - = $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i]; ?> - | - -- | - -
| - " - type="checkbox" - id="select_= htmlspecialchars($t_n_url); ?>._= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>" - style="margin: 0;" - title="select_= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>" - store_column_param="= urlencode($GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i]); ?>,= htmlspecialchars($GLOBALS['PMD_OUT']["OWNER"][$i]); ?>,= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>"> - | - -">
-
-
-
-
-
-
-
- = htmlspecialchars(
- $tab_column[$t_n]["COLUMN_NAME"][$j] . " : "
- . $tab_column[$t_n]["TYPE"][$j],
- ENT_QUOTES
- ); ?>
- |
-
-
-
- |
-
- ||
| + + | + {% endif %} ++ {{ 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 }} + | + {% if query is defined %} ++ | + {% endif %} +
| + + | + {% endif %} +
+
+ {% if tables_pk_or_unique_keys[t_n ~ '.' ~ tab_column[t_n]['COLUMN_NAME'][j]] is defined %}
+
+
+ {% else %}
+ {% set type = 'pmd/Field_small' %}
+ {% if strstr(tab_column[t_n]['TYPE'][j], 'char')
+ or strstr(tab_column[t_n]['TYPE'][j], 'text') %}
+ {% set type = type ~ '_char' %}
+ {% elseif strstr(tab_column[t_n]['TYPE'][j], 'int')
+ or strstr(tab_column[t_n]['TYPE'][j], 'float')
+ or strstr(tab_column[t_n]['TYPE'][j], 'double')
+ or strstr(tab_column[t_n]['TYPE'][j], 'decimal') %}
+ {% set type = type ~ '_int' %}
+ {% elseif strstr(tab_column[t_n]['TYPE'][j], 'date')
+ or strstr(tab_column[t_n]['TYPE'][j], 'time')
+ or strstr(tab_column[t_n]['TYPE'][j], 'year') %}
+ {% set type = type ~ '_date' %}
+ {% endif %}
+
+ {% endif %}
+ {{ tab_column[t_n]['COLUMN_NAME'][j] }} : {{ tab_column[t_n]['TYPE'][j] }}
+ |
+ {% if query is defined %}
+
+
+ |
+ {% endif %}
+ ||