Index: openacs-4/packages/xcms-ui/xcms-ui.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/xcms-ui.info,v diff -u -r1.2 -r1.3 --- openacs-4/packages/xcms-ui/xcms-ui.info 1 May 2004 13:23:02 -0000 1.2 +++ openacs-4/packages/xcms-ui/xcms-ui.info 26 May 2004 01:05:22 -0000 1.3 @@ -23,6 +23,7 @@ + Index: openacs-4/packages/xcms-ui/lib/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/lib/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/lib/index.vuh 1 May 2004 12:09:16 -0000 1.1 +++ openacs-4/packages/xcms-ui/lib/index.vuh 26 May 2004 01:05:22 -0000 1.2 @@ -13,7 +13,6 @@ # Get the paths set the_root [ns_info pageroot] set the_url "/[ad_conn path_info]" -ns_log notice "DAVEB start $the_root / $the_url" # Get the IDs # Ugly hack to workaround the fact that a URL on index will match # index.vuh, causing path_info to be empty @@ -22,11 +21,11 @@ append the_url "index" } +set xcms_package_id "REPLACE-PACKAGE-ID" +set content_root [parameter::get -parameter root_folder_id -package_id $xcms_package_id] +set template_root [parameter::get -parameter template_folder_id -package_id $xcms_package_id] -set content_root [parameter::get -parameter root_folder_id -default "-100"] -set template_root [parameter::get -parameter template_folder_idi -default "-200"] -ns_log notice "content_root $content_root template_root $template_root" -set context [parameter::get -parameter cms_context -default "public"] +set context "REPLACE-USE-CONTEXT" # Serve the page Index: openacs-4/packages/xcms-ui/lib/xcms-default.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/lib/xcms-default.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/lib/xcms-default.adp 1 May 2004 12:09:16 -0000 1.1 +++ openacs-4/packages/xcms-ui/lib/xcms-default.adp 26 May 2004 01:05:22 -0000 1.2 @@ -1,4 +1,4 @@ - + @title;noquote@ @context;noquote@

TEST

Index: openacs-4/packages/xcms-ui/lib/xcms-folder-default.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/lib/xcms-folder-default.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/lib/xcms-folder-default.adp 1 May 2004 12:09:16 -0000 1.1 +++ openacs-4/packages/xcms-ui/lib/xcms-folder-default.adp 26 May 2004 01:05:22 -0000 1.2 @@ -1,4 +1,4 @@ - + @label;noquote@ @context;noquote@ Index: openacs-4/packages/xcms-ui/tcl/xcms-ui-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/tcl/xcms-ui-install-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/tcl/xcms-ui-install-procs.tcl 1 May 2004 12:09:17 -0000 1.1 +++ openacs-4/packages/xcms-ui/tcl/xcms-ui-install-procs.tcl 26 May 2004 01:05:22 -0000 1.2 @@ -2,128 +2,157 @@ Install callback procedures for xcms-ui-base } -namespace eval xcms_ui_base::install {} +namespace eval xcms_ui::install {} -ad_proc xcms_ui_base::install::package_install {} { +ad_proc xcms_ui::install::package_install {} { - } -ad_proc xcms_ui_base::install::after_mount { +ad_proc xcms_ui::install::after_mount { -package_id -node_id } { After mount callback } { - register_default_templates -package_id $package_id -node_id $node_id + array set sn [site_node::get_from_object_id -object_id $package_id] + ns_log notice " +-------------------------------------------------------------------------------- +DAVE debugging procedure xcms_ui::install::after_mount +-------------------------------------------------------------------------------- +sn = '[array get sn]' +--------------------------------------------------------------------------------" + # create a new folder for this package_id + set folder_id [bcms::folder::create_folder \ + -name "pages-${package_id}" \ + -folder_label "Pages" \ + -parent_id "0" \ + -description "Content Managed Pages" \ + -package_id $package_id \ + -context_id $package_id \ + -content_types "content_revision content_folder content_extlink content_symlink image" + ] -} + # setup a template folder also + set template_folder_id [bcms::folder::create_folder \ + -name "templates-${package_id}" \ + -folder_label "Templates" \ + -parent_id "0" \ + -description "Content Templates" \ + -package_id $package_id \ + -context_id $package_id \ + -content_types "content_template" + ] -ad_proc xcms_ui_base::install::register_default_templates { - -package_id - -node_id -} { - Register default templates for content_folder - and content_revision. Import templates from - packages/xcms-ui-base/templates/ and create template folders +# load in default templates -} { +set template_root "templates$sn(url)" +set template_dir "[acs_root_dir]/${template_root}" +set www_dir "[acs_root_dir]/www$sn(url)" -# register public display templates +if {![file exists $template_dir]} { + file mkdir $template_dir +} - set parent_subsite_package_id [site_node::closest_ancestor_package \ - -node_id $node_id \ - -package_key "acs-subsite" - ] +if {![file exists $www_dir]} { + file mkdir $www_dir +} - set parent_subsite_url [apm_package_url_from_id $parent_subsite_package_id] - - set template_folder_id [parameter::get \ - -parameter "TemplateRoot" \ - -package_id $parent_subsite_package_id - ] - - if {![empty_string_p $template_folder_id]} { - - set template_folder_id [xcms::folder::create_folder \ - -name "xcms-${package_id}-templates" \ - -folder_label "XCMS ${package_id} Templates" \ - -parent_id "-200" \ - -content_types [list content_folder content_template]] - - parameter::set_value \ - -package_id $package_id \ - -parameter "template_folder_id" \ - -value $template_folder_id +set templates [list xcms-default content_revision "Default Content Template" xcms-folder-default content_folder "Default Folder Template"] +set template_base "[acs_root_dir]/packages/xcms-ui/lib/" - } - - set template_root "[acs_root_dir]/templates/${parent_subsite_url}" +# setup use_context +set use_context "xcms-${package_id}-public" +db_dml set_use_context "insert into cr_template_use_contexts values (:use_context)" - parameter::set_value \ - -package_id $package_id \ - -parameter TemplateRoot \ - -value $template_root - -# ideally we create a folder mapped to the site_node here set -# to the content_root_id parameter, problem is, if we -# want to manage the main site content, so default to subsite root -# which for now is just -100 - - set default_template_id [xcms::template::create_template \ - -template_name "xcms-default" \ - -parent_id $template_folder_id] - set default_template_dir [acs_r set template_root "[acs_root_dir]/templates/${parent_subsite_url}" +foreach {filename content_type title } $templates { - set default_template_file [acs_root_dir]/packages/xcms-ui-base/lib/xcms-default - set fd [open ${default_template_file}.adp] - set default_template_content [read $fd] + set template_id [bcms::template::create_template \ + -template_name $filename \ + -parent_id $template_folder_id] + + set fd [open "${template_base}${filename}.adp"] + set content [read $fd] close $fd - - xcms::template::add_template \ - -template_id $default_template_id \ - -title "Default Content Template" \ - -content $default_template_content + + + bcms::template::register_template \ + -template_id $template_id \ + -content_type $content_type \ + -context $use_context \ + -is_default_p "t" - set folder_template_id [xcms::template::create_template \ - -template_name "xcms-folder-default" \ - -parent_id $template_folder_id] + bcms::template::add_template \ + -template_id $template_id \ + -title $title \ + -content $content + + file copy -force "${template_base}${filename}.adp" "${template_base}${filename}.tcl" $template_dir - set default_folder_template_file [acs_root_dir]/packages/xcms-ui-base/lib/xcms-folder-default - set fd [open ${default_folder_template_file}.adp] - set default_folder_template_content [read $fd] - close $fd - +} - xcms::template::add_template \ - -template_id $folder_template_id \ - -title "Default Folder Template" \ - -content $default_folder_template_content - file mkdir $template_root - file copy ${default_template_dir}/public $template_root - file copy ${default_template_dir} ${template_root} - xcms::template::register_template \ - -content_type "content_revision" \ - -template_id $default_template_id \ - -context "xcms-public" +# import the sample index page +set fd [open ${template_base}sample-index.adp] +set sample_index_content [read $fd] +close $fd - xcms::template::register_template \ - -content_type "content_folder" \ - -template_id $folder_template_id \ - -context "xcms-public" +set sample_index_id [bcms::create_page \ + -page_name "index" \ + -folder_id $folder_id \ + -mime_type "text/html" \ + -title "XCMS Sample Index" \ + -page_body $sample_index_content] +# set live revision +item::publish -item_id $sample_index_id +# TODO remove these +# set parameters + +parameter::set_value -package_id $package_id -parameter "root_folder_id" -value $folder_id +parameter::set_value -package_id $package_id -parameter "template_folder_id" -value $template_folder_id +parameter::set_value -package_id $package_id -parameter "TemplateRoot" -value $template_root +parameter::set_value -package_id $package_id -parameter cms_context -value $use_context +# FIXME this requires a call from pl/sql to register the relationship + +# TODO add cr_item_rels for content and template folders, conext is +# always xcms-${package_id}-public +#bcms::item::relate_item \ + -item_id $folder_id \ + -relation_tag "xcms-root-content-folder" \ + -related_object_id $sn(node_id) +#bcms::item::relate_item \ + -item_id $template_folder_id \ + -relation_tag "xcms-root-template-folder" \ + -related_object_id $sn(node_id) + + +# get default index.vuh file +# substitute default folder ids + +#set fd [open "${template_base}index.vuh"] +#set index_content [read $fd] +#close $fd + +#regsub -- {-100} $index_content $folder_id index_content] +#regsub -- {-200} $index_content $template_folder_id index_content] +#regsub -- {REPLACE-USE-CONTEXT} $index_content $use_context index_content] +#regsub -- {REPLACE-PACKAGE-ID} $index_content $package_id index_content] + +#set fd [open "${www_dir}index.vuh" w] +#puts $fd $index_content +#close $fd + } -ad_proc xcms_ui_base::install::package_uninstall {} { +ad_proc xcms_ui::install::package_uninstall {} { } { unregister_templates } -ad_proc xcms_ui_base::install::unregister_templates {} { +ad_proc xcms_ui::install::unregister_templates {} { unregister templates for package removal Index: openacs-4/packages/xcms-ui/tcl/xcms-ui-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/tcl/xcms-ui-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/tcl/xcms-ui-procs.tcl 1 May 2004 12:09:17 -0000 1.1 +++ openacs-4/packages/xcms-ui/tcl/xcms-ui-procs.tcl 26 May 2004 01:05:22 -0000 1.2 @@ -9,9 +9,9 @@ } -namespace eval bcms_ui_base {} +namespace eval xcms_ui {} -ad_proc -public bcms_ui_base::move_url { +ad_proc -public xcms_ui::move_url { {-items_to_move:required} {-destination_folder:required} {-return_url:required} @@ -43,7 +43,7 @@ } -ad_proc -public bcms_ui_base::delete_url { +ad_proc -public xcms_ui::delete_url { {-items_to_delete:required} {-return_url:required} {-confirm:boolean} @@ -69,7 +69,7 @@ } } -ad_proc -public bcms_ui_base::apply_template_url { +ad_proc -public xcms_ui::apply_template_url { {-item_id:required} {-template_id:required} {-return_url:required} @@ -88,7 +88,7 @@ } -ad_proc -public bcms_ui_base::delete_template_url { +ad_proc -public xcms_ui::delete_template_url { {-templates_to_delete:required} {-return_url:required} } { @@ -106,7 +106,7 @@ } -ad_proc -public bcms_ui_base::switch_cms_context_url { +ad_proc -public xcms_ui::switch_cms_context_url { {-cms_context:required} {-return_url} } { @@ -127,7 +127,7 @@ } -ad_proc -public bcms_ui_base::context_action_link { +ad_proc -public xcms_ui::context_action_link { {-context_action:required} {-export_vars:required} {-context_action_label} @@ -341,7 +341,7 @@ } -ad_proc -public bcms_ui_base::redirect_after_rename { +ad_proc -public xcms_ui::redirect_after_rename { {-item_id:required} {-url_base "[ad_conn package_url]"} } { @@ -361,7 +361,7 @@ ad_script_abort } -ad_proc -public bcms_ui_base::check_include_vars { +ad_proc -public xcms_ui::check_include_vars { } { check item_id, folder_id, revision_id, form_mode and return_url vars. This is used for the forms that is included in /xcms-ui/lib } { @@ -384,3 +384,33 @@ error "return_url does not exists, please pass in return_url" } } + +ad_proc xcms_ui::content_root { + {-node_id ""} +} { + @param node_id If node_id is specified content root is returned + for that site_node. Otherwise the node_id of the current request + is used. + @return content folder_id for node_id. empty string if no folder + is mapped to node_id + +} { + + return [db_string get_content_root "" -default ""] + + +} + +ad_proc xcms_ui::template_root { + {-node_id ""} +} { + @param node_id If node_id is specified content root is returned + for that site_node. Otherwise the node_id of the current request + is used. + @return content folder_id for node_id. empty string if no folder + is mapped to node_id +} { + + return [db_string get_content_root "" -default ""] + +} Index: openacs-4/packages/xcms-ui/www/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/www/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xcms-ui/www/index.vuh 1 May 2004 12:09:17 -0000 1.1 +++ openacs-4/packages/xcms-ui/www/index.vuh 26 May 2004 01:05:22 -0000 1.2 @@ -23,7 +23,8 @@ append the_url "index" } - +#set content_root [xcms_ui::content_root] +#set template_root [xcms_ui::template_root] set content_root [parameter::get -parameter root_folder_id -default "-100"] set template_root [parameter::get -parameter template_folder_id -default "-200"] Index: openacs-4/packages/xcms-ui/www/admin/setup.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xcms-ui/www/admin/setup.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/xcms-ui/www/admin/setup.tcl 1 May 2004 13:23:03 -0000 1.3 +++ openacs-4/packages/xcms-ui/www/admin/setup.tcl 26 May 2004 01:05:22 -0000 1.4 @@ -1,3 +1,4 @@ + ad_page_contract { setup folders and templates @@ -51,7 +52,7 @@ -content_types "content_revision content_folder content_extlink content_symlink image" \ -subtypes ] - + # Main Subsite folder -100 already has a corresponding template # folder. If we are not setting up for folder_id -100 create # a template folder also @@ -69,8 +70,8 @@ # load in default templates -set template_root "/templates${sn(url)}" -set template_dir "[acs_root_dir]${template_root}" +set template_root "templates${sn(url)}" +set template_dir "[acs_root_dir]/${template_root}" set www_dir "[acs_root_dir]/www${sn(url)}" if {![file exists $template_dir]} { @@ -93,10 +94,14 @@ set content [read $fd] close $fd + # setup use_context + + db_dml set_use_context "insert into cr_template_use_contexts values ('xcms-${package_id}-public')" + bcms::template::register_template \ -template_id $template_id \ -content_type $content_type \ - -context "public" \ + -context "xcms-public" \ -is_default_p "t" bcms::template::add_template \ @@ -108,6 +113,19 @@ } + +# import the sample index page +set fd [open ${template_base}sample-index.adp] +set sample_index_content [read $fd] +close $fd + +bcms::create_page \ + -page_name "index" \ + -folder_id $folder_id \ + -mime_type "text/html" \ + -title "XCMS Sample Index" \ + -page_body $sample_index_content + # set parameters parameter::set_value -parameter "root_folder_id" -value $folder_id