Инструменты пользователя

Инструменты сайта


limb2:en:content_objects_version_control

Content objects version control

Every Limb content object supports versioning. When the user changes the content object (like article, document), the object's version number is increased and the full object copy is saved in db. Some form has 'minor_chages' flag that can tell the edit action not to create new version of object.

For instance version control panel for the document you're reading might look as follows:

Update method of the content object receives a boolean flag whether it's required to create the new version or not:

  content_object :: update((bool) $new_version);

At the moment the default version behaviour can be overriden by creating a form_edit_site_object_action de's descendant and replacing its _update_object_operation() method:

class your_action extends form_edit_site_object_action
{
    [...]
    function _update_object_operation()
    {
        if(!$this->object->update(false))
            return false;
        else
            return true;
    }
}

To browse the list of versions of an object and to be able to examine the object's state for any version you need to add an extra action to content object controller:

class document_controller extends site_object_controller
{
    function _define_actions() 
    {
        return array(
        [...]
          'admin_detail' => array(
             'template_path' => '/admin/object_detail_info.html',
             'popup' => true,
             'JIP' => true,
             'img_src' => '/shared/images/admin_detail.gif',
             'action_name' => strings :: get('detail_info'),
          ),
        );
    }
}

System 'object_detail_info.html' template renders content object system information and the versions list.

To be able to recover version or to see all content object's attributes for any version you need to have the access to the /root/version site object(to the display and recover actions in particular).

Recover action – creates a new version of the content object based on the version you provide, e.g. if you recover version 5 and the current version is 7, then the 5-th version is copied to the new 8 version.

The Limb2 versioning is at the very initial stage. It provides a simple yet effective solution for the domain of simple objects. Any complexity requires manual handling though.

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
  ____    __  ___  _      __  _      __   ___ 
 / __ \  /  |/  / | | /| / / | | /| / /  / _ |
/ /_/ / / /|_/ /  | |/ |/ /  | |/ |/ /  / __ |
\___\_\/_/  /_/   |__/|__/   |__/|__/  /_/ |_|
 
limb2/en/content_objects_version_control.txt · Последние изменения: 2010/11/10 10:02 (внешнее изменение)