content::item::get_revision_content (public)

 content::item::get_revision_content -revision_id revision_id \
    [ -item_id item_id ]

Defined in packages/acs-content-repository/tcl/content-item-procs.tcl

Create a one-row datasource called content in the calling frame which contains all attributes for the revision (including inherited ones). The datasource will contain a column called "text", representing the main content (blob) of the revision, but only if the revision has a textual mime-type.

Switches:
-revision_id
(required)
The revision whose attributes are to be retrieved
-item_id
(optional)
The item_id of the corresponding item.
Returns:
1 on success (and create a content array in the calling frame), 0 on failure
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 content::item::get_content content::item::get_content (public) content::item::get_revision_content content::item::get_revision_content content::item::get_content->content::item::get_revision_content acs_object_type::get_table_name acs_object_type::get_table_name (public) content::item::get_revision_content->acs_object_type::get_table_name content::revision::item_id content::revision::item_id (public) content::item::get_revision_content->content::revision::item_id db_0or1row db_0or1row (public) content::item::get_revision_content->db_0or1row db_1row db_1row (public) content::item::get_revision_content->db_1row db_map db_map (public) content::item::get_revision_content->db_map

Testcases:
No testcase defined.
Source code:

  if { ![info exists item_id] } {
      # Get the item id
      set item_id [::content::revision::item_id -revision_id $revision_id]

      if { $item_id eq "" } {
          ns_log warning "item::get_revision_content: No such revision: $revision_id"
          return 0
      }
  }

  # Get the "mime_type" from the revision to decide if we want the
  # "text" in the result.  The "content_type" is needed for obtaining
  # the table_name later.
  db_1row get_mime_and_content_type_from_revision {
      select mime_type, object_type as content_type
      from cr_revisionsx
      where revision_id = :revision_id
  }

  if { $mime_type ne "" && [string match "text/*" $mime_type]} {
      set text_sql [db_map grc_get_all_content_1]
  } else {
      set text_sql ""
  }

  # Get the table name
  set table_name [acs_object_type::get_table_name -object_type $content_type]

  upvar content content

  # Get (all) the content (note this is really dependent on file type)
  db_0or1row grc_get_all_content [subst {
      select x.*,
         :item_id as item_id $text_sql,
         :content_type as content_type
      from  cr_revisions r, ${table_name}x x
      where r.revision_id = :revision_id
      and   x.revision_id = r.revision_id
  }] -column_array content

  if { ![array exists content] } {
    ns_log warning "item::get_revision_content: No data found for item $item_id, revision $revision_id"
    return 0
  }

  return 1
Generic 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

[ hide source ] | [ make this the default ]
Show another procedure: