Ejemplo n.º 1
0
    protected void btSave_Click(object sender, EventArgs e)
    {
        try
        {
            Eucalypto.Wiki.Article article = Eucalypto.Wiki.WikiManager.GetArticleByName(ArticleName, true);

            //Check permissions
            if (Eucalypto.SecurityHelper.CanEdit(Page.User, article.Category, article) == false)
                throw new Eucalypto.InvalidPermissionException("edit the article");

            Eucalypto.XHTMLText xhtml = new Eucalypto.XHTMLText();
            xhtml.Load(txtBody.Text);

            Exception validateError;
            if (xhtml.IsValid(article.Category.XHtmlMode, out validateError) == false)
                throw new Eucalypto.TextNotValidException(validateError);

            //TOC
            if (chkCreateTOC.Checked)
                article.TOC = xhtml.GenerateTOC();
            else
                article.TOC = null;

            article.Body = xhtml.GetXhtml();
            article.Description = txtDescription.Text;
            article.Title = txtTitle.Text;
            article.Approved = chkApproved.Checked;
            article.Enabled = chkEnabled.Checked;
            article.UpdateUser = Page.User.Identity.Name;
            article.Author = txtAuthor.Text;

            Eucalypto.Wiki.WikiManager.UpdateArticle(article, chkBackup.Checked);

            Navigation.Wiki_ViewArticle(article.Name, 0).Redirect(this);
        }
        catch (Exception ex)
        {
            ((IErrorMessage)Master).SetError(GetType(), ex);
        }
    }
Ejemplo n.º 2
0
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            Eucalypto.Forum.Category forum = GetForum();

            //Check permission
            if (Eucalypto.SecurityHelper.CanInsert(Page.User, forum))
            {
                Eucalypto.XHTMLText xhtml = new Eucalypto.XHTMLText();
                xhtml.Load(newMessage.MessageBodyHtml);

                Exception validateError;
                if (xhtml.IsValid(forum.XHtmlMode, out validateError) == false)
                    throw new Eucalypto.TextNotValidException(validateError);

                Eucalypto.Attachment.FileInfo attachment = null;
                //Create attachment
                if (newMessage.AttachmentFile.HasFile)
                    attachment = new Eucalypto.Attachment.FileInfo(newMessage.AttachmentFile.FileName,
                                                                newMessage.AttachmentFile.PostedFile.ContentType,
                                                                newMessage.AttachmentFile.FileBytes);

                //Insert the topic
                Eucalypto.Forum.ForumManager.CreateTopic(forum, User.Identity.Name,
                                                    newMessage.MessageSubject,
                                                    xhtml.GetXhtml(),
                                                    attachment);
            }
            else
                throw new Eucalypto.InvalidPermissionException("insert new message");

            Navigation.Forum_ViewForum(ForumName).Redirect(this);
        }
        catch (Exception ex)
        {
            ((IErrorMessage)Master).SetError(GetType(), ex);
        }
    }
Ejemplo n.º 3
0
    private string ElaborateXHTML(Eucalypto.Wiki.Article latestArticle, Eucalypto.Wiki.ArticleBase article)
    {
        Eucalypto.XHTMLText xhtml = new Eucalypto.XHTMLText();
        xhtml.Load(article.Body);

        string[] attachments = Eucalypto.Wiki.WikiManager.GetFileAttachments(latestArticle, Eucalypto.Wiki.EnabledStatus.Enabled);
        Array.Sort<string>(attachments);

        xhtml.ReplaceLinks(delegate(string oldUrl, out string newUrl)
                            { ReplaceLink(latestArticle.Name, attachments, oldUrl, out newUrl); }
                            );

        //Insert the TOC
        xhtml.InsertTOC(article.TOC);

        return xhtml.GetXhtml();
    }