Index: openacs-4/packages/acs-content-repository/www/doc/guide/revisions.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/www/doc/guide/revisions.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/www/doc/guide/revisions.adp 27 Oct 2014 16:39:15 -0000 1.2 +++ openacs-4/packages/acs-content-repository/www/doc/guide/revisions.adp 7 Aug 2017 23:47:47 -0000 1.3 @@ -1,40 +1,49 @@ -{/doc/acs-content-repository {Content Repository}} {Content Repository Developer Guide: Creating Content +{/doc/acs-content-repository {ACS Content Repository}} {Content Repository Developer Guide: Creating Content Revisions} Content Repository Developer Guide: Creating Content Revisions - - -

Creating Content Revisions

At a basic level, creating a new revision of a content item -involves the following steps:

    -
  1. Insert a row in the acs_objects table to create the -object.
  2. Insert a corresponding row in the cr_revisions table -with the basic attributes for the revision.
  3. Write the content data into the content BLOB column of -the cr_revisions table.
  4. Insert a corresponding row into the attribute table of each +

    Creating Content Revisions

    + +ACS Documentation : Content Repository : Developer Guide +

    At a basic level, creating a new revision of a content item +involves the following steps:

    +
      +
    1. Insert a row in the acs_objects table to create the +object.
    2. Insert a corresponding row in the cr_revisions table +with the basic attributes for the revision.
    3. Write the content data into the content BLOB column +of the cr_revisions table.
    4. Insert a corresponding row into the attribute table of each ancestor of the content type of the item. This is not applicable if -the content type is Basic Item or an immediate subtype -thereof.
    5. Insert a corresponding row into the attribute table of the +the content type is Basic Item or an immediate +subtype thereof.
    6. Insert a corresponding row into the attribute table of the content type of the item. This is not applicable if the content -type is Basic Item.
    7. -

    Use the Content Revision API to create a revision

    Content revisions are initialized using the -content_revision.new function. The only parameters +type is Basic Item.

  5. +
+

Use the Content Revision API to create a revision

+

Content revisions are initialized using the +content_revision.new function. The only parameters required to create the revision are a title, a content item ID, and -some text:

+some text:

+
 revision_id := content_revision.new( 
     title   => 'A Revision',
     item_id => :item_id,
     text    => 'Once upon a time Goldilocks crossed the street.
                 Here comes a car...uh oh!  The End'
 );
-

The item_id parameter is ID of the content item with -which the revision is associated.

The content_item.new function accepts a number of other -optional parameters: description, mime_type, and -publish_date. The standard creation_date, -creation_user, and creation_ip should be -specified for auditing purposes. Instead of the text -parameter, this function can be called with a data -parameter, in which data is a blob:

+
+

The item_id parameter is ID of the content item with +which the revision is associated.

+

The content_item.new function accepts a number of +other optional parameters: description, +mime_type, and publish_date. The standard +creation_date, creation_user, and +creation_ip should be specified for auditing purposes. +Instead of the text parameter, this function can be +called with a data parameter, in which data +is a blob:

+
 revision_id := content_revision.new(
     title         => 'A Revision',
     description   => 'A Description of a revision',
@@ -46,54 +55,70 @@
     creation_user => :user_id,
     creation_ip   => :ip_address
 );
-

Insert additional attributes

Given that there is no way (AFAIK) to pass variable parameters +

+

Insert additional attributes

+

Given that there is no way (AFAIK) to pass variable parameters to a PL/SQL function, there is no way to make -content_revision.new generic enough to support submission -of the attributes for all different content types. This leaves you -with three alternatives:

    -
  1. Call content_revision.new followed by manual DML +content_revision.new generic enough to support +submission of the attributes for all different content types. This +leaves you with three alternatives:

    +
      +
    1. Call content_revision.new followed by manual DML statements to write data into the content BLOB and insert attributes.
    2. Write a PL/SQL package for each of your content types, which encapsulates the above code.
    3. Create revisions by inserting into the attribute view for each content type.
    4. -

    The last option is made possible by an instead of -insert trigger on the attribute view for each content type. +

+

The last option is made possible by an instead of +insert trigger on the attribute view for each content type. (An attribute view joins together the storage tables for -the ancestors of each content type, including acs_objects -and cr_revisions). Normally it is not possible to insert -into a view. Oracle allows you to create an instead of -trigger for a view, however, which intercepts the DML statement and -allows you to execute an arbitrary block of PL/SQL instead. The -code to create or replace the trigger is automatically generated -and executed with each call to -content_type.create_attribute. The trigger makes it +the ancestors of each content type, including +acs_objects and cr_revisions). Normally it is +not possible to insert into a view. Oracle allows you to create an +instead of trigger for a view, however, which intercepts +the DML statement and allows you to execute an arbitrary block of +PL/SQL instead. The code to create or replace the trigger is +automatically generated and executed with each call to +content_type.create_attribute. The trigger makes it possible to create complete revisions with a single insert -statement:

+statement:

+
 insert into cr_revisionsx (
   item_id, revision_id, title
 ) values (
   18, 19, 'All About Revisions'
 );
-

Because a special trigger is generated for each content type +

+

Because a special trigger is generated for each content type that includes insert statements for all inherited tables, revisions -with extended attributes may be created in the same fashion:

+with extended attributes may be created in the same fashion:

+
 insert into cr_imagesx (
   item_id, revision_id, title, height, width
 ) values (
   18, 19, 'A Nice Drawing', 300, 400
 );
-

Inserting content via file or text upload

Selecting a live revision

The live revision of a content item can be obtained with the -content_item.get_live_revision function:

+
+

Inserting content via file or text upload

+

Selecting a live revision

+

The live revision of a content item can be obtained with the +content_item.get_live_revision function:

+
 live_revision_id := content_item.get_live_revision(
     item_id => :item_id
 );
-

The item_id identifies the content item with which the -revision is associated.

Likewise, the most recent revision of a content item can be -obtained with the content_item.get_latest_revision -function:

+
+

The item_id identifies the content item with which +the revision is associated.

+

Likewise, the most recent revision of a content item can be +obtained with the content_item.get_latest_revision +function:

+
 latest_revision_id := content_item.get_latest_revision(
     item_id => :item_id
 );
-

karlg@arsdigita.com

Last Modified: $Id: revisions.html,v 1.1.1.1 2001/03/13 22:59:26 -ben Exp $

- +
+
+karlg\@arsdigita.com +

Last Modified: $‌Id: revisions.html,v 1.1.1.1.30.1 2016/06/22 +07:40:41 gustafn Exp $