Inheritance: IEntity
        void LoadMenuItem()
        {
            int menuID = 0;
            int.TryParse(Request.QueryString[CMSConfig.QueryString.MenuID], out menuID);

            if (base.XSLTemplateID > 0 && menuID > 0)
            {
                string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
                xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);

                XsltArgumentList arguments = new XsltArgumentList();
                arguments.AddExtensionObject("CMS:UserControl", this);

                Menu menu = new Menu();
                xmlMenu.DocumentContent = MenuManager.GetMenuItemTemplateXml(menuID, CMSContext.LanguageID, out menu);
                xmlMenu.TransformSource = xslPath;
                xmlMenu.TransformArgumentList = arguments;
                xmlMenu.DataBind();

                bool SetPageTitle = false;
                bool.TryParse(this.Attributes["SetPageTitle"], out SetPageTitle);

                if (SetPageTitle && menu != null)
                {
                    this.Page.Title = menu.Name;
                }
            }
        }
Exemple #2
0
 public static int Add(Menu menu)
 {
     if (menu.ParentObjectID > 0)
     {
         Menu menu2 = GetMenu(menu.ParentObjectID, menu.LanguageID);
         if (menu2 != null)
             throw new Exception("Menu is exists in the same language, please choose another language");
     }
     return MenuDataMapper.Add(menu);
 }
Exemple #3
0
 public static void Update(Menu menu)
 {
     MenuDataMapper.Update(menu);
 }
Exemple #4
0
        private static void SetAttributeMenuNode(XmlElement xmlEle, Menu menuItem)
        {
            XmlAttribute xmlAtt = xmlEle.OwnerDocument.CreateAttribute("ID");
            xmlAtt.Value = menuItem.ID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Description");
            xmlAtt.Value = menuItem.Description;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Image");
            xmlAtt.Value = menuItem.Image;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Name");
            xmlAtt.Value = menuItem.Name;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("PageID");
            xmlAtt.Value = menuItem.PageID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("ParentID");
            xmlAtt.Value = menuItem.ParentID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            switch (menuItem.MenuType)
            {
                case Enums.CMSEnums.MenuType.Static:
                    NameValueCollection valueCollection = HttpUtility.ParseQueryString(menuItem.URL);
                    if (string.IsNullOrEmpty(valueCollection[CMSConfig.QueryString.MenuID]))
                    {
                        if (menuItem.URL.Contains("?"))
                        {
                            menuItem.URL += "&" + CMSConfig.QueryString.MenuID + "=" + menuItem.ID;
                        }
                        else
                        {
                            menuItem.URL += "?" + CMSConfig.QueryString.MenuID + "=" + menuItem.ID;
                        }
                    }
                    break;
            }
            if (menuItem.GalleryCategoryID > 0)
            {
                if (menuItem.URL.Contains("?"))
                {
                    menuItem.URL += "&" + CMSConfig.QueryString.CategoryID + "=" + menuItem.GalleryCategoryID;
                }
                else
                {
                    menuItem.URL += "?" + CMSConfig.QueryString.CategoryID + "=" + menuItem.GalleryCategoryID;
                }
            }
            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("URL");
            xmlAtt.Value = menuItem.URL;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("MenuType");
            xmlAtt.Value = ((int)(menuItem.MenuType)).ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Order");
            xmlAtt.Value = menuItem.Order.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("CategoryID");
            xmlAtt.Value = menuItem.CategoryID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("GalleryCategoryID");
            xmlAtt.Value = menuItem.GalleryCategoryID.ToString();
            xmlEle.Attributes.Append(xmlAtt);
        }
Exemple #5
0
        public static string GetMenuItemTemplateXml(int menuId, int languageId, out Menu menu)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlElement xmlRoot = xmlDoc.CreateElement("Menus");
            xmlDoc.AppendChild(xmlRoot);

            XmlElement menuItemElement = xmlDoc.CreateElement("Menu");
            xmlRoot.AppendChild(menuItemElement);

            menu = GetMenuByIdAndLanguage(menuId, languageId);
            if (menu != null)
            {
                SetAttributeMenuNode(menuItemElement, menu);

                XmlAttribute attr = xmlDoc.CreateAttribute("Details");
                attr.Value = menu.Details;
                menuItemElement.Attributes.Append(attr);
            }

            return xmlDoc.OuterXml;
        }
        /// <summary>
        /// This Method Fills Main Parent Id (Parent Id Of Parent Obj Id If Exists Else Parent Id Of Item It Self)
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="reader"></param>
        internal static void FillFromReaderWithMainParentID(Menu menu, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_MENU_CATEGORY_ID);
            if (!reader.IsDBNull(colIndex))
                menu.CategoryID = reader.GetInt32(colIndex);

            int days = 0, seconds = 0;
            colIndex = reader.GetOrdinal(CN_MENU_CREATION_DAY);
            if (!reader.IsDBNull(colIndex))
                days = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_CREATION_SEC);
            if (!reader.IsDBNull(colIndex))
                seconds = reader.GetInt32(colIndex);

            menu.CreationDate = CMSCoreHelper.GetDateTime(days, seconds);

            colIndex = reader.GetOrdinal(CN_MENU_DESCRIPTION);
            if (!reader.IsDBNull(colIndex))
                menu.Description = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_DETAILS);
            if (!reader.IsDBNull(colIndex))
                menu.Details = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_ID);
            if (!reader.IsDBNull(colIndex))
                menu.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_IMAGE);
            if (!reader.IsDBNull(colIndex))
                menu.Image = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                menu.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_KEYWORDS);
            if (!reader.IsDBNull(colIndex))
                menu.KeyWords = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_LANGUAGE_ID);
            if (!reader.IsDBNull(colIndex))
                menu.LanguageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_NAME);
            if (!reader.IsDBNull(colIndex))
                menu.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_PAGE_ID);
            if (!reader.IsDBNull(colIndex))
                menu.PageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_PARENT_ID);
            if (!reader.IsDBNull(colIndex))
                menu.ParentID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                menu.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_SEO_NAME);
            if (!reader.IsDBNull(colIndex))
                menu.SEOName = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_URL);
            if (!reader.IsDBNull(colIndex))
                menu.URL = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_TYPE);
            if (!reader.IsDBNull(colIndex))
                menu.MenuType = (CMSEnums.MenuType)reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_ORDER);
            if (!reader.IsDBNull(colIndex))
                menu.Order = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_CREATED_BY);
            if (!reader.IsDBNull(colIndex))
                menu.CreatedBy = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_PARENT_OBJ_ID);
            if (!reader.IsDBNull(colIndex))
                menu.ParentObjectID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(PublishDataMapper.CN_PUBLISH_TYPE_ID);
            if (!reader.IsDBNull(colIndex))
                menu.IsPublished = reader.GetInt32(colIndex) == (int)AJH.CMS.Core.Enums.CMSEnums.PublishType.PublishNow;

            colIndex = reader.GetOrdinal(CN_MAIN_PARENT_ID);
            if (!reader.IsDBNull(colIndex))
                menu.MainParentID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_GALLERY_CATEGORY_ID);
            if (!reader.IsDBNull(colIndex))
                menu.GalleryCategoryID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_MENU_PAGE_TITLE);
            if (!reader.IsDBNull(colIndex))
                menu.PageTitle = reader.GetString(colIndex);
        }
        internal static Menu GetMenu(List<Menu> menus, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_MENU_ID);
            int value = reader.GetInt32(colIndex);

            Menu menu = menus.Where(c => c.ID == value).FirstOrDefault();
            if (menu == null)
            {
                menu = new Menu();
                menus.Add(menu);
            }
            return menu;
        }
        internal static Menu GetMenu(int parentObjID, int languageID)
        {
            Menu menu = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_MENU_GET_BY_PARENT_OBJ_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;

                sqlParameter = new SqlParameter(PN_MENU_PARENT_OBJ_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = parentObjID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_MENU_LANGUAGE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = languageID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PublishDataMapper.PN_PUBLISH_MODULE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = (int)AJH.CMS.Core.Enums.CMSEnums.Modules.Menu;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {

                    while (sqlDataReader.Read())
                    {
                        menu = new Menu();
                        FillFromReaderByParentObjID(menu, sqlDataReader);
                    }

                    sqlDataReader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return menu;
        }