- turn on the relation order_n column
- check that displayed names are using either the title or label
- add api on the folder-list to exclude a particular folder
- review all ns_log and properly set the sevirity level
  - Notice, Warning, Error, Fatal, Bug, Debug
- do make procs to construct the addtnl_where
- possible construct the addthnl_select too
- what do we do if the index page is delete?
- report OpenACS bug that its possible to insert to a view and the item_id is not the same content type, for example i inserted with the item_id to be a content folder
- review all ad_page_contract var so that they are all uniform set optional id var to ""
- bring back the support for lob binary items
- merge/refactor bcms::item::list_items/tree_items, etc.
- review all ad_proc, maybe too much {}s
- change all tree_ancestor_p calls to a subselect of tree_ancestor_keys and compare
it.  see file-storage-procs-postgresql.xql
- move templates to /templates



changes 3/3/2003

- move from bcms::get_cr_folder_root -> bcms::folder::get_cr_root_folder
- move from bcms::make_option_list -> bcms::widget::option_list
- move from bcms::make_option_list_trail -> bcms::widget::option_tree
- move from bcms::item::edit_item -> bcms::item::set_item
- move from bcms::item::list_items_with_ancestors -> bcms::item::tree_items
- move from bcms::folder::edit_folder -> bcms::folder::set_folder
- move from bcms::folder::list_folders_with_ancestors -> bcms::folder::tree_folders
- move from bcms::revision::revision_create_in_text -> bcms::revision::add_revision
- move from bcms::revision::revision_creare_in_fs -> bcms::revision::upload_file_revision
- move from bcms::revision::edit_revision -> bcms::revision::set_revision
- move from bcds::get_template -> bcms::template::get_template

fully implement the folder_id rather than package_id

items for changes 3/3/2003 are done


changes 7/24/2003

- change bcms::item::list_items remove the -level_diff and -revision now defaults to latest
 remove on return results revision_id and publish date
 -content_type now defaults to content_revision
 added -additional_columns
- change bcms__get_title call latest_revision -> latest, live_revision -> live
- change admin file from foo_bar to foo-bar
- change bcms::item::get_item_by_url -resolve_index change to boolean and default is now false
- depracated bcms::widget::option_list
- change bcms::folder::list_folders remove -level_diff
- change tree_X api, to just include path and not return the extra rows to build the path
- change bcms::revision::revision_list to bcms::revision::list_revisions
- added several new procs
- depracated bcms::folder::get_bcms_root_folder



procs that are moved out of bcms


# for possible contribution
ad_proc -public bcms::wizard_step { 
    {-back:boolean false}
    {-set_param_list}
} {
    creates the url for the wizard 

    -set_param_list is a list of parameters that you would like to set in the
    wizard.  It must be in a form of "varname value" pairs
} {
    # build the parameter list
    if [info exists set_param_list] {
        for {set i 0} {$i < [llength $set_param_list]} {set i [expr $i + 2]} {
            template::wizard set_param [lindex $set_param_list $i] \
                [lindex $set_param_list [expr $i + 1]]
        }
    }

    if {$back_p} {set step_no -1} else {set step_no 1}
    return [template::wizard::get_forward_url [expr [template::wizard current_step] + $step_no]]
}


# TODO: move this out of bcms?  Since this is a UI specific requirement
ad_proc -public bcms::init_bcms {
    -root_folder:required
    -root_folder_label:required
    {-description ""}
} {
    Makes a new bcms instance. creates the root folder and default subfolders
    then registers the content types, creates also an index page on the pages folder
} {
    set cr_folder_root [bcms::folder::get_cr_root_folder]

    db_transaction {

        # create the root folder
        set root_folder_id [bcms::folder::create_folder -name $root_folder \
                                -folder_label $root_folder_label -parent_id $cr_folder_root \
                                -description $description]

        # register the content types to the folders
        # we register the content type to the root folder to be flexible
        # even though we have created the default folders
        register_content_type -folder_id $root_folder_id -content_type bcms_page
        register_content_type -folder_id $root_folder_id -content_type bcms_file

        # bind this package instance to that cr_folder
        # we are going to populate the root bcms package_id column only
        set package_id [ad_conn package_id]
        db_dml update_package_id "SQL"

        # create the default subfolders
        set pages_folder_id [bcms::folder::create_folder -name "pages" \
                                 -folder_label "Pages" -parent_id $root_folder_id \
                                 -description "This folder holds web pages"]
        set images_folder_id [bcms::folder::create_folder -name "images" \
                                  -folder_label "Images" -parent_id $root_folder_id \
                                  -description "This folder holds images"]
        set files_folder_id [bcms::folder::create_folder -name "files" -folder_label "Files" \
                                 -parent_id $root_folder_id \
                                  -description "This folder holds files"]

        # create the index page for the folder
        set item_id [bcms::item::create_item -item_name index -parent_id $pages_folder_id \
                         -content_type bcms_page -storage_type text]

        # create an initial revision that is blank
        set revision_id [bcms::revision::revision_create_in_text -item_id $item_id \
                             -title $root_folder_label -content "" -description $description \
                             -mime_type "text/html" ]

        # create the template folder
        set template_folder_id [bcms::folder::create_folder -name $root_folder \
                                    -folder_label $root_folder_label -parent_id [bcds::get_cr_template_root] \
                                    -description $description]
        parameter::set_value -parameter template_folder_id -value $template_folder_id

    }
    ns_log notice "bcms::init created root folder id $root_folder_id"
}



# TODO move this out, this is too specific
ad_proc -public bcms::item::list_pages {
    {-parent_id:required}
    {-revision latest}
    {-multirow_name}
    {-return_list:boolean false}
} {
    returns a list of pages under the parent_id.  it also gets the latest
    or live pages with index name on the folder under parent_id. if revision
    is not specified then we will just get the folder label

    returns item_id, name, publish_status, content_type, storage_type, title

    TODO: will need to merge this with list_items
    I think we really need to rethink what this proc really want to do,
    confusing proc, gets pages and folders, get live... latest etc.
} {
    switch -exact $revision {
        latest { 
            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') as title, content_folder__get_label(i.item_id) as folder_label" 
        }
        default { 
            ns_log debug "bcms: revision requested not valid" 
            return
        }
    }

    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_pages "SQL"]
    } else {
        # make a multirow, it is likely that this proc is not being called from another proc
        if ![info exists multirow_name] { set multirow_name bcms_list_pages }
        db_multirow $multirow_name get_pages "SQL"
    }

}


# TODO move this out, this is too specific
ad_proc -public bcms::item::list_images {
    {-parent_id:required}
    {-live_items:boolean false}
    {-level_diff 0}
    {-multirow_name}
    {-return_list:boolean false}
} {
    list the images related to a content item which is the parent_id
} {
    if {$return_list_p} {
        # return a list of lists since its not easy to pass multirow from proc to proc
        return [list_items -parent_id $parent_id -content_type image -level_diff $level_diff -return_list]
    } else {
        # make a multirow, it is likely that this proc is not being called from another proc
        if ![info exists multirow_name] { set multirow_name bcms_list_images }
        list_items -parent_id $parent_id -content_type image -level_diff $level_diff -multirow_name $multirow_name
    }

}

# TODO move this out, this is too specific
ad_proc -public bcms::item::list_files {
    {-parent_id:required}
    {-live_items:boolean false}
    {-level_diff 0}
    {-multirow_name}
    {-return_list:boolean false}
} {
    list the files related to a content item which is the parent_id
} {
    if {$return_list_p} {
        # return a list of lists since its not easy to pass multirow from proc to proc
        return [list_items -parent_id $parent_id -content_type bcms_file -level_diff $level_diff -return_list]
    } else {
        # make a multirow, it is likely that this proc is not being called from another proc
        if ![info exists multirow_name] { set multirow_name bcms_list_files }
        list_items -parent_id $parent_id -content_type bcms_file -level_diff $level_diff -multirow_name $multirow_name
    }

}


# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_image_folder { } {
    returns the folder_id of the image folder of this bcms instance
} {
    array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url images -resolve_index false]
    return $one_item(item_id)
}

# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_file_folder { } {
    returns the folder_id of the file folder of this bcms instance
} {
    array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url files -resolve_index false]
    return $one_item(item_id)
}

# TODO: to be removed not a general proc
ad_proc -public bcms::folder::get_page_folder { } {
    returns the folder_id of the page folder of this bcms instance
} {
    array set one_item [bcms::item::get_item_by_url -root_id [get_bcms_root_folder] -url pages -resolve_index false]
    return $one_item(item_id)
}
