/// <summary>
    /// Creates collection of tabs which should be displayed to the user.
    /// </summary>
    private void GetTabs()
    {
        UITabs tabControl = CurrentMaster.Tabs;

        bool checkUI = true;

        // Disable personalization for none-HTML editors
        if ((CustomOutputFormat == "copy") || (CustomOutputFormat == "move") || (CustomOutputFormat == "link") ||
            (CustomOutputFormat == "relationship") || (CustomOutputFormat == "selectpath"))
        {
            checkUI = false;
        }
        else if (IsLiveSite)
        {
            // Ensure personalization of the HTML editor on the live site
            checkUI = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CKEditor:PersonalizeToolbarOnLiveSite"], false);
        }

        if (checkUI)
        {
            if ((OutputFormat == OutputFormatEnum.HTMLMedia) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia"))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertImageOrMedia")) + "';} "));
                return;
            }
            if ((OutputFormat == OutputFormatEnum.HTMLLink) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink"))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertLink")) + "';} "));
                return;
            }
            if ((CustomOutputFormat == "linkdoc") && !(MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "New.LinkExistingDocument") && MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "New")))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.Content", null, "New.LinkExistingDocument")) + "';} "));
                return;
            }
        }

        // Attachments
        if ((CustomOutputFormat == "") && (!HasMetaFileObjectInfo) && !HideAttachments &&
            (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab")))
        {
            tabControl.AddTab(new UITabItem()
            {
                Text        = GetString("general.attachments"),
                RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.DocumentAttachments))
            });

            if (SelectedTab == "attachments")
            {
                mSelectedTabIndex = tabControl.TabItems.Count - 1;
            }
        }
        else if ((CustomOutputFormat == "") && (HasMetaFileObjectInfo) && !HideAttachments &&
                 (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MetafilesTab")))
        {
            // Metafile attachments
            tabControl.AddTab(new UITabItem()
            {
                Text        = GetString("general.attachments"),
                RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.MetaFile))
            });


            if (SelectedTab == "attachments")
            {
                mSelectedTabIndex = tabControl.TabItems.Count - 1;
            }
        }
        else if (SelectedTab == "attachments")
        {
            SelectedTab = "web";
        }

        // Content
        if (!HideContent && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab")))
        {
            tabControl.AddTab(new UITabItem()
            {
                Text        = GetString("general.content"),
                RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.Content))
            });

            if (SelectedTab == "content")
            {
                mSelectedTabIndex = tabControl.TabItems.Count - 1;
            }
        }
        else if (SelectedTab == "content")
        {
            SelectedTab = "web";
        }

        // Media libraries
        if ((CustomOutputFormat == "") && !HideMediaLibraries &&
            (OutputFormat != OutputFormatEnum.NodeGUID) &&
            ModuleManager.IsModuleLoaded(ModuleName.MEDIALIBRARY) &&
            (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MediaLibrariesTab")))
        {
            tabControl.AddTab(new UITabItem()
            {
                Text        = GetString("dialogs.header.libraries"),
                RedirectUrl = GetMediaLibrariesPath()
            });


            if (SelectedTab == "libraries")
            {
                mSelectedTabIndex = tabControl.TabItems.Count - 1;
            }
        }
        else if (SelectedTab == "libraries")
        {
            SelectedTab = "web";
        }

        // Web
        if ((CustomOutputFormat == "") && !HideWeb && (OutputFormat != OutputFormatEnum.NodeGUID) &&
            (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "WebTab")))
        {
            tabControl.AddTab(new UITabItem()
            {
                Text        = GetString("dialogs.header.web"),
                RedirectUrl = (OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink) ? GetFilePath("Tabs_WebLink.aspx") : GetFilePath("Tabs_Web.aspx")
            });

            if (SelectedTab == "web")
            {
                mSelectedTabIndex = tabControl.TabItems.Count - 1;
            }
        }

        // Anchor & E-mail
        if ((CustomOutputFormat == "") && ((OutputFormat == OutputFormatEnum.BBLink) ||
                                           (OutputFormat == OutputFormatEnum.HTMLLink) ||
                                           (OutputFormat == OutputFormatEnum.Custom)))
        {
            // Anchor
            if (!HideAnchor && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AnchorTab")))
            {
                tabControl.AddTab(new UITabItem()
                {
                    Text        = GetString("dialogs.header.anchor"),
                    RedirectUrl = GetFilePath("Tabs_Anchor.aspx")
                });

                if (SelectedTab == "anchor")
                {
                    mSelectedTabIndex = tabControl.TabItems.Count - 1;
                }
            }
            else if (SelectedTab == "anchor")
            {
                SelectedTab = "web";
            }

            // E-mail
            if (!HideEmail && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "EmailTab")))
            {
                tabControl.AddTab(new UITabItem()
                {
                    Text        = GetString("general.email"),
                    RedirectUrl = GetFilePath("Tabs_Email.aspx")
                });

                if (SelectedTab == "email")
                {
                    mSelectedTabIndex = tabControl.TabItems.Count - 1;
                }
            }
            else if (SelectedTab == "email")
            {
                SelectedTab = "web";
            }
        }

        string selectedUrl = ((mSelectedTabIndex > 0) ? tabControl.TabItems[mSelectedTabIndex].RedirectUrl : ((tabControl.TabItems.Count > 0) ? tabControl.TabItems[0].RedirectUrl : String.Empty));

        if (!String.IsNullOrEmpty(selectedUrl))
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + selectedUrl.Replace("&amp;", "&").Replace("'", "%27") + "';} "));
        }

        // No tab is displayed -> load UI Not available
        if (tabControl.TabItems.Count == 0)
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetInformationUrl("uiprofile.uinotavailable")) + "';} "));
        }
        else if (tabControl.TabItems.Count == 1)
        {
            tabControl.Visible = false;

            // Hide empty space because of hidden tab control
            ScriptHelper.RegisterStartupScript(this, typeof(string), "headerFrameHide", ScriptHelper.GetScript("parent.$cmsj('#rowsFrameset').attr('rows','" + CMSPage.TitleOnlyHeight + ", *, " + CMSPage.FooterFrameHeight + "')"));
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Validate query string
        if (!QueryHelper.ValidateHash("hash"))
        {
            // Do nothing
        }
        else
        {
            String identifier = QueryHelper.GetString("identifier", null);
            if (String.IsNullOrEmpty(identifier))
            {
                return;
            }

            properties = WindowHelper.GetItem(identifier) as Hashtable;
            if (properties == null)
            {
                return;
            }

            // Get information on current source type
            string sourceType = ValidationHelper.GetString(GetProp("source"), "attachments");
            SourceType = CMSDialogHelper.GetMediaSource(sourceType);

            // Ensure additional styles
            CurrentMaster.HeadElements.Visible = true;
            CurrentMaster.HeadElements.Text   += CssHelper.GetStyle("*{direction:ltr !important;}body{background:transparent !important;}input,input:focus,input:hover,input:active{border:none;border-color:transparent;outline:none;}");

            // Get uploader control based on the current source type
            string uploaderPath = "";
            if (SourceType == MediaSourceEnum.MediaLibraries)
            {
                // If media library module is running
                if (ModuleManager.IsModuleLoaded(ModuleName.MEDIALIBRARY))
                {
                    uploaderPath = "~/CMSModules/MediaLibrary/Controls/Dialogs/DirectFileUploader/DirectMediaFileUploaderControl.ascx";
                }
            }
            else
            {
                uploaderPath = "~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploaderControl.ascx";
            }

            // Load direct file uploader
            if (uploaderPath != "")
            {
                DirectFileUploader fileUploaderElem = this.LoadUserControl(uploaderPath) as DirectFileUploader;
                if (fileUploaderElem != null)
                {
                    // Insert uploader to parent container
                    pnlUploaderElem.Controls.Add(fileUploaderElem);

                    // Initialize uploader control properties by query string values
                    fileUploaderElem.AttachmentGUID           = ValidationHelper.GetGuid(GetProp("attachmentguid"), Guid.Empty);
                    fileUploaderElem.AttachmentGroupGUID      = ValidationHelper.GetGuid(GetProp("attachmentgroupguid"), Guid.Empty);
                    fileUploaderElem.AttachmentGUIDColumnName = ValidationHelper.GetString(GetProp("attachmentguidcolumnname"), null);
                    fileUploaderElem.FormGUID         = ValidationHelper.GetGuid(GetProp("formguid"), Guid.Empty);
                    fileUploaderElem.DocumentID       = ValidationHelper.GetInteger(GetProp("documentid"), 0);
                    fileUploaderElem.NodeParentNodeID = ValidationHelper.GetInteger(GetProp("parentid"), 0);
                    fileUploaderElem.NodeClassName    = ValidationHelper.GetString(GetProp("classname"), "");
                    fileUploaderElem.InsertMode       = ValidationHelper.GetBoolean(GetProp("insertmode"), false);
                    fileUploaderElem.OnlyImages       = ValidationHelper.GetBoolean(GetProp("onlyimages"), false);
                    fileUploaderElem.ParentElemID     = QueryHelper.GetString("parentelemid", String.Empty);
                    fileUploaderElem.CheckPermissions = ValidationHelper.GetBoolean(GetProp("checkperm"), true);
                    fileUploaderElem.IsLiveSite       = false;
                    fileUploaderElem.RaiseOnClick     = ValidationHelper.GetBoolean(GetProp("click"), false);
                    fileUploaderElem.NodeSiteName     = ValidationHelper.GetString(GetProp("sitename"), null);
                    fileUploaderElem.SourceType       = SourceType;

                    // Metafile upload
                    fileUploaderElem.SiteID     = ValidationHelper.GetInteger(GetProp("siteid"), 0);
                    fileUploaderElem.Category   = ValidationHelper.GetString(GetProp("category"), String.Empty);
                    fileUploaderElem.ObjectID   = ValidationHelper.GetInteger(GetProp("objectid"), 0);
                    fileUploaderElem.ObjectType = ValidationHelper.GetString(GetProp("objecttype"), String.Empty);
                    fileUploaderElem.MetaFileID = ValidationHelper.GetInteger(GetProp("metafileid"), 0);

                    // Library info initialization;
                    fileUploaderElem.LibraryID          = ValidationHelper.GetInteger(GetProp("libraryid"), 0);
                    fileUploaderElem.MediaFileID        = ValidationHelper.GetInteger(GetProp("mediafileid"), 0);
                    fileUploaderElem.MediaFileName      = ValidationHelper.GetString(GetProp("filename"), null);
                    fileUploaderElem.IsMediaThumbnail   = ValidationHelper.GetBoolean(GetProp("ismediathumbnail"), false);
                    fileUploaderElem.LibraryFolderPath  = ValidationHelper.GetString(GetProp("path"), "");
                    fileUploaderElem.IncludeNewItemInfo = ValidationHelper.GetBoolean(GetProp("includeinfo"), false);

                    string siteName = SiteContext.CurrentSiteName;
                    string allowed  = ValidationHelper.GetString(GetProp("allowedextensions"), null);
                    if (allowed == null)
                    {
                        if (fileUploaderElem.SourceType == MediaSourceEnum.MediaLibraries)
                        {
                            allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSMediaFileAllowedExtensions");
                        }
                        else
                        {
                            allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSUploadExtensions");
                        }
                    }
                    fileUploaderElem.AllowedExtensions = allowed;

                    // Auto resize width
                    int autoResizeWidth = ValidationHelper.GetInteger(GetProp("autoresize_width"), -1);
                    if (autoResizeWidth == -1)
                    {
                        autoResizeWidth = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageWidth");
                    }
                    fileUploaderElem.ResizeToWidth = autoResizeWidth;

                    // Auto resize height
                    int autoResizeHeight = ValidationHelper.GetInteger(GetProp("autoresize_height"), -1);
                    if (autoResizeHeight == -1)
                    {
                        autoResizeHeight = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageHeight");
                    }
                    fileUploaderElem.ResizeToHeight = autoResizeHeight;

                    // Auto resize max side size
                    int autoResizeMaxSideSize = ValidationHelper.GetInteger(GetProp("autoresize_maxsidesize"), -1);
                    if (autoResizeMaxSideSize == -1)
                    {
                        autoResizeMaxSideSize = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageMaxSideSize");
                    }
                    fileUploaderElem.ResizeToMaxSideSize = autoResizeMaxSideSize;

                    fileUploaderElem.AfterSaveJavascript = ValidationHelper.GetString(GetProp("aftersave"), String.Empty);
                    fileUploaderElem.TargetFolderPath    = ValidationHelper.GetString(GetProp("targetfolder"), String.Empty);
                    fileUploaderElem.TargetFileName      = ValidationHelper.GetString(GetProp("targetfilename"), String.Empty);
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// Setups controls.
    /// </summary>
    private void SetupControls()
    {
        if (FileSystemMode)
        {
            // New file button
            if (!String.IsNullOrEmpty(NewTextFileExtension))
            {
                plcNewFile.Visible = true;

                string query = "?identifier=" + Identifier;

                // New folder button
                WindowHelper.Remove(Identifier);

                Hashtable properties = new Hashtable();
                properties.Add("targetpath", TargetFolderPath);
                properties.Add("newfileextension", NewTextFileExtension);
                WindowHelper.Add(Identifier, properties);

                var url = UrlResolver.ResolveUrl("~/CMSModules/Content/Controls/Dialogs/Selectors/FileSystemSelector/EditTextFile.aspx") + query;
                url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url, false));

                btnNew.ToolTip       = GetString("dialogs.actions.newfile.desc");
                btnNew.OnClientClick = String.Format("modalDialog('{0}', 'NewFile', 905, 688, null, true); return false;", url);
                btnNew.Text          = GetString("general.create");
            }
            else
            {
                plcNewFile.Visible = false;
            }

            // Initialize file uploader
            fileUploader.SourceType          = MediaSourceEnum.PhysicalFile;
            fileUploader.TargetFolderPath    = TargetFolderPath;
            fileUploader.AllowedExtensions   = AllowedExtensions;
            fileUploader.AfterSaveJavascript = "FSS_FilesUploaded";
        }
        else
        {
            // If attachments are being displayed and no document or form is specified - hide uploader
            if (!IsCopyMoveLinkDialog && (((SourceType != MediaSourceEnum.DocumentAttachments) && (SourceType != MediaSourceEnum.MetaFile)) ||
                                          ((SourceType == MediaSourceEnum.DocumentAttachments) && (Config.AttachmentDocumentID > 0 || Config.AttachmentFormGUID != Guid.Empty)) ||
                                          ((SourceType == MediaSourceEnum.MetaFile) && ((MetaFileObjectID > 0) && !string.IsNullOrEmpty(MetaFileObjectType) && !string.IsNullOrEmpty(MetaFileCategory)))))
            {
                // Initialize file uploader
                if (SourceType == MediaSourceEnum.MetaFile)
                {
                    fileUploader.ObjectID   = MetaFileObjectID;
                    fileUploader.ObjectType = MetaFileObjectType;
                    fileUploader.Category   = MetaFileCategory;

                    BaseInfo info = BaseAbstractInfoProvider.GetInfoById(MetaFileObjectType, MetaFileObjectID);

                    fileUploader.SiteID = info != null ? info.Generalized.ObjectSiteID : SiteContext.CurrentSiteID;
                }
                else
                {
                    fileUploader.DocumentID          = DocumentID;
                    fileUploader.FormGUID            = FormGUID;
                    fileUploader.NodeParentNodeID    = ((NodeID > 0) ? NodeID : ParentNodeID);
                    fileUploader.NodeClassName       = SystemDocumentTypes.File;
                    fileUploader.LibraryID           = LibraryID;
                    fileUploader.LibraryFolderPath   = LibraryFolderPath;
                    fileUploader.ResizeToHeight      = ResizeToHeight;
                    fileUploader.ResizeToMaxSideSize = ResizeToMaxSideSize;
                    fileUploader.ResizeToWidth       = ResizeToWidth;
                    fileUploader.CheckPermissions    = true;
                }
                fileUploader.ParentElemID = CMSDialogHelper.GetMediaSource(SourceType);
                fileUploader.SourceType   = SourceType;
            }
            else
            {
                plcDirectFileUploader.Visible = false;
                fileUploader.StopProcessing   = true;
            }
        }

        // Initialize disabled button
        fileUploader.IsLiveSite = IsLiveSite;
        fileUploader.Text       = GetString("general.upload");
        fileUploader.UploadMode = MultifileUploaderModeEnum.DirectMultiple;

        const string disableMenuItem =
            @"function DisableNewFileBtn() {                                      
    $cmsj('#dialogsUploaderDiv').attr('style', 'display:none;');                                 
    $cmsj('#dialogsUploaderDisabledDiv').removeAttr('style');
}
";

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "disableMenuItem", ScriptHelper.GetScript(disableMenuItem));

        if (!FileSystemActionsEnabled)
        {
            // Disable file action
            ScriptHelper.RegisterStartupScript(Page, typeof(string), "disableNewFile", ScriptHelper.GetScript("DisableNewFileBtn();"));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string          source = QueryHelper.GetString("source", "");
        MediaSourceEnum src    = CMSDialogHelper.GetMediaSource(source);

        if (src == MediaSourceEnum.Content)
        {
            // Check site availability
            if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Content", SiteContext.CurrentSiteName))
            {
                RedirectToResourceNotAvailableOnSite("CMS.Content");
            }
        }

        // Check UIProfile
        string output  = QueryHelper.GetString("output", "");
        bool   checkUI = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CKEditor:PersonalizeToolbarOnLiveSite"], false);

        if ((output == "copy") || (output == "move") || (output == "link") || (output == "linkdoc") || (output == "relationship") || (output == "selectpath"))
        {
            checkUI = false;
        }

        if (checkUI)
        {
            string errorMessage = "";

            OutputFormatEnum outputFormat = CMSDialogHelper.GetOutputFormat(output, QueryHelper.GetBoolean("link", false));
            if ((outputFormat == OutputFormatEnum.HTMLLink) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink"))
            {
                errorMessage = "InsertLink";
            }
            else if ((outputFormat == OutputFormatEnum.HTMLMedia) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia"))
            {
                errorMessage = "InsertImageOrMedia";
            }

            if (errorMessage != "")
            {
                RedirectToUIElementAccessDenied("CMS.WYSIWYGEditor", errorMessage);
                return;
            }

            switch (src)
            {
            case MediaSourceEnum.DocumentAttachments:
            case MediaSourceEnum.Attachment:
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab"))
                {
                    errorMessage = "AttachmentsTab";
                }
                break;

            case MediaSourceEnum.Content:
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab"))
                {
                    errorMessage = "ContentTab";
                }
                break;
            }
            if (errorMessage != "")
            {
                RedirectToUIElementAccessDenied("CMS.MediaDialog", errorMessage);
                return;
            }
        }

        if (QueryHelper.ValidateHash("hash"))
        {
            ScriptHelper.RegisterJQuery(Page);
            CMSDialogHelper.RegisterDialogHelper(Page);
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "InitResizers", ScriptHelper.GetScript("InitResizers();"));

            linkMedia.InitFromQueryString();
        }
        else
        {
            linkMedia.StopProcessing = true;
            linkMedia.Visible        = false;
            string url = ResolveUrl(UIHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true));
            ltlScript.Text = ScriptHelper.GetScript("if (window.parent != null) { window.parent.location = '" + url + "' }");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string          source = QueryHelper.GetString("source", "");
        MediaSourceEnum src    = CMSDialogHelper.GetMediaSource(source);

        if (src == MediaSourceEnum.Content)
        {
            // Check site availability
            if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Content", SiteContext.CurrentSiteName))
            {
                RedirectToResourceNotAvailableOnSite("CMS.Content");
            }
        }

        // Check UIProfile
        string output  = QueryHelper.GetString("output", "");
        bool   checkUI = (output != "copy") && (output != "move") && (output != "link") && (output != "linkdoc") && (output != "relationship") && (output != "selectpath");

        if (checkUI)
        {
            string errorMessage = "";

            OutputFormatEnum outputFormat = CMSDialogHelper.GetOutputFormat(output, QueryHelper.GetBoolean("link", false));
            if ((outputFormat == OutputFormatEnum.HTMLLink) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink"))
            {
                errorMessage = "InsertLink";
            }
            else if ((outputFormat == OutputFormatEnum.HTMLMedia) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia"))
            {
                errorMessage = "InsertImageOrMedia";
            }

            if (errorMessage != "")
            {
                RedirectToUIElementAccessDenied("CMS.WYSIWYGEditor", errorMessage);
                return;
            }

            switch (src)
            {
            case MediaSourceEnum.DocumentAttachments:
            case MediaSourceEnum.Attachment:
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab"))
                {
                    errorMessage = "AttachmentsTab";
                }
                break;

            case MediaSourceEnum.Content:
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab"))
                {
                    errorMessage = "ContentTab";
                }
                break;

            case MediaSourceEnum.MetaFile:
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MetafilesTab"))
                {
                    errorMessage = "MetafilesTab";
                }
                break;
            }
            if (errorMessage != "")
            {
                RedirectToUIElementAccessDenied("CMS.MediaDialog", errorMessage);
                return;
            }
        }

        // CKEditor's plugin filebrowser add custom params to url.
        // This ensures that custom params aren't validated
        if (QueryHelper.ValidateHash("hash", "CKEditor;CKEditorFuncNum;langCode", validateWithoutExcludedParameters: true))
        {
            CMSDialogHelper.RegisterDialogHelper(Page);
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "InitResizers", ScriptHelper.GetScript("InitResizers();"));

            linkMedia.InitFromQueryString();
        }
        else
        {
            linkMedia.StopProcessing = true;
            linkMedia.Visible        = false;
            string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true));
            ltlScript.Text = ScriptHelper.GetScript("if (window.parent != null) { window.parent.location = '" + url + "' }");
        }
    }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = GetString("attach.uploadfile");
        CurrentMaster.Title.TitleText  = Page.Title;
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        // Validate query string
        if (!QueryHelper.ValidateHash("hash"))
        {
            // Do nothing
        }
        else
        {
            // Get information on current source type
            string sourceType = QueryHelper.GetString("source", "attachments");
            SourceType = CMSDialogHelper.GetMediaSource(sourceType);

            // Get uploader control based on the current source type
            string uploaderPath = "";
            if (SourceType == MediaSourceEnum.MediaLibraries)
            {
                // If media library module is running
                if (ModuleEntry.IsModuleRegistered(ModuleEntry.MEDIALIBRARY) && ModuleEntry.IsModuleLoaded(ModuleEntry.MEDIALIBRARY))
                {
                    uploaderPath = "~/CMSModules/MediaLibrary/Controls/Dialogs/DirectFileUploader/FileUpload.ascx";
                }
            }
            else
            {
                uploaderPath = "~/CMSModules/Content/Controls/Attachments/FileUpload.ascx";
            }

            // Load direct file uploader
            if (uploaderPath != "")
            {
                FileUpload fileUploaderElem = LoadControl(uploaderPath) as FileUpload;
                if (fileUploaderElem != null)
                {
                    // Initialize uploader control properties by query string values
                    fileUploaderElem.ID                       = "uploader";
                    fileUploaderElem.ImageWidth               = QueryHelper.GetInteger("imagewidth", 24);
                    fileUploaderElem.ImageHeight              = QueryHelper.GetInteger("imageheight", 24);
                    fileUploaderElem.ImageUrl                 = QueryHelper.GetString("imageurl", GetImageUrl("Design/Controls/DirectUploader/upload.png"));
                    fileUploaderElem.ImageUrlOver             = QueryHelper.GetString("imageurlover", String.Empty);
                    fileUploaderElem.InnerDivHtml             = QueryHelper.GetString("innerdivhtml", String.Empty);
                    fileUploaderElem.InnerDivClass            = QueryHelper.GetString("innerdivclass", String.Empty);
                    fileUploaderElem.InnerLoadingDivHtml      = QueryHelper.GetString("innerloadingdivhtml", String.Empty);
                    fileUploaderElem.InnerLoadingDivClass     = QueryHelper.GetString("innerloadingdivclass", String.Empty);
                    fileUploaderElem.LoadingImageUrl          = QueryHelper.GetString("loadingimageurl", GetImageUrl("Design/Preloaders/preload16.gif"));
                    fileUploaderElem.AttachmentGUID           = QueryHelper.GetGuid("attachmentguid", Guid.Empty);
                    fileUploaderElem.AttachmentGroupGUID      = QueryHelper.GetGuid("attachmentgroupguid", Guid.Empty);
                    fileUploaderElem.AttachmentGUIDColumnName = QueryHelper.GetString("attachmentguidcolumnname", null);
                    fileUploaderElem.FormGUID                 = QueryHelper.GetGuid("formguid", Guid.Empty);
                    fileUploaderElem.DocumentID               = QueryHelper.GetInteger("documentid", 0);
                    fileUploaderElem.NodeParentNodeID         = QueryHelper.GetInteger("parentid", 0);
                    fileUploaderElem.NodeClassName            = QueryHelper.GetString("classname", "");
                    fileUploaderElem.InsertMode               = QueryHelper.GetBoolean("insertmode", false);
                    fileUploaderElem.OnlyImages               = QueryHelper.GetBoolean("onlyimages", false);
                    fileUploaderElem.ParentElemID             = QueryHelper.GetString("parentelemid", String.Empty);
                    fileUploaderElem.CheckPermissions         = QueryHelper.GetBoolean("checkperm", true);
                    fileUploaderElem.IsLiveSite               = QueryHelper.GetBoolean("islive", true);
                    fileUploaderElem.SourceType               = SourceType;

                    // Library info initialization
                    fileUploaderElem.LibraryID          = QueryHelper.GetInteger("libraryid", 0);
                    fileUploaderElem.LibraryFolderPath  = QueryHelper.GetString("path", "");
                    fileUploaderElem.IncludeNewItemInfo = QueryHelper.GetBoolean("includeinfo", false);

                    string siteName = CMSContext.CurrentSiteName;
                    string allowed  = QueryHelper.GetString("allowedextensions", "");
                    if (allowed == "")
                    {
                        if (fileUploaderElem.SourceType == MediaSourceEnum.MediaLibraries)
                        {
                            allowed = SettingsKeyProvider.GetStringValue(siteName + ".CMSMediaFileAllowedExtensions");
                        }
                        else
                        {
                            allowed = SettingsKeyProvider.GetStringValue(siteName + ".CMSUploadExtensions");
                        }
                    }
                    fileUploaderElem.AllowedExtensions   = allowed;
                    fileUploaderElem.ResizeToWidth       = QueryHelper.GetInteger("autoresize_width", 0);
                    fileUploaderElem.ResizeToHeight      = QueryHelper.GetInteger("autoresize_height", 0);
                    fileUploaderElem.ResizeToMaxSideSize = QueryHelper.GetInteger("autoresize_maxsidesize", 0);

                    fileUploaderElem.AfterSaveJavascript = QueryHelper.GetString("aftersave", String.Empty);

                    // Insert uploader to parent container
                    pnlUploaderElem.Controls.Add(fileUploaderElem);
                }
            }
        }
    }
    /// <summary>
    /// Returns collection of tabs which should be displayed to the user.
    /// </summary>
    private string[,] GetTabs()
    {
        int currIndex = 0;

        string[,] result = new string[6, 8];

        bool checkUI = true;

        // Disable personalization for none-HTML editors
        if ((CustomOutputFormat == "copy") || (CustomOutputFormat == "move") || (CustomOutputFormat == "link") ||
            (CustomOutputFormat == "relationship") || (CustomOutputFormat == "selectpath"))
        {
            checkUI = false;
        }
        else if (IsLiveSite)
        {
            // Ensure personalization of the HTML editor on the live site
            checkUI = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CKEditor:PersonalizeToolbarOnLiveSite"], false);
        }

        if (checkUI)
        {
            if ((OutputFormat == OutputFormatEnum.HTMLMedia) && !CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia"))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertImageOrMedia")) + "';} "));
                return(result);
            }
            if ((OutputFormat == OutputFormatEnum.HTMLLink) && !CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink"))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertLink")) + "';} "));
                return(result);
            }
            if ((CustomOutputFormat == "linkdoc") && !(CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "New.LinkExistingDocument") && CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "New")))
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetAccessDeniedUrl("CMS.Content", null, "New.LinkExistingDocument")) + "';} "));
                return(result);
            }
        }

        // Attachments
        if ((CustomOutputFormat == "") && (!HasMetaFileObjectInfo) && !HideAttachments &&
            (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab")))
        {
            result[currIndex, 0] = GetString("general.attachments");
            result[currIndex, 2] = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.DocumentAttachments));

            if (SelectedTab == "attachments")
            {
                mSelectedTabIndex = currIndex;
            }
            currIndex++;
        }
        else if ((CustomOutputFormat == "") && (HasMetaFileObjectInfo) && !HideAttachments &&
                 (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MetafilesTab")))
        {
            // Metafile attachments
            result[currIndex, 0] = GetString("general.attachments");
            result[currIndex, 2] = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.MetaFile));

            if (SelectedTab == "attachments")
            {
                mSelectedTabIndex = currIndex;
            }
            currIndex++;
        }
        else if (SelectedTab == "attachments")
        {
            SelectedTab = "web";
        }

        // Content
        if (!HideContent && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab")))
        {
            result[currIndex, 0] = GetString("general.content");
            result[currIndex, 2] = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.Content));

            if (SelectedTab == "content")
            {
                mSelectedTabIndex = currIndex;
            }
            currIndex++;
        }
        else if (SelectedTab == "content")
        {
            SelectedTab = "web";
        }

        // Media libraries
        if ((CustomOutputFormat == "") && !HideMediaLibraries &&
            (OutputFormat != OutputFormatEnum.NodeGUID) &&
            ModuleEntry.IsModuleLoaded(ModuleEntry.MEDIALIBRARY) &&
            (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MediaLibrariesTab")))
        {
            result[currIndex, 0] = GetString("dialogs.header.libraries");
            result[currIndex, 2] = GetMediaLibrariesPath();

            if (SelectedTab == "libraries")
            {
                mSelectedTabIndex = currIndex;
            }
            currIndex++;
        }
        else if (SelectedTab == "libraries")
        {
            SelectedTab = "web";
        }

        // Web
        if ((CustomOutputFormat == "") && !HideWeb && (OutputFormat != OutputFormatEnum.NodeGUID) &&
            (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "WebTab")))
        {
            result[currIndex, 0] = GetString("dialogs.header.web");
            if ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink))
            {
                result[currIndex, 2] = GetFilePath("Tabs_WebLink.aspx");
            }
            else
            {
                result[currIndex, 2] = GetFilePath("Tabs_Web.aspx");
            }

            if (SelectedTab == "web")
            {
                mSelectedTabIndex = currIndex;
            }
            currIndex++;
        }

        // Anchor & E-mail
        if ((CustomOutputFormat == "") && ((OutputFormat == OutputFormatEnum.BBLink) ||
                                           (OutputFormat == OutputFormatEnum.HTMLLink) ||
                                           (OutputFormat == OutputFormatEnum.Custom)))
        {
            // Anchor
            if (!HideAnchor && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AnchorTab")))
            {
                result[currIndex, 0] = GetString("dialogs.header.anchor");
                result[currIndex, 2] = GetFilePath("Tabs_Anchor.aspx");

                if (SelectedTab == "anchor")
                {
                    mSelectedTabIndex = currIndex;
                }
                currIndex++;
            }
            else if (SelectedTab == "anchor")
            {
                SelectedTab = "web";
            }

            // E-mail
            if (!HideEmail && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "EmailTab")))
            {
                result[currIndex, 0] = GetString("general.email");
                result[currIndex, 2] = GetFilePath("Tabs_Email.aspx");

                if (SelectedTab == "email")
                {
                    mSelectedTabIndex = currIndex;
                }
                currIndex++;
            }
            else if (SelectedTab == "email")
            {
                SelectedTab = "web";
            }
        }

        string selectedUrl = mSelectedTabIndex > 0 ? result[mSelectedTabIndex, 2] : result[0, 2];

        if (selectedUrl != null)
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + selectedUrl.Replace("&amp;", "&").Replace("'", "%27") + "';} "));
        }

        // No tab is displayed -> load UI Not available
        if (currIndex == 0)
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + URLHelper.ResolveUrl(UIHelper.GetInformationUrl("uiprofile.uinotavailable")) + "';} "));
        }

        return(result);
    }
Beispiel #8
0
    /// <summary>
    /// Initializes menu with view mode selection.
    /// </summary>
    private void InitializeActionsMenu()
    {
        if ((SourceType != MediaSourceEnum.DocumentAttachments) && (SourceType != MediaSourceEnum.MetaFile))
        {
            string selectors = (IsLiveSite ? "LiveSelectors" : "Selectors");

            // Get new folder dialog URL
            if (SourceType == MediaSourceEnum.MediaLibraries)
            {
                WindowHelper.Remove(Identifier);

                Hashtable properties = new Hashtable();
                properties.Add("libraryid", LibraryID);
                properties.Add("path", LibraryFolderPath);
                properties.Add("cancel", false);

                WindowHelper.Add(Identifier, properties);

                if (IsLiveSite)
                {
                    if (CMSContext.CurrentUser.IsAuthenticated())
                    {
                        NewFolderDialogUrl = "~/CMS/Dialogs/CMSModules/MediaLibrary/FormControls/LiveSelectors/InsertImageOrMedia/NewMediaFolder.aspx?identifier=" + Identifier;
                    }
                    else
                    {
                        NewFolderDialogUrl = "~/CMSModules/MediaLibrary/FormControls/LiveSelectors/InsertImageOrMedia/NewMediaFolder.aspx?identifier=" + Identifier;
                    }
                }
                else
                {
                    NewFolderDialogUrl = "~/CMSModules/MediaLibrary/FormControls/Selectors/InsertImageOrMedia/NewMediaFolder.aspx?identifier=" + Identifier;
                }
            }
            else
            {
                NewFolderDialogUrl = "~/CMSFormControls/" + selectors + "/InsertImageOrMedia/NewCMSFolder.aspx?nodeid=" + NodeID + "&culture=" + Config.Culture;
            }
            // Add security hash
            NewFolderDialogUrl = URLHelper.AddParameterToUrl(NewFolderDialogUrl, "hash", QueryHelper.GetHash(NewFolderDialogUrl, false));

            menuBtnNewFolder.Tooltip           = GetString("dialogs.actions.newfolder.desc");
            menuBtnNewFolder.OnClickJavascript = "modalDialog('" + URLHelper.ResolveUrl(NewFolderDialogUrl) + "', 'NewFolder', 500, 350, null, true); return false;";
            menuBtnNewFolder.Text = "<div style=\"overflow:hidden; width:66px; white-space:nowrap\">" + GetString("dialogs.actions.newfolder") + "</div>";
        }
        else
        {
            // Hide New folder button for attachments
            menuBtnNewFolder.Visible = false;
            plcActionsMenu.Visible   = false;
            pnlLeft.CssClass        += " Smaller ";
        }

        // Initialize disabled button
        imgUploaderDisabled.EnableViewState = false;
        imgUploaderDisabled.Alt             = GetString("dialogs.actions.newfile");

        // If attachments are being displayed and no document or form is specified - hide uploader
        if (!IsCopyMoveLinkDialog && (((SourceType != MediaSourceEnum.DocumentAttachments) && (SourceType != MediaSourceEnum.MetaFile)) ||
                                      ((SourceType == MediaSourceEnum.DocumentAttachments) && (Config.AttachmentDocumentID > 0 || Config.AttachmentFormGUID != Guid.Empty)) ||
                                      ((SourceType == MediaSourceEnum.MetaFile) && ((MetaFileObjectID > 0) && !string.IsNullOrEmpty(MetaFileObjectType) && !string.IsNullOrEmpty(MetaFileCategory)))))
        {
            // Initialize file uploader
            if (SourceType == MediaSourceEnum.MetaFile)
            {
                fileUploader.ObjectID   = MetaFileObjectID;
                fileUploader.ObjectType = MetaFileObjectType;
                fileUploader.Category   = MetaFileCategory;

                BaseInfo info = BaseAbstractInfoProvider.GetInfoById(MetaFileObjectType, MetaFileObjectID);

                fileUploader.SiteID = info != null ? info.Generalized.ObjectSiteID : CMSContext.CurrentSiteID;
            }
            else
            {
                fileUploader.DocumentID          = DocumentID;
                fileUploader.FormGUID            = FormGUID;
                fileUploader.NodeParentNodeID    = ((NodeID > 0) ? NodeID : ParentNodeID);
                fileUploader.NodeClassName       = URLHelper.EncodeQueryString("CMS.File");
                fileUploader.LibraryID           = LibraryID;
                fileUploader.LibraryFolderPath   = LibraryFolderPath;
                fileUploader.ResizeToHeight      = ResizeToHeight;
                fileUploader.ResizeToMaxSideSize = ResizeToMaxSideSize;
                fileUploader.ResizeToWidth       = ResizeToWidth;
                fileUploader.CheckPermissions    = true;
            }
            fileUploader.ParentElemID        = CMSDialogHelper.GetMediaSource(SourceType);
            fileUploader.SourceType          = SourceType;
            fileUploader.IsLiveSite          = IsLiveSite;
            fileUploader.InnerDivClass       = "DialogMenuInnerDiv";
            fileUploader.InnerDivHtml        = String.Format("<span>{0}</span>", GetString("dialogs.actions.newfile"));
            fileUploader.LoadingImageUrl     = GetImageUrl("Design/Preloaders/preload16.gif");
            fileUploader.InnerLoadingDivHtml = "&nbsp;";
            fileUploader.UploadMode          = MultifileUploaderModeEnum.DirectMultiple;
        }
        else
        {
            plcDirectFileUploader.Visible = false;
            fileUploader.StopProcessing   = true;
        }
    }