예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(UrlKey))
            {
                if (Article != null && Article.HandlerId == StaticHandlerId)
                {
                    StaticArticle staticArticle = new StaticArticle(Article);

                    this.Title = staticArticle.Title;

                    if (!string.IsNullOrEmpty(staticArticle.Head))
                    {
                        this.pageheadLiteral.Text = staticArticle.Head;
                    }

                    //populate the meta-data tags
                    if (!string.IsNullOrEmpty(staticArticle.Description))
                    {
                        this.MetaDescription = staticArticle.Description;
                    }

                    if (!string.IsNullOrEmpty(staticArticle.SerializedTags))
                    {
                        this.MetaKeywords = staticArticle.SerializedTags;
                    }

                    // show the article.
                    this.noArticleFoundDiv.Visible = false;

                    Control control = GetPageControl(this.Master);
                    IArticleControl articleControl = control as IArticleControl;
                    if (articleControl != null)
                    {
                        articleControl.Article = staticArticle;
                    }
                    else
                    {
                        // try as html container control
                        HtmlContainerControl htmlControl = control as HtmlContainerControl;
                        if (htmlControl != null)
                        {
                            htmlControl.InnerHtml = staticArticle.Body;
                        }
                    }

                    // add the control to div
                    this.articlesDiv.Controls.Add(control);

                    //add navigation etc.
                    AddMasterPageInformation(staticArticle);

                }
                else
                {
                    //hide the article div
                    this.articlesDiv.Visible = false;
                }

            }
        }
예제 #2
0
        private void RenderForPage(StaticArticle article)
        {
            // pages don't have summary
            this.summarydiv.Visible = false;

            if (article != null)
            {
                this.headtext.Value = article.Head;
                this.tags.Value = article.SerializedTags;
                this.navigationtab.Value = ((INavigationTag)article).Name;
                this.description.Value = article.Description;
            }
        }
예제 #3
0
        public string SavePageMetadata(string urlKey, string navigationtab, string tags, string description, string head)
        {
            //make sure the user has access
            RatnaUser user = base.ValidatedUser();
            if (user == null)
            {
                return SendAccessDenied();
            }

            ServiceOutput output = new ServiceOutput();
            output.Success = false;

            if (!string.IsNullOrEmpty(urlKey))
            {
                try
                {
                    bool exists = ArticleStore.Instance.Exists(urlKey);

                    if (exists)
                    {

                        StaticArticle article = new StaticArticle();
                        article.UrlKey = urlKey;
                        article.Read(PublishingStage.Draft);
                        article.RemoveTags();

                        ((INavigationTag)article).Name = navigationtab ?? string.Empty;;

                        if (!string.IsNullOrEmpty(tags))
                        {
                            article.AddTags(tags);
                        }

                        article.Head = head ?? string.Empty;
                        article.Description = description ?? string.Empty;
                        article.Update();

                        output.Success = true;
                    }
                }
                catch (MessageException me)
                {
                    logger.Log(LogLevel.Error, "Unable to save article metadata. MessageException - {0}", me);
                    output.AddOutput(Constants.Json.Error, me.Message);
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Unable to save article metadata. Exception - {0}", ex);
                    output.AddOutput(Constants.Json.Error, ResourceManager.GetLiteral("Admin.Articles.Edit.Create.Error"));
                }
            }

            return output.GetJson();
        }
예제 #4
0
        public string SavePage(string urlKey, string title, string body)
        {
            //make sure the user has access
            RatnaUser user = base.ValidatedUser();
            if (user == null)
            {
                return SendAccessDenied();
            }

            ServiceOutput output = new ServiceOutput();
            output.Success = false;

            if (!string.IsNullOrEmpty(urlKey))
            {
                //make sure the url is relative and valid.
                if (!Uri.IsWellFormedUriString(urlKey, UriKind.Relative))
                {
                    // failed because URL is not valid.
                    output.AddOutput(Constants.Json.Error, ResourceManager.GetLiteral("Admin.Articles.Edit.Url.Validate.Error"));
                }
                else
                {
                    try
                    {
                        bool exists = ArticleStore.Instance.Exists(urlKey);

                        StaticArticle article = new StaticArticle();
                        article.UrlKey = urlKey;

                        // if the article already exists, read the article
                        // to sync with latest version
                        if (exists)
                        {
                            article.Read(PublishingStage.Draft);
                        }

                        article.Title = title;
                        article.Body = body;

                        if (!exists)
                        {
                            article.Owner = user;
                            article.Create();
                        }
                        else
                        {
                            article.Update();
                        }

                        output.Success = true;
                    }
                    catch (MessageException me)
                    {
                        logger.Log(LogLevel.Error, "Unable to save page. MessageException - {0}", me);
                        output.AddOutput(Constants.Json.Error, me.Message);
                    }
                    catch (Exception ex)
                    {
                        logger.Log(LogLevel.Error, "Unable to save page. Exception - {0}", ex);
                        output.AddOutput(Constants.Json.Error, ResourceManager.GetLiteral("Admin.Articles.Edit.Create.Error"));
                    }
                }
            }

            return output.GetJson();
        }