コード例 #1
0
    protected void tab_DataBinding(object sender, EventArgs e)
    {
        this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "gridID", "var gridID=\"" + this.gridSub.ClientID + "\";", true);
        WikiPage curr = (WikiPage)ds.DataGraph.Caches[typeof(WikiPage)].Current;

        if (curr != null)
        {
            /*PXRichTextEdit edHtmlText = (PXRichTextEdit)this.tab.DataControls["edHtmlText"];
             *
             * edHtmlText.WikiArticleId = curr.PageID;
             * if (curr.IsHtml == true)
             * {
             *      PXUIFieldAttribute.SetVisible<WikiPage.content>(ds.DataGraph.Caches[typeof(WikiPage)], curr, false);
             *      PXUIFieldAttribute.SetVisible<WikiPage.contentHtml>(ds.DataGraph.Caches[typeof(WikiPage)], curr, true);
             * }
             * else
             * {
             *      PXUIFieldAttribute.SetVisible<WikiPage.content>(ds.DataGraph.Caches[typeof(WikiPage)], curr, true);
             *      PXUIFieldAttribute.SetVisible<WikiPage.contentHtml>(ds.DataGraph.Caches[typeof(WikiPage)], curr, false);
             * }*/
            ((PXDBContext)this.edtWikiText.PreviewSettings).WikiID = curr.WikiID;
            this.Page.Header.Controls.Add(new LiteralControl(PXHtmlFormatter.GetPageStyle(this.edtWikiText.PreviewSettings)));
            this.ScreenTitle = string.IsNullOrEmpty(curr.Title) ? (string.IsNullOrEmpty(curr.Name) ? this.ScreenTitle : curr.Name) : curr.Title;
            if (curr.Folder != true)
            {
                tab.Items["Subarticles"].Visible = false;
            }
            if (!Page.IsPostBack)
            {
                WikiDescriptor wiki = PXSelect <WikiDescriptor,
                                                Where <WikiDescriptor.pageID,
                                                       Equal <Required <WikiDescriptor.pageID> > > > .SelectWindowed(new PXGraph(), 0, 1, curr.WikiID);

                PXAuditJournal.Register("WE000000", "Edit: " +
                                        Wiki.Link((wiki != null ? wiki.Name : curr.WikiID.ToString()), curr.Name));
            }

            PXWikiMapNode node = PXSiteMap.WikiProvider.FindSiteMapNodeFromKey(curr.PageID.GetValueOrDefault()) as PXWikiMapNode;
            if (node != null)
            {
                this.CurrentNode = node;
            }

            if (!this.Page.IsCallback && !this.Page.IsPostBack && !string.IsNullOrEmpty(Request.QueryString["wiki"]))
            {
                T graph = (T)ds.DataGraph;
                graph.Caches[typeof(PX.SM.WikiArticle)].IsDirty = false;
            }
        }
    }
コード例 #2
0
ファイル: ShowPage.cs プロジェクト: blanks88/AcumaticaT100
    protected void form_DataBinding(object sender, EventArgs e)
    {
        WikiReader graph   = (WikiReader)this.DS.DataGraph;
        PXCache    cache   = graph.Views[this.DS.PrimaryView].Cache;
        WikiPage   current = cache.Current as WikiPage;

        if (current != null)
        {
            string language = Request.Params["Language"];
            if (string.IsNullOrEmpty(language))
            {
                language = LocaleInfo.GetCulture().Name;
            }

            WikiRevision currentrevision =
                PXSelect <WikiRevision,
                          Where <WikiRevision.pageID,
                                 Equal <Required <WikiRevision.pageID> >,
                                 And <WikiRevision.language, Equal <Required <WikiRevision.language> > > >, OrderBy <Desc <WikiRevision.pageRevisionID> > > .SelectWindowed(new PXGraph(), 0, 1, current.PageID, language);

            if (this.PublicUrlEditor != null)
            {
                this.PublicUrlEditor.Text = string.Empty;
            }

            if (current.WikiID != null)
            {
                if (Master is IPXMasterPage)
                {
                    (Master as IPXMasterPage).ScreenTitle = current.Title;
                }
                if (Master is IPXMasterPage)
                {
                    (Master as IPXMasterPage).BranchAvailable = false;
                }
                graph.Filter.Current.WikiID = current.WikiID;
                WikiDescriptor wiki    = graph.wikis.SelectWindowed(0, 1, current.WikiID);
                PXWikiShow     content = MainForm.FindControl("edContent") as PXWikiShow;
                if (wiki != null)
                {
                    if (!string.IsNullOrEmpty(wiki.PubVirtualPath))
                    {
                        if (PublicUrlEditor != null)
                        {
                            PublicUrlEditor.Text = Request.GetExternalUrl().ToString();
                            int index = PublicUrlEditor.Text.IndexOf("Wiki");
                            if (index > -1)
                            {
                                PublicUrlEditor.Text = PublicUrlEditor.Text.Remove(0, index);
                                PublicUrlEditor.Text = wiki.PubVirtualPath + "/" + PublicUrlEditor.Text;
                            }
                        }
                    }
                    if (!Page.IsPostBack)
                    {
                        PXAuditJournal.Register("WI000000", Wiki.Link(wiki.Name, current.Name));
                    }
                }

                if (content != null)
                {
                    PXDBContext wikiContext = (PXDBContext)content.WikiContext;

                    if (currentrevision != null)
                    {
                        wikiContext.Text = currentrevision.Content;
                    }
                    if (_pageDBContextType == null)
                    {
                        wikiContext.ContentWidth  = current.Width.GetValueOrDefault(0);
                        wikiContext.ContentHeight = current.Height.GetValueOrDefault(0);
                        wikiContext.PageTitle     = current.Title;
                    }

                    wikiContext.WikiID = current.WikiID.Value != Guid.Empty ? current.WikiID.Value : current.PageID.Value;

                    if (current.PageID != null && (_pageDBContextType == null &&
                                                   (PXSiteMap.WikiProvider.GetAccessRights(current.PageID.Value) >= PXWikiRights.Update &&
                                                    current.PageRevisionID > 0)))
                    {
                        wikiContext.LastModified        = current.PageRevisionDateTime;
                        wikiContext.LastModifiedByLogin = cache.GetStateExt(current, "PageRevisionCreatedByID").ToString();
                    }
                    if (current.PageID != null && PXSiteMap.WikiProvider.GetAccessRights(current.PageID.Value) >= PXWikiRights.Update)
                    {
                        wikiContext.RenderSectionLink = true;
                    }
                    else
                    {
                        wikiContext.HideBrokenLink    = true;
                        wikiContext.RedirectAvailable = true;
                    }

                    if (this.WikiTextPanel != null)
                    {
                        this.WikiTextPanel.Caption = current.Title;
                    }
                    if (this.WikiTextEditor != null)
                    {
                        this.WikiTextEditor.Text = graph.ConvertGuidToLink(current.Content);
                    }
                }
                if (this.LinkEditor != null)
                {
                    this.LinkEditor.Text = "[" + (wiki != null && wiki.Name != null ? wiki.Name + "\\" : string.Empty) + current.Name + "]";
                }
            }
        }
        this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "varreg", "var printLink=\"" + ResolveUrl("~/Wiki/Print.aspx") + "?" + ControlHelper.SanitizeUrl(Request.QueryString.ToString()) + "\";", true);

        if (this.LinkEditor != null)
        {
            LinkEditor.ReadOnly = true;
        }
        if (this.UrlEditor != null)
        {
            UrlEditor.Text     = Request.GetExternalUrl().ToString();
            UrlEditor.ReadOnly = true;
        }
        if (this.PublicUrlEditor != null)
        {
            PublicUrlEditor.Enabled  = !string.IsNullOrEmpty(PublicUrlEditor.Text);
            PublicUrlEditor.ReadOnly = true;
        }
    }