Forum OpenACS Development: Re: i18n of content repository content: Ideal API

Collapse
Posted by Malte Sussdorff on
I gave some thought to a TCL API for the CR to do what I need. I'm explicitly missing some functionality the CR gives, which does not mean I don't want them included. I just limit myself to the things needed with regards to I18N.
  • Create new content (cr_item_create): This function will allow us to store new content in the CR, either as a new version, a new translation or a new revision. The API will be smart enough to detect the users wishes based on the information given. Switches:
    • -content_type: Content type of the item we want to create. This also defines what additional switches need to be given. Optional if -item_id is given.
    • -item_id: If supplied the system assumes we want to store a new revision of the cr_item, otherwise it will create a new item.
    • -language: Defines the language of the item, defaults to the system language. If item_id is given as well, check if the language stored with the item_id matches. If yes, assume it is a new revision, if not, create a new item with the parent_id "item_id" (if done via rels or any other method should not concern the API).
    • -xxx: All the switches necessary e.g. for the category system.
    • -yyyy: All the switches necessary to fill the attributes of the content_type. If a not optional value is missing, throw an error.

  • Change live version: This function will define the live version. It only has to be called if the live version differentiates from the latest version (and we have versioned items in the first place).
    • -item_id: Item we want to change the live version for.
    • -revision_id: Revision of the "to be live" version.
    • -language: If given, this changes the "master" version. Usefull if you realize that the dutch version changes more often than the "master" french version and you want to display the dutch version on your page by default instead.

  • Retrieve content: This function will retrieve the content of an item and put it automatically into variables in the callers context. As an additional benefit the variable cr_attributes in the callers context will contain a list of the variables set.
    • -item_id
    • -language: Language version of the item_id. If the item_id is not the master item_id for translations and the language does not match the item_id, try to find the corresponding item_id, by going up one level to the master_item and look from there for the language. (optional)
    • -revision_id: Always return the live_revision unless the revision_id is given. In this case just return this revision. (optional)
    • -attributes: List of attributes that should be set as variables in the callers context. If {all} is given, return all.
Okay, this is a very rough sketch, maybe it helps, maybe it doesn't and hopefully I just missed something and it already exists 😊.