Home
The Toolkit for Online Communities
15902 Community Members, 0 members online, 2316 visitors today
Log In Register

util-procs.tcl

OpenACS Home : ACS API Browser : ACS Templating 5.5.1 : util-procs.tcl
Publicity:
[Public Only | All]

util-procs.tcl


Procedures in this file

Detailed information

stack_dump (public)

stack_dump
return the whole call stack as HTML

 

stack_frame_values (public)

stack_frame_values level
return the variables and arrays of one frame as HTML

Parameters:
level
 

template::get_resource_path (public)

template::get_resource_path
Get the template directory The body is doublequoted, so it is interpreted when this file is read

 

template::util::array_to_vars (public)

template::util::array_to_vars arrayname
Declare local variables for every key in an array.

Parameters:
arrayname - The name of an array in the calling frame.
 

template::util::clear_cookie (public)

template::util::clear_cookie name [ domain ]
Expires an existing cookie.

Parameters:
name
domain (optional)
 

template::util::get_cookie (public)

template::util::get_cookie name [ default_value ]
Retrieve the value of a cookie and return it Return the default if no such cookie exists

Parameters:
name
default_value (optional)
 

template::util::get_opts (public)

template::util::get_opts argv
Builds an array named "opts" in the calling frame, containing all switches passed at the end of a proc. The array values are either switch parameters or 1 if no parameter was specified. Problem: there is currently no way to specify an option parameter that begins with a dash. This particularly problematic for negative numbers.

Parameters:
argv
 

template::util::get_param (public)

template::util::get_param name [ section ] [ key ]
Retreive a stored parameter, or "" if no such parameter If section/key are present, read the parameter from the specified section.key in the INI file, and cache them under the given name

Parameters:
name
section (optional)
key (optional)
 

template::util::get_url_directory (public)

template::util::get_url_directory url
Get the directory portion of a URL. If the URL has a trailing slash, then return the entire URL.

Parameters:
url
 

template::util::is_nil (public)

template::util::is_nil ref
Determines whether a variable both exists and is not an empty string.

Parameters:
ref - The name of a variable to test in the calling frame.
Returns:
1 if the variable either not exist or is an empty string. 0 if the variable is either an array reference or a non-empty scalar.
 

template::util::is_true (public)

template::util::is_true x
interprets its argument as a boolean.

Parameters:
x - the value to test
Returns:
0 if the variable can be interpreted as false; 1 for true if it can't.
 

template::util::is_unique (public)

template::util::is_unique table columns values
Queries a database table for the existence of a particular row. Useful for validating form input to reduce the possibility of unique constraint violations.

Parameters:
table - The name of a database table.
columns - A list of columns on which to select the row.
values - A list of values for each specified column.
Returns:
1 if the row exists, 0 if not
 

template::util::list_of_lists_to_array (public)

template::util::list_of_lists_to_array lists array_ref
Converts a list of lists in the form { { key value } { key value } ... } to an array.

Parameters:
lists
array_ref
 

template::util::list_of_ns_sets_to_multirow (public)

template::util::list_of_ns_sets_to_multirow -rows rows \
    -var_name var_name [ -level level ]
Transform a list of ns_sets (most likely produced by db_list_of_ns_sets into a multirow datasource.

Switches:
-rows (required)
The data to be transformed
-var_name (required)
The name of the multirow to create
-level (defaults to "1") (optional)
How many levels up the stack to place the new datasource, defaults to 1 level up.
 

template::util::list_opts (public)

template::util::list_opts [ array_ref ]
Converts an array to an option list

Parameters:
array_ref (defaults to "opts") - The name of the array in the calling frame containing option-value pairs. Defaults to "opts".
Returns:
A list of option-value pairs suitable for appending to a command.
 

template::util::list_to_array (public)

template::util::list_to_array values array_ref columns
Converts a list of values into an array, using a list of corresponding column names for the array keys.

Parameters:
values - A list of values
array_ref - The name of the array to create in the calling frame.
columns - A list of column names to use for the array keys. The length of this list should be the same as the values list.
 

template::util::list_to_lookup (public)

template::util::list_to_lookup values array_ref
Turn a list into an array where each key corresponds to an element of the list... Sort of like a sparse bitmap. Each value corresponds to the key's position in the input list.

Parameters:
values - A list of values
array_ref - The name of the array to create in the calling frame.
 

template::util::list_to_multirow (public)

template::util::list_to_multirow name rows [ level ]
populate a multirow data source from a list string gotten from a call to template::util::multirow_to_list

Parameters:
name - the name of a multirow data source
rows - a representation of a multirow data source as a list, suitable for passing by value in the form { { row } { row } { row } ... }
level (defaults to "1")

See Also:
 

template::util::lnest (public)

template::util::lnest listref value next [ args... ]
Recursive procedure for building a hierarchical or multidimensional data structure in a list.

Parameters:
listref
value - Either a list or scalar value to store in the list.
next - A key value that determines the next node to traverse outward in the data structure.
 

template::util::lpop (public)

template::util::lpop ref
Removes the last item from a list. The operation is performed in-place, rather than returning the new list.

Parameters:
ref - The name of a list in the calling frame on which to operate.
 

template::util::multirow_foreach (public)

template::util::multirow_foreach name code_text
Deprecated.

runs a block of code foreach row in a multirow. Using "template::multirow foreach" is recommended over this routine.

Parameters:
name - the name of the multirow over which the block of code is iterated
code_text - the block of code in the for loop; this block can reference any of the columns belonging to the multirow specified; with the multirow named "fake_multirow" containing columns named "spanky" and "foobar",to set the column spanky to the value of column foobar use:
set fake_multirow.spanky @fake_multirow.foobar@

note: this block of code is evaluated in the same scope as the .tcl page that uses this procedure

Author:
simon

See Also:
 

template::util::multirow_quote_html (public)

template::util::multirow_quote_html multirow_ref column_ref
implements template::util::quote_html on the designated column of a multirow

Parameters:
multirow_ref - name of the multirow
column_ref - name of the column to be
Author:
simon
 

template::util::multirow_to_list (public)

template::util::multirow_to_list [ -level level ] name
generate a list structure representitive of a multirow data source NB: if the multirow is generated by db_multirow, db_multirow must be called with the -local option

Switches:
-level (defaults to "1") (optional)
Parameters:
name - the name of an existing multirow data source
Returns:
a representation of a multirow data source as a list, suitable for passing by value in the form { { row } { row } { row } ... }

See Also:
 

template::util::number_list (public)

template::util::number_list last_number [ start_at ]
Return a list of numbers, {1 2 3 ... n}

Parameters:
last_number
start_at (defaults to "0")
 

template::util::nvl (public)

template::util::nvl value value_if_null
Analogous to SQL NVL

Parameters:
value
value_if_null
 

template::util::quote_html (public)

template::util::quote_html html
Quote possible HTML tags in the contents of the html parameter.

Parameters:
html
 

template::util::read_file (public)

template::util::read_file path
Reads a text file.

Parameters:
path - The absolute path to the file
Returns:
A string with the contents of the file.
 

template::util::resolve_directory_url (public)

template::util::resolve_directory_url url
Resolve the file name for a directory URL

Parameters:
url
 

template::util::set_cookie (public)

template::util::set_cookie expire_state name value [ domain ]
Create a cookie with specified parameters. The expiration state may be persistent, session, or a number of minutes from the current time.

Parameters:
expire_state
name
value
domain (optional)
 

template::util::set_file_encoding (public)

template::util::set_file_encoding file_channel_id
Set encoding of the given file channel based on the OutputCharset parameter of AOLserver. All adp, tcl, and txt files are assumed to be in the same charset.

Parameters:
file_channel_id - The id of the file to set encoding for.
Author:
Peter Marklund
 

template::util::set_param (public)

template::util::set_param name value
Set a stored parameter

Parameters:
name
value
 

template::util::set_to_list (public)

template::util::set_to_list set [ args... ]
Turns an ns_set into a key-value list, excluding any number of specified keys. Useful for turning the contents on an ns_set into a form that may be cached or manipulated as a native Tcl data structure.

Parameters:
set - A reference to an ns_set.
Returns:
A list in the form { key value key value key value ... }
 

template::util::set_to_vars (public)

template::util::set_to_vars set [ args... ]
Declare local variables for set values

Parameters:
set - A reference to an ns_set.
 

template::util::tcl_to_sql_list (public)

template::util::tcl_to_sql_list lst
Convert a TCL list to a SQL list, for use with the "in" statement. Uses DoubleApos (similar to ns_dbquotevalue) functionality to escape single quotes

Parameters:
lst
 

template::util::url_to_file (public)

template::util::url_to_file url [ reference_url ]
Resolve a URL into an absolute file path.

Parameters:
url
reference_url (optional)
 

template::util::vars_to_array (public)

template::util::vars_to_array arrayname [ args... ]
Place local variables into an array

Parameters:
arrayname - The name of an array in the calling frame.
 

template::util::write_file (public)

template::util::write_file path text
Writes a text file

Parameters:
path - The absolute path to the file
text - A string containing the text to write to the file.