protected override void OnInit(EventArgs e) { base.OnInit(e); //Editors in the control panel hack if (Page != null && Page.Master != null && Page.Master.Master != null) { ContentPlaceHolder placeholder = Page.Master.Master.FindControl("StyleRegion") as ContentPlaceHolder; if (placeholder == null && Page.Master.Master.Master != null) { placeholder = Page.Master.Master.Master.FindControl("StyleRegion") as ContentPlaceHolder; } if (placeholder != null) { placeholder.PreRender += (sender, b) => { ICustomEditorPlugin plugin = PluginManager.GetSingleton <ICustomEditorPlugin>(); LiteralControl lit = new LiteralControl("<style type=\"text/css\">" + plugin.Css + "</style>"); ((Control)sender).Controls.Add(lit); }; } } }
public void ProcessRequest(HttpContextBase context) { HttpRequestBase request = context.Request; HttpResponseBase response = context.Response; StringBuilder retval = new StringBuilder(); ICustomEditorPlugin plugin = PluginManager.GetSingleton <ICustomEditorPlugin>(); if (plugin != null && plugin.EditorEnabled) { if (request.HttpMethod.Equals("POST")) { HttpFileCollectionBase upload = request.Files; for (int i = 0; i < upload.Count; i++) { UploadToApplication(context, upload[i], plugin.FileLink, plugin.DefaultWidth, plugin.DefaultHeight, retval); } } response.Clear(); response.AddHeader("Content-type", "application/json"); response.Write(retval.ToString()); } else { response.Clear(); response.StatusCode = 403; response.Status = "Access denied"; } response.End(); }
private string RenderEditor() { StringBuilder stringBuilder = new StringBuilder(); if (EnableHtmlModeEditing) { ICustomEditorPlugin plugin = PluginManager.GetSingleton <ICustomEditorPlugin>(); String name = new StringBuilder("EditorWrapper-").Append(plugin.EditorName).ToString(); if (!Page.ClientScript.IsStartupScriptRegistered(GetType(), name)) { Page.ClientScript.RegisterStartupScript(GetType(), name, ""); foreach (ICentralizedFile file in plugin.Files) { stringBuilder.Append("<script type=\"text/javascript\" src='").Append(PublicApi.Html.EncodeAttribute(file.GetDownloadUrl())).Append("'></script>").AppendLine(); } } if (!Page.ClientScript.IsStartupScriptRegistered(GetType(), ClientID)) { HttpContext context = HttpContext.Current; String uploaderId = Guid.NewGuid().ToString(); PageContext pageContext = PublicApi.Url.CurrentContext; if (pageContext == null) { pageContext = PublicApi.Url.ParsePageContext(System.Web.HttpContext.Current.Request.Url.ToString()); } var authCookie = context.Request.Cookies["AuthorizationCookie"]; string authValue = string.Empty; if (authCookie != null) { authValue = authCookie.Value; } string callbackUrl = plugin.GetCallbackUrl(uploaderId, ClientID, pageContext.ApplicationTypeId.GetValueOrDefault(), pageContext.ContainerTypeId.GetValueOrDefault(), ContentTypeId.GetValueOrDefault(), authValue, pageContext.ContextItems.GetAllContextItems()); Telligent.Evolution.Urls.Routing.IContextItem group = pageContext.ContextItems.GetAllContextItems().FirstOrDefault <Telligent.Evolution.Urls.Routing.IContextItem>(g => g.TypeName == "Group"); bool sourceButton = true; if (group != null) { sourceButton = PublicApi.Permissions.Get(PermissionRegistrar.CustomEditorSourceButton, PublicApi.Users.AccessingUser.Id.Value, group.ContentId.GetValueOrDefault(), pageContext.ContainerTypeId.Value).IsAllowed; } stringBuilder.Append("<script type=\"text/javascript\">jQuery.fourroads.customEditor.Attach('").Append(ClientID).Append("','"); stringBuilder.Append(callbackUrl); stringBuilder.Append("','").Append(callbackUrl).Append("&delete=true',").Append(SupportFileUpload.ToString().ToLower()).Append(",").Append(sourceButton.ToString().ToLower()).Append(")").Append("</script>"); } } return(stringBuilder.ToString()); }