webmcp

diff framework/env/ui/paginate.lua @ 1:985024b16520

Version 1.0.1

New feature: JSON requests

Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params

Changed behavior of load methods of atom library to accept nil as input

Bugfixes in mondelefant_atom_connector timestamp(tz) loaders

Added global constant _WEBMCP_VERSION containing a version string
author jbe
date Tue Nov 17 12:00:00 2009 +0100 (2009-11-17)
parents 9fdfb27f8e67
children 72860d232f32
line diff
     1.1 --- a/framework/env/ui/paginate.lua	Sun Oct 25 12:00:00 2009 +0100
     1.2 +++ b/framework/env/ui/paginate.lua	Tue Nov 17 12:00:00 2009 +0100
     1.3 @@ -3,12 +3,14 @@
     1.4    selector = selector,  -- a selector for items from the database
     1.5    per_page = per_page,  -- items per page, defaults to 10
     1.6    name     = name,      -- name of the CGI get variable, defaults to "page"
     1.7 +  page     = page,      -- directly specify a page, and ignore 'name' parameter
     1.8    content = function()
     1.9      ...                 -- code block which should be encapsulated with page selection links
    1.10    end
    1.11  }
    1.12  
    1.13 -This function preceeds and appends the output of the given 'content' function with page selection links. The passed selector will be modified to show only a limited amount ('per_page') of items.
    1.14 +This function preceeds and appends the output of the given 'content' function with page selection links. The passed selector will be modified to show only a limited amount ('per_page') of items. The currently displayed page will be determined directly by cgi.params, and not via the param.get(...) function, in order to pass page selections automatically to sub-views.
    1.15 +
    1.16  --]]--
    1.17  
    1.18  function ui.paginate(args)
    1.19 @@ -22,7 +24,7 @@
    1.20    count_selector:single_object_mode()
    1.21    local count = count_selector:exec().count
    1.22    local page_count = math.floor((count - 1) / per_page) + 1
    1.23 -  local current_page = param.get(name, atom.integer) or 1
    1.24 +  local current_page = atom.integer:load(cgi.params[name]) or 1
    1.25    selector:limit(per_page)
    1.26    selector:offset((current_page - 1) * per_page)
    1.27    local id     = param.get_id_cgi()

Impressum / About Us