在Alfresco 4中添加自定义操作规则

时间:2013-06-10 10:10:01

标签: java alfresco alfresco-share

我是露天新手。我正在尝试在露天做以下任务,并反映露天份额的修改。 我想要做的是创建一个名为XCopy的新规则 - 动作,这与复制功能相同。唯一不同的是名字。应该可以附加为给定文件夹定义的规则,并且应该接受要复制的文件位置。

我对alfresco模块中的弹簧配置没问题。但我对共享模块配置感到困惑。任何人都可以建议我将自定义操作添加到共享中吗? 感谢。

1 个答案:

答案 0 :(得分:4)

您必须通过将相同的文件复制到具有相同文件夹结构的Web扩展来自定义位于site-webscripts \ org \ alfresco \ components \ rules \ config的rule-config-action.get.config.xml。在< menu>< group>中添加自定义操作然后在< customize>中 比方说,

<group>
   <action name="copy"/>
   <action name="move"/>
    <action name="xcopy"/>
</group>
<customise>
      <item id="select">Select</item>
       ......
      <action name="copy">Copy</action>
      <action name="move">Move</action>
      <action name="xcopy">CreateLinkToDocument</action>    <!--xcopy should be id of spring bean configured as action-executer -->
</customise>

在rule-details.get.head.ftl和rule-edit.get.head.ftl中添加自定义javascript js

<!--Custom javascript file include for detail mode -->
<@script type="text/javascript" src="${page.url.context}/test/components/rules/config/rule-config-action-custom.js"></@script>

在share root文件夹下的test / components / rules / config文件夹中创建rule-config-action-custom.js

在if,

中打开文件选择器,添加以下代码
if (typeof SomeCo == "undefined" || !SomeCo)
{
   var SomeCo = {};
}

/**
 * RuleConfigActionCustom.
 *
 * @namespace SomeCo
 * @class SomeCo.RuleConfigActionCustom
 */
(function()
{

   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom,
      Selector = YAHOO.util.Selector,
      Event = YAHOO.util.Event;

   /**
    * Alfresco Slingshot aliases
    */
    var $html = Alfresco.util.encodeHTML,
       $hasEventInterest = Alfresco.util.hasEventInterest;

   SomeCo.RuleConfigActionCustom = function(htmlId)
   {
      SomeCo.RuleConfigActionCustom.superclass.constructor.call(this, htmlId);

      // Re-register with our own name
      this.name = "SomeCo.RuleConfigActionCustom";
      Alfresco.util.ComponentManager.reregister(this);

      // Instance variables
      this.customisations = YAHOO.lang.merge(this.customisations, SomeCo.RuleConfigActionCustom.superclass.customisations);
      this.renderers = YAHOO.lang.merge(this.renderers, SomeCo.RuleConfigActionCustom.superclass.renderers);

      return this;
   };

   YAHOO.extend(SomeCo.RuleConfigActionCustom, Alfresco.RuleConfigAction,
   {

      /**
       * CUSTOMISATIONS
       */

      customisations:
      {         
          CreateLinkToDocument:
         {
            text: function(configDef, ruleConfig, configEl)
            {
                 // Display as path
                 this._getParamDef(configDef, "destination-folder")._type = "path";
                 return configDef;
            },
            edit: function(configDef, ruleConfig, configEl)
            {
                // Hide all parameters since we are using a cusotm ui but set default values
                this._hideParameters(configDef.parameterDefinitions);

                // Make parameter renderer create a "Destination" button that displays an destination folder browser
                configDef.parameterDefinitions.push({
                   type: "arca:destination-dialog-button",
                   displayLabel: this.msg("label.to"),
                   _buttonLabel: this.msg("button.select-folder"),
                   _destinationParam: "destination-folder"
                });
                return configDef;
            }
         },
      },

   });

})();

选中此项以供参考:http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf

如果您需要更多帮助,请告知我们