东莞市连易网络科技有限公司
东莞市连易网络科技有限公司
  • 网站
  • 用户
  • 购物车
  • 购物车
  • 搜索
  • 网站
  • 用户
帮助
帮助
开发文档 书签
  • 用户文档
  • 开发文档
  • API文档
  • 提及
  • 标签
  • 更多
  • 取消
  • 新建
  • +开始
  • +UI 自定义
  • +外部集成
  • -插件/框架扩展
    • -插件
      • 异常和日志记录
      • 插件生命周期
      • -插件示例
        • 使用小组件从插件渲染内容
        • 公开数据给外部源
        • 公开配置选项
        • 创建动态
        • -创建自定义应用程序和内容
          • -向内容添加核心服务支持
            • 书签
            • 审核/滥用管理
            • 提及
            • 搜索
            • +标签
            • 点赞
            • 评论
        • 基于模板的电子邮件
        • 处理事件
        • 处理内容中的嵌入文件
        • 定义权限
        • 扩展规则支持
        • 文件交互
        • 文件查看器
        • 注册模板令牌
        • 管理依赖关系
        • 管理物理文件存储
        • 翻译插件文本
        • 通知
    • +设置开发环境
    • +进程 API

书签

IBookmarkableContentType 接口支持为内容添加书签。

为什么要使我的内容可添加书签?

对于用户来说,保存内容可能很重要。如果是计划用户,则用户可能希望返回到此内容并查看其更改。

创建一个 IBookmarkableContentType 插件

IBookmarkableContentType 在 Limyee.Core.dll 的 Limyee.Extensibility.Content.Version1 命名空间中定义。

请务必注意,可以在同一 IContentType 类中实现一个或多个核心服务。

此接口与其他接口类似,它要求您定义用户是否可以为内容添加书签或取消书签。如果内容支持书签,它还应该返回。在此示例中,我们随意选择了“读取组成员”权限,但可以在此处定义任何权限。

public bool CanBookmark(Guid contentId, int userId)
{
    return CanUseBookmarks(contentId, userId);
}

public bool CanUnBookmark(Guid contentId, int userId)
{
    return CanUseBookmarks(contentId, userId);
}

public bool SupportsBookmarks
{
    get { return true; }
}

private bool CanUseBookmarks(Guid contentId, int userId)
{
    var content = LinksData.GetLink(contentId);
    if (content == null) { return false; }

    var permission = Apis.Get<IPermissions>().Get(GroupPermission.ViewMembership, userId, content.ContentId, content.ContentTypeId);
    return permission.IsAllowed;
}

下面是完整示例。

using System;
using Limyee.Components;
using Limyee.Extensibility;
using Limyee.Extensibility.Api.Entities.Version1;
using Limyee.Extensibility.Api.Version1;
using Limyee.Extensibility.Content.Version1;
using IContent = Limyee.Extensibility.Content.Version1.IContent;

namespace Samples.Links
{
    public class LinkItemContentType : IContentType, IBookmarkableContentType
    {
        IContentStateChanges _contentState = null;

        #region IPlugin Members

        public string Description
        {
            get { return "Items in a Links collection"; }
        }

        public void Initialize()
        {
        
        }

        public string Name
        {
            get { return "Link Items"; }
        }
        
        #endregion

        #region IContentType Members

        public Guid[] ApplicationTypes
        {
            get { return new Guid[] { ContentTypes.LinksApplicationId }; }
        }

        public void AttachChangeEvents(IContentStateChanges stateChanges)
        {
            _contentState = stateChanges;
        }

        public Guid ContentTypeId
        {
            get { return ContentTypes.LinksItemId; }
        }

        public string ContentTypeName
        {
            get { return "Links Item"; }
        }

        public IContent Get(Guid contentId)
        {
            return LinksData.GetLink(contentId);
        }

        #endregion

        #region IBookmarkableContentType

        public bool CanBookmark(Guid contentId, int userId)
        {
            return CanUseBookmarks(contentId, userId);
        }

        public bool CanUnBookmark(Guid contentId, int userId)
        {
            return CanUseBookmarks(contentId, userId);
        }

        public bool SupportsBookmarks
        {
            get { return true; }
        }

        private bool CanUseBookmarks(Guid contentId, int userId)
        {
            var content = LinksData.GetLink(contentId);
            if (content == null) { return false; }

            var permission = Apis.Get<IPermissions>().Get(GroupPermission.ViewMembership, userId, content.ContentId, content.ContentTypeId);
            return permission.IsAllowed;
        }

        #endregion
    }
}

  • 分享
  • 历史
  • 更多
  • 取消
相关
推荐
Copyright © 2021 东莞市连易网络科技有限公司. All rights reserved.
Powered by Limyee Commerce System(3.0.0). © 2014 - 2025 Limyee Inc.