Ejemplo n.º 1
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;
            }
Ejemplo n.º 2
0
            public NStateMenu(ref Ektron.Cms.Controls.Menu menuObject, ref EkEnumeration.CMSMenuItemType targettype, ref CMSIDTypes.menuitem_id targetid)
            {
                ExceptionSource = this.GetType().ToString();

                CommonConstructor(menuObject, targettype, targetid);
            }
Ejemplo n.º 3
0
            //If no parameters are passed, try to get them from URL vars
            public NStateMenu(CMSIDTypes.menu_id menu_id)
            {
                ExceptionSource = this.GetType().ToString();

                menu_id_val = menu_id;
                this.AcquireVars();

                //if (!((this.menu_id_val == null) || (this.targetid_val == null) || (this.targettype_val == null)))
                //{
                try
                {
                    Fill();
                }
                catch (NStateMenu.TargetNotInMenuException)
                {
                    //Eat the exception and remain uninitialized if
                    // target doesn't exist.
                }
                //}
            }
Ejemplo n.º 4
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);
            }