Ejemplo n.º 1
0
        /// <summary>
        /// Gets the editor.
        /// </summary>
        /// <param name="placeHolderHtmlEditor">
        /// The place holder HTML editor.
        /// </param>
        /// <param name="moduleId">
        /// The module ID.
        /// </param>
        /// <param name="showUpload">
        /// The show Upload.
        /// </param>
        /// <param name="PortalSettings">
        /// The portal Settings.
        /// </param>
        /// <returns>
        /// The HTML editor interface.
        /// </returns>
        public IHtmlEditor GetEditor(
            Control placeHolderHtmlEditor, int moduleId, bool showUpload, PortalSettings PortalSettings)
        {
            IHtmlEditor desktopText;
            var         moduleImageFolder = ModuleSettings.GetModuleSettings(moduleId)["MODULE_IMAGE_FOLDER"].ToString();

            // Grabs ID from the place holder so that a unique editor is on the page if more than one
            // But keeps same ID so that the information can be submitted to be saved. [CDT]
            var uniqueId = placeHolderHtmlEditor.ID;

            switch (this.Value)
            {
            case "TinyMCE Editor":
                var tinyMce = new TinyMCETextBox {
                    ImageFolder = moduleImageFolder
                };
                desktopText = tinyMce;
                break;

            case "FCKeditor":     // 9/8/2010
                var conector = Path.ApplicationRootPath("/app_support/FCKconnectorV2.aspx");
                var fckv2    = new FCKTextBoxV2
                {
                    ImageFolder        = moduleImageFolder,
                    BasePath           = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/FCKeditorV2.6.6/"),
                    AutoDetectLanguage = false,
                    DefaultLanguage    = PortalSettings.PortalUILanguage.Name.Substring(0, 2),
                    ID = string.Concat("FCKTextBox", uniqueId),
                    ImageBrowserURL =
                        Path.WebPathCombine(
                            Path.ApplicationRoot,
                            string.Format(
                                "aspnet_client/FCKeditorV2.6.6/editor/filemanager/browser/default/browser.html?Type=Image%26Connector={0}",
                                conector)),
                    LinkBrowserURL =
                        Path.WebPathCombine(
                            Path.ApplicationRoot,
                            string.Format(
                                "aspnet_client/FCKeditorV2.6.6/editor/filemanager/browser/default/browser.html?Connector={0}",
                                conector))
                };

                // fckv2.EditorAreaCSS = PortalSettings.GetCurrentTheme().CssFile;
                desktopText = fckv2;
                break;

            case "Syrinx CkEditor":
                CkEditor.CkEditorJS = Path.WebPathCombine(
                    Path.ApplicationRoot, "aspnet_client/ckeditor/ckeditor.js");

                var sckvtb = new SyrinxCkTextBox
                {
                    ImageFolder    = moduleImageFolder,
                    BaseContentUrl = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/ckeditor/"),
                    Resizable      = false,
                    Language       = PortalSettings.PortalUILanguage.TwoLetterISOLanguageName
                };

                desktopText = sckvtb;
                break;

            case "FreeTextBox":
                var freeText = new FreeTextBox
                {
                    ImageGalleryUrl =
                        Path.WebPathCombine(
                            Path.ApplicationFullPath,
                            "app_support/ftb.imagegallery.aspx?rif={0}&cif={0}&mID=" + moduleId),
                    ImageFolder      = moduleImageFolder,
                    ImageGalleryPath = Path.WebPathCombine(PortalSettings.PortalFullPath, moduleImageFolder),
                    ID                    = string.Concat("FreeText", uniqueId),
                    Language              = GetFtbLanguage(PortalSettings.PortalUILanguage.Name),
                    JavaScriptLocation    = ResourceLocation.ExternalFile,
                    ButtonImagesLocation  = ResourceLocation.ExternalFile,
                    ToolbarImagesLocation = ResourceLocation.ExternalFile,
                    SupportFolder         = Path.WebPathCombine(Path.ApplicationFullPath, "aspnet_client/FreeTextBox")
                };

                // freeText.ToolbarLayout =
                // "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorPicker,FontBackColorPicker,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat;CreateLink,Unlink|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;InsertRule|Delete,Cut,Copy,Paste;Undo,Redo,Print;InsertTable,InsertTableColumnAfter,InsertTableColumnBefore,InsertTableRowAfter,InsertTableRowBefore,DeleteTableColumn,DeleteTableRow,InsertImageFromGallery";
                desktopText = freeText;
                break;

            // case "Code Mirror Plain Text":
            default:
                var codeMirrorTextBox = new CodeMirrorTextBox();
                desktopText = codeMirrorTextBox;
                break;
            }

            placeHolderHtmlEditor.Controls.Add((Control)desktopText);
            return(desktopText);
        }
        /// <summary>
        /// Gets the editor.
        /// </summary>
        /// <param name="PlaceHolderHTMLEditor">The place holder HTML editor.</param>
        /// <param name="moduleID">The module ID.</param>
        /// <param name="showUpload">if set to <c>true</c> [show upload].</param>
        /// <param name="portalSettings">The portal settings.</param>
        /// <returns></returns>
        public IHtmlEditor GetEditor(Control PlaceHolderHTMLEditor, int moduleID, bool showUpload,
                                     PortalSettings portalSettings)
        {
            IHtmlEditor DesktopText;
            string      moduleImageFolder = ModuleSettings.GetModuleSettings(moduleID)["MODULE_IMAGE_FOLDER"].ToString();

            // Grabs ID from the place holder so that a unique editor is on the page if more than one
            // But keeps same ID so that the information can be submitted to be saved. [CDT]
            string uniqueID = PlaceHolderHTMLEditor.ID;

            switch (Value)
            {
            case "FCKEditor V2":     // [email protected] 2004/11/09.
                FCKTextBoxV2 fckv2 = new FCKTextBoxV2();
                fckv2.ImageFolder        = moduleImageFolder;
                fckv2.BasePath           = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/FCKEditorV2/");
                fckv2.AutoDetectLanguage = false;
                fckv2.DefaultLanguage    = portalSettings.PortalUILanguage.Name.Substring(0, 2);
//					fckv2.EditorAreaCSS = portalSettings.GetCurrentTheme().CssFile;
                fckv2.ID = string.Concat("FCKTextBox", uniqueID);
                string conector = Path.ApplicationRootPath("/app_support/FCKconnectorV2.aspx");
                fckv2.ImageBrowserURL =
                    Path.WebPathCombine(Path.ApplicationRoot,
                                        "aspnet_client/FCKEditorV2/editor/filemanager/browser.html?Type=Image&Connector=" +
                                        conector);
                fckv2.LinkBrowserURL =
                    Path.WebPathCombine(Path.ApplicationRoot,
                                        "aspnet_client/FCKEditorV2/editor/filemanager/browser.html?Connector=" +
                                        conector);
                DesktopText = ((IHtmlEditor)fckv2);
                break;

            case "FreeTextBox":
                FreeTextBox freeText = new FreeTextBox();
                freeText.ToolbarLayout =
                    "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorPicker,FontBackColorPicker,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat;CreateLink,Unlink|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;InsertRule|Delete,Cut,Copy,Paste;Undo,Redo,Print;InsertTable,InsertTableColumnAfter,InsertTableColumnBefore,InsertTableRowAfter,InsertTableRowBefore,DeleteTableColumn,DeleteTableRow,InsertImageFromGallery";
                freeText.ImageGalleryUrl =
                    Path.WebPathCombine(Path.ApplicationFullPath,
                                        "app_support/ftb.imagegallery.aspx?rif={0}&cif={0}&mID=" +
                                        moduleID.ToString());
                freeText.ImageFolder      = moduleImageFolder;
                freeText.ImageGalleryPath = Path.WebPathCombine(portalSettings.PortalFullPath, freeText.ImageFolder);
                freeText.ID       = string.Concat("FreeText", uniqueID);
                freeText.Language = getFtbLanguage(portalSettings.PortalUILanguage.Name);
                DesktopText       = ((IHtmlEditor)freeText);
                break;

            case "ActiveUp HtmlTextBox":
                HtmlTextBox h = new HtmlTextBox();
                h.ImageFolder = moduleImageFolder;
                DesktopText   = (IHtmlEditor)h;

                // Allow content editors to see the content with the same style that it is displayed in
                h.ContentCssFile = portalSettings.GetCurrentTheme().CssFile;

                // Custom Properties must come after control is added to placeholder
                h.EnsureToolsCreated();

                // Set the icons folder
                h.IconsDir = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/ActiveUp/icons/");

                // Add the Help icon
                StringBuilder sbHelp = new StringBuilder();
                sbHelp.Append("var Help=window.open('");
                sbHelp.Append(Path.ApplicationRoot);
                sbHelp.Append("/aspnet_client/ActiveUp/");
                sbHelp.Append(
                    "htmltextbox_help.html', 'HTML_TextBox_Help', 'height=520, width=520, resizable=yes, scrollbars=yes, menubar=no, toolbar=no, directories=no, location=no, status=no');Help.moveTo('20', '20');");
                Custom openPage = new Custom();
                openPage.IconOff           = "help_off.gif";
                openPage.IconOver          = "help_off.gif";
                openPage.ClientSideOnClick = sbHelp.ToString();
                h.Toolbars[0].Tools.Add(openPage);

                // Add the image library
                Image imageLibrary = (Image)h.Toolbars[0].Tools["Image"];
                imageLibrary.AutoLoad = true;

                // Clear the directories collection because it is stored in ViewState and must be cleared or upload will result in display of multiple directories of the same name
                imageLibrary.Directories.Clear();
                imageLibrary.Directories.Add("images",
                                             HttpContext.Current.Server.MapPath(portalSettings.PortalFullPath +
                                                                                h.ImageFolder),
                                             portalSettings.PortalFullPath + h.ImageFolder + "/");

                if (!showUpload)
                {
                    imageLibrary.UploadDisabled = true;
                }
                break;

            case "Plain Text":
            default:
                DesktopText = (new TextEditor());
                break;
            }
            PlaceHolderHTMLEditor.Controls.Add(((Control)DesktopText));
            return(DesktopText);
        }