예제 #1
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("site_channel_list", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.channel bll = new BLL.channel();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    //检查该频道下是否还有文章
                    int articleCount = new BLL.article().GetCount("channel_id=" + id);
                    if (articleCount > 0)
                    {
                        errorCount += 1;
                        continue;
                    }
                    Model.channel model = bll.GetModel(id);
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                        //删除URL配置
                        new BLL.url_rewrite().Remove("channel", model.name);
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除频道成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!",
                       Utils.CombUrlTxt("channel_list.aspx", "category_id={0}&keywords={1}", this.category_id.ToString(), txtKeywords.Text), "Success", "parent.loadMenuTree");
        }
예제 #2
0
 //批量删除
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("site_channel_list", DTEnums.ActionEnum.Delete.ToString()); //检查权限
     int sucCount = 0;
     int errorCount = 0;
     BLL.channel bll = new BLL.channel();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
         if (cb.Checked)
         {
             //检查该频道下是否还有文章
             int articleCount = new BLL.article().GetCount("channel_id=" + id);
             if (articleCount > 0)
             {
                 errorCount += 1;
                 continue;
             }
             Model.channel model = bll.GetModel(id);
             if (bll.Delete(id))
             {
                 sucCount += 1;
                 //删除URL配置
                 new BLL.url_rewrite().Remove("channel", model.name);
             }
             else
             {
                 errorCount += 1;
             }
         }
     }
     AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除频道成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
     JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!",
         Utils.CombUrlTxt("channel_list.aspx", "category_id={0}&keywords={1}", this.category_id.ToString(), this.keywords), "Success", "parent.loadMenuTree");
 }
예제 #3
0
        private bool DoEdit(int _id)
        {
            BLL.channel   bll   = new BLL.channel();
            Model.channel model = bll.GetModel(_id);

            string old_name = model.name;

            model.site_id   = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name      = txtName.Text.Trim();
            model.title     = txtTitle.Text.Trim();
            model.is_albums = 0;
            model.is_attach = 0;
            model.is_spec   = 0;
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List <Model.channel_field> ls = new List <Model.channel_field>();

            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.channel_field {
                        channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0)
                    });
                }
            }
            model.channel_fields = ls;

            if (!bll.Update(model))
            {
                return(false);
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", old_name); //先删除旧的
            string[] itemTypeArr     = Request.Form.GetValues("item_type");
            string[] itemNameArr     = Request.Form.GetValues("item_name");
            string[] itemPageArr     = Request.Form.GetValues("item_page");
            string[] itemTempletArr  = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr  = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) &&
                    (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name    = itemNameArr[i].Trim();
                        urlModel.type    = itemTypeArr[i].Trim();
                        urlModel.page    = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item {
                                    path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2]
                                });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(PLEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志
            return(true);
        }
예제 #4
0
        private void ShowInfo(int _id)
        {
            BLL.channel bll = new BLL.channel();
            Model.channel model = bll.GetModel(_id);

            txtTitle.Text = model.title;
            txtName.Text = model.name;
            txtName.Focus(); //设置焦点,防止JS无法提交
            txtName.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=channel_name_validate&old_channel_name=" + Utils.UrlEncode(model.name));
            ddlSiteId.SelectedValue = model.site_id.ToString();
            if (model.is_albums == 1)
            {
                cbIsAlbums.Checked = true;
            }
            if (model.is_attach == 1)
            {
                cbIsAttach.Checked = true;
            }
            if (model.is_spec == 1)
            {
                cbIsSpec.Checked = true;
            }
            txtSortId.Text = model.sort_id.ToString();

            //赋值扩展字段
            if (model.channel_fields != null)
            {
                for (int i = 0; i < cblAttributeField.Items.Count; i++)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    Model.channel_field modelt = model.channel_fields.Find(p => p.field_id == int.Parse(fieldIdArr[1])); //查找对应的字段ID
                    if (modelt != null)
                    {
                        cblAttributeField.Items[i].Selected = true;
                    }
                }
            }

            //绑定URL配置列表
            rptList.DataSource = new BLL.url_rewrite().GetList(model.name);
            rptList.DataBind();
        }
예제 #5
0
        private bool DoEdit(int _id)
        {
            BLL.channel bll = new BLL.channel();
            Model.channel model = bll.GetModel(_id);

            string old_name = model.name;
            model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name = txtName.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.is_albums = 0;
            model.is_attach = 0;
            model.is_spec = 0;
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List<Model.channel_field> ls = new List<Model.channel_field>();
            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.channel_field { channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0) });
                }
            }
            model.channel_fields = ls;

            if (!bll.Update(model))
            {
                return false;
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", old_name); //先删除旧的
            string[] itemTypeArr = Request.Form.GetValues("item_type");
            string[] itemNameArr = Request.Form.GetValues("item_name");
            string[] itemPageArr = Request.Form.GetValues("item_page");
            string[] itemTempletArr = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length)
                    && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name = itemNameArr[i].Trim();
                        urlModel.type = itemTypeArr[i].Trim();
                        urlModel.page = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List<Model.url_rewrite_item> itemLs = new List<Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志
            return true;
        }
예제 #6
0
        private void ShowInfo(int _id)
        {
            BLL.channel   bll   = new BLL.channel();
            Model.channel model = bll.GetModel(_id);

            txtTitle.Text = model.title;
            txtName.Text  = model.name;
            txtName.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=channel_name_validate&old_channel_name=" + Utils.UrlEncode(model.name));
            txtName.Focus(); //设置焦点,防止JS无法提交

            ddlSiteId.SelectedValue = model.site_id.ToString();
            if (model.is_albums == 1)
            {
                cbIsAlbums.Checked = true;
            }
            if (model.is_attach == 1)
            {
                cbIsAttach.Checked = true;
            }
            if (model.is_spec == 1)
            {
                cbIsSpec.Checked = true;
            }
            txtSortId.Text = model.sort_id.ToString();

            //扩展
            if (model.is_comment == 1)
            {
                cbIsComment.Checked = true;
            }
            if (model.is_attribute == 1)
            {
                cbIsAttr.Checked = true;
            }
            if (model.is_recycle == 1)
            {
                cbIsRecycle.Checked = true;
            }
            rblIsType.SelectedValue = model.is_type.ToString();
            txtHeight.Text          = model.height.ToString();
            txtWidth.Text           = model.width.ToString();

            //SEO优化
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeywords.Text    = model.seo_keywords;
            txtSeoDescription.Text = model.seo_description;

            //赋值扩展字段
            if (model.channel_fields != null)
            {
                for (int i = 0; i < cblAttributeField.Items.Count; i++)
                {
                    string[]            fieldIdArr = cblAttributeField.Items[i].Value.Split(',');                            //分解出ID值
                    Model.channel_field modelt     = model.channel_fields.Find(p => p.field_id == int.Parse(fieldIdArr[1])); //查找对应的字段ID
                    if (modelt != null)
                    {
                        cblAttributeField.Items[i].Selected = true;
                    }
                }
            }

            //绑定URL配置列表
            rptList.DataSource = new BLL.url_rewrite().GetList(model.name);
            rptList.DataBind();
        }