예제 #1
0
파일: HtmlField.cs 프로젝트: jiaping/JPCMS
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="dataitem"></param>
        /// <returns></returns>
        private string GetLinkUrl(object dataitem)
        {
            if (ModelInfo == null)
            {
                ModelInfo = ModelHelper.GetModelInfo(We7Helper.GetParamValueFromUrl(HttpContext.Current.Request.RawUrl, "model"));
            }
            string result = string.Empty;

            foreach (We7DataColumn d in ModelInfo.DataSet.Tables[0].Columns)
            {
                if (d.Name.Contains("_Count"))
                {
                    string model = string.Format("{0}.{1}", ModelInfo.GroupName, d.Name.Remove(d.Name.Length - 6));
                    string url   = We7Helper.AddParamToUrl(HttpContext.Current.Request.RawUrl, "model", model);
                    url    = We7Helper.RemoveParamFromUrl(url, "mode");
                    url    = We7Helper.AddParamToUrl(url, d.Mapping.Split('|')[0], GetValue(dataitem, d.Mapping.Split('|')[1]));
                    result = url;
                    break;
                }
            }
            if (string.IsNullOrEmpty(result))
            {
                result = string.Format("/admin/AddIns/ModelViewer.aspx?notiframe=1&model={0}&ID={1}", ModelInfo.ModelName, GetValue(dataitem, "ID"));
            }
            return(result);
        }
예제 #2
0
        public override void InitControl()
        {
            ddlEnum.PreRender += new EventHandler(ddlEnum_PreRender);
            string model      = Control.Params["model"];
            string valuefield = Control.Params["valuefield"];
            string textfield  = Control.Params["textfield"];

            if (GeneralConfigs.GetConfig().EnableSingleTable)
            {
                ModelDBHelper helper = ModelDBHelper.Create(model);
                Criteria      c      = new Criteria(CriteriaType.Equals, "State", 1);
                DataTable     dt     = helper.Query(c, new List <Order>()
                {
                    new Order("Created", OrderMode.Desc), new Order("ID", OrderMode.Desc)
                }, 0, 0);
                ddlEnum.DataSource = dt;
            }
            else
            {
                List <Article> list = ArticleHelper.QueryArticleByModel(model);
                DataSet        ds   = ModelHelper.CreateDataSet(model);
                foreach (Article a in list)
                {
                    TextReader reader = new StringReader(a.ModelXml);
                    ds.ReadXml(reader);
                }

                ddlEnum.DataSource = ds.Tables[0];
            }

            ddlEnum.DataValueField = valuefield;
            ddlEnum.DataTextField  = textfield;
            ddlEnum.DataBind();

            ddlEnum.Items.Insert(0, new ListItem("请选择", ""));
            ddlEnum.SelectedValue = Value == null ? Control.DefaultValue : Value.ToString();

            if (!String.IsNullOrEmpty(Control.Width))
            {
                ddlEnum.Width = Unit.Parse(Control.Width);
            }
            if (!String.IsNullOrEmpty(Control.Height))
            {
                ddlEnum.Height = Unit.Parse(Control.Height);
            }

            ddlEnum.CssClass = Control.CssClass;
            if (Control.Required && !ddlEnum.CssClass.Contains("required"))
            {
                ddlEnum.CssClass += " required";
            }

            string urlParam = We7Helper.GetParamValueFromUrl(Request.RawUrl, Control.Name);

            if (!string.IsNullOrEmpty(urlParam))
            {
                ddlEnum.SelectedValue = urlParam;
            }
        }
예제 #3
0
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="cmd">命令名称</param>
        /// <param name="model">模型信息</param>
        /// <param name="state">附加数据</param>
        protected void DoCommand(object sender, string cmd, PanelContext data, object args)
        {
            //初始化模型数据
            InitModelData();

            if (data != null)
            {
                foreach (We7DataColumn colum in data.DataSet.Tables[0].Columns)
                {
                    string urlParam = We7Helper.GetParamValueFromUrl(Request.RawUrl, colum.Name);
                    if (string.IsNullOrEmpty(urlParam))
                    {
                        continue;
                    }
                    if (data.QueryFields[colum] == null)
                    {
                        data.QueryFields.Add(new QueryField(colum, urlParam));
                    }
                    else
                    {
                        data.QueryFields[colum] = urlParam;
                    }
                }
            }

            //构建模型参数
            ModelEventArgs modelArgs = new ModelEventArgs(cmd, args, data);

            //处理预处理命令
            if (OnPreCommand != null)
            {
                OnPreCommand(sender, modelArgs);
            }
            if (!modelArgs.Disable)
            {
                //处理命令
                if (OnCommand != null)
                {
                    OnCommand(sender, modelArgs);
                }
                else
                {
                    OnInteralCommand(sender, modelArgs);
                }
            }
            //处理命令完成后事件
            if (!modelArgs.Disable && OnCommandComplete != null)
            {
                OnCommandComplete(sender, modelArgs);
            }
        }
예제 #4
0
        protected override void InitContainer()
        {
            ChangeState();
            editMode.Controls.Clear();
            string curMode = HttpUtility.UrlDecode(We7Helper.GetParamValueFromUrl(Request.RawUrl, "mode"));
            bool   flag    = true;

            if (Request["groupIndex"] == null)
            {
                flag = false;
            }
            foreach (Group group in PanelContext.Panel.EditInfo.Groups)
            {
                if (group.Enable)
                {
                    if (string.IsNullOrEmpty(curMode))
                    {
                        curMode = group.Name;
                    }
                    if (!flag)
                    {
                        GroupIndex = group.Index;
                        flag       = true;
                    }
                }
                HtmlAnchor a = new HtmlAnchor();
                a.InnerText = group.Name;
                a.Style.Add(HtmlTextWriterStyle.MarginRight, "20px");
                if (group.Index == GroupIndex)
                {
                    a.Style.Add(HtmlTextWriterStyle.FontWeight, "bolder");
                }
                a.HRef = We7Helper.AddParamToUrl(Request.RawUrl, "mode", HttpUtility.UrlEncode(group.Name));
                a.HRef = We7Helper.AddParamToUrl(a.HRef, "groupIndex", group.Index.ToString());
                editMode.Controls.Add(a);
            }
            if (string.IsNullOrEmpty(curMode) || IsEdit)
            {
                curMode = "默认";
            }
            rpEditor.DataSource = PanelContext.Panel.EditInfo.Groups[curMode].Controls;
            rpEditor.DataBind();
            ModelLabel.Text   = PanelContext.Model.Label;
            MenuTabLabel.Text = BuildNavString();
            if (IsEdit)
            {
                trBtn.Visible = Security.CurrentAccountID == (PanelContext.Row["AccountID"] ?? We7Helper.EmptyGUID).ToString() ||
                                Security.CurrentAccountID == We7Helper.EmptyGUID;
            }
        }
예제 #5
0
        protected override void LoadContainer()
        {
            TagsLiteral.Text = LoadTagDictionary();
            string paramName  = string.Empty;
            string paramValue = string.Empty;

            foreach (We7DataColumn colum in PanelContext.DataSet.Tables[0].Columns)
            {
                string urlParam = We7Helper.GetParamValueFromUrl(Request.RawUrl, colum.Name);
                if (string.IsNullOrEmpty(urlParam))
                {
                    continue;
                }
                paramName  = colum.Name;
                paramValue = urlParam;
                break;
            }
            lnkNewArticle.NavigateUrl = String.Format("~/admin/addins/ModelEditor.aspx?notiframe={3}&model={0}&panel=edit&ID={1}{2}{4}",
                                                      Request["model"], We7Helper.CreateNewID(), String.IsNullOrEmpty(Request["oid"]) ? "" : String.Format("&oid={0}", Request["oid"]),
                                                      Request["notiframe"], string.IsNullOrEmpty(paramValue) ? "" : string.Format("&{0}={1}", paramName, paramValue));
        }
예제 #6
0
        protected override void Initialize()
        {
            string rawurl = Request.RawUrl;

            rawurl = We7Helper.RemoveParamFromUrl(rawurl, "keyword");
            string qString = @"<label class=""hidden"" for=""user-search-input"">ËÑË÷{0}:</label>
                <input type=""text"" class=""search-input"" id=""KeyWord"" name=""KeyWord"" value=""""  onKeyPress=""javascript:KeyPressSearch('{1}',event);""  />
                <input type=""button"" value=""ËÑË÷"" class=""button"" id=""SearchButton""  onclick=""javascript:doSearch('{1}');""  />";

            qString = string.Format(qString, "Àà±ð", rawurl);
            SearchSimpleLiteral.Text = qString;
            rawurl       = We7Helper.GetParamValueFromUrl(rawurl, "type");
            CategoryList = new ArrayList();
            if (rawurl == "dep")
            {
                NameLabel.Text = "Ñ¡ÔñÒ»¸ö²¿ÃÅ";
                List <Common.PF.Department> allDepartments = null;
                allDepartments = AccountHelper.GetDepartments(siteID, We7Helper.EmptyGUID, "", new string[] { "ID", "Title", "Description", "State" });
                foreach (Common.PF.Department d in allDepartments)
                {
                    DrawTreeMenu(d, "");
                }
                CategoryList = FilterByKeyword();
                DetailGridView.DataSource         = CategoryList;
                DetailGridView.Columns[2].Visible = false;
            }
            else
            {
                NameLabel.Text = "Ñ¡ÔñÒ»¸öÀà±ð";
                List <Category> allCategory = null;
                allCategory = CategoryHelper.GetCategoryByParentID(We7Helper.EmptyGUID);
                foreach (Category c in allCategory)
                {
                    DrawTreeMenu(c, "");
                }
                CategoryList = FilterByKeyword();
                DetailGridView.DataSource = CategoryList;
            }
            DetailGridView.DataBind();
        }
예제 #7
0
        public string GetHtmlTemplateByHandlers(string ColumnMode, string ColumnID, string SearchWord, string SeSearchWord)
        {
            GeneralConfigInfo gi = GeneralConfigs.GetConfig();

            if (gi.StartTemplateMap)
            {
                HttpContext Context      = HttpContext.Current;
                string      channelUrl   = We7Helper.GetChannelUrlFromUrl(Context.Request.RawUrl);
                string      htmlTemplate = We7Helper.GetParamValueFromUrl(Context.Request.RawUrl, "template");
                if (String.IsNullOrEmpty(htmlTemplate))
                {
                    if (channelUrl == "/" && ColumnMode == "")
                    {
                        htmlTemplate = GetHtmlTemplatePath("welcome");
                        if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate)))
                        {
                            htmlTemplate = GetHtmlTemplatePath("index");
                            if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate)))
                            {
                                return(GetTemplateByHandlers(ColumnMode, ColumnID, SearchWord, SeSearchWord));
                            }
                        }
                    }
                    else
                    {
                        htmlTemplate = GetHtmlTemplatePath(channelUrl.Trim('/').Trim('\\') + "/" + (String.IsNullOrEmpty(ColumnMode)?"index":ColumnMode));
                        if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate)))
                        {
                            return(GetTemplateByHandlers(ColumnMode, ColumnID, SearchWord, SeSearchWord));
                        }
                    }
                }
                return(htmlTemplate);
            }
            else
            {
                return(GetThisHtmlPageTemplate(ColumnMode, ColumnID, SearchWord, SeSearchWord));
            }
        }
예제 #8
0
        /// <summary>
        /// 列表模式初始化
        /// </summary>
        private void ModeInit()
        {
            phMode.Controls.Clear();
            HtmlGenericControl div = new HtmlGenericControl("div");

            div.Attributes.Add("class", "modeStyle");
            int tempMode = -1;

            foreach (Group group in PanelContext.Panel.ListInfo.Groups)
            {
                string curMode = We7Helper.GetParamValueFromUrl(Request.RawUrl, "mode");
                if (!string.IsNullOrEmpty(curMode))
                {
                    int.TryParse(curMode, out tempMode);
                }
                if (group.Enable)
                {
                    if (tempMode < 0)
                    {
                        tempMode = group.Index;
                    }
                    List.GroupIndex = tempMode;
                }
                HtmlAnchor a = new HtmlAnchor();
                a.InnerText = group.Name;
                if (group.Index == tempMode)
                {
                    a.Attributes.Add("class", "cur");
                }
                a.HRef = We7Helper.AddParamToUrl(Request.RawUrl, "mode", group.Index.ToString());
                if (group.Index == 0 || group.Enable)
                {
                    div.Controls.Add(a);
                }
            }
            div.Controls.Add(BtnBackInit());
            phMode.Controls.Add(div);
        }
예제 #9
0
        /// <summary>
        /// 根据配置选择不同的模板选择器
        /// </summary>
        /// <param name="ColumnMode"></param>
        /// <param name="ColumnID"></param>
        /// <param name="SearchWord"></param>
        /// <param name="SeSearchWord"></param>
        /// <returns></returns>
        public string GetTemplateByHandlers(string ColumnMode, string ColumnID, string SearchWord, string SeSearchWord)
        {
            GeneralConfigInfo gi = GeneralConfigs.GetConfig();

            if (gi.StartTemplateMap)
            {
                HttpContext Context      = HttpContext.Current;
                string      channelUrl   = We7Helper.GetChannelUrlFromUrl(Context.Request.RawUrl);
                string      templatePath = We7Helper.GetParamValueFromUrl(Context.Request.RawUrl, "template");
                if (string.IsNullOrEmpty(templatePath))
                {
                    if (channelUrl == "/" && ColumnMode == "")
                    {
                        templatePath = TemplateMap.GetTemplateFromMap("welcome", channelUrl);
                        if (string.IsNullOrEmpty(templatePath))
                        {
                            templatePath = templatePath = TemplateMap.GetTemplateFromMap("home", channelUrl);
                        }
                    }
                    else
                    {
                        templatePath = TemplateMap.GetTemplateFromMap(ColumnMode, channelUrl);
                    }

                    if (!string.IsNullOrEmpty(templatePath))
                    {
                        GeneralConfigInfo si = GeneralConfigs.GetConfig();
                        templatePath = GetTemplatePath(si.DefaultTemplateGroupFileName, templatePath);
                    }
                }
                return(templatePath);
            }
            else
            {
                return(GetThisPageTemplate(ColumnMode, ColumnID, SearchWord, SeSearchWord));
            }
        }
예제 #10
0
        public override void InitControl()
        {
            ddlEnum.PreRender += new EventHandler(ddlEnum_PreRender);
            #region 已废弃 2011-12-13 by Brina.G
            //以下将被更改
            //string model = Control.Params["model"];
            //string valuefield = Control.Params["valuefield"];
            //string textfield = Control.Params["textfield"];

            //if (GeneralConfigs.GetConfig().EnableSingleTable)
            //{
            //    ModelDBHelper helper=ModelDBHelper.Create(model);
            //    Criteria c=new Criteria(CriteriaType.Equals,"State",1);
            //    DataTable dt=helper.Query(c, new List<Order>() { new Order("Created",OrderMode.Desc),new Order("ID",OrderMode.Desc)}, 0, 0);
            //    ddlEnum.DataSource = dt;
            //}
            //else
            //{
            //    List<Article> list = ArticleHelper.QueryArticleByModel(model);
            //    DataSet ds = ModelHelper.CreateDataSet(model);
            //    foreach (Article a in list)
            //    {
            //        TextReader reader = new StringReader(a.ModelXml);
            //        ds.ReadXml(reader);
            //    }

            //    ddlEnum.DataSource = ds.Tables[0];
            //}
            #endregion



            //string model = Control.Params["table"];
            string model      = Control.Params["model"];
            string valuefield = Control.Params["valuefield"];
            string textfield  = Control.Params["textfield"];
            //默认启用单表存储,并且不可更改
            if (!string.IsNullOrEmpty(model) && !string.IsNullOrEmpty(valuefield) && !string.IsNullOrEmpty(textfield))
            {
                //兼容以前版本的关联控件  老版本格式为:group.tableName
                model = model.Contains(".") ? (model.Substring(model.IndexOf(".") + 1)) : model;

                TableInfo ti = new TableInfo(model);
                Criteria  c  = null;
                if (GetDataBase(ti).IsSiteGroup)
                {
                    c = new Criteria(CriteriaType.Equals, "FromSiteID", SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty);
                }
                List <TableInfo> list = GetDataBase(ti).IDatabase.GetDtByCondition <TableInfo>(ti.TableName, c, new string[] { valuefield, textfield });

                if (list != null && list.Count > 0)
                {
                    DataTable dt = list[0].Table;
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        ddlEnum.DataSource     = dt;
                        ddlEnum.DataValueField = dt.Columns[0].ColumnName; // valuefield;
                        ddlEnum.DataTextField  = dt.Columns[1].ColumnName; //textfield;
                        ddlEnum.DataBind();
                        ddlEnum.SelectedValue = Value == null ? Control.DefaultValue : Value.ToString();
                    }
                    ddlEnum.Items.Insert(0, new ListItem("请选择", ""));
                }
            }
            else
            {
                ddlEnum.Items.Insert(0, new ListItem("没有绑定数据源", ""));
            }

            if (!String.IsNullOrEmpty(Control.Width))
            {
                ddlEnum.Width = Unit.Parse(Control.Width);
            }
            if (!String.IsNullOrEmpty(Control.Height))
            {
                ddlEnum.Height = Unit.Parse(Control.Height);
            }

            Validator(ddlEnum);

            string urlParam = We7Helper.GetParamValueFromUrl(Request.RawUrl, Control.Name);
            if (!string.IsNullOrEmpty(urlParam))
            {
                ddlEnum.SelectedValue = urlParam;
            }
        }
예제 #11
0
        /// <summary>
        /// 显示列图模式
        /// </summary>
        /// <param name="result"></param>
        private void InitUlList(ListResult result)
        {
            foreach (DataRow dr in result.DataTable.Rows)
            {
                HtmlGenericControl li = new HtmlGenericControl("li");
                int width             = 0;
                foreach (ColumnInfo field in Columns)
                {
                    if (!field.Visible)
                    {
                        continue;
                    }
                    HtmlGenericControl div        = new HtmlGenericControl("div");
                    string             thisWidth  = field.Width.Contains("px") ? field.Width : field.Width + "px";
                    string             thisHeight = field.Height.Contains("px") ? field.Height : field.Height + "px";
                    div.Style.Add(HtmlTextWriterStyle.Width, thisWidth);
                    div.Style.Add(HtmlTextWriterStyle.Height, thisHeight);

                    if (int.Parse(thisWidth.Replace("px", "")) > width)
                    {
                        width = int.Parse(field.Width.Replace("px", ""));
                    }
                    if (field.IsThumb)
                    {
                        div.Attributes.Add("class", "img");
                        HtmlImage img = new HtmlImage();
                        img.Src = dr[field.Name].ToString();
                        if (img.Src.LastIndexOf('.') > 0)
                        {
                            img.Src = img.Src.Insert(img.Src.LastIndexOf('.'), "_thumb");
                        }

                        if (string.IsNullOrEmpty(img.Src))
                        {
                            img.Src = "/Admin/images/flower.jpg";
                        }
                        img.Style.Add(HtmlTextWriterStyle.Width, "100%");
                        img.Style.Add(HtmlTextWriterStyle.Height, "100%");
                        if (field.IsLink)
                        {
                            HtmlAnchor a = new HtmlAnchor();
                            GetLinkUrl(dr, a);
                            a.Controls.Add(img);
                            div.Controls.Add(a);
                        }
                        else
                        {
                            div.Controls.Add(img);
                        }
                    }
                    else if (field.IsLink)
                    {
                        HtmlAnchor a = new HtmlAnchor();
                        GetLinkUrl(dr, a);
                        a.InnerText = dr[field.Name].ToString();
                        div.Controls.Add(a);
                        div.Attributes.Add("class", "title");
                    }
                    if (field.Type == "action")
                    {
                        HtmlGenericControl span = new HtmlGenericControl("span");
                        span.InnerText = countEnable ? "数量:" + (string.IsNullOrEmpty(dr[columnCount].ToString()) ? "0" : dr[columnCount].ToString()) : string.Empty;;
                        HtmlImage imgDel = new HtmlImage();
                        imgDel.Src = "/Admin/images/icon_del1.gif";
                        imgDel.Attributes.Add("title", "删除");
                        imgDel.Attributes.Add("onclick", string.Format("Del('{0}');", dr["ID"].ToString()));
                        HtmlImage imgEdit = new HtmlImage();
                        imgEdit.Src = "/Admin/images/icon_edit1.gif";
                        imgEdit.Attributes.Add("title", "编辑");
                        string editUrl = string.Format("/admin/addins/ModelEditor.aspx?notiframe={0}&model={1}&ID={2}&groupIndex=0", We7Helper.GetParamValueFromUrl(Request.RawUrl, "notiframe"),
                                                       We7Helper.GetParamValueFromUrl(Request.RawUrl, "model"), dr["ID"].ToString());
                        imgEdit.Attributes.Add("onclick", string.Format("Edit('{0}');", editUrl));
                        div.Controls.Add(span);
                        div.Controls.Add(imgDel);
                        div.Controls.Add(imgEdit);
                        HtmlInputCheckBox selected = new HtmlInputCheckBox();
                        selected.Attributes.Add("title", "选中");
                        selected.Attributes.Add("class", dr["ID"].ToString());
                        div.Controls.Add(selected);
                        div.Attributes.Add("class", "actionbar");
                    }
                    li.Controls.Add(div);
                }
                li.Style.Add(HtmlTextWriterStyle.Width, width + "px");
                ulList.Controls.Add(li);
            }
        }
예제 #12
0
 public void ProcessRequest(HttpContext context)
 {
     string model = We7Helper.GetParamValueFromUrl(context.Request.RawUrl, "model");
 }