Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/cms/www/modules/items/template-register.adp'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/cms/www/modules/items/template-register.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/template-register.tcl,v diff -u -r1.4 -r1.4.12.1 --- openacs-4/packages/cms/www/modules/items/template-register.tcl 19 Aug 2002 03:30:59 -0000 1.4 +++ openacs-4/packages/cms/www/modules/items/template-register.tcl 31 May 2005 04:55:51 -0000 1.4.12.1 @@ -1,26 +1,71 @@ -# Add a template of the item +ad_page_contract { -request create -request set_param item_id -datatype integer -request set_param template_id -datatype integer -request set_param context -datatype keyword + @author Michael Steigman + @creation-date May 2005 +} { + { item_id:naturalnum } + { mount_point:optional "sitemap" } + { item_props_tab:optional "publishing" } + { template_id:naturalnum,optional } + { context:optional } +} +# get templates from the clipboard +set clip [clipboard::parse_cookie] +set templates [clipboard::get_items $clip templates] -db_transaction { +# if no templates are clipped, send user a message and abort +if { [llength $templates] < 1 } { + util_user_message -message "There are no templates on the clipboard" + ad_returnredirect [export_vars -base index {item_id item_props_tab mount_point}] +} - # check to make sure that no template is already registered - # to this item in this context - set second_template_p [db_string second_template_p ""] +ad_form -name select_template -form { + {item_id:naturalnum(hidden) + {value $item_id}} +} - if { $second_template_p == 0 } { - if { [catch { db_exec_plsql register_template_to_item "begin content_item.register_template( - item_id => :item_id, - template_id => :template_id, - use_context => :context ); - end;"} err_msg] } { - ns_log notice "template-register.tcl got an error: $err_msg" - } +# set up template options (if any) +if { [llength $templates] > 1 } { + set options [list] + foreach template_id $templates { + set path [content::template::get_path -template_id $template_id] + lappend options [list $path $template_id] } + ad_form -extend -name select_template -form { + {template_id:naturalnum(radio) + {label "Template"} + {options $options}} + } + +} else { + set path [content::template::get_path -template_id $templates] + ad_form -extend -name select_template -form { + {path:text(inform) + {label "Template"} + {value $path}} + {template_id:naturalnum(hidden) + {value $templates}} + } } -forward "../items/index?item_id=$item_id&#templates" + +set context_options [db_list_of_lists get_contexts {}] +ad_form -extend -name select_template -form { + + {context:text(select) + {label "Use Context"} + {options $context_options}} + +} -on_submit { + + if { ![db_string second_template_p {}] } { + content::item::register_template -item_id $item_id \ + -template_id $template_id -use_context $context + } else { + util_user_message -message "There is already a template registered for $context context" + } + + ad_returnredirect [export_vars -base index { item_id mount_point item_props_tab }] + +} Index: openacs-4/packages/cms/www/modules/items/template-register.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/template-register.xql,v diff -u -r1.1 -r1.1.14.1 --- openacs-4/packages/cms/www/modules/items/template-register.xql 25 May 2001 04:56:36 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/template-register.xql 31 May 2005 04:55:51 -0000 1.1.14.1 @@ -10,5 +10,12 @@ + + + + select use_context, use_context from cr_template_use_contexts + + + Index: openacs-4/packages/cms/www/modules/items/templates.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/templates.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/cms/www/modules/items/templates.adp 13 Apr 2005 20:15:19 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/templates.adp 31 May 2005 04:55:51 -0000 1.3.2.1 @@ -1,10 +1,12 @@ -Templates Registered to @iteminfo.name@ +Templates Registered to content item "@iteminfo.name@": -

+

 

-Templates Registered to @iteminfo.pretty_name@ +Templates Registered to content type "@iteminfo.pretty_name@": + +

Index: openacs-4/packages/cms/www/modules/items/templates.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/templates.tcl,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/cms/www/modules/items/templates.tcl 13 Apr 2005 20:15:19 -0000 1.5 +++ openacs-4/packages/cms/www/modules/items/templates.tcl 31 May 2005 04:55:51 -0000 1.5.2.1 @@ -13,10 +13,10 @@ # check if the user has write permission on the types module # MS: for now, we're just going to check if the user has write # privs on this item (need to think about this) -set can_set_default_template [permission::permission_p \ - -party_id $user_id \ - -object_id $item_id \ - -privilege write] +set can_set_default_template \ + [permission::permission_p -party_id $user_id \ + -object_id $item_id \ + -privilege write] db_1row get_iteminfo "" -column_array iteminfo @@ -25,24 +25,29 @@ template::list::create \ -name registered_templates \ -multirow registered_templates \ + -actions [list "Assign marked templates to this item" \ + [export_vars -base template-register {item_id}] \ + "Assign marked templates to this item"] \ -has_checkboxes \ -no_data "No templates registered to this content item" \ -elements { path { label "Path" } use_context { - label "Use Context?" + label "Use Context" } action { label "Action" - display_template "unregister" + display_template { + unregister + } } } # templates registered to this item -db_multirow -extend {unreg_url context} registered_templates get_reg_templates { - if {$can_read_template_p} { +db_multirow -extend {unreg_url context} registered_templates get_reg_templates {} { + if { [permission::permission_p -party_id $user_id -object_id $item_id -privilege write] } { set context $use_context set unreg_url [export_vars -base template-unregister {item_id template_id context}] } @@ -58,10 +63,10 @@ label "Path" } use_context { - label "Use Context?" + label "Use Context" } set_default_url { - label "Default?" + label "Is Default?" display_template { no, set default @@ -88,7 +93,7 @@ if {$can_read_template && $can_set_default_template} { set set_default_url [export_vars -base ../types/set-default-template {template_id context content_type return_url}] if {[string match $already_registered_p f] && {$registered_templates:rowcount == 0}} { - set register_template_url [export_vars -base template-register {item_id template_id contex return_url}] + set register_template_url [export_vars -base template-register {item_id template_id context return_url}] } else { set register_template_url "" }