예제 #1
0
        private string Service_ContentFormLoad(object sender, ContentFormLoadEventArgs e)
        {
            if (!StringUtils.EqualsIgnoreCase(e.AttributeName, ContentAttribute.Identifier))
            {
                return(null);
            }

            e.Form.TryGetValue(ContentAttribute.Identifier, out var identifier);

            return($@"
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">信息分类</label>
    <div class=""col-sm-10"">
        {ContentRepository.GetCategoriesHtml(e.SiteId, e.ChannelId, e.Form)}
    </div>
    <div class=""col-sm-1"">
       
    </div>
</div>
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">索引号</label>
    <div class=""col-sm-6"">
        <input id=""displayOnly{ContentAttribute.Identifier}"" name=""displayOnly{ContentAttribute.Identifier}"" type=""text"" class=""form-control"" disabled=""disabled"" value=""{identifier}"">
        <input id=""{ContentAttribute.Identifier}"" name=""{ContentAttribute.Identifier}"" type=""hidden"" value=""{identifier}"">
    </div>
    <div class=""col-sm-5"">
       <span class=""form-text text-muted"">索引号由系统自动生成</span>
    </div>
</div>
                    ");
        }
예제 #2
0
        private string Service_ContentFormLoad(object sender, ContentFormLoadEventArgs e)
        {
            if (e.AttributeName == ContentAttribute.DepartmentId)
            {
                var departmentId = e.Form.GetString(nameof(ContentAttribute.DepartmentId));

                var ddlDepartmentId = new DropDownList
                {
                    ID       = ContentAttribute.DepartmentId,
                    CssClass = "form-control"
                };

                var departmentInfoList = DepartmentDao.GetDepartmentInfoList();

                foreach (var departmentInfo in departmentInfoList)
                {
                    var listItem = new ListItem(departmentInfo.DepartmentName, departmentInfo.Id.ToString());
                    ddlDepartmentId.Items.Add(listItem);
                }
                Utils.SelectSingleItem(ddlDepartmentId, departmentId);

                return($@"
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">提交部门</label>
    <div class=""col-sm-6"">
        {Utils.GetControlRenderHtml(ddlDepartmentId)}
    </div>
    <div class=""col-sm-5"">

    </div>
</div>");
            }

            return(string.Empty);
        }
예제 #3
0
 public bool OnContentFormLoad(ContentFormLoadEventArgs e, out string html)
 {
     html = null;
     if (ContentFormLoad == null)
     {
         return(false);
     }
     html = ContentFormLoad.Invoke(this, e);
     return(true);
 }
예제 #4
0
        protected override void Render(HtmlTextWriter output)
        {
            if (StyleInfoList == null || StyleInfoList.Count == 0 || Attributes == null)
            {
                return;
            }

            var pageScripts = new NameValueCollection();

            var builder = new StringBuilder();

            foreach (var styleInfo in StyleInfoList)
            {
                string extra;
                var    value = BackgroundInputTypeParser.Parse(SiteInfo, ChannelId, styleInfo, Attributes, pageScripts, out extra);

                if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra))
                {
                    continue;
                }

                if (styleInfo.InputType == InputType.TextEditor)
                {
                    var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName);
                    builder.Append($@"
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">{styleInfo.DisplayName}</label>
    <div class=""col-sm-10"">
        {commands}
        <div class=""m-t-10"">
            {value}
        </div>
    </div>
    <div class=""col-sm-1"">
        {extra}
    </div>
</div>");
                }
                else
                {
                    var html = $@"
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">{styleInfo.DisplayName}</label>
    <div class=""col-sm-6"">
        {value}
    </div>
    <div class=""col-sm-5"">
        {extra}
    </div>
</div>";

                    if (styleInfo.InputType == InputType.Customize)
                    {
                        var eventArgs = new ContentFormLoadEventArgs(SiteInfo.Id, ChannelId, styleInfo.AttributeName, Attributes);
                        foreach (var service in PluginManager.Services)
                        {
                            try
                            {
                                var serviceReturnedHtml = service.OnContentFormLoad(eventArgs);
                                if (!string.IsNullOrEmpty(serviceReturnedHtml))
                                {
                                    html = serviceReturnedHtml;
                                }
                            }
                            catch (Exception ex)
                            {
                                LogUtils.AddPluginErrorLog(service.PluginId, ex, nameof(IService.ContentFormLoad));
                            }
                        }
                    }

                    builder.Append(html);
                }
            }

            output.Write(builder.ToString());

            foreach (string key in pageScripts.Keys)
            {
                output.Write(pageScripts[key]);
            }
        }
예제 #5
0
 public string OnContentFormLoad(ContentFormLoadEventArgs e)
 {
     return(ContentFormLoad?.Invoke(this, e));
 }