Commit e6b7adeb authored by Frank Bergmann's avatar Frank Bergmann

- Comitting OpenACS 5.9

parent 6356dc02
This diff is collapsed.
This diff is collapsed.
<html><head><title>Datasource for @code_stub@</title></head>
<body bgcolor=white>
<body bgcolor="white">
<h3>Data sources for @code_stub@.acs</h3>
<multiple name="datasources">
<b>@datasources.name@</b>
<table>
<tr><td align=left>Type:</td><td>@datasources.structure@</td></tr>
<tr><td align="left">Type:</td><td>@datasources.structure@</td></tr>
<tr><td>Comments:</td><td>@datasources.comment@</td></tr>
<if @datasources.structure@ in multirow multilist>
<tr><th align=left>Columns:</th><tr>
<tr><td align=left colspan=2>
<tr><th align="left">Columns:</th><tr>
<tr><td align="left" colspan="2">
<blockquote>
<table border=0 cellpadding=0 cellspacing=1>
<table border="0" cellpadding="0" cellspacing="1">
<group column="name">
<tr><th align=right valign=top>@datasources.column_name@</th><td>&nbsp;&nbsp;</td><td>@datasources.column_comment@</td><tr>
<tr><th align="right" valign="top">@datasources.column_name@</th><td>&nbsp;&nbsp;</td><td>@datasources.column_comment@</td><tr>
</group>
</table>
</blockquote>
</if>
<if @datasources.structure@ in form>
<tr><th align=left>Input options:</th><tr>
<tr><td align=left colspan=2>
<tr><th align="left">Input options:</th><tr>
<tr><td align="left" colspan="2">
<blockquote>
<table border=0 cellpadding=0 cellspacing=1>
<table border="0" cellpadding="0" cellspacing="1">
<group column="name">
<tr><th align=right valign=top>@datasources.input_name@</th><td>&nbsp;&nbsp;</td><td><i>@datasources.input_type@</i>; @datasources.input_comment@</td><tr>
<tr><th align="right" valign="top">@datasources.input_name@</th><td>&nbsp;&nbsp;</td><td><i>@datasources.input_type@</i>; @datasources.input_comment@</td><tr>
</group>
</table>
</blockquote>
......
......@@ -8,82 +8,82 @@
-- openacs port: vinod kurup vkurup@massmed.org
--
create function inline_0 ()
returns integer as '
begin
CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$
BEGIN
PERFORM acs_object_type__create_type (
''template_demo_note'', -- object_type
''Template Demo Note'', -- pretty_name
''Template Demo Notes'', -- pretty_plural
''acs_object'', -- supertype
''template_demo_notes'', -- table_name
''template_demo_note_id'', -- id_column
'template_demo_note', -- object_type
'Template Demo Note', -- pretty_name
'Template Demo Notes', -- pretty_plural
'acs_object', -- supertype
'template_demo_notes', -- table_name
'template_demo_note_id', -- id_column
null, -- package_name
''f'', -- abstract_p
'f', -- abstract_p
null, -- type_extension_table
''template_demo_note.name'' -- name_method
'template_demo_note.name' -- name_method
);
return 0;
end;' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
select inline_0 ();
drop function inline_0 ();
create function inline_1 ()
returns integer as '
begin
CREATE OR REPLACE FUNCTION inline_1 () RETURNS integer AS $$
BEGIN
PERFORM acs_attribute__create_attribute (
''template_demo_note'', -- object_type
''title'', -- attribute_name
''string'', -- datatype
''Title'', -- pretty_name
''Titles'', -- pretty_plural
'template_demo_note', -- object_type
'title', -- attribute_name
'string', -- datatype
'Title', -- pretty_name
'Titles', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
'type_specific', -- storage
'f' -- static_p
);
PERFORM acs_attribute__create_attribute (
''template_demo_note'', -- object_type
''body'', -- attribute_name
''string'', -- datatype
''Body'', -- pretty_name
''Bodies'', -- pretty_plural
'template_demo_note', -- object_type
'body', -- attribute_name
'string', -- datatype
'Body', -- pretty_name
'Bodies', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
'type_specific', -- storage
'f' -- static_p
);
PERFORM acs_attribute__create_attribute (
''template_demo_note'', -- object_type
''color'', -- attribute_name
''string'', -- datatype
''Color'', -- pretty_name
''Colors'', -- pretty_plural
'template_demo_note', -- object_type
'color', -- attribute_name
'string', -- datatype
'Color', -- pretty_name
'Colors', -- pretty_plural
null, -- table_name
null, -- column_name
null, -- default_value
1, -- min_n_values
1, -- max_n_values
null, -- sort_order
''type_specific'', -- storage
''f'' -- static_p
'type_specific', -- storage
'f' -- static_p
);
return 0;
end;' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
select inline_1 ();
......@@ -103,22 +103,32 @@ create table template_demo_notes (
color text
);
select define_function_args('template_demo_note__new','template_demo_note_id,title,body,color,object_type;template_demo_note,creation_date;now,creation_user,creation_ip,context_id');
create function template_demo_note__new (integer,varchar,varchar,varchar,varchar,timestamptz,integer,varchar,integer)
returns integer as '
declare
p_template_demo_note_id alias for $1; -- default null
p_title alias for $2;
p_body alias for $3;
p_color alias for $4;
p_object_type alias for $5; -- default ''template_demo_note''
p_creation_date alias for $6; -- default now()
p_creation_user alias for $7; -- default null
p_creation_ip alias for $8; -- default null
p_context_id alias for $9; -- default null
-- old define_function_args('template_demo_note__new','template_demo_note_id,title,body,color,object_type;template_demo_note,creation_date;now,creation_user,creation_ip,context_id')
-- new
select define_function_args('template_demo_note__new','template_demo_note_id;null,title,body,color,object_type;template_demo_note,creation_date;now,creation_user;null,creation_ip;null,context_id;null');
--
-- procedure template_demo_note__new/9
--
CREATE OR REPLACE FUNCTION template_demo_note__new(
p_template_demo_note_id integer, -- default null
p_title varchar,
p_body varchar,
p_color varchar,
p_object_type varchar, -- default 'template_demo_note'
p_creation_date timestamptz, -- default now() -- default 'now'
p_creation_user integer, -- default null
p_creation_ip varchar, -- default null
p_context_id integer -- default null
) RETURNS integer AS $$
DECLARE
v_template_demo_note_id template_demo_notes.template_demo_note_id%TYPE;
begin
BEGIN
v_template_demo_note_id := acs_object__new (
p_template_demo_note_id,
p_object_type,
......@@ -137,47 +147,63 @@ begin
PERFORM acs_permission__grant_permission(
v_template_demo_note_id,
p_creation_user,
''admin''
'admin'
);
end if;
return v_template_demo_note_id;
end;' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
select define_function_args('template_demo_note__del','template_demo_note_id');
create function template_demo_note__del (integer)
returns integer as '
declare
p_template_demo_note_id alias for $1;
begin
--
-- procedure template_demo_note__del/1
--
CREATE OR REPLACE FUNCTION template_demo_note__del(
p_template_demo_note_id integer
) RETURNS integer AS $$
DECLARE
BEGIN
delete from acs_permissions
where object_id = p_template_demo_note_id;
delete from template_demo_notes
where template_demo_note_id = p_template_demo_note_id;
raise NOTICE ''Deleting note...'';
raise NOTICE 'Deleting note...';
PERFORM acs_object__delete(p_template_demo_note_id);
return 0;
end;' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
create function template_demo_note__name (integer)
returns varchar as '
declare
p_template_demo_note_id alias for $1;
-- added
select define_function_args('template_demo_note__name','template_demo_note_id');
--
-- procedure template_demo_note__name/1
--
CREATE OR REPLACE FUNCTION template_demo_note__name(
p_template_demo_note_id integer
) RETURNS varchar AS $$
DECLARE
v_template_demo_note_name template_demo_notes.title%TYPE;
begin
BEGIN
select title into v_template_demo_note_name
from template_demo_notes
where template_demo_note_id = p_template_demo_note_id;
return v_template_demo_note_name;
end;
' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
-- neophytosd
......
......@@ -14,18 +14,25 @@ drop function template_demo_note__name (integer);
delete from acs_permissions where object_id in (select template_demo_note_id from template_demo_notes);
--drop objects
create function inline_0 ()
returns integer as '
declare
--
-- procedure inline_0/0
--
CREATE OR REPLACE FUNCTION inline_0(
) RETURNS integer AS $$
DECLARE
object_rec record;
begin
for object_rec in select object_id from acs_objects where object_type=''template_demo_note''
BEGIN
for object_rec in select object_id from acs_objects where object_type='template_demo_note'
loop
perform acs_object__delete( object_rec.object_id );
end loop;
return 0;
end;' language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
select inline_0();
drop function inline_0();
......
create function template__make_sample_data() returns integer
as
'
declare
CREATE function template__make_sample_data(
)
RETURNS integer AS $$
DECLARE
security_context_root int4;
default_context int4;
registered_users int4;
unregistered_visitor int4;
owning_party int4;
context int4;
begin
security_context_root := acs__magic_object_id(''security_context_root'');
default_context := acs__magic_object_id(''default_context'');
registered_users := acs__magic_object_id(''registered_users'');
unregistered_visitor := acs__magic_object_id(''unregistered_visitor'');
BEGIN
security_context_root := acs__magic_object_id('security_context_root');
default_context := acs__magic_object_id('default_context');
registered_users := acs__magic_object_id('registered_users');
unregistered_visitor := acs__magic_object_id('unregistered_visitor');
context := default_context;
owning_party := unregistered_visitor;
......@@ -20,11 +22,11 @@ begin
perform template_demo_note__new
(
NULL,
''title01'',
''body01'',
''red'',
'title01',
'body01',
'red',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -34,11 +36,11 @@ begin
perform template_demo_note__new
(
NULL,
''title02'',
''body02'',
''blue'',
'title02',
'body02',
'blue',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -48,11 +50,11 @@ begin
perform template_demo_note__new
(
NULL,
''title03'',
''body03'',
''green'',
'title03',
'body03',
'green',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -62,11 +64,11 @@ begin
perform template_demo_note__new
(
NULL,
''title04'',
''body04'',
''orange'',
'title04',
'body04',
'orange',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -76,11 +78,11 @@ begin
perform template_demo_note__new
(
NULL,
''title05'',
''body05'',
''purple'',
'title05',
'body05',
'purple',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -90,11 +92,11 @@ begin
perform template_demo_note__new
(
NULL,
''title06'',
''body06'',
''red'',
'title06',
'body06',
'red',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -104,11 +106,11 @@ begin
perform template_demo_note__new
(
NULL,
''title07'',
''body07'',
''blue'',
'title07',
'body07',
'blue',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -118,11 +120,11 @@ begin
perform template_demo_note__new
(
NULL,
''title08'',
''body08'',
''green'',
'title08',
'body08',
'green',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -132,11 +134,11 @@ begin
perform template_demo_note__new
(
NULL,
''title09'',
''body09'',
''orange'',
'title09',
'body09',
'orange',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -146,11 +148,11 @@ begin
perform template_demo_note__new
(
NULL,
''title10'',
''body10'',
''purple'',
'title10',
'body10',
'purple',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -160,11 +162,11 @@ begin
perform template_demo_note__new
(
NULL,
''title11'',
''body11'',
''red'',
'title11',
'body11',
'red',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -174,11 +176,11 @@ begin
perform template_demo_note__new
(
NULL,
''title12'',
''body12'',
''blue'',
'title12',
'body12',
'blue',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -188,11 +190,11 @@ begin
perform template_demo_note__new
(
NULL,
''title13'',
''body13'',
''green'',
'title13',
'body13',
'green',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -202,11 +204,11 @@ begin
perform template_demo_note__new
(
NULL,
''title14'',
''body14'',
''orange'',
'title14',
'body14',
'orange',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -216,11 +218,11 @@ begin
perform template_demo_note__new
(
NULL,
''title15'',
''body15'',
''purple'',
'title15',
'body15',
'purple',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -230,11 +232,11 @@ begin
perform template_demo_note__new
(
NULL,
''title16'',
''body16'',
''red'',
'title16',
'body16',
'red',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -244,11 +246,11 @@ begin
perform template_demo_note__new
(
NULL,
''title17'',
''body17'',
''blue'',
'title17',
'body17',
'blue',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -258,11 +260,11 @@ begin
perform template_demo_note__new
(
NULL,
''title18'',
''body18'',
''green'',
'title18',
'body18',
'green',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -272,11 +274,11 @@ begin
perform template_demo_note__new
(
NULL,
''title19'',
''body19'',
''orange'',
'title19',
'body19',
'orange',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -286,11 +288,11 @@ begin
perform template_demo_note__new
(
NULL,
''title20'',
''body20'',
''purple'',
'title20',
'body20',
'purple',
''template_demo_note'',
'template_demo_note',
now(),
owning_party,
NULL,
......@@ -298,9 +300,9 @@ begin
);
return context;
end;
'
language 'plpgsql';
END;
$$ LANGUAGE plpgsql;
select template__make_sample_data();
......
......@@ -16,11 +16,11 @@ ad_proc -public template_tag { name arglist body } {
} {
# LARS:
# We only ns_register_adptag the tag if it hasn't already been registered
# We only ns_adp_registerscript the tag if it hasn't already been registered
# (if the proc doesn't exist).
# This makes debugging templating tags so much easier, because you don't have
# to restart the server each time.
set exists_p [llength [info procs template_tag_$name]]
set exists_p [llength [info commands template_tag_$name]]
switch [llength $arglist] {
......@@ -37,7 +37,7 @@ ad_proc -public template_tag { name arglist body } {
}"
if { !$exists_p } {
ns_register_adptag $name template_tag_$name
ns_adp_registerscript $name template_tag_$name
}
}
......@@ -59,7 +59,7 @@ ad_proc -public template_tag { name arglist body } {
}"
if { !$exists_p } {
ns_register_adptag $name /$name template_tag_$name
ns_adp_registerscript $name /$name template_tag_$name
}
}
......
......@@ -12,7 +12,7 @@
# http://www.fsf.org/copyleft/gpl.html
ad_proc -public ad_return_template {
-string:boolean
-string:boolean
{template ""}
} {
This function is a wrapper for sundry template:: procs. Will set the
......@@ -21,16 +21,16 @@ ad_proc -public ad_return_template {
@param template Name of template file
@param string If specified, will return the resulting page to the caller
string instead sending it to the connection.
string instead sending it to the connection.
} {
if {$template ne ""} {
template::set_file \
[template::util::url_to_file $template [ad_conn file]]
template::set_file \
[template::util::url_to_file $template [ad_conn file]]
}
if { $string_p } {
return [template::adp_parse \
[template::util::url_to_file $template [ad_conn file]] {}]
return [template::adp_parse \
[template::util::url_to_file $template [ad_conn file]] {}]
}
}
......@@ -53,12 +53,8 @@ ad_proc -public ad_parse_template {
set template_params [list]
foreach param $params {
switch [llength $param] {
1 { lappend template_params "&"
lappend template_params [lindex $param 0]
}
2 { lappend template_params [lindex $param 0]
lappend template_params [lindex $param 1]
}
1 { lappend template_params "&" [lindex $param 0] }
2 { lappend template_params [lindex $param 0] [lindex $param 1] }
default { return -code error [_ acs-templating.Template_parser_error_in_parameter_list] }
}
}
......@@ -88,18 +84,18 @@ ad_proc -public ad_return_exception_template {
ad_proc -public get_server_root {} {
Get the server root directory (supposing we run under ACS)
} {
file dir [ns_info tcllib]
return $::acs::rootdir
}
ad_proc adp_parse_ad_conn_file {} {
handle a request for an adp and/or tcl file in the template system.
} {
namespace eval template variable parse_level ""
#ns_log debug "adp_parse_ad_conn_file => file '[file root [ad_conn file]]'"
set ::template::parse_level ""
#ns_log debug "adp_parse_ad_conn_file => file '[file rootname [ad_conn file]]'"
template::reset_request_vars
set parsed_template [template::adp_parse [file root [ad_conn file]] {}]
set parsed_template [template::adp_parse [file rootname [ad_conn file]] {}]
if {$parsed_template ne ""} {
......@@ -108,6 +104,7 @@ ad_proc adp_parse_ad_conn_file {} {
#
if { [lang::util::translator_mode_p] } {
set apm_package_url [apm_package_url_from_key "acs-lang"]
# Attempt to move all message keys outside of tags
while { [regsub -all {(<[^>]*)(\x002\(\x001[^\x001]*\x001\)\x002)([^>]*>)} $parsed_template {\2\1\3} parsed_template] } {}
......@@ -124,9 +121,9 @@ ad_proc adp_parse_ad_conn_file {} {
if { [string first "</select" [string tolower $select]] != -1 } {
set start [lindex $indices 1]
} else {
set before [string range $parsed_template 0 [expr {[lindex $indices 0]-1}]]
set before [string range $parsed_template 0 [lindex $indices 0]-1]
set message [string range $parsed_template [lindex $message_idx 0] [lindex $message_idx 1]]
set after [string range $parsed_template [expr {[lindex $indices 1] + 1}] end]
set after [string range $parsed_template [lindex $indices 1]+1 end]
set parsed_template "${before}${message}${select}${after}"
}
}
......@@ -134,27 +131,27 @@ ad_proc adp_parse_ad_conn_file {} {
# TODO: We could also move message keys out of <head>...</head>
while { [regexp -indices {\x002\(\x001([^\x001]*)\x001\)\x002} $parsed_template indices key] } {
set before [string range $parsed_template 0 [expr {[lindex $indices 0] - 1}]]
set after [string range $parsed_template [expr {[lindex $indices 1] + 1}] end]
set before [string range $parsed_template 0 [lindex $indices 0]-1]
set after [string range $parsed_template [lindex $indices 1]+1 end]
set key [string range $parsed_template [lindex $key 0] [lindex $key 1]]
lassign [split $key "."] package_key message_key
set keyv [split $key "."]
set package_key [lindex $keyv 0]
set message_key [lindex $keyv 1]
set edit_url [export_vars -base "[apm_package_url_from_key "acs-lang"]admin/edit-localized-message" { { locale {[ad_conn locale]} } package_key message_key { return_url [ad_return_url] } }]
set edit_url [export_vars -base "${apm_package_url}admin/edit-localized-message" {
{ locale {[ad_conn locale]} } package_key message_key { return_url [ad_return_url] } }]
if { [lang::message::message_exists_p [ad_conn locale] $key] } {
set edit_link "<a href=\"$edit_url\" title=\"$key\" style=\"color: green;\"><b>o</b></a>"
set edit_link [subst {<a href="[ns_quotehtml $edit_url]" title="$key" style="color: green;"><b>o</b></a>}]
} else {
if { [lang::message::message_exists_p "en_US" $key] } {
# Translation missing in this locale
set edit_link "<a href=\"$edit_url\" title=\"$key\" style=\"background-color: yellow; color: red;\"><b>*</b></a>"
set edit_link [subst {<a href="[ns_quotehtml $edit_url]" title="$key" style="background-color: yellow; color: red;"><b>*</b></a>}]
} else {
# Message key missing entirely
set new_url [export_vars -base "[apm_package_url_from_key "acs-lang"]admin/localized-message-new" { { locale en_US } package_key message_key { return_url [ad_return_url] } }]
set edit_link "<a href=\"$new_url\" title=\"$key\" style=\"background-color: red; color: white;\"><b>@</b></a>"
set new_url [export_vars -base "${apm_package_url}admin/localized-message-new" {
{ locale en_US } package_key message_key { return_url [ad_return_url] }
}]
set edit_link [subst {<a href="[ns_quotehtml $new_url]" title="$key" style="background-color: red; color: white;"><b>@</b></a>}]
}
}
......@@ -164,9 +161,16 @@ ad_proc adp_parse_ad_conn_file {} {
set mime_type [template::get_mime_type]
set header_preamble [template::get_mime_header_preamble $mime_type]
doc_return 200 $mime_type "$header_preamble$parsed_template"
doc_return 200 $mime_type "$header_preamble$parsed_template"
} else {
db_release_unused_handles
}
}
#
# Local variables:
# mode: tcl
# tcl-indent-level: 4
# indent-tabs-mode: nil
# End:
......@@ -68,8 +68,6 @@ namespace eval template {
namespace eval wizard {
# stack level at which wizard is created
variable parse_level
# An array of default buttons and their names
variable default_button_labels
array set default_button_labels \
......@@ -81,9 +79,6 @@ namespace eval template {
namespace eval paginator {
# stack level at which paginator is created
variable parse_level
# Default values for paginator properties
variable defaults
set defaults [list pagesize 20 timeout 600 groupsize 10 page_offset 0]
......@@ -94,9 +89,6 @@ namespace eval template {
namespace eval transform {}
}
# keep track of the stack frame in which a template is rendered at run-time
variable parse_level
# used for compiling Tcl code from ADP template
variable parse_list
......
......@@ -24,7 +24,7 @@ namespace eval template::widget::currency {}
ad_proc -public template::util::currency { command args } {
Dispatch procedure for the currency object
} {
eval template::util::currency::$command $args
template::util::currency::$command {*}$args
}
ad_proc -public template::util::currency::create {
......@@ -212,7 +212,7 @@ ad_proc -public template::util::currency::set_property {
set whole_part "[string range "0" [string length $whole_part] end]$whole_part"
# Chop off trailing digits beyond those called for by the given format
set fractional_part "[string range $fractional_part 0 [expr {[lindex $format 3] - 1}]]"
set fractional_part "[string range $fractional_part 0 [lindex $format 3]-1]"
}
set new_value [lreplace $currency_list 1 1 $whole_part]
return [lreplace $new_value 3 3 $fractional_part]
......
......@@ -69,7 +69,7 @@ ad_proc -public template::data::validate::naturalnum {
} {
Validates natural numbers data types.
Will trim leading 0 in order to avoid TCL interpreting it as octal (code borrowed
Will trim leading 0 in order to avoid Tcl interpreting it as octal (code borrowed
from ad_page_contract_filter_proc_naturalnum)
@author Rocael Hernandez <roc@viaro.net>
......@@ -79,7 +79,7 @@ ad_proc -public template::data::validate::naturalnum {
@return True (1) if valid, false (0) if not
} {
upvar 2 $message_ref message $value_ref value
upvar 2 $message_ref message $value_ref value
set result [regexp {^(0*)(([1-9][0-9]*|0))$} $value match zeros value]
......@@ -364,7 +364,7 @@ ad_proc -public template::data::validate::textdate {
upvar 2 $message_ref message $value_ref textdate
set error_msg [list]
if { [exists_and_not_null textdate] } {
if { ([info exists textdate] && $textdate ne "") } {
if { [regexp {^[0-9]{4}-[0-9]{2}-[0-9]{2}$} $textdate match] } {
if { [catch { clock scan "${textdate}" }] } {
# the textdate is formatted properly the template::data::transform::textdate proc
......@@ -380,7 +380,7 @@ ad_proc -public template::data::validate::textdate {
set maxdays [template::util::date::get_property days_in_month $datelist]
if { $day < 1 || $day > $maxdays } {
set month_pretty [template::util::date::get_property long_month_name $datelist]
if { $month == "2" } {
if { $month == 2 } {
# February has a different number of days depending on the year
append month_pretty " ${year}"
}
......@@ -434,10 +434,8 @@ ad_proc -public template::data::transform {
@param type The data type to be transformed.
} {
set proc_name [info procs ::template::data::transform::$type]
set proc_name [info commands ::template::data::transform::$type]
if { $proc_name ne {} } {
transform::$type $value_ref
}
}
......@@ -490,7 +488,7 @@ ad_proc -public template::data::validate::enumeration {
# unique list
set list [split $value ,]
set result [expr [llength $list] == [llength [lsort -unique $list]]]
set result [expr {[llength $list] == [llength [lsort -unique $list]]}]
if { ! $result } {
set message "Invalid enumeration. \"$value\" does not contain unique values."
......
This diff is collapsed.
......@@ -8,9 +8,9 @@ ad_proc -public watch_files {} {
foreach file $files {
set file [ns_info tcllib]/$file
set file $::acs::tcllib/$file
set proc_name [info procs ::template::mtimes::tcl::$file]
set proc_name [info commands ::template::mtimes::tcl::$file]
set mtime [file mtime $file]
if { $proc_name eq {} || $mtime != [$proc_name] } {
......
......@@ -13,11 +13,8 @@
# @datasource foo multirow
# Output info about a foo.
# @column name The name of the foo.
# @column id The ID of the foo.
# @param id
# The ID of the foo passed with the request.
# @param column name The name of the foo.
# @param id The ID of the foo passed with the request.
namespace eval template {}
......
......@@ -42,9 +42,8 @@ ad_proc -private doc::sort_@see { list_ref directive_comments } {
procedure to deal with @see comments
} {
upvar $list_ref see_list
set type [lindex $directive_comments 0]
set see_name [lindex $directive_comments 1]
set url [lindex $directive_comments 2]
lassign $directive_comments type see_name url
if {$url eq "" } {
switch -exact $type {
......@@ -57,7 +56,7 @@ ad_proc -private doc::sort_@see { list_ref directive_comments } {
set split_name $see_name
doc::util::text_divider split_name ::
set name_length [llength $split_name]
set see_namespace [join [lrange $split_name 0 [expr {$name_length - 2}]] ""]
set see_namespace [join [lrange $split_name 0 $name_length-2] ""]
set url "[doc::util::dbl_colon_fix $see_namespace].html#[set see_name]"
}
}
......@@ -92,7 +91,7 @@ ad_proc -private doc::util::find_marker_indices { text marker } {
while { [regexp -indices $marker $text marker_idx] } {
lappend indices_list [expr {[lindex $marker_idx 0] + $last_index}]
set text [string range $text [expr {[lindex $marker_idx 1] + 1}] end]
set text [string range $text [lindex $marker_idx 1]+1 end]
set last_index [expr {[lindex $marker_idx 1] + $last_index + 1}]
}
......@@ -137,10 +136,12 @@ ad_proc -private doc::util::text_divider { text_ref marker } {
return 1
}
ad_proc -private template::util::server_root {} {
ad_proc -private -deprecated template::util::server_root {} {
uses ns_library to find the server root, may not always be accurate
because it essentially asks for the tcl library path and
strips off the last /tcl directory
strips off the last /tcl directory.
@see use $::acs::rootdir instead
} {
set path_length [expr [llength [file split [ns_library private]]] - 1]
......@@ -168,8 +169,10 @@ ad_proc -private template::util::write_from_template { template file_name} {
}
ad_proc -private template::util::display_value { ref } {
ad_proc -private -deprecated template::util::display_value { ref } {
a proc used for debugging, just prints out a value to the error log
@see use simple "ns_log ...." instead
} {
upvar $ref value
ns_log notice "$ref: $value
......@@ -177,15 +180,18 @@ ad_proc -private template::util::display_value { ref } {
}
ad_proc -private template::util::proper_noun { string_ref } {
ad_proc -private -deprecated template::util::proper_noun { string_ref } {
capitalizes the first letter of a string
@return returns formatted string (UNFINISHED. FIXME.)
@see use "string totitle ..."
} {
}
ad_proc -private template::util::string_range { string indices } {
ad_proc -private -deprecated template::util::string_range { string indices } {
@see use "string range instead"
} {
return [string range $string [lindex $indices 0] [lindex $indices 1]]
}
......@@ -273,9 +279,7 @@ ad_proc -private template::util::alphabetized_index {list entry} {
ad_proc -private template::util::proc_element_compare { element1 element2 } {
used to compare two different elements in a list of parsed data for public or private procs
} {
return [string compare -nocase [lindex [lindex [lindex $element2 1] 0] 1] [lindex [lindex [lindex $element1 1] 0] 1]]
return [string compare -nocase [lindex $element2 1 0 1] [lindex $element1 1 0 1]]
}
ad_proc -private doc::set_proc_name_source_text_comment_text { proc_block } {
......@@ -468,9 +472,9 @@ ad_proc -private doc::parse_namespace { text_lines } {
set namespace_entry [lindex $total_result_listing [lsearch -exact $namespace_list $namespace_name]]
set namespace_info [lindex [lindex $namespace_entry 0] 1]
set namespace_public [lindex [lindex $namespace_entry 1] 1]
set namespace_private [lindex [lindex $namespace_entry 2] 1]
set namespace_info [lindex $namespace_entry 0 1]
set namespace_public [lindex $namespace_entry 1 1]
set namespace_private [lindex $namespace_entry 2 1]
} else {
set namespace_info [list name "$namespace_name" overview "$namespace_description" author "$namespace_author" see "$namespace_see"]
......@@ -603,7 +607,7 @@ ad_proc -private doc::parse_tcl_library { dir_list } {
foreach dir $dir_list {
#debug
template::util::display_value dir
#template::util::display_value dir
# using this lame hack since most aD servers are running an earlier version of Tcl than 8.3,
# which supports the -directory switch that this hack emulates
......@@ -612,7 +616,7 @@ ad_proc -private doc::parse_tcl_library { dir_list } {
}
#debugging
template::util::display_value file_list
#template::util::display_value file_list
foreach tcl_file $file_list {
ns_log notice "doc::parse_tcl_library: parsing through $tcl_file for documentation"
......
......@@ -44,7 +44,7 @@ ad_proc -public template::element { command form_id element_id args } {
@see template::form
} {
eval template::element::$command $form_id $element_id $args
template::element::$command $form_id $element_id {*}$args
}
ad_proc -public template::element::create { form_id element_id args } {
......@@ -139,7 +139,7 @@ ad_proc -public template::element::create { form_id element_id args } {
@see template::widget
@see template::data::validate
@see template::form::create
@see template::form::section
@see template::form::section
} {
set level [template::adp_level]
......@@ -172,11 +172,12 @@ ad_proc -public template::element::create { form_id element_id args } {
# set the form section
set opts(section) $form_properties(section)
if { $opts(section) ne "" } {
set opts(sec_fieldset) $form_properties(sec_fieldset)
set opts(sec_legend) $form_properties(sec_legend)
set opts(sec_legendtext) $form_properties(sec_legendtext)
}
if { $opts(section) ne "" } {
array set opts {sec_fieldset "" sec_legend "" sec_legendtext ""}
if {[info exists form_properties(sec_fieldset)]} {set opts(sec_fieldset) $form_properties(sec_fieldset)}
if {[info exists form_properties(sec_legend)]} {set opts(sec_legend) $form_properties(sec_legend)}
if {[info exists form_properties(sec_legendtext)]} {set opts(sec_legendtext) $form_properties(sec_legendtext)}
}
template::util::get_opts $args
......@@ -188,8 +189,7 @@ ad_proc -public template::element::create { form_id element_id args } {
# If the widget is a submit widget, remember it
# All submit widgets are optional
if { $opts(widget) eq "submit" || \
[string equal $opts(widget) "button"] } {
if { $opts(widget) eq "submit" || $opts(widget) eq "button" } {
set form_properties(has_submit) 1
set opts(optional) 1
if { ! [info exists opts(value)] } { set opts(value) $opts(label) }
......@@ -197,8 +197,7 @@ ad_proc -public template::element::create { form_id element_id args } {
}
# If the widget is a checkbox or radio widget, set attributes
if { $opts(widget) eq "radio" || \
[string equal $opts(widget) "checkbox"] } {
if { $opts(widget) eq "radio" || $opts(widget) eq "checkbox" } {
# If there's no legend text, no point to generate the fieldset
if { ![info exists opts(legendtext)] } {
......@@ -218,7 +217,7 @@ ad_proc -public template::element::create { form_id element_id args } {
append fs_options " class=\"form-fieldset\""
}
foreach name [array names fs_attributes] {
if {$fs_attributes($name) eq {}} {
if {$fs_attributes($name) eq ""} {
append fs_options " $name"
} else {
append fs_options " $name=\"$fs_attributes($name)\""
......@@ -228,12 +227,12 @@ ad_proc -public template::element::create { form_id element_id args } {
# set legend attributes
if { ![info exists opts(legend)] } {
set opts(legend) {}
set opts(legend) ""
}
array set lg_attributes $opts(legend)
set lg_options ""
foreach name [array names lg_attributes] {
if {$lg_attributes($name) eq {}} {
if {$lg_attributes($name) eq ""} {
append lg_options " $name"
} else {
append lg_options " $name=\"$lg_attributes($name)\""
......@@ -251,7 +250,7 @@ ad_proc -public template::element::create { form_id element_id args } {
# check for submission
if { [template::form is_submission $form_id] || [info exists opts(param)] } {
validate $form_id $element_id
} elseif { ![empty_string_p [ns_queryget "__edit"]] } {
} elseif { [ns_queryget "__edit"] ne "" } {
# If the magic __edit button was hit, try to get values from the form still
# but don't do any validation
set opts(values) [querygetall opts]
......@@ -262,14 +261,14 @@ ad_proc -public template::element::create { form_id element_id args } {
}
}
if { [string equal $opts(widget) "hidden"]
if { $opts(widget) eq "hidden"
&& [info exists opts(sign)]
&& $opts(sign)
} {
if {[info exists opts(value)] } {
set val $opts(value)
} else {
set val {}
set val ""
}
template::element::create $opts(form_id) $opts(id):sig \
-datatype text \
......@@ -296,7 +295,7 @@ ad_proc -public template::element::set_properties { form_id element_id args } {
template::util::get_opts $args
if { [string equal $opts(widget) "hidden"]
if { $opts(widget) eq "hidden"
&& [info exists opts(sign)]
&& $opts(sign)
&& [info exists opts(value)] } {
......@@ -355,6 +354,7 @@ ad_proc -public template::element::get_value { form_id element_id } {
get_reference
if { [info exists element(value)] } {
regsub {<script>} $element(value) {\<\s\c\r\i\p\t\>} element(value)
return $element(value)
} else {
return ""
......@@ -374,7 +374,7 @@ ad_proc -public template::element::get_values { form_id element_id } {
@see template::element::get_value
} {
get_reference
regsub {<script>} $element(values) {\<\s\c\r\i\p\t\>} element(values)
return $element(values)
}
......@@ -426,7 +426,7 @@ ad_proc -private template::element::validate { form_id element_id } {
set is_optional [info exists element(optional)]
# if the element is optional and the value is an empty string, then ignore
if { $is_optional && [string equal [lindex $values 0] {}] } {
if { $is_optional && [lindex $values 0] eq "" } {
set values [list]
# also clobber the value(s) for a submit widget
......@@ -438,13 +438,13 @@ ad_proc -private template::element::validate { form_id element_id } {
# if no values were submitted then look for values specified in the
# declaration (either values or value)
if { ! [llength $values] && [info exists element(values)] } {
if { [llength $values] == 0 && [info exists element(values)] } {
set values $element(values)
}
# set a label for use in the template
set label $element(label)
if {$label eq {}} {
if {$label eq ""} {
set label $element(name)
}
......@@ -453,13 +453,13 @@ ad_proc -private template::element::validate { form_id element_id } {
set is_inform [expr {$element(widget) eq "inform" || ($element(mode) ne "edit" && $element(mode) ne "" )}]
# Check for required element
if { ! $is_inform && ! $is_optional && ! [llength $values] } {
if { ! $is_inform && ! $is_optional && ![llength $values] } {
# no value was submitted for a required element
set formerror($element_id) [_ acs-templating.Element_is_required]
set formerror($element_id:required) [_ acs-templating.Element_is_required]
if { [lsearch -exact {hidden submit} $element(widget)] > -1 } {
if {$element(widget) in {hidden submit}} {
ns_log Warning "template::element::validate: No value for hidden/submit element $label"
}
}
......@@ -475,7 +475,7 @@ ad_proc -private template::element::validate { form_id element_id } {
# a single anonymous validation check was specified
set element(validate) [linsert $element(validate) 0 "anonymous"]
} elseif { [expr {$v_length % 3}] } {
} elseif { $v_length % 3 } {
error "Invalid number of parameters to validate option:
$element(validate) (Length is $v_length)"
......@@ -596,7 +596,7 @@ ad_proc -public template::element::querygetall { element_ref } {
set transform_proc "::template::data::transform::$datatype"
if {[info procs $transform_proc] eq {}} {
if {[info commands $transform_proc] eq ""} {
set values [ns_querygetall $element(id)]
......@@ -725,7 +725,7 @@ ad_proc -private template::element::options { form_id element_id tag_attributes
upvar #$level formgroup:$i formgroup
set option [lindex $options [expr {$i - 1}]]
set option [lindex $options $i-1]
set value [lindex $option 1]
if { ![info exists values($value)] } {
......@@ -746,8 +746,13 @@ ad_proc -private template::element::copy_value_to_values_if_defined {} {
define values from value, if the latter is more defined
} {
upvar opts opts
# values is always defined, init to "" from template::element::defaults
# opts(values) is always defined, init to "" from template::element::defaults
if { [info exists opts(value)] && [llength $opts(values)] == 0 } {
#
# GN: the following test is broken, since "opts(value)" is never
# empty; ... but changing this to a comparison with $opts(value)
# breaks eg ad_form.
#
if { [string equal opts(value) {}] } {
set opts(values) [list]
} else {
......
......@@ -27,7 +27,7 @@ ad_proc -public template::forward { url args } {
set cache_p [lindex $args 0]
if {$cache_p eq "t"} {
if {$cache_p == "t"} {
set persistent_p [lindex $args 1]
set excluded_vars [lindex $args 2]
......@@ -76,7 +76,7 @@ ad_proc -public cmp_page_filter { why } {
set url [ns_conn url]
regsub {.cmp} $url {} url_stub
regexp {^/([^/]*)(.*)} $url_stub all package_key rest
set file_stub "[acs_root_dir]/packages/$package_key/www$rest"
set file_stub "$::acs::rootdir/packages/$package_key/www$rest"
set beginTime [clock clicks -milliseconds]
......@@ -102,7 +102,7 @@ ad_proc -public dat_page_filter { why } {
set url [ns_conn url]
regsub {.dat} $url {} url_stub
regexp {^/([^/]*)(.*)} $url_stub all package_key rest
set code_stub "[acs_root_dir]/packages/$package_key/www$rest"
set code_stub "$::acs::rootdir/packages/$package_key/www$rest"
set beginTime [clock clicks -milliseconds]
......@@ -136,11 +136,10 @@ namespace eval template {
set url [ns_conn url]
regsub {.frm} $url {} url_stub
regexp {^/([^/]*)(.*)} $url_stub all package_key rest
set __adp_stub "[acs_root_dir]/packages/$package_key/www$rest"
set __adp_stub "$::acs::rootdir/packages/$package_key/www$rest"
# Set the parse level
variable parse_level
lappend parse_level [info level]
lappend ::templating::parse_level [info level]
# execute the code to prepare the form(s) for a template
adp_prepare
......
This diff is collapsed.
......@@ -18,35 +18,29 @@ ad_proc -private template::reset_request_vars {} {
returned document. This should be called at the beginning of any request
handled by the templating system.
} {
variable ::template::head::scripts
array unset scripts
array set scripts [list]
array unset ::template::head::scripts
#array set ::template::head::scripts [list]
variable ::template::head::links
array unset links
array set links [list]
array unset ::template::head::links
#array set ::template::head::links [list]
variable ::template::head::metas
array unset metas
array set metas [list]
array unset ::template::head::metas
#array set ::template::head::metas [list]
variable ::template::body_handlers
array unset body_handlers
array set body_handlers [list]
array unset ::template::body_handlers
#array set ::template::head::body_handlers [list]
variable ::template::body_scripts
array unset body_scripts
set body_scripts [list]
array unset ::template::body_scripts
#array set ::template::body_scripts [list]
variable ::template::headers
set headers [list]
variable ::template::footers
set footers [list]
set ::template::headers [list]
set ::template::footers [list]
}
ad_proc -public template::head::add_script {
{-type:required}
{-defer:boolean}
{-async:boolean}
{-src ""}
{-charset ""}
{-script ""}
......@@ -62,6 +56,8 @@ ad_proc -public template::head::add_script {
@param type the type attribute of the script tag, eg. 'text/javascript'
@param defer whether execution of the script should be defered until after
the page has been loaded
@param async whether execution of the script should be executed asynchronously
as soon as it is available
@param src the src attribute of the script tag, ie. the source url of the
script
@param charset the charset attribute of the script tag, ie. the character
......@@ -78,14 +74,20 @@ ad_proc -public template::head::add_script {
set defer ""
}
if {$async_p} {
set async async
} else {
set async ""
}
if {$src eq ""} {
if {$script eq ""} {
error "You must supply either -src or -script."
}
lappend scripts(anonymous) $type "" $charset $defer $script $order
lappend scripts(anonymous) $type "" $charset $defer $async $script $order
} else {
set scripts($src) [list $type $src $charset $defer "" $order]
set scripts($src) [list $type $src $charset $defer $async "" $order]
}
}
......@@ -192,6 +194,7 @@ ad_proc -public template::head::add_style {
ad_proc -public template::head::add_javascript {
{-defer:boolean}
{-async:boolean}
{-src ""}
{-charset ""}
{-script ""}
......@@ -203,6 +206,8 @@ ad_proc -public template::head::add_javascript {
@param defer whether execution of the script should be defered until after
the page has been loaded
@param async whether execution of the script should be executed asynchronously
as soon as it is available
@param src the src attribute of the script tag, ie. the source url of the
script
@param charset the charset attribute of the script tag, ie. the character
......@@ -213,7 +218,7 @@ ad_proc -public template::head::add_javascript {
@see template::head::add_script
} {
template::head::add_script -defer=$defer_p \
template::head::add_script -defer=$defer_p -async=$async_p \
-type text/javascript \
-src $src \
-charset $charset \
......@@ -315,6 +320,7 @@ ad_proc -public template::add_body_handler {
ad_proc -public template::add_body_script {
{-type:required}
{-defer:boolean}
{-async:boolean}
{-src ""}
{-charset ""}
{-script ""}
......@@ -325,6 +331,8 @@ ad_proc -public template::add_body_script {
@param type the type attribute of the script tag, eg. 'text/javascript'
@param defer whether execution of the script should be defered until after
the page has been loaded
@param async whether execution of the script should be executed asynchronously
as soon as it is available
@param src the src attribute of the script tag, ie. the source url of the
script
@param charset the charset attribute of the script tag, ie. the character
......@@ -340,12 +348,17 @@ ad_proc -public template::add_body_script {
} else {
set defer ""
}
if {$async_p} {
set async async
} else {
set async ""
}
if {$src eq "" && $script eq ""} {
error "You must supply either -src or -script."
}
lappend body_scripts $type $src $charset $defer $script
lappend body_scripts $type $src $charset $defer $async $script
}
ad_proc -public template::add_header {
......@@ -520,15 +533,16 @@ ad_proc template::head::prepare_multirows {} {
# Generate the head <script /> tag multirow
variable ::template::head::scripts
template::multirow create headscript type src charset defer content order
template::multirow create headscript type src charset defer async content order
if {[array exists scripts]} {
foreach name [array names scripts] {
foreach {type src charset defer content order} $scripts($name) {
foreach {type src charset defer async content order} $scripts($name) {
template::multirow append headscript \
$type \
$src \
$charset \
$defer \
$async \
$content \
$order
}
......@@ -539,14 +553,15 @@ ad_proc template::head::prepare_multirows {} {
# Generate the body <script /> tag multirow
variable ::template::body_scripts
template::multirow create body_script type src charset defer content
template::multirow create body_script type src charset defer async content
if {[info exists body_scripts]} {
foreach {type src charset defer content} $body_scripts {
foreach {type src charset defer async content} $body_scripts {
template::multirow append body_script \
$type \
$src \
$charset \
$defer \
$async \
$content
}
unset body_scripts
......
This diff is collapsed.
......@@ -35,7 +35,7 @@ ad_proc -public template::paginator { command args } {
@see template::paginator::get_row_last
@see template::paginator::reset
} {
eval paginator::$command $args
paginator::$command {*}$args
}
ad_proc -public template::paginator::create { statement_name name query args } {
......@@ -97,27 +97,48 @@ ad_proc -public template::paginator::create { statement_name name query args } {
set cache_key $name:$query
set row_ids [cache get $cache_key:row_ids]
if { ($row_ids eq {} && ![nsv_exists __template_cache_timeout $cache_key]) || ([info exists opts(flush_p)] && $opts(flush_p) eq "t") } {
# full number of rows returned by original paginator query
set full_row_count [cache get $cache_key:full_row_count]
#
# GN: In the following line, we had instead of [::cache exists
# $cache_key] the commdand [nsv_exists __template_cache_timeout
# $cache_key] It is not clear, what the intended semantic was, and
# why not the API working on the nsv was used. See as well
# below. In general, using a test for a cache entry and a code
# depening on the cached entry is NOT AN GOOD idea, since the
# operations are not atomic. Between the check and the later code,
# the cache entry might be deleted. refactoring of this code is
# recommended. Unfortunately, several places in OpenACS have this
# problem.
#
if { ($row_ids eq {} && ![::cache exists $cache_key])
|| ([info exists opts(flush_p)] && $opts(flush_p) == "t") } {
if { [info exists opts(printing_prefs)] && $opts(printing_prefs) ne "" } {
ReturnHeaders "text/html"
ns_write "
<html>
<head>"
set title [lindex $opts(printing_prefs) 0]
ns_write "<title>$title</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
set stylesheet [lindex $opts(printing_prefs) 1]
if { $stylesheet ne "" } {
ns_write "<link rel=\"stylesheet\" href=\"$stylesheet\" type=\"text/css\">"
set css_link [subst {<link rel="stylesheet" href="[ns_quotehtml $stylesheet]" type="text/css">}]
} else {
set css_link ""
}
ns_write "</head>"
ns_write "<body "
set background [lindex $opts(printing_prefs) 2]
if { $background ne "" } {
ns_write "background=\"$background\""
set bg "background=\"$background\""
} else {
set bg ""
}
ns_write ">"
ad_return_top_of_page [subst {
<html>
<head>
<title>$title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
$css_link
</head>
<body $bg>
}]
set header_file [lindex $opts(printing_prefs) 3]
if { $header_file ne "" } {
ns_write [ns_adp_parse -file $header_file]
......@@ -131,26 +152,26 @@ ad_proc -public template::paginator::create { statement_name name query args } {
}
set return_url [lindex $opts(printing_prefs) 5]
if { $return_url ne "" } {
if { [llength $opts(row_ids)]==0 } {
nsv_set __template_cache_timeout $cache_key $opts(timeout)
}
ns_write "
<SCRIPT type=\"text/javascript\">
# Not sure, what the intented semantics of this command was...
#if { [llength $opts(row_ids)]==0 } {
# nsv_set __template_cache_timeout $cache_key $opts(timeout)
#}
ns_write [subst {
<script type="text/javascript">
<!-- Begin
document.location.href=\"$return_url\";
document.location.href="[ns_quotehtml $return_url]";
// End -->
</script>
<noscript>
<a href=\"$return_url\">Click here to Continue</a>
</noscript>"
<noscript><a href="[ns_quotehtml $return_url]">Click here to continue.</a></noscript>
}]
}
ns_write [ad_footer]
ad_script_abort
} else {
init $statement_name $name $query
}
} else {
set opts(row_ids) $row_ids
set opts(full_row_count) $full_row_count
set opts(context_ids) [cache get $cache_key:context_ids]
}
......@@ -169,17 +190,42 @@ ad_proc -private template::paginator::init { statement_name name query {print_p
upvar 2 __paginator_ids ids
set ids [list]
set full_statement_name [uplevel 2 "db_qd_get_fullname $statement_name"]
# Antonio Pisano 2015-11-17: to get the full rowcount of the records,
# we need to wrap the original query into a count(*). The problem comes
# with template::list, that builds the paginator query tampering with
# the original one, so if we come here from a template::list we cannot
# retrieve the real count anymore. I had to come out with a solution
# that wouldn't break existing contract for public procs, or this would
# have caused unpredictable regressions. Below is the strategy to get
# the original query.
# If query comes from an xql we get it from there...
set original_query [db_map $full_statement_name]
# ...otherwise we try to see if we come from a template::list...
if {$original_query eq ""} {
# ...which was slightly modified to keep the original query untampered.
set list_name [lindex [split $name ,] 0]
if {![catch {template::list::get_reference -name $list_name}]} {
set original_query $list_properties(page_query_original)
}
}
# If any of the previous fail, we go for the explicit query
if {$original_query eq ""} {
set original_query $query
}
if { [info exists properties(contextual)] } {
# query contains two columns, one for ID and one for context cue
uplevel 2 "
set full_statement_name \[db_qd_get_fullname $statement_name\]
# Can't use db_foreach here, since we need to use the ns_set directly.
db_with_handle db {
set selection \[db_exec select \$db \$full_statement_name {$query}\]
set selection \[db_exec select \$db $full_statement_name {$query}\]
set __paginator_ids \[list\]
set total_so_far 1
......@@ -211,12 +257,13 @@ ad_proc -private template::paginator::init { statement_name name query {print_p
set i 0
set page_size $properties(pagesize)
set context_ids [list]
set row_ids ""
foreach row $ids {
lappend row_ids [lindex $row 0]
if { [expr {$i % $page_size}] == 0 } {
if { $i % $page_size == 0 } {
lappend context_ids [lindex $row 1]
}
incr i
......@@ -225,11 +272,6 @@ ad_proc -private template::paginator::init { statement_name name query {print_p
set properties(context_ids) $context_ids
cache set $name:$query:context_ids $context_ids $properties(timeout)
if { [template::util::is_nil row_ids] } {
set row_ids ""
}
set properties(row_ids) $row_ids
cache set $name:$query:row_ids $row_ids $properties(timeout)
......@@ -269,6 +311,11 @@ ad_proc -private template::paginator::init { statement_name name query {print_p
set properties(row_ids) $ids
cache set $name:$query:row_ids $ids $properties(timeout)
}
# Get full number of rows retrieved by original paginator query
set full_row_count [uplevel 3 [list db_string query [db_map count_query]]]
set properties(full_row_count) $full_row_count
cache set $name:$query:full_row_count $full_row_count $properties(timeout)
}
ad_proc -public template::paginator::get_page { name rownum } {
......@@ -496,7 +543,7 @@ ad_proc -public template::paginator::get_context { name datasource pages } {
set row(rownum) $rowcount
set row(page) $page
set row(context) [lindex $context_ids [expr {$page - 1}]]
set row(context) [lindex $context_ids $page-1]
}
}
......@@ -546,6 +593,20 @@ ad_proc -public template::paginator::get_row_count { name } {
return $properties(row_count)
}
ad_proc -public template::paginator::get_full_row_count { name } {
Gets the total number of records returned by the original
paginator query. This is the 'true' row_count, which won't
be limited to number_of_pages * rows_per_page.
@param name The reference to the paginator object.
@return A number representing the full row count.
} {
get_reference
return $properties(full_row_count)
}
ad_proc -public template::paginator::get_page_count { name } {
Gets the total number of pages in the paginated query
......@@ -650,8 +711,8 @@ ad_proc -public template::paginator::get_display_info { name datasource page } {
# If the paginator is contextual, set the context
if { [info exists properties(context_ids)] } {
foreach elm { next_page previous_page next_group previous_group } {
if { [exists_and_not_null info($elm)] } {
set info(${elm}_context) [lindex $properties(context_ids) [expr {$info($elm) -1}]]
if { ([info exists info($elm)] && $info($elm) ne "") } {
set info(${elm}_context) [lindex $properties(context_ids) $info($elm)-1]
}
}
}
......
This diff is collapsed.
......@@ -12,7 +12,6 @@ ad_library {
namespace eval template {}
namespace eval template::query {}
# Database Query API for the ArsDigita Templating System
# Copyright (C) 1999-2000 ArsDigita Corporation
......@@ -24,18 +23,11 @@ namespace eval template::query {}
# License. Full text of the license is available from the GNU Project:
# http://www.fsf.org/copyleft/gpl.html
# (DCW - Openacs) converted template db api to use standard api and hooked it
# into the query-dispatcher. This ties into the standard db api's
# transaction control and handle allocation into the templating query interface
# allowing the two db api's to be mixed together.
# Todo - convert caching to use ns_cache.
nsv_set __template_query_persistent_cache . .
nsv_set __template_query_persistent_timeout . .
ad_proc -public template::query { statement_name result_name type sql args } {
Public interface to template query api. This routine parses the arguements and
dispatches to the query command specified by the type arguement.
......@@ -360,7 +352,7 @@ ad_proc -private template::query::nestedlist { statement_name db result_name sql
lappend group_values [ns_set get $row $group]
}
eval template::util::lnest rows [list $values] $group_values
template::util::lnest rows $values {*}$group_values
}
if { [info exists opts(cache)] } {
......@@ -439,25 +431,27 @@ ad_proc -private get_cached_result { name type } {
if { [info exists opts(persistent)] } {
if { [nsv_exists __template_query_persistent_cache $cache_key] } {
if { [ns_cache names template_query_cache $cache_key] ne ""} {
# check the timeout
if {[ns_info name] eq "NaviServer"} {
set cached_result [ns_cache_eval template_query_cache $cache_key {}]
} else {
# get the pair of the timeout and value
lassign [ns_cache get template_query_cache $cache_key] timeout cached_result
set timeout [nsv_get __template_query_persistent_timeout $cache_key]
if { $timeout > [ns_time] } {
set cached_result \
[nsv_get __template_query_persistent_cache $cache_key]
set success 1
# check the timeout
if { $timeout > [ns_time] } {
set success 1
} else {
ns_cache flush template_query_cache $cache_key
}
}
}
} else {
global __template_query_request_cache
if { [info exists __template_query_request_cache($cache_key)] } {
set cached_result $__template_query_request_cache($cache_key)
if { [info exists ::__template_query_request_cache($cache_key)] } {
set cached_result $::__template_query_request_cache($cache_key)
set success 1
}
}
......@@ -510,23 +504,30 @@ ad_proc -private set_cached_result {} {
set cache_key $opts(cache)
if { [info exists opts(persistent)] } {
# set the result in the persistent cache
nsv_set __template_query_persistent_cache $cache_key $opts(result)
#
# calculate the timeout
#
if { [info exists opts(timeout)] } {
set timeout [expr {[ns_time] + $opts(timeout)}]
} else {
set timeout [expr {[ns_time] + 60 * 60 * 24 * 7}]
}
}
nsv_set __template_query_persistent_timeout $cache_key $timeout
if {[ns_info name] eq "NaviServer"} {
#
# NaviServer allows per entry expire time
#
ns_cache_eval -expires $timeout -force template_query_cache $cache_key \
set _ $opts(result)
} else {
#
# set the cached value as a pair of timeout and value
#
ns_cache set template_query_cache $cache_key [list $timeout $opts(result)]
}
} else {
global __template_query_request_cache
set __template_query_request_cache($cache_key) $opts(result)
set ::__template_query_request_cache($cache_key) $opts(result)
}
}
......@@ -575,21 +576,23 @@ ad_proc -private template::query::flush_cache { cache_match } {
@param cache_match Name of query to match for cache flushing
} {
# Flush persistent cache
set names [nsv_array names __template_query_persistent_cache]
set names [ns_cache names template_query_cache]
foreach name $names {
if { [string match $cache_match $name] } {
ns_log debug "template::query::flush_cache: FLUSHING QUERY (persistent): $name"
nsv_unset __template_query_persistent_cache $name
ns_cache flush template_query_cache $name
if {[ns_info name] ne "NaviServer"} {
ns_cache flush template_timeout_cache $name
}
}
}
# Flush temporary cache
global __template_query_request_cache
set names [array names __template_query_persistent_cache]
set names [array names ::__template_query_persistent_cache]
foreach name $names {
if { [string match $cache_match $name] } {
ns_log debug "template::query::flush_cache: FLUSHING QUERY (request): $name"
unset __template_query_persistent_cache($name)
unset ::__template_query_persistent_cache($name)
}
}
......@@ -975,7 +978,7 @@ ad_proc -public template::multirow {
lappend sort_list [list $i $sortby]
}
set sort_list [eval lsort $sort_args -index 1 [list $sort_list]]
set sort_list [lsort {*}$sort_args -index 1 $sort_list]
# Now we have a list with two elms, (rownum, sort-by-value), sorted by sort-by-value
......@@ -1068,7 +1071,7 @@ ad_proc -public template::url { command args } {
nsv_set __template_cache_value . .
nsv_set __template_cache_timeout . .
ad_proc -public cache { command key args } {
ad_proc -public cache { command cache_key args } {
Generic Caching
} {
......@@ -1077,43 +1080,77 @@ ad_proc -public cache { command key args } {
switch -exact $command {
get {
if { [nsv_exists __template_cache_value $key] } {
# check the timeout
set timeout [nsv_get __template_cache_timeout $key]
if { $timeout > [ns_time] } {
set result [nsv_get __template_cache_value $key]
} else {
nsv_unset __template_cache_value $key
nsv_unset __template_cache_timeout $key
if {[ns_info name] eq "NaviServer"} {
if {[ns_cache_keys template_cache $cache_key] ne ""} {
set result [ns_cache_eval template_cache $cache_key {}]
}
} else {
if { [ns_cache names template_cache $cache_key] ne "" } {
# get timeout and value
lassign [ns_cache get template_cache $cache_key] timeout value
# validate timeout
if { $timeout > [ns_time] } {
set result $value
} else {
ns_cache flush template_cache $cache_key
}
}
}
}
set {
set value [lindex $args 0]
if { [llength $args] == 1 } {
set timeout [expr {[ns_time] + 60 * 60 * 24 * 7}]
} else {
set timeout [expr {[ns_time] + [lindex $args 1]}]
}
nsv_set __template_cache_value $key $value
nsv_set __template_cache_timeout $key $timeout
if {[ns_info name] eq "NaviServer"} {
#
# NaviServer allows per entry expire time
#
ns_cache_eval -expires $timeout -force template_cache $cache_key \
set _ [lindex $args 0]
} else {
#
# Use a pair for aolserver
#
ns_cache set template_cache $cache_key [list $timeout [lindex $args 0]]
}
}
flush {
# The key is actually a string match pattern
set names [nsv_array names __template_cache_value]
foreach name $names {
if { [string match $key $name] } {
ns_log debug "cache: FLUSHING CACHE: $name"
nsv_unset __template_cache_value $name
}
if {[ns_info name] eq "NaviServer"} {
ns_cache_flush -glob template_cache $cache_key
} else {
set names [ns_cache names template_cache]
foreach name $names {
if { [string match $cache_key $name] } {
ns_log debug "cache: FLUSHING CACHE: $name"
ns_cache flush template_cache $name
}
}
}
}
exists {
if {[ns_info name] eq "NaviServer"} {
set result [expr {[ns_cache_keys template_cache $cache_key] ne ""}]
} else {
if { [ns_cache get template_cache $cache_key cached_value] } {
# get timeout and value
lassign $cached_value timeout value
# validate timeout
if { $timeout > [ns_time] } {
set result 1
} else {
set result 0
}
} else {
set result 0
}
}
}
......
......@@ -28,7 +28,7 @@ ad_proc -public template::request {
} {
Dispatch procedure for requests.
} {
eval request::$command $args
request::$command {*}$args
}
ad_proc -public template::request::create { args } {
......@@ -39,7 +39,7 @@ ad_proc -public template::request::create { args } {
Equivalent to calling set_param for each parameter, but
requiring slightly less typing.
} {
eval template::form::create request $args
template::form::create request {*}$args
set level [template::adp_level]
......@@ -56,7 +56,7 @@ ad_proc -public template::request::create { args } {
set param [string trim $param]
if {$param eq {}} { continue }
eval set_param $param
set_param {*}$param
}
}
}
......@@ -89,7 +89,7 @@ ad_proc -public template::request::set_param { name args } {
@see template::element::create
} {
set level [template::adp_level]
eval template::element::create request $name $args
template::element::create request $name {*}$args
# Set a local variable with the parameter value but no
# clobber the variable if it already exists.
......
......@@ -17,7 +17,7 @@ namespace eval template::widget {}
ad_proc -public template::util::richtext_or_file { command args } {
Dispatch procedure for the richtext_or_file object
} {
eval template::util::richtext_or_file::$command $args
template::util::richtext_or_file::$command {*}$args
}
ad_proc -public template::util::richtext_or_file::create {
......@@ -238,7 +238,7 @@ ad_proc -public template::util::richtext_or_file::get_property { what richtext_o
return [ad_html_text_convert -from $mime_type -to "text/html" -- $text]
}
file {
return "<a href=\"$content_url\">Download file</a>"
return "<a href=\"[ns_quotehtml $content_url]\">Download file</a>"
}
}
return {}
......
......@@ -19,7 +19,7 @@ namespace eval template::data::from_sql {}
ad_proc -public template::util::richtext { command args } {
Dispatch procedure for the richtext object
} {
eval template::util::richtext::$command $args
template::util::richtext::$command {*}$args
}
ad_proc -public template::util::richtext::create {
......@@ -228,7 +228,7 @@ ad_proc -public -deprecated template::widget::richtext_htmlarea { element_refere
set attributes(id) "richtext__$element(form_id)__$element(id)"
if { [exists_and_not_null element(htmlarea_p)] } {
if { ([info exists element(htmlarea_p)] && $element(htmlarea_p) ne "") } {
set htmlarea_p [template::util::is_true $element(htmlarea_p)]
} else {
set htmlarea_p [parameter::get \
......@@ -451,7 +451,7 @@ ad_proc -public template::widget::richtext { element_reference tag_attributes }
}
}
if { [exists_and_not_null element(htmlarea_p)] } {
if { ([info exists element(htmlarea_p)] && $element(htmlarea_p) ne "") } {
set htmlarea_p [template::util::is_true $element(htmlarea_p)]
} else {
set htmlarea_p [parameter::get \
......@@ -567,7 +567,11 @@ ad_proc -public template::widget::richtext { element_reference tag_attributes }
set config_value [lindex $config_pair 1]
}
ns_log debug "tinymce: key $config_key value $config_value"
lappend pairslist "${config_key}:\"${config_value}\""
if {$config_value eq "true" || $config_value eq "false"} {
lappend pairslist "${config_key}:${config_value}"
} else {
lappend pairslist "${config_key}:\"${config_value}\""
}
}
foreach name [array names options] {
......
......@@ -15,7 +15,7 @@ namespace eval template::util::spellcheck {}
ad_proc -public template::util::spellcheck { command args } {
Dispatch procedure for the spellcheck object
} {
eval template::util::spellcheck::$command $args
template::util::spellcheck::$command {*}$args
}
ad_proc -public template::util::spellcheck::merge_text { element_id } {
......@@ -61,7 +61,7 @@ ad_proc -public template::data::transform::spellcheck {
# case 2, submission of the page showing errors: returns the corrected text.
set merge_text [template::util::spellcheck::merge_text $element(id)]
if { [set richtext_p [string equal "richtext" $element(datatype)]] } {
if { [set richtext_p $element(datatype) eq "richtext"] } {
# special treatment for the "richtext" datatype.
set format [template::util::richtext::get_property format [lindex $values 0]]
if { $merge_text ne "" } {
......@@ -161,6 +161,7 @@ ad_proc -public template::util::spellcheck::get_element_formtext {
-var_to_spellcheck:required
{-language ""}
-error_num_ref:required
{-no_abort:boolean 0}
-formtext_to_display_ref:required
{-just_the_errwords_ref ""}
} {
......@@ -168,6 +169,7 @@ ad_proc -public template::util::spellcheck::get_element_formtext {
@param text The string to check for spelling errors.
@param html_p Does the text have html in it? If so, we strip out html tags in the string we feed to ispell (or aspell).
@param no_abort_p Set this tue for testing purposes (e.g. aa_test).
@param var_to_spellcheck The name of the text input type or textarea that holds this text (eg., "email_body")
......@@ -198,10 +200,31 @@ ad_proc -public template::util::spellcheck::get_element_formtext {
# the HOME environment set, and setting env(HOME) doesn't appear
# to work from AOLserver.
set spelling_wrapper [file join [acs_root_dir] bin webspell]
set spelling_wrapper [file join $::acs::rootdir bin webspell]
if {![file executable $spelling_wrapper]} {
#
# In case no_abort is given we just return the error
# message. Otherwise an ad_return_error is raised and the
# script is ad_script_aborted.
#
if {!$no_abort_p} {
ad_return_error "Webspell could not be executed" \
"Spell-checking is enabled but the spell-check wrapper\
($::acs::rootdir/bin/webspell) returns not be executed.\
Check that the wrapper exists, and that its permissions are correct."
ad_script_abort
} else {
error $errmsg
}
}
set spellchecker_path [nsv_get spellchecker path]
#
# Force default language to en_US
#set ::env(LANG) en_US.UTF-8
# the --lang switch only works with aspell and if it is not present
# aspell's (or ispell's) default language will have to do.
set lang_and_enc "--encoding=utf-8"
......@@ -209,36 +232,31 @@ ad_proc -public template::util::spellcheck::get_element_formtext {
append lang_and_enc " --lang=$language"
}
# Caveat: The "open" arg must be a list (not a string) to allow the wrapper args to be the empty string
# (which $language will be when ispell is used, for instance)
#ns_log notice WRAPPER=[list |$spelling_wrapper [ns_info home] $spellchecker_path $lang_and_enc $dictionaryfile $tmpfile]
if { [catch { set ispell_proc [open [list |$spelling_wrapper [ns_info home] $spellchecker_path $lang_and_enc $dictionaryfile $tmpfile] r] } errmsg] } {
ad_return_error "Webspell could not be executed" "Spell-checking is enabled but the spell-check wrapper ([acs_root_dir]/bin/webspell) could not be executed. Check that the wrapper exists, and that its permissions are correct. <p>Here is the error message: <pre>$errmsg</pre>"
ad_script_abort
}
# read will occasionally error out with "interrupted system call",
# so retry a few times in the hopes that it will go away.
set try 0
set max_retry 10
while { [catch { set ispell_text [read -nonewline $ispell_proc] } errmsg]
&& $try < $max_retry } {
incr try
ns_log warning "template::util::spellcheck::get_element_formtext: spellchecker had a problem: $errmsg"
}
fconfigure $ispell_proc -blocking 0
if { [catch { close $ispell_proc } errmsg] } {
ad_return_error "No dictionary found" "Spell-checking is enabled but the spell-check dictionary could not be reached. Check that the dictionary exists, and that its permissions are correct. <p>Here is the error message: <pre>$errmsg</pre>"
ad_script_abort
if {[catch {
set ispell_lines [exec $spelling_wrapper [ns_info home] $spellchecker_path $lang_and_enc $dictionaryfile $tmpfile]
} errmsg]} {
#ns_log notice "errorMsg = $errmsg"
#
# In case no_abort is given we just return the error
# message. Otherwise an ad_return_error is raised and the
# script is ad_script_aborted.
#
if {!$no_abort_p} {
ad_return_error "No dictionary found" \
"Spell-checking is enabled but the spell-check dictionary\
could not be reached. Check that the dictionary exists,\
and that its permissions are correct.\
<p>Here is the error message: <pre>$errmsg</pre>"
ad_script_abort
} else {
error $errmsg
}
}
ns_unlink $tmpfile
if { $try == $max_retry } {
return -code error "webspell: Tried to execute spellchecker $max_retry times but it did not work out. Sorry!"
}
file delete $tmpfile
####
#
......@@ -246,7 +264,7 @@ ad_proc -public template::util::spellcheck::get_element_formtext {
#
####
set ispell_lines [split $ispell_text "\n"]
set ispell_lines [split $ispell_lines "\n"]
# Remove the version line.
if { [llength $ispell_lines] > 0 } {
set ispell_lines [lreplace $ispell_lines 0 0]
......@@ -350,7 +368,7 @@ ad_proc -public template::util::spellcheck::spellcheck_properties {
} {
upvar $element_ref element
if { [empty_string_p [set spellcheck_value [ns_queryget $element(id).spellcheck]]] } {
if { [set spellcheck_value [ns_queryget $element(id).spellcheck]] eq "" } {
# The user hasn't been able to state whether (s)he wants spellchecking to be performed or not.
# That's either because spell-checking is disabled for this element, or we're not dealing with a submit.
......@@ -358,9 +376,9 @@ ad_proc -public template::util::spellcheck::spellcheck_properties {
# Do the "cheap" checks first and then (if needed) read the parameter and do additional checks.
if { [string equal "display" $element(mode)] \
|| [info exists element(nospell)] \
|| [empty_string_p [nsv_get spellchecker path]] } {
if { $element(mode) eq "display"
|| [info exists element(nospell)]
|| [nsv_get spellchecker path] eq "" } {
set spellcheck_p 0
} else {
......@@ -371,9 +389,11 @@ ad_proc -public template::util::spellcheck::spellcheck_properties {
-parameter SpellcheckFormWidgets \
-default ""]]
set spellcheck_p [expr {[array size widget_info] \
&& ($element(widget) eq "richtext" || $element(widget) eq "textarea" || $element(widget) eq "text") \
&& [lsearch -exact [array names widget_info] $element(widget)] != -1}]
set spellcheck_p [expr {[array size widget_info]
&& ($element(widget) eq "richtext" ||
$element(widget) eq "textarea" ||
$element(widget) eq "text")
&& $element(widget) in [array names widget_info]}]
}
......
......@@ -41,7 +41,7 @@ ad_proc -public template::widget::tab {
}
set id $element(form_id)
set output "<a href=\"${url}${joiner}${id}_tab=$element(name)\">"
set output "<a href=\"[ns_quotehtml ${url}${joiner}${id}_tab=$element(name)]\">"
append output "$element(label)</a>"
} else {
append output "<b>$element(label)</b>"
......@@ -61,7 +61,7 @@ ad_proc -public template::tabstrip {
} {
Dispatch procedure for tabstrip.
} {
eval template::tabstrip::$command $args
template::tabstrip::$command {*}$args
}
# Create a new tabbed page
......@@ -79,7 +79,7 @@ ad_proc -public template::tabstrip::create {
set code [list template::form create $dlg_name]
# Determine cookie name
if { [template::util::is_nil opts(cookie_name)] } {
if { ![info exists opts(cookie_name)] } {
set cookie_name $dlg_name
} else {
set cookie_name $opts(cookie_name)
......@@ -87,14 +87,14 @@ ad_proc -public template::tabstrip::create {
lappend code -cookie_name $cookie_name
eval $code $args
{*}$code {*}$args
# Determine the current tab
set level [template::adp_level]
upvar #$level $dlg_name:properties form_properties
# Check parameters
if { ![template::util::is_nil opts(current_tab)] } {
if { [info exists opts(current_tab)] } {
set current_tab $opts(current_tab)
} else {
# Check http
......@@ -140,8 +140,8 @@ ad_proc -public template::tabstrip::add_tab {
# Set tab-specific params
if { [template::util::is_nil opts(base_url)] } {
if { ![template::util::is_nil properties(base_url)] } {
if { ![info exists opts(base_url)] } {
if { [info exists properties(base_url)] } {
# use global base_url
lappend code -base_url $properties(base_url)
} else {
......@@ -158,12 +158,12 @@ ad_proc -public template::tabstrip::add_tab {
lappend code -current 0
}
eval "$code $args"
{*}$code {*}$args
upvar #$level $dlg_name:$name element
# If this is the first tab being added, set it as current
if { [template::util::is_nil properties(current_tab)] } {
if { ![info exists properties(current_tab)] } {
set_current_tab $dlg_name [lindex $properties(element_names) 0] 3
}
......
......@@ -87,7 +87,7 @@ ad_proc -public template::widget::table::default_column_def {
upvar $level "tablewidget:${name}" widget
if { [template::util::is_nil widget(column_def)] } {
if { ![info exists widget(column_def)] } {
# Get the column definition based on the first row of the datasource
upvar $level "tw_${name}_rows:rowcount" rowcount
if { $rowcount < 1 } {
......@@ -113,8 +113,8 @@ ad_proc -public template::widget::table::prepare {
upvar $level "tablewidget:${name}" widget
# Get the rows
if { [template::util::is_nil widget(rows_data)] } {
if { [template::util::is_nil widget(query)] } {
if { ![info exists widget(rows_data)] } {
if { ![info exists widget(query)] } {
error "No row datasource available for tablewidget $name"
}
......@@ -122,14 +122,14 @@ ad_proc -public template::widget::table::prepare {
set sql_query $widget(query)
# Append the order by clause, if any
if { ![template::util::is_nil widget(orderby)] } {
if { [info exists widget(orderby)] } {
if { ![regexp -nocase "order +by" $sql_query match] } {
append sql_query "\n order by"
}
append sql_query " $widget(orderby)"
}
if { ![template::util::is_nil widget(column_def)] } {
if { [info exists widget(column_def)] } {
# Convert the column def list to an array for extra speed
upvar $level "tablewidget:${name}_column_def" column_arr
array set column_arr $widget(column_def)
......@@ -164,7 +164,7 @@ ad_proc -public template::widget::table::prepare {
}
if { ![template::util::is_nil widget(eval)] } {
if { [info exists widget(eval)] } {
append eval_code $widget(eval)
}
uplevel $level "
......@@ -173,7 +173,7 @@ ad_proc -public template::widget::table::prepare {
"
# Get the column definition if it does not exist
if { [template::util::is_nil widget(column_def)] } {
if { ![info exists widget(column_def)] } {
template::widget::table::default_column_def widget \
[expr {$level + 1}]
}
......@@ -185,7 +185,7 @@ ad_proc -public template::widget::table::prepare {
}
# Process the rows datasource and get the columns
if { [template::util::is_nil widget(columns_data)] } {
if { ![info exists widget(columns_data)] } {
upvar $level "tw_${name}_columns:rowcount" rowcount
# Get the base url for the page
......@@ -211,20 +211,19 @@ ad_proc -public template::widget::table::prepare {
set row(name) $column_name
set label [lindex $column 0]
if {$label eq {}} {
if {$label eq ""} {
set label $column_name
}
set orderby_clause [lindex $column 1]
if {$orderby_clause eq {}} {
if {$orderby_clause eq ""} {
set orderby_clause $column_name
}
if { [info exists widget(orderby)] && \
[string equal $column_name $widget(orderby)] } {
if { [info exists widget(orderby)] && $column_name eq $widget(orderby) } {
set row(html) "<b>$label</b>"
set row(selected) "t"
} else {
set row(html) "<a href=\"${url}${the_joiner}tablewidget:${name}_orderby\=$row(name)\">"
set row(html) "<a href=\"[ns_quotehtml ${url}${the_joiner}tablewidget:${name}_orderby\=$row(name)]\">"
append row(html) "$label</a>"
set row(selected) "f"
}
......@@ -243,8 +242,8 @@ template_tag tablewidget { chunk params } {
set style [ns_set iget $params style]
# Use the style unless the template is specified in the tag
if { [template::util::is_nil chunk] } {
if { [template::util::is_nil style] } {
if { $chunk eq "" } {
if { $style eq "" } {
template::adp_append_code "set __tablewidget_style \"$style\""
} else {
template::adp_append_code "set __tablewidget_style \"\$tablewidget:${name}(style)\""
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -41,7 +41,7 @@ ad_proc -public template::wizard { command args } {
@see template::wizard::submit
} {
eval wizard::$command $args
wizard::$command {*}$args
}
# create a wizard from a set of steps
......@@ -111,7 +111,7 @@ ad_proc -public template::wizard::create { args } {
set step [string trim $step]
if {$step eq {}} { continue }
eval add $step
add {*}$step
}
}
}
......@@ -566,7 +566,7 @@ ad_proc -public template::wizard::forward { } {
} elseif { [ns_queryexists wizard_submit_back] } {
set last_id [lindex $steps [expr {$current_index - 2}]]
set last_id [lindex $steps $current_index-2]
template::forward [get_forward_url $last_id] $cache_p $persistent_p $excluded_vars
} elseif { [ns_queryexists wizard_submit_repeat] } {
......@@ -626,9 +626,9 @@ ad_proc -public template::wizard::get_forward_url { step_id } {
if { [lsearch -exact [split [lindex [split $param ":"] 1] ","] "multiple"] != -1 } {
# Multiple
set param [lindex [split $param ":"] 0]
if { [lsearch -exact $multiple_listed $param] == -1 } {
if {$param ni $multiple_listed} {
foreach check_param $properties(params) {
if { [string equal [lindex [split $check_param ":"] 0] $param] } {
if { [lindex [split $check_param ":"] 0] eq $param } {
set value_list [ns_querygetall $param]
for { set i 0 } { $i < [llength $value_list] } { incr i } {
append url "&$param=[ns_urlencode [lindex $value_list $i]]"
......
......@@ -3,7 +3,7 @@
@indent@ @lt@if @false_condition@>
@indent@ fail '@false_label@' should be false
@indent@ @lt@/if>@lt@else>
<include src=include l="@cdr;noquote@" indent="@indent;noquote@ "
<include src=include l="@cdr;literal@" indent="@indent;noquote@ "
>@indent;noquote@ @lt;noquote@/else>
@indent@@lt@/if>@lt@else>
@indent@ fail '@true_label@' should be true
......
......@@ -126,7 +126,7 @@ Determines all the valid content methods for instantiating a content type. Possi
<dt><b>Returns:</b>
<dd>
A TCL list of all possible content methods
A Tcl list of all possible content methods
<dt><b>Options:</b>
<table>
......
......@@ -705,7 +705,7 @@ Delete the specified URL from the filesystem, for all revisions
</tr>
<tr><td>
<blockquote>
Execute some TCL code for each root path in the PublishRoots parameter
Execute some Tcl code for each root path in the PublishRoots parameter
</blockquote>
<dl>
......
......@@ -2,10 +2,12 @@
<head>
<title>ArsDigita Templating System, Content Management Tcl Procedure Specifications</title>
</head>
<body>
<frameset cols="20%,80%">
<frame src="namespace-list.html" name="namespaceListFrame">
<frame src="namespaces.html" name="mainFrame">
</frameset>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment