Index: openacs-4/packages/cms/cms.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/cms.info,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/cms.info 17 Aug 2001 02:53:47 -0000 1.3 +++ openacs-4/packages/cms/cms.info 20 Aug 2001 04:35:41 -0000 1.4 @@ -4,7 +4,7 @@ Content Management System Content Management Systems - f + t t Index: openacs-4/packages/cms/tcl/browser-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/browser-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/browser-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/browser-procs.tcl 20 Aug 2001 04:35:41 -0000 1.2 @@ -16,12 +16,14 @@ # ################################################# -# Initialize the workspace for the first time, -# by building a state consisting only of the top-level mount points -# Return the state +ad_proc -public initFolderTree { user_id } { -proc initFolderTree { user_id } { + Initialize the workspace for the first time, + by building a state consisting only of the top-level mount points + Return the state +} { + set state [list] foreach mount_point [buildMountPoints $user_id] { lappend state [stateNodeCreate [folderAccess mount_point $mount_point] [list]] @@ -30,15 +32,17 @@ } -# Recursively rebuild the tree state based on the requested expand or collapse action -# Rebuild the children of each folder and return them -# Payload is any extra data that needs to be passed in - -proc updateTreeStateChildren { +ad_proc -public updateTreeStateChildren { user_id children mount_point target_mount_point target_id action level stateRef update_time payload } { + + Recursively rebuild the tree state based on the requested expand or collapse + action. Rebuild the children of each folder and return them + Payload is any extra data that needs to be passed in + +} { set new_children [list] upvar $stateRef state @@ -195,20 +199,26 @@ } -# Rebuild the tree state based on user's action and return the new state -proc updateTreeState { +ad_proc -public updateTreeState { user_id state target_mount_point target_id action update_time {payload ""} } { + + Rebuild the tree state based on user's action and return the new state + +} { return [updateTreeStateChildren $user_id $state "" $target_mount_point \ $target_id $action 0 state $update_time $payload] } -# Get a linear rendition of the folder tree suitable for presentation -proc fetchStateFolders { user_id stateRef } { +ad_proc -public fetchStateFolders { user_id stateRef } { + Get a linear rendition of the folder tree suitable for presentation + +} { + # Reference the state upvar $stateRef state @@ -234,11 +244,13 @@ return $folderList } -# Recursive procedure to fetch a folder's children and add them to the linear list -# of folders +ad_proc -public fetchStateChildFolders { user_id mount_point children folderListRef stateRef level parent_id } { -proc fetchStateChildFolders { user_id mount_point children folderListRef stateRef level parent_id } { + Recursive procedure to fetch a folder's children and add them to the linear + list of folders +} { + # access the growing folder list by reference upvar $folderListRef folderList upvar $stateRef state @@ -271,32 +283,41 @@ } } -# Retreive a "path" to the particular folder - in fact, this is a unique hash key -# used to reference the folder in the AOLServer cache +ad_proc -public folderPath { user_id mount_point folder_id } { -proc folderPath { user_id mount_point folder_id } { + Retreive a "path" to the particular folder - in fact, this is a unique hash + key used to reference the folder in the AOLServer cache + +} { return "${user_id}.${mount_point}.$folder_id" } -# Hit the database to retreive the list of children for the folder -# Recache the child folders if specified +ad_proc -public folderChildrenDB { mount_point folder_id } { -proc folderChildrenDB { mount_point folder_id } { + Hit the database to retreive the list of children for the folder + Recache the child folders if specified + +} { ns_log notice "DATABASE HIT: $mount_point.$folder_id" return [cm::modules::${mount_point}::getChildFolders $folder_id] } -# A constructtor procedure to implement the folder abstraction - -proc folderCreate { +ad_proc -public folderCreate { mount_point name id child_ids expandable {symlink f} {update_time 0}} { + + A constructtor procedure to implement the folder abstraction + + } { return [list $mount_point $name $id $child_ids $expandable $symlink $update_time] } -# An accessor procedure to implement the folder abstraction -proc folderAccess { op folder {user_id {}} } { +ad_proc -public folderAccess { op folder {user_id {}} } { + + An accessor procedure to implement the folder abstraction + +} { switch $op { mount_point { return [lindex $folder 0] } @@ -319,9 +340,11 @@ } } -# A "mutator" procedure for folders; actually, just returns the new folder +ad_proc -public folderMutate { op folder new_value } { -proc folderMutate { op folder new_value } { + A "mutator" procedure for folders; actually, just returns the new folder + +} { switch $op { mount_point { return [lreplace $folder 0 0 $new_value] } @@ -337,10 +360,12 @@ } } -# Convert a list of folders into a list of folder IDs, caching -# the folders in the process +ad_proc -public folderChildIDs { subfolder_list { user_id {}}} { -proc folderChildIDs { subfolder_list { user_id {}}} { + Convert a list of folders into a list of folder IDs, caching + the folders in the process + +} { set child_ids [list] foreach subfolder $subfolder_list { if { ![template::util::is_nil user_id] } { @@ -352,9 +377,12 @@ return $child_ids } -# A constructor procedure to implement the state node abstraction -proc stateNodeCreate { id children {selected ""}} { +ad_proc -public stateNodeCreate { id children {selected ""}} { + + A constructor procedure to implement the state node abstraction + +} { set ret [list $id $children] @@ -366,21 +394,28 @@ return $ret } -# An accessor procedure to implement the state node abstraction -proc stateNodeAccess { op node } { +ad_proc -public stateNodeAccess { op node } { + + An accessor procedure to implement the state node abstraction + +} { switch $op { id { return [lindex $node 0] } children { return [lindex $node 1] } selected { return [lindex $node 2] } } } -# Retreive folder information for a particular id. If that id does not exist in the cache, cache it. -# if id is the empty string, retreives the top-level mount point -proc getFolder { user_id mount_point folder_id stateRef } { +ad_proc -public getFolder { user_id mount_point folder_id stateRef } { + Retreive folder information for a particular id. If that id does not exist + in the cache, cache it. if id is the empty string, retreives the top-level + mount point + +} { + set folder_path [folderPath $user_id $mount_point $folder_id] if { ![folderIsCached $user_id $mount_point $folder_id] } { @@ -414,9 +449,12 @@ return [nsv_get browser_state $folder_path] } -# Build a list of all the top-level mount points, caching them in the process -proc buildMountPoints { user_id } { +ad_proc -public buildMountPoints { user_id } { + + Build a list of all the top-level mount points, caching them in the process + +} { set mount_point_list [cm::modules::getMountPoints] @@ -433,19 +471,25 @@ return $mount_point_list } -# Cache an individual folder -proc cacheOneFolder { user_id folder { override 0 }} { +ad_proc -public cacheOneFolder { user_id folder { override 0 }} { + + Cache an individual folder + +} { set path [folderAccess path $folder $user_id] if { $override || ![nsv_exists browser_state $path] } { ns_log notice "CACHING: $path $folder , override = $override" nsv_set browser_state $path $folder } } -# Change the cached update time in a folder -# If thr folder is not cached, do nothing -proc refreshCachedFolder { user_id mount_point folder_id } { +ad_proc -public refreshCachedFolder { user_id mount_point folder_id } { + + Change the cached update time in a folder + If thr folder is not cached, do nothing + +} { if { [folderIsCached $user_id $mount_point $folder_id] } { cacheOneFolder $user_id [folderMutate update_time \ @@ -454,26 +498,35 @@ } } -# Return 1 if the folder is in the cache, 0 otherwise -proc folderIsCached { user_id mount_point folder_id } { +ad_proc -public folderIsCached { user_id mount_point folder_id } { + + Return 1 if the folder is in the cache, 0 otherwise + +} { return [nsv_exists browser_state [folderPath $user_id $mount_point $folder_id]] } -# Uncache a folder so that it will be reloaded from the db -proc uncacheFolder { user_id mount_point folder_id } { +ad_proc -public uncacheFolder { user_id mount_point folder_id } { + + Uncache a folder so that it will be reloaded from the db + +} { set path [folderPath $user_id $mount_point $folder_id] # Catch in case the cached state does not exist (which could happen if # the server was restarted) catch " nsv_unset browser_state $path " dummy } -# Recursively traverse the path to some folder in a particular mount -# point, which is in the form -# mount_point_id parent_id_1 parent_id_2 ... folder_id -# Return the new path if the folder was found, an empty string otherwise +ad_proc -public getStateFolderPath { user_id folder_id children target_folder_id } { -proc getStateFolderPath { user_id folder_id children target_folder_id } { + Recursively traverse the path to some folder in a particular mount + point, which is in the form + mount_point_id parent_id_1 parent_id_2 ... folder_id + Return the new path if the folder was found, an empty string otherwise + +} { + # if the folder is found, return it as the last element of the path if { [string equal $folder_id $target_folder_id] } { return [list $folder_id] @@ -491,10 +544,13 @@ return "" } -# Traverse the state tree to discover the path to a particular folder. Then, -# cache all the folders on the path -proc cacheStateFolders { user_id target_mount_point target_folder_id stateRef } { +ad_proc -public cacheStateFolders { user_id target_mount_point target_folder_id stateRef } { + + Traverse the state tree to discover the path to a particular folder. Then, + cache all the folders on the path + +} { upvar $stateRef state @@ -525,12 +581,16 @@ } } -# Go through ALL children of the mount point and cache them, one by one, until the target -# folder is found. This will do a lot of redundant work, so be careful. -# This procedure will execute breadth-first search, in hope of finding the target folder quicker. -proc cacheMountPointFolders { user_id mount_point target_folder_id } { +ad_proc -public cacheMountPointFolders { user_id mount_point target_folder_id } { + Go through ALL children of the mount point and cache them, one by one, + until the target folder is found. This will do a lot of redundant work, + so be careful. This procedure will execute breadth-first search, in hope of + finding the target folder quicker. + +} { + ns_log notice "CRITICAL MISS: [folderPath $user_id $mount_point $target_folder_id]" set queue [folderChildrenDB $mount_point ""] Index: openacs-4/packages/cms/tcl/clipboard-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/clipboard-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/clipboard-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/clipboard-procs.tcl 20 Aug 2001 04:35:41 -0000 1.2 @@ -4,152 +4,189 @@ # ################ -namespace eval clipboard { +namespace eval clipboard { + # See clipboard-ui-procs.tcl + namespace eval ui {} +} - # Get the clipboard from a cookie and return it - proc parse_cookie {} { +ad_proc -public clipboard::parse_cookie {} { + + Get the clipboard from a cookie and return it + +} { set clipboard_cookie [template::util::get_cookie content_marks] ns_log notice $clipboard_cookie set clip [ns_set create] set mount_branches [split $clipboard_cookie "|"] set mount_points [list] set total_items 0 - + foreach branch $mount_branches { - if { [regexp {([a-zA-Z0-9]+):(.*)} $branch match mount_point items] } { - ns_log notice "CLIP: $branch" - set items_list [split $items ","] - set items_size [llength $items_list] - incr total_items $items_size - ns_set update $clip $mount_point $items_list - ns_set update $clip ${mount_point}_size $items_size - lappend mount_points $mount_point - } + if { [regexp {([a-zA-Z0-9]+):(.*)} $branch match mount_point items] } { + ns_log notice "CLIP: $branch" + set items_list [split $items ","] + set items_size [llength $items_list] + incr total_items $items_size + ns_set update $clip $mount_point $items_list + ns_set update $clip ${mount_point}_size $items_size + lappend mount_points $mount_point + } } ns_set put $clip __total_items__ $total_items ns_set put $clip __mount_points__ $mount_points - + return $clip - } +} - # Retreive all marked items as a list - proc get_items { clip mount_point } { +ad_proc -public clipboard::get_items { clip mount_point } { + + Retreive all marked items as a list + +} { return [ns_set get $clip $mount_point] - } +} - # Get the number of total items on the clipboard - proc get_total_items { clip } { +ad_proc -public clipboard::get_total_items { clip } { + + Get the number of total items on the clipboard + +} { return [ns_set get $clip __total_items__] - } +} - # Execute a piece of code for each item under the - # specified mount point, creating an item_id - # variable for each item id - proc map_code { clip mount_point code } { +ad_proc -public clipboard::map_code { clip mount_point code } { + + Execute a piece of code for each item under the + specified mount point, creating an item_id + variable for each item id + +} { set item_id_list [ns_set get $clip $mount_point] foreach id $item_id_list { - uplevel "set item_id $id; $code" + uplevel "set item_id $id; $code" } - } +} - # Determine if an item is marked - proc is_marked { clip mount_point item_id } { +ad_proc -public clipboard::is_marked { clip mount_point item_id } { + + Determine if an item is marked + +} { if { [lsearch -exact \ - [get_items $clip $mount_point] \ - $item_id] > -1} { - return 1 + [get_items $clip $mount_point] \ + $item_id] > -1} { + return 1 } else { - return 0 + return 0 } - } +} - # Use this function as part of the multirow query to - # set up the bookmark icon - proc get_bookmark_icon { clip mount_point item_id {row_ref row} } { +ad_proc -public clipboard::get_bookmark_icon { clip mount_point item_id {row_ref row} } { + + Use this function as part of the multirow query to + set up the bookmark icon + +} { upvar $row_ref row if { [clipboard::is_marked $clip $mount_point $item_id] } { - set row(bookmark) Bookmarked + set row(bookmark) Bookmarked } else { - set row(bookmark) Bookmarks + set row(bookmark) Bookmarks } return $row(bookmark) - } +} - # Add an item to the clipboard: BROKEN - proc add_item { clip mount_point item_id } { +ad_proc -public clipboard::add_item { clip mount_point item_id } { + + Add an item to the clipboard: BROKEN + +} { set old_items [ns_set get $clip $mount_point] if { [lsearch $old_items $item_id] == -1 } { - # Append the item - lappend old_items $item_id - ns_set update $clip $mount_point $old_items - ns_set update $clip ${mount_point}_size \ - [expr [ns_set get $clip ${mount_point}_size] + 1] - ns_set update $clip __total_items__ \ - [expr [ns_set get $clip __total_items__] + 1] - - # Append the mount point - set old_mount_points [ns_set get $clip __mount_points__] - if { [lsearch -exact $old_mount_points $mount_point] == -1 } { - lappend old_mount_points $mount_point - ns_set update $clip __mount_points__ $old_mount_points - } + # Append the item + lappend old_items $item_id + ns_set update $clip $mount_point $old_items + ns_set update $clip ${mount_point}_size \ + [expr [ns_set get $clip ${mount_point}_size] + 1] + ns_set update $clip __total_items__ \ + [expr [ns_set get $clip __total_items__] + 1] + + # Append the mount point + set old_mount_points [ns_set get $clip __mount_points__] + if { [lsearch -exact $old_mount_points $mount_point] == -1 } { + lappend old_mount_points $mount_point + ns_set update $clip __mount_points__ $old_mount_points + } } - } +} - # Remove an item from the clipboard: BROKEN - proc remove_item { clip mount_point item_id } { +ad_proc -public clipboard::remove_item { clip mount_point item_id } { + + Remove an item from the clipboard: BROKEN + +} { set old_items [ns_set get $clip $mount_point] set index [lsearch $old_items $item_id] if { $index != -1 } { - # Remove the item - set old_items [lreplace $old_items $index $index ""] - ns_set update $clip $mount_point $old_items - ns_set update $clip ${mount_point}_size \ - [expr [ns_set get $clip ${mount_point}_size] - 1] - ns_set update $clip __total_items__ \ - [expr [ns_set get $clip __total_items__] - 1] + # Remove the item + set old_items [lreplace $old_items $index $index ""] + ns_set update $clip $mount_point $old_items + ns_set update $clip ${mount_point}_size \ + [expr [ns_set get $clip ${mount_point}_size] - 1] + ns_set update $clip __total_items__ \ + [expr [ns_set get $clip __total_items__] - 1] } - } +} - # Actually set the new cookie: BROKEN - proc set_cookie { clip } { +ad_proc -public clipboard::set_cookie { clip } { + + Actually set the new cookie: BROKEN + +} { set the_cookie "" set mount_point_names [ns_set get $clip __mount_points__] set pipe "" foreach mount_point $mount_point_names { - append the_cookie "$pipe${mount_point}:[join [ns_set get $clip $mount_point] ,]" - set pipe "|" + append the_cookie "$pipe${mount_point}:[join [ns_set get $clip $mount_point] ,]" + set pipe "|" } template::util::set_cookie session content_marks $the_cookie - } +} - # Clear the clipboard: BROKEN - proc clear_cookie {} { +ad_proc -public clipboard::clear_cookie {} { + + Clear the clipboard: BROKEN + +} { template::util::clear_cookie content_marks - } +} - # Release the resources associated with the clipboard - proc free { clip } { +ad_proc -public clipboard::free { clip } { + + Release the resources associated with the clipboard + +} { ns_set free $clip - } +} - # determines whether clipboard should float or not - # currently incomplete, should be checking user prefs - proc floats_p {} { - return [ad_parameter ClipboardFloatsP] +ad_proc -public clipboard::floats_p {} { - } + determines whether clipboard should float or not + currently incomplete, should be checking user prefs - # See clipboard-ui-procs.tcl - namespace eval ui {} +} { + return [ad_parameter ClipboardFloatsP] } + + + Index: openacs-4/packages/cms/tcl/clipboard-ui-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/clipboard-ui-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/clipboard-ui-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/clipboard-ui-procs.tcl 20 Aug 2001 04:35:41 -0000 1.2 @@ -2,16 +2,19 @@ # Procedures to manipulate clipped items ######################################### -# Create a form for representing clipped items, -# also start a multirow datasource for the items -# The columns created for the multirow datasource by default are -# mount_point, item_id, title, checked, html -# -# row_code is the code to execute for each row that is added; -# will usually create -# element_names are the names of all the extra elements that will -# be created for each row of the form -proc clipboard::ui::form_create { form_name args } { +ad_proc -public clipboard::ui::form_create { form_name args } { + + Create a form for representing clipped items, + also start a multirow datasource for the items + The columns created for the multirow datasource by default are + mount_point, item_id, title, checked, html + + row_code is the code to execute for each row that is added; + will usually create + element_names are the names of all the extra elements that will + be created for each row of the form + +} { set default_columns [list mount_point item_id title checked] @@ -36,11 +39,14 @@ set form_properties(row_elements) $elements } -# Append a row to the multirow datasource -# If the -checked switch is specified, checks the box by default -# If the -eval switch is specified, executes the passed-in code -proc clipboard::ui::add_row { form_name mount_point item_id title args} { +ad_proc -public clipboard::ui::add_row { form_name mount_point item_id title args} { + Append a row to the multirow datasource + If the -checked switch is specified, checks the box by default + If the -eval switch is specified, executes the passed-in code + +} { + template::util::get_opts $args # Allocate a new row @@ -99,11 +105,14 @@ } -# A wrapper for element create which maintains the naming convention -# for the element. Appends the element to the multirow datasource -# and instantly renders the element, storing it in the html field -# of the datasource -proc clipboard::ui::element_create { form_name element_name args } { +ad_proc -public clipboard::ui::element_create { form_name element_name args } { + + A wrapper for element create which maintains the naming convention + for the element. Appends the element to the multirow datasource + and instantly renders the element, storing it in the html field + of the datasource + +} { # Get the variables set data_name "${form_name}_data" @@ -131,13 +140,16 @@ lappend row(elements) $element_name } -# Process a row of the table, executing whatever TCL code -# the user has passed in. -# Bind each element to its value (singular); -# Bind "${element}_values" to the values (plural). -proc clipboard::ui::process_row { form_name row_index row_dml } { +ad_proc -public clipboard::ui::process_row { form_name row_index row_dml } { + Process a row of the table, executing whatever TCL code + the user has passed in. + Bind each element to its value (singular); + Bind "${element}_values" to the values (plural). + +} { + # Bind variable names to values set code "upvar 0 \"${form_name}_data:${row_index}\" row\n" upvar "${form_name}_data:${row_index}" row @@ -158,9 +170,12 @@ uplevel $code } -# Assemble the entire datasource based on all items under some mount point -proc clipboard::ui::generate_form { form_name clip mount_point } { +ad_proc -public clipboard::ui::generate_form { form_name clip mount_point } { + Assemble the entire datasource based on all items under some mount point + +} { + uplevel " set __form_name $form_name set __mount_point $mount_point @@ -185,8 +200,11 @@ } } -# Generate the extra ... tags based on the elements in some row -proc clipboard::ui::generate_form_header { form_name {row_index 1}} { +ad_proc -public clipboard::ui::generate_form_header { form_name {row_index 1}} { + + Generate the extra ... tags based on the elements in some row + +} { upvar "${form_name}_header" header upvar "${form_name}_data:${row_index}" row @@ -205,9 +223,12 @@ } } -# Process the entire form, executing the same DML for each row -# If no DML is specified, uses the global dml -proc clipboard::ui::process_form { form_name row_dml } { +ad_proc -public clipboard::ui::process_form { form_name row_dml } { + + Process the entire form, executing the same DML for each row + If no DML is specified, uses the global dml + +} { upvar "${form_name}_data:rowcount" rowcount for {set i 1} {$i <= $rowcount} {incr i} { Index: openacs-4/packages/cms/tcl/content-add-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/content-add-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/content-add-procs.tcl 2 Jul 2001 14:24:21 -0000 1.3 +++ openacs-4/packages/cms/tcl/content-add-procs.tcl 20 Aug 2001 04:35:41 -0000 1.4 @@ -19,7 +19,20 @@ # @param content_type The content type of the item # @param item_id The item id -ad_proc content_add::content_method_html { content_type item_id } { +ad_proc -public content_add::content_method_html { content_type item_id } { + + + @public content_method_html + + Generates HTML stub for revision content method choices for a content item + + @author Michael Pih + + @param db A database handle + @param content_type The content type of the item + @param item_id The item id + +} { set content_method_html "" Index: openacs-4/packages/cms/tcl/content-method-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/content-method-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/content-method-procs.tcl 17 Aug 2001 04:31:38 -0000 1.3 +++ openacs-4/packages/cms/tcl/content-method-procs.tcl 20 Aug 2001 04:35:41 -0000 1.4 @@ -8,24 +8,25 @@ namespace eval content_method {} +ad_proc content_method::get_content_methods { content_type args } { -# @public get_content_methods + @public get_content_methods -# Returns a list of content_methods that are associated with -# a content type, first checking for a default method, then for registered -# content methods, and then for all content methods + Returns a list of content_methods that are associated with + a content type, first checking for a default method, then for registered + content methods, and then for all content methods -# @author Michael Pih + @author Michael Pih -# @param content_type The content type -# @option get_labels Instead of a list of content methods, return -# a list of label-value pairs of associated content methods. -# @return A list of content methods or a list of label-value pairs of -# content methods if the "-get_labels" option is specified -# @see {content_method::get_content_method_options, -# content_method::text_entry_filter_sql } + @param content_type The content type + @option get_labels Instead of a list of content methods, return + a list of label-value pairs of associated content methods. + @return A list of content methods or a list of label-value pairs of + content methods if the "-get_labels" option is specified + @see {content_method::get_content_method_options, + content_method::text_entry_filter_sql } -ad_proc content_method::get_content_methods { content_type args } { +} { template::util::get_opts $args if { [info exists opts(get_labels)] } { @@ -83,20 +84,21 @@ } +ad_proc content_method::get_content_method_options { content_type } { -# @private get_content_method_options + @private get_content_method_options -# Returns a list of label, content_method pairs that are associated with -# a content type, first checking for a default method, then for registered -# content methods, and then for all content methods + Returns a list of label, content_method pairs that are associated with + a content type, first checking for a default method, then for registered + content methods, and then for all content methods -# @author Michael Pih -# @param content_type The content type -# @return A list of label, value pairs of content methods -# @see {content_method::get_content_methods, -# content_method::text_entry_filter_sql } + @author Michael Pih + @param content_type The content type + @return A list of label, value pairs of content methods + @see {content_method::get_content_methods, + content_method::text_entry_filter_sql } -ad_proc content_method::get_content_method_options { content_type } { +} { set text_entry_filter [text_entry_filter_sql $content_type] @@ -148,17 +150,17 @@ } +ad_proc content_method::text_entry_filter_sql { content_type } { + @private text_entry_filter_sql -# @private text_entry_filter_sql + Generate a SQL stub that filters out the text_entry content method -# Generate a SQL stub that filters out the text_entry content method + @author Michael Pih + @param content_type + @return SQL stub that possibly filters out the text_entry content method -# @author Michael Pih -# @param content_type -# @return SQL stub that possibly filters out the text_entry content method - -ad_proc content_method::text_entry_filter_sql { content_type } { +} { set text_entry_filter_sql "" @@ -183,19 +185,19 @@ +ad_proc content_method::flush_content_methods_cache { {content_type ""} } { + @public flush_content_method_cache -# @public flush_content_method_cache + Flushes the cache for content_method_types for a given content type. If no + content type is specified, the entire content_method_types cache is + flushed -# Flushes the cache for content_method_types for a given content type. If no -# content type is specified, the entire content_method_types cache is -# flushed + @author Michael Pih + @param content_type The content type, default null -# @author Michael Pih -# @param content_type The content type, default null +} { -ad_proc content_method::flush_content_methods_cache { {content_type ""} } { - if { [template::util::is_nil content_type] } { # flush the entire content_method_types cache Index: openacs-4/packages/cms/tcl/content-method-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/content-method-procs.xql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/content-method-procs.xql 17 Aug 2001 04:31:38 -0000 1.3 +++ openacs-4/packages/cms/tcl/content-method-procs.xql 20 Aug 2001 04:35:41 -0000 1.4 @@ -1,39 +1,74 @@ - - - select count(*) - from cr_content_mime_type_map - where mime_type like ('%text/%') - and content_type = :content_type - - - - + + + + select count(*) + from cr_content_mime_type_map + where mime_type like ('%text/%') + and content_type = :content_type + + + + + + select + map.content_method + from + cm_content_type_method_map map, cm_content_methods m + where + map.content_method = m.content_method + and + map.content_type = :content_type + $text_entry_filter + + + + + + + + select + content_method + from + cm_content_methods m + where 1 = 1 + $text_entry_filter + + + + + + + + + select - map.content_method + label, map.content_method from - cm_content_type_method_map map, cm_content_methods m + cm_content_methods m, cm_content_type_method_map map where - map.content_method = m.content_method + m.content_method = map.content_method and map.content_type = :content_type $text_entry_filter + + + - - - - - - + + + + select - content_method + label, content_method from cm_content_methods m where 1 = 1 $text_entry_filter + + + - - Index: openacs-4/packages/cms/tcl/form-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs-oracle.xql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/cms/tcl/form-procs-oracle.xql 17 Aug 2001 04:31:38 -0000 1.9 +++ openacs-4/packages/cms/tcl/form-procs-oracle.xql 20 Aug 2001 04:35:41 -0000 1.10 @@ -163,16 +163,35 @@ - - + + update cr_revisions set content = empty_blob() where revision_id = :revision_id returning content into :1 + + - + + + + update cr_revisions + set content = empty_blob() where revision_id = :revision_id + returning content into :1 + + + + + + update cr_revisions + set content = empty_blob() where revision_id = :revision_id + returning content into :1 + + + + @@ -274,85 +293,18 @@ - - + + + begin :1 := content_revision.new( + item_id => content_symlink.resolve(:item_id), + revision_id => :revision_id, + title => :title, + creation_ip => :creation_ip, + creation_user => :creation_user $param_sql); end; + + -begin :revision_id := content_revision.new( - title => :title - - - - - , description => :description - - - - - - , publish_date => :publish_date - - - - - - , mime_type => :mime_type - - - - - - , nls_language => :nls_language - - - - - - , text => :text - - - - - - , description => null - - - - - - , publish_date => sysdate - - - - - - , mime_type => 'text/plain' - - - - - - , nls_language => null - - - - - - , text => ' ' - - - - - - , item_id => content_symlink.resolve(:item_id), - revision_id => :revision_id, - creation_date => sysdate, - creation_ip => :creation_ip, - creation_user => :creation_user - ); end; - - - Index: openacs-4/packages/cms/tcl/form-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs-postgresql.xql,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/cms/tcl/form-procs-postgresql.xql 17 Aug 2001 04:31:38 -0000 1.11 +++ openacs-4/packages/cms/tcl/form-procs-postgresql.xql 20 Aug 2001 04:35:41 -0000 1.12 @@ -13,19 +13,19 @@ widget, param, coalesce( (select param_type from cm_attribute_widget_params where attribute_id = attributes.attribute_id - and param_id = params.param_id), 'literal' ) param_type, + and param_id = params.param_id), 'literal' ) as param_type, coalesce( (select param_source from cm_attribute_widget_params where attribute_id = attributes.attribute_id - and param_id = params.param_id), 'onevalue' ) param_source, + and param_id = params.param_id), 'onevalue' ) as param_source, coalesce( (select value from cm_attribute_widget_params where attribute_id = attributes.attribute_id and param_id = params.param_id), - params.default_value ) value + params.default_value ) as value from ( select aw.attribute_id, fwp.param, - aw.widget, decode(aw.is_required,'t','t',fwp.is_required) is_required, + aw.widget, case when aw.is_required = 't' then 't' else fwp.is_required end as is_required, fwp.param_id, fwp.default_value, fwp.is_html from cm_form_widget_params fwp, cm_attribute_widgets aw @@ -39,7 +39,7 @@ types.object_type, types.pretty_name as type_label, tree_level, types.table_name from - acs_attributes attr RIGHT OUTER JOIN, + acs_attributes attr join ( select o2.object_type, o2.pretty_name, tree_level(o2.tree_sortkey) as tree_level, @@ -138,7 +138,7 @@ types.table_name, types.id_column, attr.attribute_name, attr.datatype from - acs_attributes attr, + acs_attributes attr right outer join ( select o2.object_type, o2.table_name, o2.id_column, tree_level(o2.tree_sortkey) as inherit_level @@ -182,17 +182,45 @@ + + + - - - update cr_revisions - set content = [set __lob_id [db_string get_id "select empty_lob()"]] - where revision_id = :revision_id + update cr_revisions + set content = '[read [set __f [open $tmpfile r]]] [close $__f]', + content_length = '[file size $tmpfile]' + where revision_id = :revision_id - + + + + + update + cr_revisions + set + content = '[DoubleApos [read [set __f [open $tmpfile r]]]][close $__f]', + content_length = [file size $tmpfile] + where + revision_id = :revision_id + + + + + + + + + update cr_revisions + set content = [set __lob_id [db_string new_lob "select empty_lob()"]] + where revision_id = :revision_id + + + + + @@ -221,7 +249,7 @@ - select content_item__get_title(:parent_id) + select content_item__get_title(:parent_id, 'f') @@ -237,11 +265,24 @@ - select content_revision__to_temporary_clob(:revision_id) as revision_id; + select 1 + + + + select + content + from + cr_revisions + where + revision_id = :revision_id + + + + @@ -297,80 +338,26 @@ - - + + - select content_revision__new(:title + select content_revision__new( + :title, + :description, + now(), + :mime_type, + null, + :text, + content_symlink__resolve(:item_id), + :revision_id, + now(), + :creation_user, + :creation_ip) - - + + - - - , :description - - - - - , :publish_date - - - - - - , :mime_type - - - - - - , :nls_language - - - - - - , :text - - - - - - , null - - - - - - , now() - - - - - - , 'text/plain' - - - - - - , null - - - - - - , ' ' - - - - - - , content_symlink__resolve(:item_id), :revision_id, now(), :creation_ip, :creation_user) as revision_id - - - Index: openacs-4/packages/cms/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/cms/tcl/form-procs.tcl 17 Aug 2001 23:33:53 -0000 1.11 +++ openacs-4/packages/cms/tcl/form-procs.tcl 20 Aug 2001 04:35:41 -0000 1.12 @@ -3,21 +3,24 @@ # namespace import ::template::query ::template::form ::template::element } -# Helper proc: query out all the information neccessary to create -# a custom form element based on stored metadata -# Requires the variable content_type to be set in the calling frame -ad_proc content::query_form_metadata { +ad_proc -public content::query_form_metadata { {datasource_name rows} {datasource_type multirow} \ {extra_where {}} {extra_orderby {}} } { + Helper proc: query out all the information neccessary to create + a custom form element based on stored metadata + Requires the variable content_type to be set in the calling frame + +} { + + # query for all attribute widget param values associated with a content # the 3 nvl subqueries are necessary because we cannot outer join # to more than one table without doing multiple subqueries (which is # even less efficient than this way) - upvar __query query set query [db_map attributes_query_1] if { ![template::util::is_nil extra_where] } { @@ -34,17 +37,20 @@ } uplevel " - template::query get_form_metadata $datasource_name $datasource_type \{$__query\} + template::query get_form_metadata $datasource_name $datasource_type \{$query\} " } -# Process the query and assemble the "element create..." statement -# PRE: uber-query has been run -# POST: html_params, code_params set; returns the index of the next -# available row -ad_proc content::assemble_form_element { datasource_ref the_attribute_name start_row {db {}}} { +ad_proc -public content::assemble_form_element { datasource_ref the_attribute_name start_row {db {}}} { + Process the query and assemble the "element create..." statement + PRE: uber-query has been run + POST: html_params, code_params set; returns the index of the next + available row + +} { + upvar "${datasource_ref}:rowcount" rowcount upvar code_params code_params upvar content_type content_type @@ -89,26 +95,29 @@ return $last_row } -# Create a form widget based on the given attribute. Query parameters -# out of the database, override them with the passed-in parameters -# if they exist. -# If the -revision_id flag exists, fills in the value of the attribute from -# the database, based on the given revision_id. -# If the -content_type flag exists, uses the attribute for the given content -# type (without inheritance). -# If the -item_id flag is present, the live revision for the item will be -# used. -# If the -item_id and the -revision_id flags are missing, the -content_type -# flag must be specified. -# Example: -# content::create_form_element my_form width -revision_id $image_id -size 10 -# This call will create an element representing the width attribute -# of the image type, with the textbox size set to 10 characters, -# and query the current value of the attribute out of the database. -ad_proc content::create_form_element { +ad_proc -public content::create_form_element { form_name attribute_name args } { + + Create a form widget based on the given attribute. Query parameters + out of the database, override them with the passed-in parameters + if they exist. + If the -revision_id flag exists, fills in the value of the attribute from + the database, based on the given revision_id. + If the -content_type flag exists, uses the attribute for the given content + type (without inheritance). + If the -item_id flag is present, the live revision for the item will be + used. + If the -item_id and the -revision_id flags are missing, the -content_type + flag must be specified. + Example: + content::create_form_element my_form width -revision_id $image_id -size 10 + This call will create an element representing the width attribute + of the image type, with the textbox size set to 10 characters, + and query the current value of the attribute out of the database. + +} { template::util::get_opts $args # Get the revision id if the item id is specified, or if @@ -188,12 +197,15 @@ eval $form_element } -# generate a form based on metadata -ad_proc content::get_revision_form { +ad_proc -public content::get_revision_form { content_type item_id form_name {show_sections t} {element_override {}} } { + generate a form based on metadata + +} { + # Convert overrides to an array array set overrides $element_override @@ -205,7 +217,7 @@ set html_params [list] # Perform a gigantic query to retreive all metadata - query_form_metadata $db + query_form_metadata # Process the results and create the elements for { set i 1 } { $i <= ${rows:rowcount} } { incr i } { @@ -286,12 +298,15 @@ } -# PRE: requires datatype, widget, attribute_label, is_required code_params -# to be set in the calling frame -# -# POST: appends the list of params neccessary to create a new element to code_params -ad_proc content::get_element_default_params {} { +ad_proc -public content::get_element_default_params {} { + PRE: requires datatype, widget, attribute_label, is_required code_params + to be set in the calling frame + + POST: appends the list of params neccessary to create a new element to code_params + +} { + uplevel { lappend code_params -datatype $datatype -widget $widget \ -label $attribute_label @@ -301,12 +316,15 @@ } } -# PRE: requires the following variables to be set in the uplevel scope: -# db, code_params, html_params, -# attribute_id, attribute_name, datatype, is_html, -# param_source, param_type, value -# POST: adds params to the 'element create' command ad_proc content::get_revision_create_element {} { + + PRE: requires the following variables to be set in the uplevel scope: + db, code_params, html_params, + attribute_id, attribute_name, datatype, is_html, + param_source, param_type, value + POST: adds params to the 'element create' command + +} { upvar __sql sql set sql [db_map get_enum_1] @@ -344,16 +362,18 @@ } -# perform the appropriate DML based on metadata +ad_proc -public content::process_revision_form { form_name content_type item_id {db{}} } { -ad_proc content::process_revision_form { form_name content_type item_id {db{}} } { + perform the appropriate DML based on metadata +} { + template::form get_values $form_name title description mime_type # create the basic revision - db_exec_plsql new_content_revision { + set revision_id [db_exec_plsql new_content_revision " begin - :revision_id := content_revision.new( + :1 := content_revision.new( title => :title, description => :description, mime_type => :mime_type, @@ -362,10 +382,8 @@ creation_ip => '[ns_conn peeraddr]', creation_user => [User::getID] ); - end; - } + end;"] - #ns_ora exec_plsql_bind $db $sql revision_id # query for extended attribute tables @@ -435,11 +453,14 @@ return $revision_id } -# helper function for process_revision_form -# PRE: the following variables must be set in the uplevel scope: -# columns, values, last_table -ad_proc content::process_revision_form_dml {} { +ad_proc -public content::process_revision_form_dml {} { + helper function for process_revision_form + PRE: the following variables must be set in the uplevel scope: + columns, values, last_table + +} { + upvar last_table __last_table upvar columns __columns upvar values __values @@ -458,17 +479,19 @@ } -# Perform an insert for some form, adding all attributes of a -# specific type -# exclusion_list is a list of all object types for which the elements -# are NOT to be inserted -# id_value is the revision_id - -ad_proc content::insert_element_data { +ad_proc -public content::insert_element_data { form_name content_type exclusion_list id_value \ {suffix ""} {extra_where ""} } { + Perform an insert for some form, adding all attributes of a + specific type + exclusion_list is a list of all object types for which the elements + are NOT to be inserted + id_value is the revision_id + +} { + set sql_exclusion [template::util::tcl_to_sql_list $exclusion_list] set id_value_ref id_value @@ -527,10 +550,13 @@ } -# helper function for process_revision_form -# PRE: the following variables must be set in the uplevel scope: -# columns, values, last_table, id_value_ref -ad_proc content::process_insert_statement {} { +ad_proc -public content::process_insert_statement {} { + + helper function for process_revision_form + PRE: the following variables must be set in the uplevel scope: + columns, values, last_table, id_value_ref + +} { upvar last_table __last_table upvar columns __columns upvar values __values @@ -548,9 +574,11 @@ } } +ad_proc -public content::assemble_passthrough { args } { -# Assemble a passthrough list out of variables -ad_proc content::assemble_passthrough { args } { + Assemble a passthrough list out of variables + +} { set result [list] foreach varname $args { upvar $varname var @@ -559,18 +587,24 @@ return $result } -# Convert passthrough to a URL fragment -ad_proc content::url_passthrough { passthrough } { +ad_proc -public content::url_passthrough { passthrough } { + Convert passthrough to a URL fragment + +} { + set extra_url "" foreach pair $passthrough { append extra_url "&[lindex $pair 0]=[lindex $pair 1]" } return $extra_url } -# Assemble a URL out of component parts -ad_proc content::assemble_url { base_url args } { +ad_proc -public content::assemble_url { base_url args } { + + Assemble a URL out of component parts + +} { set result $base_url if { [string first $base_url "?"] == -1 } { set joiner "?" @@ -594,21 +628,27 @@ # Procedures for generating and processing content content creation # and editing forms.. -# @public new_item -# Create a new item, including the initial revision, based on a valid -# form submission. +ad_proc -public content::new_item { form_name { storage_type text } { tmpfile "" } } { -# @param form_name Name of the form from which to obtain item -# attributes, as well as attributes of the initial revision. The form -# should include an item_id, name and revision_id. + @public new_item + Create a new item, including the initial revision, based on a valid + form submission. -# @param tmpfile Name of the temporary file containing the content to -# upload for the initial revision. + @param form_name Name of the form from which to obtain item + attributes, as well as attributes of the initial revision. The form + should include an item_id, name and revision_id. -# @see add_revision + @param storage_type Method for storing content. Can be one of content_text, + content_lob, content_file. This is an openacs extension for allowing the + storage of content in the file-system. -ad_proc content::new_item { form_name { storage_type text } { tmpfile "" } } { + @param tmpfile Name of the temporary file containing the content to + upload for the initial revision. + @see add_revision + +} { + array set defaults [list item_id "" locale "" parent_id "" content_type "content_revision"] foreach param { item_id name locale parent_id content_type } { @@ -658,22 +698,25 @@ return $item_id } -# @public add_revision -# Create a new revision for an existing item based on a valid form -# submission. Queries for attribute names and inserts a row into the -# attribute input view for the appropriate content type. Inserts the -# contents of a file into the content column of the cr_revisions table -# for the revision as well. +ad_proc -public content::add_revision { form_name { tmpfile "" } } { -# @param form_name Name of the form from which to obtain attribute -# values. The form should include an item_id and revision_id. + @public add_revision -# @param tmpfile Name of the temporary file containing the content to -# upload. + Create a new revision for an existing item based on a valid form + submission. Queries for attribute names and inserts a row into the + attribute input view for the appropriate content type. Inserts the + contents of a file into the content column of the cr_revisions table + for the revision as well. -ad_proc content::add_revision { form_name { tmpfile "" } } { + @param form_name Name of the form from which to obtain attribute + values. The form should include an item_id and revision_id. + @param tmpfile Name of the temporary file containing the content to + upload. + +} { + # initialize an ns_set to hold bind values set bind_vars [ns_set create] @@ -712,27 +755,30 @@ #cms_folder::flush sitemap $parent_id } -# @private attribute_insert_statement -# Prepare the insert statement into the attribute input view for a new -# revision (see the content repository documentation for details about -# the view). +ad_proc -public content::attribute_insert_statement { + content_type table_name bind_vars form_name } { -# @param content_type The content type of the item for which a new -# revision is being prepared. + @private attribute_insert_statement -# @param table_name The storage table of the content type. + Prepare the insert statement into the attribute input view for a new + revision (see the content repository documentation for details about + the view). -# @param bind_vars The name of an ns_set in which to store the -# attribute values for the revision. (Typically duplicates the contents -# of [ns_getform]. + @param content_type The content type of the item for which a new + revision is being prepared. -# @param form_name The name of the ATS form object used to process the -# submission. + @param table_name The storage table of the content type. -ad_proc content::attribute_insert_statement { - content_type table_name bind_vars form_name } { + @param bind_vars The name of an ns_set in which to store the + attribute values for the revision. (Typically duplicates the contents + of [ns_getform]. + @param form_name The name of the ATS form object used to process the + submission. + +} { + # get creation_user and creation_ip set creation_user [User::getID] set creation_ip [ns_conn peeraddr] @@ -776,25 +822,28 @@ return $insert_statement } -# @private add_revision_dml -# Perform the DML to insert a revision into the appropriate input view. +ad_proc -private content::add_revision_dml { statement bind_vars tmpfile filename } { -# @param statement The DML for the insert statement, specifying a bind -# variable for each column value. + @private add_revision_dml -# @param bind_vars An ns_set containing the values for all bind variables. + Perform the DML to insert a revision into the appropriate input view. -# @param tmpfile The server-side name of the file containing the body of the -# revision to upload into the content BLOB column of cr_revisions. + @param statement The DML for the insert statement, specifying a bind + variable for each column value. -# @param filename The client-side name of the file containing the body of -# the revision to upload into the content BLOB column of cr_revisions + @param bind_vars An ns_set containing the values for all bind variables. -# @see add_revision + @param tmpfile The server-side name of the file containing the body of the + revision to upload into the content BLOB column of cr_revisions. -ad_proc content::add_revision_dml { statement bind_vars tmpfile filename } { + @param filename The client-side name of the file containing the body of + the revision to upload into the content BLOB column of cr_revisions + @see add_revision + +} { + db_transaction { db_dml add_revision $statement -bind $bind_vars @@ -808,22 +857,28 @@ } } -# @private upload_content -# Inserts content into the database from an uploaded file. -# Does automatic mime_type updating -# Parses text/html content and removes tags +ad_proc -public content::upload_content { revision_id tmpfile filename } { -# @param revision_id The revision to which the content belongs + @private upload_content -# @param tmpfile The server-side name of the file containing the body of the -# revision to upload into the content BLOB column of cr_revisions. + Inserts content into the database from an uploaded file. + Does automatic mime_type updating + Parses text/html content and removes tags -# @param filename The client-side name of the file containing the body of -# the revision to upload into the content BLOB column of cr_revisions + @param db A db handle -ad_proc content::upload_content { revision_id tmpfile filename } { + @param revision_id The revision to which the content belongs + @param tmpfile The server-side name of the file containing the body of the + revision to upload into the content BLOB column of cr_revisions. + + @param filename The client-side name of the file containing the body of + the revision to upload into the content BLOB column of cr_revisions + + +} { + # if it is HTML then strip out the body set mime_type [ns_guesstype $filename] if { [string equal $mime_type text/html] } { @@ -834,46 +889,67 @@ close $fd } } - - # upload the file into the revision content - db_dml update_cr_revisions " - update cr_revisions - set content = empty_blob() where revision_id = :revision_id - returning content into :1" -blob_files $tmpfile + db_1row get_storage_type {select + storage_type, item_id + from + cr_items + where + item_id = (select + item_id + from + cr_revisions + where revision_id = :revision_id)} - # update mime_type to match the file + if {[string equal $storage_type file]} { + db_dml upload_file_revision " + update cr_revisions + set content = '[set file_path [cr_create_content_file $item_id $revision_id $tmpfile]]', + content_length = [cr_file_size $file_path] + where revision_id = :revision_id" + } elseif {[string equal $storage_type text]} { + # upload the file into the revision content + db_dml upload_text_revision "update cr_revisions + set content = empty_blob() where revision_id = :revision_id + returning content into :1" -blob_files [list $tmpfile] - if { [catch {db_dml update_mime_sql " + } else { + # upload the file into the revision content + db_dml upload_revision "update cr_revisions + set content = empty_blob() where revision_id = :revision_id + returning content into :1" -blob_files [list $tmpfile] + } + + # update mime_type to match the file + if { [catch {db_dml update_mime_type " update cr_revisions set mime_type = :mime_type - where revision_id = :revision_id" } errmsg] } { - + where revision_id = :revision_id"} errmsg] } { # if it fails, use user submitted mime_type ns_log notice "form-procs - add_revision_dml - using user mime_type instead of guessed mime type = $mime_type" } # delete the tempfile ns_unlink $tmpfile - } +ad_proc -private content::get_sql_value { name datatype } { + @private get_sql_value -# @private get_sql_value + Return the sql statement for a column value in an insert or update + statement, using a bind variable for the actual value and wrapping it + in a conversion function where appropriate. -# Return the sql statement for a column value in an insert or update -# statement, using a bind variable for the actual value and wrapping it -# in a conversion function where appropriate. + @param name The name of the column and bind variable (they should be + the same). -# @param name The name of the column and bind variable (they should be -# the same). + @param datatype The datatype of the column. -# @param datatype The datatype of the column. -ad_proc content::get_sql_value { name datatype } { +} { switch $datatype { date { set wrapper [db_map string_to_timestamp] } @@ -883,22 +959,25 @@ return $wrapper } -# @private prepare_content_file -# Looks for an element named "content" in a form and prepares a -# temporarily file in UTF-8 for uploading to the content repository. -# Checks for a query variable named "content.tmpfile" to distinguish -# between file uploads and text entry. If the type of the file is -# text, then ensures that is in UTF-8. Does nothing if the uploaded -# file is in binary format. +ad_proc -private content::prepare_content_file { form_name } { -# @param form_name The name of the form object in which content was submitted. + @private prepare_content_file -# @return The path of the temporary file containing the content, or an empty -# string if the form does not include a content element or the value -# of the element is null. + Looks for an element named "content" in a form and prepares a + temporarily file in UTF-8 for uploading to the content repository. + Checks for a query variable named "content.tmpfile" to distinguish + between file uploads and text entry. If the type of the file is + text, then ensures that is in UTF-8. Does nothing if the uploaded + file is in binary format. -ad_proc content::prepare_content_file { form_name } { + @param form_name The name of the form object in which content was submitted. + + @return The path of the temporary file containing the content, or an empty + string if the form does not include a content element or the value + of the element is null. + +} { if { ! [template::element exists $form_name content] } { return "" } @@ -930,16 +1009,19 @@ return $tmpfile } -# @private string_to_file -# Write a string in UTF-8 encoding to of temp file so it can be -# uploaded into a BLOB (which is blind to character encodings). -# Returns the name of the temp file. +ad_proc -private content::string_to_file { s } { -# @param s The string to write to the file. + @private string_to_file -ad_proc content::string_to_file { s } { + Write a string in UTF-8 encoding to of temp file so it can be + uploaded into a BLOB (which is blind to character encodings). + Returns the name of the temp file. + @param s The string to write to the file. + +} { + set tmp_file [ns_tmpnam] set fd [open $tmp_file w] @@ -964,33 +1046,36 @@ is_html default_value datatype] } -# @public new_item_form -# Adds elements to an ATS form object for creating an item and its -# initial revision. If the form does not already exist, creates the -# form object and sets its enctype to multipart/form-data to allow for -# text entries greater than 4000 characters. +ad_proc -public content::new_item_form { args } { -# @option form_name The name of the ATS form object. Defaults to -# "new_item". -# @option content_type The content_type of the item. Defaults to -# "content_revision". -# @option content_method The method to use for uploading the content body. -# Valid values are "no_content", "text_entry", -# and "file_upload". -# If the content type allows text, defaults to -# text entry, otherwise defaults to file upload. -# @option parent_id The item ID of the parent. Defaults to null (Parent -# is the root folder). -# @option name The default name of the item. Default is an empty -# string (User must supply name). -# @option attributes A list of attribute names for which to create form -# elements. -# @option action The URL to which the form should redirect following -# a successful form submission. + @public new_item_form -ad_proc content::new_item_form { args } { + Adds elements to an ATS form object for creating an item and its + initial revision. If the form does not already exist, creates the + form object and sets its enctype to multipart/form-data to allow for + text entries greater than 4000 characters. + @option form_name The name of the ATS form object. Defaults to + "new_item". + @option content_type The content_type of the item. Defaults to + "content_revision". + @option content_method The method to use for uploading the content body. + Valid values are "no_content", "text_entry", + and "file_upload". + If the content type allows text, defaults to + text entry, otherwise defaults to file upload. + @option parent_id The item ID of the parent. Defaults to null (Parent + is the root folder). + @option name The default name of the item. Default is an empty + string (User must supply name). + @option attributes A list of attribute names for which to create form + elements. + @option action The URL to which the form should redirect following + a successful form submission. + +} { + array set opts [list form_name new_item content_type content_revision \ parent_id {} name {} content_method {}] template::util::get_opts $args @@ -1046,33 +1131,36 @@ } } -# @public add_revision_form -# Adds elements to an ATS form object for adding a revision to an -# existing item. If the item already exists, element values default a -# previous revision (the latest one by default). If the form does not -# already exist, creates the form object and sets its enctype to -# multipart/form-data to allow for text entries greater than 4000 -# characters. +ad_proc -public content::add_revision_form { args } { -# @option form_name The name of the ATS form object. Defaults to -# "new_item". -# @option content_type The content_type of the item. Defaults to -# "content_revision". -# @option content_method The method to use for uploading the content body. -# If the content type is text, defaults to -# text entry, otherwise defaults to file upload. -# @option item_id The item ID of the revision. Defaults to null -# (item_id must be set by the calling code). -# @option revision_id The revision ID from which to draw default values. -# Defaults to the latest revision -# @option attributes A list of attribute names for which to create form -# elements. -# @option action The URL to which the form should redirect following -# a successful form submission. + @public add_revision_form -ad_proc content::add_revision_form { args } { + Adds elements to an ATS form object for adding a revision to an + existing item. If the item already exists, element values default a + previous revision (the latest one by default). If the form does not + already exist, creates the form object and sets its enctype to + multipart/form-data to allow for text entries greater than 4000 + characters. + @option form_name The name of the ATS form object. Defaults to + "new_item". + @option content_type The content_type of the item. Defaults to + "content_revision". + @option content_method The method to use for uploading the content body. + If the content type is text, defaults to + text entry, otherwise defaults to file upload. + @option item_id The item ID of the revision. Defaults to null + (item_id must be set by the calling code). + @option revision_id The revision ID from which to draw default values. + Defaults to the latest revision + @option attributes A list of attribute names for which to create form + elements. + @option action The URL to which the form should redirect following + a successful form submission. + +} { + array set opts [list form_name add_revision content_type content_revision \ item_id {} content_method {} revision_id {}] template::util::get_opts $args @@ -1132,22 +1220,26 @@ } } -# @public add_attribute_elements -# Add form elements to an ATS form object for all attributes of a -# content type. +ad_proc -public content::add_attribute_elements { form_name content_type \ + { revision_id "" } } { -# @param form_name The name of the ATS form object to which objects -# should be added. -# @param content_type The content type keyword for which attribute -# widgets should be added. -# @param revision_id The revision from which default values should be -# queried -# @return The list of attributes that were added. + @public add_attribute_elements -ad_proc content::add_attribute_elements { form_name content_type \ - { revision_id "" } } { + Add form elements to an ATS form object for all attributes of a + content type. + @param form_name The name of the ATS form object to which objects + should be added. + @param content_type The content type keyword for which attribute + widgets should be added. + @param revision_id The revision from which default values should be + queried + @return The list of attributes that were added. + + +} { + # query for attributes in the appropriate order set attribute_list [get_attributes $content_type object_type attribute_name] @@ -1191,23 +1283,26 @@ return $attribute_names } -# @public add_attribute_element -# Add a form element (possibly a compound widget) to an ATS form object. -# for entering or editing an attribute value. +ad_proc -public content::add_attribute_element { + form_name content_type attribute { attribute_data "" } } { -# @param form_name The name of the ATS form object to which the element -# should be added. -# @param content_type The content type keyword to which this attribute -# belongs. -# @param attribute The name of the attribute, as represented in the -# attribute_name column of the acs_attributes table. -# @param attribute_data Optional nested list of parameter data for the -# the attribute (generated by get_attribute_params). + @public add_attribute_element -ad_proc content::add_attribute_element { - form_name content_type attribute { attribute_data "" } } { + Add a form element (possibly a compound widget) to an ATS form object. + for entering or editing an attribute value. + @param form_name The name of the ATS form object to which the element + should be added. + @param content_type The content type keyword to which this attribute + belongs. + @param attribute The name of the attribute, as represented in the + attribute_name column of the acs_attributes table. + @param attribute_data Optional nested list of parameter data for the + the attribute (generated by get_attribute_params). + +} { + variable columns set command [list "template::element" create $form_name $attribute] @@ -1262,25 +1357,29 @@ lappend command -label $param(pretty_name) -widget $param(widget) \ -datatype $param(datatype) - if { [string equal $param(widget_is_required) f] } { + # changed from widget_is_required to param_is_required (OpenACS - DanW) + if { [string equal $param(param_is_required) f] } { lappend command -optional } #ns_log notice "--------------- command = $command" eval $command } -# @public add_content_element - -# Adds a content input element to an ATS form object. - -# @param form_name The name of the form to which the object should be -# added. -# @param content_method One of no_content, text_entry or file_upload -ad_proc content::add_content_element { +ad_proc -public content::add_content_element { form_name content_method { section_name "Content" } } { + @public add_content_element + + Adds a content input element to an ATS form object. + + @param form_name The name of the form to which the object should be + added. + @param content_method One of no_content, text_entry or file_upload + +} { + template::element create $form_name content_method \ -datatype keyword \ -widget hidden \ @@ -1334,21 +1433,25 @@ } } -# @public add_child_relation_element -# -# Add a select box listing all valid child relation tags. -# The form must contain a parent_id element and a content_type element. -# If the elements do not exist, or if there are no valid relation tags, -# this proc does nothing. -# -# @param form_name The name of the form -# -# @option section {none} If present, creates a new form section -# for the element. -# -# @option label {Child relation tag} The label for the element ad_proc content::add_child_relation_element { form_name args } { + + @public add_child_relation_element + + Add a select box listing all valid child relation tags. + The form must contain a parent_id element and a content_type element. + If the elements do not exist, or if there are no valid relation tags, + this proc does nothing. + + @param form_name The name of the form + + @option section {none} If present, creates a new form section + for the element. + + @option label {Child relation tag} The label for the element + + +} { # Process parameters @@ -1422,17 +1525,19 @@ } -# @private get_widget_param_value +ad_proc -private content::get_widget_param_value { + array_ref {content_type content_revision} +} { -# Utility procedure to return the value of a widget parameter + @private get_widget_param_value -# @param array_ref The name of an array in the calling frame -# containing parameter data selected from the form -# metadata. -# @param content_type The current content type; defaults to content_revision + Utility procedure to return the value of a widget parameter -ad_proc content::get_widget_param_value { - array_ref {content_type content_revision} + @param array_ref The name of an array in the calling frame + containing parameter data selected from the form + metadata. + @param content_type The current content type; defaults to content_revision + } { upvar $array_ref param @@ -1469,18 +1574,21 @@ return $value } -# @private get_type_attribute_params -# Query for attribute form metadata +ad_proc -private content::get_type_attribute_params { args } { -# @param args Any number of object types + @private get_type_attribute_params -# @return A list of attribute parameters nested by object_type, attribute_name -# and the is_html flag. For attributes with no parameters, -# there is a single entry with is_html as null. + Query for attribute form metadata -ad_proc content::get_type_attribute_params { args } { + @param args Any number of object types + @return A list of attribute parameters nested by object_type, attribute_name + and the is_html flag. For attributes with no parameters, + there is a single entry with is_html as null. + +} { + variable columns foreach object_type $args { @@ -1499,17 +1607,20 @@ return $attribute_data } -# @private get_attribute_params -# Query for parameters associated with a particular attribute +ad_proc -private content::get_attribute_params { content_type attribute_name } { -# @param content_type The content type keyword to which this attribute -# belongs. -# @param attribute_name The name of the attribute, as represented in the -# attribute_name column of the acs_attributes table. + @private get_attribute_params -ad_proc content::get_attribute_params { content_type attribute_name } { + Query for parameters associated with a particular attribute + @param content_type The content type keyword to which this attribute + belongs. + @param attribute_name The name of the attribute, as represented in the + attribute_name column of the acs_attributes table. + +} { + variable columns template::query gap_get_attribute_data attribute_data nestedlist " @@ -1526,20 +1637,23 @@ return $attribute_data } -# @private set_attribute_values -# Set the default values for attribute elements in ATS form object -# based on a previous revision +ad_proc -private content::set_attribute_values { form_name content_type revision_id \ + attributes } { -# @param form_name The name of the ATS form object containing -# the attribute elements. -# @param content_type The type of item being revised in the form. -# @param revision_id The revision ID from where to get the default values -# @param attributes The list of attributes whose values should be set. + @private set_attribute_values -ad_proc content::set_attribute_values { form_name content_type revision_id \ - attributes } { + Set the default values for attribute elements in ATS form object + based on a previous revision + @param form_name The name of the ATS form object containing + the attribute elements. + @param content_type The type of item being revised in the form. + @param revision_id The revision ID from where to get the default values + @param attributes The list of attributes whose values should be set. + +} { + if { [llength $attributes] == 0 } { set attributes [get_attributes $content_type] } @@ -1594,31 +1708,37 @@ } -# @private set_content_value -# Set the default value for the content text area in an ATS form object -# based on a previous revision +ad_proc -private content::set_content_value { form_name revision_id } { -# @param form_name The name of the ATS form object containing -# the content element. -# @param revision_id The revision ID of the content to revise + @private set_content_value -ad_proc content::set_content_value { form_name revision_id } { + Set the default value for the content text area in an ATS form object + based on a previous revision + @param form_name The name of the ATS form object containing + the content element. + @param revision_id The revision ID of the content to revise + +} { + set content [get_content_value $revision_id] template::element set_properties $form_name content -value $content } -# @private get_default_content_method -# Gets the content input method most appropriate for an content type, -# based on the MIME types that are registered for that content type. +ad_proc -private content::get_default_content_method { content_type } { -# @param content_type The content type for which an input method is needed. + @private get_default_content_method -ad_proc content::get_default_content_method { content_type } { + Gets the content input method most appropriate for an content type, + based on the MIME types that are registered for that content type. + @param content_type The content type for which an input method is needed. + +} { + template::query count_mime_type is_text onevalue "select count(*) from cr_content_mime_type_map where content_type = :content_type and mime_type like 'text/%'" @@ -1635,18 +1755,21 @@ # Procedure wrappers for basic ACS Object and Content Repository queries # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -# @private get_type_info -# Return specified columns from the acs_object_types table. +ad_proc -private content::get_type_info { object_type ref args } { -# @param object_type Object type key for which info is required. -# @param ref If no further arguments, name of the column value to -# return. If further arguments are specified, name of -# the array in which to store info in the calling -# @param args Column names to query. + @private get_type_info -ad_proc content::get_type_info { object_type ref args } { + Return specified columns from the acs_object_types table. + @param object_type Object type key for which info is required. + @param ref If no further arguments, name of the column value to + return. If further arguments are specified, name of + the array in which to store info in the calling + @param args Column names to query. + +} { + if { [llength $args] == 0 } { template::query get_type_info_1 info onevalue " @@ -1671,16 +1794,19 @@ } } -# @public get_object_id -# Grab an object ID for creating a new ACS object. +ad_proc -public content::get_object_id {} { -ad_proc content::get_object_id {} { + @public get_object_id + Grab an object ID for creating a new ACS object. + +} { + return [db_string nextval "select acs_object_id_seq.nextval from dual"] } -ad_proc content::get_content_value { revision_id } { +ad_proc -public content::get_content_value { revision_id } { db_transaction { db_exec_plsql gcv_get_revision_id { @@ -1704,18 +1830,21 @@ return $content } -# @private get_attributes -# Returns columns from the acs_attributes table for all attributes -# associated with a content type. +ad_proc -private content::get_attributes { content_type args } { -# @param content_type The name of the content type (ACS Object Type) -# for which to obtain the list of attributes. -# @param args Names of columns to query. If no columns are specified, -# returns a simple list of attribute names. + @private get_attributes -ad_proc content::get_attributes { content_type args } { + Returns columns from the acs_attributes table for all attributes + associated with a content type. + @param content_type The name of the content type (ACS Object Type) + for which to obtain the list of attributes. + @param args Names of columns to query. If no columns are specified, + returns a simple list of attribute names. + +} { + if { [llength $args] == 0 } { set args [list attribute_name] } @@ -1753,16 +1882,19 @@ return $attributes } -# @public get_attribute_enum_values -# Returns a list of { pretty_name enum_value } for an attribute of -# datatype enumeration. +ad_proc -public content::get_attribute_enum_values { attribute_id } { -# @param attribute_id The primary key of the attribute as in the -# attribute_id column of the acs_attributes table. + @public get_attribute_enum_values -ad_proc content::get_attribute_enum_values { attribute_id } { + Returns a list of { pretty_name enum_value } for an attribute of + datatype enumeration. + @param attribute_id The primary key of the attribute as in the + attribute_id column of the acs_attributes table. + +} { + template::query gaev_get_enum_values enum multilist " select nvl(pretty_name,enum_value), @@ -1778,75 +1910,87 @@ return $enum } -# @public get_latest_revision +ad_proc -public content::get_latest_revision { item_id } { -# Get the ID of the latest revision for the specified content item. + @public get_latest_revision -# @param item_id The ID of the content item. + Get the ID of the latest revision for the specified content item. -ad_proc content::get_latest_revision { item_id } { + @param item_id The ID of the content item. +} { + template::query glr_get_latest_revision latest_revision onevalue " select content_item.get_latest_revision(:item_id) from dual" return $latest_revision } -# @public add_basic_revision +ad_proc -public content::add_basic_revision { item_id revision_id title args } { -# Create a basic new revision using the content_revision PL/SQL API. + @public add_basic_revision -# @param item_id -# @param revision_id -# @param title + Create a basic new revision using the content_revision PL/SQL API. -# @option description -# @option mime_type -# @option text -# @option tmpfile -# RBM: FIX ME. Not sure if this will work because of line 1822 -ad_proc content::add_basic_revision { item_id revision_id title args } { + @param item_id + @param revision_id + @param title + @option description + @option mime_type + @option text + @option tmpfile + +} { + template::util::get_opts $args set creation_ip [ns_conn peeraddr] set creation_user [User::getID] - set sql [db_map abr_new_revision_title] - - foreach param { description publish_date mime_type nls_language text } { + set param_sql "" + array set defaults [list description "" mime_type "text/plain" text " "] + foreach param { description mime_type text } { if { [info exists opts($param)] } { - set $param $opts($param) - append sql [db_map abr_new_revision_$param] + set $param $opts($param) + append param_sql ", $param => :$param" } else { - append sql [db_map abr_new_revision_${param}_ne] + set $param $defaults($param) } } - append sql [db_map abr_new_revision_end_items] + db_transaction { - db_transaction " db_exec_plsql abr_new_revision_final $sql -bind revision_id " + set revision_id [db_exec_plsql basic_get_revision_id "begin :1 := content_revision.new( + item_id => content_symlink.resolve(:item_id), + revision_id => :revision_id, + title => :title, + creation_ip => :creation_ip, + creation_user => :creation_user $param_sql); end;"] - if { [info exists opts(tmpfile)] } { + if { [info exists opts(tmpfile)] } { - update_content_from_file $revision_id $opts(tmpfile) + update_content_from_file $revision_id $opts(tmpfile) + } } } -# @private update_content_from_file -# Update the BLOB column of a revision with the contents of a file +ad_proc -private content::update_content_from_file { revision_id tmpfile } { -# @param revision_id The object ID of the revision to update. -# @param tmpfile The name of a temporary file containing the content. -# The file is deleted following the update. + @private update_content_from_file -ad_proc content::update_content_from_file { revision_id tmpfile } { + Update the BLOB column of a revision with the contents of a file - set file_upload " + @param revision_id The object ID of the revision to update. + @param tmpfile The name of a temporary file containing the content. + The file is deleted following the update. +} { + + db_dml upcff_update_cr_revisions " update cr_revisions set content = empty_blob() where revision_id = :revision_id @@ -1857,22 +2001,24 @@ -# @public copy_latest_content +ad_proc -public content::copy_content { revision_id_src revision_id_dest } { -# Update the BLOB column of one revision with the content of another revision + @public copy_latest_content -# @param revision_id_src The object ID of the revision with the content to be -# copied. + Update the BLOB column of one revision with the content of another revision -# @param revision_id_dest The object ID of the revision to be updated. -# copied. + @param revision_id_src The object ID of the revision with the content to be + copied. -ad_proc content::copy_content { revision_id_src revision_id_dest } { + @param revision_id_dest The object ID of the revision to be updated. + copied. +} { + db_transaction { # copy the content from the source to the target - db_dml cc_copy_content { + db_exec_plsql cc_copy_content { begin content_revision.content_copy ( revision_id => :revision_id_src, @@ -1896,14 +2042,15 @@ } +ad_proc -public content::add_content { form_name revision_id } { -# @public add_content + @public add_content -# Update the BLOB column of a revision with content submitted in a form + Update the BLOB column of a revision with content submitted in a form -# @param revision_id The object ID of the revision to be updated. + @param revision_id The object ID of the revision to be updated. -ad_proc content::add_content { form_name revision_id } { +} { # if content exists, prepare it for insertion if { [template::element exists $form_name content] } { @@ -1921,15 +2068,16 @@ } } +ad_proc -public content::validate_name { form_name } { + @public validate_name -# @public validate_name + Make sure that name is unique for the folder -# Make sure that name is unique for the folder + @param form_name The name of the form (containing name and parent_id) + @return 0 if there are items with the same name, 1 otherwise -# @param form_name The name of the form (containing name and parent_id) -# @return 0 if there are items with the same name, 1 otherwise -ad_proc content::validate_name { form_name } { +} { set name [template::element get_value $form_name name] set parent_id [template::element get_value $form_name parent_id] Index: openacs-4/packages/cms/tcl/item-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/item-procs-oracle.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/item-procs-oracle.xql 11 Aug 2001 17:41:34 -0000 1.1 +++ openacs-4/packages/cms/tcl/item-procs-oracle.xql 20 Aug 2001 04:35:41 -0000 1.2 @@ -47,24 +47,13 @@ - - - select content_item.get_id(:url - - + + + select content_item__get_id(:url $root_sql) from dual + + + - - - , :root_folder - - - - - - ) from dual - - - Index: openacs-4/packages/cms/tcl/item-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/item-procs-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/item-procs-postgresql.xql 11 Aug 2001 17:41:34 -0000 1.1 +++ openacs-4/packages/cms/tcl/item-procs-postgresql.xql 20 Aug 2001 04:35:41 -0000 1.2 @@ -15,7 +15,7 @@ - select content_item__get_path(:item_id) + select content_item__get_path(:item_id, null) @@ -42,33 +42,23 @@ - select content_item__get_title(:item_id) + select content_item__get_title(:item_id, 'f') - - - select content_item__get_id(:url - - + + - - - , :root_folder - - + select content_item__get_id(:url $root_sql) + + + - - - ) - - - - , content__blob_to_string(content) as text + , content as text Index: openacs-4/packages/cms/tcl/item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/item-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/tcl/item-procs.tcl 11 Aug 2001 17:40:26 -0000 1.4 +++ openacs-4/packages/cms/tcl/item-procs.tcl 20 Aug 2001 04:35:41 -0000 1.5 @@ -12,20 +12,23 @@ namespace eval item {} -# @public get_live_revision -# -# Retrieves the live revision for the item. If the item has no live -# revision, returns an empty string. -# -# @param item_id The item id -# -# @return The live revision id for the item, or an empty string if no -# live revision exists -# @see proc item::get_best_revision -# @see proc item::get_item_from_revision -ad_proc item::get_live_revision { item_id } { +ad_proc -public item::get_live_revision { item_id } { + @public get_live_revision + + Retrieves the live revision for the item. If the item has no live + revision, returns an empty string. + + @param item_id The item id + + @return The live revision id for the item, or an empty string if no + live revision exists + @see proc item::get_best_revision + @see proc item::get_item_from_revision + +} { + template::query glr_get_live_revision live_revision onevalue " select live_revision from cr_items where item_id = :item_id" -cache "item_live_revision $item_id" @@ -39,21 +42,22 @@ } +ad_proc -public item::get_best_revision { item_id } { -# @public get_best_revision -# -# Attempts to retrieve the live revision for the item. If no live revision -# exists, attempts to retrieve the latest revision. If the item has no -# revisions, returns an empty string. -# -# @param item_id The item id -# -# @return The best revision id for the item, or an empty string if no -# revisions exist -# @see proc item::get_live_revision -# @see proc item::get_item_from_revision + @public get_best_revision + + Attempts to retrieve the live revision for the item. If no live revision + exists, attempts to retrieve the latest revision. If the item has no + revisions, returns an empty string. + + @param item_id The item id + + @return The best revision id for the item, or an empty string if no + revisions exist + @see proc item::get_live_revision + @see proc item::get_item_from_revision -ad_proc item::get_best_revision { item_id } { +} { template::query gbr_get_best_revision revision_id onevalue " select content_item.get_best_revision(:item_id) from dual " -cache "item_best_revision $item_id" @@ -62,36 +66,40 @@ } -# @public get_item_from_revision -# -# Gets the item_id of the item to which the revision belongs. -# -# @param revision_id The revision id -# -# @return The item_id of the item to which this revision belongs -# @see proc item::get_live_revision -# @see proc item::get_best_revision +ad_proc -public item::get_item_from_revision { revision_id } { -ad_proc item::get_item_from_revision { revision_id } { + @public get_item_from_revision + + Gets the item_id of the item to which the revision belongs. + + @param revision_id The revision id + + @return The item_id of the item to which this revision belongs + @see proc item::get_live_revision + @see proc item::get_best_revision + +} { template::query gifr_get_one_revision item_id onevalue " select item_id from cr_revisions where revision_id = :revision_id " -cache "item_from_revision $revision_id" return $item_id } -# @public get_url -# -# Retrieves the relative URL stub to th item. The URL is relative to the -# page root, and has no extension (Example: "/foo/bar/baz"). -# -# @param item_id The item id -# -# @return The relative URL to the item, or an empty string on failure -# @see proc item::get_extended_url +ad_proc -public item::get_url { item_id } { -ad_proc item::get_url { item_id } { + @public get_url + + Retrieves the relative URL stub to th item. The URL is relative to the + page root, and has no extension (Example: "/foo/bar/baz"). + + @param item_id The item id + + @return The relative URL to the item, or an empty string on failure + @see proc item::get_extended_url +} { + # Get the path template::query gu_get_path item_path onevalue " select content_item.get_path(:item_id) from dual @@ -104,34 +112,37 @@ } } -# @public get_id -# -# Looks up the URL and gets the item id at that URL, if any. -# -# @param url The URL -# @param root_folder {default The Sitemap} -# The ID of the root folder to use for resolving the URL -# -# @return The item ID of the item at that URL, or the empty string -# on failure -# @see proc item::get_url -ad_proc item::get_id { url {root_folder ""}} { +ad_proc -public item::get_id { url {root_folder ""}} { + @public get_id + + Looks up the URL and gets the item id at that URL, if any. + + @param url The URL + @param root_folder {default The Sitemap} + The ID of the root folder to use for resolving the URL + + @return The item ID of the item at that URL, or the empty string + on failure + @see proc item::get_url + +} { + # Strip off file extension set last [string last "." $url] if { $last > 0 } { set url [string range $url 0 [expr $last - 1]] } - set sql [db_map gi_get_item_id_1] if { ![template::util::is_nil root_folder] } { - append sql [db_map gi_get_item_id_2] - } - append sql [db_map gi_get_item_id_3] + set root_sql ", :root_folder, 'f'" + } else { + set root_sql ", null, 'f'" + } # Get the path - template::query gi_get_item_id item_id onevalue $sql -cache "item_id $url $root_folder" + template::query id_get_item_id item_id onevalue "select content_item__get_id(:url $root_sql) from dual" -cache "item_id $url $root_folder" if { [info exists item_id] } { return $item_id @@ -140,22 +151,25 @@ } } -# @public get_mime_info -# -# Creates a onerow datasource in the calling frame which holds the -# mime_type and file_extension of the specified revision. If the -# revision does not exist, does not create the datasource. -# -# @param revision_id The revision id -# @param datasource_ref {default mime_info} The name of the -# datasource to be created. The datasource will have two columns, -# mime_type and file_extension. -# -# return 1 (one) if the revision exists, 0 (zero) otherwise. -# @see proc item::get_extended_url -ad_proc item::get_mime_info { revision_id {datasource_ref mime_info} } { +ad_proc -public item::get_mime_info { revision_id {datasource_ref mime_info} } { + @public get_mime_info + + Creates a onerow datasource in the calling frame which holds the + mime_type and file_extension of the specified revision. If the + revision does not exist, does not create the datasource. + + @param revision_id The revision id + @param datasource_ref {default mime_info} The name of the + datasource to be created. The datasource will have two columns, + mime_type and file_extension. + + return 1 (one) if the revision exists, 0 (zero) otherwise. + @see proc item::get_extended_url + +} { + return [template::query gmi_get_mime_info mime_info onerow " select m.mime_type, m.file_extension @@ -169,18 +183,20 @@ } -# @public get_content_type -# -# Retrieves the content type of tyhe item. If the item does not exist, -# returns an empty string. -# -# @param item_id The item id -# -# @return The content type of the item, or an empty string if no such -# item exists +ad_proc -public item::get_content_type { item_id } { -ad_proc item::get_content_type { item_id } { + @public get_content_type + + Retrieves the content type of tyhe item. If the item does not exist, + returns an empty string. + + @param item_id The item id + + @return The content type of the item, or an empty string if no such + item exists +} { + template::query gct_get_content_type content_type onevalue " select content_type from cr_items where item_id = :item_id @@ -193,33 +209,36 @@ } } -# @public get_content_type -# -# Retrieves the relative URL of the item with a file extension based -# on the item's mime_type (Example: "/foo/bar/baz.html"). -# -# @param item_id The item id -# -# @option template_extension Signifies that the file extension should -# be retrieved using the mime_type of the template assigned to -# the item, not from the item itself. The live revision of the -# template is used. If there is no template which could be used to -# render the item, or if the template has no live revision, the -# extension defaults to ".html" -# -# @option revision_id {default the live revision} Specifies the -# revision_id which will be used to retrieve the item's mime_type. -# This option is ignored if the -template_extension -# option is specified. -# -# @return The relative URL of the item with the appropriate file extension -# or an empty string on failure -# @see proc item::get_url -# @see proc item::get_mime_info -# @see proc item::get_template_id -ad_proc item::get_extended_url { item_id args } { +ad_proc -public item::get_extended_url { item_id args } { + @public get_content_type + + Retrieves the relative URL of the item with a file extension based + on the item's mime_type (Example: "/foo/bar/baz.html"). + + @param item_id The item id + + @option template_extension Signifies that the file extension should + be retrieved using the mime_type of the template assigned to + the item, not from the item itself. The live revision of the + template is used. If there is no template which could be used to + render the item, or if the template has no live revision, the + extension defaults to ".html" + + @option revision_id {default the live revision} Specifies the + revision_id which will be used to retrieve the item's mime_type. + This option is ignored if the -template_extension + option is specified. + + @return The relative URL of the item with the appropriate file extension + or an empty string on failure + @see proc item::get_url + @see proc item::get_mime_info + @see proc item::get_template_id + +} { + set item_url [get_url $item_id] if { [template::util::is_nil item_url] } { @@ -278,24 +297,27 @@ return $file_url } -# @public get_template_id -# -# Retrieves the template which can be used to render the item. If there is -# a template registered directly to the item, returns the id of that template. -# Otherwise, returns the id of the default template registered to the item's -# content_type. Returns an empty string on failure. -# -# @param item_id The item id -# @param context {default 'public'} The context in which the template -# will be used. -# -# @return The template_id of the template which can be used to render the -# item, or an empty string on failure -# -# @see proc item::get_template_url -ad_proc item::get_template_id { item_id {context public} } { +ad_proc -public item::get_template_id { item_id {context public} } { + @public get_template_id + + Retrieves the template which can be used to render the item. If there is + a template registered directly to the item, returns the id of that template. + Otherwise, returns the id of the default template registered to the item's + content_type. Returns an empty string on failure. + + @param item_id The item id + @param context {default 'public'} The context in which the template + will be used. + + @return The template_id of the template which can be used to render the + item, or an empty string on failure + + @see proc item::get_template_url + +} { + template::query gti_get_template_id template_id onevalue " select content_item.get_template(:item_id, :context) as template_id from dual" -cache "item_itemplate_id $item_id" @@ -307,23 +329,26 @@ } } -# @public get_template_url -# -# Retrieves the relative URL of the template which can be used to -# render the item. The URL is relative to the TemplateRoot as it is -# specified in the ini file. -# -# @param item_id The item id -# @param context {default 'public'} The context in which -# the template will be used. -# -# @return The template_id of the template which can be used to render the -# item, or an empty string on failure -# -# @see proc item::get_template_id -ad_proc item::get_template_url { item_id {context public} } { +ad_proc -public item::get_template_url { item_id {context public} } { + @public get_template_url + + Retrieves the relative URL of the template which can be used to + render the item. The URL is relative to the TemplateRoot as it is + specified in the ini file. + + @param item_id The item id + @param context {default 'public'} The context in which + the template will be used. + + @return The template_id of the template which can be used to render the + item, or an empty string on failure + + @see proc item::get_template_id + +} { + set template_id [get_template_id $item_id $context] if { [template::util::is_nil template_id] } { @@ -333,41 +358,47 @@ return [get_url $template_id] } -# @public content_is_null -# -# Determines if the content for the revision is null (not mereley -# zero-length) -# @param revision_id The revision id -# -# @return 1 if the content is null, 0 otherwise -ad_proc item::content_is_null { revision_id } { +ad_proc -public item::content_is_null { revision_id } { + + @public content_is_null + + Determines if the content for the revision is null (not mereley + zero-length) + @param revision_id The revision id + + @return 1 if the content is null, 0 otherwise + +} { template::query cin_get_content content_test onevalue " select 't' from cr_revisions where revision_id = :revision_id and content is not null" return [template::util::is_nil content_test] } -# @public content_methods_by_type -# -# Determines all the valid content methods for instantiating -# a content type. -# Possible choices are text_entry, file_upload, no_content and -# xml_import. Currently, this proc merely removes the text_entry -# method if the item does not have a text mime type registered to -# it. In the future, a more sophisticated mechanism will be -# implemented. -# -# @param content_type The content type -# -# @option get_labels Return not just a list of types, -# but a list of name-value pairs, as in the -options -# ATS switch for form widgets -# -# @return A TCL list of all possible content methods -ad_proc item::content_methods_by_type { content_type args } { +ad_proc -public item::content_methods_by_type { content_type args } { + + @public content_methods_by_type + + Determines all the valid content methods for instantiating + a content type. + Possible choices are text_entry, file_upload, no_content and + xml_import. Currently, this proc merely removes the text_entry + method if the item does not have a text mime type registered to + it. In the future, a more sophisticated mechanism will be + implemented. + + @param content_type The content type + + @option get_labels Return not just a list of types, + but a list of name-value pairs, as in the -options + ATS switch for form widgets + + @return A TCL list of all possible content methods + +} { template::util::get_opts $args @@ -400,28 +431,31 @@ return $methods } -# @public get_revision_content -# -# Create a onerow datasource called content in the calling frame -# which contains all attributes for the revision (including inherited -# ones).

-# The datasource will contain a column called "text", representing the -# main content (blob) of the revision, but only if the revision has a -# textual mime-type. -# -# @param revision_id The revision whose attributes are to be retrieved -# -# @option item_id {default auto-generated} The item_id of the -# corresponding item. -# -# @return 1 on success (and create a content array in the calling frame), -# 0 on failure -# -# @see proc item::get_mime_info -# @see proc item::get_content_type -ad_proc item::get_revision_content { revision_id args } { +ad_proc -public item::get_revision_content { revision_id args } { + @public get_revision_content + + Create a onerow datasource called content in the calling frame + which contains all attributes for the revision (including inherited + ones).

+ The datasource will contain a column called "text", representing the + main content (blob) of the revision, but only if the revision has a + textual mime-type. + + @param revision_id The revision whose attributes are to be retrieved + + @option item_id {default auto-generated} The item_id of the + corresponding item. + + @return 1 on success (and create a content array in the calling frame), + 0 on failure + + @see proc item::get_mime_info + @see proc item::get_content_type + +} { + template::util::get_opts $args if { [template::util::is_nil opts(item_id)] } { @@ -482,67 +516,77 @@ } -# @public is_publishable -# -# Determine if the item is publishable. The item is publishable only -# if: -#

    -#
  • All child relations, as well as item relations, are satisfied -# (according to min_n and max_n)
  • -#
  • The workflow (if any) for the item is finished
  • -#
-# -# @param item_id The item id -# -# @return 1 if the item is publishable, 0 otherwise -ad_proc item::is_publishable { item_id } { +ad_proc -public item::is_publishable { item_id } { + + @public is_publishable + + Determine if the item is publishable. The item is publishable only + if: +
    +
  • All child relations, as well as item relations, are satisfied + (according to min_n and max_n)
  • +
  • The workflow (if any) for the item is finished
  • +
+ + @param item_id The item id + + @return 1 if the item is publishable, 0 otherwise + +} { template::query ip_is_publishable_p is_publishable onevalue " select content_item.is_publishable(:item_id) from dual " -cache "item_is_publishable $item_id" return [string equal $is_publishable t] } -# @public get_publish_status -# -# Get the publish status of the item. The publish status will be one of -# the following: -#
    -#
  • production - The item is still in production. The workflow -# (if any) is not finished, and the item has no live revision.
  • -#
  • ready - The item is ready for publishing
  • -#
  • live - The item has been published
  • -#
  • expired - The item has been published in the past, but -# its publication has expired
  • -#
-# -# @param item_id The item id -# -# @return The publish status of the item, or the empty string on failure -# -# @see proc item::is_publishable -ad_proc item::get_publish_status { item_id } { +ad_proc -public item::get_publish_status { item_id } { + + @public get_publish_status + + Get the publish status of the item. The publish status will be one of + the following: +
    +
  • production - The item is still in production. The workflow + (if any) is not finished, and the item has no live revision.
  • +
  • ready - The item is ready for publishing
  • +
  • live - The item has been published
  • +
  • expired - The item has been published in the past, but + its publication has expired
  • +
+ + @param item_id The item id + + @return The publish status of the item, or the empty string on failure + + @see proc item::is_publishable + +} { + template::query gps_get_publish_status publish_status onevalue " select publish_status from cr_items where item_id = :item_id " -cache "item_publish_status $item_id" return $publish_status } -# @public get_title -# -# Get the title for the item. If a live revision for the item exists, -# use the live revision. Otherwise, use the latest revision. -# -# @param item_id The item id -# -# @return The title of the item -# -# @see proc item::get_best_revision -ad_proc item::get_title { item_id } { +ad_proc -public item::get_title { item_id } { + + @public get_title + + Get the title for the item. If a live revision for the item exists, + use the live revision. Otherwise, use the latest revision. + + @param item_id The item id + + @return The title of the item + + @see proc item::get_best_revision + +} { template::query gt_get_title title onevalue " select content_item.get_title(:item_id) from dual " -cache "item_title $item_id" Index: openacs-4/packages/cms/tcl/module-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/module-procs-oracle.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/module-procs-oracle.xql 14 Aug 2001 18:11:30 -0000 1.2 +++ openacs-4/packages/cms/tcl/module-procs-oracle.xql 20 Aug 2001 04:35:41 -0000 1.3 @@ -3,8 +3,60 @@ oracle8.1.6 - + + + select + o.object_id as item_id, + o.object_type || ': ' || acs_object.name(o.object_id) as item_path, + o.object_type as item_type + from + acs_objects o, parties p + where + o.object_id = p.party_id + and + o.object_id in ($sql_id_list) + order by + item_path + + + + + + + + select + item_id, + content_item.get_path(item_id, :sorted_paths_root_id) as item_path, + content_type as item_type + from + cr_items + where + item_id in ($sql_id_list) + order by item_path + + + + + + + + + select + keyword_id as item_id, + content_keyword.get_path(keyword_id) as item_path, + 'content_keyword' as item_type + from + cr_keywords + where + keyword_id in ($sql_id_list) + + + + + + + select :mount_point as mount_point, @@ -29,23 +81,23 @@ - + select content_template.get_root_folder() from dual - + select content_item.get_root_folder() from dual - + select @@ -61,11 +113,10 @@ - - + + - - select + select :module_name as mount_point, t.pretty_name, t.object_type, @@ -84,15 +135,13 @@ supertype = :id order by t.pretty_name - - + - - select + select :module_name as mount_point, content_keyword.get_heading(keyword_id) as name, keyword_id, @@ -116,11 +165,10 @@ - - + + - - select + select :module_name as mount_point, g.group_name as name, g.group_id, '' as children, @@ -139,57 +187,8 @@ $where_clause order by name - - - - select - item_id, - content_item.get_path(item_id, :sorted_paths_root_id) as item_path, - content_type as item_type - from - cr_items - where - item_id in ($sql_id_list) - order by item_path - - - - - - - select - keyword_id as item_id, - content_keyword.get_path(keyword_id) as item_path, - 'content_keyword' as item_type - from - cr_keywords - where - keyword_id in ($sql_id_list) - - - - - - - - select - o.object_id as item_id, - o.object_type || ': ' || acs_object.name(o.object_id) as item_path, - o.object_type as item_type - from - acs_objects o, parties p - where - o.object_id = p.party_id - and - o.object_id in ($sql_id_list) - order by - item_path - - - - Index: openacs-4/packages/cms/tcl/module-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/module-procs-postgresql.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/tcl/module-procs-postgresql.xql 17 Aug 2001 02:53:47 -0000 1.4 +++ openacs-4/packages/cms/tcl/module-procs-postgresql.xql 20 Aug 2001 04:35:41 -0000 1.5 @@ -2,9 +2,61 @@ postgresql7.1 - - + + + + select + o.object_id as item_id, + o.object_type || ': ' || acs_object__name(o.object_id) as item_path, + o.object_type as item_type + from + acs_objects o, parties p + where + o.object_id = p.party_id + and + o.object_id in ($sql_id_list) + order by + item_path + + + + + + + + + select + item_id, + content_item__get_path(item_id, :sorted_paths_root_id) as item_path, + content_type as item_type + from + cr_items + where + item_id in ($sql_id_list) + order by item_path + + + + + + + + + select + keyword_id as item_id, + content_keyword__get_path(keyword_id) as item_path, + 'content_keyword' as item_type + from + cr_keywords + where + keyword_id in ($sql_id_list) + + + + + + select :mount_point as mount_point, @@ -14,7 +66,7 @@ coalesce((select 't'::text where exists (select 1 from cr_folders f_child, cr_resolved_items r_child where r_child.parent_id = r.resolved_id - and f_child.folder_id = r_child.resolved_id)), 'f'::text) as expandable, + and f_child.folder_id = r_child.resolved_id)), 'f') as expandable, r.is_symlink as symlink, 0 as update_time from @@ -29,52 +81,53 @@ - + select content_template__get_root_folder() - + select content_item__get_root_folder(null) - + - FIX ME CONNECT BY select - lpad(' ', level, '-') || pretty_name as label, + lpad(' ', tree_level(t.tree_sortkey), '-') || pretty_name as label, object_type as value from acs_object_types t - connect by - supertype = prior object_type - start with - object_type = 'content_revision' + where + t.tree_sortkey like (select tree_sortkey || '%' + from acs_object_types + where object_type = 'content_revision') - - + + - select + select :module_name as mount_point, t.pretty_name, t.object_type, '' as children, - ( CASE WHEN - (select count(*) from acs_object_types - where supertype = t.object_type) = 0 - THEN 'f' ELSE 't' END ) as expandable, + coalesce( + (select 't'::text + where exists (select 1 from acs_object_types + where supertype = t.object_type)), + 'f' + ) as expandable, 'f' as symlink, 0 as update_time from @@ -83,61 +136,19 @@ supertype = :id order by t.pretty_name - - + - - select - :module_name as mount_point, - content_keyword__get_heading(keyword_id) as name, - keyword_id, - '' as children, - (CASE WHEN ( - select 1 from cr_keywords k2 - where k2.parent_id = k.keyword_id - and content_keyword__is_leaf(k2.keyword_id) = 'f') - ) = 1 THEN 't' ELSE 'f' END - ) as expandable, - 'f' as symlink, - 0 as update_time - from - cr_keywords k - where - $where_clause - and - content_keyword__is_leaf(keyword_id) = 'f' - order by - name - - - - - - select - item_id, - content_item__get_path(item_id, :sorted_paths_root_id) as item_path, - content_type as item_type - from - cr_items - where - item_id in ($sql_id_list) - order by item_path - - - - - - select + select :module_name as mount_point, content_keyword__get_heading(keyword_id) as name, keyword_id, '' as children, - coalesce( (select 't'::text from dual + coalesce( (select 't'::text where exists ( select 1 from cr_keywords k2 where k2.parent_id = k.keyword_id @@ -153,53 +164,19 @@ content_keyword__is_leaf(keyword_id) = 'f' order by name - +
+ + + - - - - select - keyword_id as item_id, - content_keyword__get_path(keyword_id) as item_path, - 'content_keyword' as item_type - from - cr_keywords - where - keyword_id in ($sql_id_list) - - - - - - - - select - o.object_id as item_id, - o.object_type || ': ' || acs_object__name(o.object_id) as item_path, - o.object_type as item_type - from - acs_objects o, parties p - where - o.object_id = p.party_id - and - o.object_id in ($sql_id_list) - order by - item_path - - - - - - - - select + select :module_name as mount_point, g.group_name as name, g.group_id, '' as children, coalesce( - (select 't'::text from dual + (select 't'::text where exists ( select 1 from group_component_map m2 where m2.group_id = g.group_id)), @@ -213,8 +190,8 @@ $where_clause order by name - - + + Index: openacs-4/packages/cms/tcl/module-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/module-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/tcl/module-procs.tcl 14 Aug 2001 18:11:30 -0000 1.4 +++ openacs-4/packages/cms/tcl/module-procs.tcl 20 Aug 2001 04:35:41 -0000 1.5 @@ -19,43 +19,62 @@ namespace eval cm { + namespace eval modules { + namespace eval workspace { } + namespace eval templates { } + namespace eval workflow { } + namespace eval sitemap { } + namespace eval types { } + namespace eval search { } + namespace eval categories { } + namespace eval users { } + namespace eval clipboard { } + } +} - namespace eval modules { - # Get the id of some module, return empty string on failure - ad_proc get_module_id { module_name } { - template::query gmi_get_module_id id onevalue " +ad_proc -public cm::modules::get_module_id { module_name } { + + Get the id of some module, return empty string on failure + +} { + template::query module_get_id id onevalue " select module_id from cm_modules where key = :module_name " -cache "get_module_name $module_name" -persistent - return $id - } + return $id +} - # Get a list of all the mount points - ad_proc getMountPoints {} { +ad_proc -public cm::modules::getMountPoints {} { - template::query gmp_get_mount_points mount_point_list multilist " - select + Get a list of all the mount points + +} { + + template::query get_list mount_point_list multilist "select key, name, '' as id, '' as children, 't' as expandable, 'f' as symlink, 0 as update_time from cm_modules - order by sort_key" - - # Append clipboard - lappend mount_point_list [folderCreate "clipboard" "Clipboard" "" [list] t f 0] + order by sort_key" + + # Append clipboard + lappend mount_point_list [folderCreate "clipboard" "Clipboard" "" [list] t f 0] - return $mount_point_list - } + return $mount_point_list +} - # Generic getCHildFolders procedure for sitemap and templates - ad_proc getChildFolders { mount_point id } { +ad_proc -public cm::modules::getChildFolders { mount_point id } { - # query for child site nodes - set module_name [namespace tail [namespace current]] + Generic getCHildFolders procedure for sitemap and templates - template::query gcf_get_child_folders result multilist " +} { + + # query for child site nodes + set module_name [namespace tail [namespace current]] + + template::query module_get_result result multilist " select :mount_point as mount_point, r.name, @@ -76,109 +95,120 @@ order by name" - return $result - } + return $result +} - namespace eval workspace { +ad_proc -public cm::modules::workspace::getRootFolderID {} { return 0 } - ad_proc getRootFolderID {} { return 0 } +ad_proc -public cm::modules::workspace::getChildFolders { id } { + return [list] +} - ad_proc getChildFolders { id } { - return [list] - } - } - namespace eval templates { - # Retreive the id of the root folder - ad_proc getRootFolderID {} { - if { ![nsv_exists browser_state template_root] } { - template::query grfi_get_root_id root_id onevalue " +ad_proc -public cm::modules::templates::getRootFolderID {} { + + Retreive the id of the root folder + +} { + if { ![nsv_exists browser_state template_root] } { + template::query template_get_root_id root_id onevalue " select content_template.get_root_folder() from dual" - nsv_set browser_state template_root $root_id - return $root_id - } else { - return [nsv_get browser_state template_root] - } - } + nsv_set browser_state template_root $root_id + return $root_id + } else { + return [nsv_get browser_state template_root] + } +} - ad_proc getChildFolders { id } { - if { [string equal $id {}] } { - set id [getRootFolderID] - } +ad_proc -public cm::modules::templates::getChildFolders { id } { - # query for child site nodes - set module_name [namespace tail [namespace current]] - return [cm::modules::getChildFolders $module_name $id] - } +} { + if { [string equal $id {}] } { + set id [getRootFolderID] + } - ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { - uplevel " + # query for child site nodes + set module_name [namespace tail [namespace current]] + + return [cm::modules::getChildFolders $module_name $id] +} + +ad_proc -public cm::modules::templates::getSortedPaths { name id_list {root_id 0} {eval_code {}}} { + + +} { + uplevel " cm::modules::sitemap::getSortedPaths $name \{$id_list\} $root_id \{$eval_code\} " - } - } +} - namespace eval workflow { - ad_proc getRootFolderID {} { return 0 } +ad_proc -public cm::modules::workflow::getRootFolderID {} { return 0 } - ad_proc getChildFolders { id } { - return [list] - } - } +ad_proc -public cm::modules::workflow::getChildFolders { id } { + return [list] +} - namespace eval sitemap { - # Retreive the id of the root folder - ad_proc getRootFolderID {} { - if { ![nsv_exists browser_state sitemap_root] } { - template::query grfi_get_root_id root_id onevalue " + +ad_proc -public cm::modules::sitemap::getRootFolderID {} { + + Retreive the id of the root folder + +} { + if { ![nsv_exists browser_state sitemap_root] } { + template::query sitemap_get_root_id root_id onevalue " select content_item.get_root_folder() from dual" - nsv_set browser_state sitemap_root $root_id - return $root_id - } else { - return [nsv_get browser_state sitemap_root] - } - } + nsv_set browser_state sitemap_root $root_id + return $root_id + } else { + return [nsv_get browser_state sitemap_root] + } +} - ad_proc getChildFolders { id } { - if { [string equal $id {}] } { - set id [getRootFolderID] - } +ad_proc -public cm::modules::sitemap::getChildFolders { id } { - # query for child site nodes - set module_name [namespace tail [namespace current]] - - return [cm::modules::getChildFolders $module_name $id] - } - ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { +} { + if { [string equal $id {}] } { + set id [getRootFolderID] + } - set sql_id_list "'" - append sql_id_list [join $id_list "','"] - append sql_id_list "'" + # query for child site nodes + set module_name [namespace tail [namespace current]] + + return [cm::modules::getChildFolders $module_name $id] +} - set sql_query [db_map gsp_get_sorted_paths] +ad_proc -public cm::modules::sitemap::getSortedPaths { name id_list {root_id 0} {eval_code {}}} { - upvar sql_query __sql - upvar sorted_paths_root_id _root_id - set _root_id $root_id - uplevel " - template::query gsp_get_paths multirow \{$__sql\} -eval \{$eval_code\} + +} { + + set sql_id_list "'" + append sql_id_list [join $id_list "','"] + append sql_id_list "'" + + upvar sorted_paths_root_id _root_id + set _root_id $root_id + set sql [db_map sitemap_get_name] + uplevel " + template::query sitemap_get_name $name multirow \{$sql\} -eval \{$eval_code\} " - } - - } - # end of sitemap namespace +} - namespace eval types { - # Return a multilist representing the types tree, - # for use in a select widget - ad_proc getTypesTree { } { - template::query gtt_get_tree_types result multilist " + +ad_proc -public cm::modules::types::getTypesTree { } { + + Return a multilist representing the types tree, + for use in a select widget + +} { + + template::query types_get_result result multilist " select lpad(' ', level, '-') || pretty_name as label, object_type as value @@ -190,25 +220,28 @@ object_type = 'content_revision' " - set result [concat [list [list "--" ""]] $result] + set result [concat [list [list "--" ""]] $result] - return $result - } + return $result +} - ad_proc getRootFolderID {} { return "content_revision" } +ad_proc -public cm::modules::types::getRootFolderID {} { return "content_revision" } - ad_proc getChildFolders { id } { +ad_proc -public cm::modules::types::getChildFolders { id } { - set children [list] - if { [string equal $id {}] } { - set id [getRootFolderID] - } +} { - # query for message categories - set module_name [namespace tail [namespace current]] + set children [list] - template::query gcf_get_child_folders result multilist "select + if { [string equal $id {}] } { + set id [getRootFolderID] + } + + # query for message categories + set module_name [namespace tail [namespace current]] + + template::query get_result result multilist "select :module_name as mount_point, t.pretty_name, t.object_type, @@ -227,40 +260,39 @@ supertype = :id order by t.pretty_name" - - return $result - } - } - # end of types namespace - namespace eval search { - ad_proc getRootFolderID {} { return 0 } + return $result +} - ad_proc getChildFolders { id } { - return [list] - } - } +# end of types namespace - namespace eval categories { +ad_proc -public cm::modules::search::getRootFolderID {} { return 0 } - ad_proc getRootFolderID {} { return 0 } +ad_proc -public cm::modules::search::getChildFolders { id } { + return [list] +} - ad_proc getChildFolders { id } { - set children [list] +ad_proc -public cm::modules::categories::getRootFolderID {} { return 0 } - if { [string equal $id {}] } { - set where_clause "k.parent_id is null" - } else { - set where_clause "k.parent_id = :id" - } +ad_proc -public cm::modules::categories::getChildFolders { id } { - set module_name [namespace tail [namespace current]] - # query for keyword categories +} { - template::query gcf_get_child_folders children multilist " - select + set children [list] + + if { [string equal $id {}] } { + set where_clause "k.parent_id is null" + } else { + set where_clause "k.parent_id = :id" + } + + set module_name [namespace tail [namespace current]] + + # query for keyword categories + + template::query category_get_children children multilist "select :module_name as mount_point, content_keyword.get_heading(keyword_id) as name, keyword_id, @@ -282,43 +314,45 @@ order by name" - return $children - } + return $children +} - ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { +ad_proc -public cm::modules::categories::getSortedPaths { name id_list {root_id 0} {eval_code {}}} { - set sql_id_list "'" - append sql_id_list [join $id_list "','"] - append sql_id_list "'" - set sql_query [db_map gsp_get_query] +} { - upvar __sql sql_query - uplevel " - template::query $name multirow \{$__sql\} -eval \{$eval_code\} - " - } + set sql_id_list "'" + append sql_id_list [join $id_list "','"] + append sql_id_list "'" - } - # end of categories namespace + set sql [db_map get_paths] + uplevel "template::query get_paths $name multirow \{$sql\} -eval \{$eval_code\}" +} - namespace eval users { - ad_proc getRootFolderID {} { return 0 } - ad_proc getChildFolders { id } { - - if { [string equal $id {}] } { - set where_clause "not exists (select 1 from group_component_map m +# end of categories namespace + +ad_proc -public cm::modules::users::getRootFolderID {} { return 0 } + +ad_proc -public cm::modules::users::getChildFolders { id } { + + +} { + + if { [string equal $id {}] } { + set where_clause "not exists (select 1 from group_component_map m where m.component_id = g.group_id)" - set map_table "" - } else { - set where_clause "m.group_id = :id and m.component_id = g.group_id" - set map_table ", group_component_map m" - } + set map_table "" + } else { + set where_clause "m.group_id = :id and m.component_id = g.group_id" + set map_table ", group_component_map m" + } - set module_name [namespace tail [namespace current]] + set module_name [namespace tail [namespace current]] - template::query gcf_get_child_folders result multilist "select + + template::query users_get_result result multilist "select :module_name as mount_point, g.group_name as name, g.group_id, '' as children, @@ -337,54 +371,51 @@ $where_clause order by name" - return $result - } + return $result +} - ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { +ad_proc -public cm::modules::users::getSortedPaths { name id_list {root_id 0} {eval_code {}}} { - set sql_id_list "'" - append sql_id_list [join $id_list "','"] - append sql_id_list "'" - set sql_query [db_map gsp_get_sort_paths] +} { - upvar __sql sql_query - uplevel "template::query $name multirow \{$__sql\} -eval \{$eval_code\}" - } - - } + set sql_id_list "'" + append sql_id_list [join $id_list "','"] + append sql_id_list "'" - namespace eval clipboard { + set sql [db_map users_get_paths] + + uplevel "template::query users_get_paths $name multirow \{$sql\} -eval \{$eval_code\}" +} - ad_proc getRootFolderID {} { return 0 } - ad_proc getChildFolders { id } { - # Only the mount point is expandable - if { ![template::util::is_nil id] } { - return [list] - } +ad_proc -public cm::modules::clipboard::getRootFolderID {} { return 0 } - set children [list] - - set module_name [namespace tail [namespace current]] +ad_proc -public cm::modules::clipboard::getChildFolders { id } { - template::query gcf_get_child_folders result multilist " - select + +} { + + # Only the mount point is expandable + if { ![template::util::is_nil id] } { + return [list] + } + + set children [list] + + set module_name [namespace tail [namespace current]] + + template::query clip_get_result result multilist "select :module_name as mount_point, name, key, '' as children, 'f' as expandable, 'f' as symlink, 0 as update_type from cm_modules order by sort_key" - return $result - } - } - # end of clipboard namespace - } - # end of modules namespace -} -# end of cm namespace + return $result +} +# end of clipboard namespace Index: openacs-4/packages/cms/tcl/module-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/module-procs.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/module-procs.xql 14 Aug 2001 18:11:30 -0000 1.2 +++ openacs-4/packages/cms/tcl/module-procs.xql 20 Aug 2001 04:35:42 -0000 1.3 @@ -1,7 +1,7 @@ - + select module_id from cm_modules @@ -11,10 +11,9 @@ - + - - select + select key, name, '' as id, '' as children, 't' as expandable, 'f' as symlink, 0 as update_time @@ -24,10 +23,9 @@ - + - - select + select :module_name as mount_point, name, key, '' as children, 'f' as expandable, Index: openacs-4/packages/cms/tcl/pagination-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/pagination-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/cms/tcl/pagination-procs.tcl 17 Aug 2001 23:33:53 -0000 1.5 +++ openacs-4/packages/cms/tcl/pagination-procs.tcl 20 Aug 2001 04:35:42 -0000 1.6 @@ -6,17 +6,20 @@ namespace eval pagination {} -# @public paginate_query -# Paginates a query +ad_proc -public pagination::paginate_query { sql page } { -# @author Michael Pih + @public paginate_query -# @param sql The sql query to paginate -# @param page The current page number + Paginates a query -ad_proc pagination::paginate_query { sql page } { + @author Michael Pih + @param sql The sql query to paginate + @param page The current page number + +} { + set rows_per_page [pagination::get_rows_per_page] set start_row [expr $rows_per_page*[expr $page-1]+1] @@ -26,50 +29,58 @@ } -# @private get_rows_per_page -# Returns the number of rows per page +ad_proc -private pagination::get_rows_per_page {} { -proc pagination::get_rows_per_page {} { + @private get_rows_per_page + + Returns the number of rows per page + +} { return 10 } -# @public get_total_pages -# Gets the number of pages returned by a query -# PRE: requires $sql +ad_proc -public pagination::get_total_pages { sql } { -# @author Michael Pih + @public get_total_pages -# @param db A database handle + Gets the number of pages returned by a query + PRE: requires $sql -ad_proc pagination::get_total_pages { sql } { - - template::query gtp_get_total_pages total_pages onevalue " + @author Michael Pih + + @param db A database handle + +} { + + template::query gtp_get_total_pages total_pages onevalue " select ceil(count(*) / [pagination::get_rows_per_page] ) from ($sql) x " - return $total_pages - + return $total_pages } -# @public page_number_links -# Generate HTML for navigating pages of a datasource +ad_proc -public pagination::page_number_links { page total_pages } { -# @author Michael Pih + @public page_number_links -# @param page The current page number -# @param total_pages The total pages returned by the query + Generate HTML for navigating pages of a datasource -ad_proc pagination::page_number_links { page total_pages } { + @author Michael Pih + @param page The current page number + @param total_pages The total pages returned by the query + +} { + if { $total_pages == 1 } { return "" } @@ -126,15 +137,18 @@ } -# @private ns_set_to_url_vars -# Converts an ns_set into a list of url variables +ad_proc -private pagination::ns_set_to_url_vars { set_id } { -# @author Michael Pih + @private ns_set_to_url_vars -# @param set_id The set id + Converts an ns_set into a list of url variables -ad_proc pagination::ns_set_to_url_vars { set_id } { + @author Michael Pih + + @param set_id The set id + +} { set url_vars "" set size [ns_set size $set_id] for { set i 0 } { $i < $size } { incr i } { Index: openacs-4/packages/cms/tcl/perm-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/perm-procs-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/perm-procs-postgresql.xql 14 Aug 2001 18:11:30 -0000 1.2 +++ openacs-4/packages/cms/tcl/perm-procs-postgresql.xql 20 Aug 2001 04:35:42 -0000 1.3 @@ -34,22 +34,17 @@ --- RBM: I thought about using Dan's simpler suggestion as per his comments in --- acs-kernel/sql/postgresql/acs-permissions-create.sql but the query does some --- indenting with the tree_level. - select t.child_privilege as privilege, lpad(' ', t.tree_level * 24, ' ') || coalesce(p.pretty_name, t.child_privilege) as label, cms_permission__permission_p(:object_id, :grantee_id, t.child_privilege) as permission_p, cms_permission__permission_p (:object_id, :grantee_id, t.privilege) as parent_permission_p - from ( - select h2.privilege, h2.child_privilege, tree_level(h2.tree_sortkey) as tree_level - from acs_privilege_hierarchy_index h1, - acs_privilege_hierarchy_index h2 - where h1.child_privilege = 'cm_root' - and h1.tree_sortkey like (h2.tree_sortkey || '%') - and h2.tree_sortkey < h1.tree_sortkey + from (select privilege, child_privilege, + tree_level(tree_sortkey) as tree_level + from acs_privilege_hierarchy_index + where tree_sortkey like (select tree_sortkey || '%' + from acs_privilege_hierarchy_index + where privilege = 'cm_root') ) t, acs_privileges p where p.privilege = t.child_privilege Index: openacs-4/packages/cms/tcl/perm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/perm-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/perm-procs.tcl 11 Aug 2001 17:40:26 -0000 1.3 +++ openacs-4/packages/cms/tcl/perm-procs.tcl 20 Aug 2001 04:35:42 -0000 1.4 @@ -4,15 +4,18 @@ # ############################################## -# Redirect the user to an error message -# In the future, have this procedure produce a custom, internationalized -# error message, or something +ad_proc -public content::show_error { + message {return_url {}} {passthrough {}} +} { -# Will pick up mount_point, id, parent_id if they exist in the calling -# frame + Redirect the user to an error message + In the future, have this procedure produce a custom, internationalized + error message, or something -ad_proc content::show_error { - message {return_url {}} {passthrough {}} + Will pick up mount_point, id, parent_id if they exist in the calling + frame + + } { if { [template::util::is_nil return_url] } { @@ -29,21 +32,25 @@ template::forward "[ad_conn package_url]error?[export_vars { message return_url passthrough}]" } -# Query the datatbase for access, show the error page if -# no sufficient access is found. Set up an array -# called "user_permissions" in the calling frame, where the keys -# are permissions and the values are "t" or "f" -# Flags: -# -user_id -# -mount_point -# -parent_id -# -return_url -# -passthrough < { {name value} {name value} ... } -# -request_error: if present, use request error as opposed to error box -# -refresh: if present, update query cache -ad_proc content::check_access { object_id privilege args } { +ad_proc -public content::check_access { object_id privilege args } { + Query the datatbase for access, show the error page if + no sufficient access is found. Set up an array + called "user_permissions" in the calling frame, where the keys + are permissions and the values are "t" or "f" + Flags: + -user_id + -mount_point + -parent_id + -return_url + -passthrough < { {name value} {name value} ... } + -request_error: if present, use request error as opposed to error box + -refresh: if present, update query cache + + +} { + # Set up the default options foreach varname { mount_point return_url parent_id passthrough } { set opts($varname) "" @@ -62,20 +69,21 @@ # Query the database, set up the array upvar user_permissions user_permissions - set code [list template::query ca_get_perm_list perm_list multilist " + if { [info exists opts(refresh)] } { + set switches "-refresh" + } else { + set switches "" + } + + template::query ca_get_perm_list perm_list multilist " select p.privilege, cms_permission.permission_p ( :object_id, :user_id, p.privilege ) as is_granted from - acs_privileges p" \ - -cache "content::check_access $object_id $user_id" -persistent \ - -timeout 300] - if { [info exists opts(refresh)] } { - lappend code "-refresh" - } - eval $code + acs_privileges p + " -cache "content::check_access $object_id $user_id" -persistent -timeout 300 $switches template::util::list_of_lists_to_array $perm_list user_permissions @@ -129,21 +137,26 @@ } -# Flush the cache used by check_access -ad_proc content::flush_access_cache { {object_id {}} } { +ad_proc -public content::flush_access_cache { {object_id {}} } { + + Flush the cache used by check_access + +} { template::query::flush_cache "content::check_access ${object_id}*" } -# Generate a form for modifying permissions -# Requires object_id, grantee_id, user_id to be set in calling frame +ad_proc -public content::perm_form_generate { form_name_in {passthrough "" } } { -ad_proc content::perm_form_generate { form_name_in {passthrough "" } } { + Generate a form for modifying permissions + Requires object_id, grantee_id, user_id to be set in calling frame +} { + upvar perm_form_name form_name set form_name $form_name_in - set sql [db_map pfg_get_permission_boxes] upvar __sql sql + set sql [db_map pfg_get_permission_boxes] uplevel { set is_request [form is_request $perm_form_name] @@ -190,17 +203,19 @@ } -# Process the permission form +ad_proc -public content::perm_form_process { form_name_in } { -ad_proc content::perm_form_process { form_name_in } { + Process the permission form +} { + upvar perm_form_name form_name set form_name $form_name_in - set sql_grant [db_map pfp_grant_permission_1] - set sql_revoke [db_map pfp_revoke_permission_1] upvar __sql_grant sql_grant upvar __sql_revoke sql_revoke + set sql_grant [db_map pfp_grant_permission_1] + set sql_revoke [db_map pfp_revoke_permission_1] uplevel { Index: openacs-4/packages/cms/tcl/publish-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/publish-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/publish-procs.tcl 10 Aug 2001 15:03:28 -0000 1.3 +++ openacs-4/packages/cms/tcl/publish-procs.tcl 20 Aug 2001 04:35:42 -0000 1.4 @@ -28,24 +28,27 @@ # Procs to maintain the item_id stack # main_item_id is always the id at the top of the stack -# @private push_id -# -# Push an item id on top of stack. This proc is used -# to store state between child, relation -# and content tags. -# -# @param item_id -# The id to be put on stack -# -# @param revision_id {default ""} -# The id of the revision to use. If missing, live -# revision will most likely be used -# -# @see proc publish::pop_id -# @see proc publish::get_main_item_id -# @see proc publish::get_main_revision_id -proc publish::push_id { item_id {revision_id ""}} { +ad_proc -private publish::push_id { item_id {revision_id ""}} { + + @private push_id + + Push an item id on top of stack. This proc is used + to store state between child, relation + and content tags. + + @param item_id + The id to be put on stack + + @param revision_id {default ""} + The id of the revision to use. If missing, live + revision will most likely be used + + @see proc publish::pop_id + @see proc publish::get_main_item_id + @see proc publish::get_main_revision_id + +} { variable item_id_stack variable revision_html @@ -86,19 +89,22 @@ set ::content::revision_id $revision_id } -# @private pop_id -# -# Pop the item_id and the revision_id off the top of the stack. -# Clear the temporary item cache if the stack becomes empty. -# -# @return The popped item id, or the empty string if the string is -# already empty -# -# @see proc publish::push_id -# @see proc publish::get_main_item_id -# @see proc publish::get_main_revision_id -proc publish::pop_id {} { +ad_proc -private publish::pop_id {} { + + @private pop_id + + Pop the item_id and the revision_id off the top of the stack. + Clear the temporary item cache if the stack becomes empty. + + @return The popped item id, or the empty string if the string is + already empty + + @see proc publish::push_id + @see proc publish::get_main_item_id + @see proc publish::get_main_revision_id + +} { variable item_id_stack set pair [lindex $item_id_stack 0] @@ -119,18 +125,20 @@ return $::content::item_id } -# @private get_main_item_id -# -# Get the main item id from the top of the stack -# -# @return the main item id -# -# @see proc publish::pop_id -# @see proc publish::push_id -# @see proc publish::get_main_revision_id +ad_proc -private publish::get_main_item_id {} { -proc publish::get_main_item_id {} { + @private get_main_item_id + + Get the main item id from the top of the stack + + @return the main item id + + @see proc publish::pop_id + @see proc publish::push_id + @see proc publish::get_main_revision_id +} { + if { ![template::util::is_nil ::content::item_id] } { set ret $::content::item_id } else { @@ -140,18 +148,21 @@ return $ret } -# @private get_main_revision_id -# -# Get the main item revision from the top of the stack -# -# @return the main item id -# -# @see proc publish::pop_id -# @see proc publish::push_id -# @see proc publish::get_main_item_id -proc publish::get_main_revision_id {} { +ad_proc -private publish::get_main_revision_id {} { + @private get_main_revision_id + + Get the main item revision from the top of the stack + + @return the main item id + + @see proc publish::pop_id + @see proc publish::push_id + @see proc publish::get_main_item_id + +} { + if { [template::util::is_nil ::content::revision_id] } { set item_id [get_main_item_id] set ret [item::get_live_revision $item_id] @@ -166,21 +177,23 @@ # # Publish procs -# @public get_page_root -# -# Get the page root. All items will be published to the -# filesystem with their URLs relative to this root. -# The page root is controlled by the PageRoot parameter in CMS. -# A relative path is relative to [ns_info pageroot] -# The default is [ns_info pageroot] -# -# @return The page root -# -# @see proc publish::get_template_root -# @see proc publish::get_publish_roots +ad_proc -public publish::get_page_root {} { -proc publish::get_page_root {} { + @public get_page_root + + Get the page root. All items will be published to the + filesystem with their URLs relative to this root. + The page root is controlled by the PageRoot parameter in CMS. + A relative path is relative to [ns_info pageroot] + The default is [ns_info pageroot] + + @return The page root + + @see proc publish::get_template_root + @see proc publish::get_publish_roots +} { + set root_path [ad_parameter -package_id [ad_conn package_id] \ PageRoot dummy ""] @@ -193,20 +206,23 @@ } -# @public get_publish_roots -# -# Get a list of all page roots to which files may be published. -# The publish roots are controlled by the PublishRoots parameter in CMS, -# which should be a space-separated list of all the roots. Relative paths -# are relative to publish::get_page_root. -# The default is [list [publish::get_page_root]] -# -# @return A list of all the publish roots -# -# @see proc publish::get_template_root -# @see proc publish::get_page_root -proc publish::get_publish_roots {} { +ad_proc -public publish::get_publish_roots {} { + @public get_publish_roots + + Get a list of all page roots to which files may be published. + The publish roots are controlled by the PublishRoots parameter in CMS, + which should be a space-separated list of all the roots. Relative paths + are relative to publish::get_page_root. + The default is [list [publish::get_page_root]] + + @return A list of all the publish roots + + @see proc publish::get_template_root + @see proc publish::get_page_root + +} { + set root_paths [ad_parameter -package_id [ad_conn package_id] \ PublishRoots dummy] @@ -229,57 +245,69 @@ } -# @public get_template_root -# -# Get the template root. All templates are assumed to exist -# in the filesystem with their URLs relative to this root. -# The page root is controlled by the TemplateRoot parameter in CMS. -# The default is /web/yourserver/templates -# -# @return The template root -# -# @see proc content::get_template_root, proc publish::get_page_root -proc publish::get_template_root {} { +ad_proc -public publish::get_template_root {} { + + @public get_template_root + + Get the template root. All templates are assumed to exist + in the filesystem with their URLs relative to this root. + The page root is controlled by the TemplateRoot parameter in CMS. + The default is /web/yourserver/templates + + @return The template root + + @see proc content::get_template_root, proc publish::get_page_root + +} { return [content::get_template_root] } -# Legacy compatibility -proc content::get_template_path {} { +ad_proc -public content::get_template_path {} { + + Legacy compatibility + +} { return [publish::get_template_root] } -# @public mkdirs -# -# Create all the directories neccessary to save the specified file -# -# @param path -# The path to the file that is about to be saved -# -proc publish::mkdirs { path } { +ad_proc -public publish::mkdirs { path } { + @public mkdirs + + Create all the directories neccessary to save the specified file + + @param path + The path to the file that is about to be saved + + +} { + set index [string last "/" $path] if { $index != -1 } { file mkdir [string range $path 0 [expr $index - 1]] } } -# @private foreach_publish_path -# -# Execute some TCL code for each root path in the PublishRoots -# parameter -# -# @param url Relative URL to append to the roots -# @param code Execute this code -# @param root_path {default The empty string} -# Use this root path instead of the paths specified in the INI -# file -# -# @see proc publish::get_publish_roots -proc publish::foreach_publish_path { url code {root_path ""} } { +ad_proc -private publish::foreach_publish_path { url code {root_path ""} } { + + @private foreach_publish_path + + Execute some TCL code for each root path in the PublishRoots + parameter + + @param url Relative URL to append to the roots + @param code Execute this code + @param root_path {default The empty string} + Use this root path instead of the paths specified in the INI + file + + @see proc publish::get_publish_roots + +} { if { ![template::util::is_nil root_path] } { set paths [list $root_path] } else { @@ -297,18 +325,20 @@ } -# @private write_multiple_files -# -# Write a relative URL to the multiple publishing roots. -# -# @param url Relative URL of the file to write -# @param text A string of text to be written to the URL -# -# @see proc template::util::write_file -# @see proc publish::get_publish_roots -# @see proc publish::write_multiple_blobs +ad_proc -private publish::write_multiple_files { url text {root_path ""}} { -proc publish::write_multiple_files { url text {root_path ""}} { + @private write_multiple_files + + Write a relative URL to the multiple publishing roots. + + @param url Relative URL of the file to write + @param text A string of text to be written to the URL + + @see proc template::util::write_file + @see proc publish::get_publish_roots + @see proc publish::write_multiple_blobs + +} { foreach_publish_path $url { mkdirs $filename template::util::write_file $filename $text @@ -317,82 +347,91 @@ } $root_path } -# @private write_multiple_blobs -# -# Write the content of some revision to multiple publishing roots. -# -# @param db A valid database handle -# @param url Relative URL of the file to write -# @param revision_id Write the blob for this revision -# -# @see proc publish::get_publish_roots -# @see proc publish::write_multiple_files -ad_proc publish::write_multiple_blobs { +ad_proc -private publish::write_multiple_blobs { url revision_id {root_path ""} } { + + @private write_multiple_blobs + + Write the content of some revision to multiple publishing roots. + + @param db A valid database handle + @param url Relative URL of the file to write + @param revision_id Write the blob for this revision + + @see proc publish::get_publish_roots + @see proc publish::write_multiple_files + +} { foreach_publish_path $url { mkdirs $filename db_blob_get_file wmb_get_blob_file " select content from cr_revisions where revision_id = $revision_id - " $filename + " -file $filename ns_chmod $filename 0764 ns_log notice "PUBLISH: Wrote revision $revision_id to $filename" } $root_path } -# @private delete_multiple_files -# -# Delete the specified URL from the filesystem, for all revisions -# -# @param url Relative URL of the file to write -# -# @see proc publish::get_publish_roots -# @see proc publish::write_multiple_files -# @see proc publish::write_multiple_blobs -proc publish::delete_multiple_files { url {root_path ""}} { +ad_proc -private publish::delete_multiple_files { url {root_path ""}} { + + @private delete_multiple_files + + Delete the specified URL from the filesystem, for all revisions + + @param url Relative URL of the file to write + + @see proc publish::get_publish_roots + @see proc publish::write_multiple_files + @see proc publish::write_multiple_blobs + +} { foreach_publish_path $url { ns_unlink -nocomplain $filename ns_log notice "PUBLISH: Delete file $filename" } $root_path } -# @public write_content -# -# Write the content (blob) of a revision into a binary file in the -# filesystem. The file will be published at the relative URL under -# each publish root listed under the PublishRoots parameter in the -# server's INI file (the value returnded by publish::get_page_root is -# used as the default). The file extension will be based on the -# revision's mime-type.
-# For example, an revision whose mime-type is "image/jpeg" -# for an item at "Sitemap/foo/bar" may be written as -# /web/your_server_name/www/foo/bar.jpg -# -# @param revision_id -# The id of the revision to write -# -# @option item_id {default The item_id of the revision} -# Specifies the item to which this revision belongs (mereley -# for optimization purposes) -# -# @option text -# If specified, indicates that the content of the -# revision is readable text (clob), not a binary file -# -# @option root_path {default All paths in the PublishPaths parameter} -# Write the content to this path only. -# -# @return The relative URL of the file that was written, or an empty -# string on failure -# -# @see proc content::get_content_value -# @see proc publish::get_publish_roots -ad_proc publish::write_content { revision_id args } { +ad_proc -public publish::write_content { revision_id args } { + @public write_content + + Write the content (blob) of a revision into a binary file in the + filesystem. The file will be published at the relative URL under + each publish root listed under the PublishRoots parameter in the + server's INI file (the value returnded by publish::get_page_root is + used as the default). The file extension will be based on the + revision's mime-type.
+ For example, an revision whose mime-type is "image/jpeg" + for an item at "Sitemap/foo/bar" may be written as + /web/your_server_name/www/foo/bar.jpg + + @param revision_id + The id of the revision to write + + @option item_id {default The item_id of the revision} + Specifies the item to which this revision belongs (mereley + for optimization purposes) + + @option text + If specified, indicates that the content of the + revision is readable text (clob), not a binary file + + @option root_path {default All paths in the PublishPaths parameter} + Write the content to this path only. + + @return The relative URL of the file that was written, or an empty + string on failure + + @see proc content::get_content_value + @see proc publish::get_publish_roots + +} { + template::util::get_opts $args if { [template::util::is_nil opts(root_path)] } { @@ -415,11 +454,10 @@ } else { set item_id $opts(item_id) } - } + - set file_url [item::get_extended_url $item_id -revision_id $revision_id] + set file_url [item::get_extended_url $item_id -revision_id $revision_id] - db_transaction { # Write blob/text to file ns_log notice "Writing item $item_id to $file_url" @@ -446,20 +484,20 @@ } -# @public get_html_body -# -# Strip the <body> tags from the HTML, leaving just the body itself. -# Useful for including templates in each other. -# -# @param html -# The html to be processed -# -# @return Everything between the <body> and the </body> tags -# if they exist; the unchanged HTML if they do not -# -# FIX ME: This approach is not really flexible, as HTML 4 accepts tags broken in lines +ad_proc -public publish::get_html_body { html } { -proc publish::get_html_body { html } { + @public get_html_body + + Strip the <body> tags from the HTML, leaving just the body itself. + Useful for including templates in each other. + + @param html + The html to be processed + + @return Everything between the <body> and the </body> tags + if they exist; the unchanged HTML if they do not + +} { if { [regexp -nocase {]*>(.*)} $html match body_text] } { return $body_text @@ -468,50 +506,53 @@ } } -# @private render_subitem -# -# Render a child/related item and return the resulting HTML, stripping -# off the headers. -# -# @param main_item_id The id of the parent item -# -# @param relation_type -# Either child or relation. -# Determines which tables are searched for subitems. -# -# @param relation_tag -# The relation tag to look for -# -# @param index -# The relative index of the subitem. The subitem with -# lowest order_n has index 1, the second lowest order_n -# has index 2, and so on. -# -# @param is_embed -# If "t", the child item may be embedded directly -# in the HTML. Otherwise, it may be dynamically included. The proc -# does not process this parameter directly, but passes it to -# handle_item -# -# @param extra_args -# Any additional HTML arguments to be used when -# rendering the item, in form {name value name value ...} -# -# @param is_merge {default t} -# If "t", merge_with_template may -# be used to render the subitem. Otherwise, merge_with_template -# should not be used, in order to prevent infinite recursion. -# -# @return The rendered HTML for the child item -# -# @see proc publish::merge_with_template -# @see proc publish::handle_item -ad_proc publish::render_subitem { +ad_proc -public publish::render_subitem { main_item_id relation_type relation_tag \ index is_embed extra_args {is_merge t} } { + @private render_subitem + + Render a child/related item and return the resulting HTML, stripping + off the headers. + + @param main_item_id The id of the parent item + + @param relation_type + Either child or relation. + Determines which tables are searched for subitems. + + @param relation_tag + The relation tag to look for + + @param index + The relative index of the subitem. The subitem with + lowest order_n has index 1, the second lowest order_n + has index 2, and so on. + + @param is_embed + If "t", the child item may be embedded directly + in the HTML. Otherwise, it may be dynamically included. The proc + does not process this parameter directly, but passes it to + handle_item + + @param extra_args + Any additional HTML arguments to be used when + rendering the item, in form {name value name value ...} + + @param is_merge {default t} + If "t", merge_with_template may + be used to render the subitem. Otherwise, merge_with_template + should not be used, in order to prevent infinite recursion. + + @return The rendered HTML for the child item + + @see proc publish::merge_with_template + @see proc publish::handle_item + +} { + # Get the child item if { [string equal $relation_type child] } { @@ -562,53 +603,58 @@ } -# @public proc_exists -# -# Determine if a procedure exists in the given namespace -# -# @param namespace_name The fully qualified namespace name, -# such as "template::util" -# -# @param proc_name The proc name, such as "is_nil" -# -# @return 1 if the proc exists in the given namespace, 0 otherwise +ad_proc -public publish::proc_exists { namespace_name proc_name } { -proc publish::proc_exists { namespace_name proc_name } { + @public proc_exists + + Determine if a procedure exists in the given namespace + + @param namespace_name The fully qualified namespace name, + such as "template::util" + + @param proc_name The proc name, such as "is_nil" + + @return 1 if the proc exists in the given namespace, 0 otherwise +} { + return [expr ![string equal \ [namespace eval $namespace_name \ "info procs $proc_name"] {}]] } -# @public get_mime_handler -# -# Return the name of a proc that should be used to render items with -# the given mime-type. -# The mime type handlers should all follow the naming convention -# -#
-# proc publish::handle::mime_prefix::mime_suffix -#
-# -# If the specific mime handler could not be found, get_mime_handler -# looks for a generic procedure with the name -# -#
-# proc publish::handle::mime_prefix -#
-# -# If the generic mime handler does not exist either, -# get_mime_handler returns "" -# -# @param mime_type -# The full mime type, such as "text/html" or "image/jpg" -# -# @return The name of the proc which should be used to handle the mime-type, -# or an empty string on failure. -# -# @see proc publish::handle_item -proc publish::get_mime_handler { mime_type } { +ad_proc -public publish::get_mime_handler { mime_type } { + + @public get_mime_handler + + Return the name of a proc that should be used to render items with + the given mime-type. + The mime type handlers should all follow the naming convention + +
+ proc publish::handle::mime_prefix::mime_suffix +
+ + If the specific mime handler could not be found, get_mime_handler + looks for a generic procedure with the name + +
+ proc publish::handle::mime_prefix +
+ + If the generic mime handler does not exist either, + get_mime_handler returns "" + + @param mime_type + The full mime type, such as "text/html" or "image/jpg" + + @return The name of the proc which should be used to handle the mime-type, + or an empty string on failure. + + @see proc publish::handle_item + +} { set mime_pair [split $mime_type "/"] set mime_prefix [lindex $mime_pair 0] set mime_suffix [lindex $mime_pair 1] @@ -628,47 +674,50 @@ } -# @private handle_item -# -# Render an item either by looking it up in the the temporary cache, -# or by using the appropriate mime handler. Once the item is rendered, it -# is stored in the temporary cache under a key which combines the item_id, -# any extra HTML parameters, and a flag which specifies whether the item -# was merged with its template.
-# This proc takes the same arguments as the individual mime handlers. -# -# @param item_id The id of the item to be rendered -# -# @option revision_id {default The live revision} -# The revision which is to be used when rendering the item -# -# @option no_merge -# Indicates that the item should NOT be merged with its -# template. This option is used to avoid infinite recursion. -# -# @option refresh -# Re-render the item even if it exists in the cache. -# Use with caution - circular dependencies may cause infinite recursion -# if this option is specified -# -# @option embed -# Signifies that the content should be statically embedded directly in -# the HTML. If this option is not specified, the item may -# be dynamically referenced, f.ex. using the <include> -# tag -# -# @option html -# Extra HTML parameters to be passed to the item handler, in format -# {name value name value ...} -# -# @return The rendered HTML for the item, or an empty string on failure -# -# @see proc publish::handle_binary_file -# @see proc publish::handle::text -# @see proc publish::handle::image -proc publish::handle_item { item_id args } { +ad_proc -private publish::handle_item { item_id args } { + @private handle_item + + Render an item either by looking it up in the the temporary cache, + or by using the appropriate mime handler. Once the item is rendered, it + is stored in the temporary cache under a key which combines the item_id, + any extra HTML parameters, and a flag which specifies whether the item + was merged with its template.
+ This proc takes the same arguments as the individual mime handlers. + + @param item_id The id of the item to be rendered + + @option revision_id {default The live revision} + The revision which is to be used when rendering the item + + @option no_merge + Indicates that the item should NOT be merged with its + template. This option is used to avoid infinite recursion. + + @option refresh + Re-render the item even if it exists in the cache. + Use with caution - circular dependencies may cause infinite recursion + if this option is specified + + @option embed + Signifies that the content should be statically embedded directly in + the HTML. If this option is not specified, the item may + be dynamically referenced, f.ex. using the <include> + tag + + @option html + Extra HTML parameters to be passed to the item handler, in format + {name value name value ...} + + @return The rendered HTML for the item, or an empty string on failure + + @see proc publish::handle_binary_file + @see proc publish::handle::text + @see proc publish::handle::image + +} { + template::util::get_opts $args variable revision_html @@ -734,23 +783,26 @@ } -# @public publish_revision -# -# Render a revision for an item and write it to the filesystem. The -# revision is always rendered with the -embed option turned -# on. -# -# @param revision_id The revision id -# -# @option root_path {default All paths in the PublishPaths parameter} -# Write the content to this path only. -# -# @see proc item::get_extended_url -# @see proc publish::get_publish_paths -# @see proc publish::handle_item -proc publish::publish_revision { revision_id args} { +ad_proc -public publish::publish_revision { revision_id args} { + @public publish_revision + + Render a revision for an item and write it to the filesystem. The + revision is always rendered with the -embed option turned + on. + + @param revision_id The revision id + + @option root_path {default All paths in the PublishPaths parameter} + Write the content to this path only. + + @see proc item::get_extended_url + @see proc publish::get_publish_paths + @see proc publish::handle_item + +} { + template::util::get_opts $args if { [template::util::is_nil opts(root_path)] } { @@ -773,21 +825,24 @@ } -# @public unpublish_item -# -# Delete files which were created by publish_revision -# -# @param item_id The item id -# -# @option revision_id {default The live revision} -# The revision which is to be used for determining the item filename -# -# @option root_path {default All paths in the PublishPaths parameter} -# Write the content to this path only. -# -# @see proc publish::publish_revision -proc publish::unpublish_item { item_id args } { +ad_proc -public publish::unpublish_item { item_id args } { + + @public unpublish_item + + Delete files which were created by publish_revision + + @param item_id The item id + + @option revision_id {default The live revision} + The revision which is to be used for determining the item filename + + @option root_path {default All paths in the PublishPaths parameter} + Write the content to this path only. + + @see proc publish::publish_revision + +} { template::util::get_opts $args @@ -834,25 +889,28 @@ } -# @private merge_with_template -# -# Merge the item with its template and return the resulting HTML. This proc -# is simlar to content::init -# -# @param item_id The item id -# -# @option revision_id {default The live revision} -# The revision which is to be used when rendering the item -# -# @option html -# Extra HTML parameters to be passed to the ADP parser, in format -# {name value name value ...} -# -# @return The rendered HTML, or the empty string on failure -# -# @see proc publish::handle_item -proc publish::merge_with_template { item_id args } { +ad_proc -private publish::merge_with_template { item_id args } { + + @private merge_with_template + + Merge the item with its template and return the resulting HTML. This proc + is simlar to content::init + + @param item_id The item id + + @option revision_id {default The live revision} + The revision which is to be used when rendering the item + + @option html + Extra HTML parameters to be passed to the ADP parser, in format + {name value name value ...} + + @return The rendered HTML, or the empty string on failure + + @see proc publish::handle_item + +} { #set ::content::item_id $item_id set ::content::item_url [item::get_url $item_id] @@ -895,19 +953,22 @@ return $html } -# @private set_to_pairs -# -# Convert an ns_set into a list of name-value pairs, in form -# {name value name value ...} -# -# @param params The ns_set id -# @param exclusion_list {} -# A list of keys to be ignored -# -# @return A list of name-value pairs representing the data in the ns_set -proc publish::set_to_pairs { params {exclusion_list ""} } { +ad_proc -private publish::set_to_pairs { params {exclusion_list ""} } { + @private set_to_pairs + + Convert an ns_set into a list of name-value pairs, in form + {name value name value ...} + + @param params The ns_set id + @param exclusion_list {} + A list of keys to be ignored + + @return A list of name-value pairs representing the data in the ns_set + +} { + set extra_args [list] for { set i 0 } { $i < [ns_set size $params] } { incr i } { set key [ns_set key $params $i] @@ -924,19 +985,22 @@ # # The content tags -# @private process_tag -# -# Process a child or relation tag. This is -# a helper proc for the tags, which acts as a wrapper for -# render_subitem. -# -# @param relation_type Either child or relation -# @param params The ns_set id for extra HTML parameters -# -# @see proc publish::render_subitem -proc publish::process_tag { relation_type params } { +ad_proc -private publish::process_tag { relation_type params } { + @private process_tag + + Process a child or relation tag. This is + a helper proc for the tags, which acts as a wrapper for + render_subitem. + + @param relation_type Either child or relation + @param params The ns_set id for extra HTML parameters + + @see proc publish::render_subitem + +} { + set tag [template::get_attribute content $params tag] set index [template::get_attribute content $params index 1] set embed [ns_set find $params embed] @@ -1021,19 +1085,21 @@ template::adp_append_code "append __adp_output \[$command\]" } + +ad_proc -private publish::html_args { argv } { -# @private html_args -# -# Concatenate a list of name-value pairs as returned by -# set_to_pairs into a list of "name=value" pairs -# -# @param argv The list of name-value pairs -# -# @return An HTML string in format "name=value name=value ..." -# -# @see proc publish::set_to_pairs + @private html_args -proc publish::html_args { argv } { + Concatenate a list of name-value pairs as returned by + set_to_pairs into a list of "name=value" pairs + + @param argv The list of name-value pairs + + @return An HTML string in format "name=value name=value ..." + + @see proc publish::set_to_pairs + +} { set extra_html "" if { ![template::util::is_nil argv] } { foreach { name value } $argv { @@ -1044,27 +1110,29 @@ return $extra_html } -# @public item_include_tag -# -# Create an include tag to include an item, in the form -#
-# include src=/foo/bar/baz item_id=item_id -# param=value param=value ... -#
-# -# @param item_id The item id -# -# @param extra_args {} -# A list of extra parameters to be passed to the include -# tag, in form {name value name value ...} -# -# @return The HTML for the include tag -# -# @see proc item::item_url -# @see proc publish::html_args +ad_proc -public publish::item_include_tag { item_id {extra_args {}} } { -proc publish::item_include_tag { item_id {extra_args {}} } { + @public item_include_tag + + Create an include tag to include an item, in the form +
+ include src=/foo/bar/baz item_id=item_id + param=value param=value ... +
+ + @param item_id The item id + + @param extra_args {} + A list of extra parameters to be passed to the include + tag, in form {name value name value ...} + + @return The HTML for the include tag + + @see proc item::item_url + @see proc publish::html_args +} { + # Concatenate all the extra html arguments into a string set extra_html [publish::html_args $extra_args]"" set item_url [item::get_url $item_id] @@ -1076,56 +1144,59 @@ # Procs for handling mime types # -# @public handle_binary_file -# -# Helper procedure for writing handlers for binary files. -# It will write the blob of the item to the filesystem, -# but only if -embed is specified. Then, it will attempt to -# merge the image with its template.
-# This proc accepts exactly the same options a typical handler. -# -# @param item_id -# The id of the item to handle -# -# @param revision_id_ref {required} -# The name of the variable in the calling frame that will -# recieve the revision_id whose content blob was written -# to the filesystem. -# -# @param url_ref -# The name of the variable in the calling frame that will -# recieve the relative URL of the file in the file system -# which contains the content blob -# -# @param error_ref -# The name of the variable in the calling frame that will -# recieve an error message. If no error has ocurred, this -# variable will be set to the empty string "" -# -# @option embed -# Signifies that the content should be embedded directly in -# the parent item. -embed is required for this -# proc, since it makes no sense to handle the binary file -# in any other way. -# -# @option revision_id {default The live revision for the item} -# The revision whose content is to be used -# -# @option no_merge -# If present, do NOT merge with the template, in order to -# prevent infinite recursion in the <content> tag. In -# this case, the proc will return the empty string "" -# -# @return The HTML resulting from merging the item with its -# template, or "" if no template exists or the -no_merge -# flag was specified -# -# @see proc publish::handle::image -proc publish::handle_binary_file { +ad_proc -public publish::handle_binary_file { item_id revision_id_ref url_ref error_ref args } { + @public handle_binary_file + + Helper procedure for writing handlers for binary files. + It will write the blob of the item to the filesystem, + but only if -embed is specified. Then, it will attempt to + merge the image with its template.
+ This proc accepts exactly the same options a typical handler. + + @param item_id + The id of the item to handle + + @param revision_id_ref {required} + The name of the variable in the calling frame that will + recieve the revision_id whose content blob was written + to the filesystem. + + @param url_ref + The name of the variable in the calling frame that will + recieve the relative URL of the file in the file system + which contains the content blob + + @param error_ref + The name of the variable in the calling frame that will + recieve an error message. If no error has ocurred, this + variable will be set to the empty string "" + + @option embed + Signifies that the content should be embedded directly in + the parent item. -embed is required for this + proc, since it makes no sense to handle the binary file + in any other way. + + @option revision_id {default The live revision for the item} + The revision whose content is to be used + + @option no_merge + If present, do NOT merge with the template, in order to + prevent infinite recursion in the <content> tag. In + this case, the proc will return the empty string "" + + @return The HTML resulting from merging the item with its + template, or "" if no template exists or the -no_merge + flag was specified + + @see proc publish::handle::image + +} { + template::util::get_opts $args upvar $error_ref error_msg @@ -1170,13 +1241,16 @@ } -# The basic image handler. Writes the image blob to the filesystem, -# then either merges with the template or provides a default -# tag. Uses the title for alt text if no alt text is specified -# externally. -ad_proc publish::handle::image { item_id args } { +ad_proc -public publish::handle::image { item_id args } { + The basic image handler. Writes the image blob to the filesystem, + then either merges with the template or provides a default + tag. Uses the title for alt text if no alt text is specified + externally. + +} { + template::util::get_opts $args set html [eval publish::handle_binary_file \ @@ -1239,10 +1313,12 @@ } -# Return the text body of the item +ad_proc -public publish::handle::text { item_id args } { -proc publish::handle::text { item_id args } { + Return the text body of the item +} { + template::util::get_opts $args if { [template::util::is_nil opts(revision_id)] } { @@ -1281,26 +1357,29 @@ # # Scheduled proc stuff -# @public set_publish_status -# -# Set the publish status of the item. If the status is live, publish the -# live revision of the item to the filesystem. Otherwise, unpublish -# the item from the filesystem. -# -# @param db The database handle -# @param item_id The item id -# @param new_status -# The new publish status. Must be "production", "expired", "ready" or -# "live" -# @param revision_id {default The live revision} -# The revision id to be used when publishing the item to the filesystem. -# -# @see proc publish::publish_revision -# @see proc publish::unpublish_item -ad_proc publish::set_publish_status { item_id new_status {revision_id ""} } { +ad_proc -public publish::set_publish_status { item_id new_status {revision_id ""} } { + @public set_publish_status + + Set the publish status of the item. If the status is live, publish the + live revision of the item to the filesystem. Otherwise, unpublish + the item from the filesystem. + + @param db The database handle + @param item_id The item id + @param new_status + The new publish status. Must be "production", "expired", "ready" or + "live" + @param revision_id {default The live revision} + The revision id to be used when publishing the item to the filesystem. + + @see proc publish::publish_revision + @see proc publish::unpublish_item +} { + + switch $new_status { production - expired { @@ -1349,14 +1428,16 @@ } + +ad_proc -private publish::track_publish_status {} { -# @private track_publish_status -# -# Scheduled proc which keeps the publish status updated -# -# @see proc publish::schedule_status_sweep + @private track_publish_status -ad_proc publish::track_publish_status {} { + Scheduled proc which keeps the publish status updated + + @see proc publish::schedule_status_sweep + +} { ns_log notice "PUBLISH: Tracking publish status" @@ -1419,28 +1500,31 @@ } } -# @public schedule_status_sweep -# -# Schedule a proc to keep track of the publish status. Resets -# the publish status to "expired" if the expiration date has passed. -# Publishes the item and sets the publish status to "live" if -# the current status is "ready" and the scheduled publication time -# has passed. -# -# @param interval {default 3600} -# The interval, in seconds, between the sweeps of all items in -# the content repository. Lower values increase the precision -# of the publishing/expiration dates but decrease performance. -# If this parameter is not specified, the value of the -# StatusSweepInterval parameter in the server's INI file is used -# (if it exists). -# -# @see proc publish::set_publish_status -# @see proc publish::unschedule_status_sweep -# @see proc publish::track_publish_status -proc publish::schedule_status_sweep { {interval ""} } { +ad_proc -public publish::schedule_status_sweep { {interval ""} } { + @public schedule_status_sweep + + Schedule a proc to keep track of the publish status. Resets + the publish status to "expired" if the expiration date has passed. + Publishes the item and sets the publish status to "live" if + the current status is "ready" and the scheduled publication time + has passed. + + @param interval {default 3600} + The interval, in seconds, between the sweeps of all items in + the content repository. Lower values increase the precision + of the publishing/expiration dates but decrease performance. + If this parameter is not specified, the value of the + StatusSweepInterval parameter in the server's INI file is used + (if it exists). + + @see proc publish::set_publish_status + @see proc publish::unschedule_status_sweep + @see proc publish::track_publish_status + +} { + if { [template::util::is_nil interval] } { # Kludge: relies on that CMS is a singleton package set package_id [apm_package_id_from_key "cms"] @@ -1453,14 +1537,15 @@ } +ad_proc -public publish::unschedule_status_sweep {} { -# @public unschedule_status_sweep -# -# Unschedule the proc which keeps track of the publish status. -# -# @see proc publish::schedule_status_sweep + @public unschedule_status_sweep + + Unschedule the proc which keeps track of the publish status. + + @see proc publish::schedule_status_sweep -proc publish::unschedule_status_sweep {} { +} { set proc_id [cache get status_sweep_proc_id] if { ![template::util::is_nil proc_id] } { Index: openacs-4/packages/cms/tcl/rel-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/rel-procs.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/rel-procs.tcl 11 Aug 2001 17:40:26 -0000 1.2 +++ openacs-4/packages/cms/tcl/rel-procs.tcl 20 Aug 2001 04:35:42 -0000 1.3 @@ -6,18 +6,21 @@ namespace eval cms_rel {} -# @public sort_related_item_order -# Resort the related items order for a given content item, ensuring that -# order_n is unique for an item_id. Chooses new order based on the old -# order_n and then rel_id (the order the item was related) +ad_proc -public cms_rel::sort_related_item_order { item_id } { -# @author Michael Pih + @public sort_related_item_order -# @param item_id The item for which to resort related items + Resort the related items order for a given content item, ensuring that + order_n is unique for an item_id. Chooses new order based on the old + order_n and then rel_id (the order the item was related) -ad_proc cms_rel::sort_related_item_order { item_id } { + @author Michael Pih + @param item_id The item for which to resort related items + +} { + db_transaction { # grab all related items ordered by order_n, rel_id @@ -48,18 +51,19 @@ } +ad_proc -public cms_rel::sort_child_item_order { item_id } { -# @public sort_child_item_order + @public sort_child_item_order -# Resort the child items order for a given content item, ensuring that -# order_n is unique for an item_id. Chooses new order based on the old -# order_n and then rel_id (the order the item was related) + Resort the child items order for a given content item, ensuring that + order_n is unique for an item_id. Chooses new order based on the old + order_n and then rel_id (the order the item was related) -# @author Michael Pih + @author Michael Pih -# @param item_id The item for which to resort child items + @param item_id The item for which to resort child items -ad_proc cms_rel::sort_child_item_order { item_id } { +} { db_transaction { Index: openacs-4/packages/cms/tcl/search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/search-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/search-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/search-procs.tcl 20 Aug 2001 04:35:42 -0000 1.2 @@ -2,13 +2,16 @@ namespace eval search {} -# Convert a list of keywords, such as "rat fish bird" -# into an Intermedia search clause of the form -# %rat%, %fish%, %bird% -# If the -within varname option is specified, use the within clause -# In the future, do something so that the scoring is consistent -proc search::intermedia_keywords { keywords args } { +ad_proc -public search::intermedia_keywords { keywords args } { + Convert a list of keywords, such as "rat fish bird" + into an Intermedia search clause of the form + %rat%, %fish%, %bird% + If the -within varname option is specified, use the within clause + In the future, do something so that the scoring is consistent + +} { + template::util::get_opts args set word_list [split $keywords " "] @@ -24,4 +27,4 @@ } return $inter_clause -} \ No newline at end of file +} Index: openacs-4/packages/cms/tcl/user-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/user-procs-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/user-procs-postgresql.xql 14 Aug 2001 18:11:30 -0000 1.2 +++ openacs-4/packages/cms/tcl/user-procs-postgresql.xql 20 Aug 2001 04:35:42 -0000 1.3 @@ -6,7 +6,7 @@ - select content_permission__cm_admin_exists + select content_permission__cm_admin_exists () Index: openacs-4/packages/cms/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/widget-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/widget-procs.tcl 11 Aug 2001 17:40:26 -0000 1.3 +++ openacs-4/packages/cms/tcl/widget-procs.tcl 20 Aug 2001 04:35:42 -0000 1.4 @@ -7,30 +7,33 @@ namespace eval widget {} -# @public param_element_create -# Dipatches subprocs to generate the form elements for -# setting an attribute widget param -# @param form Name of the form in which to generate the form elements +ad_proc -public widget::param_element_create { form param order param_id \ + {default ""} {is_required ""} {param_source ""}} { -# @param param Name of the form widget param for which to generate a -# form element + @public param_element_create + Dipatches subprocs to generate the form elements for + setting an attribute widget param -# @param order The order that the param form widget will appear in the form + @param form Name of the form in which to generate the form elements -# @param param_id The ID of the form widget param + @param param Name of the form widget param for which to generate a + form element -# @param default The default value of the form widget param + @param order The order that the param form widget will appear in the form -# @param is_required Flag indicating whether the form widget param is -# optional or required + @param param_id The ID of the form widget param -# @param param_source The default source of the value of the form widget -# param. One of literal, eval, query + @param default The default value of the form widget param -proc widget::param_element_create { form param order param_id \ - {default ""} {is_required ""} {param_source ""}} { + @param is_required Flag indicating whether the form widget param is + optional or required + @param param_source The default source of the value of the form widget + param. One of literal, eval, query + +} { + template::element create $form param_$order \ -datatype keyword \ -widget hidden \ @@ -47,17 +50,20 @@ } -# @private create_param_type -# Create default param_type form widget for adding/editing -# metadata form widgets +ad_proc -private widget::create_param_type { form order } { -# @author Michael Pih + @private create_param_type -# @param form The name of the form -# @param order The order of placement of the form widget within the form + Create default param_type form widget for adding/editing + metadata form widgets -proc widget::create_param_type { form order } { + @author Michael Pih + + @param form The name of the form + @param order The order of placement of the form widget within the form + +} { template::element create $form param_type_$order \ -datatype keyword \ -widget select \ @@ -70,19 +76,22 @@ } -# @private create_param_source -# Create default param_source form widget for adding/editing metadata -# form widgets +ad_proc -private widget::create_param_source { form order param_source } { -# @author Michael Pih + @private create_param_source -# @param form -# @param order The order of placement of the form widget within the form -# @param param_source The default param source of the metadata widget -# (literal, query, eval) + Create default param_source form widget for adding/editing metadata + form widgets -proc widget::create_param_source { form order param_source } { + @author Michael Pih + + @param form + @param order The order of placement of the form widget within the form + @param param_source The default param source of the metadata widget + (literal, query, eval) + +} { template::element create $form param_source_$order \ -datatype keyword \ -widget select \ @@ -92,20 +101,21 @@ } +ad_proc -private widget::create_param_value { form order default is_required } { -# @private create_param_value + @private create_param_value -# Create default param_value form widget for adding/editing metadata form -# widgets + Create default param_value form widget for adding/editing metadata form + widgets -# @author Michael Pih + @author Michael Pih -# @param form The name of the form -# @param order The order of placement of the form widget within the form -# @param is_required A flag indicating whether the value of the form widget -# param is mandatory + @param form The name of the form + @param order The order of placement of the form widget within the form + @param is_required A flag indicating whether the value of the form widget + param is mandatory -proc widget::create_param_value { form order default is_required } { +} { if { ![template::util::is_nil is_required] } { template::element create $form param_value_$order \ @@ -126,21 +136,24 @@ } } -# @private create_text_param -# Create default text param form widget for adding/editing metadata form -# widgets +ad_proc -private widget::create_text_param { form order default is_required param_source} { -# @author Michael Pih + @private create_text_param -# @param form The name of the form -# @param default The default value for the form widget param value -# @param is_required A flag indicating whether the value of the form widget -# param is mandatory -# @param param_source The deafult param source for the form widget param -# value (literal, query, eval) + Create default text param form widget for adding/editing metadata form + widgets -proc widget::create_text_param { form order default is_required param_source} { + @author Michael Pih + + @param form The name of the form + @param default The default value for the form widget param value + @param is_required A flag indicating whether the value of the form widget + param is mandatory + @param param_source The deafult param source for the form widget param + value (literal, query, eval) + +} { template::element create $form param_type_$order \ -datatype keyword \ -widget hidden \ @@ -153,23 +166,26 @@ -# @private create_options_param -# Create the options param form widget for adding/editing metadata form -# widgets +ad_proc -private widget::create_options_param { form order default is_required \ + param_source} { -# @author Michael Pih + @private create_options_param -# @param form The name of the form -# @param order The order of placement of the form widget within the form -# @param default The default value of the form widget param value -# @param is_required A flag indicating whether the form widget param -# value is mandatory -# @param param_source The default param source for the form widget param -# value (literal, query, eval) + Create the options param form widget for adding/editing metadata form + widgets -proc widget::create_options_param { form order default is_required \ - param_source} { + @author Michael Pih + + @param form The name of the form + @param order The order of placement of the form widget within the form + @param default The default value of the form widget param value + @param is_required A flag indicating whether the form widget param + value is mandatory + @param param_source The default param source for the form widget param + value (literal, query, eval) + +} { template::element create $form param_type_$order \ -datatype keyword \ @@ -181,22 +197,25 @@ } -# @private create_values_param -# Create the values param form widget for adding/editing metadata widgets +ad_proc -private widget::create_values_param { form order default is_required param_source} { -# @author Michael Pih + @private create_values_param -# @param form The name of the form -# @param order The order of placement of the form widget within the -# metadata form -# @param default The default value of the form widget param value -# @param is_required A flag indicating whether the form widget param value -# is mandatory -# @param param_source The default param_source for the form widget param -# value (literal, query, eval) + Create the values param form widget for adding/editing metadata widgets -proc widget::create_values_param { form order default is_required param_source} { + @author Michael Pih + + @param form The name of the form + @param order The order of placement of the form widget within the + metadata form + @param default The default value of the form widget param value + @param is_required A flag indicating whether the form widget param value + is mandatory + @param param_source The default param_source for the form widget param + value (literal, query, eval) + +} { template::element create $form param_type_$order \ -datatype keyword \ @@ -210,26 +229,28 @@ -# @private process_param -# Edits a metadata form widget parameter from the form +ad_proc -private widget::process_param { form order content_type attribute_name } { -# @author Michael Pih + @private process_param -# @param db A database handle -# @param form The name of the form -# @param order The order of placement of the param form widgets within the form -# @param content_type The content type to which the attribute belongs -# @param attribute_name The name of the attribute + Edits a metadata form widget parameter from the form -ad_proc widget::process_param { form order content_type attribute_name } { + @author Michael Pih + + @param db A database handle + @param form The name of the form + @param order The order of placement of the param form widgets within the form + @param content_type The content type to which the attribute belongs + @param attribute_name The name of the attribute + +} { template::form get_values $form \ param_$order param_type_$order \ param_source_$order param_value_$order - set sql - db_dml pp_proces_param " + db_exec_plsql pp_proces_param " begin cm_form_widget.set_attribute_param_value ( content_type => :content_type, @@ -264,16 +285,19 @@ namespace eval cm_widget {} -# @private validate_description -# Make sure that description <= 4000 bytes +ad_proc -private cm_widget::validate_description { value } { -# @author Michael Pih + @private validate_description -# @param value The submitted value of the description form element + Make sure that description <= 4000 bytes -proc cm_widget::validate_description { value } { + @author Michael Pih + @param value The submitted value of the description form element + +} { + set result 1 if { [string bytelength $value] > 4000 } { set result 0 Index: openacs-4/packages/cms/tcl/workflow-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/workflow-procs-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/workflow-procs-postgresql.xql 11 Aug 2001 17:41:34 -0000 1.1 +++ openacs-4/packages/cms/tcl/workflow-procs-postgresql.xql 20 Aug 2001 04:35:42 -0000 1.2 @@ -8,9 +8,9 @@ select transition_name, party_id, - content_item__get_title(i.item_id) title, - to_char(cd.deadline,'Month DD, YYYY') deadline_pretty, - coalesce(party__name(party_id),person__name(party_id)) name + content_item__get_title(i.item_id, 'f') as title, + to_char(cd.deadline,'Month DD, YYYY') as deadline_pretty, + coalesce(party__name(party_id), person__name(party_id)) as name from wf_transitions t, cr_items i, wf_cases c, wf_case_assignments ca, wf_case_deadlines cd @@ -42,10 +42,10 @@ select o.creation_user as admin_id, transition_name, party_id, - content_item__get_title(i.item_id) title, - to_char(deadline,'Month DD, YYYY') deadline_pretty, - coalesce(party__name(party_id),person__name(party_id)) name, - coalesce(party__name(admin_id),person__name(admin_id)) admin_name + content_item__get_title(i.item_id, 'f') as title, + to_char(deadline,'Month DD, YYYY') as deadline_pretty, + coalesce(party__name(party_id),person__name(party_id)) as name, + coalesce(party__name(admin_id),person__name(admin_id)) as admin_name from wf_cases c, wf_case_assignments ca, wf_case_deadlines cd, wf_transitions t, cr_items i, acs_objects o @@ -90,7 +90,7 @@ select transition_name, - content_item__get_title(i.item_id) as title, + content_item__get_title(i.item_id,'f') as title, o.creation_user as admin_id, person__name( o.creation_user ) as admin_name, to_char(current_timestamp,'Mon DD, YYYY') as today Index: openacs-4/packages/cms/tcl/workflow-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/workflow-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/tcl/workflow-procs.tcl 11 Aug 2001 17:40:26 -0000 1.3 +++ openacs-4/packages/cms/tcl/workflow-procs.tcl 20 Aug 2001 04:35:42 -0000 1.4 @@ -4,17 +4,20 @@ namespace eval workflow {} -# @public notify_of_assignments +ad_proc -public workflow::notify_of_assignments { case_id user_id } { -# Emails assigned users of new publishing workflow tasks + @public notify_of_assignments -# @author Michael Pih + Emails assigned users of new publishing workflow tasks -# @param case_id The publishing workflow -# @param user_id The From: user when sending the email + @author Michael Pih -ad_proc workflow::notify_of_assignments { case_id user_id } { + @param db A database handle + @param case_id The publishing workflow + @param user_id The From: user when sending the email +} { + template::query noa_get_assignments assignments multilist " select transition_name, party_id, @@ -60,35 +63,39 @@ This task is due on $deadline_pretty. " - db_exec_plsql " + set request_id [db_exec_plsql notify " begin - :request_id := nt.post_request( + :1 := nt.post_request( party_from => :user_id, party_to => :party_id, expand_group => 'f', subject => :subject, message => :message ); end; - " -bind request_id + "] } } -# @public notify_admin_of_new_tasks +ad_proc -public workflow::notify_admin_of_new_tasks { case_id transition_key } { -# Sends email notification to the creator of an item who has been assigned -# to a specific task (author/edit/approve that item) + @public notify_admin_of_new_tasks -# @author Michael Pih + Sends email notification to the creator of an item who has been assigned + to a specific task (author/edit/approve that item) -# @param case_id The workflow of an item -# @param transition_key The name of the task + @author Michael Pih -ad_proc workflow::notify_admin_of_new_tasks { case_id transition_key } { + @param db A database handle + @param case_id The workflow of an item + @param transition_key The name of the task + +} { + template::query naont_get_assignments assignments multilist " select o.creation_user as admin_id, transition_name, party_id, @@ -140,33 +147,35 @@ This task is due on $deadline_pretty. " - db_exec_plsql " + set request_id [db_exec_plsql notify " begin - request_id := nt.post_request( + :1 := nt.post_request( party_from => -1, party_to => :admin_id, expand_group => 'f', subject => :subject, message => :message ); end; - " -bind request_id + "] } - } +ad_proc -public workflow::notify_admin_of_finished_task { task_id } { -# @public notify_admin_of_finished_tasks + @public notify_admin_of_finished_tasks -# Notify that the admin of when a workflow task has been completed + Notify that the admin of when a workflow task has been completed -# @author Michael Pih + @author Michael Pih -# @param task_id The task + @param db A database handle + @param task_id The task -ad_proc workflow::notify_admin_of_finished_task { task_id } { +} { + # the user who finished the task set user_id [User::getID] template::query naoft_get_name name onevalue " @@ -207,38 +216,38 @@ set message "Dear $admin_name, $name has completed the task: $transition_name of $title on $today." - db_exec_plsql $db " + set request_id [db_exec_plsql notify " begin - :request_id := nt.post_request( + :1 := nt.post_request( party_from => -1, party_to => :admin_id, expand_group => 'f', subject => :subject, message => :message ); end; - " -bind request_id + "] } +ad_proc -public workflow::check_wf_permission { item_id {show_error t}} { + @public check_wf_permission -# @public check_wf_permission + A permission check that Integrates user permissions with workflow tasks -# A permission check that Integrates user permissions with workflow tasks + @author Michael Pih -# @author Michael Pih + @param db A database handle + @param item_id The item on which to check permissions + @param show_error t Flag indicating whether to display an error message + or return t -# @param item_id The item on which to check permissions -# @param show_error t Flag indicating whether to display an error message -# or return t + @return Redirects to an error page if show_error is t. If show_error is f, + then returns t if the current user has permission to access the item, f + if not -# @return Redirects to an error page if show_error is t. If show_error is f, -# then returns t if the current user has permission to access the item, f -# if not - -ad_proc workflow::check_wf_permission { item_id {show_error t}} { - +} { set user_id [User::getID] template::query cwp_touch_info can_touch onevalue " @@ -259,15 +268,15 @@ } } +proc -private workflow::mail_notifications {} { + @private mail_notifications -# @private mail_notifications + Schedules procedure for mailing notifications -# Schedules procedure for mailing notifications + @author Michael Pih -# @author Michael Pih - -proc workflow::mail_notifications {} { +} { ns_log Notice "Running Scheduled Notifications Proc" set mail_server [template::util::get_param mail_server "ns/server/[ns_info server]/cms" OutgoingMailServer] @@ -282,16 +291,13 @@ if { [template::util::is_nil mail_port] } { set mail_port 25 } - - set db [template::begin_db_transaction] - - template::query process_queue dml " - begin - nt.process_queue( :mail_server, :mail_port ); - end; - " - - template::end_db_transaction + db_transaction { + db_exec_plsql process_queue " + begin + nt.process_queue( :mail_server, :mail_port ); + end; + " + } } ns_schedule_proc -thread 300 workflow::mail_notifications