content::item::new (public)
content::item::new -name name [ -parent_id parent_id ] \ [ -item_id item_id ] [ -locale locale ] \ [ -creation_date creation_date ] [ -creation_user creation_user ] \ [ -context_id context_id ] [ -package_id package_id ] \ [ -creation_ip creation_ip ] [ -item_subtype item_subtype ] \ [ -content_type content_type ] [ -title title ] \ [ -description description ] [ -mime_type mime_type ] \ [ -nls_language nls_language ] [ -text text ] [ -data data ] \ [ -relation_tag relation_tag ] [ -is_live is_live ] \ [ -storage_type storage_type ] [ -attributes attributes ] \ [ -tmp_filename tmp_filename ]
Defined in packages/acs-content-repository/tcl/content-item-procs.tcl
Create a new content item This proc creates versioned content items where content_type iscontent_revision or subtypes of content revision. There are procedures for each other base content item. This procedure uses package_instantiate object. Under PostgreSQL the object_type new function must be registered with define_function_args.
- Switches:
- -name (required)
- name of the item, must be unique for the folder
- -parent_id (optional)
- parent object of this content_item
- -item_id (optional)
- item_id of this content_item. If this is not specified an item_id will be generated automatically
- -locale (optional)
- -
- -creation_date (optional)
- defaults to current date and time
- -creation_user (optional)
- -
- -context_id (optional)
- Context of the item. usually used in conjunction with permissions.
- -package_id (optional)
- Package ID of the object
- -creation_ip (optional)
- -
- -item_subtype (optional, defaults to
"content_item"
)- -content_type (optional, defaults to
"content_revision"
)- content_revision or subtype of content_revision
- -title (optional)
- - title of content_revision to be created
- -description (optional)
- of content_revision to be created
- -mime_type (optional)
- -nls_language (optional)
- - ???
- -text (optional)
- - text of content revision to be created
- -data (optional)
- - ???
- -relation_tag (optional)
- -is_live (optional, defaults to
"f"
)- -storage_type (optional, defaults to
"file"
)- file, lob, or text (postgresql only)
- -attributes (optional)
- A list of lists of pairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value such as [list [list attribute value] [list attribute value]]
- -tmp_filename (optional)
- file containing content to be added to new revision. Caller is responsible to handle cleaning up the temporary file
- Returns:
- item_id of the new content item
- Author:
- Dave Bauer <dave@thedesignexperience.org>
- Created:
- 2004-05-28
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- content_image, content_item, content_item_nested_structure, content_revision, cr_item_search_triggers, data_links_update_links, data_links_update_links_with_tag, data_links_with_tag
Source code: if {$creation_user eq ""} { set creation_user [ad_conn user_id] } if {$creation_ip eq ""} { set creation_ip [ad_conn peeraddr] } if {$package_id eq ""} { set package_id [ad_conn package_id] } set mime_type [cr_check_mime_type -filename $name -mime_type $mime_type -file $tmp_filename] set var_list [list] lappend var_list [list name $name] [list parent_id $parent_id ] [list item_id $item_id ] [list locale $locale ] [list creation_date $creation_date ] [list creation_user $creation_user ] [list context_id $context_id ] [list package_id $package_id ] [list creation_ip $creation_ip ] [list item_subtype $item_subtype ] [list content_type $content_type ] [list mime_type $mime_type ] [list nls_language $nls_language ] [list relation_tag $relation_tag ] [list is_live $is_live ] [list storage_type $storage_type] # we don't pass title, text, or data to content_item__new because # the magic revision creation of the pl/sql proc does not create a # proper subtype of content revision, also it can't set attributes # of an extended type # the content type is not the object type of the cr_item so we # pass in the cr_item subtype here and content_type as part of # var_list db_transaction { # An explicit lock was necessary for PostgreSQL between 8.0 and # 8.2; left the following statement here for documentary # purposes # # db_dml lock_objects "LOCK TABLE acs_objects IN SHARE ROW EXCLUSIVE MODE" set item_id [package_exec_plsql -var_list $var_list content_item new] # if we have attributes we pass in everything and create a # revision with all subtype attributes that were passed in # since we can't rely on content_item__new to create a # revision we have to pass is_live to content::revision::new # and set the live revision there if {$title ne "" || $text ne "" || $data ne "" || $tmp_filename ne "" || [llength $attributes] } { content::revision::new -item_id $item_id -title $title -description $description -content $text -mime_type $mime_type -content_type $content_type -is_live $is_live -package_id $package_id -creation_user $creation_user -creation_ip $creation_ip -creation_date $creation_date -nls_language $nls_language -tmp_filename $tmp_filename -attributes $attributes } } return $item_idGeneric XQL file: packages/acs-content-repository/tcl/content-item-procs.xql
PostgreSQL XQL file: packages/acs-content-repository/tcl/content-item-procs-postgresql.xql
Oracle XQL file: packages/acs-content-repository/tcl/content-item-procs-oracle.xql