Beispiel #1
0
 public void Import(We7.CMS.Common.MenuItem it)
 {
     Created  = it.Created;
     Name     = it.Name;
     ID       = it.ID;
     Title    = it.Title;
     ParentID = it.ParentID;
     Type     = it.Type;
     Index    = it.Index;
     Href     = it.Href;
     Group    = it.Group;
 }
Beispiel #2
0
        /// <summary>
        /// 生成一级菜单字符串
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        string GenerateMenuItem(We7.CMS.Common.MenuItem menu, string pos, int index)
        {
            string frmMenu = @"
            <li class=""{0}"" id=""{1}"" {6} >
	            <div class=""we7-menu-image""><br></div>
	            <div class=""we7-menu-toggle""><br></div>
	            <a  class=""{3}"" tabindex=""1"">{4}</a>
	            <div class=""we7-submenu"">
		            <div class=""we7-submenu-head"">{4}</div>
		            <ul>
                    {5}
                    </ul>
	             </div>
            </li>";
            string liClass = "menu-top";

            if (index == 0)
            {
                liClass = AddCssClass(liClass, "we7-first-item");
            }
            if (menu.Items.Count > 0)
            {
                liClass = AddCssClass(liClass, "we7-has-submenu");
            }
            if (pos.IndexOf("first") > -1)
            {
                liClass = AddCssClass(liClass, "menu-top-first");
            }
            if (pos.IndexOf("last") > -1)
            {
                liClass = AddCssClass(liClass, "menu-top-last");
            }
            string js = "";// @"onmousemove=""menuHover(this)"" onmouseout=""menuOut(this)"" ";

            if (menu.ID == CurrentMenuID)
            {
                liClass = AddCssClass(liClass, "we7-has-current-submenu");
                liClass = AddCssClass(liClass, "we7-menu-open");
                js      = "";
            }

            //兼容admin目录
            //if (!menu.Href.ToLower().StartsWith("/admin/")) menu.Href = "/admin" + menu.Href;

            string aClass = liClass;
            string ret    = string.Format(frmMenu, liClass, GetIDFromIcon(menu.Icon), menu.Href, aClass, menu.Title, GenerateSubMenuItem(menu.Items, GetIDFromIcon(menu.Icon)), js);

            return(ret);
        }
Beispiel #3
0
 void BindingData()
 {
     We7.CMS.Common.MenuItem menuItem = new We7.CMS.Common.MenuItem();
     if (MenuID != null)
     {
         menuItem             = MenuHelper.GetMenuItem(MenuID);
         TitleTextBox.Text    = menuItem.Title;
         DesTextBox.Text      = menuItem.Name;
         IndexTextBox.Text    = menuItem.Index.ToString();
         UrlTextBox.Text      = menuItem.Href;
         CreateDateLabel.Text = menuItem.Created.ToString("yyyy-MM-dd");
         if (MenuID == "{00000000-0000-0000-0000-000000000000}")
         {
             GroupTextBox.Text = menuItem.Group.ToString();
         }
     }
 }
Beispiel #4
0
        MenuItemEx ConvertToEx(We7.CMS.Common.MenuItem menuItem, string keyword, int state)
        {
            if (state < 100)
            {
                if (state != menuItem.Type)
                {
                    return(null);
                }
                else if (!string.IsNullOrEmpty(keyword) && menuItem.Name.IndexOf(keyword) == -1)
                {
                    return(null);
                }
            }

            MenuItemEx menuItemEx = new MenuItemEx();

            menuItemEx.Import(menuItem);
            if (menuItem.Type == 99)
            {
                menuItemEx.MenuType             = "用户自定义菜单";
                menuItemEx.MenuDelVisble        = "";
                menuItemEx.MenuSystemVisble     = "none";
                menuItemEx.MenuSystemShowVisble = "none";
                menuItemEx.MenuDelUrl           = String.Format("javascript:DeleteConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            else if (menuItem.Type == 2)
            {
                menuItemEx.MenuType             = "隐藏菜单";
                menuItemEx.MenuDelVisble        = "none";
                menuItemEx.MenuSystemVisble     = "none";
                menuItemEx.MenuSystemShowVisble = "";
                menuItemEx.MenuSystemShowUrl    = String.Format("javascript:ShowConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            else
            {
                menuItemEx.MenuType             = "系统菜单";
                menuItemEx.MenuDelVisble        = "none";
                menuItemEx.MenuSystemVisble     = "";
                menuItemEx.MenuSystemShowVisble = "none";
                menuItemEx.MenuSystemUrl        = String.Format("javascript:HideConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            return(menuItemEx);
        }
Beispiel #5
0
        MenuItemEx ConvertToEx(We7.CMS.Common.MenuItem menuItem, string keyword, int state)
        {
            if (state < 100)
            {
                if (state != menuItem.Type)
                {
                    return(null);
                }
                else if (!string.IsNullOrEmpty(keyword) && menuItem.Name.IndexOf(keyword) == -1)
                {
                    return(null);
                }
            }

            MenuItemEx menuItemEx = new MenuItemEx();

            menuItemEx.Import(menuItem);
            string suffix = "";

            switch (menuItem.MenuType)
            {
            case 0:
                suffix = "(普通)";
                break;

            case 1:
                suffix = "(顶级)";
                break;

            case 2:
                suffix = "(分组)";
                break;

            case 3:
                suffix = "(引用)";
                break;

            default:
                suffix = "(普通)";
                break;
            }
            if (menuItem.Type == 99)
            {
                menuItemEx.MenuType             = "用户自定义菜单" + suffix;
                menuItemEx.MenuDelVisble        = "";
                menuItemEx.MenuSystemVisble     = "none";
                menuItemEx.MenuSystemShowVisble = "none";
                menuItemEx.MenuDelUrl           = String.Format("javascript:DeleteConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            else if (menuItem.Type == 2)
            {
                menuItemEx.MenuType             = "隐藏菜单" + suffix;
                menuItemEx.MenuDelVisble        = "none";
                menuItemEx.MenuSystemVisble     = "none";
                menuItemEx.MenuSystemShowVisble = "";
                menuItemEx.MenuSystemShowUrl    = String.Format("javascript:ShowConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            else
            {
                menuItemEx.MenuType             = "系统菜单" + suffix;
                menuItemEx.MenuDelVisble        = "none";
                menuItemEx.MenuSystemVisble     = "";
                menuItemEx.MenuSystemShowVisble = "none";
                menuItemEx.MenuSystemUrl        = String.Format("javascript:HideConfirm('{0}','{1}');", menuItem.ID, menuItem.Name);
            }
            return(menuItemEx);
        }
Beispiel #6
0
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     We7.CMS.Common.MenuItem menuItem = new We7.CMS.Common.MenuItem();
     if (MenuID != null)
     {
         string menuName = TitleTextBox.Text.Trim();
         if (MenuHelper.ExistMenuItem(menuName, MenuID))
         {
             Messages.ShowMessage("请您更换菜单名字");
             return;
         }
         menuItem.ID    = MenuID;
         menuItem.Index = Int32.Parse(IndexTextBox.Text.Trim());
         menuItem.Href  = UrlTextBox.Text.Trim();
         menuItem.Name  = DesTextBox.Text.Trim();
         menuItem.Title = TitleTextBox.Text.Trim();
         if (MenuID == "{00000000-0000-0000-0000-000000000000}")
         {
             string theme = SiteSettingHelper.Instance.Config.CMSTheme;
             if (theme == null || theme == "")
             {
                 theme = "classic";
             }
             string  path   = "~/" + Constants.ThemePath + "/" + theme + "/images";
             Boolean fileOk = false;
             //判断是否选择了文件
             if (IconFileUpload.HasFile)
             {
                 //返回文件的扩展名
                 string fileExtension = System.IO.Path.GetExtension(IconFileUpload.FileName).ToLower();
                 //设置文件类型
                 string[] allowExtensions = { ".jpg", ".gif", ".png" };
                 //判断选择文件是否符合条件
                 for (int i = 0; i < allowExtensions.Length; i++)
                 {
                     if (fileExtension == allowExtensions[i])
                     {
                         fileOk = true;
                     }
                 }
                 //文件大小的设置
                 if (IconFileUpload.PostedFile.ContentLength > 1024000)
                 {
                     fileOk = false;
                 }
                 if (fileOk)
                 {
                     string pathFile = Path.Combine(path, IconFileUpload.FileName);
                     IconFileUpload.PostedFile.SaveAs(Server.MapPath(pathFile));
                     menuItem.Icon = IconFileUpload.FileName;
                 }
                 else
                 {
                     throw new Exception("图片类型不对或文件超出1024KB!");
                 }
             }
             else
             {
                 throw new Exception("请选择需要上传的图片...");
             }
             menuItem.Group = Int32.Parse(GroupTextBox.Text.Trim());
         }
         MenuHelper.UpdateMenuItem(menuItem);
         Messages.ShowMessage("更新成功");
     }
 }
Beispiel #7
0
        /// <summary>
        /// 检查各项是否已经创建
        /// </summary>
        void Exist()
        {
            IDataBaseHelper helper = DataBaseHelperFactory.Create();
            StringBuilder   sb     = new StringBuilder();

            sb.Append("{\"modelName\":\"" + ModelInfo.ModelName + "\",\"Data\":[");

            #region 检查部件
            //部件
            int    widgetCount  = 0;
            string viewPath     = ModelHelper.GetWidgetDirectory(modelInfo, "View");
            string listPath     = ModelHelper.GetWidgetDirectory(modelInfo, "List");
            string pageListPath = ModelHelper.GetWidgetDirectory(modelInfo, "PagedList");
            if (Directory.Exists(viewPath))
            {
                widgetCount++;
            }
            if (Directory.Exists(listPath))
            {
                widgetCount++;
            }
            if (Directory.Exists(pageListPath))
            {
                widgetCount++;
            }
            //存在至少一个部件
            if (widgetCount > 0)
            {
                sb.Append("{\"name\":\"createWidget\",\"exist\":true},");
            }
            else
            {
                sb.Append("{\"name\":\"createWidget\",\"exist\":false},");
            }
            #endregion

            if (isArticle)
            {
                #region 检查表结构
                int rowCount = 0;
                try
                {
                    rowCount = helper.Count(ModelInfo.Name, "");
                    sb.Append("{\"name\":\"createTable\",\"exist\":true},");
                }
                catch
                {
                    sb.Append("{\"name\":\"createTable\",\"exist\":false},");
                }

                #endregion

                #region 检查左侧菜单
                MenuHelper MenuHelper        = HelperFactory.Instance.GetHelper <MenuHelper>();
                We7.CMS.Common.MenuItem item = MenuHelper.GetMenuItemByTitle(ModelInfo.Label + "管理");
                if (item != null && !string.IsNullOrEmpty(item.ID))
                {
                    sb.Append("{\"name\":\"addLeftMenu\",\"exist\":true},");
                }
                else
                {
                    sb.Append("{\"name\":\"addLeftMenu\",\"exist\":false},");
                }
                #endregion

                #region 检查布局

                string layoutPath = ModelHelper.GetModelLayoutDirectory(ModelInfo.ModelName) + "GenerateLayout.ascx";
                if (File.Exists(layoutPath))
                {
                    layoutPath = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, ModelInfo.GroupName, ModelInfo.Name, "GenerateLayout.ascx");
                    EditInfo entity = ModelInfo.Layout.Panels["edit"].EditInfo;
                    sb.Append("{\"name\":\"createLayout\",\"exist\":true,\"path\":\"" + layoutPath + "\"},");

                    //ModelInfo.Layout.Panels["edit"].EditInfo.Layout;
                    if (!string.IsNullOrEmpty(entity.Layout))
                    {
                        chkAE.Checked = true;
                    }

                    if (!string.IsNullOrEmpty(entity.ViewerLayout))
                    {
                        chkView.Checked = true;
                    }

                    if (!string.IsNullOrEmpty(entity.UcLayout))
                    {
                        chkUC.Checked = true;
                    }
                }
                else
                {
                    sb.Append("{\"name\":\"createLayout\",\"exist\":false},");
                }


                #endregion
            }
            sb.Append("]}");
            strScript = sb.ToString();
            strScript = strScript.Remove(strScript.LastIndexOf(","), 1);

            strScript = new JavaScriptSerializer().Serialize(strScript);
        }