示例#1
0
 public void Fill()
 {
     //if ((this.menu_id_val == null) || (this.targetid_val == null) || (this.targettype_val == null))
     //{
     //    Exception ex = new Exception(this.GetType().ToString() + ": Menu_id or targettype or targetid is null.");
     //    ex.Source = ExceptionSource;
     //    throw (ex);
     //}
     //else
     //{
     Ektron.Cms.Controls.Menu motemp = new Ektron.Cms.Controls.Menu();
     motemp.CacheInterval = 60;
     motemp.DefaultMenuID = this.menu_id_val.val;
     motemp.Fill();
     this.CommonConstructor(motemp, this.targettype_val, this.targetid_val);
     //}
 }
示例#2
0
            private void CommonConstructor(Ektron.Cms.Controls.Menu menuObject, Ektron.Cms.Common.EkEnumeration.CMSMenuItemType targettype, CMSIDTypes.menuitem_id targetid)
            {
                this.menu_id_val = new CMSIDTypes.menu_id(menuObject.DefaultMenuID);
                this.targettype_val = targettype;
                this.targetid_val = targetid;
                MenuObj_val = menuObject;

                // Test for standard menu XML xpaths

                XmlNodeList xnl;

                StringCollection strcolValidationPaths = new StringCollection();
                string[] strarrValidationPaths = new string[] { "/MenuDataResult", "/MenuDataResult/Item", "/MenuDataResult/Item/Item" };
                strcolValidationPaths.AddRange(strarrValidationPaths);

                foreach (string strValidationPath in strcolValidationPaths)
                {
                    xnl = MenuObj_val.XmlDoc.SelectNodes(strValidationPath);
                    if (xnl.Count <= 0)
                    {
                        TargetNotInMenuException ex = new TargetNotInMenuException(this.GetType().ToString() + ": CMS returns invalid menu data.  XPath \"" + strValidationPath + "\" is missing from the XML returned for menu_id " + MenuObj_val.DefaultMenuID.ToString() + ".  This may indicate that no menu with ID " + MenuObj_val.DefaultMenuID.ToString() + " exists.");
                        ex.Source = ExceptionSource;
                        throw (ex);
                    }
                }

                string menuTargetXPath = "/descendant::Item[child::ItemID=\'" + targetid.val.ToString() + "\' and ItemType=\'" + targettype.ToString() + "\']";
                xnl = MenuObj_val.XmlDoc.SelectNodes(menuTargetXPath);
                if (xnl.Count > 0) // Test to ensure that the target item exists in the menu
                {
                    TargetCrumb_val = xnl[0];
                }
                else
                {
                    TargetNotInMenuException ex = new TargetNotInMenuException(this.GetType().ToString() + ": Item ID " + targetid.val.ToString() + ", Type \"" + targettype.ToString() + "\" does not exist in menu_id " + MenuObj_val.DefaultMenuID.ToString());
                    ex.Source = ExceptionSource;
                    throw (ex);
                }

                string menuAncestorsXPath = "(" + menuTargetXPath + "/ancestor::Item[ItemType=\'" + Ektron.Cms.Common.EkEnumeration.CMSMenuItemType.Submenu.ToString() + "\'])|(" + menuTargetXPath + ")";
                TierCrumb_val = MenuObj_val.XmlDoc.SelectNodes(menuAncestorsXPath);
                TierCrumb_idx = new XMLNodeListIndexer(TierCrumb_val);

                XmlNode xn;
                Ektron.Cms.Common.EkEnumeration.CMSMenuItemType xn_ItemType;
                int xn_ItemID;

                string tierXPath;
                int TierListLength;

                if (targettype == Ektron.Cms.Common.EkEnumeration.CMSMenuItemType.Submenu)
                {
                    //If target is a submenu we'll grab the children
                    TierListLength = TierCrumb_val.Count;
                }
                else
                {
                    TierListLength = TierCrumb_val.Count - 1;
                }

                TierList_val = new XmlNodeList[TierListLength + 1];

                for (int I = 0; I <= (TierListLength); I++)
                {
                    if (I == 0)
                    {

                        xn = TierCrumb_val[0];
                        xn_ItemType = (Ektron.Cms.Common.EkEnumeration.CMSMenuItemType)(Enum.Parse(typeof(Ektron.Cms.Common.EkEnumeration.CMSMenuItemType), xn.SelectSingleNode("ItemType").InnerText));
                        xn_ItemID = int.Parse(xn.SelectSingleNode("ItemID").InnerText);
                        tierXPath = "/descendant::Item[child::ItemID=\'" + xn_ItemID.ToString() + "\' and ItemType=\'" + xn_ItemType.ToString() + "\']";
                    }
                    else if (TierCrumb_val.Count > 0)
                    {
                        xn = TierCrumb_val[I - 1];
                        xn_ItemType = (Ektron.Cms.Common.EkEnumeration.CMSMenuItemType)(Enum.Parse(typeof(Ektron.Cms.Common.EkEnumeration.CMSMenuItemType), xn.SelectSingleNode("ItemType").InnerText));
                        xn_ItemID = int.Parse((string)(xn.SelectSingleNode("ItemID").InnerText));
                        tierXPath = "/descendant::Item[child::ItemID=\'" + xn_ItemID.ToString() + "\' and ItemType=\'" + xn_ItemType.ToString() + "\']/child::Menu/child::Item";
                        break;
                    }
                    else
                    {
                        xn = TierCrumb_val[I];
                        xn_ItemType = (Ektron.Cms.Common.EkEnumeration.CMSMenuItemType)(Enum.Parse(typeof(Ektron.Cms.Common.EkEnumeration.CMSMenuItemType), xn.SelectSingleNode("ItemType").InnerText));
                        xn_ItemID = int.Parse(xn.SelectSingleNode("ItemID").InnerText);
                        tierXPath = "/descendant::Item[child::ItemID=\'" + xn_ItemID.ToString() + "\' and ItemType=\'" + xn_ItemType.ToString() + "\']/parent::Menu/child::Item";
                    }

                    xnl = MenuObj_val.XmlDoc.SelectNodes(tierXPath);
                    TierList_val.SetValue(xnl, I);
                }

                IsInitialized = true;
            }
示例#3
0
            public NStateMenu(CMSIDTypes.menu_id menu_id, ref EkEnumeration.CMSMenuItemType targettype, ref CMSIDTypes.menuitem_id targetid)
            {
                ExceptionSource = this.GetType().ToString();

                Ektron.Cms.Controls.Menu motemp = new Ektron.Cms.Controls.Menu();
                motemp.CacheInterval = 60;
                motemp.DefaultMenuID = menu_id.val;
                motemp.Fill();
                CommonConstructor(motemp, targettype, targetid);
            }