Example #1
0
    protected void show_EditorCreated(object sender, EventArgs e)
    {
        PXWikiShow show  = sender as PXWikiShow;
        WikiReader graph = (WikiReader)this.DS.DataGraph;

        if (show != null)
        {
            if (graph.Pages.Current != null)
            {
                ((PXDBContext)show.Editor.PreviewSettings).WikiID = graph.Pages.Current.WikiID;
                if (graph.Pages.Current.ArticleType == WikiArticleType.Notification)
                {
                    WikiNotificationTemplateMaintenance g = TreeDS.DataGraph as WikiNotificationTemplateMaintenance;
                    if (g != null)
                    {
                        g.Filter.Current.PageID = graph.Pages.Current.PageID;
                        g.Pages.Current         = g.Pages.SelectWindowed(0, 1);
                    }

                    show.Editor.TemplateDataSourceID = TreeDS.ID;
                    PXTreeItemBinding binding = new PXTreeItemBinding();
                    binding.DataMember    = "EntityItems";
                    binding.TextField     = "Name";
                    binding.ValueField    = "Path";
                    binding.ImageUrlField = "Icon";
                    show.Editor.TemplateDataBindings.Add(binding);
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        WikiReader     reader   = PXGraph.CreateInstance <WikiReader>();
        PXWikiSettings settings = new PXWikiSettings(this, reader);

        reader.Filter.Current.PageID = PX.Common.GUID.CreateGuid(this.Request["PageID"]);
        WikiPage article = reader.Pages.SelectWindowed(0, 1);

        reader.Pages.Current = article;
        if (article != null && !string.IsNullOrEmpty(article.Content))
        {
            MemoryStream  stream   = new MemoryStream();
            PXPdfRenderer renderer = new PXPdfRenderer(stream, settings.Relative);
            settings.Relative.Renderer = renderer;
            PXWikiParser.Parse(article.Content, settings.Relative);
            string mime  = MimeTypes.GetMimeType(".pdf");
            byte[] bytes = new byte[renderer.ResultPDFStream.Length];

            renderer.ResultPDFStream.Position = 0;
            renderer.ResultPDFStream.Read(bytes, 0, bytes.Length);
            Response.AddHeader("cache-control", "no-store, private");
            Response.Clear();
            Response.Cache.SetCacheability(HttpCacheability.Private);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(2));
            Response.Cache.SetValidUntilExpires(true);
            Response.AddHeader("Content-Type", mime);
            Response.AddHeader("Content-Length", renderer.ResultPDFStream.Length.ToString());
            Response.BinaryWrite(bytes);
        }
    }
Example #3
0
 protected override void Initialize()
 {
     if (_templateWikiArticleType != null && _rootTemplate != null)
     {
         string language = Request.Params["Language"];
         if (string.IsNullOrEmpty(language))
         {
             language = LocaleInfo.GetCulture().Name;
         }
         int        revision;
         Guid       pageID          = WikiPageId;
         int?       correctRevision = int.TryParse(Request.Params["PageRevisionID"], out revision) ? (int?)revision : null;
         WikiReader graph           = PXGraph.CreateInstance <WikiReader>();
         try
         {
             object article = pageID == Guid.Empty
                                     ? Activator.CreateInstance(_templateWikiArticleType, graph, Request.Params["wiki"], Request.Params["art"], language, correctRevision)
                                     : Activator.CreateInstance(_templateWikiArticleType, graph, pageID, language, correctRevision);
             _wikiShow = new TemplateWikiShow((IWikiArticle)article, (IRootTemplateInfo)_rootTemplate.GetValue(article, null));
         }
         catch (StackOverflowException) { throw; }
         catch (OutOfMemoryException) { throw; }
         catch
         {
             _wikiShow = new PXWikiShow();
         }
     }
     else
     {
         _wikiShow = new PXWikiShow();
     }
     _wikiShow.NotFoundMessage = PXMessages.LocalizeNoPrefix(Msg.WkNotFound);
     base.Initialize();
 }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        T graph = (T)ds.DataGraph;

        this.gridSub         = this.tab.FindControl("gridSub") as PXGrid;
        this.gridAttachments = this.tab.FindControl("gridAttachments") as PXGrid;

        WikiPage curr = (WikiPage)graph.Caches[typeof(WikiPage)].Current;

        if (!this.hasQueryParams && curr != null && !this.Page.IsPostBack && !this.Page.IsCallback)
        {
            this.ds.DataGraph.Clear();
            this.Response.Redirect(this.Request.RawUrl + "?wiki=" + curr.WikiID.GetValueOrDefault().ToString() + "&parent=" + curr.ParentUID.GetValueOrDefault().ToString() + "&name=" + curr.Name);
            return;
        }

        WikiReader reader = PXGraph.CreateInstance <WikiReader>();

        this.edtWikiText = (PXWikiEdit)this.tab.DataControls["edtWikiText"];
        this.edtWikiText.PreviewSettings = new PXWikiSettings(this.Page, reader).Relative;
        this.edtWikiText.FileNamePrefix  = curr == null ? null : curr.Name;
        this.edtWikiText.FileUploaded   += new PXFileUploadEventHandler(editor_FileUploaded);

        graph.GetFileUrl            = Request.GetWebsiteAuthority().GetLeftPart(UriPartial.Authority) + ResolveUrl("~/Frames/GetFile.ashx");
        graph.CurrentAttachmentGuid = PX.Common.GUID.CreateGuid((string)gridAttachments.DataValues["FileID"]).GetValueOrDefault();

        PXEntryStatus recStatus = ds.DataGraph.Caches[typeof(WikiPage)].GetStatus(curr);

        if (recStatus == PXEntryStatus.Deleted || recStatus == PXEntryStatus.Inserted || recStatus == PXEntryStatus.InsertedDeleted)
        {
            edtWikiText.AttachFileEnabled = false;
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string         exportType = Request["type"];
        WikiReader     reader     = PXGraph.CreateInstance <WikiReader>();
        PXWikiSettings settings   = new PXWikiSettings(this, reader);

        this.SetReaderFilter(reader);
        WikiPage article = reader.Pages.SelectWindowed(0, 1);

        reader.Pages.Current = article;
        PXRenderer renderer = this.CreateRenderer(exportType, settings.Absolute);

        if (article != null && !string.IsNullOrEmpty(article.Content) && renderer != null)
        {
            var ctx = new PXDBContext(settings.Absolute);

            ctx.Renderer = renderer;
            ctx.WikiID   = article.WikiID;
            string result = PXWikiParser.Parse(article.Content, ctx);
            string mime   = MimeTypes.GetMimeType("." + exportType);
            Response.AddHeader("cache-control", "no-store, private");
            Response.Clear();
            Response.Cache.SetCacheability(HttpCacheability.Private);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(2));
            Response.Cache.SetValidUntilExpires(true);
            Response.AddHeader("Content-Type", mime);
            Response.AddHeader("Content-Encoding", "ansi");
            this.AdditionalResponseParams(renderer, article);
            Response.Write(result);
        }
    }
Example #6
0
    protected override void Initialize()
    {
        if (_templateWikiArticleType != null && _rootTemplate != null)
        {
            string language = Request.Params["Language"];
            if (string.IsNullOrEmpty(language))
            {
                language = LocaleInfo.GetCulture().Name;
            }
            int        revision;
            Guid       pageID          = WikiPageId;
            int?       correctRevision = int.TryParse(Request.Params["PageRevisionID"], out revision) ? (int?)revision : null;
            WikiReader graph           = PXGraph.CreateInstance <WikiReader>();
            object     article         = pageID == Guid.Empty
                                ? Activator.CreateInstance(_templateWikiArticleType, graph, Request.Params["wiki"], Request.Params["art"], language, correctRevision)
                                : Activator.CreateInstance(_templateWikiArticleType, graph, pageID, language, correctRevision);
            _wikiShow = new TemplateWikiShow((IWikiArticle)article, (IRootTemplateInfo)_rootTemplate.GetValue(article, null));
        }
        else
        {
            _wikiShow = new PXWikiShow();
        }

        base.Initialize();
        this.MainForm.DataBinding += new EventHandler(MainForm_DataBinding);
    }
Example #7
0
        public virtual IEnumerable IndexCustomArticles(PXAdapter adapter)
        {
            PXLongOperation.StartOperation(this, delegate()
            {
                foreach (var result in WikiArticles.Select())
                {
                    string plaintext = null;

                    var _wp = (WikiPage)result[typeof(WikiPage)];
                    var _wr = (WikiRevision)result[typeof(WikiRevision)];
                    var _wl = (WikiPageLanguage)result[typeof(WikiPageLanguage)];

                    if (_wp.IsHtml != true)
                    {
                        WikiReader reader       = PXGraph.CreateInstance <WikiReader>();
                        PXWikiSettings settings = new PXWikiSettings(new PXPage(), reader);
                        PXTxtRenderer renderer  = new PXTxtRenderer(settings.Absolute);
                        var ctx      = new PXDBContext(settings.Absolute);
                        ctx.Renderer = renderer;
                        plaintext    = (_wl.Title ?? "") + Environment.NewLine + PXWikiParser.Parse(_wr.Content, ctx);
                    }
                    else
                    {
                        plaintext = (_wl.Title ?? "") + Environment.NewLine + SearchService.Html2PlainText(_wr.Content);
                    }


                    //Try updating the article in current Company
                    if (!PXDatabase.Update <WikiRevision>(
                            new PXDataFieldAssign("PlainText", PXDbType.NVarChar, plaintext),
                            new PXDataFieldRestrict("PageID", PXDbType.UniqueIdentifier, _wr.PageID),
                            new PXDataFieldRestrict("PageRevisionID", PXDbType.Int, _wr.PageRevisionID),
                            new PXDataFieldRestrict("Language", PXDbType.VarChar, _wr.Language)
                            ))
                    {
                        //Article may be shared. Try updating the article through graph (thus handling the shared record update stratagy)
                        //if article is not updatable an exception may be thrown - ignore.
                        try
                        {
                            ArticleUpdater updater = PXGraph.CreateInstance <ArticleUpdater>();
                            WikiRevision rev       = updater.Revision.Select(_wr.PageID, _wr.PageRevisionID, _wr.Language);
                            rev.PlainText          = plaintext;
                            updater.Revision.Update(rev);
                            updater.Persist();
                        }
                        catch (Exception ex)
                        {
                            PXTrace.WriteInformation("Plain text field could not be updated for article = {0}. Error Message: {1}", _wr.PageID, ex.Message);
                        }
                    }
                }
            });



            return(adapter.Get());
        }
Example #8
0
    private WikiPage GetArticle()
    {
        WikiReader reader = PXGraph.CreateInstance <WikiReader>();

        SetReaderFilter(reader);
        WikiPage article = reader.Pages.SelectWindowed(0, 1);

        reader.Pages.Current = article;
        return(article);
    }
	private void SetReaderFilter(WikiReader reader)
	{
		if (!string.IsNullOrEmpty(this.Request["PageID"]))
			reader.Filter.Current.PageID = PX.Common.GUID.CreateGuid(this.Request["PageID"]);
		else if (!string.IsNullOrEmpty(this.Request["wiki"]) && !string.IsNullOrEmpty(this.Request["art"]))
		{
			reader.Filter.Current.Wiki = this.Request["wiki"];
			reader.Filter.Current.Art = this.Request["art"];
		}
	}
Example #10
0
 private void SetReaderFilter(WikiReader reader)
 {
     if (!string.IsNullOrEmpty(this.Request["PageID"]))
     {
         reader.Filter.Current.PageID = PX.Common.GUID.CreateGuid(this.Request["PageID"]);
     }
     else if (!string.IsNullOrEmpty(this.Request["wiki"]) && !string.IsNullOrEmpty(this.Request["art"]))
     {
         reader.Filter.Current.Wiki = this.Request["wiki"];
         reader.Filter.Current.Art  = this.Request["art"];
     }
 }
Example #11
0
    protected virtual void Initialize()
    {
        Guid pageId = WikiPageId;

        article = new WikiPage();
        article = GetArticle();

        PXWikiShow show = GetRenderControl("edContent", "Content", "lblContent");

        MainForm.TemplateContainer.Controls.Add(show);

        MainForm.DataBinding += new EventHandler(form_DataBinding);
        if (show != null)
        {
            show.WikiContext = _pageDBContextType == null
                                ? new PXDBContext(WikiSettings.Relative)
                                : (PXDBContext)Activator.CreateInstance(_pageDBContextType, WikiSettings.Relative, pageId);
            show.SectionEditStarting += new PXWikiSectionEventHandler(show_SectionEditStarting);
            show.SectionUpdated      += new PXWikiSectionEventHandler(show_SectionUpdated);
            show.EditorCreated       += new EventHandler(show_EditorCreated);
            this.ClientScript.RegisterClientScriptBlock(GetType(), "showid", "var wikiShowId='" + show.ClientID + "';", true);
        }
        if (!DesignMode)
        {
            string prevScreenID = Page.Request.QueryString["PrevScreenID"];
            if (!string.IsNullOrEmpty(prevScreenID) && this.Master is IPXMasterPage)
            {
                (Master as IPXMasterPage).ScreenID = prevScreenID;
            }
        }
        string navurl = this.GetExportUrl();

        if (this.MainToolbar != null)
        {
            PXToolBarButton exportBtn = ((PXToolBarButton)this.MainToolbar.Items["export"]);
            exportBtn.MenuItems[0].NavigateUrl = navurl + "&type=txt";
            exportBtn.MenuItems[1].NavigateUrl = navurl + "&type=rtf";

            /*if (article != null)
             * {
             *      exportBtn.MenuItems[2].NavigateUrl = "ExportDita.axd?DITAConversionType=ConversionType1&pageid=" + article.PageID + "&lang=" + article.Language + "&name=" + HttpUtility.HtmlEncode(article.Title) + "&type=last";
             *      exportBtn.MenuItems[3].NavigateUrl = "ExportDita.axd?DITAConversionType=ConversionType1&pageid=" + article.PageID + "&lang=" + article.Language + "&name=" + HttpUtility.HtmlEncode(article.Title) + "&type=published";
             * }*/
        }
        WikiReader wikiReader = DS.DataGraph as WikiReader;

        if (wikiReader != null)
        {
            wikiReader.AppVirtualPath  = Request.GetWebsiteAuthority().GetLeftPart(UriPartial.Authority);
            wikiReader.WebDAVFilesPath = !string.IsNullOrEmpty(_filesPath) ? ResolveUrl(_filesPath) : ResolveUrl("~/Files");
        }
    }
Example #12
0
    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;
        }
    }
Example #13
0
    protected void show_SectionEditStarting(object sender, PXWikiSectionEventArgs e)
    {
        WikiReader graph = (WikiReader)this.DS.DataGraph;

        e.SectionContent = graph.ConvertGuidToLink(e.SectionContent);
    }
Example #14
0
		public PXWikiSettings(Page page, WikiReader reader)
		{
			this.page = page;
			this.reader = reader ?? PXGraph.CreateInstance<WikiReader>();
		}
Example #15
0
 public PXWikiSettings(Page page, WikiReader reader)
 {
     this.page   = page;
     this.reader = reader ?? PXGraph.CreateInstance <WikiReader>();
 }