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