ad_table_sort_form (public, deprecated)

 ad_table_sort_form datadef [ type ] [ return_url ] [ item_group ] \
    [ item ] [ sort_spec ] [ allowed ]

Defined in packages/acs-tcl/tcl/deprecated-procs.tcl

Deprecated. Invoking this procedure generates a warning.

builds a form for setting up custom sorts.

  • datadef is the table definition as in ad_table.
  • type is select or radio (only select is implemented now)
  • return_url is the return url passed through to the page that validates and saves the sort customization.
  • item_group is a string identifying the customization "ticket_tracker_main_sort" for example.
  • item is the user entered identifier
  • sort_spec is the sort specifier as in ad_new_sort_by
  • allowed is the list of all the columns allowed, if empty all are allowed.

An example from the ticket system:

      ad_table_sort_form $tabledef select $return_url ticket_tracker_main_sort $ticket_sort $orderby
    

Parameters:
datadef (required)
type (optional, defaults to "select")
return_url (optional)
item_group (optional)
item (optional)
sort_spec (optional)
allowed (optional)
See Also:

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc ad_table_sort_form
    # first build a map of all available columns
    set sel_list [ad_table_column_list -sortable t $datadef $allowed]

    # build the map of currently selected columns
    set full_column [split $sort_spec ","]
    set sel_columns [list]
    set direction [list]
    foreach col $full_column {
        regexp {([^*,]+)([*])?} $col match coln dirn
        if {$dirn eq "*"} {
            set dirn desc
        } else {
            set dirn asc
        }
        lappend sel_columns $coln
        lappend direction $dirn
    }

    set max_columns 4
    set n_sel_columns [llength $sel_columns]

    set html {}
    if {$item eq "CreateNewCustom" } {
        set item {}
    }
    # now spit out the form fragment.
    if {$item ne ""} {
        append html "<h2>Editing <strong>$item</strong></h2>"
        append html "<form method=\"get\" action=\"/tools/sort-custom\">"
        append html "<input type=\"submit\" value=\"Delete this sort\">"
        append html "<input type=\"hidden\" name=\"delete_the_sort\" value=\"1\">"
        append html "[export_vars -form {item_group item}]"
        if {$return_url ne ""} {
            append html "[export_vars -form {return_url}]"
        }
        append html "</form>"
    }

    append html "<form method=get action=\"/tools/sort-custom\">"
    if {$return_url ne ""} {
        append html "[export_vars -form {return_url}]"
    }
    if {$item_group eq ""} {
        set item_group [ad_conn url]
    }

    append html "[export_vars -form {item_group}]"
    if {$item ne ""} {
        set item_original $item
        append html "[export_vars -form {item_original}]"
        append html "<input type=\"submit\" value=\"Save changes\">"
    } else {
        append html "<input type=\"submit\" value=\"Save new sort\">"
    }

    append html "<table>"
    append html "<tr><th>Name:</th><td><input type=\"text\" size=\"60\" name=\"item\" [export_form_value item]></td></tr>"
    if {$item ne ""} {
        set item_original item
        append html "[export_vars -form {item_original}]"
        append html "<tr><td>&nbsp;</td><td><em>Editing the name will rename the sort</em></td></tr>"
    }

    set options "<option value=\"\">---</option>"
    foreach opt $sel_list {
        append options " <option value=\"[lindex $datadef $opt 0]\">[lindex $datadef $opt 1]</option>"
    }

    for {set i 0} { $i < $max_columns} {incr i} {
        if {$i < $n_sel_columns} {
            set match [lindex $sel_columns $i]
            regsub "(<option )(value=\"$match\">)" $options "\\1 selected=\"selected\" \\2" out
        } else {
            set out $options
        }
        append html "<tr><th>[expr {$i + 1}]</th><td><select name=\"col\">$out</select>"
        switch [lindex $direction $i] {
            asc {
                append html "<select name=\"dir\"><option value=\"asc\" selected=\"selected\">increasing</option><option value=\"desc\">decreasing</option></select>"
            }
            default {
                append html "<select name=\"dir\"><option value=\"asc\">increasing</option><option value=\"desc\" selected=\"selected\">decreasing</option></select>"

            }
        }
        append html "\n</td></tr>\n"
    }
    append html "</table></form>"

    return $html
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/deprecated-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: