Standards used in BCMS

This document gives a guideline what was used in bcms. There maybe exceptions but more or less the following standards was followed.

Tcl proc naming

As much as possible i used a standard set of names.

create_X, get_X, set_X, delete_X, list_Xs, tree_Xs.

For example: create_folder, get_folder, set_folder, delete_folder, list_folders, tree_folders.


create_X – is to create an object (e.g. Item, revision, folder, etc.)

get_X – is to get an object and its properties

set_X – is to modify/edit an object and its properties

delete_X – is to delete an object

list_Xs – is to list all objects under a particular item item. Like list all folders under CR root folder.

tree_Xs – is similar to list_Xs but will list objects under sub folders too. Normally there is a parameter to set how deep to traverse the folders.


ad_proc switches are used

ad_procs's switches are used to pass in parameters. This means ad_procs are defined this way:



ad_proc mynamespace::myproc {

{-param1:required}

{-param2 “default value”}

{-abooleanparam:boolean}

} {

api doc goes here

}



get_X returns an array

get_X is used to get an object and its properties. An array is returned. An example on using get_X is:



array set one_page [bcms::item::get_item -item_id $page_id -revision latest]



after this call you will now have $one_page(title), $one_page(name), etc.



create_X returns object id

When create_X is called the object id is normally returned. ex.



set revision_id [bcms::revision::add_revision -item_id $page_id \

-title $title -content $content -description $description \

-mime_type "text/html" \

-creation_user_id $creation_user_id -creation_ip $creation_ip]



set_X and delete_X returns status results

Normally set_X and delete_X calls will return a status. ex.



if [bcms::folder::delete_folder -folder_id $folder_id] {

ad_returnredirect $return_url

}



list_X and tree_X either returns a multirow or list of ns sets

Using list_X and tree_X you have the option to return a multirow or a list of ns_sets. By default it returns a multirow, if if a -multirow_name is not supplied it uses a default name.

ex of multirow

bcms::item::list_related_items -item_id $page_id -relation_tag $relation_tag -revision latest -multirow_name related_items

ex of list of ns sets

set folder_option_list [bcms::widget::option_tree -list_of_ns_sets \

[bcms::folder::tree_folders -return_list] \

-value_column folder_id -display_columns label]