From b7f6d6c85535819a731fb08875b44cb500290697 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 7 Aug 2018 03:42:55 +0100 Subject: [PATCH] lib/lua/nb.lua --- lib/lua/nb.lua | 23 +++++++++++++++++++++-- lib/php/db/table.php | 5 +++-- lib/php/out/div.php | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index 175eba1b..7955c305 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -19,6 +19,25 @@ function nb:readall(file) end end +function nb:ngx_uri_arg(k,v) + local uri = ngx.var.request_uri + local args = uri:gsub('^[^%?]+%?(.*)$','%1') + uri = uri:gsub('^([^%?]+).*$','%1') + + args = args:gsub('^' .. k .. '=[^&]+','') + args = args:gsub('&' .. k .. '=[^&]+','') + + if v ~= '' then + if args ~= '' then args = args .. '&' end + args = args .. ngx.escape_uri(k) .. '=' .. ngx.escape_uri(v) + end + + args = args:gsub('^&','') + if args ~= '' then uri = uri .. '?' .. args end + + return uri +end + function nb:ngx_rows(url) local json = require('json') local rows = json.decode(ngx.location.capture(url).body) @@ -26,11 +45,11 @@ function nb:ngx_rows(url) if not rows then rows = {} end local count = 0 for _,row in pairs(rows) do count = count+1 end - --local langs = {} langs["eng"] = 1 + local langs = {} -- langs["eng"] = 1 local count = 0 for _,row in pairs(rows) do count = count + 1 - --langs[rows.lang] = 1 + --langs[row.country] = "1" end return { diff --git a/lib/php/db/table.php b/lib/php/db/table.php index cbfa10a6..21765b6e 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1298,7 +1298,7 @@ Class Table extends nb { if (!$this->field($f)) continue; # # Mime content - $row[$f] = $field->htmlValue($row[$f]); + if ($opt['is_html']) $row[$f] = $field->htmlValue($row[$f]); $row[$f] = $field->out(isset($row[$f]) ? $row[$f] : ''); @@ -1369,10 +1369,11 @@ Class Table extends nb { echo $this->{"rows_end_$format"}(); if ($opt['is_html']) { - echo '