Exemple #1
0
        // on ok
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull((object)args, "args");
            ListString listString = new ListString(WebUtil.GetFormValue("sortorder"));

            if (listString.Count == 0) // no changes made
            {
                base.OnOK(sender, args);
            }
            else
            {
                if (IsDBsort(listString.ToString()))
                {
                    SortContentOptions sortContentOptions = SortContentOptions.Parse();
                    ProcessDbOrder(sortContentOptions.Item.Children[0], listString); // save sort order of db view data
                }
                else // sort input view items
                {
                    ListString source = listString;
                    this.Sort(source.Select <string, ID>(x => ShortID.DecodeID(x)));
                    SheerResponse.SetDialogValue("1");
                }
                base.OnOK(sender, args);
            }
        }
Exemple #2
0
        // on load
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull((object)e, "e");
            base.OnLoad(e);
            if (Context.ClientPage.IsEvent)
            {
                return;
            }
            SortContentOptions sortContentOptions = SortContentOptions.Parse();
            string             contentToSortQuery = sortContentOptions.ContentToSortQuery;

            Assert.IsNotNullOrEmpty(contentToSortQuery, "query");
            Item[] itemsToSort = this.GetItemsToSort(sortContentOptions.Item, contentToSortQuery);
            Array.Sort <Item>(itemsToSort, (IComparer <Item>) new DefaultComparer());
            if (itemsToSort.Length < 1) // no items to sort
            {
                this.OK.Disabled = true;
            }
            else if (itemsToSort.Length == 1 && sortContentOptions.Item.TemplateName.Equals("Faculty Directory DB Section") && // item to sort = one db view item
                     IsEditable(sortContentOptions.Item) && sortContentOptions.Item.Children.Count == 1)
            {
                Item DBViewItem = sortContentOptions.Item.Children[0];
                itemIconURL = Images.GetThemedImageSource(DBViewItem.Appearance.Icon, ImageDimension.id16x16);
                string contentToSort = string.Empty;
                if (DBViewItem.TemplateName.Equals("Faculty Directory DB View"))
                {
                    contentToSort = DBViewItem.Fields["Faculty List"].Value;
                }
                string[] dataToSort = this.GetDataToSort(contentToSort);
                if (dataToSort.Length > 1) // at least two db entries to sort
                {
                    this.MainContainer.Controls.Clear();
                    this.MainContainer.InnerHtml = this.RenderData((IEnumerable <string>)dataToSort);
                }
            }
            else // at least two input view items to sort
            {
                this.MainContainer.Controls.Clear();
                this.MainContainer.InnerHtml = this.RenderItems((IEnumerable <Item>)itemsToSort);
            }
        }
Exemple #3
0
        // sorts the specified order of input view items
        private void Sort(IEnumerable <ID> orderList)
        {
            Assert.ArgumentNotNull((object)orderList, "orderList");
            SortContentOptions sortContentOptions = SortContentOptions.Parse();
            int defaultSortOrder = Settings.DefaultSortOrder;

            Item[] itemsToSort = this.GetItemsToSort(sortContentOptions.Item, sortContentOptions.ContentToSortQuery);
            foreach (ID order in orderList)
            {
                Item obj = Array.Find <Item>(itemsToSort, x => x.ID == order);
                if (obj != null)
                {
                    using (new SecurityDisabler())
                    {
                        using (new EditContext(obj, false, false))
                            obj.Appearance.Sortorder = defaultSortOrder;
                    }
                    defaultSortOrder += 100;
                }
            }
        }
 protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         SortContentOptions options = SortContentOptions.Parse();
         this.sortBy = options.SortBy;
         this.expandStandardValuesTokens = options.ExpandStandardValuesTokens;
         string contentToSortQuery = options.ContentToSortQuery;
         Assert.IsNotNullOrEmpty(contentToSortQuery, "query");
         Item[] itemsToSort = this.GetItemsToSort(options.Item, contentToSortQuery);
         Array.Sort <Item>(itemsToSort, new DefaultComparer());
         if (itemsToSort.Length < 2)
         {
             base.OK.Disabled = true;
         }
         else
         {
             this.MainContainer.Controls.Clear();
             this.MainContainer.InnerHtml = this.Render(itemsToSort);
         }
     }
 }
        private void Sort(IEnumerable <ID> orderList)
        {
            Assert.ArgumentNotNull(orderList, "orderList");
            SortContentOptions options = SortContentOptions.Parse();
            int defaultSortOrder       = Settings.DefaultSortOrder;

            Item[] itemsToSort = this.GetItemsToSort(options.Item, options.ContentToSortQuery);
            foreach (ID id in orderList)
            {
                ID   idToFind = id;
                Item item     = Array.Find <Item>(itemsToSort, i => i.ID == idToFind);
                if (item != null)
                {
                    using (new SecurityDisabler())
                    {
                        using (new EditContext(item, false, false))
                        {
                            item.Appearance.Sortorder = defaultSortOrder;
                        }
                    }
                    defaultSortOrder += 100;
                }
            }
        }
Exemple #6
0
        /// <inheritdoc/>
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull((object)e, "e");
            base.OnLoad(e);
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var sortContentOptions = SortContentOptions.Parse();
            var contentToSortQuery = sortContentOptions.ContentToSortQuery;

            Assert.IsNotNullOrEmpty(contentToSortQuery, "query");

            // use reflection to call private method, we don't want to copy&paste it from Sitecore with bunch of other needed private methods
            var getItemsMethod = typeof(SortForm).GetMethod("GetItemsToSort", BindingFlags.NonPublic | BindingFlags.Instance);

            Item[] itemsToSort = (Item[])getItemsMethod.Invoke(this, new object[] { sortContentOptions.Item, contentToSortQuery });

            Array.Sort(itemsToSort, new DefaultComparer());

            // we need to change behaviour to check if there's at least 1 child item, istead of 2
            if (itemsToSort.Length < 1)
            {
                this.OK.Disabled = true;
            }
            else
            {
                this.OK.Disabled = false;
                this.MainContainer.Controls.Clear();

                // use reflection to call private method, we don't want to copy&paste it from Sitecore  with bunch of other needed private methods
                var renderMethod = typeof(SortForm).GetMethod("Render", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(IEnumerable <Item>) }, null);
                this.MainContainer.InnerHtml = (string)renderMethod.Invoke(this, new object[] { itemsToSort });
            }
        }