Index: openacs-4/packages/acs-object-management/acs-object-management.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/acs-object-management.info,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/acs-object-management.info 28 Jul 2009 23:35:08 -0000 1.1 +++ openacs-4/packages/acs-object-management/acs-object-management.info 27 Nov 2009 00:38:50 -0000 1.2 @@ -10,13 +10,13 @@ f acs-object-management - + Don Baccus API to manage all things objecty API and admin pages to create and edit object types. 0 - + Index: openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml 13 Aug 2009 00:15:05 -0000 1.2 +++ openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml 27 Nov 2009 00:38:50 -0000 1.3 @@ -6,43 +6,56 @@ Add an attribute Add checked attributes Add a Form element - Add a Form - Add a Type + Add Form + Add Type + add widget Add a View Attribute Add Attribute Default Value Edit Attribute Attribute Name - This name must be lower case, contain only letters and underscores, and contain no spaces. If not specified one will be generated for you. - Name of attribute displayed in forms. + This name must be lower case, contain only letters and underscores, and contain no spaces. + Human-friendly name of attribute displayed in forms, tables, etc. Plural form of pretty name. Attributes Available Attributes + Choose a widget Export code to recreate dynamic types and forms Tcl code to recreate selected dynamic types and forms Content Create Type Create View + Customize Widget delete Delete Datatype Delete checked attributes Dynamic Types Edit Form Name + edit widget + Edit widget parameters Chose the attrbiute for this widget. Form elements Export + Form Elements Form Name Form "%form_name%" + Form Forms + Form Widget + Help Text Inherited Attributes + Is Required + remove widget + Manage Form you must supply either -multirow or -indexed_array node 'element' must have either a 'name' attribute or an 'attribute' attribute. + No Object Type - Object View + View Parameter Parameter "%param%" Source @@ -58,15 +71,19 @@ Parameters Pretty Name Pretty Plural + Preview Widget Remove Remove Element from Form Required? Supertype + Types unable to retrieve widget parameter %name% for attribute %attribute_id% - returning "" as parameter value View View Attributes Views Widget + Widget Add/Edit -- Default Widget -- Choose widget type + Yes Index: openacs-4/packages/acs-object-management/lib/forms/generic.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/lib/forms/generic.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/lib/forms/generic.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/acs-object-management/lib/forms/generic.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/lib/forms/generic.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/lib/forms/generic.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,37 @@ +ad_page_contract { + + Includelet to handle generic add/edit operations for a non-content repository + object object_view. + + Adding a new object requires "create" on [ad_conn package_id]. + Editing an existing object requires "write" on the object. + +} " + ${object_view}_id:naturalnum,optional +" + +ad_form -name $object_view \ + -form [form::form_part -object_view $object_view] \ + -select_query_name select_values \ + -on_request { + if { [info exists ${object_view}_id] } { + permission::require_permission \ + -party_id [ad_conn user_id] \ + -object_id [set ${object_view}_id] \ + -privilege write + } else { + permission::require_permission \ + -party_id [ad_conn user_id] \ + -object_id [ad_conn package_id] \ + -privilege create + } +} -new_data { + object::new_from_form -object_view $object_view +} -edit_data { + object::update_from_form -object_view $object_view +} -after_submit { + if { [info exists return_url] } { + ad_returnredirect $return_url + ad_script_abort + } +} Index: openacs-4/packages/acs-object-management/lib/forms/generic.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/lib/forms/generic.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/lib/forms/generic.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + + + select * + from ${object_view} + where ${object_view}_id = [set ${object_view}_id] + + + + Index: openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/Attic/acs-kernel-changes-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql 27 Nov 2009 00:38:50 -0000 1.2 @@ -3,6 +3,11 @@ alter table acs_datatypes add column_check_expr text; alter table acs_datatypes add column_output_function text; +insert into acs_datatypes + (datatype, database_type) +values + ('richtext', 'text'); + -- Making user and person dynamic can lead to a broken web site, so -- for now at least I won't do it. Code using these types have assumptions -- about the existence of certain attributes, and of course deleting them @@ -41,7 +46,9 @@ '; comment on column acs_datatypes.column_check_expr is ' - Optional check constraint expression to declare for the type_specific database column. + Optional check constraint expression to declare for the type_specific database column. In + Oracle, for instance, the abstract "boolean" type is declared "text", with a column + check expression to restrict the values to "f" and "t". '; comment on column acs_datatypes.column_output_function is ' @@ -55,189 +62,217 @@ -- it possible to write a high-level type specification that works in both Oracle and PG. -- DRB: add double bigint etc if Oracle supports them +begin; -update acs_datatypes -set database_type = 'varchar', - column_size = '4000' -where datatype = 'string'; + update acs_datatypes + set database_type = 'varchar', + column_size = '250' + where datatype = 'url'; -update acs_datatypes -set database_type = 'boolean' -where datatype = 'boolean'; + update acs_datatypes + set database_type = 'varchar', + column_size = '4000' + where datatype = 'string'; -update acs_datatypes -set database_type = 'numeric', - column_size = '10,2' -where datatype = 'number'; + update acs_datatypes + set database_type = 'boolean' + where datatype = 'boolean'; -update acs_datatypes -set database_type = 'integer' -where datatype = 'integer'; + update acs_datatypes + set database_type = 'numeric', + column_size = '10,2' + where datatype = 'number'; -update acs_datatypes -set database_type = 'money' -where datatype = 'money'; + update acs_datatypes + set database_type = 'integer' + where datatype = 'integer'; -update acs_datatypes -set database_type = 'timestamp' -where datatype = 'date'; + update acs_datatypes + set database_type = 'money' + where datatype = 'money'; -update acs_datatypes -set database_type = 'timestamp' -where datatype = 'timestamp'; + update acs_datatypes + set database_type = 'timestamp' + where datatype = 'date'; -update acs_datatypes -set database_type = 'timestamp' -where datatype = 'time_of_day'; + update acs_datatypes + set database_type = 'timestamp' + where datatype = 'timestamp'; -update acs_datatypes -set database_type = 'varchar', - column_size = '100' -where datatype = 'enumeration'; + update acs_datatypes + set database_type = 'timestamp' + where datatype = 'time_of_day'; -update acs_datatypes -set database_type = 'varchar', - column_size = 200 -where datatype = 'email'; + update acs_datatypes + set database_type = 'varchar', + column_size = '100' + where datatype = 'enumeration'; -update acs_datatypes -set database_type = 'varchar', - column_size = 200 -where datatype = 'file'; + update acs_datatypes + set database_type = 'varchar', + column_size = 200 + where datatype = 'email'; -update acs_datatypes -set database_type = 'text' -where datatype = 'text'; + update acs_datatypes + set database_type = 'varchar', + column_size = 200 + where datatype = 'file'; -update acs_datatypes -set database_type = 'varchar', - column_size = 100 -where datatype = 'keyword'; + update acs_datatypes + set database_type = 'text' + where datatype = 'text'; -update acs_datatypes -set column_output_function = 'acs_datatype__timestamp_output_function' -where datatype = 'date'; + update acs_datatypes + set database_type = 'varchar', + column_size = 100 + where datatype = 'keyword'; -update acs_datatypes -set column_output_function = 'acs_datatype__timestamp_output_function' -where datatype = 'timestamp'; + update acs_datatypes + set column_output_function = 'acs_datatype__date_output_function' + where datatype = 'date'; -update acs_datatypes -set column_output_function = 'acs_datatype__timestamp_output_function' -where datatype = 'time_of_day'; + update acs_datatypes + set column_output_function = 'acs_datatype__timestamp_output_function' + where datatype = 'timestamp'; + update acs_datatypes + set column_output_function = 'acs_datatype__timestamp_output_function' + where datatype = 'time_of_day'; +end; + +create or replace function acs_datatype__date_output_function(text) +returns text as ' +declare + p_attribute_name alias for $1; +begin + return ''to_char('' || p_attribute_name || '', ''''YYYY-MM-DD'''')''; +end;' language 'plpgsql'; + create or replace function acs_datatype__timestamp_output_function(text) returns text as ' declare p_attribute_name alias for $1; begin - return ''to_char('' || p_attribute_name || '', ''''YYYY-MM-DD HH24:MI'''')''; + return ''to_char('' || p_attribute_name || '', ''''YYYY-MM-DD HH24:MI:SS'''')''; end;' language 'plpgsql'; -- New tables to model object-based views. Since view names must be unique in SQL -- we force them to be unique in our datamodel, too (rather than only unique to the -- object type). -create table acs_object_views ( +create table acs_views ( object_view text - constraint acs_object_views__pk + constraint acs_views__pk primary key, object_type text - constraint acs_object_views_object_type_fk + constraint acs_views_object_type_fk references acs_object_types on delete cascade, pretty_name text - constraint acs_object_views_pretty_name_nn + constraint acs_views_pretty_name_nn not null, root_view_p boolean default 'f' - constraint acs_object_views_root_view_p_nn + constraint acs_views_root_view_p_nn not null ); -comment on table acs_object_views is ' +comment on table acs_views is ' Track information on object type-based views, including the initial view created for an object type '; -comment on column acs_object_views.object_view is ' +comment on column acs_views.object_view is ' The name of the view. The initial view for an object type is given the name "object_type_name_v". If the object type the view references is deleted, the acs_view will be dropped, too. '; -comment on column acs_object_views.object_type is ' +comment on column acs_views.object_type is ' The object type this view is built from. '; -comment on column acs_object_views.pretty_name is ' +comment on column acs_views.pretty_name is ' Pretty name for this view '; -create table acs_object_view_attributes ( +create table acs_view_attributes ( attribute_id integer - constraint acs_object_view_attributes_attribute_id_fk + constraint acs_view_attributes_attribute_id_fk references acs_attributes on delete cascade, - col_name text, + view_attribute text, object_view text - constraint acs_object_view_attributes_object_view_fk - references acs_object_views(object_view) + constraint acs_view_attributes_object_view_fk + references acs_views(object_view) on delete cascade, pretty_name text - constraint acs_object_views_pretty_name_nn + constraint acs_views_pretty_name_nn not null, sort_order integer - constraint acs_object_views_sort_order + constraint acs_views_sort_order not null, col_expr text - constraint acs_object_view_attributes_type_col_spec_nn + constraint acs_view_attributes_type_col_spec_nn not null, - constraint acs_object_view_attributes_pk primary key (object_view, col_name) + constraint acs_view_attributes_pk primary key (object_view, attribute_id) ); -comment on table acs_object_view_attributes is ' +comment on table acs_view_attributes is ' Track information on view attributes. This extends the acs_attributes table with view-specific attribute information. If the view or object type attribute referenced by the view attribute is deleted, the view attribute will be, too. '; -comment on column acs_object_view_attributes.attribute_id is ' +comment on column acs_view_attributes.attribute_id is ' The acs_attributes row we are augmenting with view-specific information. This is not used as the primary key because multiple views might use the same acs_attribute. '; -comment on column acs_object_view_attributes.col_name is ' +comment on column acs_view_attributes.view_attribute is ' The name assigned to this column in the view. Usually it is the acs_attribute name, but if multiple attributes have the same name, they are disambiguated with suffixes of the form _N. '; -comment on column acs_object_view_attributes.object_view is ' +comment on column acs_view_attributes.object_view is ' The name of the view this attribute is being declared for. '; -comment on column acs_object_view_attributes.pretty_name is ' +comment on column acs_view_attributes.pretty_name is ' The pretty name of the view. '; -comment on column acs_object_view_attributes.sort_order is ' +comment on column acs_view_attributes.sort_order is ' The order of display when shown to a user. A bit odd to have it here, but the original object attributes have a sort_order defined, so for consistency we will do the same for view attributes. '; -comment on column acs_object_view_attributes.col_expr is ' +comment on column acs_view_attributes.col_expr is ' The expression used to build the column. Usually just the acs_attribute name, but certain datatypes might call a function on the attribute value (i.e. "to_char()" for timestamp types). '; -select define_function_args('acs_object_view__create_sql_view','object_view'); +select define_function_args('acs_view__drop_sql_view','object_view'); -create or replace function acs_object_view__create_sql_view (varchar) +create or replace function acs_view__drop_sql_view (varchar) returns integer as ' declare p_view alias for $1; +begin + if table_exists(p_view) then + execute ''drop view '' || p_view; + end if; + return 0; +end;' language 'plpgsql'; + +select define_function_args('acs_view__create_sql_view','object_view'); + +create or replace function acs_view__create_sql_view (varchar) +returns integer as ' +declare + p_view alias for $1; v_cols varchar; v_tabs varchar; v_joins varchar; @@ -252,7 +287,7 @@ end if; if not exists (select 1 - from acs_object_views + from acs_views where object_view = p_view) then raise exception ''No object type named "%" exists'',p_view; end if; @@ -261,11 +296,11 @@ v_joins := ''''; v_first_p := ''t''; v_tree_sortkey_found_p := ''f''; - v_cols := ''acs_objects.object_id''; + v_cols := ''acs_objects.object_id as '' || p_view || ''_id''; for v_join_rec in select ot2.object_type, ot2.table_name, ot2.id_column, tree_level(ot2.tree_sortkey) as level - from acs_object_types ot1, acs_object_types ot2, acs_object_views ov + from acs_object_types ot1, acs_object_types ot2, acs_views ov where ov.object_view = p_view and ot1.object_type = ov.object_type and ot1.tree_sortkey between ot2.tree_sortkey and tree_right(ot2.tree_sortkey) @@ -297,12 +332,12 @@ end if; end loop; - for v_attr_rec in select col_name, col_expr - from acs_object_view_attributes + for v_attr_rec in select view_attribute, col_expr + from acs_view_attributes where object_view = p_view order by sort_order loop - v_cols := v_cols || '','' || v_attr_rec.col_expr || '' as '' || v_attr_rec.col_name; + v_cols := v_cols || '','' || v_attr_rec.col_expr || '' as '' || v_attr_rec.view_attribute; end loop; if v_joins <> '''' then @@ -334,7 +369,7 @@ v_attr_rec record; v_type_rec record; v_dupes integer; - v_col_name text; + v_view_attribute text; v_col_expr text; v_sort_order integer; v_view text; @@ -348,9 +383,9 @@ v_view := p_type || ''_v''; - delete from acs_object_views where object_view = v_view; + delete from acs_views where object_view = v_view; - insert into acs_object_views + insert into acs_views (object_view, object_type, pretty_name, root_view_p) select v_view, p_type, pretty_name, ''t'' from acs_object_types @@ -375,8 +410,8 @@ and a.datatype = d.datatype loop - v_col_name := v_attr_rec.attribute_name; - v_col_expr := v_type_rec.table_name || ''.'' || v_col_name; + v_view_attribute := v_attr_rec.attribute_name; + v_col_expr := v_type_rec.table_name || ''.'' || v_view_attribute; if v_attr_rec.column_output_function is not null then execute ''select '' || v_attr_rec.column_output_function || ''('''''' || v_col_expr || @@ -396,21 +431,21 @@ between tree_left(ot2.tree_sortkey) and tree_right(ot2.tree_sortkey)); if v_dupes > 0 then - v_col_name := v_col_name || ''_'' || substr(to_char(v_dupes, ''9''),2,1); + v_view_attribute := v_view_attribute || ''_'' || substr(to_char(v_dupes, ''9''),2,1); end if; - insert into acs_object_view_attributes - (attribute_id, col_name, object_view, pretty_name, sort_order, col_expr) + insert into acs_view_attributes + (attribute_id, view_attribute, object_view, pretty_name, sort_order, col_expr) values - (v_attr_rec.attribute_id, v_col_name, v_view, v_attr_rec.pretty_name, v_sort_order, + (v_attr_rec.attribute_id, v_view_attribute, v_view, v_attr_rec.pretty_name, v_sort_order, v_col_expr); v_sort_order := v_sort_order + 1; end loop; end loop; - perform acs_object_view__create_sql_view(p_type || ''_v''); + perform acs_view__create_sql_view(p_type || ''_v''); -- Now fix all subtypes (really only necessary for the attributes view when an attribute -- has been added or dropped, but there is no harm in doing it always). The supertype @@ -568,7 +603,7 @@ p_size alias for $16; p_null_p alias for $17; p_references alias for $18; - p_check_expr alias for $19; + p_check_expr alias for $19; p_column_spec alias for $20; v_sort_order acs_attributes.sort_order%TYPE; Index: openacs-4/packages/acs-object-management/sql/postgresql/acs-object-management-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/acs-object-management-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/sql/postgresql/acs-object-management-create.sql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/sql/postgresql/acs-object-management-create.sql 27 Nov 2009 00:38:50 -0000 1.2 @@ -1,4 +1,3 @@ \i acs-kernel-changes-create.sql \i acs-content-repository-changes-create.sql - -select acs_object_type__refresh_view('acs_object'); +\i acs-templating-changes-create.sql Index: openacs-4/packages/acs-object-management/sql/postgresql/acs-templating-changes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/acs-templating-changes-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/sql/postgresql/acs-templating-changes-create.sql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,343 @@ +-- Some of these should probably be objects, but I'll worry about that later. + +create table acs_form_widgets ( + widget text + constraint acs_form_widgets_pk + primary key +); + +create table acs_form_default_widgets ( + widget text + constraint acs_form_default_widgets_fk + references acs_form_widgets, + datatype text + constraint acs_form_default_widgets_datatype_fk + references acs_datatypes (datatype), + primary key (widget, datatype) +); + +comment on table acs_form_widgets is ' + Canonical list of all template form widgets defined in the system. +'; + +create sequence acs_form_widget_param_seq; + +create table acs_form_widget_params ( + param_id integer + constraint acs_form_widget_params_pk + primary key, + widget text + constraint acs_widget_params_fk + references acs_form_widgets + on delete cascade, + param text + constraint acs_widget_param_nil + not null, + required_p boolean + constraint acs_form_widget_params_required_p_nn + not null, + html_p boolean + constraint acs_form_widget_params_html_p_nn + not null, + default_value text +); + +comment on table acs_form_widget_params is ' + Parameters that are specific to a particular type of form widget. +'; + +create table acs_view_attribute_widgets ( + attribute_id integer, + object_view text, + widget text + constraint acs_attr_widget_widget_fk + references acs_form_widgets + on delete cascade + constraint acs_attr_widget_nnl + not null, + required_p boolean + constraint acs_view_attribute_widgets_required_p_nn + not null, + help_text text, + + constraint acs_view_attribute_widgets_pk + primary key (object_view, attribute_id), + + constraint acs_view_attribute_widgets_fk + foreign key (object_view, attribute_id) + references acs_view_attributes + on delete cascade +); + +comment on table acs_view_attribute_widgets is ' + Map of widgets to object view attributes, only one allowed per attribute. +'; + +create table acs_view_attribute_widget_params ( + attribute_id integer, + object_view text, + param_id integer + constraint acs_view_attr_widg_params_param_nn + not null + constraint acs_view_attr_widg_paramsparam_fk + references acs_form_widget_params + on delete cascade, + param_type text default 'onevalue' + constraint acs_view_attr_widg_params_param_type_nn + not null + constraint acs_view_attr_widg_params_param_type_ck + check (param_type in ('onevalue', 'onelist', 'multilist')), + param_source text default 'literal' + constraint acs_view_attr_widg_params_param_src_nn + not null + constraint acs_view_attr_widg_params_param_src_ck + check (param_source in ('literal', 'query', 'eval')), + value text, + + constraint acs_view_attr_widg_params_attr_fk + foreign key (object_view, attribute_id) + references acs_view_attributes + on delete cascade, + + constraint acs_view_attr_widg_param_pk + primary key (object_view, attribute_id, param_id) +); + +comment on table acs_view_attribute_widget_params is ' + Parameter values for specific object view attribute widgets. +'; + +-- insert the standard form widgets. This was taken from CMS and is incomplete. + +begin; + + -- text widget + insert into acs_form_widgets (widget) values ('text'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (10, 'text', 'size', 'f', 't', '30'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (11, 'text', 'maxlength', 'f', 't', null); + + -- textarea widget + insert into acs_form_widgets (widget) values ('textarea'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (20, 'textarea', 'rows', 'f', 't', '6'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (30, 'textarea', 'cols', 'f', 't', '60'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (31, 'textarea', 'wrap', 'f', 't', 'physical'); + + -- radio widget + insert into acs_form_widgets (widget) values ('radio'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (40, 'radio', 'options', 't', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (41, 'radio', 'values', 'f', 'f', null); + + -- checkbox widget + insert into acs_form_widgets (widget) values ('checkbox'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (50, 'checkbox', 'options', 't', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (51, 'checkbox', 'values', 'f', 'f', null); + + -- select widget + insert into acs_form_widgets (widget) values ('select'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (60, 'select', 'options', 't', 'f', '{ -- {} }'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (61, 'select', 'values', 'f', 'f', '{}'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (70, 'select', 'size', 'f', 't', null); + + -- multiselect widget + insert into acs_form_widgets (widget) values ('multiselect'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (80, 'multiselect', 'options', 't', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (90, 'multiselect', 'size', 'f', 't', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (91, 'multiselect', 'values', 'f', 'f', null); + + -- timestamp widget + insert into acs_form_widgets (widget) values ('timestamp'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (92, 'timestamp', 'format', 'f', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (93, 'timestamp', 'year_interval', 'f', 'f', null); + + -- date widget + insert into acs_form_widgets (widget) values ('date'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (100, 'date', 'format', 'f', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (110, 'date', 'year_interval', 'f', 'f', null); + + -- richtext widget + insert into acs_form_widgets (widget) values ('richtext'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (200, 'richtext', 'rows', 'f', 't', '20'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (230, 'richtext', 'cols', 'f', 't', '80'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (231, 'richtext', 'wrap', 'f', 't', 'physical'); + + -- search widget + insert into acs_form_widgets (widget) values ('search'); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (120, 'search', 'search_query', 't', 'f', null); + + insert into acs_form_widget_params + (param_id, widget, param, required_p, html_p, default_value) + values + (121, 'search', 'result_datatype', 'f', 'f', 'search'); +end; + +-- default widgets for datatypes + +begin; + + insert into acs_form_default_widgets + (datatype, widget) + values + ('url', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('richtext', 'richtext'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('text', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('string', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('boolean', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('number', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('integer', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('money', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('enumeration', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('email', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('file', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('keyword', 'text'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('date', 'date'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('timestamp', 'timestamp'); + + insert into acs_form_default_widgets + (datatype, widget) + values + ('time_of_day', 'timestamp'); +end; Index: openacs-4/packages/acs-object-management/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/form-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/form-procs.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,78 @@ +ad_library { + + Supporting procs for forms that work with views. + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date August 28, 2009 + @cvs-id $Id: form-procs.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} + +namespace eval form {} + +ad_proc form::form_part { + -object_view:required +} { + + Returns an ad_form snippet meant to be embedded in the "-form" part of the call. + + @param object_view The object view whose form we should render. + +} { + set form_part [list [list ${object_view}_id:key(acs_object_id_seq)]] + lappend form_part [list object_view:text(hidden) [list value $object_view]] + foreach attribute_id [db_list get_attribute_ids {}] { + lappend form_part [form::element -object_view $object_view -attribute_id $attribute_id] + } + return $form_part +} + +ad_proc form::get_attributes { + -object_view:required + -array:required +} { + upvar $array local + foreach attribute_id [db_list get_attribute_ids {}] { + object_view::attribute::get \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -array attr + set value [template::element::get_value $object_view $attr(view_attribute)] + if { [llength [info procs ::template::data::to_sql::${attr(datatype)}]] } { + set value [template::data::to_sql::${attr(datatype)} $value] + } else { + set value "'$value'" + } + set local($attr(view_attribute)) $value + } +} + +ad_proc form::element { + -object_view:required + -attribute_id:required +} { +} { + db_1row get_attr_info {} + + set html_params {} + set params {} + db_foreach get_params {} { + if { $html_p } { + lappend html_params $param + lappend html_params $value + } else { + lappend params [list $param $value] + } + } + if { [llength $html_params] > 0 } { + lappend params [list html $html_params] + } + if { $pretty_name ne "" } { + lappend params [list label $pretty_name] + } + if { $help_text ne "" } { + lappend params [list help_text $help_text] + } + set optional [expr { $required_p ? "" : ",optional" }] + return [concat ${view_attribute}:${datatype}($widget)$optional $params] +} Index: openacs-4/packages/acs-object-management/tcl/form-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/form-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/form-procs.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,54 @@ + + + + + + select attribute_id + from acs_view_attributes + where object_view = :object_view + order by sort_order + + + + + + select attribute_id + from acs_view_attributes + where object_view = :object_view + order by sort_order + + + + + + select aova.pretty_name, aova.sort_order, aa.datatype, aa.object_type, aova.view_attribute, + coalesce(aovaw.widget, + (select widget from acs_form_default_widgets where datatype = aa.datatype)) as widget, + coalesce(aovaw.required_p, 'f') as required_p, aovaw.help_text + from acs_attributes aa join acs_view_attributes aova using (attribute_id) + left join acs_view_attribute_widgets aovaw using (object_view, attribute_id) + where aova.object_view = :object_view + and aa.attribute_id = :attribute_id + + + + + + select afwp.param, afwp.html_p, aovawp.value + from acs_form_widget_params afwp, acs_view_attribute_widget_params aovawp, + acs_view_attribute_widgets avaw + where avaw.object_view = :object_view + and aovawp.attribute_id = :attribute_id + and afwp.param_id = aovawp.param_id + union + select afwp2.param, afwp2.html_p, afwp2.default_value as value + from acs_form_widget_params afwp2 + where not exists (select 1 + from acs_view_attribute_widgets + where object_view = :object_view + and attribute_id = :attribute_id) + and afwp2.default_value is not null + + + + Index: openacs-4/packages/acs-object-management/tcl/object-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/tcl/object-procs.tcl 14 Aug 2009 01:06:08 -0000 1.3 +++ openacs-4/packages/acs-object-management/tcl/object-procs.tcl 27 Nov 2009 00:38:50 -0000 1.4 @@ -11,6 +11,15 @@ namespace eval object {} +ad_proc -private object::quote_attribute_values { + -array:required +} { + upvar $array attributes + foreach attribute [array names attributes] { + set attributes($attribute) "'[DoubleApos $attributes($attribute)]'" + } +} + ad_proc -private object::split_attributes { -object_type:required -attributes_array:required @@ -97,7 +106,8 @@ if { [llength [array names supertype_attributes]] > 0 } { # Internal error check - if we're creating an acs_object, it has no supertype # therefore should have no supertype_attributes. - return -code "Internal error - supertype_attributes should be empty" + ns_log Error "supertype_attributes should be empty, value: [array get supertype_attributes]" + return -code error "Internal error - supertype_attributes should be empty" } } @@ -107,7 +117,7 @@ foreach name [array names our_attributes] { lappend name_list $name set __$name $our_attributes($name) - lappend value_name_list :__$name + lappend value_list [set __$name] } db_dml insert_object {} @@ -166,14 +176,7 @@ set attributes_array(object_type) $object_type - if { [ad_conn isconnected] } { - if { ![exists_and_not_null attributes_array(creation_user)] } { - set attributes_array(creation_user) [ad_conn user_id] - } - if { ![exists_and_not_null attributes_array(creation_ip)] } { - set attributes_array(creation_ip) [ad_conn peeraddr] - } - } + object::quote_attribute_values -array attributes_array db_transaction { set object_id [object::new_inner \ @@ -184,6 +187,34 @@ return $object_id } +ad_proc object::new_from_form { + -object_view:required +} { +} { + set object_id [template::element::get_value $object_view \ + [template::element::get_value $object_view __key]] + + form::get_attributes \ + -object_view $object_view \ + -array attributes +ns_log Notice "Huh? attributes: [array get attributes]" + + set object_type [object_view::get_element \ + -object_view $object_view \ + -element object_type] + + set attributes(creation_user) "'[ad_conn user_id]'" + set attributes(creation_ip) "'[ad_conn peeraddr]'" + set attributes(object_type) "'$object_type'" + + db_transaction { + object::new_inner \ + -object_type $object_type \ + -object_id $object_id \ + -attributes [array get attributes] + } +} + ad_proc object::delete { -object_id:required } { @@ -272,19 +303,22 @@ -object_id $object_id \ -attributes [array get supertype_attributes] } else { - if { [llength [array name subtype_attributes]] > 0 } { - # error ... + if { [llength [array names supertype_attributes]] > 0 } { + # Internal error check - if we're creating an acs_object, it has no supertype + # therefore should have no supertype_attributes. + ns_log Error "supertype_attributes should be empty, value: [array get supertype_attributes]" + return -code error "Internal error - supertype_attributes should be empty" } } if { $object_type_info(table_name) ne "" } { foreach name [array names our_attributes] { set __$name $our_attributes($name) - lappend name_value_list "$name = :__$name" + lappend name_value_list "$name = [set __$name]" } - if { [llength $name_value_list] > 0 } { + if { [info exists name_value_list] } { db_dml update_object {} } @@ -321,6 +355,8 @@ } } + object::quote_attribute_values -array attributes_array + set object_type [object::get_object_type -object_id $object_id] db_transaction { @@ -330,3 +366,29 @@ -attributes [array get attributes_array] } } + +ad_proc object::update_from_form { + -object_view:required +} { +} { + set object_id [template::element::get_value $object_view \ + [template::element::get_value $object_view __key]] + + form::get_attributes \ + -object_view $object_view \ + -array attributes + + set object_type [object_view::get_element \ + -object_view $object_view \ + -element object_type] + + set attributes(modifying_user) "'[ad_conn user_id]'" + set attributes(modifying_ip) "'[ad_conn peeraddr]'" + + db_transaction { + object::update_inner \ + -object_id $object_id \ + -object_type $object_type \ + -attributes [array get attributes] + } +} Index: openacs-4/packages/acs-object-management/tcl/object-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-procs.xql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-procs.xql 27 Nov 2009 00:38:50 -0000 1.2 @@ -6,7 +6,7 @@ insert into $object_type_info(table_name) ([join $name_list ,]) values - ([join $value_name_list ,]) + ([join $value_list ,]) Index: openacs-4/packages/acs-object-management/tcl/object-type-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-type-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-type-procs.xql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-type-procs.xql 27 Nov 2009 00:38:50 -0000 1.2 @@ -22,7 +22,7 @@ select object_view - from acs_object_views + from acs_views where object_type = :object_type and root_view_p Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 14 Aug 2009 01:06:08 -0000 1.3 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 27 Nov 2009 00:38:50 -0000 1.4 @@ -2,17 +2,16 @@ Supporting procs for ACS Object Types - @author Yonatan Feldman (yon@arsdigita.com) - @creation-date August 13, 2000 + @author Don Baccus (dhogaza@pacifier.com) + @creation-date Sept 13, 2009 @cvs-id $Id$ } -namespace eval object_type {} -namespace eval object_type::view {} -namespace eval object_type::view::attribute {} +namespace eval object_view {} +namespace eval object_view::attribute {} -ad_proc object_type::view::new { +ad_proc object_view::new { -object_view:required -pretty_name:required -object_type:required @@ -28,22 +27,25 @@ @param object_type The object type the view's being built for. } { db_dml insert_object_view {} + set var_list [list [list object_view $object_view]] + package_exec_plsql -var_list $var_list acs_view create_sql_view object_type::flush_cache -object_type $object_type } -ad_proc object_type::view::delete { +ad_proc object_view::delete { -object_view:required } { Delete a view, both the metadata and SQL view. @param object_view The name of the view to delete. } { - object_type::view::flush_cache -object_view $object_view + object_view::flush_cache -object_view $object_view db_dml delete_object_view {} - db_dml drop_view {} + set var_list [list [list object_view $object_view]] + package_exec_plsql -var_list $var_list acs_view drop_sql_view } -ad_proc object_type::view::get { +ad_proc object_view::get { -object_view:required -array:required } { @@ -58,7 +60,7 @@ get_object_view {} -column_array local } -ad_proc object_type::view::get_element { +ad_proc object_view::get_element { -object_view:required -element:required } { @@ -67,11 +69,11 @@ @param object_view The object view whose metadata should be returned. @param element The name of the metadata element to return (pretty_name, etc). } { - object_type::view::get -object_view $object_view -array view + object_view::get -object_view $object_view -array view return $view($element) } -ad_proc object_type::view::flush_cache { +ad_proc object_view::flush_cache { -object_view:required } { Flush all queries dependent on a view. This also flushes queries dependent on the @@ -80,7 +82,7 @@ @param object_view The view to flush. } { - object_type::flush_cache -object_type [object_type::view::get_element \ + object_type::flush_cache -object_type [object_view::get_element \ -object_view $object_view \ -element object_type] db_flush_cache -cache_pool acs_metadata -cache_key_pattern v::${object_view}::* Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 14 Aug 2009 01:06:08 -0000 1.3 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 27 Nov 2009 00:38:50 -0000 1.4 @@ -1,32 +1,26 @@ - + - insert into acs_object_views + insert into acs_views (object_view, object_type, pretty_name, root_view_p) values (:object_view, :object_type, :pretty_name, 'f') - + - delete from acs_object_views + delete from acs_views where object_view = :object_view - + - drop view :object_view - - - - - select * - from acs_object_views + from acs_views where object_view = :object_view Index: openacs-4/packages/acs-object-management/tcl/templating-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/Attic/templating-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/templating-procs.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,125 @@ +ad_library { + + Supporting code for automagically massaging values back and forth between forms + and the database. + + acs-templating has the necessary code but no standard set of naming conventions. + + For instance, to transform a value from a form date to a sql date, you call + "get_property sql_date". + + In this library, if a transformation is necessary from (for instance) the list + form to to_date(), it can be found by calling template::util::date::to_sql. + + The code should move to acs-templating eventually. This is something I've + wanted to do since kludging around the lack when writing ad_form many moons ago. + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date August 28, 2009 + @cvs-id $Id: templating-procs.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} + +namespace eval template {} +namespace eval template::util {} +namespace eval template::util::timestamp {} +namespace eval template::widget {} +namespace eval template::data {} +namespace eval template::data::validate {} +namespace eval template::data::transform {} +namespace eval template::data::to_sql {} +namespace eval template::data::from_sql {} + +# handle date transformations using a standardized naming convention. + +ad_proc template::data::to_sql::date { value } { +} { + return [template::util::date::get_property sql_date $value] +} + +ad_proc template::data::from_sql::date { value } { +} { +ns_log Notice "Huh? value: $value" + return [template::util::date::acquire ansi $value] +} + +# The abstract type system includes a timestamp type, so we need to implement one +# in the template "data type" system (even though in reality it should really just +# be a widget working on the abstract type "date", or "timestamp" should replace "date") + +ad_proc -public template::data::validate::timestamp { + value_ref + message_ref +} { + Validate that a submitted date conforms to the template system's notion + of what a date should be. + + @param value_ref Reference variable to the submitted value + @param message_ref Reference variable for returning an error message + + @return True (1) if valid, false (0) if not +} { + + upvar 2 $message_ref message $value_ref value + + return [template::util::date::validate $value message] +} + +ad_proc template::data::to_sql::timestamp { value } { +} { + return [template::data::to_sql::date $value] +} + +ad_proc template::data::from_sql::timestamp { value } { +} { + return [template::data::from_sql::date $value] +} + +ad_proc -public template::data::transform::timestamp { element_ref } { + Collect a timestamp object from the form +} { + upvar $element_ref element + return [template::data::transform::date element] +} + +ad_proc -public template::util::timestamp::set_property { what date value } { + + get a property in a list created by a timestamp widget. It's the same + as the date one. + + This is needed by the form builder to support explicit from_sql element modifiers. + +} { + return [template::util::date::set_property $what $date $value] +} + +ad_proc -public template::util::timestamp::get_property { what date } { + + Replace a property in a list created by a timestamp widget. It's the same + as the date one. + + This is needed by the form builder to support explicit to_sql element modifiers. +} { + return [template::util::date::get_property $what $date] +} + +ad_proc -public template::widget::timestamp { element_reference tag_attributes } { + Render a timestamp widget. Default is the localized version. +} { + + upvar $element_reference element + + if { ! [info exists element(format)] } { + set element(format) "[_ acs-lang.localization-formbuilder_date_format] [_ acs-lang.localization-formbuilder_time_format]" + } + return [template::widget::date element $tag_attributes] +} + +# handle richtext transformations using a standardized naming convention. + +namespace eval template::util::richtext {} + +ad_proc template::data::to_sql::richtext { value } { + return "'[DoubleApos [list [template::util::richtext::get_property content $value] \ + [template::util::richtext::get_property format $value]]]'" +} Index: openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl 14 Aug 2009 01:06:08 -0000 1.2 +++ openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl 27 Nov 2009 00:38:50 -0000 1.3 @@ -6,11 +6,10 @@ @cvs-id $Id$ } -namespace eval object_type {} -namespace eval object_type::view {} -namespace eval object_type::view::attribute {} +namespace eval object_view {} +namespace eval object_view::attribute {} -ad_proc object_type::view::attribute::copy { +ad_proc object_view::attribute::copy { -to_object_view:required -from_object_view -attribute_id:required @@ -21,17 +20,19 @@ @param attribute_id The attribute_id to copy. } { set object_type \ - [object_type::view::get_element -object_view $to_object_view -element object_type] + [object_view::get_element -object_view $to_object_view -element object_type] if { ![info exists from_object_view] } { set from_object_view [object_type::get_root_view -object_type $object_type] } db_dml copy {} - object_type::view::flush_cache -object_view $to_object_view + object_view::flush_cache -object_view $to_object_view + set var_list [list [list object_view $to_object_view]] + package_exec_plsql -var_list $var_list acs_view create_sql_view } -ad_proc object_type::view::attribute::delete { +ad_proc object_view::attribute::delete { -object_view:required -attribute_id:required } { @@ -41,5 +42,47 @@ @param attribute_id:required } { db_dml delete {} - object_type::view::flush_cache -object_view $object_view + object_view::flush_cache -object_view $object_view + set var_list [list [list object_view $object_view]] + package_exec_plsql -var_list $var_list acs_view create_sql_view } + +ad_proc object_view::attribute::get { + -object_view:required + -attribute_id:required + -array:required +} { + + Get the metadata for the given view attribute and place it in the named array at the + caller's level. + + @param object_view The object type this attribute belongs to. + @param attribute_name The name of the attribute. + @param array The name of the array to store the metadata in. + +} { + upvar $array row + db_1row -cache_pool acs_metadata \ + -cache_key v::${object_view}::${attribute_id}::attribute::get \ + get {} -column_array row +} + +ad_proc object_view::attribute::get_element { + -object_view:required + -attribute_id:required + -element:required +} { + + Get the metadata for the given view attribute and return the requested element. + + @param object_type The object type this attribute belongs to. + @param attribute_name The name of the attribute. + +} { + object_view::attribute::get \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -array row + return $row($element) +} + Index: openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql 13 Aug 2009 00:15:05 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql 27 Nov 2009 00:38:50 -0000 1.2 @@ -1,26 +1,37 @@ - + - insert into acs_object_view_attributes - (attribute_id, col_name, object_view, pretty_name, col_expr, sort_order) - select attribute_id, col_name, :to_object_view, pretty_name, col_expr, + insert into acs_view_attributes + (attribute_id, view_attribute, object_view, pretty_name, col_expr, sort_order) + select attribute_id, view_attribute, :to_object_view, pretty_name, col_expr, (select coalesce(max(sort_order), 1) - from acs_object_view_attributes + from acs_view_attributes where object_view = :to_object_view) - from acs_object_view_attributes + from acs_view_attributes where object_view = :from_object_view and attribute_id = :attribute_id - + - delete from acs_object_view_attributes + delete from acs_view_attributes where object_view = :object_view and attribute_id = :attribute_id + + + select aa.object_type, aa.datatype, aa.default_value, aova.view_attribute, + aova.pretty_name, aova.sort_order, aova.col_expr + from acs_attributes aa, acs_view_attributes aova + where aova.object_view = :object_view + and aova.attribute_id = :attribute_id + and aa.attribute_id = :attribute_id + + + Index: openacs-4/packages/acs-object-management/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/widget-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/widget-procs.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,94 @@ +ad_library { + + Supporting procs for widgets and views. Essentially allows for the assignment of + a widget and parameters to individual view attributes. + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date August 28, 2009 + @cvs-id $Id: widget-procs.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} + +namespace eval object_type {} +namespace eval object_view {} +namespace eval object_view::attribute::widget {} +namespace eval object_view::attribute::widget::param {} + +ad_proc object_view::attribute::widget::register { + -object_view:required + -attribute_id:required + -widget:required + -required_p:required + -help_text:required +} { +} { + if { [db_0or1row widget_exists {}] } { + db_dml update_widget {} + } else { + db_dml insert_widget {} + } + object_view::flush_cache -object_view $object_view +} + +ad_proc object_view::attribute::widget::unregister { + -object_view:required + -attribute_id:required +} { +} { + db_dml delete_widget {} + object_view::flush_cache -object_view $object_view +} + +ad_proc object_view::attribute::widget::exists_p { + -object_view:required + -attribute_id:required +} { +} { + return [db_0or1row exists {}] +} + +ad_proc object_view::attribute::widget::get { + -object_view:required + -attribute_id:required + -array:required +} { +} { + upvar $array row + db_1row get {} -column_array row +} + +ad_proc object_view::attribute::widget::get_element { + -object_view:required + -attribute_id:required + -element:required +} { +} { + object_view::attribute::widget::get \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -array row + return $row($element) +} + +ad_proc object_view::attribute::widget::param::delete { + -object_view:required + -attribute_id:required + -param_id:required +} { +} { + db_dml delete {} +} + +ad_proc object_view::attribute::widget::param::set { + -object_view:required + -attribute_id:required + -param_id:required + -value:required +} { +} { + if { [db_0or1row param_exists {}] } { + db_dml update_value {} + } else { + db_dml insert_param {} + } +} Index: openacs-4/packages/acs-object-management/tcl/widget-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/widget-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/widget-procs.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,99 @@ + + + + + + select 1 + from acs_view_attribute_widgets + where attribute_id = :attribute_id + and object_view = :object_view + + + + + + update acs_view_attribute_widgets + set required_p = :required_p, + help_text = :help_text, + widget = :widget + where attribute_id = :attribute_id + and object_view = :object_view + + + + + + insert into acs_view_attribute_widgets + (object_view, attribute_id, widget, required_p, help_text) + values + (:object_view, :attribute_id, :widget, :required_p, :help_text) + + + + + + delete from acs_view_attribute_widgets + where attribute_id = :attribute_id + and object_view = :object_view + + + + + + select 1 + where exists (select * + from acs_view_attribute_widgets + where object_view = :object_view + and attribute_id = :attribute_id) + + + + + + + select widget, required_p, help_text + from acs_view_attribute_widgets + where object_view = :object_view + and attribute_id = :attribute_id + + + + + + delete from acs_view_attribute_widget_params + where object_view = :object_view + and attribute_id = :attribute_id + and param_id = :param_id + + + + + + select 1 + from acs_view_attribute_widget_params + where object_view = :object_view + and attribute_id = :attribute_id + and param_id = :param_id + + + + + + update acs_view_attribute_widget_params + set value = :value + where object_view = :object_view + and attribute_id = :attribute_id + and param_id = :param_id + + + + + + insert into acs_view_attribute_widget_params + (object_view, attribute_id, param_id, value) + values + (:object_view, :attribute_id, :param_id, :value) + + + + Index: openacs-4/packages/acs-object-management/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/index.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1 @@ +ad_returnredirect admin Index: openacs-4/packages/acs-object-management/www/admin/attribute-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/attribute-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/attribute-delete.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/attribute-delete.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -16,6 +16,6 @@ -attribute_name $attribute_name \ -object_type $object_type \ -drop_column_p t - ad_returnredirect ./[export_vars -base dtype {object_type}] + ad_returnredirect ./[export_vars -base object-type {object_type}] ad_script_abort } Index: openacs-4/packages/acs-object-management/www/admin/attribute-move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/Attic/attribute-move.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/attribute-move.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/attribute-move.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -1,7 +1,7 @@ ad_page_contract { Change attribute sort order } { - attribute_id:integer,notnull + attribute_id:naturalnum object_type sort_order direction:notnull @@ -48,4 +48,4 @@ set return_url [export_vars -base dtype {object_type}] } -ad_returnredirect $return_url \ No newline at end of file +ad_returnredirect $return_url Index: openacs-4/packages/acs-object-management/www/admin/attribute.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/attribute.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/www/admin/attribute.tcl 14 Aug 2009 22:15:42 -0000 1.2 +++ openacs-4/packages/acs-object-management/www/admin/attribute.tcl 27 Nov 2009 00:38:50 -0000 1.3 @@ -17,14 +17,14 @@ set page_title "[_ acs-object-management.attribute_add]" } -set context [list [list [export_vars -base dtype {object_type}] $type_info(pretty_name)] $page_title] +set context [list [list [export_vars -base object-type {object_type}] $type_info(pretty_name)] $page_title] set table_name $type_info(table_name) set datatype_options [db_list_of_lists get_datatypes {}] ad_form -name attribute_form -export {object_type} -form { {attribute_id:key} {attribute_name:text {label "[_ acs-object-management.attribute_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_name_help]"}} - {pretty_name:text,optional {label "[_ acs-object-management.pretty_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_pname_help]"}} + {pretty_name:text {label "[_ acs-object-management.pretty_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_pname_help]"}} {pretty_plural:text,optional {label "[_ acs-object-management.pretty_plural]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_pplural_help]"}} } @@ -54,12 +54,6 @@ } -edit_request { db_1row attribute_data {} } -on_submit { - if {[empty_string_p $pretty_name]} { - foreach word [split $attribute_name] { - lappend pretty_name [string totitle $word] - } - set pretty_name [join $pretty_name] - } set default_locale [lang::system::site_wide_locale] } -new_data { object_type::attribute::new \ @@ -82,12 +76,7 @@ lang::message::register -update_sync $default_locale acs-translations "${object_type}_$attribute_name" $pretty_name lang::message::register -update_sync $default_locale acs-translations "${object_type}_${attribute_name}s" $pretty_plural - util_memoize_flush "dtype::form::metadata::widgets_list -no_cache -object_type \"$object_type\" -dform \"implicit\" -exclude_static_p 0" - util_memoize_flush "dtype::form::metadata::widgets_list -no_cache -object_type \"$object_type\" -dform \"implicit\" -exclude_static_p 1" - - util_memoize_flush_regexp "dtype::form::metadata::params_list -no_cache -object_type \"$object_type\".*" - - ad_returnredirect [export_vars -base dtype {object_type}] + ad_returnredirect [export_vars -base object-type {object_type}] ad_script_abort } Index: openacs-4/packages/acs-object-management/www/admin/form-preview.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/form-preview.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/form-preview.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,2 @@ + + Index: openacs-4/packages/acs-object-management/www/admin/form-preview.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/form-preview.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/form-preview.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-08-07 + @cvs-id $Id: form-preview.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} { + object_view:notnull,sql_identifier +} + +ad_form -name object_view \ + -form [form::form_part -object_view $object_view] \ + -after_submit { + ad_returnredirect [export_vars -base form {object_view}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/acs-object-management/www/admin/form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/form.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,8 @@ + +@page_title@ +@context@ + +

Form for: @view_info.pretty_name@

+ +

+Preview Form Index: openacs-4/packages/acs-object-management/www/admin/form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/form.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/form.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,58 @@ +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-08-07 + @cvs-id $Id: form.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} { + object_view:notnull,sql_identifier +} + +object_view::get -object_view $object_view -array view_info +object_type::get -object_type $view_info(object_type) -array type_info + +set page_title $view_info(pretty_name) +set context [list [list . "Types"] \ + [list [export_vars -base object-type \ + {{object_type $view_info(object_type)}}] $type_info(pretty_name)] \ + [list [export_vars -base view {object_view}] "Form For $view_info(pretty_name)"] \ + $page_title] +set return_url [ad_conn url]?[ad_conn query] + +list::create \ + -name form_elements \ + -caption [_ acs-object-management.form_elements] \ + -multirow form_elements \ + -key attribute_id \ + -pass_properties { + object_view + } \ + -elements { + pretty_name { + label "[_ acs-object-management.pretty_name]" + } + datatype { + label "[_ acs-object-management.datatype]" + } + widget { + label "[_ acs-object-management.widget]" + } + action { + label "[_ acs-object-management.Action]" + display_template " + + [_ acs-object-management.customize_widget] + + " + } + } + +db_multirow -extend {add_edit_widget_url} \ + form_elements get_form_elements {} { + set add_edit_widget_url [export_vars -base widget-add-edit \ + {object_view attribute_id widget}] +} + +set form_preview_url [export_vars -base form-preview {object_view}] +ad_return_template Index: openacs-4/packages/acs-object-management/www/admin/form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/form.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/form.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,18 @@ + + + + + + + select aova.attribute_id, aova.view_attribute, aova.pretty_name, aova.sort_order, + aova.col_expr, aa.datatype, aa.object_type, + coalesce(aovaw.widget, + (select widget from acs_form_default_widgets where datatype = aa.datatype)) as widget + from acs_attributes aa join acs_view_attributes aova using (attribute_id) + left join acs_view_attribute_widgets aovaw using (object_view, attribute_id) + where aova.object_view = :object_view + order by aova.sort_order + + + + Index: openacs-4/packages/acs-object-management/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/index.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/index.adp 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/index.adp 27 Nov 2009 00:38:50 -0000 1.2 @@ -2,4 +2,4 @@ @page_title@ @context@ - + Index: openacs-4/packages/acs-object-management/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/www/admin/index.tcl 14 Aug 2009 22:15:42 -0000 1.3 +++ openacs-4/packages/acs-object-management/www/admin/index.tcl 27 Nov 2009 00:38:50 -0000 1.4 @@ -14,17 +14,16 @@ set context [list $page_title] list::create \ - -name dtypes \ + -name object_types \ -caption $page_title \ - -multirow dtypes \ + -multirow object_types \ -key object_type \ - -actions [list "[_ acs-object-management.add_type]" [export_vars -base dtype-add] "[_ acs-object-management.add_type]"] \ + -actions [list "[_ acs-object-management.add_type]" [export_vars -base object-type-add] "[_ acs-object-management.add_type]"] \ -row_pretty_plural "[_ acs-object-management.dynamic_types]" \ - -bulk_actions [list "[_ acs-object-management.export]" dtypes-code "[_ acs-object-management.code_export]"] \ -elements { pretty_name { label "[_ acs-object-management.pretty_name]" - link_url_eval $dtype_url + link_url_eval $object_type_url orderby "lower(pretty_name)" } object_type { @@ -33,14 +32,17 @@ } action { label "[_ acs-object-management.Action]" - display_template "delete" + display_template " + + [_ acs-object-management.delete] + " } } -set orderby_clause [list::orderby_clause -orderby -name dtypes] +set orderby_clause [list::orderby_clause -orderby -name object_types] -db_multirow -extend { dtype_url delete_url } dtypes select_dtypes {} { - set dtype_url [export_vars -base dtype {object_type}] - set delete_url [export_vars -base dtype-delete {object_type}] +db_multirow -extend { object_type_url delete_url } object_types select_object_types {} { + set object_type_url [export_vars -base object-type {object_type}] + set delete_url [export_vars -base object-type-delete {object_type}] } Index: openacs-4/packages/acs-object-management/www/admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/index.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/index.xql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/index.xql 27 Nov 2009 00:38:50 -0000 1.2 @@ -2,7 +2,7 @@ - + select object_type, pretty_name Index: openacs-4/packages/acs-object-management/www/admin/object-type-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-add.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title@ +@context@ + + Index: openacs-4/packages/acs-object-management/www/admin/object-type-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-add.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,42 @@ +ad_page_contract { + + @author Vinod Kurup (vinod@kurup.com) + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-07-20 + + Modified from dynamic types. +} + +set page_title [_ acs-object-management.create_type] +set context [list $page_title] + + +ad_form -name dtype-add -form { + {object_type:keyword + {label {[_ acs-object-management.object_type]}} + {html {size 30 maxlength 100}} + } + {pretty_name:text + {label {[_ acs-object-management.pretty_name]}} + {html {size 30 maxlength 100}} + } + {pretty_plural:text + {label {[_ acs-object-management.pretty_plural]}} + {html {size 30 maxlength 100}} + } + {supertype:keyword(select) + {label {[_ acs-object-management.supertype]}} + {options {[lang::util::localize [db_list_of_lists select_object_types {}]]}} + } +} -on_submit { + object_type::new \ + -object_type $object_type \ + -supertype $supertype \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -create_table_p t +} -after_submit { + ad_returnredirect ./ + ad_script_abort +} + Index: openacs-4/packages/acs-object-management/www/admin/object-type-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-add.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-add.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + + + select repeat('  ', tree_level(tree_sortkey)-1) || pretty_name, object_type + from acs_object_types + order by tree_sortkey + + + + Index: openacs-4/packages/acs-object-management/www/admin/object-type-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-delete.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,7 @@ + + +

+ +Really delete type "@type.pretty_name@"? + + Index: openacs-4/packages/acs-object-management/www/admin/object-type-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-delete.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,15 @@ +ad_page_contract { + +} { + object_type:sql_identifier,notnull +} + +object_type::get -object_type $object_type -array type + +ad_form -name delete -export {object_type} -form { +} -on_submit { + + object_type::delete -object_type $object_type -drop_table_p t -drop_children_p t + ad_returnredirect ./[export_vars -base .] + ad_script_abort +} Index: openacs-4/packages/acs-object-management/www/admin/object-type-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type-postgresql.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,20 @@ + + + + + + + select a.attribute_id, a.attribute_name, a.pretty_name, a.pretty_plural, + a.datatype, t.pretty_name as object_pretty_name + from acs_attributes a, acs_object_types t + where t.object_type in (select ot1.object_type + from acs_object_types ot1, acs_object_types ot2 + where ot2.tree_sortkey between + tree_left(ot1.tree_sortkey) and tree_right(ot1.tree_sortkey) + and ot2.object_type = :object_type) + and a.object_type = t.object_type + order by t.tree_sortkey desc, a.sort_order asc; + + + + Index: openacs-4/packages/acs-object-management/www/admin/object-type.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,11 @@ + +@page_title@ +@context@ + +

#acs-object-management.object_type#: @type_info.pretty_name@

+ +
+ +
+ + Index: openacs-4/packages/acs-object-management/www/admin/object-type.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,117 @@ +ad_page_contract { + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-05-02 + @cvs-id $Id: object-type.tcl,v 1.1 2009/11/27 00:38:50 donb Exp $ + +} { + object_type:notnull,sql_identifier +} + +object_type::get -object_type $object_type -array type_info + +set page_title $type_info(pretty_name) +set context [list [list . "Object Types"] $page_title] +set return_url [ad_conn url]?[ad_conn query] + +list::create \ + -name attributes \ + -caption [_ acs-object-management.attributes] \ + -multirow attributes \ + -key attribute_id \ + -pass_properties { + object_type + } -actions [list "[_ acs-object-management.add_attribute]" [export_vars -base attribute {object_type}] "[_ acs-object-management.add_attribute]"] \ + -elements { + pretty_name { + label "[_ acs-object-management.attribute]" + link_url_eval $attribute_url + } + datatype { + label "[_ acs-object-management.datatype]" + } + action { + label "[_ acs-object-management.Action]" + display_template " + + [_ acs-object-management.delete] + " + } + } -filters { + object_type {} + } + +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_attributes \ + -extend { attribute_url delete_url} attributes get_attributes {} { + set attribute_url [export_vars -base attribute {attribute_id object_type}] + set delete_url [export_vars -base attribute-delete {object_type attribute_name}] +} + +list::create \ + -name inherited_attributes \ + -caption [_ acs-object-management.inherited_attributes] \ + -multirow inherited_attributes \ + -key attribute_id \ + -elements { + pretty_name { + label "[_ acs-object-management.attribute]" + } + object_pretty_name { + label "[_ acs-object-management.object_type]" + } + datatype { + label "[_ acs-object-management.datatype]" + } + } -filters { + object_type {} + } + +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_inherited_attributes \ + inherited_attributes get_inherited_attributes {} + +list::create \ + -name views \ + -caption [_ acs-object-management.views] \ + -multirow views \ + -key object_view \ + -actions [list "[_ acs-object-management.add_view]" [export_vars -base view-add {object_type}] "[_ acs-object-management.add_view]"] \ + -elements { + pretty_name { + label "[_ acs-object-management.pretty_name]" + display_template " + + @views.pretty_name@ + + + + @views.pretty_name@ + + " + } + object_view { + label "[_ acs-object-management.view]" + } + actions { + label "[_ acs-object-management.Action]" + display_template " + + + [_ acs-object-management.manage_form] + + + [_ acs-object-management.delete] + + " + } + } -filters { + object_type {} + } + +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_views \ + -extend { view_url delete_url manage_form_url } views get_views {} { + set delete_url [export_vars -base view-delete {return_url object_view}] + set manage_form_url [export_vars -base form {object_view}] + set view_url [export_vars -base view {object_view}] +} + +ad_return_template Index: openacs-4/packages/acs-object-management/www/admin/object-type.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/object-type.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/object-type.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + + + select a.attribute_id, a.attribute_name, a.pretty_name, a.pretty_plural, + a.datatype + from acs_attributes a + where a.object_type = :object_type + order by a.sort_order asc; + + + + + + select object_view, pretty_name, root_view_p + from acs_views + where object_type = :object_type + + + + Index: openacs-4/packages/acs-object-management/www/admin/view-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-add.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/view-add.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/view-add.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -12,20 +12,20 @@ ad_form -name view-add -export {object_type} -form { {object_view:keyword - {label {[_ acs-object-management.object_view]}} + {label {[_ acs-object-management.view]}} {html {size 30 maxlength 100}} } {pretty_name:text {label {[_ acs-object-management.pretty_name]}} {html {size 30 maxlength 100}} } } -on_submit { - object_type::view::new \ + object_view::new \ -object_type $object_type \ -object_view $object_view \ -pretty_name $pretty_name } -after_submit { - ad_returnredirect ./[export_vars -base dtype {object_type}] + ad_returnredirect ./[export_vars -base object-type {object_type}] ad_script_abort } Index: openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl 13 Aug 2009 00:15:05 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -10,7 +10,7 @@ } foreach one_attribute_id $attribute_id { - object_type::view::attribute::copy -to_object_view $object_view -attribute_id $one_attribute_id + object_view::attribute::copy -to_object_view $object_view -attribute_id $one_attribute_id } ad_returnredirect $return_url Index: openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl 13 Aug 2009 00:15:05 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -10,7 +10,7 @@ } foreach one_attribute_id $attribute_id { - object_type::view::attribute::delete \ + object_view::attribute::delete \ -object_view $object_view \ -attribute_id $one_attribute_id } Index: openacs-4/packages/acs-object-management/www/admin/view-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/view-delete.tcl 13 Aug 2009 00:15:05 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/view-delete.tcl 27 Nov 2009 00:38:50 -0000 1.2 @@ -2,16 +2,14 @@ } { object_view:sql_identifier,notnull - object_type:sql_identifier,notnull } -object_type::view::get \ - -object_view $object_view \ - -array view +object_view::get -object_view $object_view -array view +set object_type $view(object_type) ad_form -name delete -export {object_view object_type} -form { } -on_submit { - object_type::view::delete -object_view $object_view - ad_returnredirect ./[export_vars -base dtype {object_type}] + object_view::delete -object_view $object_view + ad_returnredirect ./[export_vars -base object-type {object_type}] ad_script_abort } Index: openacs-4/packages/acs-object-management/www/admin/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/www/admin/view.adp 14 Aug 2009 22:15:42 -0000 1.2 +++ openacs-4/packages/acs-object-management/www/admin/view.adp 27 Nov 2009 00:38:50 -0000 1.3 @@ -2,7 +2,7 @@ @page_title@ @context@ -

#acs-object-management.object_view#: @view_info.pretty_name@

+

#acs-object-management.view#: @view_info.pretty_name@


Index: openacs-4/packages/acs-object-management/www/admin/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/www/admin/view.tcl 14 Aug 2009 22:15:42 -0000 1.2 +++ openacs-4/packages/acs-object-management/www/admin/view.tcl 27 Nov 2009 00:38:50 -0000 1.3 @@ -8,13 +8,12 @@ object_view:notnull,sql_identifier } -object_type::view::get -object_view $object_view -array view_info +object_view::get -object_view $object_view -array view_info set object_type $view_info(object_type) set page_title $view_info(pretty_name) set context [list [list . "Dynamic Types"] \ - [list [export_vars -base dtype \ - {{object_type $view_info(object_type)}}] $view_info(object_type)] \ + [list [export_vars -base object-type {object_type $view_info(object_type)}] $view_info(object_type)] \ $page_title] set return_url [ad_conn url]?[ad_conn query] @@ -25,15 +24,15 @@ -key attribute_id \ -pass_properties { object_view - } \ + } -actions [list [_ acs-object-management.manage_form] [export_vars -base form {object_view}] [_ acs-object-management.manage_form]] \ -bulk_actions [list [_ acs-object-management.delete_checked_attributes] view-attributes-delete [_ acs-object-management.delete_checked_attributes]] \ -bulk_action_export_vars {return_url object_view} \ -elements { pretty_name { label "[_ acs-object-management.pretty_name]" link_url_eval $attribute_url } - col_name { + view_attribute { label "[_ acs-object-management.attribute]" } object_type { @@ -45,14 +44,16 @@ action { label "[_ acs-object-management.Action]" display_template " - + [_ acs-object-management.delete] - " + + " } } db_multirow -cache_pool acs_metadata -cache_key v::${object_view}::get_view_attributes \ - -extend {attribute_url delete_url} view_attributes get_view_attributes {} { + -extend {attribute_url delete_url manage_form_url} \ + view_attributes get_view_attributes {} { set delete_url [export_vars -base view-attributes-delete {object_view return_url attribute_id}] } @@ -67,7 +68,7 @@ pretty_name { label "[_ acs-object-management.pretty_name]" } - col_name { + view_attribute { label "[_ acs-object-management.attribute]" } object_type { @@ -79,17 +80,16 @@ action { label "[_ acs-object-management.Action]" display_template " - + [_ acs-object-management.add] " } } +set object_type $view_info(object_type) db_multirow -cache_pool acs_metadata -cache_key v::${object_view}::get_available_attributes \ -extend {add_url} available_attributes get_available_attributes {} { set add_url [export_vars -base view-attributes-add {object_view attribute_id return_url}] } -set add_form_url [export_vars -base form-ae {object_type}] -set return_url [ad_return_url] ad_return_template Index: openacs-4/packages/acs-object-management/www/admin/view.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/view.xql 13 Aug 2009 00:15:05 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/view.xql 27 Nov 2009 00:38:50 -0000 1.2 @@ -4,28 +4,26 @@ - select aova.attribute_id, aova.col_name, aova.pretty_name, aova.sort_order, + select aova.attribute_id, aova.view_attribute, aova.pretty_name, aova.sort_order, aova.col_expr, aa.datatype, aa.object_type - from acs_attributes aa, acs_object_view_attributes aova + from acs_attributes aa join acs_view_attributes aova using (attribute_id) where aova.object_view = :object_view - and aa.attribute_id = aova.attribute_id + order by aova.sort_order - select aova.attribute_id, aova.col_name, aova.pretty_name, aova.sort_order, + select aova.attribute_id, aova.view_attribute, aova.pretty_name, aova.sort_order, aova.col_expr, aa.datatype, aa.object_type - from acs_object_views aov, acs_object_view_attributes aova, - acs_attributes aa + from acs_attributes aa join acs_view_attributes aova using (attribute_id) + join acs_views aov using (object_view) where aov.object_type = :object_type and aov.root_view_p - and aov.object_view = aova.object_view - and aova.attribute_id = aa.attribute_id and not exists (select 1 - from acs_object_view_attributes aova2 + from acs_view_attributes aova2 where aova2.object_view = :object_view - and aova2.col_name = aova.col_name) + and aova2.view_attribute = aova.view_attribute) order by aova.sort_order Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,5 @@ +Register Attribute Widget + +

Register Attribute Widget

+ + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + + Register a widget to an attribute +} { + attribute_id:naturalnum + object_view:sql_identifier,notnull + widget:sql_identifier,notnull +} + +set form_widgets [db_list_of_lists get_form_widgets "" ] + +ad_form -name widget_register -export {attribute_id object_view} -form { + {object_view_pretty:text(inform) + {label "[_ acs-object-management.view]"} + } + {attribute_name_pretty:text(inform) + {label "[_ acs-object-management.attribute]"} + } + {widget:keyword(select) + {label "[_ acs-object-management.form_widget]"} + {options $form_widgets} + } + {required_p:boolean(radio) + {label "[_ acs-object-management.required_p]"} + {options {{"[_ acs-object-management.Yes]" t} + {"[_ acs-object-management.No]" f}}} + } + {help_text:text,optional + {label "[_ acs-object-management.help_text]"} + } +} -on_request { + db_1row get_attr_info {} + set object_view_pretty [lang::util::localize $object_view_pretty] + set attribute_name_pretty [lang::util::localize $attribute_name_pretty] + ad_set_form_values object_view_pretty attribute_name_pretty + + if { [object_view::attribute::widget::exists_p \ + -object_view $object_view \ + -attribute_id $attribute_id] } { + object_view::attribute::widget::get \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -array current + ad_set_form_values {widget $widget} {required_p $current(required_p)} \ + {help_text $current(help_text)} + } else { + ad_set_form_values {widget $widget} {required_p f} + } + + wizard submit widget_register -buttons { next } +} -on_submit { + db_transaction { + if { [db_0or1row get_reg_widget {}] && $registered_widget ne $widget } { + object_view::attribute::widget::unregister \ + -object_view $object_view \ + -attribute_id $attribute_id + } + object_view::attribute::widget::register \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -widget $widget \ + -required_p $required_p \ + -help_text $help_text + } + wizard set_param widget $widget + wizard forward + ad_script_abort +} + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-1.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + + select widget, widget + from acs_form_widgets + + + + + + select widget as registered_widget + from acs_view_attribute_widgets + where attribute_id = :attribute_id + and object_view = :object_view + + + + + + select aova.pretty_name as attribute_name_pretty, + aov.pretty_name as object_view_pretty + from acs_view_attributes aova, acs_views aov + where aov.object_view = :object_view + and aova.attribute_id = :attribute_id + and aova.object_view = :object_view + + + + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,3 @@ +Set Attribute Widget Params + + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + + Set widget parameter values. + +} { + attribute_id:naturalnum + object_view:sql_identifier + widget:sql_identifier +} + +ad_form -name widget_register -export {attribute_id object_view} -form { + {object_view_pretty:text(inform) + {label "Object View"} + } + {attribute_name_pretty:text(inform) + {label "Attribute"} + } + {widget:keyword(inform) + {label "Widget"} + } + {-section "Widget Parameters" {legendtext "Widget Parameters"}} +} + +db_multirow params get_params {} { + set optional_flag [expr { $required_p ? "" : ",optional" }] + set param [lang::util::localize $param] + ad_form -extend -name widget_register -form { + {${param}:text(textarea)$optional_flag} + } +} + +ad_form -extend -name widget_register -on_request { + db_1row get_attr_info "" + set object_view_pretty [lang::util::localize $object_view_pretty] + set attribute_name_pretty [lang::util::localize $attribute_name_pretty] + ad_set_form_values object_view_pretty attribute_name_pretty widget + + for { set i 1 } { $i <= [template::multirow size params] } { incr i } { + ad_set_element_value -element [template::multirow get params $i param] \ + [template::multirow get params $i value] + } + + wizard submit widget_register -buttons { back next } +} -on_submit { + for { set i 1 } { $i <= [template::multirow size params] } { incr i } { + set value [template::element::get_value widget_register [template::multirow get params $i param]] + set param_id [template::multirow get params $i param_id] + if { $value eq "" } { + object_view::attribute::widget::param::delete \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -param_id $param_id + } else { + object_view::attribute::widget::param::set \ + -object_view $object_view \ + -attribute_id $attribute_id \ + -param_id $param_id \ + -value $value + } + } + wizard forward + ad_script_abort +} + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-2.xql 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,32 @@ + + + + + + select aova.pretty_name as attribute_name_pretty, + aov.pretty_name as object_view_pretty + from acs_view_attributes aova, acs_views aov + where aov.object_view = :object_view + and aova.attribute_id = :attribute_id + and aova.object_view = :object_view + + + + + + select + afwp.param_id, afwp.param, afwp.required_p, afwp.html_p, + coalesce(aovawp.value, afwp.default_value) as value, + coalesce(aovawp.param_source,'literal') as param_source + from + acs_form_widget_params afwp + left join acs_view_attribute_widgets aovaw using (widget) + left join acs_view_attribute_widget_params aovawp + using (param_id, attribute_id, object_view) + where aovaw.attribute_id = :attribute_id + and aovaw.object_view = :object_view + order by afwp.html_p, afwp.param_id + + + + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,3 @@ +Preview Attribute Widget + + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit-3.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,26 @@ +ad_page_contract { + + Preview a widget that's been registered to an attribute. + +} { + object_view:sql_identifier,notnull + attribute_id:naturalnum +} + +set step [wizard current_step] +set last_step [expr $step-1] +set back_url [wizard get_forward_url $last_step] + +ad_form -name widget_preview -has_submit 1 -form \ + [list [form::element \ + -object_view $object_view \ + -attribute_id $attribute_id]] + +ad_form -name widget_buttons -form { +} -on_request { + wizard submit widget_buttons -buttons { back finish } +} -on_submit { + wizard forward + ad_script_abort +} + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit.adp 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,13 @@ + +#acs-object-management.widget_add_edit# + + + + @wizard.rownum@. @wizard.label@ + + + @wizard.rownum@. @wizard.label@ + + § + + Index: openacs-4/packages/acs-object-management/www/admin/widget-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-add-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-add-edit.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,24 @@ +ad_page_contract { + + wizard for adding/editing widgets registered to object views. + +} { + attribute_id:naturalnum + object_view:sql_identifier,notnull + widget:sql_identifier +} + +wizard set_param attribute_id $attribute_id +wizard set_param object_view $object_view +wizard set_param widget $widget + +wizard create -action widget-add-edit -params { + attribute_id object_view widget +} -steps { + 1 -label "[_ acs-object-management.choose_a_widget]" -url widget-add-edit-1 + 2 -label "[_ acs-object-management.edit_widget_params]" -url widget-add-edit-2 + 3 -label "[_ acs-object-management.preview_widget]" -url "widget-add-edit-3" +} +wizard set_finish_url [export_vars -base form {object_view}] + +wizard get_current_step Index: openacs-4/packages/acs-object-management/www/admin/widget-remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/widget-remove.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/widget-remove.tcl 27 Nov 2009 00:38:50 -0000 1.1 @@ -0,0 +1,15 @@ +ad_page_contract { + + Remove the widget registered to a view attribute. + +} { + attribute_id:naturalnum + object_view:sql_identifier + return_url:notnull +} + + object_view::attribute::widget::unregister \ + -object_view $object_view \ + -attribute_id $attribute_id + +ad_returnredirect $return_url