Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public int MoveTo(string[] ids, string[] nodes)
        {
            if (ids.Length == 0)
            {
                throw new Exception("被移动的文章未选择!");
            }
            if (nodes.Length == 0)
            {
                throw new Exception("要移动到的栏目未选择!");
            }

            int r = 0;

            try
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    cmsNewsCatalog nc = NewsCatalogService.GetInstance().Get(nodes[i]);

                    string sql = @"update cmsNews set nodecode='{0}',langId={1} where 1=1 and Id in ('{2}')";
                    sql = string.Format(sql, nodes[i], nc.LangId, string.Join("','", ids).Replace("'0',", ""));

                    r = DBSession.CurrentSession.FromSql(sql).ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(r);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="catalogs"></param>
        /// <param name="parentCode"></param>
        /// <param name="prefix"></param>
        private void buildCatalogTree(Table tbl, List <cmsNewsCatalog> catalogs, List <cmsNewsCatalog> childs, string prefix)
        {
            string pf = "";

            for (int i = 0; i < childs.Count; i++)
            {
                cmsNewsCatalog        item     = childs[i];
                List <cmsNewsCatalog> children = catalogs.FindAll(m => m.ParentCode == item.NodeCode);

                if (IsAdmin || PurviewExists(item.NodeCode, 0))
                {
                    TableRow tr = new TableRow();
                    tr.CssClass = "Row";

                    // 复选框
                    TableCell td = new TableCell();
                    td.Width = Unit.Pixel(20);
                    HtmlInputCheckBox cb = new HtmlInputCheckBox();
                    cb.ID = "C" + item.NodeCode;
                    cb.Attributes.Add("class", "C");
                    cb.Value = item.NodeCode;
                    cb.Attributes.Add("onclick", "selectCatalog(this);");
                    if (children.Count > 0)
                    {
                        cb.Attributes.Add("disabled", "disabled");
                    }
                    td.Controls.Add(cb);
                    tr.Cells.Add(td);
                    // 栏目名称
                    td = new TableCell();
                    td.Style.Add("text-align", "left");
                    //td.Style.Add("padding-left", "10px");
                    if (i < childs.Count - 1)
                    {
                        td.Text = prefix + "├" + item.NodeName;
                        pf      = prefix + "│";
                    }
                    else
                    {
                        td.Text = prefix + "└" + item.NodeName;
                        pf      = prefix + " "; // 全角空格[ ]制表符[│][├][└]
                    }
                    tr.Cells.Add(td);
                    tbl.Rows.Add(tr);


                    if (children.Count > 0)
                    {
                        buildCatalogTree(tbl, catalogs, children, pf);
                    }
                    else
                    {
                        if (item.NodeType == 0)
                        {
                            tbl.Rows.Remove(tr);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="catalogs"></param>
        /// <param name="parentCode"></param>
        /// <param name="prefix"></param>
        private void buildNewsCatalogTree(DropDownList ddl, List <cmsNewsCatalog> catalogs, string parentCode, string prefix)
        {
            string pf = "";
            List <cmsNewsCatalog> childs = catalogs.FindAll(delegate(cmsNewsCatalog m) { return(m.ParentCode == parentCode); });

            for (int i = 0; i < childs.Count; i++)
            {
                cmsNewsCatalog item = childs[i];

                ListItem itm = new ListItem();
                itm.Value = item.NodeCode;
                if (i < childs.Count - 1)
                {
                    itm.Text = prefix + "├" + item.NodeName;
                    pf       = prefix + "│";
                }
                else
                {
                    itm.Text = prefix + "└" + item.NodeName;
                    pf       = prefix + " "; // 全角空格[ ]制表符[│][├][└]
                }
                ddl.Items.Add(itm);

                buildNewsCatalogTree(ddl, catalogs, item.NodeCode, pf);
            }
        }
Exemplo n.º 4
0
 protected void ddlParentNode_SelectedIndexChanged(object sender, EventArgs e)
 {
     catalog = ncs.Get(ddlParentNode.SelectedValue);
     if (catalog != null)
     {
         ddlType.SelectedValue = catalog.NodeType.ToString();
     }
     txtOrder.Text = ncs.GetNextOrder(ddlParentNode.SelectedValue).ToString();
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id     = Request["id"];
            action = Request["action"];
            action = (string.IsNullOrEmpty(action)) ? "add" : action;

            catalog = ncs.Get(NodeCode);

            if (!IsPostBack)
            {
                InitControls();

                InitData();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="menus"></param>
        /// <param name="parentCode"></param>
        /// <param name="prefix"></param>
        private void buildCatalogTree(Table tbl, List <cmsNewsCatalog> menus, string parentCode, string prefix)
        {
            string pf = "";
            List <cmsNewsCatalog> childs = menus.FindAll(delegate(cmsNewsCatalog m) { return(m.ParentCode == parentCode); });

            for (int i = 0; i < childs.Count; i++)
            {
                cmsNewsCatalog item = childs[i];

                {
                    TableRow tr = new TableRow();
                    tr.CssClass = "Row";

                    // 复选框
                    TableCell td = new TableCell();
                    td.Width = Unit.Pixel(20);
                    HtmlInputCheckBox cb = new HtmlInputCheckBox();
                    cb.ID = "C" + item.NodeCode;
                    cb.Attributes.Add("class", "C");
                    cb.Value = item.NodeCode;
                    cb.Attributes.Add("onclick", "selectCatalog(this);");
                    td.Controls.Add(cb);
                    tr.Cells.Add(td);
                    // 栏目名称
                    td = new TableCell();
                    td.Style.Add("text-align", "left");
                    //td.Style.Add("padding-left", "10px");
                    if (i < childs.Count - 1)
                    {
                        td.Text = prefix + "├" + item.NodeName;
                        pf      = prefix + "│";
                    }
                    else
                    {
                        td.Text = prefix + "└" + item.NodeName;
                        pf      = prefix + " "; // 全角空格[ ]制表符[│][├][└]
                    }
                    tr.Cells.Add(td);

                    tbl.Rows.Add(tr);

                    buildCatalogTree(tbl, menus, item.NodeCode, pf);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string getNodeUrl(cmsNewsCatalog node, bool addTags)
        {
            string url = "", target = "";
            string aformat = "<a href='{0}' title='{1}' target='{2}'>{1}</a>";

            if (node == null)
            {
                return(addTags ? string.Format(aformat, "", "", "") : url);
            }
            string nodename = node.NodeName;
            int    t        = node.NodeType;

            if (t == 0)
            {
                cmsNewsCatalog nc = getFirstNode(node.NodeCode);
                if (nc != null)
                {
                    node = nc;
                    t    = node.NodeType;
                }
            }
            cmsModule mdl      = ModuleService.GetInstance().GetModel(t);
            string    frontUrl = mdl == null ? "NewsList.aspx" : mdl.FrontUrl;
            string    u1       = string.Empty;
            string    u2       = string.Empty;

            if (frontUrl.Length > 1)
            {
                string[] u = frontUrl.Split('.');
                u1 = "/" + u[0] + "/{0}.html";     // 如 "/Page/0001.html"
                u2 = "/" + frontUrl + "?node={0}"; // 如 "/Page.aspx"
            }
            if (t != 20)                           // 不是外链模块
            {
                url = CurrentLanguage.HomeUrl.TrimEnd('/') + string.Format((IsUrlRewrite ? u1 : u2), node.NodeCode);
                url = GetClientUrl(url);
            }
            else
            {
                url    = node.LinkUrl;
                target = "_blank";
            }
            return(addTags ? string.Format(aformat, url, nodename, target) : url);
        }
Exemplo n.º 8
0
        private void InitData()
        {
            if (!string.IsNullOrEmpty(code))
            {
                catalog = ncs.Get(code);
                if (action.Equals("add"))
                {
                    ddlParentNode.SelectedValue = code;
                    txtOrder.Text = ncs.GetNextOrder(code).ToString();
                    if (catalog != null)
                    {
                        ddlType.SelectedValue = catalog.NodeType.ToString();
                    }
                }
                else if (action.Equals("edit") && catalog != null)
                {
                    hidCode.Value             = catalog.NodeCode;
                    ddlLanguage.SelectedValue = catalog.LangId + "";
                    ddlLanguage.Enabled       = false;

                    CatalogBind();
                    ddlParentNode.SelectedValue = catalog.ParentCode;
                    txtName.Text          = catalog.NodeName;
                    txtTitle.Text         = catalog.Title;
                    txtSubTitle.Text      = catalog.SubTitle;
                    txtLinkUrl.Text       = catalog.LinkUrl;
                    txtBackUrl.Text       = catalog.BackUrl;
                    hidImages1.Value      = catalog.BigPic;
                    hidImages2.Value      = catalog.SmallPic;
                    ddlType.SelectedValue = catalog.NodeType.ToString();
                    if (!ConfigHelper.GetVal <bool>("NodeTypeIsEditable"))
                    {
                        ddlType.Enabled = false;
                    }
                    txtOrder.Text            = catalog.OrderNo.ToString();
                    rblNavType.SelectedValue = catalog.NavType.ToString();
                    chkEnabled.Checked       = catalog.IsEnabled == 1;
                }
            }
            else
            {
                CatalogBind();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="catalogs"></param>
        /// <param name="purviews"></param>
        /// <param name="parentCode"></param>
        /// <param name="prefix"></param>
        private void buildNewsCatalogTree(DropDownList ddl, List <cmsNewsCatalog> catalogs, string parentCode, List <cmsNewsCatalog> childs, string prefix)
        {
            string pf = "";

            for (int i = 0; i < childs.Count; i++)
            {
                cmsNewsCatalog item = childs[i];
                if (IsAdmin || PurviewExists(item.NodeCode, 0))
                {
                    ListItem itm = new ListItem();
                    itm.Value = item.NodeCode;
                    if (i < childs.Count - 1)
                    {
                        itm.Text = prefix + "├" + item.NodeName;
                        pf       = prefix + "│";
                    }
                    else
                    {
                        itm.Text = prefix + "└" + item.NodeName;
                        pf       = prefix + " "; // 全角空格[ ]制表符[│][├][└]
                    }
                    ddl.Items.Add(itm);

                    List <cmsNewsCatalog> children = catalogs.FindAll(m => m.ParentCode == item.NodeCode);
                    if (children.Count > 0)
                    {
                        buildNewsCatalogTree(ddl, catalogs, item.NodeCode, children, pf);
                    }
                    else
                    {
                        if (item.NodeType == 0)
                        {
                            ddlCatalog.Items.Remove(itm);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public int CopyTo(string[] ids, string[] nodes)
        {
            if (ids.Length == 0)
            {
                throw new Exception("被复制的文章未选择!");
            }
            if (nodes.Length == 0)
            {
                throw new Exception("要复制到的栏目未选择!");
            }

            int r = 0;

            try
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    cmsNewsCatalog nc = NewsCatalogService.GetInstance().Get(nodes[i]);

                    for (int j = 0; j < ids.Length; j++)
                    {
                        string sql = @"insert into cmsNews(RGuid,NodeCode,Title,Content,Summary,Tags,Author,Source,SmallPic,Pics,Hits,AddTime,AddUser,EditTime,EditUser,OrderNo,IsIndex,IsTop,IsAudit,AuditTime,AuditUser,AuditComment,ProductNo,ProductModel,Parameter1,Parameter2,Parameter3,Parameter4,Parameter5,langId)
                                   select '{0}','{1}',Title,Content,Summary,Tags,Author,Source,SmallPic,Pics,Hits,AddTime,AddUser,EditTime,EditUser,OrderNo,IsIndex,IsTop,IsAudit,AuditTime,AuditUser,AuditComment,ProductNo,ProductModel,Parameter1,Parameter2,Parameter3,Parameter4,Parameter5,{2} from cmsNews 
                                   where 1=1 and Id='{3}'";
                        sql = string.Format(sql, Guid.NewGuid().ToString(), nodes[i], nc.LangId, ids[j]);
                        r   = DBSession.CurrentSession.FromSql(sql).ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(r);
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="menus"></param>
        /// <param name="parentCode"></param>
        /// <param name="prefix"></param>
        private void buildCatalogTree(Table tbl, List <cmsNewsCatalog> menus, string parentCode, string prefix, long language)
        {
            string pf = "";
            List <cmsNewsCatalog> childs = menus.FindAll(delegate(cmsNewsCatalog m) { return(m.ParentCode == parentCode); });

            for (int i = 0; i < childs.Count; i++)
            {
                cmsNewsCatalog item = childs[i];

                TableRow tr = new TableRow();
                tr.CssClass = "Row";

                TableCell td = null;
                //
                //if (!language.Equals(item.Language.Value) && i == 0)
                //{
                //    td = new TableCell();
                //    tr.Cells.Add(td);
                //    //tr.CssClass = "HeaderRow";
                //    td = new TableCell();
                //    td.ColumnSpan = 6;
                //    td.BackColor = System.Drawing.ColorTranslator.FromHtml("#dddddd");
                //    td.Font.Size = FontUnit.Larger;
                //    td.Font.Bold = true;
                //    td.Style.Add("text-align", "left");
                //    td.Style.Add("padding-left", "10px");
                //    td.Text = dicLang[item.Language.Value];
                //    tr.Cells.Add(td);
                //    tbl.Rows.Add(tr);

                //    tr = new TableRow();
                //    tr.CssClass = "Row";
                //}
                // 所属语言
                //td = new TableCell();
                //td.Style.Add("text-align", "left");
                //td.Style.Add("padding-left", "10px");
                //td.Text = dicLang[item.Language.Value];
                //tr.Cells.Add(td);

                // 排序号
                td = new TableCell();
                HtmlInputText inp = new HtmlInputText();
                inp.ID   = item.NodeCode;
                inp.Size = 4;
                inp.Style.Add("text-align", "center");
                inp.Attributes.Add("onblur", "changeOrder('" + inp.ID + "'," + item.OrderNo + ",this.value);");
                inp.Value = item.OrderNo.ToString();
                //td.Text = item.OrderNo.ToString();
                td.Controls.Add(inp);
                tr.Cells.Add(td);
                // 栏目名称
                td = new TableCell();
                td.Style.Add("text-align", "left");
                td.Style.Add("padding-left", "10px");
                if (i < childs.Count - 1)
                {
                    td.Text = prefix + "├" + item.NodeName;
                    pf      = prefix + "│";
                }
                else
                {
                    td.Text = prefix + "└" + item.NodeName;
                    pf      = prefix + " "; // 全角空格[ ]制表符[│][├][└]
                }
                tr.Cells.Add(td);
                // 栏目前台链接
                td = new TableCell();
                td.Style.Add("text-align", "left");
                td.Text = item.LinkUrl;
                tr.Cells.Add(td);
                // 栏目后台链接
                //td = new TableCell();
                //td.Style.Add("text-align", "left");
                //td.Text = item.BackUrl;
                //tr.Cells.Add(td);
                // 栏目类别
                td      = new TableCell();
                td.Text = dictonaries[item.NodeType];
                tr.Cells.Add(td);
                // 导航
                td = new TableCell();
                //HtmlAnchor nav = new HtmlAnchor();
                //nav.InnerText = getNavTypeStr(item.NavType);
                //nav.HRef = "javascript:void(0);";
                //nav.Attributes.Add("onclick", "nav(this, '" + item.NodeCode + "'); return false;");
                //td.Controls.Add(nav);
                td.Text = getNavTypeStr(item.NavType);
                tr.Cells.Add(td);
                // 启用
                td = new TableCell();
                HtmlAnchor enable = new HtmlAnchor();
                enable.InnerText = item.IsEnabled == 1 ? "是" : "否";
                enable.HRef      = "javascript:void(0);";
                enable.Attributes.Add("onclick", "enable(this, '" + item.NodeCode + "'); return false;");
                td.Controls.Add(enable);
                tr.Cells.Add(td);
                // 操作
                td = new TableCell();
                HtmlAnchor add = new HtmlAnchor();
                add.InnerText = "添加";
                add.HRef      = "NewsCatalogAdd.aspx?node=" + NodeCode + "&code=" + item.NodeCode + "&action=add&lang=" + ddlLanguage.SelectedValue;
                td.Controls.Add(add);
                HtmlGenericControl blank = new HtmlGenericControl();
                blank.InnerText = " ";
                td.Controls.Add(blank);
                HtmlAnchor edit = new HtmlAnchor();
                edit.InnerText = "编辑";
                edit.HRef      = "NewsCatalogAdd.aspx?node=" + NodeCode + "&code=" + item.NodeCode + "&action=edit";
                td.Controls.Add(edit);
                blank           = new HtmlGenericControl();
                blank.InnerText = " ";
                td.Controls.Add(blank);
                HtmlAnchor del = new HtmlAnchor();
                del.InnerText = "删除";
                del.HRef      = "javascript:void(0);";
                del.Attributes.Add("onclick", "del('" + item.NodeCode + "'); return false;");
                td.Controls.Add(del);
                tr.Cells.Add(td);

                tbl.Rows.Add(tr);

                buildCatalogTree(tbl, menus, item.NodeCode, pf, item.LangId);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="node"></param>
 /// <param name="addTags"></param>
 /// <returns></returns>
 public string GetNodeUrl(cmsNewsCatalog node, bool addTags)
 {
     return(getNodeUrl(node, addTags));
 }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <param name="addTags"></param>
        /// <returns></returns>
        public string GetNodeUrl(string node, bool addTags)
        {
            cmsNewsCatalog c = NewsCatalogService.GetInstance().Get(node);

            return(getNodeUrl(c, addTags));
        }
Exemplo n.º 14
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlLanguage.SelectedValue == "0")
            {
                ScriptUtil.Alert("请选择所属语言!");
                return;
            }

            if (string.IsNullOrEmpty(txtOrder.Text.Trim()))
            {
                txtOrder.Text = "0";
            }

            if (action.Equals("add"))
            {
                catalog        = new cmsNewsCatalog();
                catalog.LangId = Convert.ToInt32(ddlLanguage.SelectedValue);
            }
            else if (action.Equals("edit"))
            {
                if (ddlParentNode.SelectedValue.StartsWith(hidCode.Value))
                {
                    ScriptUtil.Alert("上级栏目不能设为自身或其子级!");
                    return;
                }
                catalog = ncs.Get(code);
                if (catalog != null)
                {
                    catalog.Attach();
                }
                else
                {
                    catalog        = new cmsNewsCatalog();
                    catalog.LangId = Convert.ToInt64(ddlLanguage.SelectedValue);
                }
            }
            if (catalog.ParentCode != ddlParentNode.SelectedValue)
            {
                catalog.NodeCode = ncs.GetNextChildCode(ddlParentNode.SelectedValue);
            }
            catalog.ParentCode = ddlParentNode.SelectedValue;
            catalog.NodeName   = txtName.Text.Trim();
            catalog.NodeType   = Convert.ToInt32(ddlType.SelectedValue);
            catalog.Title      = string.IsNullOrEmpty(txtTitle.Text) ? catalog.NodeName : txtTitle.Text;
            catalog.SubTitle   = txtSubTitle.Text;
            catalog.LinkUrl    = txtLinkUrl.Text.Trim();
            if (catalog.NodeType == 0)
            {
                catalog.BackUrl = "";
            }
            //if (action == "add")
            {
                cmsModule mdl = ModuleService.GetInstance().GetModel(catalog.NodeType);
                if (mdl != null && !string.IsNullOrEmpty(mdl.Url))
                {
                    catalog.BackUrl = mdl.Url;                                               //txtBackUrl.Text.Trim();
                }
            }
            catalog.OrderNo   = Convert.ToInt32(txtOrder.Text.Trim());
            catalog.NavType   = int.Parse(rblNavType.SelectedValue);
            catalog.IsEnabled = chkEnabled.Checked ? 1 : 0;
            catalog.BigPic    = hidImages1.Value;
            catalog.SmallPic  = hidImages2.Value;
            try
            {
                int r = ncs.Save(catalog);
                //if (r > 0)
                {
                    hidCode.Value = catalog.NodeCode;

                    if (action.Equals("add"))
                    {
                        ScriptUtil.ConfirmAndRedirect(@"栏目添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "NewsCatalogAdd.aspx?node=" + NodeCode + "&code=" + ddlParentNode.SelectedValue + "&lang=" + ddlLanguage.SelectedValue, "NewsCatalogList.aspx?node=" + NodeCode + "&lang=" + ddlLanguage.SelectedValue);
                    }
                    else
                    {
                        ScriptUtil.ConfirmAndRedirect(@"栏目修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "NewsCatalogAdd.aspx?node=" + NodeCode + "&code=" + code + "&action=" + action, "NewsCatalogList.aspx?node=" + NodeCode + "&lang=" + ddlLanguage.SelectedValue);
                        //ScriptUtil.Alert("栏目修改成功!");
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }