util-procs.tcl

Utility procedures for the ArsDigita Templating System

Location:
packages/acs-templating/tcl/util-procs.tcl
Authors:
Karl Goldstein <karlg@arsdigita.com>
Stanislav Freidin <sfreidin@arsdigita.com>
CVS Identification:
$Id: util-procs.tcl,v 1.45 2024/09/11 06:15:48 gustafn Exp $

Procedures in this file

Detailed information

anchor_form (public)

 anchor_form [ -id id ] [ -vars vars ] [ -action action ] \
    [ -label label ]

return an inline form with the appearance of an anchor

Switches:
-id (optional)
-vars (optional)
-action (optional)
-label (optional, defaults to "link")

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-admin/www/apm/package-delete-2.tcl packages/acs-admin/ www/apm/package-delete-2.tcl anchor_form anchor_form packages/acs-admin/www/apm/package-delete-2.tcl->anchor_form template::add_body_script template::add_body_script (public) anchor_form->template::add_body_script

Testcases:
No testcase defined.

stack_dump (public, deprecated)

 stack_dump
Deprecated. Invoking this procedure generates a warning.

return the whole call stack as HTML DEPRECATED: does not comply with OpenACS naming convention.

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) template::stack_dump template::stack_dump (public) stack_dump stack_dump stack_dump->ad_log_deprecated stack_dump->template::stack_dump

Testcases:
No testcase defined.

template::resource_path (public)

 template::resource_path [ -verbose ] -type type -style style \
    [ -relative ] [ -subsite_id subsite_id ] [ -theme_dir theme_dir ]

Process the templating "style" and return the stub (path without extensions). When the style is not an absolute path, check if the resource can be obtained from the theme, if not fallback to the resources directory of acs-templating.

Switches:
-verbose (optional, boolean, defaults to "false")
-type (required)
type of resource (e.g. "forms" or "lists")
-style (required)
name of the resource within the type (e.g. "standard")
-relative (optional, boolean)
return optionally the path relative to the OpenACS root directory
-subsite_id (optional)
subsite_id to determine theming information
-theme_dir (optional)
theming directory (alternative to determination via subsite), higher priority
Returns:
path of the resource (without extension)
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 ad_dimensional ad_dimensional (public) template::resource_path template::resource_path ad_dimensional->template::resource_path packages/acs-templating/tcl/tag-init.tcl packages/acs-templating/ tcl/tag-init.tcl packages/acs-templating/tcl/tag-init.tcl->template::resource_path template::dat_page_filter template::dat_page_filter (private) template::dat_page_filter->template::resource_path template::form::template template::form::template (private) template::form::template->template::resource_path template::list::element::render template::list::element::render (public) template::list::element::render->template::resource_path ad_conn ad_conn (public) template::resource_path->ad_conn parameter::get parameter::get (public) template::resource_path->parameter::get

Testcases:
No testcase defined.

template::stack_dump (public)

 template::stack_dump

Return the whole call stack as HTML

Partial Call Graph (max 5 caller/called nodes):
%3 stack_dump stack_dump (public, deprecated) template::stack_dump template::stack_dump stack_dump->template::stack_dump template::stack_frame_values template::stack_frame_values (private) template::stack_dump->template::stack_frame_values

Testcases:
No testcase defined.

template::stack_frame_values (private)

 template::stack_frame_values level

return the variables and arrays of one frame as HTML

Parameters:
level (required)

Partial Call Graph (max 5 caller/called nodes):
%3 template::stack_dump template::stack_dump (public) template::stack_frame_values template::stack_frame_values template::stack_dump->template::stack_frame_values

Testcases:
No testcase defined.

template::streaming_template (public)

 template::streaming_template [ -subsite_id subsite_id ]

Return the path of the streaming template

Switches:
-subsite_id (optional)
id of the subsite. Defaults to [ad_conn subsite_id]
Returns:
path to themed template

Partial Call Graph (max 5 caller/called nodes):
%3 Class ::xowf::test_item::Answer_manager Class ::xowf::test_item::Answer_manager (public) template::streaming_template template::streaming_template Class ::xowf::test_item::Answer_manager->template::streaming_template packages/acs-admin/www/apm/package-load-2.tcl packages/acs-admin/ www/apm/package-load-2.tcl packages/acs-admin/www/apm/package-load-2.tcl->template::streaming_template packages/acs-admin/www/apm/packages-install-4.tcl packages/acs-admin/ www/apm/packages-install-4.tcl packages/acs-admin/www/apm/packages-install-4.tcl->template::streaming_template packages/acs-admin/www/apm/write-all-specs.tcl packages/acs-admin/ www/apm/write-all-specs.tcl packages/acs-admin/www/apm/write-all-specs.tcl->template::streaming_template xowf::test_item::Answer_manager instproc render_answers xowf::test_item::Answer_manager instproc render_answers (public) xowf::test_item::Answer_manager instproc render_answers->template::streaming_template ad_conn ad_conn (public) template::streaming_template->ad_conn parameter::get parameter::get (public) template::streaming_template->parameter::get template::resource_path template::resource_path (public) template::streaming_template->template::resource_path

Testcases:
No testcase defined.

template::themed_template (public)

 template::themed_template [ -verbose ] path

Given a path like /packages/acs-admin/www/index pointing to an .adp file, this function tries to locate this path in the ResourceDir of the subsite (determined by the theme). If found the themed template is returned, otherwise the passed template path.

Switches:
-verbose (optional, boolean, defaults to "false")
Parameters:
path (required)
absolute path within the open acs tree (without extension)
Returns:
path to themed template or input value (without extension)

Partial Call Graph (max 5 caller/called nodes):
%3 ad_page_contract ad_page_contract (public) template::themed_template template::themed_template ad_page_contract->template::themed_template adp_parse_ad_conn_file adp_parse_ad_conn_file (private) adp_parse_ad_conn_file->template::themed_template apidoc::xql_links_list apidoc::xql_links_list (private) apidoc::xql_links_list->template::themed_template apm_build_repository apm_build_repository (private) apm_build_repository->template::themed_template apm_git_build_repository apm_git_build_repository (private) apm_git_build_repository->template::themed_template template::resource_path template::resource_path (public) template::themed_template->template::resource_path

Testcases:
No testcase defined.

template::util::array_to_vars (public, deprecated)

 template::util::array_to_vars arrayname
Deprecated. Invoking this procedure generates a warning.

Declare local variables for every key in an array.

Parameters:
arrayname (required)
The name of an array in the calling frame. DEPRECATED: this is a trivial idiom that can just be inlined.
See Also:
  • array

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) template::util::array_to_vars template::util::array_to_vars template::util::array_to_vars->ad_log_deprecated

Testcases:
No testcase defined.

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 (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_get_opts get_opts (test acs-templating) template::util::get_opts template::util::get_opts test_get_opts->template::util::get_opts doc::get_proc_doc doc::get_proc_doc (private, deprecated) doc::get_proc_doc->template::util::get_opts publish::handle::image publish::handle::image (public) publish::handle::image->template::util::get_opts publish::handle::text publish::handle::text (public) publish::handle::text->template::util::get_opts publish::handle_binary_file publish::handle_binary_file (public) publish::handle_binary_file->template::util::get_opts publish::handle_item publish::handle_item (private) publish::handle_item->template::util::get_opts

Testcases:
get_opts

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 (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_get_url_directory get_url_directory (test acs-templating) template::util::get_url_directory template::util::get_url_directory test_get_url_directory->template::util::get_url_directory

Testcases:
get_url_directory

template::util::is_nil (public)

 template::util::is_nil ref

Determines whether a variable both exists and is not an empty string.

Parameters:
ref (required)
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 nonempty scalar.

Partial Call Graph (max 5 caller/called nodes):
%3 test_util_is_nil util_is_nil (test acs-templating) template::util::is_nil template::util::is_nil test_util_is_nil->template::util::is_nil content::get_content content::get_content (public) content::get_content->template::util::is_nil packages/acs-templating/tcl/tag-init.tcl packages/acs-templating/ tcl/tag-init.tcl packages/acs-templating/tcl/tag-init.tcl->template::util::is_nil publish::foreach_publish_path publish::foreach_publish_path (private) publish::foreach_publish_path->template::util::is_nil publish::get_main_item_id publish::get_main_item_id (private) publish::get_main_item_id->template::util::is_nil publish::get_main_revision_id publish::get_main_revision_id (private) publish::get_main_revision_id->template::util::is_nil

Testcases:
util_is_nil

template::util::is_true (public, deprecated)

 template::util::is_true x
Deprecated. Invoking this procedure generates a warning.

interprets its argument as a boolean.

Parameters:
x (required)
the value to test DEPRECATED 5.10.1: since October 2015 this proc is implemented via the standard Tcl idiom "string is true -strict ..." that can be easily inlined.
Returns:
0 if the variable can be interpreted as false; 1 for true if it can't.
See Also:
  • string

Partial Call Graph (max 5 caller/called nodes):
%3 packages/directory/www/index.tcl packages/directory/ www/index.tcl template::util::is_true template::util::is_true packages/directory/www/index.tcl->template::util::is_true ad_log_deprecated ad_log_deprecated (public) template::util::is_true->ad_log_deprecated

Testcases:
No testcase defined.

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 (required)
The name of a database table.
columns (required)
A list of columns on which to select the row.
values (required)
A list of values for each specified column.
Returns:
1 if the row exists, 0 if not

Partial Call Graph (max 5 caller/called nodes):
%3 db_string db_string (public) template::util::is_unique template::util::is_unique template::util::is_unique->db_string

Testcases:
No testcase defined.

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 (required)
array_ref (required)

Partial Call Graph (max 5 caller/called nodes):
%3 callback::acs_mail_lite::incoming_email::impl::bug-tracker callback::acs_mail_lite::incoming_email::impl::bug-tracker (private) template::util::list_of_lists_to_array template::util::list_of_lists_to_array callback::acs_mail_lite::incoming_email::impl::bug-tracker->template::util::list_of_lists_to_array ref_countries::get_country_code ref_countries::get_country_code (public) ref_countries::get_country_code->template::util::list_of_lists_to_array

Testcases:
No testcase defined.

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 (e.g. 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 (optional, defaults to "1")
How many levels up the stack to place the new datasource, defaults to 1 level up.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::list_to_array (public, deprecated)

 template::util::list_to_array values array_ref columns
Deprecated. Invoking this procedure generates a warning.

Converts a list of values into an array, using a list of corresponding column names for the array keys.

Parameters:
values (required)
A list of values
array_ref (required)
The name of the array to create in the calling frame.
columns (required)
A list of column names to use for the array keys. The length of this list should be the same as the values list. DEPRECATED: as of August 2022 no OpenACS code is using this proc. The operation it implements can be easily achieved via plain Tcl idioms.
See Also:
  • array

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) template::util::list_to_array template::util::list_to_array template::util::list_to_array->ad_log_deprecated

Testcases:
No testcase defined.

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 (required)
A list of values
array_ref (required)
The name of the array to create in the calling frame.

Partial Call Graph (max 5 caller/called nodes):
%3 test_util_list_to_lookup util_list_to_lookup (test acs-templating) template::util::list_to_lookup template::util::list_to_lookup test_util_list_to_lookup->template::util::list_to_lookup packages/categories/www/categories-browse.tcl packages/categories/ www/categories-browse.tcl packages/categories/www/categories-browse.tcl->template::util::list_to_lookup packages/categories/www/include/widget.tcl packages/categories/ www/include/widget.tcl packages/categories/www/include/widget.tcl->template::util::list_to_lookup template::element::options template::element::options (private) template::element::options->template::util::list_to_lookup template::paginator::get_data template::paginator::get_data (public) template::paginator::get_data->template::util::list_to_lookup template::paginator::get_query template::paginator::get_query (public) template::paginator::get_query->template::util::list_to_lookup

Testcases:
util_list_to_lookup

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 (required)
the name of a multirow data source
rows (required)
a representation of a multirow data source as a list, suitable for passing by value in the form { { row } { row } { row } ... }
level (optional, defaults to "1")
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-api-browser/www/content-page-view.tcl packages/acs-api-browser/ www/content-page-view.tcl template::util::list_to_multirow template::util::list_to_multirow packages/acs-api-browser/www/content-page-view.tcl->template::util::list_to_multirow packages/acs-automated-testing/www/admin/proc-coverage.tcl packages/acs-automated-testing/ www/admin/proc-coverage.tcl packages/acs-automated-testing/www/admin/proc-coverage.tcl->template::util::list_to_multirow packages/acs-lang/www/admin/index.tcl packages/acs-lang/ www/admin/index.tcl packages/acs-lang/www/admin/index.tcl->template::util::list_to_multirow packages/categories/www/cadmin/index.tcl packages/categories/ www/cadmin/index.tcl packages/categories/www/cadmin/index.tcl->template::util::list_to_multirow packages/forums/lib/message/post.tcl packages/forums/ lib/message/post.tcl packages/forums/lib/message/post.tcl->template::util::list_to_multirow

Testcases:
No testcase defined.

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 (required)
value (required)
Either a list or scalar value to store in the list.
next (required)
A key value that determines the next node to traverse outward in the data structure.

Partial Call Graph (max 5 caller/called nodes):
%3 template::query::nestedlist template::query::nestedlist (private) template::util::lnest template::util::lnest template::query::nestedlist->template::util::lnest

Testcases:
No testcase defined.

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 (required)
The name of a list in the calling frame on which to operate.

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) template::util::lpop template::util::lpop test_create_form_with_form_instance->template::util::lpop test_xowiki_test_cases xowiki_test_cases (test xowiki) test_xowiki_test_cases->template::util::lpop apm::process_install_xml apm::process_install_xml (public) apm::process_install_xml->template::util::lpop photo_album::search::photo::datasource photo_album::search::photo::datasource (private) photo_album::search::photo::datasource->template::util::lpop template::adp_eval template::adp_eval (public) template::adp_eval->template::util::lpop template::adp_include template::adp_include (public) template::adp_include->template::util::lpop template::adp_parse template::adp_parse (public) template::adp_parse->template::util::lpop

Testcases:
xowiki_test_cases, create_form_with_form_instance

template::util::master_to_file (public)

 template::util::master_to_file url [ reference_url ]

Resolve a URL into an absolute file path, but respect styled master configuration for named masters (e.g. acs-templating/resources/masters/... containing 2cols.adp)

Parameters:
url (required)
reference_url (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-templating/tcl/tag-init.tcl packages/acs-templating/ tcl/tag-init.tcl template::util::master_to_file template::util::master_to_file packages/acs-templating/tcl/tag-init.tcl->template::util::master_to_file template::resource_path template::resource_path (public) template::util::master_to_file->template::resource_path

Testcases:
No testcase defined.

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 (required)
name of the multirow
column_ref (required)
name of the column to be
Author:
simon

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

template::util::multirow_to_list (public)

 template::util::multirow_to_list [ -level level ] name

generate a list structure representative 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 (optional, defaults to "1")
Parameters:
name (required)
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:

Partial Call Graph (max 5 caller/called nodes):
%3 packages/workflow/www/admin/workflow-ae.tcl packages/workflow/ www/admin/workflow-ae.tcl template::util::multirow_to_list template::util::multirow_to_list packages/workflow/www/admin/workflow-ae.tcl->template::util::multirow_to_list packages/workflow/www/admin/workflow-clone.tcl packages/workflow/ www/admin/workflow-clone.tcl packages/workflow/www/admin/workflow-clone.tcl->template::util::multirow_to_list

Testcases:
No testcase defined.

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 (required)
start_at (optional, defaults to "0")

Partial Call Graph (max 5 caller/called nodes):
%3 test_number_list number_list (test acs-templating) template::util::number_list template::util::number_list test_number_list->template::util::number_list

Testcases:
number_list

template::util::nvl (public, deprecated)

 template::util::nvl value value_if_null
Deprecated. Invoking this procedure generates a warning.

Analogous to SQL NVL DEPRECATED: a plain Tcl oneliner can easily replace this proc

Parameters:
value (required)
value_if_null (required)
See Also:
  • expr {$value ne "" ? $value : $value_if_null}

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) template::util::nvl template::util::nvl template::util::nvl->ad_log_deprecated

Testcases:
No testcase defined.

template::util::read_file (public)

 template::util::read_file path

Reads a text file.

Parameters:
path (required)
The absolute path to the file
Returns:
A string with the contents of the file.

Partial Call Graph (max 5 caller/called nodes):
%3 test_read_write_file read_write_file (test acs-templating) template::util::read_file template::util::read_file test_read_write_file->template::util::read_file test_sync_file_get_document sync_file_get_document (test acs-authentication) test_sync_file_get_document->template::util::read_file ad_try ad_try (public) template::util::read_file->ad_try template::util::set_file_encoding template::util::set_file_encoding (public) template::util::read_file->template::util::set_file_encoding aa_test::parse_install_file aa_test::parse_install_file (public) aa_test::parse_install_file->template::util::read_file aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->template::util::read_file acs::disk_cache_eval acs::disk_cache_eval (public) acs::disk_cache_eval->template::util::read_file api_add_calling_info_to_procdoc api_add_calling_info_to_procdoc (private) api_add_calling_info_to_procdoc->template::util::read_file apidoc::get_xql_snippet apidoc::get_xql_snippet (private) apidoc::get_xql_snippet->template::util::read_file

Testcases:
sync_file_get_document, read_write_file

template::util::resolve_directory_url (public)

 template::util::resolve_directory_url url

Resolve the filename for a directory URL

Parameters:
url (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

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 (required)
The id of the file to set encoding for.
Author:
Peter Marklund

Partial Call Graph (max 5 caller/called nodes):
%3 test_read_write_file read_write_file (test acs-templating) template::util::set_file_encoding template::util::set_file_encoding test_read_write_file->template::util::set_file_encoding template::util::read_file template::util::read_file (public) template::util::read_file->template::util::set_file_encoding template::util::write_file template::util::write_file (public) template::util::write_file->template::util::set_file_encoding

Testcases:
read_write_file

template::util::url_to_file (public)

 template::util::url_to_file url [ reference_url ]

Resolve a URL into an absolute file path.

Parameters:
url (required)
reference_url (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 ad_parse_template ad_parse_template (public) template::util::url_to_file template::util::url_to_file ad_parse_template->template::util::url_to_file ad_return_template ad_return_template (public) ad_return_template->template::util::url_to_file packages/acs-templating/tcl/tag-init.tcl packages/acs-templating/ tcl/tag-init.tcl packages/acs-templating/tcl/tag-init.tcl->template::util::url_to_file packages/faq/www/try.tcl packages/faq/ www/try.tcl packages/faq/www/try.tcl->template::util::url_to_file template::adp_include template::adp_include (public) template::adp_include->template::util::url_to_file

Testcases:
No testcase defined.

template::util::vars_to_array (public, deprecated)

 template::util::vars_to_array arrayname [ args... ]
Deprecated. Invoking this procedure generates a warning.

Place local variables into an array

Parameters:
arrayname (required)
The name of an array in the calling frame.
See Also:
  • array

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) template::util::vars_to_array template::util::vars_to_array template::util::vars_to_array->ad_log_deprecated

Testcases:
No testcase defined.

template::util::write_file (public)

 template::util::write_file path text

Writes a text file

Parameters:
path (required)
The absolute path to the file
text (required)
A string containing the text to write to the file.

Partial Call Graph (max 5 caller/called nodes):
%3 test_read_write_file read_write_file (test acs-templating) template::util::write_file template::util::write_file test_read_write_file->template::util::write_file template::util::set_file_encoding template::util::set_file_encoding (public) template::util::write_file->template::util::set_file_encoding aa_test::write_test_file aa_test::write_test_file (private) aa_test::write_test_file->template::util::write_file acs::disk_cache_eval acs::disk_cache_eval (public) acs::disk_cache_eval->template::util::write_file auth::authority::batch_sync auth::authority::batch_sync (public) auth::authority::batch_sync->template::util::write_file content::deploy content::deploy (public, deprecated) content::deploy->template::util::write_file content::init content::init (public) content::init->template::util::write_file

Testcases:
read_write_file
[ show source ]