Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 5 Oct 2003 12:28:03 -0000 1.6
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 14 Oct 2003 14:58:31 -0000 1.7
@@ -162,7 +162,7 @@
- select name, parent_id, storage_type, content_type, storage_type, publish_status,
+ select item_id, name, parent_id, storage_type, content_type, storage_type, publish_status,
revision_id, title, content, description, publish_date, mime_type
from cr_items i, cr_revisions r where
i.item_id = r.item_id
@@ -180,7 +180,7 @@
-
+
select content_item__get_id(:url, :root_id, :resolve_index);
Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 9 Oct 2003 09:57:17 -0000 1.6
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 14 Oct 2003 14:58:31 -0000 1.7
@@ -148,6 +148,7 @@
# initialize the addtionals we will use
set addtnl_where_list [list]
+ set addtnl_where_folder_list [list]
if {[info exists additional_columns]} {
set addtnl_select_list $additional_columns
} else {
@@ -179,9 +180,12 @@
# construct the additionals
if {[llength $addtnl_where_list] > 0} {
set addtnl_where "and [join $addtnl_where_list " and "]"
- set addtnl_where_folder "and [join $addtnl_where_folder_list " and "]"
} else {
set addtnl_where ""
+ }
+ if {[llength $addtnl_where_folder_list] > 0} {
+ set addtnl_where_folder "and [join $addtnl_where_folder_list " and "]"
+ } else {
set addtnl_where_folder ""
}
if {[llength $addtnl_select_list] > 0} {
@@ -330,11 +334,30 @@
}
+ad_proc -public bcms::item::get_item_id_by_url {
+ {-root_id:required}
+ {-url:required}
+ {-resolve_index:boolean}
+} {
+ get the content item details based from the url.
+
+ @param root_id starting from which url to resolve the item
+ @param url the url which we would like to resolve
+ @param resolve_index return the item_id of the index content item on a content_folder
+ rather than the content_folder's item_id
+
+ @returns the item_id of the item from that URL, or the empty string if no such item exists.
+} {
+ set resolve_index [db_boolean $resolve_index_p]
+ return [db_exec_plsql get_item_id {}]
+}
+
+
#TODO: use the views to select the revision info
ad_proc -public bcms::item::get_item_by_url {
{-root_id:required}
{-url:required}
- {-revision}
+ {-revision ""}
{-resolve_index:boolean}
} {
get the content item details based from the url.
@@ -366,27 +389,19 @@
array unset yourarray.
} {
- if {$resolve_index_p} { set resolve_index true } else { set resolve_index false }
+ set item_id [get_item_id_by_url -root_id $root_id -url $url -resolve_index=$resolve_index_p]
- set item_id [db_exec_plsql get_item_id "SQL"]
-
- if [string equal $item_id ""] {
+ if { [string equal $item_id ""] } {
return {}
- } else {
- if [info exists revision] {
- array set one_item [get_item -item_id $item_id -revision $revision]
- } else {
- array set one_item [get_item -item_id $item_id]
- }
- set one_item(item_id) $item_id
- return [array get one_item]
}
+
+ return [get_item -item_id $item_id -revision $revision]
}
#TODO: use the views to select the revision info
ad_proc -public bcms::item::get_item {
{-item_id:required}
- {-revision}
+ {-revision ""}
} {
get the content item details.
@@ -415,7 +430,7 @@
# if additional revision data must be returned, set the additional columns here
# for revisions. I am not using db_map since I think its not useful.
- if [info exists revision] {
+ if { [exists_and_not_null revision] } {
set addtnl_select ", r.revision_id, r.title, r.content, r.description, r.publish_date, r.mime_type"
set addtnl_from ", cr_revisions r"
switch -exact $revision {
@@ -438,7 +453,7 @@
set addtnl_where ""
}
- if {[db_0or1row get_1item "SQL" -column_array one_item]} {
+ if {[db_0or1row get_1item {} -column_array one_item]} {
return [array get one_item]
} else {
return {}
@@ -464,10 +479,10 @@
} {
switch -exact $revision {
latest {
- set addtnl_select ", bcms__get_title(i.item_id, 'latest_revision') as title, content_folder__get_label(i.item_id) as folder_label"
+ set addtnl_select ", bcms__get_title(i.item_id, 'latest') as title, content_folder__get_label(i.item_id) as folder_label"
}
live {
- set addtnl_select ", bcms__get_title(i.item_id, 'live_revision') as title, content_folder__get_label(i.item_id) as folder_label"
+ set addtnl_select ", bcms__get_title(i.item_id, 'live') as title, content_folder__get_label(i.item_id) as folder_label"
}
default {
ns_log notice "bcms: revision requested not valid"
Index: openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 27 Aug 2003 17:23:27 -0000 1.3
+++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 14 Oct 2003 14:58:31 -0000 1.4
@@ -4,7 +4,7 @@
- select i.name, i.parent_id, i.live_revision, i.latest_revision,
+ select i.item_id, i.name, i.parent_id, i.live_revision, i.latest_revision,
i.content_type, i.storage_type, i.publish_status
$addtnl_select
from cr_items i $addtnl_from