From 79319a60fcf3cae9eafdcc34b36cc1ef50772c7d Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 31 May 2015 03:23:26 +0800 Subject: [PATCH] Templates for table related scripts Signed-off-by: Jason --- libraries/TableSearch.class.php | 886 ++---------------- libraries/normalization.lib.php | 10 +- libraries/tbl_columns_definition_form.lib.php | 598 +++--------- libraries/tbl_gis_visualization.lib.php | 152 +-- libraries/tbl_indexes.lib.php | 221 +---- libraries/tbl_printview.lib.php | 498 +++------- libraries/tbl_relation.lib.php | 434 +-------- .../column_adjust_privileges.phtml | 6 + .../column_attribute.phtml | 12 + .../column_auto_increment.phtml | 8 + .../columns_definitions/column_comment.phtml | 10 + .../columns_definitions/column_default.phtml | 27 + .../column_definitions_form.phtml | 167 ++++ .../columns_definitions/column_extra.phtml | 7 + .../columns_definitions/column_indexes.phtml | 27 + .../columns_definitions/column_length.phtml | 11 + .../columns_definitions/column_null.phtml | 8 + .../columns_definitions/column_type.phtml | 7 + templates/columns_definitions/mime_type.phtml | 17 + .../columns_definitions/move_column.phtml | 15 + .../table_fields_definitions.phtml | 21 + .../columns_definitions/transformation.phtml | 26 + .../transformation_option.phtml | 6 + .../gis_visualization/gis_visualization.phtml | 84 ++ templates/index_form.phtml | 240 +++++ templates/printview/columns.phtml | 91 ++ templates/printview/footer.phtml | 2 + templates/printview/row_statistics.phtml | 92 ++ templates/printview/space_usage.phtml | 42 + .../space_usage_and_row_statistics.phtml | 26 + templates/printview/tables_detail.phtml | 20 + templates/printview/tables_info.phtml | 15 + templates/printview/tables_structure.phtml | 33 + .../table/column_comparison_operators.phtml | 7 + templates/table/fields_table.phtml | 24 + templates/table/form_tag.phtml | 22 + templates/table/geom_func.phtml | 39 + templates/table/input_box.phtml | 135 +++ templates/table/options.phtml | 73 ++ templates/table/options_zoom.phtml | 48 + templates/table/replace_preview.phtml | 42 + templates/table/rows_normal.phtml | 51 + templates/table/rows_zoom.phtml | 88 ++ templates/table/search_and_replace.phtml | 26 + templates/table/secondary_tabs.phtml | 6 + templates/table/selection_form.phtml | 78 ++ templates/table/table_header.phtml | 12 + templates/table/zoom_result_form.phtml | 100 ++ templates/tbl_chart.phtml | 7 +- templates/tbl_relation/common_form.phtml | 98 ++ .../tbl_relation/dropdown_generate.phtml | 12 + templates/tbl_relation/foreign_key_row.phtml | 115 +++ .../internal_relational_row.phtml | 16 + .../tbl_relation/relational_dropdown.phtml | 18 + test/classes/PMA_TableReplaceSearch_test.php | 21 +- test/classes/PMA_TableSearch_test.php | 12 +- .../PMA_tbl_columns_definition_form_test.php | 621 +++++------- .../PMA_tbl_gis_visualization_test.php | 84 +- test/libraries/PMA_tbl_indexes_test.php | 3 +- test/libraries/PMA_tbl_relation_test.php | 100 +- 60 files changed, 2712 insertions(+), 2965 deletions(-) create mode 100644 templates/columns_definitions/column_adjust_privileges.phtml create mode 100644 templates/columns_definitions/column_attribute.phtml create mode 100644 templates/columns_definitions/column_auto_increment.phtml create mode 100644 templates/columns_definitions/column_comment.phtml create mode 100644 templates/columns_definitions/column_default.phtml create mode 100644 templates/columns_definitions/column_definitions_form.phtml create mode 100644 templates/columns_definitions/column_extra.phtml create mode 100644 templates/columns_definitions/column_indexes.phtml create mode 100644 templates/columns_definitions/column_length.phtml create mode 100644 templates/columns_definitions/column_null.phtml create mode 100644 templates/columns_definitions/column_type.phtml create mode 100644 templates/columns_definitions/mime_type.phtml create mode 100644 templates/columns_definitions/move_column.phtml create mode 100644 templates/columns_definitions/table_fields_definitions.phtml create mode 100644 templates/columns_definitions/transformation.phtml create mode 100644 templates/columns_definitions/transformation_option.phtml create mode 100644 templates/gis_visualization/gis_visualization.phtml create mode 100644 templates/index_form.phtml create mode 100644 templates/printview/columns.phtml create mode 100644 templates/printview/footer.phtml create mode 100644 templates/printview/row_statistics.phtml create mode 100644 templates/printview/space_usage.phtml create mode 100644 templates/printview/space_usage_and_row_statistics.phtml create mode 100644 templates/printview/tables_detail.phtml create mode 100644 templates/printview/tables_info.phtml create mode 100644 templates/printview/tables_structure.phtml create mode 100644 templates/table/column_comparison_operators.phtml create mode 100644 templates/table/fields_table.phtml create mode 100644 templates/table/form_tag.phtml create mode 100644 templates/table/geom_func.phtml create mode 100644 templates/table/input_box.phtml create mode 100644 templates/table/options.phtml create mode 100644 templates/table/options_zoom.phtml create mode 100644 templates/table/replace_preview.phtml create mode 100644 templates/table/rows_normal.phtml create mode 100644 templates/table/rows_zoom.phtml create mode 100644 templates/table/search_and_replace.phtml create mode 100644 templates/table/secondary_tabs.phtml create mode 100644 templates/table/selection_form.phtml create mode 100644 templates/table/table_header.phtml create mode 100644 templates/table/zoom_result_form.phtml create mode 100644 templates/tbl_relation/common_form.phtml create mode 100644 templates/tbl_relation/dropdown_generate.phtml create mode 100644 templates/tbl_relation/foreign_key_row.phtml create mode 100644 templates/tbl_relation/internal_relational_row.phtml create mode 100644 templates/tbl_relation/relational_dropdown.phtml diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php index 30e9bdecdc..51049d2325 100644 --- a/libraries/TableSearch.class.php +++ b/libraries/TableSearch.class.php @@ -9,6 +9,8 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/Template.class.php'; + /** * Class to handle normal-search * and zoom-search in a table @@ -168,29 +170,6 @@ class PMA_TableSearch $this->_foreigners = PMA_getForeigners($this->_db, $this->_table); } - /** - * Sets the table header for displaying a table in query-by-example format. - * - * @return string HTML content, the tags and content for table header - */ - private function _getTableHeader() - { - // Display the Function column only if there is at least one geometry column - $func = ''; - if ($this->_geomColumnFlag) { - $func = '' . __('Function') . ''; - } - - return ' - ' . $func . '' . __('Column') . ' - ' . __('Type') . ' - ' . __('Collation') . ' - ' . __('Operator') . ' - ' . __('Value') . ' - - '; - } - /** * Returns an array with necessary configurations to create * sub-tabs in the table_select page. @@ -220,141 +199,6 @@ class PMA_TableSearch return $subtabs; } - /** - * Provides html elements for search criteria inputbox - * in case the column's type is geometrical - * - * @param int $column_index Column's index - * @param bool $in_fbs Whether we are in 'function based search' - * - * @return string HTML elements. - */ - private function _getGeometricalInputBox($column_index, $in_fbs) - { - $html_output = ''; - - if ($in_fbs) { - $edit_url = 'gis_data_editor.php' . PMA_URL_getCommon(); - $edit_str = PMA_Util::getIcon('b_edit.png', __('Edit/Insert')); - $html_output .= ''; - $html_output .= PMA_Util::linkOrButton( - $edit_url, $edit_str, array(), false, false, '_blank' - ); - $html_output .= ''; - } - return $html_output; - } - - /** - * Provides html elements for search criteria inputbox - * in case the column is a Foreign Key - * - * @param array $foreignData Foreign keys data - * @param string $column_name Column name - * @param int $column_index Column index - * @param array $titles Selected title - * @param int $foreignMaxLimit Max limit of displaying foreign elements - * @param array $criteriaValues Array of search criteria inputs - * @param string $column_id Column's inputbox's id - * - * @return string HTML elements. - */ - private function _getForeignKeyInputBox($foreignData, $column_name, - $column_index, $titles, $foreignMaxLimit, $criteriaValues, $column_id - ) { - $html_output = ''; - if (is_array($foreignData['disp_row'])) { - $html_output .= ''; - - } elseif ($foreignData['foreign_link'] == true) { - $html_output .= ''; - - $html_output .= ''; - } - return $html_output; - } - - /** - * Provides html elements for search criteria inputbox - * in case the column is of ENUM or SET type - * - * @param int $column_index Column index - * @param array $criteriaValues Array of search criteria inputs - * @param string $column_type Column type - * @param string $column_id Column's inputbox's id - * @param bool $in_zoom_search_edit Whether we are in zoom search edit - * - * @return string HTML elements. - */ - private function _getEnumSetInputBox($column_index, $criteriaValues, - $column_type, $column_id, $in_zoom_search_edit = false - ) { - $column_type = htmlspecialchars($column_type); - $html_output = ''; - $value = explode( - ', ', - str_replace("'", '', /*overload*/mb_substr($column_type, 5, -1)) - ); - $cnt_value = count($value); - - /* - * Enum in edit mode --> dropdown - * Enum in search mode --> multiselect - * Set in edit mode --> multiselect - * Set in search mode --> input (skipped here, so the 'else' - * section would handle it) - */ - if ((strncasecmp($column_type, 'enum', 4) && ! $in_zoom_search_edit) - || (strncasecmp($column_type, 'set', 3) && $in_zoom_search_edit) - ) { - $html_output .= ''; - } - - //Add select options - for ($j = 0; $j < $cnt_value; $j++) { - if (isset($criteriaValues[$column_index]) - && is_array($criteriaValues[$column_index]) - && in_array($value[$j], $criteriaValues[$column_index]) - ) { - $html_output .= ''; - } else { - $html_output .= ''; - } - } // end for - $html_output .= ''; - return $html_output; - } - /** * Creates the HTML content for: * 1) Browsing foreign data for a column. @@ -377,55 +221,23 @@ class PMA_TableSearch $column_index, $titles, $foreignMaxLimit, $criteriaValues, $in_fbs = false, $in_zoom_search_edit = false ) { - $str = ''; - $column_type = (string)$column_type; - $column_id = ($in_zoom_search_edit) ? 'edit_fieldID_' : 'fieldID_'; - - // Get inputbox based on different column types - // (Foreign key, geometrical, enum) - if ($this->_foreigners - && PMA_searchColumnInForeigners($this->_foreigners, $column_name) - ) { - $str .= $this->_getForeignKeyInputBox( - $foreignData, $column_name, $column_index, $titles, - $foreignMaxLimit, $criteriaValues, $column_id - ); - - } elseif (in_array($column_type, PMA_Util::getGISDatatypes())) { - $str .= $this->_getGeometricalInputBox($column_index, $in_fbs); - - } elseif (strncasecmp($column_type, 'enum', 4) == 0 - || (strncasecmp($column_type, 'set', 3) == 0 && $in_zoom_search_edit) - ) { - $str .= $this->_getEnumSetInputBox( - $column_index, $criteriaValues, $column_type, $column_id, - $in_zoom_search_edit = false - ); - - } else { - // other cases - $the_class = 'textfield'; - - if ($column_type == 'date') { - $the_class .= ' datefield'; - } elseif ($column_type == 'datetime' - || substr($column_type, 0, 9) == 'timestamp' - ) { - $the_class .= ' datetimefield'; - } elseif (substr($column_type, 0, 3) == 'bit') { - $the_class .= ' bit'; - } - - $str .= ''; - } - return $str; + return PMA\Template::get('table/input_box') + ->render(array( + 'str' => '', + 'column_type' => (string) $column_type, + 'column_id' => ($in_zoom_search_edit) ? 'edit_fieldID_' : 'fieldID_', + 'in_zoom_search_edit' => $in_zoom_search_edit, + '_foreigners' => $this->_foreigners, + 'column_name' => $column_name, + 'foreignData' => $foreignData, + 'table' => $this->_table, + 'column_index' => $column_index, + 'foreignMaxLimit' => $foreignMaxLimit, + 'criteriaValues' => $criteriaValues, + 'db' => $this->_db, + 'titles' => $titles, + 'in_fbs' => $in_fbs + )); } /** @@ -730,183 +542,6 @@ class PMA_TableSearch return ''; } - /** - * Generates HTML for a geometrical function column to be displayed in table - * search selection form - * - * @param integer $column_index index of current column in $columnTypes array - * - * @return string the generated HTML - */ - private function _getGeomFuncHtml($column_index) - { - $html_output = ''; - // return if geometrical column is not present - if (! $this->_geomColumnFlag) { - return $html_output; - } - - /** - * Displays 'Function' column if it is present - */ - $html_output .= ''; - $geom_types = PMA_Util::getGISDatatypes(); - // if a geometry column is present - if (in_array($this->_columnTypes[$column_index], $geom_types)) { - $html_output .= ''; - } else { - $html_output .= ' '; - } - $html_output .= ''; - return $html_output; - } - - /** - * Generates formatted HTML for extra search options in table search form - * - * @return string the generated HTML - */ - private function _getOptions() - { - $html_output = ''; - $html_output .= PMA_Util::getDivForSliderEffect( - 'searchoptions', __('Options') - ); - - /** - * Displays columns select list for selecting distinct columns in the search - */ - $html_output .= '
' - . '' . __('Select columns (at least one):') . '' - . '' - . '' - . '
'; - - /** - * Displays input box for custom 'Where' clause to be used in the search - */ - $html_output .= '
' - . '' . '' . __('Or') . ' ' - . __('Add search conditions (body of the "where" clause):') - . ''; - $html_output .= PMA_Util::showMySQLDocu('Functions'); - $html_output .= ''; - $html_output .= '
'; - - /** - * Displays option of changing default number of rows displayed per page - */ - $html_output .= '
' - . '' . __('Number of rows per page') . '' - . '' - . '
'; - - /** - * Displays option for ordering search results - * by a column value (Asc or Desc) - */ - $html_output .= '
' - . '' . __('Display order:') . '' - . ''; - $choices = array( - 'ASC' => __('Ascending'), - 'DESC' => __('Descending') - ); - $html_output .= PMA_Util::getRadioFields( - 'order', $choices, 'ASC', false, true, "formelement" - ); - unset($choices); - - $html_output .= '

'; - return $html_output; - } - - /** - * Other search criteria like data label - * (for tbl_zoom_select.php) - * - * @param string|null $dataLabel Label for points in zoom plot - * - * @return string the generated html - */ - private function _getOptionsZoom($dataLabel) - { - $html_output = ''; - $html_output .= ''; - //Select options for datalabel - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - //Inputbox for changing default maximum rows to plot - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= '
'; - $html_output .= ''; - $html_output .= '
'; - return $html_output; - } - /** * Provides a column's type, collation, operators list, and criteria value * to display in table search form @@ -931,14 +566,14 @@ class PMA_TableSearch $type = $this->_columnTypes[$column_index]; $collation = $this->_columnCollations[$column_index]; //Gets column's comparison operators depending on column type - $func = ''; + $func = PMA\Template::get('table/column_comparison_operators') + ->render(array( + 'search_index' => $search_index, + 'columnTypes' => $this->_columnTypes, + 'column_index' => $column_index, + 'columnNullFlags' => $this->_columnNullFlags, + 'selected_operator' => $selected_operator + )); //Gets link to browse foreign data(if any) and criteria inputbox $foreignData = PMA_getForeignData( $this->_foreigners, $this->_columnNames[$column_index], false, '', '' @@ -955,213 +590,6 @@ class PMA_TableSearch ); } - /** - * Provides the search form's table row in case of Normal Search - * (for tbl_select.php) - * - * @return string the generated table row - */ - private function _getRowsNormal() - { - $odd_row = true; - $html_output = ''; - // for every column present in table - for ( - $column_index = 0, $nb = count($this->_columnNames); - $column_index < $nb; - $column_index++ - ) { - $html_output .= ''; - $odd_row = !$odd_row; - //If 'Function' column is present - $html_output .= $this->_getGeomFuncHtml($column_index); - //Displays column's name, type, collation and value - $html_output .= '' - . htmlspecialchars($this->_columnNames[$column_index]) . ''; - $properties = $this->getColumnProperties($column_index, $column_index); - $html_output .= '' - . htmlspecialchars($properties['type']) - . ''; - $html_output .= '' . $properties['collation'] . ''; - $html_output .= '' . $properties['func'] . ''; - // here, the data-type attribute is needed for a date/time picker - $html_output .= '' . $properties['value'] . ''; - $html_output .= ''; - //Displays hidden fields - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - } // end for - - return $html_output; - } - - /** - * Provides the search form's table row in case of Zoom search - * (for tbl_zoom_select.php) - * - * @return string the generated table row - */ - private function _getRowsZoom() - { - $odd_row = true; - $html_output = ''; - $type = $collation = $func = $value = array(); - /** - * Get already set search criteria (if any) - */ - - //Displays column rows for search criteria input - for ($i = 0; $i < 4; $i++) { - //After X-Axis and Y-Axis column rows, display additional criteria - // option - if ($i == 2) { - $html_output .= ''; - $html_output .= __("Additional search criteria"); - $html_output .= ''; - } - $html_output .= ''; - $odd_row = ! $odd_row; - //Select options for column names - $html_output .= ''; - if (isset($_POST['criteriaColumnNames']) - && $_POST['criteriaColumnNames'][$i] != 'pma_null' - ) { - $key = array_search( - $_POST['criteriaColumnNames'][$i], - $this->_columnNames - ); - $properties = $this->getColumnProperties($i, $key); - $type[$i] = $properties['type']; - $collation[$i] = $properties['collation']; - $func[$i] = $properties['func']; - $value[$i] = $properties['value']; - } - //Column type - $html_output .= '' . (isset($type[$i]) ? $type[$i] : '') . ''; - //Column Collation - $html_output .= '' . (isset($collation[$i]) ? $collation[$i] : '') - . ''; - //Select options for column operators - $html_output .= '' . (isset($func[$i]) ? $func[$i] : '') . ''; - //Inputbox for search criteria value - $html_output .= '' . (isset($value[$i]) ? $value[$i] : '') . ''; - $html_output .= ''; - //Displays hidden fields - $html_output .= ''; - $html_output - .= ''; - $html_output .= ''; - }//end for - return $html_output; - } - - /** - * Generates HTML for displaying fields table in search form - * - * @return string the generated HTML - */ - private function _getFieldsTableHtml() - { - $html_output = ''; - $html_output .= '_searchType == 'zoom' ? ' id="tableFieldsId"' : '') . '>'; - $html_output .= $this->_getTableHeader(); - $html_output .= ''; - - if ($this->_searchType == 'zoom') { - $html_output .= $this->_getRowsZoom(); - } else { - $html_output .= $this->_getRowsNormal(); - } - - $html_output .= '
'; - return $html_output; - } - - /** - * Provides the form tag for table search form - * (normal search or zoom search) - * - * @param string $goto Goto URL - * - * @return string the HTML for form tag - */ - private function _getFormTag($goto) - { - $html_output = ''; - $scriptName = ''; - $formId = ''; - switch ($this->_searchType) { - case 'normal' : - $scriptName = 'tbl_select.php'; - $formId = 'tbl_search_form'; - break; - case 'zoom' : - $scriptName = 'tbl_zoom_select.php'; - $formId = 'zoom_search_form'; - break; - case 'replace' : - $scriptName = 'tbl_find_replace.php'; - $formId = 'find_replace_form'; - break; - } - - $html_output .= '
'; - - $html_output .= PMA_URL_getHiddenInputs($this->_db, $this->_table); - $html_output .= ''; - $html_output .= ''; - - return $html_output; - } - /** * Returns the HTML for secondary levels tabs of the table search page * @@ -1169,17 +597,14 @@ class PMA_TableSearch */ public function getSecondaryTabs() { - $url_params = array(); - $url_params['db'] = $this->_db; - $url_params['table'] = $this->_table; - - $html_output = '
    '; - foreach ($this->_getSubTabs() as $tab) { - $html_output .= PMA_Util::getHtmlTab($tab, $url_params); - } - $html_output .= '
'; - $html_output .= '
'; - return $html_output; + return PMA\Template::get('table/secondary_tabs') + ->render(array( + 'url_params' => array( + 'db' => $this->_db, + 'table' => $this->_table + ), + 'sub_tabs' => $this->_getSubTabs() + )); } /** @@ -1192,53 +617,18 @@ class PMA_TableSearch */ public function getSelectionForm($goto, $dataLabel = null) { - $html_output = $this->_getFormTag($goto); - - if ($this->_searchType == 'zoom') { - $html_output .= ''; - } else if ($this->_searchType == 'normal') { - $html_output .= ''; - } else if ($this->_searchType == 'replace') { - $html_output .= '
'; - $html_output .= '
'; - $html_output .= '' . __('Find and replace') . ''; - $html_output .= $this->_getSearchAndReplaceHTML(); - $html_output .= '
'; - $html_output .= '
'; - } - - /** - * Displays selection form's footer elements - */ - $html_output .= '
'; - $html_output .= ''; - $html_output .= '
'; - $html_output .= '
'; - return $html_output; + return PMA\Template::get('table/selection_form')->render(array( + 'searchType' => $this->_searchType, + 'db' => $this->_db, + 'table' => $this->_table, + 'goto' => $goto, + 'self' => $this, + 'geomColumnFlag' => $this->_geomColumnFlag, + 'columnNames' => $this->_columnNames, + 'columnTypes' => $this->_columnTypes, + 'columnCollations' => $this->_columnCollations, + 'dataLabel' => $dataLabel + )); } /** @@ -1252,93 +642,24 @@ class PMA_TableSearch */ public function getZoomResultsForm($goto, $data) { - $html_output = ''; $titles = array( 'Browse' => PMA_Util::getIcon( 'b_browse.png', __('Browse foreign values') ) ); - $html_output .= '
'; - $html_output .= PMA_URL_getHiddenInputs($this->_db, $this->_table); - $html_output .= ''; - $html_output - .= ''; - $html_output .= '
'; - $html_output .= '' . __('Browse/Edit the points') . ''; - - //JSON encode the data(query result) - $html_output .= '
'; - if (isset($_POST['zoom_submit']) && ! empty($data)) { - $html_output .= '
'; - $html_output .= '
' - . __('How to use') . '
'; - $html_output .= ''; - $html_output .= '
'; - $html_output .= ''; - $html_output .= '
'; - } - $html_output .= '
'; - - //Displays rows in point edit form - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - return $html_output; + return PMA\Template::get('table/zoom_result_form')->render(array( + '_db' => $this->_db, + '_table' => $this->_table, + '_columnNames' => $this->_columnNames, + '_foreigners' => $this->_foreigners, + '_columnNullFlags' => $this->_columnNullFlags, + '_columnTypes' => $this->_columnTypes, + 'titles' => $titles, + 'goto' => $goto, + 'data' => $data + )); } /** @@ -1348,31 +669,11 @@ class PMA_TableSearch */ function _getSearchAndReplaceHTML() { - $htmlOutput = __('Find:') - . ''; - $htmlOutput .= __('Replace with:') - . ''; - - $htmlOutput .= __('Column:') . ''; - - $htmlOutput .= '
' - . PMA_Util::getCheckbox( - 'useRegex', - __('Use regular expression'), - false, - false, - 'useRegex' - ); - return $htmlOutput; + return PMA\Template::get('table/search_and_replace') + ->render(array( + 'columnNames' => $this->_columnNames, + 'columnTypes' => $this->_columnTypes + )); } /** @@ -1456,58 +757,15 @@ class PMA_TableSearch $result = $GLOBALS['dbi']->fetchResult($sql_query, 0); } - $htmlOutput = '
'; - $htmlOutput .= PMA_URL_getHiddenInputs($this->_db, $this->_table); - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - - $htmlOutput .= '
'; - $htmlOutput .= '' . __('Find and replace - preview') . ''; - - $htmlOutput .= '' - . '' - . '' - . '' - . '' - . ''; - - $htmlOutput .= ''; - $odd = true; - if (is_array($result)) { - foreach ($result as $row) { - $val = $row[0]; - $replaced = $row[1]; - $count = $row[2]; - - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - $htmlOutput .= ''; - - $odd = ! $odd; - } - } - $htmlOutput .= ''; - $htmlOutput .= '
' . __('Count') . '' . __('Original string') . '' . __('Replaced string') . '
' . htmlspecialchars($count) - . '' . htmlspecialchars($val) . '' . htmlspecialchars($replaced) . '
'; - $htmlOutput .= '
'; - - $htmlOutput .= '
'; - $htmlOutput .= ''; - $htmlOutput .= '
'; - - $htmlOutput .= '
'; - return $htmlOutput; + return PMA\Template::get('table/replace_preview')->render(array( + 'db' => $this->_db, + 'table' => $this->_table, + 'columnIndex' => $columnIndex, + 'find' => $find, + 'replaceWith' => $replaceWith, + 'useRegex' => $useRegex, + 'result' => $result + )); } /** diff --git a/libraries/normalization.lib.php b/libraries/normalization.lib.php index ec19362569..b0df53e208 100644 --- a/libraries/normalization.lib.php +++ b/libraries/normalization.lib.php @@ -10,6 +10,9 @@ if (! defined('PHPMYADMIN')) { exit; } + +require_once 'libraries/Template.class.php'; + /** * build the html for columns of $colTypeCategory category * in form of given $listType in a table @@ -95,7 +98,12 @@ function PMA_getHtmlForCreateNewColumn( isset($available_mime)?$available_mime:array(), $mime_map ); } - return PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells); + + return PMA\Template::get('columns_definitions/table_fields_definitions') + ->render(array( + 'header_cells' => $header_cells, + 'content_cells' => $content_cells + )); } /** * build the html for step 1.1 of normalization diff --git a/libraries/tbl_columns_definition_form.lib.php b/libraries/tbl_columns_definition_form.lib.php index 9319e69e61..5e73b12b2d 100644 --- a/libraries/tbl_columns_definition_form.lib.php +++ b/libraries/tbl_columns_definition_form.lib.php @@ -9,6 +9,8 @@ if (!defined('PHPMYADMIN')) { exit; } +require_once 'libraries/Template.class.php'; + /** * Function to get form parameters * @@ -58,211 +60,6 @@ function PMA_getFormsParameters( return $form_params; } -/** - * Function to get html for table comments, storage engine, collation and - * partition definition - * - * @return string - */ -function PMA_getHtmlForTableConfigurations() -{ - $html = ''; - $html .= '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . ''; - - $commentLength = PMA_MYSQL_INT_VERSION >= 50503 ? 2048 : 60; - $html .= '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . ''; - - if (PMA_Partition::havePartitioning()) { - $html .= '' - . '' - . '' - . '' - . '' - . ''; - } - $html .= '
' . __('Table comments:') . ' ' . __('Collation:') . ' ' - . __('Storage Engine:') - . PMA_Util::showMySQLDocu('Storage_engines') - . ' ' - . __('Connection:') - . PMA_Util::showMySQLDocu('federated-create-connection') - . '
' - . ' ' - . PMA_generateCharsetDropdownBox( - PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, - (isset($_REQUEST['tbl_collation']) - ? $_REQUEST['tbl_collation'] - : null - ), - false - ) - . ' ' - . PMA_StorageEngine::getHtmlSelect( - 'tbl_storage_engine', null, - (isset($_REQUEST['tbl_storage_engine']) - ? $_REQUEST['tbl_storage_engine'] - : null - ) - ) - . ' ' - . '
' . __('PARTITION definition:') . ' ' - . PMA_Util::showMySQLDocu('Partitioning') - . '
' - . '' - . '
' - . '
'; - - return $html; -} - -/** - * Function to get html for the footer - * - * @return string - */ -function PMA_getHtmlForFooter() -{ - $html = '
' - . '' - . '' - . '
' - . '
' - . ''; - - $html .= ''; - - return $html; -} - -/** - * Function to get html for table create table name and number of fields - * - * @return string - */ -function PMA_getHtmlForTableNameAndNoOfColumns() -{ - $html = '
' - . '' - . '' - . '' - . '' - . '' - . '
' . __('Table name') - . ': ' - . ''; - $html .= sprintf( - __('Add %s column(s)'), '' - ); - - $html .= ''; - - $html .= '
' - . '
'; - - return $html; -} - -/** - * Function to get html for table field definitions - * - * @param array $header_cells header cells - * @param array $content_cells content cells - * - * @return string - */ -function PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells) -{ - $html = ''; - $html .= ''; - - $html .= ''; - foreach ($header_cells as $header_val) { - $html .= ''; - } - $html .= ''; - - $odd_row = true; - foreach ($content_cells as $content_row) { - $html .= ''; - $odd_row = ! $odd_row; - - if (is_array($content_row)) { - foreach ($content_row as $content_row_val) { - $html .= ''; - } - } - $html .= ''; - } - $html .= '
' . __('Structure') - . PMA_Util::showMySQLDocu('CREATE_TABLE') . '
' . $header_val . '
' . $content_row_val . '
' - . '
'; - - return $html; -} - -/** - * Function to get html for the hidden fields containing index creation info - * - * @param string $index_type the index type - * - * @return string - */ -function PMA_getHtmlForHiddenIndexInfo($index_type) -{ - $html = ''; - - return $html; -} - /** * Function to get html for the create table or field add view * @@ -276,31 +73,12 @@ function PMA_getHtmlForHiddenIndexInfo($index_type) function PMA_getHtmlForTableCreateOrAddField($action, $form_params, $content_cells, $header_cells ) { - $html = '
'; - $html .= PMA_URL_getHiddenInputs($form_params); - - $html .= PMA_getHtmlForHiddenIndexInfo('primary_indexes'); - $html .= PMA_getHtmlForHiddenIndexInfo('unique_indexes'); - $html .= PMA_getHtmlForHiddenIndexInfo('indexes'); - $html .= PMA_getHtmlForHiddenIndexInfo('fulltext_indexes'); - - if ($action == 'tbl_create.php') { - $html .= PMA_getHtmlForTableNameAndNoOfColumns(); - } - - if (is_array($content_cells) && is_array($header_cells)) { - $html .= PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells); - } - - if ($action == 'tbl_create.php') { - $html .= PMA_getHtmlForTableConfigurations(); - } - - $html .= PMA_getHtmlForFooter(); - - return $html; + return PMA\Template::get('columns_definitions/column_definitions_form')->render(array( + 'action' => $action, + 'form_params' => $form_params, + 'content_cells' => $content_cells, + 'header_cells' => $header_cells + )); } /** @@ -682,14 +460,13 @@ function PMA_getHtmlForColumnType($columnNumber, $ci, $ci_offset, $type_upper, $columnMeta ) { $select_id = 'field_' . $columnNumber . '_' . ($ci - $ci_offset); - $html = ''; - $html .= PMA_Util::getSupportedDatatypes(true, $type_upper); - $html .= ' '; - return $html; + return PMA\Template::get('columns_definitions/column_type')->render(array( + 'columnNumber' => $columnNumber, + 'columnMeta' => $columnMeta, + 'type_upper' => $type_upper, + 'select_id' => $select_id + )); } /** @@ -717,14 +494,13 @@ function PMA_getHtmlForTransformationOption($columnNumber, $ci, $ci_offset, ) : ''; - $html = ''; - - return $html; + return PMA\Template::get('columns_definitions/transformation_option')->render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'options_key' => $options_key, + 'val' => $val + )); } /** @@ -742,30 +518,14 @@ function PMA_getHtmlForTransformationOption($columnNumber, $ci, $ci_offset, function PMA_getHtmlForMimeType($columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map ) { - $html = ''; - - return $html; + return PMA\Template::get('columns_definitions/mime_type')->render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'available_mime' => $available_mime, + 'columnMeta' => $columnMeta, + 'mime_map' => $mime_map + )); } /** @@ -786,42 +546,16 @@ function PMA_getHtmlForTransformation($columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map, $type_prefix ) { $type = $type_prefix . 'transformation'; - $html = ''; - - return $html; + return PMA\Template::get('columns_definitions/transformation')->render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'available_mime' => $available_mime, + 'columnMeta' => $columnMeta, + 'mime_map' => $mime_map, + 'type' => $type + )); } /** @@ -838,11 +572,6 @@ function PMA_getHtmlForTransformation($columnNumber, $ci, $ci_offset, function PMA_getHtmlForMoveColumn($columnNumber, $ci, $ci_offset, $move_columns, $columnMeta ) { - $html = ''; - - return $html; + return PMA\Template::get('columns_definitions/move_column')->render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'columnMeta' => $columnMeta, + 'move_columns' => $move_columns, + 'current_index' => $current_index + )); } /** @@ -891,18 +604,13 @@ function PMA_getHtmlForMoveColumn($columnNumber, $ci, $ci_offset, $move_columns, function PMA_getHtmlForColumnComment($columnNumber, $ci, $ci_offset, $columnMeta, $comments_map ) { - $maxLength = PMA_MYSQL_INT_VERSION >= 50503 ? 1024 : 255; - $html = ''; - - return $html; + return PMA\Template::get('columns_definitions/column_comment')->render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'columnMeta' => $columnMeta, + 'comments_map' => $comments_map + )); } /** @@ -918,17 +626,12 @@ function PMA_getHtmlForColumnComment($columnNumber, $ci, $ci_offset, $columnMeta function PMA_getHtmlForColumnAutoIncrement($columnNumber, $ci, $ci_offset, $columnMeta ) { - $html = 'render(array( + 'columnNumber' => $columnNumber, + 'ci' => $ci, + 'ci_offset' => $ci_offset, + 'columnMeta' => $columnMeta + )); } /** @@ -943,53 +646,12 @@ function PMA_getHtmlForColumnAutoIncrement($columnNumber, $ci, $ci_offset, */ function PMA_getHtmlForColumnIndexes($columnNumber, $ci, $ci_offset, $columnMeta) { - $html = ''; - - return $html; -} - -/** - * Function to get html for the index options - * - * @param int $columnNumber column number - * @param array $columnMeta column meta - * @param string $type index type - * @param string $key column meta key - * - * @return string - */ -function PMA_getHtmlForIndexTypeOption($columnNumber, $columnMeta, $type, $key) -{ - $typeToLower = /*overload*/mb_strtolower($type); - $typeToUpper = /*overload*/mb_strtoupper($type); - $html = '