示例#1
0
        protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SettingEntity ThemeSetting = (e.Item.DataItem as SettingEntity).Clone();

                KeyValueEntity KeyValue = ItemValues.Find(r1 => r1.Key == ThemeSetting.Name);
                if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
                {
                    ThemeSetting.DefaultValue = KeyValue.Value.ToString();
                }

                //构造输入控件
                PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder;

                #region "创建控件"
                ControlHelper ctl = new ControlHelper(this);

                ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting));
                #endregion

                Literal liTitle = e.Item.FindControl("liTitle") as Literal;
                liTitle.Text = ViewTitleAndHelp(ThemeSetting);


                if (!String.IsNullOrEmpty(ThemeSetting.Description))
                {
                    Literal liHelp = e.Item.FindControl("liHelp") as Literal;
                    liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateCheckBox(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<label class=\"checkbox-inline\" for=\"{0}\">", ControlID);

            ControlHtml.AppendFormat("<input type=\"checkbox\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            ControlHtml.AppendFormat(" class=\"square-green grey {0}\"", ViewVerification(FieldItem));

            if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                Boolean DefaultValue, b; DefaultValue = b = false;
                if (FieldItem.DefaultValue == "1" || FieldItem.DefaultValue.Equals(Boolean.TrueString, StringComparison.CurrentCultureIgnoreCase))
                {
                    DefaultValue = true;
                }
                else if (FieldItem.DefaultValue == "0" || FieldItem.DefaultValue.Equals(Boolean.FalseString, StringComparison.CurrentCultureIgnoreCase))
                {
                    DefaultValue = false;
                }
                else if (Boolean.TryParse(FieldItem.DefaultValue.ToLower(), out b))
                {
                    DefaultValue = b;
                }

                if (DefaultValue)
                {
                    ControlHtml.Append("checked=\"checked\"");
                }
            }


            ControlHtml.Append(" />");

            //提示的关键字用作是后面的描述
            //if (!String.IsNullOrEmpty(FieldItem.Description))
            //{
            //    ControlHtml.Append( FieldItem.Description);
            //}

            ControlHtml.Append("</label>");

            //提示的关键字用作是后面的描述
            //if (!String.IsNullOrEmpty(FieldItem.ToolTip))
            //{
            //    ControlHtml.AppendFormat("<label for=\"{0}\" title=\"{1}\" style=\"display:inline;\">{1}</label>", ControlID, FieldItem.ToolTip);
            //}
            //if (!String.IsNullOrEmpty(FieldItem.Description))
            //{
            //    ControlHtml.AppendFormat("<label for=\"{0}\" title=\"{1}\" style=\"display:inline;\">{1}</label>", ControlID, FieldItem.Description);
            //}

            //ControlHtml.Append("</div>");

            return(ControlHtml.ToString());
        }
示例#3
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateCheckBoxList(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<span id=\"{1}\" name=\"{0}\" class=\"auto\">", ControlName, ControlID);



            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                List <String> list             = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|");
                List <String> DefaultListValue = Common.GetList(FieldItem.DefaultValue);
                for (Int32 i = 0; i < list.Count; i++)
                {
                    if (!String.IsNullOrEmpty(list[i]))
                    {
                        String OptionText  = list[i];
                        String OptionValue = list[i];
                        //判断是否包含有键值对,将键值对分离开
                        if (list[i].IndexOf(":") >= 0)
                        {
                            List <String> ItemKeyValue = Common.GetList(list[i], ":");
                            OptionText  = ItemKeyValue[0];
                            OptionValue = ItemKeyValue[1];

                            //如果有图标就检测,没有就忽略
                            OptionText = FormatIcon(OptionText);
                        }


                        ControlHtml.AppendFormat("<label  for=\"{0}_{1}\"  class=\"checkbox-inline\" >", ControlID, i);

                        String CheckedStr = DefaultListValue.Count > 0 && DefaultListValue.Exists(r => r.ToLower() == OptionValue.ToLower()) ? "checked=\"checked\"" : "";

                        ControlHtml.AppendFormat("<input id=\"{1}_{2}\" type=\"checkbox\" name=\"{0}\"", ControlName, ControlID, i);

                        if (FieldItem.Required)
                        {
                            ControlHtml.AppendFormat(" class=\"square-green grey {0}\" ", "validate[minCheckbox[1]]");
                        }

                        ControlHtml.AppendFormat("value=\"{0}\" {1} />", OptionValue, CheckedStr);

                        ControlHtml.AppendFormat(" {0}</label>", OptionText);

                        if (FieldItem.Direction == EnumControlDirection.Vertical.ToString())
                        {
                            ControlHtml.Append("<br />");
                        }
                    }
                }
            }

            ControlHtml.Append(" </span>");
            return(ControlHtml.ToString());
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateLabel(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<span  name=\"{0}\" id=\"{1}\"", ControlName, ControlID);
            //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

            ControlHtml.AppendFormat(">{0}</span>", FieldItem.DefaultValue);
            return(ControlHtml.ToString());
        }
        /// <summary>
        /// 绑定元素到页面
        /// </summary>
        private void BindItemToPage()
        {
            ControlHelper ctl          = new ControlHelper(this);
            SettingEntity ThemeSetting = new SettingEntity();

            ThemeSetting.Name         = "Icons";
            ThemeSetting.Width        = 250;
            ThemeSetting.ControlType  = EnumControlType.IconPicker.ToString();
            ThemeSetting.DefaultValue = GetPortalSetting(String.Format("ThemePlugin_TabIcon_{0}", EditTabID), "");
            phControl.Controls.Add((Control)ctl.ViewControl(ThemeSetting));
        }
示例#6
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateDatePicker(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID));

            ControlHtml.Append("<script type=\"text/javascript\">");
            ControlHtml.Append("jQuery(document).ready(function(){").AppendLine();
            ControlHtml.Append("	    jQuery(function() {").AppendLine();
            ControlHtml.AppendFormat("		    jQuery(\"#{0}\").datepicker({{showButtonPanel: true,changeMonth: true,changeYear: true}});", ControlID).AppendLine();
            ControlHtml.Append("	    });").AppendLine();
            ControlHtml.Append("});").AppendLine();
            ControlHtml.Append("</script>");
            return(ControlHtml.ToString());
        }
示例#7
0
        /// <summary>
        /// 创建URLs
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <param name="ControlID"></param>
        /// <returns></returns>
        public Control ViewCreateUrls(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            string ContentSrc = BaseModule.ResolveClientUrl(string.Format("{0}Resource_RichUrls.ascx", BaseModule.ModulePath));

            if (System.IO.File.Exists(BaseModule.MapPath(ContentSrc)))
            {
                Resource_RichUrls ManageContent = new Resource_RichUrls();
                ManageContent = (Resource_RichUrls)BaseModule.LoadControl(ContentSrc);
                ManageContent.ModuleConfiguration = BaseModule.ModuleConfiguration;
                ManageContent.ID = ControlID;
                ManageContent.LocalResourceFile = Localization.GetResourceFile(ManageContent.Control, string.Format("{0}.resx", "Resource_RichUrls.ascx"));
                ManageContent.FieldItem         = FieldItem;
                return(ManageContent);
            }
            return(new Literal());
        }
示例#8
0
        /// <summary>
        /// 创建TextBox
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <returns></returns>
        public String ViewCreateTextBox(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            //看行数决定控件的是什么控件
            if (FieldItem.Rows > 1)
            {
                ControlHtml.AppendFormat("<textarea  name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

                //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

                ControlHtml.AppendFormat(" class=\"form-control input_text {0}\"", ViewVerification(FieldItem));

                ControlHtml.AppendFormat(" style=\"width:{0}px;height:{1}px;\" rows=\"{2}\"", FieldItem.Width, FieldItem.Rows * 20, FieldItem.Rows);

                ControlHtml.Append(" >");

                //默认值
                if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
                {
                    ControlHtml.Append(FieldItem.DefaultValue);
                }

                ControlHtml.Append("</textarea>");
            }
            else
            {
                ControlHtml.AppendFormat("<input type=\"text\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

                //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

                ControlHtml.AppendFormat(" class=\"form-control  input_text {0}\"", ViewVerification(FieldItem));

                ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width);

                if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
                {
                    ControlHtml.AppendFormat(" value=\"{0}\"", FieldItem.DefaultValue);
                }

                ControlHtml.Append(" />");
            }

            return(ControlHtml.ToString());
        }
示例#9
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateDropDownListFont(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<select name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            if (FieldItem.Width >= 100)
            {
                ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width);
            }

            ControlHtml.AppendFormat(" class=\"form-control form_default input_text {0}\">", ViewVerification(FieldItem));

            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                List <String> list = WebHelper.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|");
                for (Int32 i = 0; i < list.Count; i++)
                {
                    if (!String.IsNullOrEmpty(list[i]))
                    {
                        //判断是否包含有键值对,将键值对分离开
                        if (list[i].IndexOf(":") > 0)
                        {
                            List <String> ItemKeyValue = WebHelper.GetList(list[i], ":");
                            if (ItemKeyValue.Count == 2)
                            {
                                String CheckedStr = FieldItem.DefaultValue.ToLower() == ItemKeyValue[1].ToLower() ? "selected=\"selected\"" : "";
                                ControlHtml.AppendFormat("<option {0} value=\"{1}\">{2}</option>", CheckedStr, ItemKeyValue[1], ItemKeyValue[0]);
                            }
                        }
                        else
                        {
                            String CheckedStr = FieldItem.DefaultValue.ToLower() == list[i].ToLower() ? "selected=\"selected\"" : "";
                            ControlHtml.AppendFormat("<option {0} value=\"{1}\">{1}</option>", CheckedStr, list[i]);
                        }

                        //List<String> KeyValueList = WebHelper.GetList(list[i].Replace(":", ","));
                        //String CheckedStr = FieldItem.DefaultValue == KeyValueList[0] ? "selected=\"selected\"" : "";
                        //ControlHtml.AppendFormat("<option {0} value=\"{1}\">{1}</option>", CheckedStr, KeyValueList[0]);
                    }
                }
            }
            ControlHtml.Append(" </select>");
            return(ControlHtml.ToString());
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateRichTextBox(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<textarea  name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

            ControlHtml.AppendFormat(" class=\"form-control tinymce input_text {0}\"", ViewVerification(FieldItem));

            ControlHtml.AppendFormat(" style=\"width:{0}px;height:{1}px;\" rows=\"{2}\"", FieldItem.Width, FieldItem.Rows * 20, FieldItem.Rows);

            ControlHtml.Append(" >");

            //默认值
            if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                ControlHtml.Append(FieldItem.DefaultValue);
            }

            ControlHtml.Append("</textarea>");


            //ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID));


            //ControlHtml.Append("<script type=\"text/javascript\">").AppendLine();
            //ControlHtml.Append("jQuery(function ($) {").AppendLine();
            //ControlHtml.AppendFormat("    $('#{0}').xheditor({{skin:'nostyle',tools:'simple'}});", ControlID).AppendLine();
            //ControlHtml.Append(" });").AppendLine();
            //ControlHtml.Append("</script>").AppendLine();

            //ControlHtml.Append("<script>");
            //ControlHtml.Append("var editor;").AppendLine();
            //ControlHtml.Append("KindEditor.ready(function (K) {").AppendLine();
            //ControlHtml.AppendFormat("    editor = K.create('#{0}', {{", ControlID).AppendLine();
            //ControlHtml.Append("		afterBlur: function(){this.sync();},allowPreviewEmoticons: false,allowImageUpload: false,").AppendLine();
            //ControlHtml.Append("	    items: [ 'source', '|','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist', '|', 'emoticons', 'image', 'link']").AppendLine();
            //ControlHtml.Append("        });").AppendLine();
            //ControlHtml.Append(" });").AppendLine();
            //ControlHtml.Append("</script>");

            return(ControlHtml.ToString());
        }
示例#11
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateFont(SettingEntity FieldItem, SettingEntity FontBoldField, String ControlName, String ControlID, String BoldControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<select name=\"{0}\" id=\"{1}\" data-default=\"{2}\" data-bold=\"{3}\" data-for=\"{4}\"  ", ControlName, ControlID, FieldItem.DefaultValue, FontBoldField.DefaultValue, BoldControlID);

            ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width);

            ControlHtml.AppendFormat(" class=\"form-control fonts  input_text {0}\">", ViewVerification(FieldItem));

            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|");

                for (Int32 i = 0; i < list.Count; i++)
                {
                    if (!String.IsNullOrEmpty(list[i]))
                    {
                        String OptionText  = list[i];
                        String OptionValue = list[i];
                        //判断是否包含有键值对,将键值对分离开
                        if (list[i].IndexOf(":") >= 0)
                        {
                            List <String> ItemKeyValue = Common.GetList(list[i], ":");
                            OptionText  = ItemKeyValue[0];
                            OptionValue = ItemKeyValue[1];
                        }

                        //检索出每一项粗细
                        String FontBold = "normal,bold";
                        if (BaseModule.FontDBs.Exists(r => r.PrimaryGuid == OptionValue))
                        {
                            FontBold = BaseModule.FontDBs.Find(r => r.PrimaryGuid == OptionValue).Bold;
                        }

                        String CheckedStr = FieldItem.DefaultValue.IndexOf(OptionValue, StringComparison.CurrentCultureIgnoreCase) >= 0 ? "selected=\"selected\"" : "";
                        ControlHtml.AppendFormat("<option {0} value=\"{1}\" data-bold=\",{3},\">{2}</option>", CheckedStr, OptionValue, OptionText, FontBold.Trim(','));
                    }
                }
            }
            ControlHtml.Append(" </select>");
            return(ControlHtml.ToString());
        }
        /// <summary>
        /// 更新内容
        /// </summary>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                SettingEntity ThemeSetting = new SettingEntity();
                ThemeSetting.Name        = "Icons";
                ThemeSetting.ControlType = EnumControlType.IconPicker.ToString();


                UpdatePortalSetting(String.Format("ThemePlugin_TabIcon_{0}", EditTabID), ControlHelper.GetWebFormValue(ThemeSetting, this));

                mTips.LoadMessage("SaveIconSuccess", EnumTips.Success, this, new String[] { });

                Response.Redirect(xUrl("Pages"), false);
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
示例#13
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateColorPicker(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            if (String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                FieldItem.DefaultValue = "#ffffff";
            }


            ControlHtml.AppendFormat("<div class=\"input-group\" style=\"width:{0}px;\">", FieldItem.Width);
            ControlHtml.AppendFormat("<label class=\"input-group-addon color-picker-box tooltips\" for=\"{0}\" style=\"background-color: {1};\"> <i class=\"clip-eyedropper-2 \" ></i> </label>", ControlID, FieldItem.DefaultValue);


            ControlHtml.AppendFormat("<input type=\"text\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

            ControlHtml.AppendFormat(" class=\"form-control color-picker-auto input_text {0}\"", ViewVerification(FieldItem));

            ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width - 40);

            if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                ControlHtml.AppendFormat(" value=\"{0}\"", FieldItem.DefaultValue);
            }


            ControlHtml.Append(" />");


            ControlHtml.Append("</div>");



            //ControlHtml.Append("<div class=\"input-group colorpicker-component\" data-color=\"rgb(81, 145, 185)\" data-color-format=\"rgb\">");
            //ControlHtml.Append(ViewCreateTextBox(FieldItem, ControlName, ControlID));
            //ControlHtml.Append("<span class=\"input-group-addon\"><i style=\"background-color: rgb(81, 145, 185)\"></i></span>");
            //ControlHtml.Append("</div>");
            return(ControlHtml.ToString());
        }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateRadioButtonList(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<span id=\"{0}\"  class=\"{1} auto control_{2}\" >", ControlID, ViewVerification(FieldItem), FieldItem.Name.ToLower());


            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                List <String> list = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|");
                for (Int32 i = 0; i < list.Count; i++)
                {
                    if (!String.IsNullOrEmpty(list[i]))
                    {
                        String OptionText  = list[i];
                        String OptionValue = list[i];
                        String OptionImage = String.Empty;
                        //判断是否包含有键值对,将键值对分离开
                        if (list[i].IndexOf(":") >= 0)
                        {
                            List <String> ItemKeyValue = Common.GetList(list[i], ":");
                            OptionText  = ItemKeyValue[0];
                            OptionValue = ItemKeyValue[1];

                            //如果有图标就检测,没有就忽略
                            OptionText = FormatIcon(OptionText);
                        }
                        List <String> selectValues = WebHelper.GetList(FieldItem.DefaultValue);
                        String        CheckedStr   = selectValues.Exists(r => r.ToLower() == OptionValue.ToLower()) ? "checked=\"checked\"" : "";
                        ControlHtml.AppendFormat("<label  class=\"radio-inline\" for=\"{1}_{2}\" ><input id=\"{1}_{2}\"  type=\"radio\" name=\"{0}\" value=\"{3}\" {4} /> {5}</label>", ControlName, ControlID, i, OptionValue, CheckedStr, OptionText);
                        if (FieldItem.Direction == EnumControlDirection.Vertical.ToString())
                        {
                            ControlHtml.Append("<br />");
                        }
                    }
                }
            }

            ControlHtml.Append(" </span>");
            return(ControlHtml.ToString());
        }
示例#15
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateFileUpload(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                String PicUrl = BaseModule.ResolveUrl(String.Format("{0}{1}", BaseModule.SkinPath, FieldItem.DefaultValue));

                ControlHtml.AppendFormat("<img class=\"img-responsive\" src=\"{0}\" style=\"max-width:200px;max-height:200px;\" /><br />", PicUrl);
            }

            ControlHtml.AppendFormat("<input type=\"file\" name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            //if (!String.IsNullOrEmpty(FieldItem.ToolTip)) ControlHtml.AppendFormat(" title=\"{0}\"", FieldItem.ToolTip);

            ControlHtml.AppendFormat(" class=\"validate[{0}custom[onlyImage]]\"", String.IsNullOrEmpty(FieldItem.DefaultValue) && FieldItem.Required ? "required," : "");

            ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width < 250 ? 250 : FieldItem.Width);

            ControlHtml.Append(" />");
            return(ControlHtml.ToString());
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateListBox(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            ControlHtml.AppendFormat("<select name=\"{0}\" id=\"{1}\"", ControlName, ControlID);

            ControlHtml.AppendFormat(" class=\"form-control input_text {0}\"", ViewVerification(FieldItem));

            ControlHtml.AppendFormat(" style=\"width:{0}px;\"", FieldItem.Width);

            ControlHtml.AppendFormat(" size=\"{0}\" multiple=\"multiple\">", FieldItem.Rows);

            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                List <String> list             = Common.GetList(FieldItem.ListContent.Replace(",", "|").Replace("\r\n", "|").Replace("\r", "|"), "|");
                List <String> DefaultListValue = Common.GetList(FieldItem.DefaultValue);
                for (Int32 i = 0; i < list.Count; i++)
                {
                    if (!String.IsNullOrEmpty(list[i]))
                    {
                        String OptionText  = list[i];
                        String OptionValue = list[i];
                        //判断是否包含有键值对,将键值对分离开
                        if (list[i].IndexOf(":") >= 0)
                        {
                            List <String> ItemKeyValue = Common.GetList(list[i], ":");
                            OptionText  = ItemKeyValue[0];
                            OptionValue = ItemKeyValue[1];
                        }

                        String CheckedStr  = DefaultListValue.Exists(r => r.ToLower() == OptionValue.ToLower()) ? "selected=\"selected\"" : "";
                        String DisabledStr = String.IsNullOrEmpty(OptionValue) ? "disabled=\"disabled\"" : "";
                        ControlHtml.AppendFormat("<option {0} {1} value=\"{2}\">{3}</option>", CheckedStr, DisabledStr, OptionValue, OptionText);
                    }
                }
            }
            ControlHtml.Append(" </select>");
            return(ControlHtml.ToString());
        }
示例#17
0
        /// <summary>
        /// 验证字符
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <returns></returns>
        public String ViewVerification(SettingEntity FieldItem)
        {
            //无验证时退出
            //if (FieldItem.Verification == EnumVerification.optional.ToString() && !FieldItem.Required) return "";

            String custom = String.Empty;

            if (!String.IsNullOrEmpty(FieldItem.Verification) && FieldItem.Verification != EnumVerification.optional.ToString())
            {
                if (!(("DropDownList,ListBox,RadioButtonList,FileUpload,CheckBox,CheckBoxList,Label").IndexOf(FieldItem.ControlType) >= 0))
                {
                    custom = String.Format("custom[{0}]", FieldItem.Verification);
                }
            }
            if (!String.IsNullOrEmpty(custom))
            {
                if (!FieldItem.Required)
                {
                    return(String.Format("validate[{0}]", String.IsNullOrEmpty(custom) ? "optional" : custom));
                }
                else
                {
                    return(String.Format("validate[required,{0}]", custom));
                }
            }
            else
            {
                if (FieldItem.Required)
                {
                    return("validate[required]");
                }
                else
                {
                    return("");
                }
            }
        }
示例#18
0
 public String ViewControlID(SettingEntity FieldItem)
 {
     return(String.Format("Ctl_{0}_{1}", FieldItem.Name, ModuleId));
 }
示例#19
0
 /// <summary>
 /// 显示标题控件
 /// </summary>
 /// <param name="FieldItem"></param>
 /// <returns></returns>
 public String ViewLable(SettingEntity FieldItem)
 {
     return(ViewLable(FieldItem, ""));;
 }
示例#20
0
        /// <summary>
        /// 获取Form传值
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public static String GetWebFormValue(SettingEntity fieldItem, BaseModule bpm)
        {
            String WebFormValue = String.Empty;

            //创建控件的Name和ID
            ControlHelper ControlItem = new ControlHelper(bpm.ModuleId);
            String        ControlName = ControlItem.ViewControlName(fieldItem);
            String        ControlID   = ControlItem.ViewControlID(fieldItem);

            if (fieldItem.ControlType == EnumControlType.CheckBox.ToString())
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
                WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false";
            }
            else if (fieldItem.ControlType == EnumControlType.FileUpload.ToString())
            {
                HttpPostedFile hpFile = HttpContext.Current.Request.Files[ControlName];
                if (hpFile != null && hpFile.ContentLength > 0)
                {
                    //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements
                    bool retValue = FileSystemUtils.CheckValidFileName(hpFile.FileName);
                    if (retValue)
                    {
                        WebFormValue = String.Format("{0}", FileSystemUtils.UploadFile(hpFile, bpm));//存放到目录中,并返回
                    }
                }
                else
                {
                    WebFormValue = fieldItem.DefaultValue;
                }
            }
            else if (fieldItem.ControlType == EnumControlType.Urls.ToString())
            {
                String ClientName = GetRichUrlsName(fieldItem);
                if (bpm.ModuleContext.Items.Contains(ClientName))
                {
                    WebFormValue = Convert.ToString(bpm.ModuleContext.Items[ClientName]);
                }
            }
            else if (fieldItem.ControlType == EnumControlType.Fonts.ToString())
            {
                String ControlFontName = ControlItem.ViewControlName(new SettingEntity()
                {
                    Name = String.Format("{0}Font", fieldItem.Name)
                });
                String ControlBoldName = ControlItem.ViewControlName(new SettingEntity()
                {
                    Name = String.Format("{0}Bold", fieldItem.Name)
                });

                String ControlFontValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlFontName, "");
                String ControlBoldValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlBoldName, "");
                String FontFamily       = String.Empty;
                if (bpm.FontDBs.Exists(r => r.PrimaryGuid == ControlFontValue))
                {
                    FontFamily = bpm.FontDBs.Find(r => r.PrimaryGuid == ControlFontValue).Family;
                }

                WebFormValue = String.Format("{0}:{1}:{2}", ControlFontValue, FontFamily, ControlBoldValue);
            }
            else
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
            }
            return(WebFormValue);
        }
示例#21
0
        /// <summary>
        /// 显示标题控件
        /// </summary>
        /// <param name="FieldItem">显示字段</param>
        /// <param name="Suffix">后缀名</param>
        /// <returns></returns>
        public String ViewLable(SettingEntity FieldItem, String Suffix)
        {
            String ControlName = ViewControlID(FieldItem);

            return(String.Format("<label for=\"{0}\">{1}{2}</label>", ControlName, FieldItem.Alias, Suffix));
        }
示例#22
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <param name="ControlName"></param>
        /// <returns></returns>
        public String ViewCreateFonts(SettingEntity FieldItem, String ControlName, String ControlID)
        {
            StringBuilder ControlHtml = new StringBuilder();//控件的HTML

            //创建字体方案的值
            StringBuilder ListContent     = new StringBuilder();
            String        BoldListContent = String.Empty;



            //处理字体方案和字体粗细的默认值
            String FontDefaultValue = "arial";
            String BoldDefaultValue = "normal";


            //获取字体方案并处理
            List <FontDB> FontDBs = BaseModule.FontDBs;

            foreach (var FontItem in FontDBs)
            {
                ListContent.AppendFormat("{0}( {1} ):{2}", FontItem.Alias, FontItem.Family, FontItem.PrimaryGuid).AppendLine();
                if (FontItem.PrimaryGuid == FontDefaultValue)
                {
                    BoldListContent = FontItem.Bold;
                }
            }



            //先创建字体方案的下拉列表
            SettingEntity FontField = new SettingEntity()
            {
                Width        = FieldItem.Width,
                ControlType  = EnumControlType.DropDownList.ToString(),
                Name         = String.Format("{0}Font", FieldItem.Name, ModuleId),
                ListContent  = ListContent.ToString(),
                DefaultValue = FontDefaultValue
            };
            //创建字体粗细的下拉列表
            SettingEntity FontBoldField = new SettingEntity()
            {
                Width        = FieldItem.Width,
                ControlType  = EnumControlType.DropDownList.ToString(),
                Name         = String.Format("{0}Bold", FieldItem.Name, ModuleId),
                ListContent  = BoldListContent,
                DefaultValue = BoldDefaultValue
            };


            if (!String.IsNullOrEmpty(FieldItem.DefaultValue))
            {
                //拆分字体默认值
                List <String> defaultFonts = Common.GetList(FieldItem.DefaultValue, ":");
                if (defaultFonts != null && defaultFonts.Count == 3)
                {
                    FontField.DefaultValue     = defaultFonts[0];
                    FontBoldField.DefaultValue = defaultFonts[2];
                }
            }


            //打印字体方案
            ControlHtml.Append(ViewCreateFont(FontField, FontBoldField, ViewControlName(FontField), ViewControlID(FontField), ViewControlID(FontBoldField))).AppendLine();
            //打印粗细方案
            ControlHtml.Append("<div class=\"font_weight\">Font weight:</div>").Append(ViewCreateDropDownList(FontBoldField, ViewControlName(FontBoldField), ViewControlID(FontBoldField))).AppendLine();



            return(ControlHtml.ToString());
        }
示例#23
0
 /// <summary>
 /// 获取URLs控件的名称
 /// </summary>
 /// <param name="fieldItem"></param>
 /// <returns></returns>
 public static String GetRichUrlsName(SettingEntity fieldItem)
 {
     return(String.Format("RichUrls{0}", fieldItem.Name).Replace("_", "").Replace("-", ""));
 }
示例#24
0
        /// <summary>
        /// 显示输入控件内容
        /// </summary>
        /// <param name="FieldItem"></param>
        /// <returns></returns>
        public Control ViewControl(SettingEntity FieldItem)
        {
            String  ControlName   = ViewControlName(FieldItem);
            String  ControlID     = ViewControlID(FieldItem);
            Control CreateControl = new Control();
            String  ControlHtml   = String.Empty;//控件的HTML

            if (FieldItem.ControlType == EnumControlType.CheckBox.ToString())
            {
                ControlHtml = ViewCreateCheckBox(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.CheckBoxList.ToString())
            {
                ControlHtml = ViewCreateCheckBoxList(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.DatePicker.ToString())
            {
                ControlHtml = ViewCreateDatePicker(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType.ToLower() == EnumControlType.ColorPicker.ToString().ToLower())
            {
                ControlHtml = ViewCreateColorPicker(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.IconPicker.ToString())
            {
                ControlHtml = ViewCreateIconPicker(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.DropDownList.ToString())
            {
                ControlHtml = ViewCreateDropDownList(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.DropDownList_Font.ToString())
            {
                ControlHtml = ViewCreateDropDownListFont(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.Fonts.ToString())
            {
                ControlHtml = ViewCreateFonts(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.FileUpload.ToString())
            {
                ControlHtml = ViewCreateFileUpload(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.Urls.ToString())
            {
                CreateControl = ViewCreateUrls(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.Label.ToString())
            {
                ControlHtml = ViewCreateLabel(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.ListBox.ToString())
            {
                ControlHtml = ViewCreateListBox(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.RadioButtonList.ToString())
            {
                ControlHtml = ViewCreateRadioButtonList(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.RadioButtonList_Icon.ToString())
            {
                ControlHtml = ViewCreateRadioButtonListIcon(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.RichTextBox.ToString())
            {
                ControlHtml = ViewCreateRichTextBox(FieldItem, ControlName, ControlID);
            }
            else if (FieldItem.ControlType == EnumControlType.TextBox.ToString() || FieldItem.ControlType.IndexOf("text") >= 0)
            {
                ControlHtml = ViewCreateTextBox(FieldItem, ControlName, ControlID);
            }

            if (!String.IsNullOrEmpty(ControlHtml))
            {
                Literal liHtml = new Literal();
                liHtml.Text   = ControlHtml;
                CreateControl = liHtml;
            }

            return(CreateControl);
        }