From d3d149c3605d8b26748d02aa6e534018e9fd123a Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 22 Oct 2010 07:40:20 -0400 Subject: [PATCH] refactoring for checkbox and links in Browse mode (vertical) --- libraries/display_tbl.lib.php | 79 +++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 12f108160..d56844377 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1459,32 +1459,22 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { } if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { - $vertical_display['row_delete'][$row_no] .= ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + $vertical_display['row_delete'][$row_no] .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, '[%_PMA_CHECKBOX_DIR_%]', $alternating_color_class, $column_style_vertical, $column_marker_vertical); } else { unset($vertical_display['row_delete'][$row_no]); } if (isset($edit_url)) { - $vertical_display['edit'][$row_no] .= '' . "\n" - . PMA_linkOrButton($edit_url, $edit_str, array(), false); - // Generates the 'where_clause' hidden input field - // for inline ajax edit if required - if(! empty($where_clause) ) { - $vertical_display['edit'][$row_no] .= ''; - } - $vertical_display['edit'][$row_no] .= ''; + $vertical_display['edit'][$row_no] .= PMA_generateEditLink($edit_url, $alternating_color_class . ' ' . $edit_anchor_class, $edit_str, $where_clause, $where_clause_html, $column_style_vertical); } else { unset($vertical_display['edit'][$row_no]); } if (isset($del_url)) { - $vertical_display['delete'][$row_no] .= ' ' . "\n" - . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), false) - . ' ' . "\n"; + if (! isset($js_conf)) { + $js_conf = ''; + } + $vertical_display['delete'][$row_no] .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, $alternating_color_class, $column_style_vertical); } else { unset($vertical_display['delete'][$row_no]); } @@ -1525,7 +1515,7 @@ function PMA_displayVerticalTable() echo '' . "\n"; } - echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val); + echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_l', $val); $foo_counter++; } // end while echo '' . "\n"; @@ -1596,7 +1586,7 @@ function PMA_displayVerticalTable() echo '' . "\n"; } - echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val); + echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_r', $val); $foo_counter++; } // end while echo '' . "\n"; @@ -2457,15 +2447,23 @@ function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed * @param string $where_clause_html * @param string $del_query * @param string $id_suffix + * @param string $class + * @param string $column_style_vertical + * @param string $column_marker_vertical * @return string the generated HTML */ -function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix) { +function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix, $class, $column_style_vertical, $column_marker_vertical) { $ret = ''; if (! empty($del_url) && $is_display['del_lnk'] != 'kp') { - $ret .= '' - . '' . ' '; } @@ -2477,17 +2475,18 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_cla * * @uses PMA_linkOrButton() * @param string $edit_url - * @param string $edit_anchor_class + * @param string $class * @param string $edit_str * @param string $where_clause * @param string $where_clause_html + * @param string $column_style_vertical * @return string the generated HTML */ -function PMA_generateEditLink($edit_url, $edit_anchor_class, $edit_str, $where_clause, $where_clause_html) { +function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, $column_style_vertical) { $ret = ''; if (! empty($edit_url)) { - $ret .= '' - . PMA_linkOrButton($edit_url, $edit_str, '', FALSE); + $ret .= '' + . PMA_linkOrButton($edit_url, $edit_str, array(), FALSE); /* * Where clause for selecting this row uniquely is provided as * a hidden input. Used by jQuery scripts for handling inline editing @@ -2507,14 +2506,20 @@ function PMA_generateEditLink($edit_url, $edit_anchor_class, $edit_str, $where_c * @param string $del_url * @param string $del_str * @param string $js_conf + * @param string $class + * @param string $column_style_vertical * @return string the generated HTML */ -function PMA_generateDeleteLink($del_url, $del_str, $js_conf) { +function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class, $column_style_vertical) { $ret = ''; if (! empty($del_url)) { - $ret .= ' ' + $ret .= '' . PMA_linkOrButton($del_url, $del_str, $js_conf, FALSE) - . ' '; + . ''; } return $ret; } @@ -2534,28 +2539,28 @@ function PMA_generateDeleteLink($del_url, $del_str, $js_conf) { * @param string $del_query * @param string $id_suffix * @param string $edit_url - * @param string $edit_anchor_class + * @param string $class * @param string $edit_str * @param string $del_str * @param string $js_conf * @return string the generated HTML */ -function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, $id_suffix, $edit_url, $edit_anchor_class, $edit_str, $del_str, $js_conf) { +function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, $id_suffix, $edit_url, $class, $edit_str, $del_str, $js_conf) { $ret = ''; if ($position == 'left') { - $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='l'); + $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_l', '', '', ''); - $ret .= PMA_generateEditLink($edit_url, $edit_anchor_class, $edit_str, $where_clause, $where_clause_html); + $ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, ''); - $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf); + $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); } elseif ($position == 'right') { - $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf); + $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); - $ret .= PMA_generateEditLink($edit_url, $edit_anchor_class, $edit_str, $where_clause, $where_clause_html); + $ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, ''); - $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='r'); + $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_r', '', '', ''); } return $ret; }