From 113f8f490e3aaed204f5e112e9cb0b8bf1222b37 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Wed, 4 Dec 2013 23:59:08 +0530 Subject: [PATCH 1/2] Feature 1455 - Display image,text or both in table row actions area Signed-off-by: Chanaka Indrajith --- ChangeLog | 1 + config.sample.inc.php | 6 +++ doc/config.rst | 8 ++++ libraries/DisplayResults.class.php | 59 +++++++++++++++++++++++++++--- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index aee3826ecf..05b0c19a3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog ====================== 4.2.0.0 (not yet released) ++ rfe #1455 Display image/text/both for the table row actions + rfe #1473 Transformation to convert Boolean value to text - bug #4157 Changing users password will delete it diff --git a/config.sample.inc.php b/config.sample.inc.php index 07047acbeb..d148515671 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -75,6 +75,12 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; $cfg['UploadDir'] = ''; $cfg['SaveDir'] = ''; +/** + * Whether to display image or text or both image and text in table row + * action segment. Value can be either of 'image', 'text' or 'both'. + */ +//$cfg['row_action_type'] = 'both'; + /** * Defines whether a user should be displayed a "show all (records)" * button in browse mode or not. diff --git a/doc/config.rst b/doc/config.rst index 5d362ff5f1..41451b1fa0 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -2806,3 +2806,11 @@ Developer Whether to display errors from PHP or not. +.. config:option:: $cfg['row_action_type'] + + :type: string + :default: ``'both'`` + + Whether to display image or text or both image and text in table row action + segment. Value can be either of ``'image'``, ``'text'`` or ``'both'``. + diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 81dd7fff2a..e79022b727 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -70,6 +70,9 @@ class PMA_DisplayResults const ROUTINE_PROCEDURE = 'procedure'; const ROUTINE_FUNCTION = 'function'; + + const ACTION_LINK_CONTENT_IMAGE = 'image'; + const ACTION_LINK_CONTENT_TEXT = 'text'; // Declare global fields @@ -3348,10 +3351,10 @@ class PMA_DisplayResults $_url_params + array('default_action' => 'insert') ); - $edit_str = PMA_Util::getIcon( + $edit_str = $this->_getActionLinkContent( 'b_edit.png', __('Edit') ); - $copy_str = PMA_Util::getIcon( + $copy_str = $this->_getActionLinkContent( 'b_insrow.png', __('Copy') ); @@ -3420,10 +3423,8 @@ class PMA_DisplayResults . ' WHERE ' . PMA_jsFormat($where_clause, false) . ($clause_is_unique ? '' : ' LIMIT 1'); - $del_str = PMA_Util::getIcon( - 'b_drop.png', __('Delete') - ); - + $del_str = $this->_getActionLinkContent('b_drop.png', __('Delete')); + } elseif ($del_lnk == self::KILL_PROCESS) { // kill process case $_url_params = array( @@ -3457,6 +3458,52 @@ class PMA_DisplayResults } // end of the '_getDeleteAndKillLinks()' function + /** + * Get content inside the table row action links (Edit/Copy/Delete) + * + * @param string $icon The name of the file to get + * @param string $display_text The text displaying after the image icon + * + * @return string + * + * @access private + * + * @see _getModifiedLinks(), _getDeleteAndKillLinks() + */ + private function _getActionLinkContent($icon, $display_text) + { + + $linkContent = ''; + + if (isset($GLOBALS['cfg']['row_action_type']) + && $GLOBALS['cfg']['row_action_type'] == self::ACTION_LINK_CONTENT_IMAGE + ) { + + $linkContent .= '' + . PMA_Util::getImage( + $icon, $display_text + ) + . ''; + + } else if (isset($GLOBALS['cfg']['row_action_type']) + && $GLOBALS['cfg']['row_action_type'] == self::ACTION_LINK_CONTENT_TEXT + ) { + + $linkContent .= '' . $display_text . ''; + + } else { + + $linkContent .= PMA_Util::getIcon( + $icon, $display_text + ); + + } + + return $linkContent; + + } + + /** * Prepare placed links * From 30522c8d5f8bebf547eb90c46fe5af033075fd2b Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Thu, 5 Dec 2013 23:31:50 +0530 Subject: [PATCH 2/2] Rename the global variable from row_action_type to RowActionType Signed-off-by: Chanaka Indrajith --- config.sample.inc.php | 2 +- doc/config.rst | 2 +- libraries/DisplayResults.class.php | 8 ++++---- libraries/config.default.php | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config.sample.inc.php b/config.sample.inc.php index d148515671..ff18bf0306 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -79,7 +79,7 @@ $cfg['SaveDir'] = ''; * Whether to display image or text or both image and text in table row * action segment. Value can be either of 'image', 'text' or 'both'. */ -//$cfg['row_action_type'] = 'both'; +//$cfg['RowActionType'] = 'both'; /** * Defines whether a user should be displayed a "show all (records)" diff --git a/doc/config.rst b/doc/config.rst index 41451b1fa0..34968256c5 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -2806,7 +2806,7 @@ Developer Whether to display errors from PHP or not. -.. config:option:: $cfg['row_action_type'] +.. config:option:: $cfg['RowActionType'] :type: string :default: ``'both'`` diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index e79022b727..9866c4a350 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -3475,8 +3475,8 @@ class PMA_DisplayResults $linkContent = ''; - if (isset($GLOBALS['cfg']['row_action_type']) - && $GLOBALS['cfg']['row_action_type'] == self::ACTION_LINK_CONTENT_IMAGE + if (isset($GLOBALS['cfg']['RowActionType']) + && $GLOBALS['cfg']['RowActionType'] == self::ACTION_LINK_CONTENT_IMAGE ) { $linkContent .= '' @@ -3485,8 +3485,8 @@ class PMA_DisplayResults ) . ''; - } else if (isset($GLOBALS['cfg']['row_action_type']) - && $GLOBALS['cfg']['row_action_type'] == self::ACTION_LINK_CONTENT_TEXT + } else if (isset($GLOBALS['cfg']['RowActionType']) + && $GLOBALS['cfg']['RowActionType'] == self::ACTION_LINK_CONTENT_TEXT ) { $linkContent .= '' . $display_text . ''; diff --git a/libraries/config.default.php b/libraries/config.default.php index b4902e3fe4..fcc6fe7807 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -1287,6 +1287,12 @@ $cfg['DefaultTabDatabase'] = 'db_structure.php'; */ $cfg['DefaultTabTable'] = 'sql.php'; +/** + * Whether to display image or text or both image and text in table row + * action segment. Value can be either of ``image``, ``text`` or ``both``. + */ +$cfg['RowActionType'] = 'both'; + /******************************************************************************* * Export defaults */