예제 #1
0
        /// <summary>
        /// Save the content.
        /// </summary>
        /// <param name="content"></param>
        public void SaveContent(StaticHtmlContent content)
        {
            ITransaction tx = base.NHSession.BeginTransaction();

            try
            {
                if (content.Id == -1)
                {
                    content.UpdateTimestamp = DateTime.Now;
                    base.NHSession.Save(content);
                    OnContentCreated(new IndexEventArgs(StaticHtmlContentToSearchContent(content)));
                }
                else
                {
                    base.NHSession.Update(content);
                    OnContentUpdated(new IndexEventArgs(StaticHtmlContentToSearchContent(content)));
                }
                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw new Exception("Unable to save content: " + ex.Message, ex);
            }
        }
예제 #2
0
        public override void DeleteModuleContent()
        {
            // Delete the associated StaticHtmlContent
            StaticHtmlContent content = this.GetContent();

            if (content != null)
            {
                DeleteContent(content);
            }
        }
예제 #3
0
        public SearchContent[] GetAllSearchableContent()
        {
            StaticHtmlContent shc = GetContent();

            if (shc != null)
            {
                SearchContent[] searchContents = new SearchContent[1];
                searchContents[0] = StaticHtmlContentToSearchContent(shc);
                return(searchContents);
            }
            else
            {
                return(new SearchContent[0]);
            }
        }
예제 #4
0
        /// <summary>
        /// Delete the content.
        /// </summary>
        /// <param name="content"></param>
        public void DeleteContent(StaticHtmlContent content)
        {
            ITransaction tx = base.NHSession.BeginTransaction();

            try
            {
                base.NHSession.Delete(content);
                tx.Commit();
                OnContentDeleted(new IndexEventArgs(StaticHtmlContentToSearchContent(content)));
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw new Exception("Unable to delete content: " + ex.Message, ex);
            }
        }
예제 #5
0
        private SearchContent StaticHtmlContentToSearchContent(StaticHtmlContent shc)
        {
            SearchContent sc = new SearchContent();

            sc.Title        = shc.Section.Title;
            sc.Summary      = Text.TruncateText(shc.Content, 200);        // trunctate the summary to 200 chars
            sc.Contents     = shc.Content;
            sc.Author       = shc.ModifiedBy.FullName;
            sc.ModuleType   = shc.Section.ModuleType.Name;
            sc.Path         = this.SectionUrl;
            sc.Category     = String.Empty;
            sc.Site         = (shc.Section.Node != null ? shc.Section.Node.Site.Name : String.Empty);
            sc.DateCreated  = shc.UpdateTimestamp;
            sc.DateModified = shc.UpdateTimestamp;
            sc.SectionId    = shc.Section.Id;

            return(sc);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.fckEditor.BasePath = this.Page.ResolveUrl("~/Support/FCKeditor/");
            this._module            = base.Module as StaticHtmlModule;

            if (!this.IsPostBack)
            {
                StaticHtmlContent shc = this._module.GetContent();
                if (shc != null)
                {
                    this.fckEditor.Value = shc.Content;
                }
                else
                {
                    this.fckEditor.Value = String.Empty;
                }
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            StaticHtmlModule module = this.Module as StaticHtmlModule;

            if (module != null && !base.HasCachedOutput)
            {
                Literal           htmlControl = new Literal();
                StaticHtmlContent shc         = module.GetContent();
                if (shc != null)
                {
                    htmlControl.Text = shc.Content;
                }
                else
                {
                    htmlControl.Text = String.Empty;
                }
                this.plcContent.Controls.Add(htmlControl);
            }
        }
        private void SaveStaticHtml()
        {
            CMS.Core.Domain.User currentUser = (CMS.Core.Domain.User)Context.User.Identity;
            StaticHtmlContent    content     = this._module.GetContent();

            if (content == null)
            {
                // New
                content            = new StaticHtmlContent();
                content.Section    = this._module.Section;
                content.CreatedBy  = currentUser;
                content.ModifiedBy = currentUser;
            }
            else
            {
                // Exisiting
                content.ModifiedBy = currentUser;
            }
            content.Content = this.fckEditor.Value;
            this._module.SaveContent(content);
        }