Index: openacs-4/packages/edit-this-page/sql/oracle/edit-this-page-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/sql/oracle/edit-this-page-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/edit-this-page/sql/oracle/edit-this-page-create.sql 16 Nov 2001 03:11:08 -0000 1.2 +++ openacs-4/packages/edit-this-page/sql/oracle/edit-this-page-create.sql 17 Nov 2001 19:48:47 -0000 1.3 @@ -9,52 +9,52 @@ create or replace package etp as function get_attribute_value ( - p_object_id in acs_objects.object_id%TYPE, - p_attribute_id in acs_attribute_values.attribute_id%TYPE + object_id in acs_objects.object_id%TYPE, + attribute_id in acs_attribute_values.attribute_id%TYPE ) return varchar; function create_page ( - p_package_id in apm_packages.package_id%TYPE, - p_name in varchar, - p_title in varchar, - p_content_type in varchar default 'content_revision' + package_id in apm_packages.package_id%TYPE, + name in varchar, + title in varchar, + content_type in varchar default 'content_revision' ) return integer; function create_extlink ( - p_package_id in apm_packages.package_id%TYPE, - p_url in varchar, - p_title in varchar, - p_description in varchar + package_id in apm_packages.package_id%TYPE, + url in varchar, + title in varchar, + description in varchar ) return integer; function create_symlink ( - p_package_id in apm_packages.package_id%TYPE, - p_target_id in integer + package_id in apm_packages.package_id%TYPE, + target_id in integer ) return integer; function create_new_revision ( - p_package_id in apm_packages.package_id%TYPE, - p_name in varchar, - p_user_id in users.user_id%TYPE + package_id in apm_packages.package_id%TYPE, + name in varchar, + user_id in users.user_id%TYPE ) return integer; function get_folder_id ( - p_package_id in apm_packages.package_id%TYPE + package_id in apm_packages.package_id%TYPE ) return integer; function get_relative_url ( - p_item_id in cr_items.item_id%TYPE, - p_name in varchar + item_id in cr_items.item_id%TYPE, + name in varchar ) return varchar; function get_title ( - p_item_id in cr_items.item_id%TYPE, - p_revision_title in varchar + item_id in cr_items.item_id%TYPE, + revision_title in varchar ) return varchar; function get_description ( - p_item_id in cr_items.item_id%TYPE, - p_revision_description in varchar + item_id in cr_items.item_id%TYPE, + revision_description in varchar ) return varchar; end etp; @@ -66,28 +66,26 @@ create or replace package body etp as function get_attribute_value ( - p_object_id in acs_objects.object_id%TYPE, - p_attribute_id in acs_attribute_values.attribute_id%TYPE + object_id in acs_objects.object_id%TYPE, + attribute_id in acs_attribute_values.attribute_id%TYPE ) return varchar is v_value acs_attribute_values.attr_value%TYPE; begin select attr_value into v_value from acs_attribute_values - where object_id = p_object_id - and attribute_id = p_attribute_id; - - exception when no_data_found then v_value := ''; - + where object_id = object_id + and attribute_id = attribute_id; return v_value; + exception when no_data_found then return null; end get_attribute_value; function create_page ( - p_package_id in apm_packages.package_id%TYPE, - p_name in varchar, - p_title in varchar, - p_content_type in varchar default 'content_revision' + package_id in apm_packages.package_id%TYPE, + name in varchar, + title in varchar, + content_type in varchar default 'content_revision' ) return integer is v_item_id cr_items.item_id%TYPE; @@ -101,17 +99,17 @@ sysdate(), null, null, - p_package_id + package_id ); - v_folder_id := etp.get_folder_id(p_package_id); + v_folder_id := etp.get_folder_id(package_id); insert into cr_items (item_id, parent_id, name, content_type) values - (v_item_id, v_folder_id, p_name, v_content_type); + (v_item_id, v_folder_id, name, v_content_type); - -- would like to use p_content_type here, but since there''s + -- would like to use content_type here, but since there''s -- no table that corresponds to it, we get an error from -- the dynamic sql in acs_object__delete. so just use content_revision. @@ -120,7 +118,7 @@ insert into cr_revisions (revision_id, item_id, title, publish_date, mime_type) - values (v_revision_id, v_item_id, p_title, sysdate, 'text/html'); + values (v_revision_id, v_item_id, title, sysdate, 'text/html'); update cr_items set live_revision = v_revision_id @@ -130,10 +128,10 @@ end create_page; function create_extlink ( - p_package_id in apm_packages.package_id%TYPE, - p_url in varchar, - p_title in varchar, - p_description in varchar + package_id in apm_packages.package_id%TYPE, + url in varchar, + title in varchar, + description in varchar ) return integer is v_item_id cr_items.item_id%TYPE; @@ -144,7 +142,7 @@ 'content_extlink' ); - v_folder_id := etp.get_folder_id(p_package_id); + v_folder_id := etp.get_folder_id(package_id); insert into cr_items (item_id, parent_id, name, content_type) @@ -156,21 +154,21 @@ insert into cr_extlinks (extlink_id, url, label, description) values - (v_item_id, p_url, p_title, p_description); + (v_item_id, url, title, description); return 1; end create_extlink; function create_symlink ( - p_package_id in apm_packages.package_id%TYPE, - p_target_id in integer + package_id in apm_packages.package_id%TYPE, + target_id in integer ) return integer is v_item_id cr_items.item_id%TYPE; v_folder_id cr_folders.folder_id%TYPE; begin v_item_id := acs_object.new(null, 'content_symlink'); - v_folder_id := etp.get_folder_id(p_package_id); + v_folder_id := etp.get_folder_id(package_id); insert into cr_items ( item_id, parent_id, name, content_type) @@ -182,15 +180,15 @@ insert into cr_symlinks (symlink_id, target_id) values - (v_item_id, p_target_id); + (v_item_id, target_id); return 1; end create_symlink; function create_new_revision ( - p_package_id in apm_packages.package_id%TYPE, - p_name in varchar, - p_user_id in users.user_id%TYPE + package_id in apm_packages.package_id%TYPE, + name in varchar, + user_id in users.user_id%TYPE ) return integer is v_revision_id cr_revisions.revision_id%TYPE; @@ -201,8 +199,8 @@ select max(r.revision_id) into v_revision_id from cr_revisions r, cr_items i - where i.name = p_name - and i.parent_id = etp.get_folder_id(p_package_id) + where i.name = name + and i.parent_id = etp.get_folder_id(package_id) and r.item_id = i.item_id; select object_type @@ -219,7 +217,7 @@ insert into acs_objects ( object_id, object_type, creation_date, creation_user) values - (v_new_revision_id, v_content_type, sysdate, p_user_id); + (v_new_revision_id, v_content_type, sysdate, user_id); insert into cr_revisions (revision_id, item_id, title, description, content, mime_type) @@ -241,23 +239,21 @@ end create_new_revision; function get_folder_id ( - p_package_id in apm_packages.package_id%TYPE + package_id in apm_packages.package_id%TYPE ) return integer is v_folder_id cr_folders.folder_id%TYPE; begin select folder_id into v_folder_id from cr_folders - where package_id = p_package_id; - - exception when no_data_found then v_folder_id := content_item.c_root_folder_id; - + where package_id = get_folder_id.package_id; return v_folder_id; + exception when no_data_found then return content_item.c_root_folder_id; end get_folder_id; function get_relative_url ( - p_item_id in cr_items.item_id%TYPE, - p_name in varchar + item_id in cr_items.item_id%TYPE, + name in varchar ) return varchar is v_url cr_extlinks.url%TYPE; @@ -276,28 +272,28 @@ select object_type into v_object_type from acs_objects - where object_id = p_item_id; + where object_id = get_relative_url.item_id; if v_object_type = 'content_item' then - return p_name; + return name; end if; -- is this portable? wouldn't seperator be better if v_object_type = 'content_folder' then - return p_name || '/'; + return name || '/'; end if; if v_object_type = 'content_extlink' then select url into v_url from cr_extlinks - where extlink_id = p_item_id; + where extlink_id = get_relative_url.item_id; return v_url; end if; if v_object_type = 'content_symlink' then select target_id into v_item_id from cr_symlinks - where symlink_id = p_item_id; + where symlink_id = get_relative_url.item_id; open v_link_rec; fetch v_link_rec into v_package_id, v_name; @@ -317,27 +313,27 @@ function get_title( - p_item_id in cr_items.item_id%TYPE, - p_revision_title in varchar + item_id in cr_items.item_id%TYPE, + revision_title in varchar ) return varchar is v_title cr_revisions.title%TYPE; v_object_type acs_objects.object_type%TYPE; v_item_id cr_items.item_id%TYPE; begin - if p_revision_title is not null then - return p_revision_title; + if revision_title is not null then + return revision_title; end if; select object_type into v_object_type from acs_objects - where object_id = p_item_id; + where object_id = get_title.item_id; if v_object_type = 'content_folder' then select r.title into v_title from cr_items i, cr_revisions r - where i.parent_id = p_item_id + where i.parent_id = get_title.item_id and i.name = 'index' and i.live_revision = r.revision_id; return v_title; @@ -346,21 +342,21 @@ if v_object_type = 'content_extlink' then select label into v_title from cr_extlinks - where extlink_id = p_item_id; + where extlink_id = get_title.item_id; return v_title; end if; if v_object_type = 'content_symlink' then select target_id into v_item_id from cr_symlinks - where symlink_id = p_item_id; - return etp.get_title(p_item_id, null); + where symlink_id = get_title.item_id; + return etp.get_title(item_id, null); end if; if v_object_type = 'content_item' then select r.title into v_title from cr_items i, cr_revisions r - where i.item_id = p_item_id + where i.item_id = get_title.item_id and i.live_revision = r.revision_id; return v_title; end if; @@ -370,27 +366,27 @@ end get_title; function get_description( - p_item_id in cr_items.item_id%TYPE, - p_revision_description in varchar + item_id in cr_items.item_id%TYPE, + revision_description in varchar ) return varchar is v_description cr_revisions.description%TYPE; v_object_type acs_objects.object_type%TYPE; v_item_id cr_items.item_id%TYPE; begin - if p_revision_description is not null then - return p_revision_description; + if revision_description is not null then + return revision_description; end if; select object_type into v_object_type from acs_objects - where object_id = p_item_id; + where object_id = get_description.item_id; if v_object_type = 'content_folder' then select r.description into v_description from cr_items i, cr_revisions r - where i.parent_id = p_item_id + where i.parent_id = get_description.item_id and i.name = 'index' and i.live_revision = r.revision_id and i.item_id = r.item_id; @@ -400,21 +396,21 @@ if v_object_type = 'content_extlink' then select description into v_description from cr_extlinks - where extlink_id = p_item_id; + where extlink_id = get_description.item_id; return v_description; end if; if v_object_type = 'content_symlink' then select target_id into v_item_id from cr_symlinks - where symlink_id = p_item_id; - return etp.get_description(p_item_id, null); + where symlink_id = get_description.item_id; + return etp.get_description(item_id, null); end if; if v_object_type = 'content_item' then select r.description into v_description from cr_items i, cr_revisions r - where i.item_id = p_item_id + where i.item_id = get_description.item_id and i.live_revision = r.revision_id; return v_description; end if; Index: openacs-4/packages/edit-this-page/tcl/etp-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-init.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/edit-this-page/tcl/etp-init.tcl 24 Sep 2001 17:24:13 -0000 1.1 +++ openacs-4/packages/edit-this-page/tcl/etp-init.tcl 17 Nov 2001 19:48:47 -0000 1.2 @@ -9,36 +9,25 @@ } # Definitions of the attributes that belong to special content types - -etp::define_content_type journal_issue "Journal Issue" "Journal Issues" { - { publication_date "Publication Date" "Publication Dates" string "size=60" "" } - { issue_name "Issue name" "Issue names" string "size=60" "" } -} - - -etp::define_content_type journal_article "Journal Article" "Journal Articles" { - { section Section Sections string "" "" } - { byline Byline Bylines string "" "" } - { abstract Abstract Abstracts string "rows=24 cols=80" "" } - { citation Citation Citations string "rows=4 cols=80" "" } -} - - -etp::define_content_type news_item "News Item" "News Items" { - { location "Location" "Location" string "size=80" "" } - { subtitle "Subtitle" "Subtitle" string "rows=4 cols=80" "" } - { release_date "Release Date" "Release Dates" string "size=60" "" } - { archive_date "Archive Date" "Archive Dates" string "size=60" "" } -} - -# Definitions of ETP "applications". One of these must be chosen for +# and of ETP "applications". One of "application" must be chosen for # each package instance of ETP, thereby determining the behavior and # appearance of the package and the admin pages. # Note: when defining your own application, you can specify # whichever of these parameters you want to change; those you leave # unspecified will be looked up from the "default" application. +# DRB: I added code to guard these definitions and to only define applications if the +# type exists or is successfully created. This is a workaround for the fact that certain +# older packages may define types with the same pretty name as an ETP type. When such a +# package was mounted, ETP would not work. The real-life example is news, where both the +# original news package and ETP define a content type with the pretty name "News Item". +# The name is so logical that I couldn't really see much sense in changing the name in +# one package or the other. + +# This admittedly has made the code ugly but mounting news or any other package must +# not be allowed to break ETP ... + etp::define_application default { index_template packages/edit-this-page/templates/article-index index_content_type content_revision @@ -61,7 +50,44 @@ auto_page_name "" } +if { [catch {etp::define_content_type journal_issue "Journal Issue" "Journal Issues" { + { publication_date "Publication Date" "Publication Dates" string "size=60" "" } + { issue_name "Issue name" "Issue names" string "size=60" "" } + }} errmsg]} { + ns_log Notice "ETP: define 'Journal Issue' failed: $errmsg" +} +if { [catch {etp::define_content_type journal_article "Journal Article" "Journal Articles" { + { section Section Sections string "" "" } + { byline Byline Bylines string "" "" } + { abstract Abstract Abstracts string "rows=24 cols=80" "" } + { citation Citation Citations string "rows=4 cols=80" "" } + }} errmsg]} { + ns_log Notice "ETP: define 'Journal Articles' failed: $errmsg" +} + + +if { [catch {etp::define_content_type news_item "News Item" "News Items" { + { location "Location" "Location" string "size=80" "" } + { subtitle "Subtitle" "Subtitle" string "rows=4 cols=80" "" } + { release_date "Release Date" "Release Dates" string "size=60" "" } + { archive_date "Archive Date" "Archive Dates" string "size=60" "" } + }} errmsg]} { + ns_log Notice "ETP: define 'News Items' failed: $errmsg" +} else { + etp::define_application news { + index_template packages/edit-this-page/templates/news-index + content_template packages/edit-this-page/templates/news-content + content_content_type news_item + content_object_name "news item" + allow_subtopics f + allow_extlinks f + allow_symlinks f + auto_page_name "number" + } +} + + etp::define_application faq { index_template packages/edit-this-page/templates/faq-index index_object_name "FAQ" @@ -76,15 +102,3 @@ allow_symlinks f auto_page_name "number" } - - -etp::define_application news { - index_template packages/edit-this-page/templates/news-index - content_template packages/edit-this-page/templates/news-content - content_content_type news_item - content_object_name "news item" - allow_subtopics f - allow_extlinks f - allow_symlinks f - auto_page_name "number" -} Index: openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql 16 Nov 2001 03:11:08 -0000 1.3 +++ openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql 17 Nov 2001 19:48:47 -0000 1.4 @@ -2,42 +2,34 @@ oracle8.1.6 - + begin acs_object_type.create_type ( - :content_type, - :pretty_name, - :pretty_plural, - 'content_revision', - :content_type, - :content_type, - null, - 'f', - null, - null + object_type => :content_type, + pretty_name => :pretty_name, + pretty_plural => :pretty_plural, + supertype => 'content_revision', + table_name => :content_type, + id_column => :content_type ); end; - + begin :1 := acs_attribute.create_attribute ( - :content_type, - :a_name, - :a_datatype, - :a_pretty_name, - :a_pretty_plural, - null, - null, - :a_default, - 1, - 1, - null, - 'generic', - 'f' + object_type => :content_type, + attribute_name => :a_name, + datatype => :a_datatype, + pretty_name => :a_pretty_name, + pretty_plural => :a_pretty_plural, + default_value => :a_default, + min_n_values => 1, + max_n_values => 1, + storage => 'generic' ); end; @@ -46,12 +38,12 @@ begin - etp.create_page( - :package_id, - :name, - :title, - :content_type - ); + :1 := etp.create_page( + package_id => :package_id, + name => :name, + title => :title, + content_type => :content_type + ); end; @@ -119,13 +111,11 @@ select * from ( select $columns - from cr_items i - left join - cr_revisions r - on (i.live_revision = r.revision_id) + from cr_items i, cr_revisions r where i.parent_id = etp.get_folder_id(:package_id) and i.name != 'index' - ) as attributes + and i.live_revision = r.revision_id(+) + ) attributes where $extra_where_clauses order by $orderby $limit_clause Index: openacs-4/packages/edit-this-page/www/etp-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/edit-this-page/www/etp-oracle.xql 31 Oct 2001 05:00:02 -0000 1.2 +++ openacs-4/packages/edit-this-page/www/etp-oracle.xql 17 Nov 2001 19:48:47 -0000 1.3 @@ -6,7 +6,7 @@ select i.item_id, i.name, r.revision_id, r.title, content_revision.get_number(r.revision_id) as latest_revision, - content_revision.get_number(r.live_revision) as live_revision, + content_revision.get_number(i.live_revision) as live_revision, r.description, r.publish_date, r.content $extended_attributes from cr_items i, cr_revisions r where i.parent_id = :package_id Index: openacs-4/packages/edit-this-page/www/etp-setup-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-2-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/edit-this-page/www/etp-setup-2-oracle.xql 31 Oct 2001 05:21:41 -0000 1.2 +++ openacs-4/packages/edit-this-page/www/etp-setup-2-oracle.xql 17 Nov 2001 19:48:47 -0000 1.3 @@ -4,13 +4,20 @@ -select content_folder.new(:name, :title, '', etp_get_folder_id(:parent_package_id)); + begin + :1 := content_folder.new( + name => :name, + label => :title, + description => '', + parent_id => etp.get_folder_id(:parent_package_id) + ); + end; -select acs_object.name(:package_id) as title + select acs_object.name(:package_id) as title from dual