コード例 #1
0
ファイル: editMedia.aspx.cs プロジェクト: SKDon/Triphulcas
        protected void Save(object sender, System.EventArgs e)
        {
            // error handling test
            if (!Page.IsValid)
            {
                foreach (uicontrols.TabPage tp in tmp.GetPanels())
                {
                    tp.ErrorControl.Visible = true;
                    tp.ErrorHeader          = ui.Text("errorHandling", "errorHeader");
                    tp.CloseCaption         = ui.Text("close");
                }
            }
            else if (Page.IsPostBack)
            {
                // hide validation summaries
                foreach (uicontrols.TabPage tp in tmp.GetPanels())
                {
                    tp.ErrorControl.Visible = false;
                }
            }
            _media.Save();

            this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString();
            this.UpdateMediaFileLinksLiteral();

            _media.XmlGenerate(new XmlDocument());
            ClientTools.SyncTree(_media.Path, true);
        }
コード例 #2
0
ファイル: nodeSorter.asmx.cs プロジェクト: Jeavon/Umbraco-CMS
        public void UpdateSortOrder(int ParentId, string SortOrder)
        {
            //TODO: The amount of processing this method takes is HUGE. We should look at 
            // refactoring this to use purely the new APIs and see how much faster we can make it!

            try
            {
                if (AuthorizeRequest() == false) return;
                if (SortOrder.Trim().Length <= 0) return;
                var ids = SortOrder.Split(',');

                var isContent = helper.Request("app") == "content" | helper.Request("app") == "";
                var isMedia = helper.Request("app") == "media";
                //ensure user is authorized for the app requested
                if (isContent && AuthorizeRequest(DefaultApps.content.ToString()) == false) return;
                if (isMedia && AuthorizeRequest(DefaultApps.media.ToString()) == false) return;

                for (var i = 0; i < ids.Length; i++)
                {
                    if (ids[i] == "" || ids[i].Trim() == "") continue;

                    if (isContent)
                    {
                        var document = new Document(int.Parse(ids[i]))
                            {
                                sortOrder = i
                            };

                        if (document.Published)
                        {
                            document.Publish(BusinessLogic.User.GetCurrent());

                            //TODO: WE don't want to have to republish the entire document !!!!
                            library.UpdateDocumentCache(document);
                        }
                        else
                        {
                            //we need to save it if it is not published to persist the sort order value
                            document.Save();
                        }
                    }
                        // to update the sortorder of the media node in the XML, re-save the node....
                    else if (isMedia)
                    {
                        var media = new cms.businesslogic.media.Media(int.Parse(ids[i]))
                            {
                                sortOrder = i
                            };
                        media.Save();                        
                    }

                    // Refresh sort order on cached xml
                    if (isContent)
                    {
                        XmlNode parentNode = ParentId == -1
                                                 ? content.Instance.XmlContent.DocumentElement
                                                 : content.Instance.XmlContent.GetElementById(ParentId.ToString());

                        //only try to do the content sort if the the parent node is available... 
                        if (parentNode != null)
                            content.SortNodes(ref parentNode);

                        // Load balancing - then refresh entire cache
                        if (UmbracoSettings.UseDistributedCalls)
                            library.RefreshContent();

                        // fire actionhandler, check for content
                        BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance);
                    }
                }                
            }
            catch (Exception ex)
            {
                LogHelper.Error<nodeSorter>("Could not update sort order", ex);
            }
        }
コード例 #3
0
        public void UpdateSortOrder(int ParentId, string SortOrder)
        {
            //TODO: The amount of processing this method takes is HUGE. We should look at
            // refactoring this to use purely the new APIs and see how much faster we can make it!

            try
            {
                if (AuthorizeRequest() == false)
                {
                    return;
                }
                if (SortOrder.Trim().Length <= 0)
                {
                    return;
                }
                var ids = SortOrder.Split(',');

                var isContent = helper.Request("app") == "content" | helper.Request("app") == "";
                var isMedia   = helper.Request("app") == "media";
                //ensure user is authorized for the app requested
                if (isContent && AuthorizeRequest(DefaultApps.content.ToString()) == false)
                {
                    return;
                }
                if (isMedia && AuthorizeRequest(DefaultApps.media.ToString()) == false)
                {
                    return;
                }

                for (var i = 0; i < ids.Length; i++)
                {
                    if (ids[i] == "" || ids[i].Trim() == "")
                    {
                        continue;
                    }

                    if (isContent)
                    {
                        var document = new Document(int.Parse(ids[i]))
                        {
                            sortOrder = i
                        };

                        if (document.Published)
                        {
                            document.Publish(BusinessLogic.User.GetCurrent());

                            //TODO: WE don't want to have to republish the entire document !!!!
                            library.UpdateDocumentCache(document);
                        }
                        else
                        {
                            //we need to save it if it is not published to persist the sort order value
                            document.Save();
                        }
                    }
                    // to update the sortorder of the media node in the XML, re-save the node....
                    else if (isMedia)
                    {
                        var media = new cms.businesslogic.media.Media(int.Parse(ids[i]))
                        {
                            sortOrder = i
                        };
                        media.Save();
                    }

                    // Refresh sort order on cached xml
                    if (isContent)
                    {
                        XmlNode parentNode = ParentId == -1
                                                 ? content.Instance.XmlContent.DocumentElement
                                                 : content.Instance.XmlContent.GetElementById(ParentId.ToString());

                        //only try to do the content sort if the the parent node is available...
                        if (parentNode != null)
                        {
                            content.SortNodes(ref parentNode);
                        }

                        // Load balancing - then refresh entire cache
                        if (UmbracoSettings.UseDistributedCalls)
                        {
                            library.RefreshContent();
                        }

                        // fire actionhandler, check for content
                        BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <nodeSorter>("Could not update sort order", ex);
            }
        }