From b93fd027188dc5c4e139eb6d1bd79fe5ca0f74a5 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 23 Oct 2017 12:28:01 +0100 Subject: [PATCH] lib/php/db/table.php --- lib/php/db/table.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 7ea1237b..e640aa1b 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -482,13 +482,25 @@ Class Table extends nb { } - public static function form_hidden($ignore=[]) { + public static function params2hash($keys) { + $params = []; + foreach ($keys as $k) { + $params[$k] = self::p($k); + if (!isset($params[$k]) or (string)$params[$k] === '') unset($params[$k]); + } + return $params; + } + + public static function form_hidden($ignore=[],$params=null) { $h = ''; + if (!isset($params)) { + $params = self::params2hash(self::$params); + } - foreach (array_diff(self::$params,$ignore) as $p) { - if (($v=self::p($p)) or $p=='action') { - if (self::p('debug')) $h .= ""; - $h .= ''.NB_EOL; + foreach (array_diff($params,$ignore) as $k=>$v) { + if (isset($v) or $k=='action') { + if (self::p('debug')) $h .= ""; + $h .= ''.NB_EOL; } } @@ -559,10 +571,14 @@ Class Table extends nb { if ($this->show_hidden_params and !empty(self::$params)) { echo '' - .self::form_hidden(['action','referer']) - # NB 19.10.17: reactivated for rent - .(!empty($fields['action']) ? '' : '') - .(!empty($_SERVER['HTTP_REFERER']) ? '' : '') + .self::form_hidden([],array_merge($this->params2hash(self::$params),[ + 'action' => ($add ? 'insert' : 'update'), + 'referer' => (!empty($_SERVER['HTTP_REFERER']) ? urlencode($_SERVER['HTTP_REFERER']) : ''), + ])) +# NB 23.10.17 .self::form_hidden(['action','referer']) +# NB 23.10.17 // NB 19.10.17: action reactivated for rent +# NB 23.10.17 .(!empty($fields['action']) ? '' : '') +# NB 23.10.17 .(!empty($_SERVER['HTTP_REFERER']) ? '' : '') ; } else { echo (!empty($_SERVER['HTTP_REFERER']) ? '' : ''); -- 2.47.3