protected override void Render(HtmlTextWriter writer) { var headControl = Page.Header; if (headControl == null) { base.Render(writer); return; } try { var hrefSchemeAndServerPart = PortalContext.Current.OriginalUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped); var hrefPathPart = PortalContext.Current.OriginalUri.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped); hrefSchemeAndServerPart = VirtualPathUtility.AppendTrailingSlash(hrefSchemeAndServerPart); var hrefString = String.Concat(hrefSchemeAndServerPart, hrefPathPart); //note that if the original URI already contains a trailing slash, we do not remove it if (AppendTrailingSlash) hrefString = VirtualPathUtility.AppendTrailingSlash(hrefString); var baseTag = new LiteralControl { ID = "baseTag", Text = String.Format("<base href=\"{0}\" />", hrefString) }; baseTag.RenderControl(writer); } catch (Exception exc) //logged { Logger.WriteException(exc); } }
private void cbUpgrade_Callback(object sender, Controls.CallBackEventArgs e) { string upFilePath = Server.MapPath("~/desktopmodules/activeforums/upgrade4x.txt"); string err = "Success"; try { if (System.IO.File.Exists(upFilePath)) { string s = Utilities.GetFileContent(upFilePath); err = DotNetNuke.Entities.Portals.PortalSettings.ExecuteScript(s); System.IO.File.Delete(upFilePath); } } catch (Exception ex) { if (ex is UnauthorizedAccessException && string.IsNullOrEmpty(err)) { err = "<span style=\"font-size:14px;font-weight:bold;\">The forum data was upgraded successfully, but you must manually delete the following file:<br /><br />" + upFilePath + "<br /><br />The upgrade is not complete until you delete the file indicated above.</span>"; } else { err = "<span style=\"font-size:14px;font-weight:bold;\">Upgrade Failed - Please go to the <a href=\"http://www.activemodules.com/community/helpdesk.aspx\">Active Modules Help Desk</a> to report the error indicated below:<br /><br />" + ex.Message + "</span>"; } } LiteralControl lit = new LiteralControl(); if (string.IsNullOrEmpty(err)) { err = "<script type=\"text/javascript\">LoadView('home');</script>"; } lit.Text = err; lit.RenderControl(e.Output); }
protected override void RenderContents(HtmlTextWriter writer) { LiteralControl ctrl = new LiteralControl(); if (base.State == SourceCode.Forms.Controls.Web.Shared.ControlState.Runtime) { string sampleHTML = GenerateHTML(); ctrl.Text = sampleHTML; } else { ctrl.Text = "Thai Baht Text by K2"; } ctrl.RenderControl(writer); }
public override string XGetDesignTimeHtml(DesignerRegionCollection regions) { EditableDesignerRegion region = new EditableDesignerRegion(this, "Body", false); regions.Add(region); StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); FieldSet c = (FieldSet)this.Control; string width = " width: {0};".FormatWith(c.Width.ToString()); string height = " height: {0}px;".FormatWith((c.Height.Value - 39).ToString()); string buttons = ""; buttons += (c.CheckboxToggle && !c.Collapsible) ? "<input name=\"ext-comp-1002-checkbox\" type=\"checkbox\">" : ""; buttons += (c.Collapsible && !c.CheckboxToggle) ? "<div class=\"x-tool x-tool-toggle\"> </div>" : ""; /* * 0 - ClientID * 1 - Title * 2 - Width * 3 - Height * 4 - Buttons * 5 - BodyStyle */ object[] args = new object[6]; args[0] = c.ClientID; args[1] = c.Title; args[2] = width; args[3] = height; args[4] = buttons; args[5] = c.BodyStyle; LiteralControl topCtrl = new LiteralControl(string.Format(this.HtmlBegin, args)); topCtrl.RenderControl(htmlWriter); HtmlGenericControl div = (HtmlGenericControl)c.ContentContainer; div.Attributes[DesignerRegion.DesignerRegionAttributeName] = "0"; div.InnerHtml = this.GetEditableDesignerRegionContent(region); div.RenderControl(htmlWriter); LiteralControl bottomCtrl = new LiteralControl(this.HtmlEnd); bottomCtrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); Checkbox c = (Checkbox)this.Control; object[] args = new object[7]; args[0] = c.ClientID; args[1] = c.Checked.ToString().ToLower(); args[5] = c.StyleSpec; args[6] = "x-form-checkbox x-form-field " + c.ClearCls; LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); DatePicker c = (DatePicker)this.Control; string width = (c.Width != Unit.Empty) ? " width: {0};".FormatWith(c.Width.ToString()) : ""; string height = (c.Height != Unit.Empty) ? " height: {0};".FormatWith(c.Height.ToString()) : ""; object[] args = new object[3]; args[0] = c.ClientID; args[1] = DateTime.Today.ToString("MMMM yyyy"); args[2] = c.TodayText; LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); TextArea c = (TextArea)this.Control; string width = (c.Width != Unit.Empty) ? " width: {0};".FormatWith(c.Width.ToString()) : ""; string height = (c.Height != Unit.Empty) ? " height: {0};".FormatWith(c.Height.ToString()) : ""; object[] args = new object[7]; args[0] = c.ClientID; args[1] = c.Text.IsEmpty() ? c.EmptyText : c.Text; args[2] = width; args[3] = height; args[4] = c.StyleSpec; args[5] = "x-form-textarea x-form-field " + (c.Text.IsEmpty() ? "x-form-empty-field " : "") + c.Cls; LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
/// <summary> /// /// </summary> /// <returns></returns> public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); NumberField c = (NumberField)this.Control; string width = (c.Width != Unit.Empty) ? " width: {0};".FormatWith((c.Grow && c.GrowMin.Value > c.Width.Value) ? c.GrowMin.ToString() : c.Width.ToString()) : ""; string height = (c.Height != Unit.Empty) ? " height: {0};".FormatWith(c.Height.ToString()) : ""; object[] args = new object[7]; args[0] = c.ClientID; args[1] = c.Text.IsEmpty() ? c.EmptyText : c.Text; args[2] = c.InputType.ToString().ToLower(); args[3] = width; args[4] = height; args[5] = c.StyleSpec; args[6] = "x-form-text x-form-field x-form-num-field " + ((c.Text.IsEmpty()) ? "x-form-empty-field " : "") + c.Cls; LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); HtmlEditor c = (HtmlEditor)this.Control; string width = " width: {0};".FormatWith((c.Width != Unit.Empty) ? c.Width.ToString() : "504px"); string height = " height: {0};".FormatWith((c.Height != Unit.Empty) ? c.Height.ToString() : "275px"); /* * 0 - ClientID * 1 - Text * 2 - Width * 3 - Height * 4 - Font * 5 - Format * 6 - FontSize * 7 - Colors * 8 - Alignments * 9 - Links * 10 - Lists * 11- SourceEdit */ object[] args = new object[12]; args[0] = c.ClientID; args[1] = c.Text; args[2] = width; args[3] = height; args[4] = (c.EnableFont) ? this.Font : ""; args[5] = (c.EnableFormat) ? this.Format : ""; args[6] = (c.EnableFontSize) ? this.FontSize : ""; args[7] = (c.EnableColors) ? this.Colors : ""; args[8] = (c.EnableAlignments) ? this.Alignments : ""; args[9] = (c.EnableLinks) ? this.Links : ""; args[10] = (c.EnableLists) ? this.Lists : ""; args[11] = (c.EnableSourceEdit) ? this.SourceEdit : ""; LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
protected virtual void RenderEmptyZoneText(HtmlTextWriter writer) { var emptyText = new LiteralControl(EmptyZoneText); emptyText.RenderControl(writer); }
protected void renderToolbar(HtmlTextWriter writer) { LiteralControl toolbar = new LiteralControl(); toolbar.Text = "<div class='widgetToolbarWrapper'>"; toolbar.Text += "<div><a href='#' type='textbox'><img src='/umbraco/plugins/WidgetBuilder/images/textbox.png' alt='' title='Textbox'/><span>Textbox</span></a></div>"; toolbar.Text += "<div><a href='#' type='textarea'><img src='/umbraco/plugins/WidgetBuilder/images/textarea.png' alt='' title='Textarea'/><span>Textarea</span></a></div>"; toolbar.Text += "<div><a href='#' type='tinymce'><img src='/umbraco/plugins/WidgetBuilder/images/tinymce.png' alt='' title='TinyMCE'/><span>TinyMCE</span></a></div>"; toolbar.Text += "<div><a href='#' type='list'><img src='/umbraco/plugins/WidgetBuilder/images/list.png' alt='' title='List'/><span>List</span></a></div>"; if (Widget_Builder.HasSpreadsheet) { toolbar.Text += "<div><a href='#' type='spreadsheet'><img src='/umbraco/plugins/WidgetBuilder/images/spreadsheet.png' alt='' title='Spreadsheet'/><span>Spreadsheet</span></a></div>"; } toolbar.Text += "<div><a href='#' type='mediapicker'><img src='/umbraco/plugins/WidgetBuilder/images/mediapicker.png' alt='' title='MediaPicker'/><span>Media Picker</span></a></div>"; toolbar.Text += "<div><a href='#' type='checkradio'><img src='/umbraco/plugins/WidgetBuilder/images/checkradio.png' alt='' title='Checkbox/Radio'/><span>Check/Radio</span></a></div>"; toolbar.Text += "<div><a href='#' type='dropdown'><img src='/umbraco/plugins/WidgetBuilder/images/dropdown.png' alt='' title='Dropdown'/><span>Dropdown</span></a></div>"; toolbar.Text += "<div><a href='#' type='contentpicker'><img src='/umbraco/plugins/WidgetBuilder/images/contentpicker.png' alt='' title='ContentPicker'/><span>Content Picker</span></a></div>"; if (Widget_Builder.HasDamp) { toolbar.Text += "<div><a href='#' type='damp'><img src='/umbraco/plugins/WidgetBuilder/images/damp.png' alt='' title='DAMP'/><span>DAMP</span></a></div>"; } toolbar.Text += "<div><a href='#' type='map'><img src='/umbraco/plugins/WidgetBuilder/images/map.png' alt='' title='DAMP'/><span>Map</span></a></div>"; toolbar.Text += "<div><a href='#' type='inlinepicker'><img src='/umbraco/plugins/WidgetBuilder/images/inlinepicker.png' alt='' title='Inline Image Picker'/><span>Inline Image Picker</span></a></div>"; //toolbar.Text += "<div><a href='#' type='datepicker'><img src='/umbraco/plugins/WidgetBuilder/images/datepicker.png' alt='' title='Date Picker'/><span>Date Picker</span></a></div>"; toolbar.Text += "</div>"; toolbar.Text += "<div><a class='json' href='#'>Toggle JSON (Advanced Only)</a></div>"; toolbar.RenderControl(writer); }
/// <summary> /// Overrides <see cref="HtmlControl.Render"/>. /// </summary> protected override void Render( HtmlTextWriter writer ) { base.Render(writer); if ( master != null ) { LiteralControl script = new LiteralControl("\r\n<script language='javascript'>\r\nMetaBuilders_RowSelectorColumn_Register('" + master.ClientID + "', '" + this.ClientID + "')\r\n</script>"); script.RenderControl(writer); } }
public override string XGetDesignTimeHtml(DesignerRegionCollection regions) { designerRegions = regions; Panel c = (Panel)this.Control; StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); string width = " width: {0};".FormatWith((c.Width == Unit.Empty) ? "auto" : c.Width.ToString()); string height = " height: {0};".FormatWith((c.Height == Unit.Empty) ? "auto" : (c.Height.Value - 27).ToString() + "px"); string buttons = ""; buttons += (c.Collapsible) ? "<a {0}><div class=\"x-tool x-tool-toggle\"> </div></a>" : ""; if (this.Layout.HasValue && this.Layout.Value != LayoutType.Border || !this.Layout.HasValue) { if (buttons.IsNotEmpty()) { buttons = string.Format(buttons, GetDesignerRegionAttribute(PanelClickAction.Toggle)); } else { // for prevent shifting regions designerRegions.Add(new DesignerRegion(CurrentDesigner, "Empty", false)); } } if (this.Layout.HasValue) { if (!Width.IsEmpty) { width = " width: {0};".FormatWith((Width == Unit.Empty) ? "auto" : Width.ToString()); } if (!Height.IsEmpty) { if (Height.Type == UnitType.Pixel) { height = " height: {0}px;".FormatWith(Height.Value - 27); } else { height = " height: {0};".FormatWith(Height); } } if (this.Layout.Value == LayoutType.Border) { if (BorderRegion.Collapsible && BorderRegion.Region != RegionPosition.Center) { buttons = "<a {1}><div class=\"x-tool x-tool-toggle x-tool-collapse-{0}\"> </div></a>".FormatWith(BorderRegion.Region.ToString().ToLower(), GetDesignerRegionAttribute(BorderRegion.Region, BorderLayoutDesigner.BorderLayoutClickAction.Collapse)); } else { // for prevent shifting regions designerRegions.Add(new DesignerRegion(CurrentDesigner, "Empty", false)); buttons = ""; } } } string iconCls = ""; this.AddIcon(c.Icon); if (c.IconClsProxy.IsNotEmpty()) { if (c.Frame) { iconCls = "x-panel-icon " + c.IconClsProxy; } else { iconCls = "<img src=\"{0}\" class=\"x-panel-inline-icon {1}\" />".FormatWith(c.ResourceManager.BLANK_IMAGE_URL, c.IconClsProxy); } } string header = ""; if (c.Header) { /* * 0 - x-panel-header-noborder * 1 - IconCls * 2 - Title * 3 - Buttons */ object[] headerArgs = new object[4]; headerArgs[0] = !c.Border ? "x-panel-header-noborder" : ""; headerArgs[1] = iconCls; headerArgs[2] = c.Title; headerArgs[3] = buttons; header = string.Format(this.HtmlHeader, headerArgs); } /* 0 - Width 1 - x-panel-noborder 2 - Collapsed style 3 - Collapsed display: block; 4 - BodyStyle 5 - Height 6 - x-panel-body-noborder 7 - HEADER */ object[] args = new object[8]; args[0] = width; args[1] = !c.Border ? "x-panel-noborder" : ""; args[2] = c.Collapsed && c.Collapsible ? "x-panel-collapsed" : ""; args[3] = (c.Collapsed) ? "display: none;" : "display: block;"; args[4] = c.BodyStyle; args[5] = height; args[6] = !c.Border ? "x-panel-body-noborder" : ""; args[7] = header; LiteralControl topCtrl = new LiteralControl(string.Format(this.HtmlBegin, args) + this.GetIconStyleBlock()); topCtrl.RenderControl(htmlWriter); HtmlGenericControl div = (HtmlGenericControl)c.ContentContainer; EditableDesignerRegion region = new EditableDesignerRegion(CurrentDesigner, ContentRegionName, false); designerRegions.Add(region); if ((!c.Collapsible) || (c.Collapsible && !c.Collapsed) || (this.Layout.HasValue && this.Layout.Value == LayoutType.Border)) { div.Attributes[DesignerRegion.DesignerRegionAttributeName] = (designerRegions.Count - 1).ToString(); div.Style["height"] = "100%"; div.Style["overflow"] = "hidden"; div.RenderControl(htmlWriter); } LiteralControl bottomCtrl = new LiteralControl(this.HtmlEnd); bottomCtrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml() { StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); DateField c = (DateField)this.Control; string width = (c.Width != Unit.Empty) ? " width: {0};".FormatWith(c.Width.ToString()) : ""; string height = (c.Height != Unit.Empty) ? " height: {0};".FormatWith(c.Height.ToString()) : ""; object[] args = new object[9]; args[0] = c.ClientID; if (c.SelectedDate != DateTime.MinValue && c.SelectedDate != DateTime.MaxValue) { args[1] = c.SelectedDate.ToString(c.Format); } else { args[1] = ""; } args[2] = width; args[3] = height; args[4] = c.StyleSpec; args[5] = "x-form-text x-form-field " + ((c.IsEmpty) ? "x-form-empty-field " : "") + c.Cls; args[6] = "x-form-trigger x-form-date-trigger " + c.TriggerClass; ResourceManager sm = c.ResourceManager; if (sm != null) { args[7] = c.ResourceManager.BLANK_IMAGE_URL; } else { args[7] = ""; } args[8] = " width: {0};".FormatWith((c.Width != Unit.Empty) ? (c.Width.Value + 20) + "px" : "144px"); LiteralControl ctrl = new LiteralControl(string.Format(this.Html, args)); ctrl.RenderControl(htmlWriter); return writer.ToString(); }
public override string XGetDesignTimeHtml(DesignerRegionCollection regions) { Window c = (Window)this.Control; designerRegions = regions; EditableDesignerRegion region = new EditableDesignerRegion(this, "Body", false); regions.Add(region); StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); string width = " width: {0};".FormatWith(c.Width.ToString()); string height = " height: {0}px;".FormatWith((c.Height.Value - 30).ToString()); string buttons = ""; buttons += (c.Closable) ? "<div class=\"x-tool x-tool-close\"> </div>" : ""; buttons += (c.Maximizable) ? "<div class=\"x-tool x-tool-maximize\"> </div>" : ""; buttons += (c.Minimizable) ? "<div class=\"x-tool x-tool-minimize\"> </div>" : ""; buttons += (c.Collapsible) ? "<a {0}><div class=\"x-tool x-tool-toggle\"> </div></a>" : ""; if (c.Collapsible) { buttons = string.Format(buttons, GetDesignerRegionAttribute(WindowClickAction.Toggle)); } else { // for prevent shifting regions designerRegions.Add(new DesignerRegion(this.CurrentDesigner, "Empty", false)); } /* * 0 - ClientID * 1 - Title * 2 - Width * 3 - Height * 4 - Buttons * 5 - BodyStyle */ object[] args = new object[9]; args[0] = c.ClientID; args[1] = c.Title.IsEmpty() ? " " : c.Title; args[2] = width; args[3] = height; args[4] = buttons; args[5] = c.BodyStyle; args[6] = c.IconClsProxy.IsNotEmpty() ? "x-panel-icon " + c.IconClsProxy : ""; args[7] = c.Collapsed && c.Collapsible ? "x-panel-collapsed" : ""; args[8] = (c.Collapsed && c.Collapsible) ? "display: none;" : "display: block;"; // NOTE: Make sure you add to the object[SIZE] above if adding to the args array. this.AddIcon(c.Icon); LiteralControl topCtrl = new LiteralControl(string.Format(this.HtmlBegin, args) + this.GetIconStyleBlock()); topCtrl.RenderControl(htmlWriter); if (!(c.Collapsed && c.Collapsible)) { HtmlGenericControl div = (HtmlGenericControl)c.ContentContainer; div.Attributes[DesignerRegion.DesignerRegionAttributeName] = "0"; div.Style["height"] = "100%"; div.RenderControl(htmlWriter); } LiteralControl bottomCtrl = new LiteralControl(string.Format(this.HtmlEnd, args[8])); bottomCtrl.RenderControl(htmlWriter); string temp = writer.ToString(); return temp; }
private void cbSecurityToggle_Callback(object sender, CallBackEventArgs e) { string action = e.Parameters[0].ToString(); int pId = PermissionsId; string secId = e.Parameters[2].ToString(); int secType = Convert.ToInt32(e.Parameters[3].ToString()); string key = e.Parameters[4].ToString(); string returnId = e.Parameters[5].ToString(); Data.Common db = new Data.Common(); string sOut = string.Empty; if (action == "delete") { Permissions.RemoveObjectFromAll(secId, secType, pId); } else if (action == "addobject") { if (secType == 1) { UserController uc = new UserController(); User ui = uc.GetUser(PortalId, ModuleId, secId); if (ui != null) { secId = ui.UserId.ToString(); } else { secId = string.Empty; } } else { if (secId.Contains(":")) { secType = 2; } } if (! (string.IsNullOrEmpty(secId))) { string permSet = db.GetPermSet(pId, "View"); permSet = Permissions.AddPermToSet(secId, secType, permSet); db.SavePermSet(pId, "View", permSet); } } else { string permSet = db.GetPermSet(pId, key); if (action == "remove") { permSet = Permissions.RemovePermFromSet(secId, secType, permSet); } else { permSet = Permissions.AddPermToSet(secId, secType, permSet); } db.SavePermSet(pId, key, permSet); sOut = action + "|" + returnId; } LiteralControl lit = new LiteralControl(sOut); lit.RenderControl(e.Output); }
private void cbMyFiles_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { string attachIds = e.Parameters[1].ToString(); switch (e.Parameters[0].ToLowerInvariant()) { case "del": if (SimulateIsNumeric.IsNumeric(e.Parameters[2])) { int aid = Convert.ToInt32(e.Parameters[2]); Data.AttachController ac = new Data.AttachController(); int uid = -1; if (SimulateIsNumeric.IsNumeric(e.Parameters[3])) { uid = Convert.ToInt32(e.Parameters[3]); } if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser) { ac.Attach_Delete(aid, -1, uid); } } break; } PendingAttach = 0; plhMyFiles.Controls.Clear(); BindMyFiles(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); plhMyFiles.RenderControl(htmlWriter); string html = stringWriter.GetStringBuilder().ToString(); html = Utilities.LocalizeControl(html); LiteralControl lit = new LiteralControl(); lit.Text = html; lit.RenderControl(e.Output); }
private void cbAttach_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { string attachIds = e.Parameters[1].ToString(); switch (e.Parameters[0].ToLowerInvariant()) { case "delcont": { if (SimulateIsNumeric.IsNumeric(e.Parameters[2])) { int aid = Convert.ToInt32(e.Parameters[2]); int uid = -1; if (SimulateIsNumeric.IsNumeric(e.Parameters[3])) { uid = Convert.ToInt32(e.Parameters[3]); } if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser) { Data.AttachController adb = new Data.AttachController(); adb.Attach_Delete(aid, ContentId); //ac.Attach_Delete(aid, -1, uid) } } break; } case "thumb": { if (SimulateIsNumeric.IsNumeric(e.Parameters[2])) { int aid = Convert.ToInt32(e.Parameters[2]); Data.AttachController ac = new Data.AttachController(); int uid = -1; if (SimulateIsNumeric.IsNumeric(e.Parameters[3])) { uid = Convert.ToInt32(e.Parameters[3]); } AttachInfo ai = ac.Attach_Get(aid, -1, uid, false); if (ai != null) { int w = Convert.ToInt32(e.Parameters[4]); int h = Convert.ToInt32(e.Parameters[5]); System.IO.MemoryStream imgStream = new System.IO.MemoryStream(); string fpath = string.Empty; int fileSize = 0; string tmpFilename = string.Empty; if (ai.FileData != null) { byte[] bindata = null; bindata = (byte[])ai.FileData; System.IO.MemoryStream memStream = new System.IO.MemoryStream(bindata); imgStream = (System.IO.MemoryStream)(Images.CreateImageForDB(memStream, h, w)); fileSize = Convert.ToInt32(imgStream.Length); tmpFilename = "thumb_" + ai.Filename; } else { fpath = Server.MapPath(PortalSettings.HomeDirectory + "activeforums_Attach/"); //fpath &= "thumb_" & ai.Filename tmpFilename = "thumb_" + ai.Filename; string sFullFile = fpath + tmpFilename; int i = 0; while (File.Exists(sFullFile)) { i += 1; tmpFilename = i.ToString().PadLeft(3, '0') + "_thumb_" + ai.Filename; sFullFile = fpath + tmpFilename; } File.Copy(fpath + ai.Filename, sFullFile); Images.CreateImage(sFullFile, h, w); fileSize = (int)new FileInfo(sFullFile).Length; } AttachInfo aiThumb = new AttachInfo(); aiThumb.ContentId = -1; aiThumb.UserID = ai.UserID; aiThumb.Filename = tmpFilename; aiThumb.ContentType = "image/x-png"; aiThumb.FileSize = fileSize; if (ForumInfo.AttachStore == AttachStores.DATABASE) { aiThumb.FileData = imgStream.ToArray(); //File.Delete(fpath & "thumb_" & ai.Filename) } aiThumb.ParentAttachId = aid; int thumbId = ac.Attach_Save(aiThumb); attachIds += thumbId.ToString() + ";"; BindMyFiles(); if (Convert.ToBoolean(e.Parameters[4])) { string strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(Request)) + "/"; string s = "<script type=\"text/javascript\">"; string sInsert = string.Empty; if (ForumInfo.AllowHTML && ForumInfo.EditorType != EditorTypes.TEXTBOX) { sInsert = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + aid + "\" target=\"_blank\"><img src=" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + " border=0 /></a>"; } else { sInsert = "[THUMBNAIL:" + thumbId.ToString() + ":" + aid + "]"; } s += "amaf_insertHTML('" + sInsert + "');"; s += "</script>"; LiteralControl litScript = new LiteralControl(); litScript.Text = s; plhAttach.Controls.Add(litScript); } } } break; } case "inline": { if (SimulateIsNumeric.IsNumeric(e.Parameters[2])) { int aid = Convert.ToInt32(e.Parameters[2]); Data.AttachController ac = new Data.AttachController(); int uid = -1; if (SimulateIsNumeric.IsNumeric(e.Parameters[3])) { uid = Convert.ToInt32(e.Parameters[3]); } AttachInfo ai = ac.Attach_Get(aid, -1, uid, false); if (ai != null) { int opt = Convert.ToInt32(e.Parameters[4]); if (opt == 0) { ai.DisplayInline = true; ai.AllowDownload = false; } else { if (ai.AllowDownload) { ai.DisplayInline = true; ai.AllowDownload = false; } else { ai.DisplayInline = false; ai.AllowDownload = true; } } ac.Attach_Save(ai); } } break; } } BindAttach(attachIds); System.IO.StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); plhAttach.RenderControl(htmlWriter); string html = stringWriter.GetStringBuilder().ToString(); html = Utilities.LocalizeControl(html); LiteralControl lit = new LiteralControl(); lit.Text = html; lit.RenderControl(e.Output); }
private void Add(HtmlTextWriter w, string html) { LiteralControl lit = new LiteralControl(html); lit.RenderControl(w); }