I've posted the 0.95 files required to do this here: http://www.mostlylucid.co.uk/archive/2004/06/03/1066.aspx, not perfect but does the job for the moment...
Thanks for the info guys. I've added quite a few little tweaks for DNN and ASP.NET Forums, so please feel free to tell me if there are any .Text specific needs. Also FYI: the latest version has table support and I'm working on some possible image upload/gallery
apps (notably http://www.lennybacon.com/samples/StaticDust.Web.UI.Controls.UploadDialog.aspx). Thanks again for .Text! (I'm just beginning to use mine at http://blog.revjon.com/) JD
Do you know what changes do I need to do to the core of .Text in order to use the new FreeTextBox version 2? I tryd to put the EditEntry.ascx file you gave with the new FreeTextBox.dll file, but it returns null - I can't copy over the dll's cause I made core
changes. Thanks.
Free LIFETIME DNN Portal with 100MB(Up to 3000MB),200 Modules(2000$ worth),50 Skins,30 Languages,Statistics,Guides and Forum for help. Browse the directory of hundreds of sites. www.BuildPortal.com
Umm...yes...I've been a little remiss in putting together the sourcefile changes. I still have the issue (in IE inly of the little javascript prompt appearing - I'll get back to this hopefully!) Here's the basic source changes, so you have the ascx, the codebehind
currently looks like this:
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Dottext.Framework;
using Dottext.Framework.Components;
using Dottext.Framework.Configuration;
using Dottext.Framework.Util;
using Dottext.Web.Admin.Pages;
using Dottext.Web.Admin.WebUI;
using FreeTextBoxControls;
using Page = Dottext.Web.Admin.WebUI.Page;
#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// .Text WebLog
//
// .Text is an open source weblog system started by Scott Watermasysk.
// Blog: http://ScottWater.com/blog
// RSS: http://scottwater.com/blog/rss.aspx
// Email: Dottext@ScottWater.com
//
// For updated news and information please visit http://scottwater.com/dottext and subscribe to
// the Rss feed @ http://scottwater.com/dottext/rss.aspx
//
// On its release (on or about August 1, 2003) this application is licensed under the BSD. However, I reserve the
// right to change or modify this at any time. The most recent and up to date license can always be fount at:
// http://ScottWater.com/License.txt
//
// Please direct all code related questions to:
// GotDotNet Workspace: http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=e99fccb3-1a8c-42b5-90ee-348f6b77c407
// Yahoo Group http://groups.yahoo.com/group/DotText/
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion
namespace Dottext.Web.Admin.UserControls
{
public class EntryEditor : UserControl
{
private const string FTB_RESOURCE_PATH = "/admin/resources/ftb/DotText/";
private const string VSKEY_POSTID = "PostID";
private const string VSKEY_CATEGORYID = "CategoryID";
private const string VSKEY_CATEGORYTYPE = "CategoryType";
private int _filterCategoryID = Constants.NULL_CATEGORYID;
private int _resultsPageNumber = 1;
private PostType _entryType = PostType.BlogPost;
private bool _isListHidden = false;
protected MessagePanel Messages;
protected Repeater rprSelectionList;
protected HtmlGenericControl NoMessagesLabel;
protected Pager ResultsPager;
protected HyperLink hlEntryLink;
protected TextBox txbTitle;
protected TextBox txbBody;
protected FreeTextBox ftbBody;
protected Button Post;
protected TextBox txbExcerpt;
protected TextBox txbTitleUrl;
protected TextBox Textbox1;
protected TextBox Textbox2;
protected CheckBox ckbPublished;
protected CheckBox chkComments;
protected CheckBox chkDisplayHomePage;
protected CheckBox chkMainSyndication;
protected CheckBox chkSyndicateDescriptionOnly;
protected CheckBox chkIsAggregated;
protected CheckBoxList cklCategories;
protected AdvancedPanel Results;
protected AdvancedPanel Advanced;
protected TextBox txbSourceName;
protected TextBox txbSourceUrl;
protected LinkButton lkbPost;
protected LinkButton lkbCancel;
protected AdvancedPanel Edit;
protected RequiredFieldValidator valftbBodyRequired;
protected RequiredFieldValidator valTitleRequired;
protected LinkButton lkbNewPost;
protected TextBox txbEntryName;
#region Accessors
// REFACTOR: are all of these still relevant when done?
public PostType EntryType
{
get { return _entryType; }
set { _entryType = value; }
}
public int PostID
{
get
{
if(ViewState[VSKEY_POSTID] != null)
return (int)ViewState[VSKEY_POSTID];
else
return Constants.NULL_POSTID;
}
set { ViewState[VSKEY_POSTID] = value; }
}
private int CategoryID
{
get
{
if(ViewState[VSKEY_CATEGORYID] != null)
return (int)ViewState[VSKEY_CATEGORYID];
else
return Constants.NULL_CATEGORYID;
}
set { ViewState[VSKEY_CATEGORYID] = value; }
}
public CategoryType CategoryType
{
get
{
if(ViewState[VSKEY_CATEGORYTYPE] != null)
return (CategoryType)ViewState[VSKEY_CATEGORYTYPE];
else
throw new ApplicationException("CategoryType was not set");
}
set
{
ViewState[VSKEY_CATEGORYTYPE] = value;
}
}
public bool IsListHidden
{
get { return _isListHidden; }
set { _isListHidden = value; }
}
public string ResultsTitle
{
get
{
return Results.HeaderText;
}
set
{
Results.HeaderText = value;
}
}
public string ResultsUrlFormat
{
set
{
this.ResultsPager.UrlFormat = value;
}
}
#endregion
private void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (null != Request.QueryString[Keys.QRYSTR_PAGEINDEX])
_resultsPageNumber = Convert.ToInt32(Request.QueryString[Keys.QRYSTR_PAGEINDEX]);
if (null != Request.QueryString[Keys.QRYSTR_CATEGORYID])
_filterCategoryID = Convert.ToInt32(Request.QueryString[Keys.QRYSTR_CATEGORYID]);
ResultsPager.PageSize = Preferences.ListingItemCount;
ResultsPager.PageIndex = _resultsPageNumber;
Results.Collapsible = false;
if (Constants.NULL_CATEGORYID != _filterCategoryID)
ResultsPager.UrlFormat += String.Format("&{0}={1}",
Keys.QRYSTR_CATEGORYID, _filterCategoryID);
BindList();
BindCategoryList();
SetEditorMode();
ftbBody.ButtonPath = Globals.WebPathCombine(Request.ApplicationPath,FTB_RESOURCE_PATH);
}
}
private void BindList()
{
Edit.Visible = false;
PagedEntryCollection selectionList = Entries.GetPagedEntries(_entryType, _filterCategoryID,
_resultsPageNumber, ResultsPager.PageSize,true);
if (selectionList.Count > 0)
{
ResultsPager.ItemCount = selectionList.MaxItems;
rprSelectionList.DataSource = selectionList;
rprSelectionList.DataBind();
NoMessagesLabel.Visible = false;
}
NoMessagesLabel.Visible = selectionList.Count <= 0;
ResultsPager.Visible = selectionList.Count > 0;
}
private void BindCategoryList()
{
cklCategories.DataSource = Links.GetCategories(CategoryType,false);
cklCategories.DataValueField = "CategoryID";
cklCategories.DataTextField = "Title";
cklCategories.DataBind();
}
private void SetConfirmation()
{
ConfirmationPage confirmPage = (ConfirmationPage)this.Page;
confirmPage.IsInEdit = true;
confirmPage.Message = "You will lose any unsaved content";
this.lkbPost.Attributes.Add("OnClick",ConfirmationPage.ByPassFuncationName);
this.lkbCancel.Attributes.Add("OnClick",ConfirmationPage.ByPassFuncationName);
}
private void BindPostEdit()
{
SetConfirmation();
Entry currentPost = Entries.GetEntry(PostID, false);
Results.Collapsed = true;
Edit.Visible = true;
txbTitle.Text = currentPost.Title;
txbExcerpt.Text = currentPost.Description;
txbSourceUrl.Text = currentPost.SourceUrl;
txbSourceName.Text = currentPost.SourceName;
hlEntryLink.NavigateUrl = currentPost.Link;
hlEntryLink.Text = currentPost.Link;
hlEntryLink.Attributes.Add("title", "view: " + currentPost.Title);
hlEntryLink.Visible = true;
chkComments.Checked = currentPost.AllowComments;
chkDisplayHomePage.Checked = currentPost.DisplayOnHomePage;
chkMainSyndication.Checked = currentPost.IncludeInMainSyndication;
chkSyndicateDescriptionOnly.Checked = currentPost.SyndicateDescriptionOnly ;
chkIsAggregated.Checked = currentPost.IsAggregated;
SetEditorText(currentPost.Body);
ckbPublished.Checked = currentPost.IsActive;
for (int i =0; i < cklCategories.Items.Count;i++)
cklCategories.Items[i].Selected = false;
LinkCollection postCategories = Links.GetLinkCollectionByPostID(PostID);
if (postCategories.Count > 0)
{
for (int i = 0; i < postCategories.Count; i++)
{
cklCategories.Items.FindByValue(postCategories[i].CategoryID.ToString()).Selected = true;
}
}
SetEditorMode();
Results.Collapsible = true;
Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced;
Control container = Page.FindControl("PageContainer");
if (null != container && container is Page)
{
Page page = (Page)container;
string title = String.Format("Editing {0} \"{1}\"",
CategoryType == CategoryType.StoryCollection ? "Article" : "Post", currentPost.Title);
page.BreadCrumbs.AddLastItem(title);
page.Title = title;
}
if(currentPost.HasEntryName)
{
this.Advanced.Collapsed = false;
txbEntryName.Text = currentPost.EntryName;
}
}
public void EditNewEntry()
{
ResetPostEdit(true);
SetConfirmation();
}
private void ResetPostEdit(bool showEdit)
{
PostID = Constants.NULL_POSTID;
Results.Collapsible = showEdit;
Results.Collapsed = showEdit;
Edit.Visible = showEdit;
hlEntryLink.NavigateUrl = String.Empty;
hlEntryLink.Attributes.Clear();
hlEntryLink.Visible = false;
txbTitle.Text = String.Empty;
txbExcerpt.Text = String.Empty;
txbSourceUrl.Text = String.Empty;
txbSourceName.Text = String.Empty;
txbEntryName.Text = string.Empty;
ckbPublished.Checked = Preferences.AlwaysCreateIsActive;
chkComments.Checked = true;
chkDisplayHomePage.Checked = true;
chkMainSyndication.Checked = true;
chkSyndicateDescriptionOnly.Checked = false;
chkIsAggregated.Checked = true;
ftbBody.Text = String.Empty;
txbBody.Text = String.Empty;
for(int i =0; i < cklCategories.Items.Count;i++)
cklCategories.Items[i].Selected = false;
Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced;
SetEditorMode();
}
private void UpdatePost()
{
if(Page.IsValid)
{
string successMessage = Constants.RES_SUCCESSNEW;
try
{
Entry entry = new Entry(EntryType);
entry.Title = txbTitle.Text;
entry.Body = Globals.StripRTB(ftbBody.Text,Request.Url.Host);
//entry.Body = Globals.StripRTB(Utilities.CheckIsIE55() ? ftbBody.Text : txbBody.Text,Request.Url.Host);
entry.IsActive = ckbPublished.Checked;
entry.SourceName = txbSourceName.Text;
entry.Author = Config.CurrentBlog().Author;
entry.Email = Config.CurrentBlog().Email;
entry.SourceUrl = txbSourceUrl.Text;
entry.Description = txbExcerpt.Text;
entry.TitleUrl = txbTitleUrl.Text;
entry.AllowComments = chkComments.Checked;
entry.DisplayOnHomePage = chkDisplayHomePage.Checked;
entry.IncludeInMainSyndication = chkMainSyndication.Checked;
entry.SyndicateDescriptionOnly = chkSyndicateDescriptionOnly.Checked;
entry.IsAggregated = chkIsAggregated.Checked;
entry.EntryName = txbEntryName.Text;
entry.BlogID = Config.CurrentBlog().BlogID;
if (PostID > 0)
{
successMessage = Constants.RES_SUCCESSEDIT;
entry.DateUpdated = BlogTime.CurrentBloggerTime;
entry.EntryID = PostID;
Entries.Update(entry);
}
else
{
entry.DateCreated = BlogTime.CurrentBloggerTime;
PostID = Entries.Create(entry);
}
if (PostID > 0)
{
//LinkCollection lc = new LinkCollection();
ArrayList al = new ArrayList();
int count = cklCategories.Items.Count;
for (int i =0; i<count;i++)
{
if (cklCategories.Items[i].Selected)
{
al.Add(Int32.Parse(cklCategories.Items[i].Value));
}
}
int[] Categories = (int[])al.ToArray(typeof(int));
Entries.SetEntryCategoryList(PostID,Categories);
BindList();
this.Messages.ShowMessage(successMessage);
this.ResetPostEdit(false);
}
else
this.Messages.ShowError(Constants.RES_FAILUREEDIT
+ " There was a baseline problem posting your entry.");
}
catch(Exception ex)
{
this.Messages.ShowError(String.Format(Constants.RES_EXCEPTION,
Constants.RES_FAILUREEDIT, ex.Message));
}
finally
{
Results.Collapsible = false;
}
}
}
private void SetEditorMode()
{
//valftbBodyRequired.Visible = ftbBody.Visible = Utilities.CheckIsIE55();
//valtbBodyRequired.Visible = txbBody.Visible = !ftbBody.Visible;
if(CategoryType == CategoryType.StoryCollection)
{
this.chkDisplayHomePage.Visible = false;
this.chkIsAggregated.Visible = false;
this.chkMainSyndication.Visible =false;
this.chkSyndicateDescriptionOnly.Visible = false;
}
}
private void SetEditorText(string bodyValue)
{
//if (Utilities.CheckIsIE55())
ftbBody.Text = bodyValue;
//else
// txbBody.Text = bodyValue;
}
private void ConfirmDelete(int postID)
{
(Page as AdminPage).Command = new DeletePostCommand(postID);
(Page as AdminPage).Command.RedirectUrl = Request.Url.ToString();
Server.Transfer(Constants.URL_CONFIRM);
}
public string CheckHiddenStyle()
{
if (_isListHidden)
return Constants.CSSSTYLE_HIDDEN;
else
return String.Empty;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.rprSelectionList.ItemCommand += new RepeaterCommandEventHandler(this.rprSelectionList_ItemCommand);
this.lkbPost.Click += new EventHandler(this.lkbPost_Click);
this.lkbCancel.Click += new EventHandler(this.lkbCancel_Click);
this.Load += new EventHandler(this.Page_Load);
}
#endregion
private void rprSelectionList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "edit" :
PostID = Convert.ToInt32(e.CommandArgument);
BindPostEdit();
break;
case "delete" :
ConfirmDelete(Convert.ToInt32(e.CommandArgument));
break;
default:
break;
}
}
private void lkbCancel_Click(object sender, EventArgs e)
{
ResetPostEdit(false);
}
private void lkbPost_Click(object sender, EventArgs e)
{
UpdatePost();
}
private void lkbNewPost_Click(object sender, EventArgs e)
{
ResetPostEdit(true);
}
}
}
revjon
Member
225 Points
45 Posts
FreeTextBox 2
Jun 02, 2004 07:17 PM|LINK
Scott Gallow...
Participant
1510 Points
302 Posts
Re: FreeTextBox 2
Jun 02, 2004 11:01 PM|LINK
Scott Gallow...
Participant
1510 Points
302 Posts
Re: FreeTextBox 2
Jun 02, 2004 11:26 PM|LINK
ScottW
Contributor
3651 Points
730 Posts
ASPInsiders
Re: FreeTextBox 2
Jun 03, 2004 02:37 AM|LINK
http://www.scottw.com
revjon
Member
225 Points
45 Posts
Re: FreeTextBox 2
Jun 03, 2004 03:03 PM|LINK
liorlustig
Contributor
2035 Points
407 Posts
Re: FreeTextBox 2
Jul 07, 2004 12:14 PM|LINK
Browse the directory of hundreds of sites.
www.BuildPortal.com
Scott Gallow...
Participant
1510 Points
302 Posts
Re: FreeTextBox 2
Jul 08, 2004 10:19 PM|LINK
using System; using System.Collections; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using Dottext.Framework; using Dottext.Framework.Components; using Dottext.Framework.Configuration; using Dottext.Framework.Util; using Dottext.Web.Admin.Pages; using Dottext.Web.Admin.WebUI; using FreeTextBoxControls; using Page = Dottext.Web.Admin.WebUI.Page; #region Disclaimer/Info /////////////////////////////////////////////////////////////////////////////////////////////////// // .Text WebLog // // .Text is an open source weblog system started by Scott Watermasysk. // Blog: http://ScottWater.com/blog // RSS: http://scottwater.com/blog/rss.aspx // Email: Dottext@ScottWater.com // // For updated news and information please visit http://scottwater.com/dottext and subscribe to // the Rss feed @ http://scottwater.com/dottext/rss.aspx // // On its release (on or about August 1, 2003) this application is licensed under the BSD. However, I reserve the // right to change or modify this at any time. The most recent and up to date license can always be fount at: // http://ScottWater.com/License.txt // // Please direct all code related questions to: // GotDotNet Workspace: http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=e99fccb3-1a8c-42b5-90ee-348f6b77c407 // Yahoo Group http://groups.yahoo.com/group/DotText/ // /////////////////////////////////////////////////////////////////////////////////////////////////// #endregion namespace Dottext.Web.Admin.UserControls { public class EntryEditor : UserControl { private const string FTB_RESOURCE_PATH = "/admin/resources/ftb/DotText/"; private const string VSKEY_POSTID = "PostID"; private const string VSKEY_CATEGORYID = "CategoryID"; private const string VSKEY_CATEGORYTYPE = "CategoryType"; private int _filterCategoryID = Constants.NULL_CATEGORYID; private int _resultsPageNumber = 1; private PostType _entryType = PostType.BlogPost; private bool _isListHidden = false; protected MessagePanel Messages; protected Repeater rprSelectionList; protected HtmlGenericControl NoMessagesLabel; protected Pager ResultsPager; protected HyperLink hlEntryLink; protected TextBox txbTitle; protected TextBox txbBody; protected FreeTextBox ftbBody; protected Button Post; protected TextBox txbExcerpt; protected TextBox txbTitleUrl; protected TextBox Textbox1; protected TextBox Textbox2; protected CheckBox ckbPublished; protected CheckBox chkComments; protected CheckBox chkDisplayHomePage; protected CheckBox chkMainSyndication; protected CheckBox chkSyndicateDescriptionOnly; protected CheckBox chkIsAggregated; protected CheckBoxList cklCategories; protected AdvancedPanel Results; protected AdvancedPanel Advanced; protected TextBox txbSourceName; protected TextBox txbSourceUrl; protected LinkButton lkbPost; protected LinkButton lkbCancel; protected AdvancedPanel Edit; protected RequiredFieldValidator valftbBodyRequired; protected RequiredFieldValidator valTitleRequired; protected LinkButton lkbNewPost; protected TextBox txbEntryName; #region Accessors // REFACTOR: are all of these still relevant when done? public PostType EntryType { get { return _entryType; } set { _entryType = value; } } public int PostID { get { if(ViewState[VSKEY_POSTID] != null) return (int)ViewState[VSKEY_POSTID]; else return Constants.NULL_POSTID; } set { ViewState[VSKEY_POSTID] = value; } } private int CategoryID { get { if(ViewState[VSKEY_CATEGORYID] != null) return (int)ViewState[VSKEY_CATEGORYID]; else return Constants.NULL_CATEGORYID; } set { ViewState[VSKEY_CATEGORYID] = value; } } public CategoryType CategoryType { get { if(ViewState[VSKEY_CATEGORYTYPE] != null) return (CategoryType)ViewState[VSKEY_CATEGORYTYPE]; else throw new ApplicationException("CategoryType was not set"); } set { ViewState[VSKEY_CATEGORYTYPE] = value; } } public bool IsListHidden { get { return _isListHidden; } set { _isListHidden = value; } } public string ResultsTitle { get { return Results.HeaderText; } set { Results.HeaderText = value; } } public string ResultsUrlFormat { set { this.ResultsPager.UrlFormat = value; } } #endregion private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (null != Request.QueryString[Keys.QRYSTR_PAGEINDEX]) _resultsPageNumber = Convert.ToInt32(Request.QueryString[Keys.QRYSTR_PAGEINDEX]); if (null != Request.QueryString[Keys.QRYSTR_CATEGORYID]) _filterCategoryID = Convert.ToInt32(Request.QueryString[Keys.QRYSTR_CATEGORYID]); ResultsPager.PageSize = Preferences.ListingItemCount; ResultsPager.PageIndex = _resultsPageNumber; Results.Collapsible = false; if (Constants.NULL_CATEGORYID != _filterCategoryID) ResultsPager.UrlFormat += String.Format("&{0}={1}", Keys.QRYSTR_CATEGORYID, _filterCategoryID); BindList(); BindCategoryList(); SetEditorMode(); ftbBody.ButtonPath = Globals.WebPathCombine(Request.ApplicationPath,FTB_RESOURCE_PATH); } } private void BindList() { Edit.Visible = false; PagedEntryCollection selectionList = Entries.GetPagedEntries(_entryType, _filterCategoryID, _resultsPageNumber, ResultsPager.PageSize,true); if (selectionList.Count > 0) { ResultsPager.ItemCount = selectionList.MaxItems; rprSelectionList.DataSource = selectionList; rprSelectionList.DataBind(); NoMessagesLabel.Visible = false; } NoMessagesLabel.Visible = selectionList.Count <= 0; ResultsPager.Visible = selectionList.Count > 0; } private void BindCategoryList() { cklCategories.DataSource = Links.GetCategories(CategoryType,false); cklCategories.DataValueField = "CategoryID"; cklCategories.DataTextField = "Title"; cklCategories.DataBind(); } private void SetConfirmation() { ConfirmationPage confirmPage = (ConfirmationPage)this.Page; confirmPage.IsInEdit = true; confirmPage.Message = "You will lose any unsaved content"; this.lkbPost.Attributes.Add("OnClick",ConfirmationPage.ByPassFuncationName); this.lkbCancel.Attributes.Add("OnClick",ConfirmationPage.ByPassFuncationName); } private void BindPostEdit() { SetConfirmation(); Entry currentPost = Entries.GetEntry(PostID, false); Results.Collapsed = true; Edit.Visible = true; txbTitle.Text = currentPost.Title; txbExcerpt.Text = currentPost.Description; txbSourceUrl.Text = currentPost.SourceUrl; txbSourceName.Text = currentPost.SourceName; hlEntryLink.NavigateUrl = currentPost.Link; hlEntryLink.Text = currentPost.Link; hlEntryLink.Attributes.Add("title", "view: " + currentPost.Title); hlEntryLink.Visible = true; chkComments.Checked = currentPost.AllowComments; chkDisplayHomePage.Checked = currentPost.DisplayOnHomePage; chkMainSyndication.Checked = currentPost.IncludeInMainSyndication; chkSyndicateDescriptionOnly.Checked = currentPost.SyndicateDescriptionOnly ; chkIsAggregated.Checked = currentPost.IsAggregated; SetEditorText(currentPost.Body); ckbPublished.Checked = currentPost.IsActive; for (int i =0; i < cklCategories.Items.Count;i++) cklCategories.Items[i].Selected = false; LinkCollection postCategories = Links.GetLinkCollectionByPostID(PostID); if (postCategories.Count > 0) { for (int i = 0; i < postCategories.Count; i++) { cklCategories.Items.FindByValue(postCategories[i].CategoryID.ToString()).Selected = true; } } SetEditorMode(); Results.Collapsible = true; Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced; Control container = Page.FindControl("PageContainer"); if (null != container && container is Page) { Page page = (Page)container; string title = String.Format("Editing {0} \"{1}\"", CategoryType == CategoryType.StoryCollection ? "Article" : "Post", currentPost.Title); page.BreadCrumbs.AddLastItem(title); page.Title = title; } if(currentPost.HasEntryName) { this.Advanced.Collapsed = false; txbEntryName.Text = currentPost.EntryName; } } public void EditNewEntry() { ResetPostEdit(true); SetConfirmation(); } private void ResetPostEdit(bool showEdit) { PostID = Constants.NULL_POSTID; Results.Collapsible = showEdit; Results.Collapsed = showEdit; Edit.Visible = showEdit; hlEntryLink.NavigateUrl = String.Empty; hlEntryLink.Attributes.Clear(); hlEntryLink.Visible = false; txbTitle.Text = String.Empty; txbExcerpt.Text = String.Empty; txbSourceUrl.Text = String.Empty; txbSourceName.Text = String.Empty; txbEntryName.Text = string.Empty; ckbPublished.Checked = Preferences.AlwaysCreateIsActive; chkComments.Checked = true; chkDisplayHomePage.Checked = true; chkMainSyndication.Checked = true; chkSyndicateDescriptionOnly.Checked = false; chkIsAggregated.Checked = true; ftbBody.Text = String.Empty; txbBody.Text = String.Empty; for(int i =0; i < cklCategories.Items.Count;i++) cklCategories.Items[i].Selected = false; Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced; SetEditorMode(); } private void UpdatePost() { if(Page.IsValid) { string successMessage = Constants.RES_SUCCESSNEW; try { Entry entry = new Entry(EntryType); entry.Title = txbTitle.Text; entry.Body = Globals.StripRTB(ftbBody.Text,Request.Url.Host); //entry.Body = Globals.StripRTB(Utilities.CheckIsIE55() ? ftbBody.Text : txbBody.Text,Request.Url.Host); entry.IsActive = ckbPublished.Checked; entry.SourceName = txbSourceName.Text; entry.Author = Config.CurrentBlog().Author; entry.Email = Config.CurrentBlog().Email; entry.SourceUrl = txbSourceUrl.Text; entry.Description = txbExcerpt.Text; entry.TitleUrl = txbTitleUrl.Text; entry.AllowComments = chkComments.Checked; entry.DisplayOnHomePage = chkDisplayHomePage.Checked; entry.IncludeInMainSyndication = chkMainSyndication.Checked; entry.SyndicateDescriptionOnly = chkSyndicateDescriptionOnly.Checked; entry.IsAggregated = chkIsAggregated.Checked; entry.EntryName = txbEntryName.Text; entry.BlogID = Config.CurrentBlog().BlogID; if (PostID > 0) { successMessage = Constants.RES_SUCCESSEDIT; entry.DateUpdated = BlogTime.CurrentBloggerTime; entry.EntryID = PostID; Entries.Update(entry); } else { entry.DateCreated = BlogTime.CurrentBloggerTime; PostID = Entries.Create(entry); } if (PostID > 0) { //LinkCollection lc = new LinkCollection(); ArrayList al = new ArrayList(); int count = cklCategories.Items.Count; for (int i =0; i<count;i++) { if (cklCategories.Items[i].Selected) { al.Add(Int32.Parse(cklCategories.Items[i].Value)); } } int[] Categories = (int[])al.ToArray(typeof(int)); Entries.SetEntryCategoryList(PostID,Categories); BindList(); this.Messages.ShowMessage(successMessage); this.ResetPostEdit(false); } else this.Messages.ShowError(Constants.RES_FAILUREEDIT + " There was a baseline problem posting your entry."); } catch(Exception ex) { this.Messages.ShowError(String.Format(Constants.RES_EXCEPTION, Constants.RES_FAILUREEDIT, ex.Message)); } finally { Results.Collapsible = false; } } } private void SetEditorMode() { //valftbBodyRequired.Visible = ftbBody.Visible = Utilities.CheckIsIE55(); //valtbBodyRequired.Visible = txbBody.Visible = !ftbBody.Visible; if(CategoryType == CategoryType.StoryCollection) { this.chkDisplayHomePage.Visible = false; this.chkIsAggregated.Visible = false; this.chkMainSyndication.Visible =false; this.chkSyndicateDescriptionOnly.Visible = false; } } private void SetEditorText(string bodyValue) { //if (Utilities.CheckIsIE55()) ftbBody.Text = bodyValue; //else // txbBody.Text = bodyValue; } private void ConfirmDelete(int postID) { (Page as AdminPage).Command = new DeletePostCommand(postID); (Page as AdminPage).Command.RedirectUrl = Request.Url.ToString(); Server.Transfer(Constants.URL_CONFIRM); } public string CheckHiddenStyle() { if (_isListHidden) return Constants.CSSSTYLE_HIDDEN; else return String.Empty; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.rprSelectionList.ItemCommand += new RepeaterCommandEventHandler(this.rprSelectionList_ItemCommand); this.lkbPost.Click += new EventHandler(this.lkbPost_Click); this.lkbCancel.Click += new EventHandler(this.lkbCancel_Click); this.Load += new EventHandler(this.Page_Load); } #endregion private void rprSelectionList_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName.ToLower()) { case "edit" : PostID = Convert.ToInt32(e.CommandArgument); BindPostEdit(); break; case "delete" : ConfirmDelete(Convert.ToInt32(e.CommandArgument)); break; default: break; } } private void lkbCancel_Click(object sender, EventArgs e) { ResetPostEdit(false); } private void lkbPost_Click(object sender, EventArgs e) { UpdatePost(); } private void lkbNewPost_Click(object sender, EventArgs e) { ResetPostEdit(true); } } }