From e55a721791810169a393f23f4e8307fc8ee48ea4 Mon Sep 17 00:00:00 2001 From: "Jehan-Guillaume (ioguix) de Rorthais" Date: Fri, 11 May 2012 12:02:32 +0200 Subject: [PATCH] Make sure edit/delete action buttons are accessible from plugins --- display.php | 80 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/display.php b/display.php index 4fbdb0ed..854c5e56 100644 --- a/display.php +++ b/display.php @@ -552,24 +552,54 @@ } } - $buttons = array(); - $plugin_functions_parameters = array( + $buttons = array( + 'edit' => array ( + 'content' => $lang['stredit'], + 'attr'=> array ( + 'href' => array ( + 'url' => 'display.php', + 'urlvars' => array_merge(array ( + 'action' => 'confeditrow', + 'strings' => $_REQUEST['strings'], + 'page' => $_REQUEST['page'], + ), $_gets, $_getsort) + ) + ) + ), + 'delete' => array ( + 'content' => $lang['strdelete'], + 'attr'=> array ( + 'href' => array ( + 'url' => 'display.php', + 'urlvars' => array_merge(array ( + 'action' => 'confdelrow', + 'strings' => $_REQUEST['strings'], + 'page' => $_REQUEST['page'], + ), $_gets, $_getsort) + ) + ) + ), + ); + $actions = array( 'actionbuttons' => &$buttons, 'place' => 'display-browse' ); - $plugin_manager->do_hook('actionbuttons', $plugin_functions_parameters); + $plugin_manager->do_hook('actionbuttons', $actions); - foreach (array_keys($plugin_functions_parameters['actionbuttons']) as $action) { - $plugin_functions_parameters['actionbuttons'][$action]['attr']['href']['urlvars'] = array_merge( - $plugin_functions_parameters['actionbuttons'][$action]['attr']['href']['urlvars'], + foreach (array_keys($actions['actionbuttons']) as $action) { + $actions['actionbuttons'][$action]['attr']['href']['urlvars'] = array_merge( + $actions['actionbuttons'][$action]['attr']['href']['urlvars'], $_gets, $_getsort ); } - error_log(print_r($plugin_functions_parameters, 1)); + $edit_params = $actions['actionbuttons']['edit']; + $delete_params = $actions['actionbuttons']['delete']; + + error_log(print_r($actions, 1)); // Display edit and delete actions if we have a key - $colspan = count($buttons) + 2; + $colspan = count($buttons); if (sizeof($key) > 0) echo "{$lang['stractions']}\n"; @@ -585,32 +615,38 @@ echo "\n"; // Display edit and delete links if we have a key if (sizeof($key) > 0) { - $key_str = ''; + $keys_array = array(); $has_nulls = false; foreach ($key as $v) { if ($rs->fields[$v] === null) { $has_nulls = true; break; } - if ($key_str != '') $key_str .= '&'; - $key_str .= urlencode("key[{$v}]") . '=' . urlencode($rs->fields[$v]); + $keys_array["key[{$v}]"] = $rs->fields[$v]; } if ($has_nulls) { echo " \n"; } else { - echo "{$lang['stredit']}\n"; - echo "{$lang['strdelete']}\n"; - - foreach ($plugin_functions_parameters['actionbuttons'] as $action) { + + if (isset($actions['actionbuttons']['edit'])) { + $actions['actionbuttons']['edit'] = $edit_params; + $actions['actionbuttons']['edit']['attr']['href']['urlvars'] = array_merge( + $actions['actionbuttons']['edit']['attr']['href']['urlvars'], + $keys_array + ); + } + + if (isset($actions['actionbuttons']['delete'])) { + $actions['actionbuttons']['delete'] = $delete_params; + $actions['actionbuttons']['delete']['attr']['href']['urlvars'] = array_merge( + $actions['actionbuttons']['delete']['attr']['href']['urlvars'], + $keys_array + ); + } + + foreach ($actions['actionbuttons'] as $action) { echo ""; $misc->printLink($action); - // "{$lang['stredit']}" echo "\n"; } -- 2.39.5