Index: openacs-4/packages/acs-content-repository/acs-content-repository.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/acs-content-repository.info,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/acs-content-repository/acs-content-repository.info 8 Sep 2001 23:38:24 -0000 1.12
+++ openacs-4/packages/acs-content-repository/acs-content-repository.info 17 Sep 2001 05:16:40 -0000 1.13
@@ -82,6 +82,7 @@
+
@@ -93,9 +94,18 @@
+
+
+
+
+
+
+
+
+
@@ -137,9 +147,14 @@
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v
diff -u -r1.25 -r1.26
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 14 Sep 2001 04:53:02 -0000 1.25
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 17 Sep 2001 05:16:40 -0000 1.26
@@ -1275,7 +1275,7 @@
-- show errors
-- prompt *** Preparing search indices...
--- \i content-search.sql
+\i content-search.sql
Index: openacs-4/packages/acs-content-repository/tcl/item-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/item-procs-oracle.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,42 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ select 't' from cr_revisions r, cr_items i
+ where r.revision_id = :revision_id
+ and i.item_id = r.item_id
+ and ((r.content is not null and i.storage_type in ('lob','text')) or
+ (r.filename is not null and i.storage_type = 'file'))
+
+
+
+
+
+
+ select content_item.get_template(:item_id, :context) as template_id
+ from dual
+
+
+
+
+
+
+
+ select content_item.get_path(:item_id) from dual
+
+
+
+
+
+
+
+ select content_item.get_best_revision(:item_id) from dual
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/item-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/item-procs-postgresql.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,43 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select 't' from cr_revisions r, cr_items i
+ where r.revision_id = :revision_id
+ and i.item_id = r.item_id
+ and ((r.content is not null and i.storage_type in ('text','file')) or
+ (r.lob is not null and i.storage_type = 'lob'))
+
+
+
+
+
+
+
+ select content_item__get_template(:item_id, :context) as template_id
+ from dual
+
+
+
+
+
+
+
+ select content_item__get_path(:item_id, null)
+
+
+
+
+
+
+
+ select content_item__get_best_revision(:item_id)
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/item-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/item-procs.tcl 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,280 @@
+namespace eval item {}
+
+
+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]
+}
+
+
+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"
+
+ if { [info exists template_id] } {
+ return $template_id
+ } else {
+ return ""
+ }
+}
+
+
+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] } {
+ return ""
+ }
+
+ return [get_url $template_id]
+}
+
+
+ad_proc -public 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
+ " -cache "item_path $item_id"
+
+ if { [info exists item_path] } {
+ return $item_path
+ } else {
+ return ""
+ }
+}
+
+
+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"
+
+ if { [template::util::is_nil live_revision] } {
+ ns_log notice "WARNING: No live revision for item $item_id"
+ return ""
+ } else {
+ return $live_revision
+ }
+}
+
+
+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
+ from
+ cr_mime_types m, cr_revisions r
+ where
+ r.mime_type = m.mime_type
+ and
+ r.revision_id = :revision_id
+ " -cache "rev_mime_info $revision_id" -uplevel]
+}
+
+
+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
+
+} {
+ 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"
+
+ return $revision_id
+}
+
+
+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] } {
+ ns_log notice "WARNING: No item URL found for content item $item_id"
+ return ""
+ }
+
+ template::util::get_opts $args
+
+ # Get full path
+ set file_url [ns_normalizepath "/$item_url"]
+
+ # Determine file extension
+ if { [info exists opts(template_extension)] } {
+
+ set file_extension "html"
+
+ # Use template mime type
+ set template_id [get_template_id $item_id]
+
+ if { ![template::util::is_nil template_id] } {
+ # Get extension from the template mime type
+ set template_revision_id [get_best_revision $template_id]
+
+ if { ![template::util::is_nil template_revision_id] } {
+ get_mime_info $template_revision_id mime_info
+
+ if { [info exists mime_info] } {
+ set file_extension $mime_info(file_extension)
+ }
+ }
+
+ }
+ } else {
+ # Use item mime type if template extension does not exist
+
+ # Determine live revision, if none specified
+ if { [template::util::is_nil opts(revision_id)] } {
+ set revision_id [get_live_revision $item_id]
+
+ if { [template::util::is_nil revision_id] } {
+ ns_log notice "WARNING: No live revision for content item $item_id"
+ return ""
+ }
+
+ } else {
+ set revision_id $opts(revision_id)
+ }
+
+ get_mime_info $revision_id mime_info
+ set file_extension $mime_info(file_extension)
+ }
+
+ append file_url ".$file_extension"
+
+ return $file_url
+}
Index: openacs-4/packages/acs-content-repository/tcl/item-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/item-procs.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ select live_revision from cr_items
+ where item_id = :item_id
+
+
+
+
+
+
+
+ select
+ m.mime_type, m.file_extension
+ from
+ cr_mime_types m, cr_revisions r
+ where
+ r.mime_type = m.mime_type
+ and
+ r.revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/publish-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/publish-procs-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/publish-procs-oracle.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,62 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+
+ begin
+ content_revision.to_temporary_clob(:revision_id);
+ end;
+
+
+
+
+
+
+
+ select
+ content
+ from
+ cr_content_text
+ where
+ revision_id = :revision_id
+
+
+
+
+
+
+
+ select [ad_decode $storage_type file "'[cr_fs_path]' || filename" content] from cr_revisions where revision_id = $revision_id
+
+
+
+
+
+
+
+
+ begin
+ content_revision.to_temporary_clob(:revision_id);
+ end;
+
+
+
+
+
+
+
+ select
+ content
+ from
+ cr_content_text
+ where
+ revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/publish-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/publish-procs-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/publish-procs-postgresql.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,62 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select 1
+
+
+
+
+
+
+
+ select
+ content
+ from
+ cr_revisions
+ where
+ revision_id = :revision_id
+
+
+
+
+
+
+
+ select case when i.storage_type = 'file'
+ then '[cr_fs_path]' || r.content
+ when i.storage_type = 'lob'
+ then lob::text
+ else r.content end as content, i.storage_type
+ from cr_revisions r, cr_items i
+ where r.item_id = i.item_id and r.revision_id = $revision_id
+
+
+
+
+
+
+
+ select 1
+
+
+
+
+
+
+
+ select
+ content
+ from
+ cr_revisions
+ where
+ revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,1074 @@
+
+namespace eval publish {
+
+ variable item_id_stack
+ variable revision_html
+ namespace eval handle {}
+}
+
+###############################################
+# Procs to maintain the item_id stack
+# main_item_id is always the id at the top of the stack
+
+
+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
+
+ if { [template::util::is_nil item_id] } {
+ error "Null id pushed on stack in publish::push_id"
+ }
+
+ # Determine old configuration
+ set old_item_id ""
+ set old_revision_id ""
+
+ if { [info exists ::content::item_id] } {
+ set old_item_id $::content::item_id
+ }
+
+ if { [info exists ::content::revision_id] } {
+ set old_revision_id $::content::revision_id
+ }
+
+ # Preserve old data
+ if { ![template::util::is_nil old_item_id] } {
+
+ set pair [list $old_item_id $old_revision_id]
+
+ if { ![template::util::is_nil item_id_stack] } {
+ set item_id_stack [concat [list $pair] $item_id_stack]
+ } else {
+ # This is the first id pushed - also clear the cache
+ set item_id_stack [list $pair]
+ array unset revision_html
+ }
+ } else {
+ set item_id_stack [list]
+ }
+
+ # Set new data
+ set ::content::item_id $item_id
+ set ::content::revision_id $revision_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]
+ if { [template::util::is_nil pair] } {
+ #error "Item id stack is empty in publish::pop_id"
+ }
+
+ set item_id_stack [lrange $item_id_stack 1 end]
+
+ # If the stack is now empty, clear the cache
+ if { [template::util::is_nil item_id_stack] } {
+ array unset revision_html
+ }
+
+ set ::content::item_id [lindex $pair 0]
+ set ::content::revision_id [lindex $pair 1]
+
+ return $::content::item_id
+}
+
+
+ad_proc -public 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"] {}]]
+}
+
+##########################################################
+#
+# Procs for handling mime types
+#
+
+
+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
+ upvar $url_ref file_url
+ upvar $revision_id_ref revision_id
+ set error_msg ""
+
+ if { [template::util::is_nil opts(revision_id)] } {
+ set revision_id [item::get_live_revision $item_id]
+ } else {
+ set revision_id $opts(revision_id)
+ }
+
+ # If the embed tag is true, return the html. Otherwise,
+ # just write the image to the filesystem
+ if { [info exists opts(embed)] } {
+
+ set file_url [publish::write_content $revision_id \
+ -item_id $item_id]
+
+ # If write_content aborted, give up
+ if { [template::util::is_nil file_url] } {
+ set error_msg "No URL found for revision $revision_id, item $item_id"
+ return ""
+ }
+
+ # Try to use the registered template for the image
+ if { ![info exists opts(no_merge)] } {
+ set code "publish::merge_with_template $item_id $args"
+ set html [eval $code]
+ # Return the result of merging - could be ""
+ return $html
+ }
+
+ return ""
+
+ } else {
+ set error_msg "No embed specified for handle_binary_file, aborting"
+ return ""
+ }
+
+}
+
+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
+
+} {
+ set extra_html ""
+ if { ![template::util::is_nil argv] } {
+ foreach { name value } $argv {
+ append extra_html "$name=\"$value\" "
+ }
+ }
+
+ return $extra_html
+}
+
+
+ad_proc -public 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]
+ return ""
+}
+
+
+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 \
+ $item_id revision_id url error_msg $args]
+
+ # If an error happened, abort
+ if { ![template::util::is_nil error_msg] } {
+ ns_log notice "WARNING: $error_msg"
+ return ""
+ }
+
+ # Return the HTML if we have any
+ if { ![template::util::is_nil html] } {
+ return $html
+ }
+
+ # If the merging failed, output a straight tag
+ template::query i_get_image_info image_info onerow "
+ select
+ im.width, im.height, r.title as image_alt
+ from
+ images im, cr_revisions r
+ where
+ im.image_id = :revision_id
+ and
+ r.revision_id = :revision_id
+ " -cache "image_info $revision_id"
+
+ template::util::array_to_vars image_info
+
+ # Concatenate all the extra html arguments into a string
+ if { [info exists opts(html)] } {
+ set extra_html [publish::html_args $opts(html)]
+ set have_alt [expr [lsearch [string tolower $opts(html)] "alt"] >= 0]
+ } else {
+ set extra_html ""
+ set have_alt 0
+ }
+
+ set html ""
+
+ return $html
+
+}
+
+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]
+
+ template::util::get_opts $args
+
+ # Either auto-get the live revision or use the parameter
+ if { ![template::util::is_nil opts(revision_id)] } {
+ set revision_id $opts(revision_id)
+ } else {
+ set revision_id [item::get_live_revision $item_id]
+ }
+
+ # Get the template
+ set ::content::template_url [item::get_template_url $item_id]
+
+ if { [string equal $::content::template_url {}] } {
+ ns_log notice "MERGE: No template for item $item_id"
+ return ""
+ }
+
+ ns_log notice "MERGE: Template for item $item_id is $::content::template_url"
+
+ # Get the full path to the template
+ set root_path [content::get_template_root]
+ set file_stub [ns_normalizepath "$root_path/$::content::template_url"]
+
+ # Set the passed-in variables
+ if { ![template::util::is_nil opts(html)] } {
+ set adp_args $opts(html)
+ } else {
+ set adp_args ""
+ }
+
+ # Parse the template and return the result
+ publish::push_id $item_id $revision_id
+ ns_log notice "MERGE: Parsing $file_stub"
+ set html [eval "template::adp_parse \"$file_stub\" \[list $adp_args\]"]
+ publish::pop_id
+
+ return $html
+}
+
+
+
+ad_proc -public 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)] } {
+ set revision_id [item::get_live_revision $item_id]
+ } else {
+ set revision_id $opts(revision_id)
+ }
+
+ if { [info exists opts(embed)] } {
+ # Render the child item and embed it in the code
+ if { ![info exists opts(no_merge)] } {
+ set code "publish::merge_with_template $item_id $args"
+ set html [eval $code]
+ } else {
+
+ db_transaction {
+ db_exec_plsql get_revision_id {
+ begin
+ content_revision.to_temporary_clob(:revision_id);
+ end;
+ }
+
+ # Query for values from a previous revision
+
+ template::query get_previous_content html onevalue "
+ select
+ content
+ from
+ cr_content_text
+ where
+ revision_id = :revision_id"
+
+ }
+ }
+ } else {
+
+ # Just create an include tag
+
+ # Concatenate all the extra html arguments into a string
+ if { [info exists opts(html)] } {
+ set extra_args $opts(html)
+ } else {
+ set extra_args ""
+ }
+
+ set html [publish::item_include_tag $item_id $extra_args]
+ }
+
+ return $html
+}
+
+
+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]
+
+ # Look for the specific handler
+ if { [proc_exists "::publish::handle::${mime_prefix}" $mime_suffix] } {
+ return "::publish::handle::${mime_prefix}::$mime_suffix"
+ }
+
+ # Look for the generic handler
+ if { [proc_exists "::publish::handle" $mime_prefix] } {
+ return "::publish::handle::${mime_prefix}"
+ }
+
+ # Failure
+ return ""
+}
+
+
+ad_proc -private 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 {
+ error "Item id stack is empty"
+ }
+
+ return $ret
+}
+
+
+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]
+ } else {
+ set ret $::content::revision_id
+ }
+
+ return $ret
+}
+
+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
+
+ # Process options
+ if { [template::util::is_nil opts(revision_id)] } {
+ set revision_id [item::get_live_revision $item_id]
+ } else {
+ set revision_id $opts(revision_id)
+ }
+
+ if { [template::util::is_nil revision_id] } {
+ ns_log notice "HANDLER: No live revision for $item_id"
+ return ""
+ }
+
+ if { [template::util::is_nil opts(no_merge)] } {
+ set merge_str "merge"
+ } else {
+ set merge_str "no_merge"
+ }
+
+ # Create a unique key
+ set revision_key "$merge_str $revision_id"
+ if { ![template::util::is_nil opts(html)] } {
+ lappend revision_key $opts(html)
+ }
+
+ # Pull the item out of the cache
+ if { ![info exists opts(refresh)] && \
+ [info exists revision_html($revision_key)] } {
+
+ ns_log notice "HANDLER: Fetching $item_id from cache"
+ return $revision_html($revision_key)
+
+ } else {
+
+ # Render the item and cache it
+ ns_log notice "HANDLER: Rendering item $item_id"
+ item::get_mime_info $revision_id mime_info
+ set item_handler [get_mime_handler $mime_info(mime_type)]
+
+ if { [template::util::is_nil item_handler] } {
+ ns_log notice "HANDLER: No mime handler for mime type $mime_info(mime_type)"
+ return ""
+ }
+
+ # Call the appropriate handler function
+ set code [list $item_handler $item_id]
+ set code [concat $code $args]
+
+ # Pass the revision_id
+ if { ![info exists opts(revision_id)] } {
+ lappend code -revision_id $revision_id
+ }
+
+ set html [eval $code]
+ ns_log notice "HANDLER: Caching html for revision $revision_id"
+ set revision_html($revision_key) $html
+
+ return $html
+ }
+}
+
+
+ad_proc -public 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
+ } else {
+ return $html
+ }
+}
+
+
+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] } {
+ template::query rs_get_subitems subitems onelist "
+ select
+ child_id
+ from
+ cr_child_rels r, cr_items i
+ where
+ r.parent_id = :main_item_id
+ and
+ r.relation_tag = :relation_tag
+ and
+ i.item_id = r.child_id
+ order by
+ order_n" -cache "item_child_items $main_item_id $relation_tag"
+ } else {
+ template::query cs_get_subitems_related subitems onelist "
+ select
+ related_object_id
+ from
+ cr_item_rels r, cr_items i
+ where
+ r.item_id = :main_item_id
+ and
+ r.relation_tag = :relation_tag
+ and
+ i.item_id = r.related_object_id
+ order by
+ r.order_n" -cache "item_related_items $main_item_id $relation_tag"
+ }
+
+ set sub_item_id [lindex $subitems [expr $index - 1]]
+
+ if { [template::util::is_nil sub_item_id] } {
+ ns_log notice "publish::render_subitem: No such subitem"
+ return ""
+ }
+
+ # Call the appropriate handler function
+ set code [list handle_item $sub_item_id -html $extra_args]
+
+ if { [string equal $is_embed t] } {
+ lappend code -embed
+ }
+
+ return [get_html_body [eval $code]]
+}
+
+#######################################################
+#
+# The content tags
+
+
+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]
+ set value [ns_set value $params $i]
+ if { [lsearch $exclusion_list $key] == -1 } {
+ lappend extra_args $key $value
+ }
+ }
+
+ return $extra_args
+}
+
+
+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]
+ if { $embed != -1 } { set embed t } else { set embed f }
+ set parent_item_id [ns_set iget $params parent_item_id]
+
+ # Concatenate all other keys into the extra arguments list
+ set extra_args [publish::set_to_pairs $params \
+ {tag index embed parent_item_id}]
+
+ # Render the item, append it to the page
+ # set item_id [publish::get_main_item_id]
+
+ set command "publish::render_subitem"
+ append command \
+ " \[template::util::nvl \"$parent_item_id\" \$::content::item_id\]"
+ append command " $relation_type $tag $index $embed"
+ append command " \{$extra_args\}"
+
+ template::adp_append_code "append __adp_output \[$command\]"
+}
+
+
+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 {
+ # set paths [get_publish_roots]
+ set paths "./"
+ }
+
+ upvar filename filename
+ upvar current_page_root current_page_root
+
+ foreach root_path $paths {
+ set current_page_root $root_path
+ set filename [ns_normalizepath "/$root_path/$url"]
+ uplevel $code
+ }
+}
+
+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_1row get_storage_type "
+ select storage_type
+ from cr_items
+ where item_id = (select item_id
+ from cr_revisions
+ where revision_id = :revision_id)"
+
+ db_blob_get_file wmb_get_blob_file "
+ select content from cr_revisions where revision_id = $revision_id
+ " -file $filename
+
+ ns_chmod $filename 0764
+ ns_log notice "PUBLISH: Wrote revision $revision_id to $filename"
+ } $root_path
+}
+
+
+ad_proc -private 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
+ ns_chmod $filename 0764
+ ns_log notice "PUBLISH: Wrote text to $filename"
+ } $root_path
+}
+
+
+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)] } {
+ set root_path ""
+ } else {
+ set root_path $opts(root_path)
+ }
+
+ db_transaction {
+
+ # Get the item id if none specified
+ if { [template::util::is_nil opts(item_id)] } {
+ template::query get_one_revision item_id onevalue "
+ select item_id from cr_revisions where revision_id = :revision_id
+ " -cache "item_from_revision $revision_id"
+
+ if { [template::util::is_nil item_id] } {
+ ns_log notice \
+ "WARNING: publish::write_content: No such revision $revision_id"
+ return ""
+ }
+ } else {
+ set item_id $opts(item_id)
+ }
+
+
+ set file_url [item::get_extended_url $item_id -revision_id $revision_id]
+
+ # Write blob/text to file
+ ns_log notice "Writing item $item_id to $file_url"
+
+ if { [info exists opts(text)] } {
+ db_transaction {
+ db_exec_plsql gcv_get_revision_id {
+ begin
+ content_revision.to_temporary_clob(:revision_id);
+ end;
+ }
+
+ # Query for values from a previous revision
+
+ template::query gcv_get_previous_content text onevalue "
+ select
+ content
+ from
+ cr_content_text
+ where
+ revision_id = :revision_id"
+ }
+
+ write_multiple_files $file_url $text $root_path
+ } else {
+
+ # Determine if the blob is null. If it is, give up (or else the
+ # ns_ora blob_get_file will crash).
+ if { [item::content_is_null $revision_id] } {
+ ns_log notice \
+ "WARNING: publish::write_content: No content supplied for revision $revision_id"
+ return ""
+ }
+
+ # Write the blob
+ write_multiple_blobs $file_url $revision_id $root_path
+ }
+ }
+
+ # Return either the full path or the relative URL
+ return $file_url
+}
+
+
Index: openacs-4/packages/acs-content-repository/tcl/publish-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/publish-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/publish-procs.xql 17 Sep 2001 05:16:40 -0000 1.1
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+ select
+ im.width, im.height, r.title as image_alt
+ from
+ images im, cr_revisions r
+ where
+ im.image_id = :revision_id
+ and
+ r.revision_id = :revision_id
+
+
+
+
+
+
+
+ select
+ child_id
+ from
+ cr_child_rels r, cr_items i
+ where
+ r.parent_id = :main_item_id
+ and
+ r.relation_tag = :relation_tag
+ and
+ i.item_id = r.child_id
+ order by
+ order_n
+
+
+
+
+
+
+
+ select
+ related_object_id
+ from
+ cr_item_rels r, cr_items i
+ where
+ r.item_id = :main_item_id
+ and
+ r.relation_tag = :relation_tag
+ and
+ i.item_id = r.related_object_id
+ order by
+ r.order_n
+
+
+
+
+
+
+
+ select storage_type
+ from cr_items
+ where item_id = (select item_id
+ from cr_revisions
+ where revision_id = :revision_id)
+
+
+
+
+
+
+
+
+ select item_id from cr_revisions where revision_id = :revision_id
+
+
+
+
+
+
Index: openacs-4/packages/acs-content-repository/tcl/search-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/search-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/acs-content-repository/tcl/search-procs.tcl 14 Sep 2001 04:53:02 -0000 1.5
+++ openacs-4/packages/acs-content-repository/tcl/search-procs.tcl 17 Sep 2001 05:16:40 -0000 1.6
@@ -6,32 +6,21 @@
} {
db_0or1row revisions_datasource {
select r.revision_id as object_id,
- r.title as title,
- r.content as content,
- r.lob as lob,
+ r.title,
+ case i.storage_type
+ when 'lob' then r.lob::text
+ when 'file' then '[cr_fs_path]' || r.content
+ when 'text' then r.content
+ else r.content
+ end as content,
r.mime_type as mime,
'' as keywords,
- i.storage_type as storage
+ i.storage_type
from cr_revisions r, cr_items i
where revision_id = :object_id
and i.item_id = r.item_id
} -column_array datasource
- switch $datasource(storage) {
- lob {
- db_with_handle db {
- set datasource(content) [ns_pg blob_get $db $datasource(lob)]
- }
- }
-
- file {
- set fh [open [cr_fs_path]/$content r]
- fconfigure $fh -translation binary
- set datasource(content) [read $fh]
- close $fh
- }
- }
-
return [array get datasource]
}
@@ -66,13 +55,12 @@
select r.revision_id as object_id,
r.title as title,
r.description as content,
- r.lob as lob,
r.mime_type as mime,
'' as keywords,
- i.storage_type as storage
- from cr_revisions r, cr_items i
+ 'text' as storage_type
+ from cr_revisions r
where revision_id = :object_id
- and i.item_id = r.item_id
+
} -column_array datasource
return [array get datasource]
@@ -109,31 +97,20 @@
db_0or1row revisions_datasource {
select r.revision_id as object_id,
r.title as title,
- r.content as content,
- r.lob as lob,
+ case i.storage_type
+ when 'lob' then r.lob::text
+ when 'file' then '[cr_fs_path]' || r.content
+ when 'text' then r.content
+ else r.content
+ end as content,
r.mime_type as mime,
'' as keywords,
- i.storage_type as storage
+ i.storage_type
from cr_revisions r, cr_items i
where revision_id = :object_id
and i.item_id = r.item_id
} -column_array datasource
- switch $datasource(storage) {
- lob {
- db_with_handle db {
- set datasource(content) [ns_pg blob_get $db $datasource(lob)]
- }
- }
-
- file {
- set fh [open [cr_fs_path]/$content r]
- fconfigure $fh -translation binary
- set datasource(content) [read $fh]
- close $fh
- }
- }
-
return [array get datasource]
}
Index: openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl 13 Sep 2001 04:59:26 -0000 1.2
+++ openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl 17 Sep 2001 05:16:40 -0000 1.3
@@ -134,6 +134,7 @@
set docblock [join $docblock "\n\r"]
set arguments [join $arguments]
+ ns_log Notice "sc_proc: $proc_name, $arguments"
ad_proc $proc_name $arguments $docblock $body
}
Index: openacs-4/packages/acs-templating/tcl/tag-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/tag-init.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-templating/tcl/tag-init.tcl 13 Mar 2001 22:59:27 -0000 1.1
+++ openacs-4/packages/acs-templating/tcl/tag-init.tcl 17 Sep 2001 05:16:40 -0000 1.2
@@ -406,3 +406,66 @@
template::adp_append_string ""
}
+
+
+# @private tag_child
+#
+# Implements the child tag which renders a child item.
+# See the Developer Guide for more information.
+# The child tag format is
+#
+# <child tag=tag index=n embed args>
+#
+#
+# @param params The ns_set id for extra HTML parameters
+
+template_tag child { params } {
+ publish::process_tag child $params
+}
+
+# @private tag_relation
+#
+# Implements the relation tag which renders a related item.
+# See the Developer Guide for more information.
+# The relation tag format is
+#
+# <relation tag=tag index=n embed args>
+#
+#
+# @param params The ns_set id for extra HTML parameters
+
+template_tag relation { params } {
+ publish::process_tag relation $params
+}
+
+
+# @private tag_content
+#
+# Implements the content tag which renders the content
+# of the current item.
+# See the Developer Guide for more information.
+# The content tag format is simply <content>. The
+# embed and no_merge parameters are implicit to
+# the tag.
+#
+# @param params The ns_set id for extra HTML parameters
+
+template_tag content { params } {
+
+ # Get item id/revision_id
+ set item_id [publish::get_main_item_id]
+ set revision_id [publish::get_main_revision_id]
+
+ # Concatenate all other keys into the extra arguments list
+ set extra_args [publish::set_to_pairs $params]
+
+ # Add code to flush the cache
+
+ # Render the item, return the html
+ set command "publish::get_html_body \[publish::handle_item"
+ append command " \$::content::item_id"
+ append command " -html \{$extra_args\} -no_merge -embed"
+ append command " -revision_id \[publish::get_main_revision_id\]\]"
+
+ template::adp_append_code "append __adp_output \[$command\]"
+}
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 -r1.3 -r1.4
--- openacs-4/packages/cms/tcl/item-procs-oracle.xql 2 Sep 2001 14:24:58 -0000 1.3
+++ openacs-4/packages/cms/tcl/item-procs-oracle.xql 17 Sep 2001 05:16:40 -0000 1.4
@@ -2,48 +2,7 @@
oracle8.1.6
-
-
-
-
-
- select 't' from cr_revisions r, cr_items i
- where r.revision_id = :revision_id
- and i.item_id = r.item_id
- and ((r.content is not null and i.storage_type in ('lob','text')) or
- (r.filename is not null and i.storage_type = 'file'))
-
-
-
-
-
-
-
- select content_item.get_best_revision(:item_id) from dual
-
-
-
-
-
-
-
-
- select content_item.get_path(:item_id) from dual
-
-
-
-
-
-
-
-
- select content_item.get_template(:item_id, :context) as template_id
- 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 -r1.5 -r1.6
--- openacs-4/packages/cms/tcl/item-procs-postgresql.xql 2 Sep 2001 14:24:58 -0000 1.5
+++ openacs-4/packages/cms/tcl/item-procs-postgresql.xql 17 Sep 2001 05:16:40 -0000 1.6
@@ -3,33 +3,6 @@
postgresql7.1
-
-
-
- select content_item__get_best_revision(:item_id)
-
-
-
-
-
-
-
-
- select content_item__get_path(:item_id, null)
-
-
-
-
-
-
-
-
- select content_item__get_template(:item_id, :context) as template_id
-
-
-
-
-
@@ -63,16 +36,4 @@
-
-
-
- select 't' from cr_revisions r, cr_items i
- where r.revision_id = :revision_id
- and i.item_id = r.item_id
- and ((r.content is not null and i.storage_type in ('text','file')) or
- (r.lob is not null and i.storage_type = 'lob'))
-
-
-
-
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 -r1.5 -r1.6
--- openacs-4/packages/cms/tcl/item-procs.tcl 20 Aug 2001 04:35:41 -0000 1.5
+++ openacs-4/packages/cms/tcl/item-procs.tcl 17 Sep 2001 05:16:40 -0000 1.6
@@ -42,30 +42,6 @@
}
-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
-
-} {
- 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"
-
- return $revision_id
-}
-
-
ad_proc -public item::get_item_from_revision { revision_id } {
@public get_item_from_revision
@@ -86,33 +62,6 @@
}
-ad_proc -public 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
- " -cache "item_path $item_id"
-
- if { [info exists item_path] } {
- return $item_path
- } else {
- return ""
- }
-}
-
-
ad_proc -public item::get_id { url {root_folder ""}} {
@public get_id
@@ -152,37 +101,8 @@
}
-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
- from
- cr_mime_types m, cr_revisions r
- where
- r.mime_type = m.mime_type
- and
- r.revision_id = :revision_id
- " -cache "rev_mime_info $revision_id" -uplevel]
-}
-
-
ad_proc -public item::get_content_type { item_id } {
@public get_content_type
@@ -210,174 +130,6 @@
}
-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] } {
- ns_log notice "WARNING: No item URL found for content item $item_id"
- return ""
- }
-
- template::util::get_opts $args
-
- # Get full path
- set file_url [ns_normalizepath "/$item_url"]
-
- # Determine file extension
- if { [info exists opts(template_extension)] } {
-
- set file_extension "html"
-
- # Use template mime type
- set template_id [get_template_id $item_id]
-
- if { ![template::util::is_nil template_id] } {
- # Get extension from the template mime type
- set template_revision_id [get_best_revision $template_id]
-
- if { ![template::util::is_nil template_revision_id] } {
- get_mime_info $template_revision_id mime_info
-
- if { [info exists mime_info] } {
- set file_extension $mime_info(file_extension)
- }
- }
-
- }
- } else {
- # Use item mime type if template extension does not exist
-
- # Determine live revision, if none specified
- if { [template::util::is_nil opts(revision_id)] } {
- set revision_id [get_live_revision $item_id]
-
- if { [template::util::is_nil revision_id] } {
- ns_log notice "WARNING: No live revision for content item $item_id"
- return ""
- }
-
- } else {
- set revision_id $opts(revision_id)
- }
-
- get_mime_info $revision_id mime_info
- set file_extension $mime_info(file_extension)
- }
-
- append file_url ".$file_extension"
-
- return $file_url
-}
-
-
-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"
-
- if { [info exists template_id] } {
- return $template_id
- } else {
- return ""
- }
-}
-
-
-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] } {
- return ""
- }
-
- return [get_url $template_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]
-}
-
-
ad_proc -public item::content_methods_by_type { content_type args } {
@public content_methods_by_type
Index: openacs-4/packages/cms/tcl/item-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/item-procs.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/cms/tcl/item-procs.xql 2 Sep 2001 14:24:58 -0000 1.2
+++ openacs-4/packages/cms/tcl/item-procs.xql 17 Sep 2001 05:16:40 -0000 1.3
@@ -1,15 +1,6 @@
-
-
-
- select live_revision from cr_items
- where item_id = :item_id
-
-
-
-
@@ -18,23 +9,6 @@
-
-
-
-
- select
- m.mime_type, m.file_extension
- from
- cr_mime_types m, cr_revisions r
- where
- r.mime_type = m.mime_type
- and
- r.revision_id = :revision_id
-
-
-
-
-
Index: openacs-4/packages/cms/tcl/publish-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/publish-procs-oracle.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/cms/tcl/publish-procs-oracle.xql 2 Sep 2001 14:24:58 -0000 1.2
+++ openacs-4/packages/cms/tcl/publish-procs-oracle.xql 17 Sep 2001 05:16:40 -0000 1.3
@@ -2,15 +2,6 @@
oracle8.1.6
-
-
-
-
- select [ad_decode $storage_type file "'[cr_fs_path]' || filename" content] from cr_revisions where revision_id = $revision_id
-
-
-
-
Index: openacs-4/packages/cms/tcl/publish-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/publish-procs-postgresql.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/cms/tcl/publish-procs-postgresql.xql 30 Aug 2001 01:46:05 -0000 1.3
+++ openacs-4/packages/cms/tcl/publish-procs-postgresql.xql 17 Sep 2001 05:16:40 -0000 1.4
@@ -3,20 +3,7 @@
postgresql7.1
-
-
- select case when i.storage_type = 'file'
- then '[cr_fs_path]' || r.content
- when i.storage_type = 'lob'
- then lob::text
- else r.content end as content, i.storage_type
- from cr_revisions r, cr_items i
- where r.item_id = i.item_id and r.revision_id = $revision_id
-
-
-
-
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 -r1.5 -r1.6
--- openacs-4/packages/cms/tcl/publish-procs.tcl 2 Sep 2001 14:24:58 -0000 1.5
+++ openacs-4/packages/cms/tcl/publish-procs.tcl 17 Sep 2001 05:16:40 -0000 1.6
@@ -13,166 +13,13 @@
# @see namespace item item.html
namespace eval publish {
- variable item_id_stack
-
- variable revision_html
- namespace eval handle {
- namespace eval text {}
- namespace eval program {}
- namespace eval image {}
- }
+ variable item_id_stack
+ variable revision_html
}
-###############################################
-# Procs to maintain the item_id stack
-# main_item_id is always the id at the top of the stack
-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
-
- if { [template::util::is_nil item_id] } {
- error "Null id pushed on stack in publish::push_id"
- }
-
- # Determine old configuration
- set old_item_id ""
- set old_revision_id ""
-
- if { [info exists ::content::item_id] } {
- set old_item_id $::content::item_id
- }
-
- if { [info exists ::content::revision_id] } {
- set old_revision_id $::content::revision_id
- }
-
- # Preserve old data
- if { ![template::util::is_nil old_item_id] } {
-
- set pair [list $old_item_id $old_revision_id]
-
- if { ![template::util::is_nil item_id_stack] } {
- set item_id_stack [concat [list $pair] $item_id_stack]
- } else {
- # This is the first id pushed - also clear the cache
- set item_id_stack [list $pair]
- array unset revision_html
- }
- } else {
- set item_id_stack [list]
- }
-
- # Set new data
- set ::content::item_id $item_id
- set ::content::revision_id $revision_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]
- if { [template::util::is_nil pair] } {
- #error "Item id stack is empty in publish::pop_id"
- }
-
- set item_id_stack [lrange $item_id_stack 1 end]
-
- # If the stack is now empty, clear the cache
- if { [template::util::is_nil item_id_stack] } {
- array unset revision_html
- }
-
- set ::content::item_id [lindex $pair 0]
- set ::content::revision_id [lindex $pair 1]
-
- return $::content::item_id
-}
-
-ad_proc -private 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 {
- error "Item id stack is empty"
- }
-
- return $ret
-}
-
-
-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]
- } else {
- set ret $::content::revision_id
- }
-
- return $ret
-}
-
###################################################
#
# Publish procs
@@ -292,97 +139,7 @@
}
-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 {
- set paths [get_publish_roots]
- }
-
- upvar filename filename
- upvar current_page_root current_page_root
-
- foreach root_path $paths {
- set current_page_root $root_path
- set filename [ns_normalizepath "/$root_path/$url"]
- uplevel $code
- }
-}
-
-
-ad_proc -private 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
- ns_chmod $filename 0764
- ns_log notice "PUBLISH: Wrote text to $filename"
- } $root_path
-}
-
-
-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_1row get_storage_type "
- select storage_type
- from cr_items
- where item_id = (select item_id
- from cr_revisions
- where revision_id = :revision_id)"
-
- db_blob_get_file wmb_get_blob_file "
- select content from cr_revisions where revision_id = $revision_id
- " -file $filename
-
- ns_chmod $filename 0764
- ns_log notice "PUBLISH: Wrote revision $revision_id to $filename"
- } $root_path
-}
-
ad_proc -private publish::delete_multiple_files { url {root_path ""}} {
@private delete_multiple_files
@@ -403,394 +160,6 @@
}
-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)] } {
- set root_path ""
- } else {
- set root_path $opts(root_path)
- }
-
- db_transaction {
-
- # Get the item id if none specified
- if { [template::util::is_nil opts(item_id)] } {
- set item_id [content_item::get_item_from_revision $revision_id]
-
- if { [template::util::is_nil item_id] } {
- ns_log notice \
- "WARNING: publish::write_content: No such revision $revision_id"
- return ""
- }
- } else {
- set item_id $opts(item_id)
- }
-
-
- set file_url [item::get_extended_url $item_id -revision_id $revision_id]
-
- # Write blob/text to file
- ns_log notice "Writing item $item_id to $file_url"
-
- if { [info exists opts(text)] } {
- set text [content::get_content_value $revision_id]
- write_multiple_files $file_url $text $root_path
- } else {
-
- # Determine if the blob is null. If it is, give up (or else the
- # ns_ora blob_get_file will crash).
- if { [item::content_is_null $revision_id] } {
- ns_log notice \
- "WARNING: publish::write_content: No content supplied for revision $revision_id"
- return ""
- }
-
- # Write the blob
- write_multiple_blobs $file_url $revision_id $root_path
- }
- }
-
- # Return either the full path or the relative URL
- return $file_url
-}
-
-
-ad_proc -public 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
- } else {
- return $html
- }
-}
-
-
-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] } {
- template::query rs_get_subitems subitems onelist "
- select
- child_id
- from
- cr_child_rels r, cr_items i
- where
- r.parent_id = :main_item_id
- and
- r.relation_tag = :relation_tag
- and
- i.item_id = r.child_id
- order by
- order_n" -cache "item_child_items $main_item_id $relation_tag"
- } else {
- template::query cs_get_subitems_related subitems onelist "
- select
- related_object_id
- from
- cr_item_rels r, cr_items i
- where
- r.item_id = :main_item_id
- and
- r.relation_tag = :relation_tag
- and
- i.item_id = r.related_object_id
- order by
- r.order_n" -cache "item_related_items $main_item_id $relation_tag"
- }
-
- set sub_item_id [lindex $subitems [expr $index - 1]]
-
- if { [template::util::is_nil sub_item_id] } {
- ns_log notice "publish::render_subitem: No such subitem"
- return ""
- }
-
- # Call the appropriate handler function
- set code [list handle_item $sub_item_id -html $extra_args]
-
- if { [string equal $is_embed t] } {
- lappend code -embed
- }
-
- return [get_html_body [eval $code]]
-}
-
-
-ad_proc -public 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"] {}]]
-}
-
-
-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]
-
- # Look for the specific handler
- if { [proc_exists "::publish::handle::${mime_prefix}" $mime_suffix] } {
- return "::publish::handle::${mime_prefix}::$mime_suffix"
- }
-
- # Look for the generic handler
- if { [proc_exists "::publish::handle" $mime_prefix] } {
- return "::publish::handle::${mime_prefix}"
- }
-
- # Failure
- return ""
-}
-
-
-
-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
-
- # Process options
- if { [template::util::is_nil opts(revision_id)] } {
- set revision_id [item::get_live_revision $item_id]
- } else {
- set revision_id $opts(revision_id)
- }
-
- if { [template::util::is_nil revision_id] } {
- ns_log notice "HANDLER: No live revision for $item_id"
- return ""
- }
-
- if { [template::util::is_nil opts(no_merge)] } {
- set merge_str "merge"
- } else {
- set merge_str "no_merge"
- }
-
- # Create a unique key
- set revision_key "$merge_str $revision_id"
- if { ![template::util::is_nil opts(html)] } {
- lappend revision_key $opts(html)
- }
-
- # Pull the item out of the cache
- if { ![info exists opts(refresh)] && \
- [info exists revision_html($revision_key)] } {
-
- ns_log notice "HANDLER: Fetching $item_id from cache"
- return $revision_html($revision_key)
-
- } else {
-
- # Render the item and cache it
- ns_log notice "HANDLER: Rendering item $item_id"
- item::get_mime_info $revision_id mime_info
- set item_handler [get_mime_handler $mime_info(mime_type)]
-
- if { [template::util::is_nil item_handler] } {
- ns_log notice "HANDLER: No mime handler for mime type $mime_info(mime_type)"
- return ""
- }
-
- # Call the appropriate handler function
- set code [list $item_handler $item_id]
- set code [concat $code $args]
-
- # Pass the revision_id
- if { ![info exists opts(revision_id)] } {
- lappend code -revision_id $revision_id
- }
-
- set html [eval $code]
- ns_log notice "HANDLER: Caching html for revision $revision_id"
- set revision_html($revision_key) $html
-
- return $html
- }
-}
-
-
-
ad_proc -public publish::publish_revision { revision_id args} {
@public publish_revision
@@ -897,469 +266,11 @@
}
-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]
- template::util::get_opts $args
- # Either auto-get the live revision or use the parameter
- if { ![template::util::is_nil opts(revision_id)] } {
- set revision_id $opts(revision_id)
- } else {
- set revision_id [item::get_live_revision $item_id]
- }
- # Get the template
- set ::content::template_url [item::get_template_url $item_id]
-
- if { [string equal $::content::template_url {}] } {
- ns_log notice "MERGE: No template for item $item_id"
- return ""
- }
-
- ns_log notice "MERGE: Template for item $item_id is $::content::template_url"
-
- # Get the full path to the template
- set root_path [content::get_template_root]
- set file_stub [ns_normalizepath "$root_path/$::content::template_url"]
-
- # Set the passed-in variables
- if { ![template::util::is_nil opts(html)] } {
- set adp_args $opts(html)
- } else {
- set adp_args ""
- }
-
- # Parse the template and return the result
- publish::push_id $item_id $revision_id
- ns_log notice "MERGE: Parsing $file_stub"
- set html [eval "template::adp_parse \"$file_stub\" \[list $adp_args\]"]
- publish::pop_id
-
- return $html
-}
-
-
-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]
- set value [ns_set value $params $i]
- if { [lsearch $exclusion_list $key] == -1 } {
- lappend extra_args $key $value
- }
- }
-
- return $extra_args
-}
-
-#######################################################
-#
-# The content tags
-
-
-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]
- if { $embed != -1 } { set embed t } else { set embed f }
- set parent_item_id [ns_set iget $params parent_item_id]
-
- # Concatenate all other keys into the extra arguments list
- set extra_args [publish::set_to_pairs $params \
- {tag index embed parent_item_id}]
-
- # Render the item, append it to the page
- # set item_id [publish::get_main_item_id]
-
- set command "publish::render_subitem"
- append command \
- " \[template::util::nvl \"$parent_item_id\" \$::content::item_id\]"
- append command " $relation_type $tag $index $embed"
- append command " \{$extra_args\}"
-
- template::adp_append_code "append __adp_output \[$command\]"
-}
-
-# @private tag_child
-#
-# Implements the child tag which renders a child item.
-# See the Developer Guide for more information.
-# The child tag format is
-#
-# <child tag=tag index=n embed args>
-#
-#
-# @param params The ns_set id for extra HTML parameters
-
-template_tag child { params } {
- publish::process_tag child $params
-}
-
-# @private tag_relation
-#
-# Implements the relation tag which renders a related item.
-# See the Developer Guide for more information.
-# The relation tag format is
-#
-# <relation tag=tag index=n embed args>
-#
-#
-# @param params The ns_set id for extra HTML parameters
-
-template_tag relation { params } {
- publish::process_tag relation $params
-}
-
-
-# @private tag_content
-#
-# Implements the content tag which renders the content
-# of the current item.
-# See the Developer Guide for more information.
-# The content tag format is simply <content>. The
-# embed and no_merge parameters are implicit to
-# the tag.
-#
-# @param params The ns_set id for extra HTML parameters
-
-template_tag content { params } {
-
- # Get item id/revision_id
- set item_id [publish::get_main_item_id]
- set revision_id [publish::get_main_revision_id]
-
- # Concatenate all other keys into the extra arguments list
- set extra_args [publish::set_to_pairs $params]
-
- # Add code to flush the cache
-
- # Render the item, return the html
- set command "publish::get_html_body \[publish::handle_item"
- append command " \$::content::item_id"
- append command " -html \{$extra_args\} -no_merge -embed"
- append command " -revision_id \[publish::get_main_revision_id\]\]"
-
- 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
-
-} {
- set extra_html ""
- if { ![template::util::is_nil argv] } {
- foreach { name value } $argv {
- append extra_html "$name=\"$value\" "
- }
- }
-
- return $extra_html
-}
-
-ad_proc -public 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]
- return ""
-}
-
-##########################################################
-#
-# Procs for handling mime types
-#
-
-
-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
- upvar $url_ref file_url
- upvar $revision_id_ref revision_id
- set error_msg ""
-
- if { [template::util::is_nil opts(revision_id)] } {
- set revision_id [item::get_live_revision $item_id]
- } else {
- set revision_id $opts(revision_id)
- }
-
- # If the embed tag is true, return the html. Otherwise,
- # just write the image to the filesystem
- if { [info exists opts(embed)] } {
-
- set file_url [publish::write_content $revision_id \
- -item_id $item_id]
-
- # If write_content aborted, give up
- if { [template::util::is_nil file_url] } {
- set error_msg "No URL found for revision $revision_id, item $item_id"
- return ""
- }
-
- # Try to use the registered template for the image
- if { ![info exists opts(no_merge)] } {
- set code "publish::merge_with_template $item_id $args"
- set html [eval $code]
- # Return the result of merging - could be ""
- return $html
- }
-
- return ""
-
- } else {
- set error_msg "No embed specified for handle_binary_file, aborting"
- return ""
- }
-
-}
-
-
-
-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 \
- $item_id revision_id url error_msg $args]
-
- # If an error happened, abort
- if { ![template::util::is_nil error_msg] } {
- ns_log notice "WARNING: $error_msg"
- return ""
- }
-
- # Return the HTML if we have any
- if { ![template::util::is_nil html] } {
- return $html
- }
-
- # If the merging failed, output a straight tag
- template::query i_get_image_info image_info onerow "
- select
- im.width, im.height, r.title as image_alt
- from
- images im, cr_revisions r
- where
- im.image_id = :revision_id
- and
- r.revision_id = :revision_id
- " -cache "image_info $revision_id"
-
- template::util::array_to_vars image_info
-
- # Concatenate all the extra html arguments into a string
- if { [info exists opts(html)] } {
- set extra_html [publish::html_args $opts(html)]
- set have_alt [expr [lsearch [string tolower $opts(html)] "alt"] >= 0]
- } else {
- set extra_html ""
- set have_alt 0
- }
-
- set html ""
-
- return $html
-
-}
-
-ad_proc -public 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)] } {
- set revision_id [item::get_live_revision $item_id]
- } else {
- set revision_id $opts(revision_id)
- }
-
- if { [info exists opts(embed)] } {
- # Render the child item and embed it in the code
- if { ![info exists opts(no_merge)] } {
- set code "publish::merge_with_template $item_id $args"
- set html [eval $code]
- } else {
- set html [content::get_content_value $revision_id]
- }
- } else {
-
- # Just create an include tag
-
- # Concatenate all the extra html arguments into a string
- if { [info exists opts(html)] } {
- set extra_args $opts(html)
- } else {
- set extra_args ""
- }
-
- set html [publish::item_include_tag $item_id $extra_args]
- }
-
- return $html
-}
-
-
###########################################################
#
# Scheduled proc stuff
Index: openacs-4/packages/cms/tcl/publish-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/publish-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cms/tcl/publish-procs.xql 11 Aug 2001 17:41:34 -0000 1.1
+++ openacs-4/packages/cms/tcl/publish-procs.xql 17 Sep 2001 05:16:40 -0000 1.2
@@ -9,58 +9,4 @@
-
-
-
- select
- child_id
- from
- cr_child_rels r, cr_items i
- where
- r.parent_id = :main_item_id
- and
- r.relation_tag = :relation_tag
- and
- i.item_id = r.child_id
- order by
- order_n
-
-
-
-
-
-
-
- select
- related_object_id
- from
- cr_item_rels r, cr_items i
- where
- r.item_id = :main_item_id
- and
- r.relation_tag = :relation_tag
- and
- i.item_id = r.related_object_id
- order by
- r.order_n
-
-
-
-
-
-
-
- select
- im.width, im.height, r.title as image_alt
- from
- images im, cr_revisions r
- where
- im.image_id = :revision_id
- and
- r.revision_id = :revision_id
-
-
-
-
-
Index: openacs-4/packages/search/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/search/www/search.tcl 15 Sep 2001 23:23:52 -0000 1.4
+++ openacs-4/packages/search/www/search.tcl 17 Sep 2001 05:16:40 -0000 1.5
@@ -13,6 +13,8 @@
q:notnull {You must specify some keywords.}
}
+ns_log Notice "args = [info args AcsSc.FtsEngineDriver.search.openfts-driver]"
+ns_log Notice "args = [info args openfts_driver__search]"
ns_startcontent -type "text/html"
set this_dir [file dirname [ad_conn file]]
set template_top_file "$this_dir/search-results-top"