Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 10 Jan 2007 21:22:03 -0000 1.18
+++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 12 Apr 2007 11:52:35 -0000 1.19
@@ -153,7 +153,10 @@
@author Dave Bauer (dave@thedesignexperience.org)
@creation-date 2004-05-28
- Delete a content item
+ Delete a content item from the database. If the content item
+ to delete has children content items referencing its parent
+ via acs_objects.context_id then this proc will fail.
+
@param item_id
} {
return [package_exec_plsql \
@@ -294,7 +297,7 @@
Retrieves the content type of the item. If the item does not exist,
returns an empty string.
- @param item_id The item id
+ @param item_id The item_id of the content item
@return The content type of the item, or an empty string if no such
item exists
@@ -305,25 +308,19 @@
}
-ad_proc -public content::item::get_best_revision {
- -item_id:required
-} {
- @param item_id
- @return NUMBER(38)
-} {
- return [package_exec_plsql -var_list [list \
- [list item_id $item_id ] \
- ] content_item get_best_revision]
-}
ad_proc -public content::item::get_content_type {
-item_id:required
} {
- @param item_id
+ Retrieves the content type of the item. If the item does not exist,
+ returns an empty string.
- @return VARCHAR2(100)
+ @param item_id The item_id of the content item
+
+ @return The content type of the item, or an empty string if no such
+ item exists
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -349,11 +346,14 @@
{-root_folder_id ""}
{-resolve_index ""}
} {
- @param item_path
- @param root_folder_id
- @param resolve_index
+ Looks up the item_path starting with the root folder and returns item_id for that
+ content item or empty, if none exists
- @return NUMBER(38)
+ @param item_path
+ @param root_folder_id
+ @param resolve_index
+
+ @return The item_id of the found item, or the empty string on failure
} {
return [package_exec_plsql -var_list [list \
[list item_path $item_path ] \
@@ -362,13 +362,41 @@
] content_item get_id]
}
+ad_proc -public content::item::get_best_revision {
+ -item_id:required
+} {
+ 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 of the content item
+
+ @return The best revision_id for the item, or an empty string if no
+ revisions exist
+
+ @see content::revision::item_id
+ @see content::item::get_live_revision
+ @see content::item::get_latest_revision
+} {
+ return [package_exec_plsql -var_list [list \
+ [list item_id $item_id ] \
+ ] content_item get_best_revision]
+}
+
ad_proc -public content::item::get_latest_revision {
-item_id:required
} {
- @param item_id
+ Retrieves the latest revision for the item. If the item has no live
+ revision, returns an empty string.
+
+ @param item_id The item_id of the content item
+
+ @return The latest revision_id for the item, or an empty string if no
+ revisions exist
- @return NUMBER(38)
+ @see content::revision::item_id
+ @see content::item::get_best_revision
+ @see content::item::get_live_revision
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -379,9 +407,17 @@
ad_proc -public content::item::get_live_revision {
-item_id:required
} {
- @param item_id
+ Retrieves the live revision for the item. If the item has no live
+ revision, returns an empty string.
+
+ @param item_id The item_id of the content item
+
+ @return The live revision_id for the item, or an empty string if no
+ live revision exists
- @return NUMBER(38)
+ @see content::revision::item_id
+ @see content::item::get_best_revision
+ @see content::item::get_latest_revision
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -464,10 +500,16 @@
-item_id:required
-use_context:required
} {
- @param item_id
- @param use_context
-
- @return 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 The context in which the template will be used (e.g. public)
+
+ @return The template_id of the template which can be used to render the
+ item, or an empty string on failure
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -480,10 +522,16 @@
-item_id:required
{-is_live ""}
} {
- @param item_id
- @param is_live
-
- @return VARCHAR2(1000)
+ 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 of the content item
+ @param is_live
+
+ @return The title of the item
+
+ @see content::item::get_best_revision
+ @see content::item::get_title
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -496,10 +544,14 @@
-item_id:required
{-root_folder_id ""}
} {
- @param item_id
- @param root_folder_id
+ Retrieves the relative path to the item. The path is relative to the
+ page root, and has no extension (Example: "/foo/bar/baz").
+
+ @param item_id The item_id for the item, for which the path is computed
+ @param root_folder_id Starts path resolution from this folder.
+ Defaults to the root of the sitemap (when null).
- @return VARCHAR2
+ @return The path to the item, or an empty string on failure
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -527,9 +579,20 @@
ad_proc -public content::item::is_publishable {
-item_id:required
} {
- @param item_id
- @return CHAR
+ 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 of the content item
+
+ @see content::item::is_publishable
+
+ @return 't' if the item is publishable, 'f' otherwise
} {
return [package_exec_plsql -var_list [list \
[list item_id $item_id ] \
@@ -708,13 +771,13 @@
copy a content item to a new content item
- @param item_id - item id of the content to be copied from. source content item
+ @param item_id - item_id of the content to be copied from. source content item
@param target_folder_id - destination folder where the new content item is be passed
@param creation_user -
@param creation_ip -
@param name - the name of the new item, useful if you are copying in the same folder.
- @return item id of the new copied item
+ @return item_id of the new copied item
} {
return [package_exec_plsql \
-var_list [list \
@@ -786,12 +849,44 @@
{-name:required}
{-parent_id:required}
} {
- Returns the item_id of the a content item with the passed in name
+ Returns The item_id of the a content item with the passed in name
@param name Name of the content item
@param parent_id Parent_id of the content item
- @return the item id belonging to the name, empty string if no item_id was found
+ @return The item_id belonging to the name, empty string if no item_id was found
} {
return [db_string get_item_id_by_name {} -default ""]
}
+
+#
+#
+#
+
+ad_proc -public ::content::item::get_publish_status {
+ -item_id:required
+} {
+ 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 of the content item
+
+ @return The publish status of the item, or the empty string on failure
+
+ @see proc content::item::is_publishable
+
+} {
+
+ set publish_status [db_string gps_get_publish_status \
+ "select publish_status from cr_items where item_id = :item_id"]
+
+ return $publish_status
+}
\ No newline at end of file
Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 10 Jan 2007 21:22:03 -0000 1.19
+++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 12 Apr 2007 11:52:35 -0000 1.20
@@ -354,9 +354,11 @@
ad_proc -public content::revision::item_id {
-revision_id:required
} {
- @param revision_id
-
- @return item_id
+ 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
} {
return [db_string item_id {} -default ""]
}
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 -r1.6 -r1.7
--- openacs-4/packages/acs-content-repository/tcl/item-procs-oracle.xql 6 May 2004 13:01:39 -0000 1.6
+++ openacs-4/packages/acs-content-repository/tcl/item-procs-oracle.xql 12 Apr 2007 11:52:36 -0000 1.7
@@ -3,22 +3,6 @@
oracle8.1.6
-
-
-
- select content_item.get_title(:item_id) from dual
-
-
-
-
-
-
-
- select content_item.is_publishable(:item_id) from dual
-
-
-
-
@@ -27,13 +11,6 @@
-
-
- select content_item__get_id(:url $root_sql) from dual
-
-
-
-
@@ -45,75 +22,4 @@
-
-
-
- select content_item.get_template(:item_id, :context) as template_id
- from dual
-
-
-
-
-
-
-
- select content_item.get_path(:item_id, $root_folder_id) from dual
-
-
-
-
-
-
-
- select content_item.get_best_revision(:item_id) from dual
-
-
-
-
-
-
-
- begin
- content_item.delete(:item_id);
- end;
-
-
-
-
-
-
-
- begin
- content_item.copy(
- item_id => :item_id,
- target_folder_id => :target_folder_id,
- creation_user => :creation_user,
- creation_ip => :creation_ip
- );
- end;
-
-
-
-
-
-
- begin
- content_item.set_live_revision(
- revision_id => :revision_id,
- publish_status => 'live'
- );
- end;
-
-
-
-
-
- begin
- content_item.unset_live_revision(
- item_id => :item_id
- );
- end;
-
-
-
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 -r1.22 -r1.23
--- openacs-4/packages/acs-content-repository/tcl/item-procs.tcl 10 Jan 2007 21:22:03 -0000 1.22
+++ openacs-4/packages/acs-content-repository/tcl/item-procs.tcl 12 Apr 2007 11:52:36 -0000 1.23
@@ -12,80 +12,69 @@
namespace eval item {}
-ad_proc -public -deprecated item::get_title { item_id } {
+ad_proc -public item::get_content {
+ {-revision_id ""}
+ {-array:required}
+ {-item_id ""}
+} {
- @public get_title
+ @public get_revision_content
- Get the title for the item. If a live revision for the item exists,
- use the live revision. Otherwise, use the latest revision.
+ 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 item_id The item id
+ @param revision_id The revision whose attributes are to be retrieved
- @return The title of the item
+ @option item_id The item_id of the
+ corresponding item. You can provide this as an optimization.
+ If you don't provide revision_id, you must provide item_id,
+ and the item must have a live revision.
- @see proc item::get_best_revision
- @see content::item::get_title
+ @return 1 on success (and set the array in the calling frame),
+ 0 on failure
+
+ @see proc item::get_mime_info
+ @see proc item::get_content_type
} {
+ upvar 1 $array content
- set title [db_string gt_get_title ""]
-
- return $title
+ if { $item_id eq "" } {
+ set item_id [::content::revision::item_id -revision_id $revision_id]
+ if { $item_id eq "" } {
+ ns_log notice "item::get_content: no such revision: $revision_id"
+ return 0
+ }
+ } elseif { $revision_id eq "" } {
+ set revision_id [::content::item::get_live_revision -item_id $item_id]
+ }
+ if { $revision_id eq "" } {
+ error "You must supply revision_id, or the item must have a live revision."
+ }
+
+ return [item::get_revision_content $revision_id $item_id]
}
-ad_proc -public item::get_publish_status { item_id } {
+ad_proc -public item::content_is_null { revision_id } {
- @public get_publish_status
+ @public content_is_null
- 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
-
+ Determines if the content for the revision is null (not mereley
+ zero-length)
+ @param revision_id The revision id
- @param item_id The item id
-
- @return The publish status of the item, or the empty string on failure
-
- @see proc item::is_publishable
+ @return 1 if the content is null, 0 otherwise
} {
+ set content_test [db_string cin_get_content ""]
- set publish_status [db_string gps_get_publish_status ""]
-
- return $publish_status
+ return [template::util::is_nil content_test]
}
-ad_proc -public -deprecated 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
-
- @see content::item::is_publishable
-
- @return 1 if the item is publishable, 0 otherwise
-
-} {
- set is_publishable [db_string ip_is_publishable_p ""]
-
- return [string equal $is_publishable "t"]
-}
-
-
ad_proc -public item::get_revision_content { revision_id args } {
@public get_revision_content
@@ -114,7 +103,7 @@
if { [template::util::is_nil opts(item_id)] } {
# Get the item id
- set item_id [get_item_from_revision $revision_id]
+ set item_id [::content::revision::item_id -revision_id $revision_id]
if { [template::util::is_nil item_id] } {
ns_log warning "item::get_revision_content: No such revision: $reivision_id"
@@ -135,7 +124,7 @@
}
# Get the content type
- set content_type [get_content_type $item_id]
+ set content_type [::content::item::get_content_type -item_id $item_id]
# Get the table name
set table_name [db_string grc_get_table_names ""]
@@ -153,7 +142,7 @@
return 1
}
-
+
ad_proc -public item::content_methods_by_type { content_type args } {
@public content_methods_by_type
@@ -172,7 +161,7 @@
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
+ @return A Tcl list of all possible content methods
} {
@@ -204,6 +193,244 @@
}
+
+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
+
+} {
+ set sql [db_map gmi_get_mime_info]
+
+ return [uplevel "db_0or1row ignore \"$sql\" -column_array $datasource_ref"]
+}
+
+ad_proc -public item::get_extended_url { item_id args } {
+
+ 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 warning "item::get_extended_url: 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 [::content::item::get_best_revision -item_id $template_id]
+
+ if { ![template::util::is_nil template_revision_id] } {
+ get_mime_info $template_revision_id mime_info
+
+ if { [info exists mime_info(file_extension)] } {
+ 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 [::content::item::get_live_revision -item_id $item_id]
+
+ if { [template::util::is_nil revision_id] } {
+ ns_log warning "item::get_best_revision: No live revision for content item $item_id"
+ return ""
+ }
+
+ } else {
+ set revision_id $opts(revision_id)
+ }
+
+ get_mime_info $revision_id mime_info
+ if { [info exists mime_info(file_extension)] } {
+ set file_extension $mime_info(file_extension)
+ } else {
+ set file_extension "html"
+ }
+ }
+
+ append file_url ".$file_extension"
+
+ return $file_url
+}
+
+#######################################################
+#
+# the following have no counter parts in content::item::*
+# but use no direct sql calls.
+#
+#######################################################
+ad_proc -public item::get_element {
+ {-item_id:required}
+ {-element:required}
+} {
+ Return the value of a single element (attribute) of a content
+ item.
+
+ @param item_id The id of the item to get element value for
+ @param element The name (column name) of the element. See
+ item::get for valid element names.
+} {
+ ::content::item::get -item_id $item_id -array row
+ return $row($element)
+}
+ad_proc -public item::publish {
+ {-item_id:required}
+ {-revision_id ""}
+} {
+ Publish a content item. Updates the live_revision and publish_date attributes, and
+ sets publish_status to live.
+
+ @param item_id The id of the content item
+ @param revision_id The id of the revision to publish. Defaults to the latest revision.
+
+ @author Peter Marklund
+} {
+ if { $revision_id eq "" } {
+ set revision_id [::content::item::get_latest_revision -item_id $item_id]
+ }
+ ::content::item::set_live_revision -revision_id $revision_id -publish_status 'live'
+}
+
+ad_proc -public item::unpublish {
+ {-item_id:required}
+ {-publish_status "production"}
+} {
+ Unpublish a content item.
+
+ @param item_id The id of the content item
+ @param publish_status The publish_status to put the item in after unpublishing it.
+
+ @author Peter Marklund
+} {
+ ::content::item::set_live_revision -item_id $item_id
+ ::content::item::update -item_id $item_id -attributes [list [list publish_status $publish_status]]
+}
+
+#######################################################
+#
+# all the following procs are deprecated and do not have
+# direct sql calls.
+#
+#######################################################
+
+ad_proc -public -deprecated 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 item::get_best_revision
+ @see content::item::get_title
+
+} {
+ return [::content::item::get_title -item_id item_id]
+}
+
+ad_proc -public -deprecated 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
+
+} {
+
+ return [::content::item::get_publish_status -item_id item_id]
+}
+
+ad_proc -public -deprecated 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
+
+ @see content::item::is_publishable
+
+ @return 1 if the item is publishable, 0 otherwise
+
+} {
+ return [string equal [::content::item::is_publishable -item_id $item_id] "t"]
+}
+
ad_proc -public -deprecated item::get_content_type { item_id } {
@public get_content_type
@@ -219,35 +446,25 @@
@see content::item::get_content_type
} {
-
- set content_type [db_string gct_get_content_type ""]
-
- if { [info exists content_type] } {
- return $content_type
- } else {
- return ""
- }
+ return [::content::item::get_content_type -item_id $item_id]
}
+ad_proc -public -deprecated item::get_item_from_revision { revision_id } {
-ad_proc -public 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
+ @see content::item::get_live_revision
+ @see content::revision::item_id
} {
- set item_id [db_string gifr_get_one_revision ""]
- return $item_id
+ return [::content::revision::item_id -revision_id $revision_id]
}
-
ad_proc -public -deprecated item::get_id { url {root_folder ""}} {
@public get_id
@@ -271,40 +488,13 @@
set url [string range $url 0 [expr {$last - 1}]]
}
- if { ![template::util::is_nil root_folder] } {
- set root_sql ", :root_folder, 'f'"
+ if {$root_folder ne ""} {
+ return [::content::item::get_id -item_path $url]
} else {
- set root_sql ", null, 'f'"
+ return [::content::item::get_id -item_path $url -root_folder_id $root_folder]
}
-
- # Get the path
- set item_id [db_string id_get_item_id ""]
-
- if { [info exists item_id] } {
- return $item_id
- } else {
- return ""
- }
}
-
-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
-
-} {
- set content_test [db_string cin_get_content ""]
-
- return [template::util::is_nil content_test]
-}
-
-
ad_proc -public -deprecated item::get_template_id { item_id {context public} } {
@public get_template_id
@@ -325,17 +515,9 @@
@see content::item::get_template
} {
-
- set template_id [db_string gti_get_template_id ""]
-
- if { [info exists template_id] } {
- return $template_id
- } else {
- return ""
- }
+ return [::content::item::get_template -item_id $item_id -use_context $context]
}
-
ad_proc -public -deprecated item::get_template_url { item_id {context public} } {
@public get_template_url
@@ -356,15 +538,14 @@
} {
- set template_id [get_template_id $item_id $context]
+ set template_id [::content::item::get_template -item_id $item_id -use_context $context]
- if { [template::util::is_nil template_id] } {
+ if { $template_id eq "" } {
return ""
}
return [get_url $template_id]
}
-
ad_proc -public -deprecated item::get_url {
{-root_folder_id "null"}
@@ -373,7 +554,7 @@
@public get_url
- Retrieves the relative URL stub to th item. The URL is relative to the
+ Retrieves the relative URL stub to the item. The URL is relative to the
page root, and has no extension (Example: "/foo/bar/baz").
@param item_id The item id
@@ -386,68 +567,14 @@
} {
- # Get the path
- set item_path [db_string gu_get_path ""]
-
- if { [info exists item_path] } {
- return $item_path
- } else {
- return ""
- }
+ if {$root_folder_id eq "null"} {
+ return [::content::item::get_virtual_path -item_id $item_id]
+ } else {
+ return [::content::item::get_virtual_path -item_id $item_id -root_folder_id $root_folder_id]
+ }
+
}
-
-ad_proc -public -deprecated 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
- @see proc content::item::get_live_revision
-
-} {
-
- set live_revision [db_string glr_get_live_revision "" -default ""]
-
- if { [template::util::is_nil live_revision] } {
- ns_log warning "item::get_live_revision: 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
-
-} {
- set sql [db_map gmi_get_mime_info]
-
- return [uplevel "db_0or1row ignore \"$sql\" -column_array $datasource_ref"]
-}
-
-
ad_proc -public -deprecated item::get_best_revision { item_id } {
@public get_best_revision
@@ -460,118 +587,56 @@
@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
- @see content::item::get_best_revision
-
+ @see content::item::get_live_revision
+ @see content::item::get_latest_revision
+ @see content::item::get_best_revision
} {
-
- return [db_string gbr_get_best_revision ""]
+ return [::content::item::get_best_revision -item_id $item_id]
}
+ad_proc -public -deprecated item::get_latest_revision { item_id } {
-ad_proc -public item::get_extended_url { item_id args } {
-
- @public get_content_type
+ Retrieves the latest revision for the item. If the item has no live
+ revision, returns an empty string.
- 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
+ @return The latest revision id for the item, or an empty string if no
+ revisions exist
+ @see content::item::get_live_revision
+ @see content::item::get_latest_revision
+ @see content::item::get_best_revision
} {
+ return [::content::item::get_latest_revision -item_id $item_id]
+}
- set item_url [get_url $item_id]
+ad_proc -public -deprecated item::get_live_revision { item_id } {
- if { [template::util::is_nil item_url] } {
- ns_log warning "item::get_extended_url: No item URL found for content item $item_id"
- return ""
- }
+ @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 item::get_best_revision
+ @see content::revision::item_id
+ @see content::item::get_live_revision
- 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(file_extension)] } {
- 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 warning "item::get_best_revision: No live revision for content item $item_id"
- return ""
- }
-
- } else {
- set revision_id $opts(revision_id)
- }
-
- get_mime_info $revision_id mime_info
- if { [info exists mime_info(file_extension)] } {
- set file_extension $mime_info(file_extension)
- } else {
- set file_extension "html"
- }
- }
-
- append file_url ".$file_extension"
-
- return $file_url
-}
-
+} {
+ return [::content::item::get_live_revision -item_id $item_id]
+}
+
ad_proc -public -deprecated item::get_type { item_id } {
Returns the content type of the specified item, or empty string
if the item_id is invalid
@see content::item::get_content_type
} {
- if { [db_0or1row get_content_type ""] } {
- return $content_type
- } else {
- return ""
- }
+ return [::content::item::get_content_type -item_id $item_id]
}
ad_proc -deprecated item::copy {
@@ -586,12 +651,10 @@
@see content::item::copy
} {
-
- set creation_user [ad_conn user_id]
- set creation_ip [ad_conn peeraddr]
-
- db_exec_plsql copy_item {}
-
+ ::content::item::copy -item_id $item_id \
+ -target_folder_id $target_folder_id \
+ -creation_user [ad_conn user_id] \
+ -creation_ip [ad_conn peeraddr]
}
ad_proc -public -deprecated item::get {
@@ -612,75 +675,9 @@
} {
upvar $array row
- db_1row select_item_data {
- select *
- from cr_items
- where item_id = :item_id
- } -column_array row
+ ::content::item::get -item_id $item_id -array row
}
-ad_proc -public item::get_element {
- {-item_id:required}
- {-element:required}
-} {
- Return the value of a single element (attribute) of a content
- item.
-
- @param item_id The id of the item to get element value for
- @param element The name (column name) of the element. See
- item::get for valid element names.
-} {
- get -item_id $item_id -array row
- return $row($element)
-}
-
-ad_proc -public item::get_content {
- {-revision_id ""}
- {-array:required}
- {-item_id ""}
-} {
-
- @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 The item_id of the
- corresponding item. You can provide this as an optimization.
- If you don't provide revision_id, you must provide item_id,
- and the item must have a live revision.
-
- @return 1 on success (and set the array in the calling frame),
- 0 on failure
-
- @see proc item::get_mime_info
- @see proc item::get_content_type
-
-} {
- upvar 1 $array content
-
- if { $item_id eq "" } {
- set item_id [get_item_from_revision $revision_id]
- if { $item_id eq "" } {
- ns_log notice "item::get_content: no such revision: $reivision_id"
- return 0
- }
- } elseif { $revision_id eq "" } {
- set revision_id [item::get_live_revision $item_id]
- }
- if { $revision_id eq "" } {
- error "You must supply revision_id, or the item must have a live revision."
- }
-
- return [get_revision_content $revision_id $item_id]
-}
-
ad_proc -public -deprecated item::delete {
{-item_id:required}
} {
@@ -691,43 +688,6 @@
@author Peter Marklund
@see content::item::delete
} {
- db_exec_plsql delete_item {}
+ ::content::item::delete -item_id $item_id
}
-ad_proc -public item::publish {
- {-item_id:required}
- {-revision_id ""}
-} {
- Publish a content item. Updates the live_revision and publish_date attributes, and
- sets publish_status to live.
-
- @param item_id The id of the content item
- @param revision_id The id of the revision to publish. Defaults to the latest revision.
-
- @author Peter Marklund
-} {
- if { $revision_id eq "" } {
- set revision_id [item::get_element -item_id $item_id -element latest_revision]
- }
-
- db_exec_plsql set_live { }
-}
-
-ad_proc -public item::unpublish {
- {-item_id:required}
- {-publish_status "production"}
-} {
- Unpublish a content item.
-
- @param item_id The id of the content item
- @param publish_status The publish_status to put the item in after unpublishing it.
-
- @author Peter Marklund
-} {
-
- db_exec_plsql unset_live {
- }
-
- db_dml update_publish_status {
- }
-}
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 -r1.6 -r1.7
--- openacs-4/packages/acs-content-repository/tcl/item-procs.xql 16 Jan 2004 19:18:44 -0000 1.6
+++ openacs-4/packages/acs-content-repository/tcl/item-procs.xql 12 Apr 2007 11:52:36 -0000 1.7
@@ -1,14 +1,6 @@
-
-
-
- select publish_status from cr_items where item_id = :item_id
-
-
-
-
@@ -44,39 +36,6 @@
-
-
-
- select content_type from cr_items where
- item_id = :item_id
-
-
-
-
-
-
-
- select item_id from cr_revisions where revision_id = :revision_id
-
-
-
-
-
-
- select content_type from cr_items
- where item_id = :item_id
-
-
-
-
-
-
- select live_revision from cr_items
- where item_id = :item_id
-
-
-
-
@@ -92,12 +51,4 @@
-
-
- update cr_items
- set publish_status = :publish_status
- where item_id = :item_id
-
-
-