Example #1
0
        } // en dof ImageFormat

        /// <summary>
        /// Determine the Url of the named string
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <returns></returns>
        internal static string Url(string name, out int width, out int height)
        {
            string url = string.Empty;
            // Obtain PortalSettings from Current Context
            PortalSettings PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            try
            {
                // current theme
                Theme CurrentTheme = PortalSettings.GetCurrentTheme();

                //TODO: verify default works in all cases
                Image image = CurrentTheme.GetImage(name, "~/Design/Themes/Default/" + name.Substring(8));
                // dimensions
                width  = (int)image.Width.Value;
                height = (int)image.Height.Value;
                // url
                url = image.ImageUrl;
            }
            catch
            {
                width  = 0;
                height = 0;
            }

            return(url);
        } // end of Url
 /// <summary>
 /// Gets the current image from theme.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="bydefault">The bydefault.</param>
 /// <returns>A string value...</returns>
 public string GetCurrentImageFromTheme(string name, string bydefault)
 {
     // Obtain PortalSettings from Current Context
     if (HttpContext.Current != null && HttpContext.Current.Items["PortalSettings"] != null)
     {
         PortalSettings pS = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
         return(pS.GetCurrentTheme().GetImage(name, bydefault).ImageUrl);
     }
     return(bydefault);
 }
        /// <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);
        }