/// <summary>Runs the custom item saving rules.</summary>
        private void RunItemSavingRules(Item item)
        {
            // Reflect and call the Static RunRules method with our custom Item Saving rules folder
            var refelectedMethod = typeof(Sitecore.Rules.ItemEventHandler)
                                   .GetMethod("RunRules", BindingFlags.Static | BindingFlags.NonPublic);

            refelectedMethod.Invoke(null, new object[] { item, MainUtil.GetID(ItemSavingRules) });
        }
        protected virtual ID ParseRenderingId(XmlNode configNode)
        {
            if (configNode == null)
            {
                return(ID.Null);
            }

            return(MainUtil.GetID(XmlUtil.GetAttribute("id", configNode), ID.Null));
        }
        public static Item GetStateItem(string stateId, Database database)
        {
            var iD = MainUtil.GetID(stateId, null);

            if (iD.IsNull)
            {
                return(null);
            }
            return(GetItem(iD, database));
        }
Ejemplo n.º 4
0
        public static string GetBackgroundClass([NotNull] this Rendering rendering)
        {
            var id = MainUtil.GetID(rendering.Parameters[Constants.BackgroundLayoutParameters.Background] ?? "", null);

            if (ID.IsNullOrEmpty(id))
            {
                return("");
            }
            var item = rendering.RenderingItem.Database.GetItem(id);

            return(item?[Templates.Style.Fields.Class] ?? "");
        }
Ejemplo n.º 5
0
        private static string GetStyle(Rendering rendering, string paramName)
        {
            var id = MainUtil.GetID(rendering.Parameters[paramName] ?? "", null);

            if (ID.IsNullOrEmpty(id))
            {
                return("");
            }
            var item = rendering.RenderingItem.Database.GetItem(id);

            return(item?[Templates.Style.Fields.Class] ?? "");
        }
Ejemplo n.º 6
0
        public void Process(WorkflowPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            ProcessorItem processorItem = args.ProcessorItem;

            if (processorItem == null || args.DataItem == null)
            {
                return;
            }

            Item innerItem = processorItem.InnerItem;

            MultilistField langs = innerItem.Fields[FieldnameWorkflowLanguages];
            Database       db    = Factory.GetDatabase("master");

            if (langs == null || langs.TargetIDs == null || !langs.TargetIDs.Any() || db == null)
            {
                return;
            }

            ID iD = ID.Null;

            foreach (var lang in langs.TargetIDs)
            {
                Item item = db.GetItem(lang);

                if (item == null)
                {
                    continue;
                }

                if (item.Name.Equals(args.DataItem.Language.Name, StringComparison.CurrentCultureIgnoreCase))
                {
                    iD = MainUtil.GetID(innerItem[FieldnameWorkflowNextState], null);
                    break;
                }
            }

            if (iD.IsNull)
            {
                return;
            }

            args.NextStateId = iD;
        }
        //Load numbered versions in the dropdown for master and web items


        //private void PopuplateItemVersionsDropdowns()
        //{
        //    PopuplateItemVersionsDropdown(MasterVersionDropdown, GetMasterItem());
        //    PopuplateItemVersionsDropdown(WebVersionDropdown, GetWebItem());
        //}

        //private static void PopuplateItemVersionsDropdown(Combobox itemVersionsDropdown, Item itemVersions)
        //{
        //    foreach (var version in itemVersions.Versions.GetVersions())
        //    {
        //        itemVersionsDropdown.Controls.Add(
        //            new ListItem {
        //                ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem"),
        //                Header = version.Version.Number.ToString(),
        //                Value = version.Version.Number.ToString(),
        //                Selected = string.Equals(version.Name, itemVersions.Name)
        //            }
        //            );
        //    }
        //}
        #endregion

        private static void PopuplateLanguageDropdown(Combobox languageDropdown)
        {
            LanguageCollection languageVersions = ItemManager.GetContentLanguages(GetDatabase("master").GetItem(MainUtil.GetID(GetGetQueryStringProperty(IDKey, IDKey), ID.Null)));

            foreach (var language in languageVersions)
            {
                var itm = GetDatabase("master").GetItem(MainUtil.GetID(GetGetQueryStringProperty(IDKey, IDKey), ID.Null), language);
                if (itm.Versions.Count > 0)
                {
                    languageDropdown.Controls.Add
                    (
                        new Sitecore.Web.UI.HtmlControls.ListItem
                    {
                        ID       = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem"),
                        Header   = language.Title + " - " + language.Name, //To-do - remove obsolete reference
                        Value    = language.Name,
                        Selected = string.Equals(language.Name, Context.Language)
                    }
                    );
                }
            }
        }
 private ID GetID()
 {
     return(MainUtil.GetID(GetGetQueryStringProperty(IDKey, IDKey), ID.Null));
 }
Ejemplo n.º 9
0
        private Item GetStateItem(string stateId)
        {
            ID id = MainUtil.GetID(stateId, null);

            return(id == (ID)null ? null : this.GetStateItem(id));
        }