Index: openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/sql/postgresql/bcms-create.sql 27 Aug 2003 17:23:27 -0000 1.3 @@ -216,3 +216,34 @@ return 0; end;' language 'plpgsql'; + + + +create or replace function content_keyword__get_path_id (integer) +returns text as ' +declare + get_path__keyword_id alias for $1; + v_path text default ''''; + v_is_found boolean default ''f''; + v_keyword_id cr_keywords.keyword_id%TYPE; + v_rec record; +begin + for v_rec in select keyword_id + from (select k2.keyword_id, tree_level(k2.tree_sortkey) as tree_level + from cr_keywords k1, cr_keywords k2 + where k1.keyword_id = get_path__keyword_id + and k1.tree_sortkey between k2.tree_sortkey and tree_right(k2.tree_sortkey)) k + order by tree_level + LOOP + v_keyword_id := v_rec.keyword_id; + v_is_found := ''t''; + v_path := v_path || ''/'' || v_keyword_id; + end LOOP; + + if v_is_found = ''f'' then + return null; + else + return v_path; + end if; + +end;' language 'plpgsql'; Index: openacs-4/contrib/packages/bcms/tcl/bcms-category-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-category-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/bcms/tcl/bcms-category-procs-postgresql.xql 27 Aug 2003 17:23:27 -0000 1.1 @@ -0,0 +1,77 @@ + + + postgresql7.2 + + + + + + select content_keyword__new (:heading, + :description, + :parent_id, + null, + now(), + :creation_user_id, + :creation_ip, + 'content_keyword') + + + + + + + + + select content_keyword__delete (:category_id) + + + + + + + + + select c.keyword_id as category_id, c.parent_id, c.heading, + c.description, content_keyword__get_path(c.keyword_id) as path + from cr_keywords c, + (select keyword_id, tree_sortkey from cr_keywords where keyword_id = :parent_id) p + where + c.tree_sortkey between p.tree_sortkey and tree_right(p.tree_sortkey) + order by c.tree_sortkey; + + + + + + + + + select keyword_id as category_id, parent_id, heading, description, has_children + from cr_keywords k, + (select tree_sortkey from cr_keywords where keyword_id = :category_id) c + where k.tree_sortkey = tree_root_key(c.tree_sortkey); + + + + + + + (select keyword_id as category_id, heading, :prepend_path || content_keyword__get_path_id(keyword_id) as path + from cr_keywords + where keyword_id = :root_id) + + union + + (select keyword_id as category_id, heading, :prepend_path || content_keyword__get_path_id(keyword_id) as path + from cr_keywords c, + (select tree_sortkey from cr_keywords where keyword_id = :root_id) r, + (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_keywords where keyword_id = :category_id) p + where + c.tree_sortkey = p.tree_sortkey + and c.tree_sortkey > r.tree_sortkey + order by c.tree_sortkey) + + + + + Index: openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.tcl 27 Aug 2003 17:23:27 -0000 1.1 @@ -0,0 +1,217 @@ +ad_library { + + Procs for content repository keywords + + @author Jun Yamog + @creation-date Aug 2003 + @cvs-id $Id: bcms-category-procs.tcl,v 1.1 2003/08/27 17:23:27 juny Exp $ + + some are derived from Deds classified-ads:categories +} + +namespace eval bcms::category {} + +ad_proc -public bcms::category::create_category { + {-heading:required} + {-description ""} + {-parent_id ""} + {-creation_user_id} + {-creation_ip} +} { + + creates a new keyword that's used for categorization + + @param heading The heading of the new keyword + @param description The description of the new keyword + @param parent_id The parent of this new keyword if it is a subcategory + +} { + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + + return [db_exec_plsql create_category "SQL"] +} + + +ad_proc -public bcms::category::set_category { + {-category_id:required} + {-heading} + {-description} +} { + + sets/edits properties of an existing category + + @param category_id The keyword id of the category to edit + @param heading The new heading to use + @param description The new description to use + +} { + + if {[info exists heading]} { + db_dml set_heading "SQL" + } + + if {[info exists description]} { + db_dml set_description "SQL" + } + +} + + +ad_proc -public bcms::category::delete_category { + {-category_id:required} +} { + + deletes a category + + @param category_id The category id of the category to delete + +} { + db_exec_plsql delete_category {} +} + + +ad_proc -public bcms::category::get_category { + {-category_id:required} +} { + + returns the data for a particular category + + @param category_id The category id of the category to get the data + + @returns an array with the following properties: + category_id, parent_id, heading, description, has_children + +} { + + if {[db_0or1row get_category "SQL" -column_array category]} { + return [array get category] + } else { + return {} + } + +} + + +ad_proc -public bcms::category::list_categories { + {-parent_id} + {-return_list:boolean} + {-multirow_name bcms_list_category} +} { + + returns the categories under a parent + + @parent_id id of the category which will list the category under it, if not supplied + it will list all the root keywords + @param multirow_name you can supply your own multirow name + @param return_list if supplied a list of ns_sets otherwise it + returns a multirow uses the multirow_name if given + + @returns makes a multirow of categories or list of ns sets with the following properties: + category_id, parent_id, heading, description, has_children + +} { + + if {[info exists parent_id]} { + set where_str "parent_id = :parent_id" + } else { + set where_str "parent_id is null" + } + + if {$return_list_p} { + # return a list of lists since its not easy to pass multirow from proc to proc + return [db_list_of_ns_sets get_categories "SQL"] + } else { + # make a multirow, it is likely that this proc is not being called from another proc + db_multirow $multirow_name get_categories "SQL" + } + +} + + +ad_proc -public bcms::category::tree_categories { + {-parent_id:required} + {-return_list:boolean} + {-multirow_name bcms_tree_category} +} { + + returns the all sub categories under the root id + + @parent_id category id of root node of the tree to return + @param multirow_name you can supply your own multirow name + @param return_list if supplied a list of ns_sets otherwise it + returns a multirow uses the multirow_name if given + + @returns all sub categories under the root_id with the following attributes: + category_id, parent_id, heading, description, has_children, path +} { + + if {$return_list_p} { + # return a list of lists since its not easy to pass multirow from proc to proc + return [db_list_of_ns_sets get_categories "SQL"] + } else { + # make a multirow, it is likely that this proc is not being called from another proc + db_multirow $multirow_name get_categories "SQL" + } + +} + + +ad_proc -public bcms::category::get_category_path { + {-category_id:required} + {-root_id} + {-prepend_path ''} + {-multirow_name bcms_category_path} + {-return_list:boolean} +} { + returns a path from the root_id to the category_id + + @param category_id build the path to this category + @param root_id build the path from this root, if not supplied it will use the root node of the + current category + @param prepend_path you can add a string to prepend the path column + @param multirow_name you can supply your own multirow name + @param return_list if supplied a list of ns_sets otherwise it + returns a multirow uses the multirow_name if given + + @returns a multirow/list with the following elements: + category_id, path, heading +} { + + if {![info exists root_id]} { + # if the root_id does not exists then start from the root + array set root [bcms::category::get_root -category_id $category_id] + if {[array size root] > 0} { + set root_id $root(category_id) + } else { + ns_log notice "bcms: category does not exists" + } + } + + if {$return_list_p} { + return [db_list_of_ns_sets get_category_path "SQL"] + } else { + db_multirow $multirow_name get_category_path "SQL" + } +} + + +ad_proc -public bcms::category::get_root { + {-category_id:required} +} { + gets the root id of a category tree, supplied with any category underneath it + + @param category_id a node of the category tree + + @returns an array with the following properties: + category_id, parent_id, heading, description, has_children +} { + + if {[db_0or1row get_root "SQL" -column_array category]} { + return [array get category] + } else { + return {} + } + +} + Index: openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/bcms/tcl/bcms-category-procs.xql 27 Aug 2003 17:23:27 -0000 1.1 @@ -0,0 +1,33 @@ + + + postgresql7.2 + + + + update cr_keywords set heading = :heading where keyword_id = :category_id + + + + + + update cr_keywords set description = :description where keyword_id = :category_id + + + + + + select keyword_id as category_id, parent_id, heading, description, has_children + from cr_keywords + where keyword_id = :category_id + + + + + + select keyword_id as category_id, parent_id, heading, description, has_children + from cr_keywords + where $where_str + + + + Index: openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-folder-procs.tcl 27 Aug 2003 17:23:27 -0000 1.3 @@ -1,10 +1,10 @@ ad_library { - Provide functions for Content Repository folders - - @author Jun Yamog - @creation-date 10 Aug 2002 - @cvs-id $Id$ + Provide functions for Content Repository folders + + @author Jun Yamog + @creation-date 10 Aug 2002 + @cvs-id $Id$ } namespace eval bcms::folder {} @@ -26,10 +26,10 @@ } { set bcms_root_folder [parameter::get -parameter root_folder_id -default 0] if {($bcms_root_folder > 0) || ($bcms_root_folder == [bcms::folder::get_cr_root_folder])} { - return $bcms_root_folder + return $bcms_root_folder } else { - ns_log warning "bcms root folder id not properly set, please set on the admin pages" - return 0 + ns_log warning "bcms root folder id not properly set, please set on the admin pages" + return 0 } } 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.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs-postgresql.xql 27 Aug 2003 17:23:27 -0000 1.3 @@ -212,18 +212,53 @@ - select i.item_id, :prepend_path || content_item__get_path(i.item_id, r.item_id) as path, + (select i.item_id, :prepend_path as path, case when i.content_type = 'content_folder' then content_folder__get_label(i.item_id) else bcms__get_title(i.item_id, 'latest') end as title + from cr_items i where item_id = :root_id) + + union + + (select i.item_id, :prepend_path || content_item__get_path(i.item_id, r.item_id) as path, + case when i.content_type = 'content_folder' then content_folder__get_label(i.item_id) else bcms__get_title(i.item_id, 'latest') end as title from cr_items i, (select tree_sortkey, item_id from cr_items where item_id = :root_id) r, (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = :item_id) p where i.tree_sortkey = p.tree_sortkey and i.tree_sortkey > r.tree_sortkey - order by i.tree_sortkey + $addtnl_where + order by i.tree_sortkey) + + + + select content_keyword__item_assign (:item_id, + :category_id, + null, + null, + null) + + + + + + + select content_keyword__item_unassign (:item_id, + :category_id) + + + + + + + select content_keyword__item_unassign (item_id, keyword_id) + from cr_item_keyword_map where item_id = :item_id; + + + + 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.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl 27 Aug 2003 17:23:27 -0000 1.3 @@ -81,6 +81,8 @@ return $item_id } + +#TODO: use the views to update ad_proc -public bcms::item::set_item { {-item_id:required} {-name} @@ -123,7 +125,7 @@ {-content_type content_revision} {-multirow_name bcms_list_items} {-return_list:boolean false} - {-additional_columns [list]} + {-additional_columns} } { Gets all content item under the parent_id @@ -146,7 +148,11 @@ # initialize the addtionals we will use set addtnl_where_list [list] - set addtnl_select_list $additional_columns + if {[info exists additional_columns]} { + set addtnl_select_list $additional_columns + } else { + set addtnl_select_list [list] + } # if additional revision data must be returned, set the additional columns here # for revisions. @@ -182,8 +188,9 @@ set addtnl_select_list [linsert $addtnl_select_list 0 r.title r.description] set addtnl_select ", [join $addtnl_select_list ", "]" } else { - set addtnl_select "" set addtnl_select_folder "" + set addtnl_select_list [linsert $addtnl_select_list 0 r.title r.description] + set addtnl_select ", [join $addtnl_select_list ", "]" } if {$return_list_p} { @@ -322,6 +329,7 @@ } +#TODO: use the views to select the revision info ad_proc -public bcms::item::get_item_by_url { {-root_id:required} {-url:required} @@ -372,6 +380,7 @@ } } +#TODO: use the views to select the revision info ad_proc -public bcms::item::get_item { {-item_id:required} {-revision} @@ -603,26 +612,91 @@ {-root_id} {-prepend_path ''} {-multirow_name bcms_item_path} - {-return_list:boolean false} + {-return_list:boolean} + {-no_parent:boolean} } { - returns a path from the root_id to the item_id. + returns a multirow/list of path from the root_id to the item_id. - @param item_id build the path to this item + @param item_id build the path to this item @param root_id build the path from this folder, if not supplied it use the current bcms root @param prepend_path you can add a string to prepend the path column @param multirow_name you can supply your own multirow name @param return_list if supplied a list of ns_sets otherwise it returns a multirow uses the multirow_name if given - @returns the following attributes item_id, path, title + @param no_parent does not return additional rows containing the parents to this item + + @returns a multirow/list with following elements item_id, path, title } { if ![info exists root_id] { # if the parent_id does not exists then start from the root set root_id [bcms::folder::get_bcms_root_folder] } + if {$no_parent_p} { + set addtnl_where "and i.item_id = :item_id" + } else { + set addtnl_where "" + } + if {$return_list_p} { return [db_list_of_ns_sets get_item_path "SQL"] } else { db_multirow $multirow_name get_item_path "SQL" } } + + +ad_proc -public bcms::item::assign_category { + {-category_id:required} + {-item_id:required} +} { + + categorize a content item to a category + + @param category_id The keyword id of the category we map to + @param item_id The item id of the content item we map + +} { + return [db_exec_plsql assign_category "SQL"] +} + + +ad_proc -public bcms::item::unassign_category { + {-category_id:required} + {-item_id:required} +} { + + removes map of a category to a content item + + @param category_id The category id of the category we unmap to + @param item_id The item id of the content item we unmap + +} { + return [db_exec_plsql unassign_category "SQL"] +} + + +ad_proc -public bcms::item::clear_categories { + {-item_id:required} +} { + clears all the assigned categories for a particular item + + @param item_id The item id of the content item we unmap +} { + db_list unassign_all_category "SQL" +} + + +# TODO: make this similar to list_X calls? +ad_proc -public bcms::item::get_categories { + {-item_id:required} +} { + get the categories assigned to this item + + @param item_id id of the item + + @returns category ids assigned to this item +} { + + return [db_list get_categories "SQL"] +} 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.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.xql 27 Aug 2003 17:23:27 -0000 1.3 @@ -26,10 +26,16 @@ - - - select table_name from acs_object_types where object_type = :content_type - - + + + select table_name from acs_object_types where object_type = :content_type + + + + + select keyword_id as category_id from cr_item_keyword_map where item_id = :item_id + + + Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs-postgresql.xql 27 Aug 2003 17:23:27 -0000 1.3 @@ -40,5 +40,10 @@ + + + select content_revision__copy(:revision_id, null, null, :creation_user_id, :creation_ip) + + Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 27 Aug 2003 17:23:27 -0000 1.3 @@ -20,12 +20,15 @@ {-mime_type "text/plain"} {-description ""} {-content ""} - {-creation_user_id ""} - {-creation_ip ""} + {-creation_user_id} + {-creation_ip} } { Adds a new revision to a content item stored in the cr_revision.content column. Normally you will use your own proc patterned after this proc } { + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + if ![info exists content_type] { set content_type [bcms::item::get_content_type -item_id $item_id] } @@ -124,7 +127,7 @@ } { Get the revision info on a single revision returns an array that contains item_id, name, title, description, - content, content_type, publish_status, live_revision, storage_type + content, content_type, publish_status, latest_revision, live_revision, storage_type } { if {[db_0or1row get_1revision "SQL" -column_array one_revision]} { @@ -201,3 +204,23 @@ } +ad_proc -public bcms::revision::copy_revision { + {-revision_id:required} + {-creation_user_id} + {-creation_ip} +} { + creates another revision based from the revision_id passed. + + @param revision_id id of which the version will be copied from + @param creation_user user performing the copy + @param creation_ip ip address of the user performing the copy + + @returns the version id of the new revision +} { + + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + + return [db_exec_plsql copy_revision "SQL"] + +} Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql 14 May 2003 15:34:59 -0000 1.1 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.xql 27 Aug 2003 17:23:27 -0000 1.2 @@ -46,7 +46,7 @@ select i.item_id, i.name, r.title, r.description, r.content, - i.content_type, i.publish_status, i.live_revision, i.storage_type + i.content_type, i.publish_status, i.live_revision, i.latest_revision, i.storage_type from cr_revisions r, cr_items i where r.revision_id = :revision_id and i.item_id = r.item_id Index: openacs-4/contrib/packages/bcms/tcl/bcms-template-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-template-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/bcms/tcl/bcms-template-procs-postgresql.xql 14 May 2003 15:34:59 -0000 1.1 +++ openacs-4/contrib/packages/bcms/tcl/bcms-template-procs-postgresql.xql 27 Aug 2003 17:23:27 -0000 1.2 @@ -10,6 +10,12 @@ + + + select content_revision__new(:title, :description, now(), 'text/html', null, :content, :template_id, null, now(), :creation_user_id, :creation_ip) + + + select content_template__delete(:template_id) @@ -40,4 +46,16 @@ + + + select i.item_id as template_id, i.name, i.live_revision, i.latest_revision, i.publish_status, i.content_type, i.storage_type, i.tree_sortkey, + r.title, r.description + from cr_items i, cr_revisions r + where + i.parent_id = :parent_id + and i.item_id = r.item_id + and r.revision_id = $revision + + + Index: openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl 14 May 2003 15:34:59 -0000 1.1 +++ openacs-4/contrib/packages/bcms/tcl/bcms-template-procs.tcl 27 Aug 2003 17:23:27 -0000 1.2 @@ -8,19 +8,77 @@ ad_proc -public bcms::template::create_template { {-template_name:required} - {-parent_id} - {-creation_user_id ""} - {-creation_ip ""} + {-parent_id:required} + {-creation_user_id} + {-creation_ip} } { This proc creates a template and returns the item_id of the new template } { - if ![info exists parent_id] { - set parent_id [get_bcds_root_folder] - } + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + set item_id [db_exec_plsql create_template "SQL"] return $item_id } +ad_proc -public bcms::template::add_template { + {-template_id:required} + {-title:required} + {-description ""} + {-content ""} + {-creation_user_id} + {-creation_ip} +} { + adds a template revision +} { + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + + set revision_id [db_exec_plsql add_template "SQL"] + return $revision_id +} + +ad_proc -public bcms::template::list_templates { + {-parent_id:required} + {-revision latest} + {-multirow_name bcms_list_templates} + {-return_list:boolean} +} { + list the template under a folder, since templates a bit different we can't use + the general item::list_items call + + @param parent_id id of the which contents you wish to list, normally a folder + @param multirow_name you can supply your own multirow name + @param return_list if supplied a list of ns_sets otherwise it + returns a multirow uses the multirow_name if given + + @returns rows of content items below the parent_id + with the following columns: + + template_id, name, live_revision, latest_revision, publish_status, content_type, storage_type, tree_sortkey, + title, description + +} { + + if {[string equal $revision "latest"]} { + set revision "i.latest_revision" + } elseif {[string equal $revision "live"]} { + set revision "i.live_revision" + } else { + error "invalid revision value, valid values are live or latest" + } + + if {$return_list_p} { + # return a list of lists since its not easy to pass multirow from proc to proc + return [db_list_of_ns_sets list_templates "SQL"] + } else { + # make a multirow, it is likely that this proc is not being called from another proc + db_multirow $multirow_name list_templates "SQL" + } + +} + + ad_proc -public bcms::template::delete_template { {-template_id:required} } { Index: openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 27 Aug 2003 17:23:27 -0000 1.3 @@ -140,20 +140,55 @@ ad_proc -public bcms::widget::item_context { - -item_id:required - {-append_list {}} + {-item_id:required} + {-root_id} } { creates a list based the folder it resides that can be used as context or trail. @param item_id id of which item to get a context + @param root_id start from which id @returns a list in {{url label} {url label}} format } { set root_url [ad_conn package_url] - set root_id [bcms::folder::get_bcms_root_folder] + if {![info exists root_id]} { + set root_id [bcms::folder::get_bcms_root_folder] + } return [bcms::widget::extract_values -list_of_ns_sets \ [bcms::item::get_item_path -item_id $item_id -root_id $root_id -prepend_path "$root_url" -return_list] \ -keys_to_extract {path title}] } + + +ad_proc -public bcms::widget::category_context { + {-category_id:required} + {-root_id} +} { + creates a list category listing from the root_id to the category_id + + @param category_id id of which item to get a context + @param root_id start from which id + + @returns a list in {{url label} {url label}} format +} { + + if {![info exists root_id]} { + # if the root_id does not exists then start from the root + array set root [bcms::category::get_root -category_id $category_id] + if {[array size root] > 0} { + set root_id $root(category_id) + } else { + ns_log notice "bcms: category does not exists" + } + } + + set root_url [ad_conn package_url] + set root_url [string range $root_url 0 [expr [string length $root_url] - 2]] + + return [bcms::widget::extract_values -list_of_ns_sets \ + [bcms::category::get_category_path -category_id $category_id -root_id $root_id -prepend_path "$root_url" -return_list] \ + -keys_to_extract {path heading}] +} +