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" -}