[FIX] Page nav. with self-refering tables

2011-05-15
2013-05-20
  • Nobody/Anonymous

    Limbas 2.2.28.810

    This is not a real bugfix.

    If you have a table to store any graph (maybe a family tree with ancestors and
    descendants) you need a self refering table.

    Having such a construction Limbas will display the number of refered record in
    the Table View or if there is only one reference the value of the linked field.
    Both are rendered as HTML-links to a new Table View-window displaying the
    referenced records.

    The Problem occurs if there is only one reference. Now you are not able to use
    the page navigation at the bottom of the table as assumed since Limbas resets
    the value of the current page when querying more information for that one
    refered record.

    First Limbas gets the next page to display from post or get variables in
    gtab_register.lib around line 188.

    if($filter_page){
        $filter_page_ = explode("/",$filter_page[key($filter_page)]);
        $filter["page"][key($filter_page)] = $filter_page_[0];
    }
    

    The following code snippet from gtab.lib.get_sqlresult() (around line 3402)
    (re-)sets the current page.
    Why twice? $filter and $GLOBALS, removing $GLOBALS works,
    but I don't know the whole story.

    if($filter["anzahl"][$gtabid]){
        if (!$filter["page"][$gtabid] OR $filter["page"][$gtabid] < 1 OR $filter["page"][$gtabid] > (ceil($gresult[$gtabid]["max_count"]/$filter["anzahl"][$gtabid])) ){$filter["page"][$gtabid] = 1;$GLOBALS["filter"]["page"][$gtabid] = 1;}
    }
    

    Workaround

    As a quick workaround I store the page number to a temporary variable after
    building the page and table head and restore it after getting table data.

    Index: gtab/html/gtab_erg.php

    -- gtab/html/gtab_erg.php (revision 14)
    +++ gtab/html/gtab_erg.php (working copy)
    @@ -591,7 +591,9 @@
    table_body_open();
    table_search($gtabid,$verknpf,$verkn);
    table_header($gtabid,$gresult,0);
    + $tmp_filter_page = $filter;
    table_body($gtabid,$gresult,1,$verkn,$verknpf,$filter,0,0,0,0,1);
    + $filter = $tmp_filter_page;
    table_body_close();
    table_footer($gtabid,$gresult,$filter);
    table_all_close();

     
  • Daniel

    Daniel - 2011-05-15

    I forgot to log in.

    Daniel

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks