]> git.nbdom.net Git - nb.git/commitdiff
lib/lua/nb.lua
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Aug 2018 02:42:55 +0000 (03:42 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Aug 2018 02:42:55 +0000 (03:42 +0100)
lib/lua/nb.lua
lib/php/db/table.php
lib/php/out/div.php

index 175eba1be2484e67ac282efcbb2c547efbe9da6a..7955c305d810575a06ba6af7778db58f5699477d 100644 (file)
@@ -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 {
index cbfa10a6851b7a5e46c4ec812e736bf052a76708..21765b6e048d0e0f6caadd2418683670590f2bef 100644 (file)
@@ -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 '<div class="nav bottom">'
+                               $nav = '<div class="nav bottom">'
                                        .$this->nav($opt['count'],$opt['tot'],$opt['limit'])
                                 .'</div>'.NB_EOL
                                ;
+                               echo $nav;
                         }
 
                } # < out
index 9682824d959c2288b73dcc439f9dd5c39d48f70c..781f63c0ccebd706a6fa34af22bfae4b0e74b13b 100644 (file)
@@ -4,11 +4,11 @@ return [
   'enclose' => ["<div class=\"rows\">".NB_EOL,"</div>".NB_EOL],
   'tag_enclose' => 'div class="row"',
   'tag' => 'div',
+  'row' => 'out_tag',
   'tag_key' => 'label',
   'tag_val' => 'span',
 # NB 31.01.18   'tag_val' => 'p',
 # NB 06.01.18 div.row div span { text-align: right; }
-  'row' => 'out_tag',
 # NB 06.01.18   'parse' => function(&$o,&$r) {
 # NB 06.01.18          $n = [];
 # NB 06.01.18          foreach ($r as $k=>$v) {