Beispiel #1
0
        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());
        }