using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Web.Script.Serialization; using CMS.PortalControls; using CMS.PortalEngine; using CMS.UIControls; using CMS.Chat; using CMS.GlobalHelper; using CMS.CMSHelper; using CMS.Controls; using CMS.DataEngine; using CMS.SettingsProvider; public partial class CMSWebParts_Chat_InitiatedChat : CMSAbstractWebPart { #region Properties /// /// Gets or sets ItemTemplate property. /// public string TransformationName { get { return DataHelper.GetNotEmpty(this.GetValue("TransformationName"), ChatHelper.TransformationInitiatedChat); } set { this.SetValue("TransformationName", value); } } /// /// Transformation name for messages in ChatRoomMessages child webpart /// public string ChatMessageTransformationName { get { return DataHelper.GetNotEmpty(this.GetValue("ChatMessageTransformationName"), ChatHelper.TransformationRoomMessages); } set { this.SetValue("ChatMessageTransformationName", value); } } /// /// Transformation name for errors in ChatErrors child webpart /// public string ChatErrorTransformationName { get { return DataHelper.GetNotEmpty(this.GetValue("ChatErrorTransformationName"), ChatHelper.TransformationErrors); } set { this.SetValue("ChatErrorTransformationName", value); } } /// /// Transformation name for clear all errors button in ChatErrors child webpart /// public string ChatErrorDeleteAllButtonTransformationName { get { return DataHelper.GetNotEmpty(this.GetValue("ChatErrorDeleteAllButtonTransformationName"), ChatHelper.TransformationErrorsDeleteAll); } set { this.SetValue("ChatErrorDeleteAllButtonTransformationName", value); } } /// /// Transformation name for users in ChatRoomUsers child webpart /// public string ChatRoomUserTransformationName { get { return DataHelper.GetNotEmpty(this.GetValue("ChatRoomUserTransformationName"), ChatHelper.TransformationRoomUsers); } set { this.SetValue("ChatRoomUserTransformationName", value); } } #endregion protected void Page_Prerender(object sender, EventArgs e) { ChatHelper.RegisterStylesheet(Page, false); } protected void Page_Load(object sender, EventArgs e) { if (!((ViewMode == ViewModeEnum.LiveSite) || (ViewMode == ViewModeEnum.Preview))) { return; } // Registration to chat webservice AbstractCMSPage cmsPage = Page as AbstractCMSPage; if (cmsPage != null) { ChatHelper.RegisterChatAJAXProxy(cmsPage); } // Script references insertion ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx", false); ScriptHelper.RegisterScriptFile(Page, "jquery/jquery-tmpl.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/InitiatedChat_files/InitiatedChat.js"); int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName); // Run script JavaScriptSerializer sr = new JavaScriptSerializer(); string json = sr.Serialize( new { clientID = pnlInitiatedChat.ClientID, contentID = pnlContent.ClientID, pnlErrorID = pnlError.ClientID, lblErrorID = lblError.ClientID, windowURL = ChatHelper.GetChatRoomWindowURL(), trans = ChatHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"), guid = optID, pingTick = ChatHelper.GlobalPingIntervalSetting * 1000 } ); string startupScript = string.Format("InitInitiatedChatManager({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatInitiatedChat_" + ClientID, startupScript, true); } }