/// <summary>
        /// Gets the magic URL list.
        /// </summary>
        /// <param name="portalID">The portal ID.</param>
        /// <returns></returns>
        private Hashtable GetMagicUrlList(string portalID)
        {
            Hashtable _result = new Hashtable();

            if ( Cache["rainbow_MagicUrlList_" + Portal.UniqueID] == null )
            {
                string myPath = Server.MapPath(Path.WebPathCombine(portalSettings.PortalFullPath, "MagicUrl/MagicUrlList.xml"));
                if ( File.Exists(myPath) )
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(myPath);
                    XmlNodeList xnl = xmlDoc.SelectNodes("/MagicUrlList/MagicUrl");
                    foreach ( XmlNode node in xnl )
                    {
                        try
                        {
                            _result.Add(node.Attributes["key"].Value, HttpUtility.HtmlDecode(node.Attributes["value"].Value));
                        }
                        catch
                        {}
                    }
                    Cache.Insert("rainbow_MagicUrlList_" + Portal.UniqueID, _result, new CacheDependency(myPath));
                }
            }
            else
            {
                _result = (Hashtable) Cache["rainbow_MagicUrlList_" + Portal.UniqueID];
            }

            return _result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the portal path.
        /// </summary>
        /// <param name="portalPath">The portal path.</param>
        public void CreatePortalPath(string portalPath)
        {
            portalPath = portalPath.Replace("/", string.Empty);
            portalPath = portalPath.Replace("\\", string.Empty);
            portalPath = portalPath.Replace(".", string.Empty);

            if (!portalPath.StartsWith("_"))
            {
                portalPath = "_" + portalPath;
            }
            // jes1111
            //			string pd = ConfigurationSettings.AppSettings[strPortalsDirectory];
            //
            //			if(pd!=null)
            //			{
            //			if (portalPath.IndexOf (pd) > -1)
            //				portalPath = portalPath.Substring(portalPath.IndexOf (pd) + pd.Length);
            //			}
            string pd = Config.PortalsDirectory;

            if (portalPath.IndexOf(pd) > -1)
            {
                portalPath = portalPath.Substring(portalPath.IndexOf(pd) + pd.Length);
            }

            // jes1111 - string portalPhisicalDir = HttpContext.Current.Server.MapPath(Path.ApplicationRoot + "/" + ConfigurationSettings.AppSettings[strPortalsDirectory] + "/" + portalPath);
            string portalPhisicalDir =
                HttpContext.Current.Server.MapPath(
                    Path.WebPathCombine(Path.ApplicationRoot, Config.PortalsDirectory, portalPath));

            if (!Directory.Exists(portalPhisicalDir))
            {
                Directory.CreateDirectory(portalPhisicalDir);
            }
            // Subdirs
            string[] subdirs = { "images", "polls", "documents", "xml" };

            for (int i = 0; i <= subdirs.GetUpperBound(0); i++)
            {
                if (!Directory.Exists(portalPhisicalDir + "\\" + subdirs[i]))
                {
                    Directory.CreateDirectory(portalPhisicalDir + "\\" + subdirs[i]);
                }
            }
        }
 /// <summary>
 /// Register the correct css module file searching in this order in current theme/mod,
 /// default theme/mod and in module folder.
 /// </summary>
 /// <param name="folderModuleName">The name of module directory</param>
 /// <param name="file">The Css file</param>
 public void RegisterCssModule(string folderModuleName, string file)
 {
     if (!IsCssFileRegistered(file))
     {
         string cssFile = currentTheme.Module_CssFile(file);
         if (cssFile.Equals(string.Empty))
         {
             cssFile = Path.WebPathCombine(Path.ApplicationRoot, "DesktopModules", folderModuleName, file);
             if (!File.Exists(HttpContext.Current.Server.MapPath(cssFile)))
             {
                 cssFile = string.Empty;
             }
         }
         if (!cssFile.Equals(string.Empty))
         {
             RegisterCssFile(file, cssFile);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the image menu.
        /// </summary>
        /// <returns>A System.Collections.Hashtable value...</returns>
        private Hashtable GetImageMenu()
        {
            Hashtable imageMenuFiles;

            if (!CurrentCache.Exists(Key.ImageMenuList(portalSettings.CurrentLayout)))
            {
                imageMenuFiles = new Hashtable();
                imageMenuFiles.Add("-Default-", string.Empty);
                string        menuDirectory = string.Empty;
                LayoutManager layoutManager = new LayoutManager(PortalPath);

                menuDirectory = Path.WebPathCombine(layoutManager.PortalLayoutPath, portalSettings.CurrentLayout);
                if (Directory.Exists(menuDirectory))
                {
                    menuDirectory = Path.WebPathCombine(menuDirectory, "menuimages");
                }
                else
                {
                    menuDirectory = Path.WebPathCombine(LayoutManager.Path, portalSettings.CurrentLayout, "menuimages");
                }

                if (Directory.Exists(menuDirectory))
                {
                    FileInfo[] menuImages = (new DirectoryInfo(menuDirectory)).GetFiles("*.gif");

                    foreach (FileInfo fi in menuImages)
                    {
                        if (fi.Name != "spacer.gif" && fi.Name != "icon_arrow.gif")
                        {
                            imageMenuFiles.Add(fi.Name, fi.Name);
                        }
                    }
                }
                CurrentCache.Insert(Key.ImageMenuList(portalSettings.CurrentLayout), imageMenuFiles, null);
            }
            else
            {
                imageMenuFiles = (Hashtable)CurrentCache.Get(Key.ImageMenuList(portalSettings.CurrentLayout));
            }
            return(imageMenuFiles);
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            // set current directory so paths are relative to this page location
            Environment.CurrentDirectory = this.Server.MapPath(this.TemplateSourceDirectory);

            // set localized Page Title
            this.PageTitle = General.GetString("TAB_TITLE_RAINBOW_HELP", "Rainbow Help", this);
            // add the Help css
            this.ClearCssFileList();
            this.RegisterCssFile("help", "css/help.css");
            this.RegisterCssFile("menu", "css/mainmenu.css");

            if (!this.IsAdditionalMetaElementRegistered("ie7"))
            {
                string _ie7     = string.Empty;
                string _ie7Part = string.Empty;

                foreach (string _script in Ie7Script.Split(new char[] { ';' }))
                {
                    _ie7Part = Path.WebPathCombine(Path.ApplicationRoot, _script);
                    _ie7Part = string.Format("<!--[if lt IE 7]><script src=\"{0}\" type=\"text/javascript\"></script><![endif]-->", _ie7Part);
                    _ie7    += _ie7Part + "\n";
                }
                this.RegisterAdditionalMetaElement("ie7", _ie7);
            }


            string      loc         = string.Empty;
            string      src         = string.Empty;
            string      xslt        = string.Empty;
            CultureInfo lang        = this.portalSettings.PortalContentLanguage;
            CultureInfo defaultLang = this.portalSettings.PortalContentLanguage;
            //jes1111 - CultureInfo fallbackLang = new CultureInfo(ConfigurationSettings.AppSettings["DefaultLanguage"]);
            CultureInfo  fallbackLang = new CultureInfo(Config.DefaultLanguage);
            XslTransform xt;

            // grab the QueryString
            NameValueCollection qs = Request.QueryString;

            // Read Location
            if (qs["loc"] != null && qs["loc"].Length != 0)
            {
                loc = qs["loc"];
            }
            else
            {
                loc = defaultLocation;
            }

            // Read Source
            if (qs["src"] != null && qs["src"].Length != 0)
            {
                src = qs["src"];
            }
            else
            {
                src = defaultSource;
            }

            // Read Culture
            if (qs["lang"] != null && qs["lang"].Length != 0)
            {
                try{ lang = new CultureInfo(qs["lang"], false); }
                catch {}
            }

            // Read XSLT Stylesheet
            if (qs["xslt"] != null &&
                qs["xslt"].Length != 0 &&
                File.Exists(qs["xslt"])
                )
            {
                xslt = qs["xslt"];
            }
            else
            {
                xslt = defaultXslt;
            }

            // create language sequence
            ArrayList langSequence = new ArrayList(7);

            langSequence.Add(lang);
            if (!lang.Equals(defaultLang))
            {
                langSequence.Add(defaultLang);
            }
            if (!defaultLang.Equals(fallbackLang))
            {
                langSequence.Add(fallbackLang);
            }
            langSequence.Add(new CultureInfo(string.Empty));

            // create file sequence
            ArrayList fileSequence = new ArrayList(2);

            fileSequence.Add(Path.WebPathCombine(loc, src));
            fileSequence.Add(Path.WebPathCombine(defaultLocation, defaultSource));

            string filePath         = string.Empty;
            bool   found            = false;
            bool   asRequested      = true;
            string languageReturned = string.Empty;

            // find a file
            foreach (string _file in fileSequence)
            {
                foreach (CultureInfo _language in langSequence)
                {
                    filePath = string.Concat(_file, ".", _language.Name, sourceExtension);
                    filePath = filePath.Replace("..", ".");
                    if (File.Exists(filePath))
                    {
                        languageReturned = _language.Name;
                        found            = true;
                        break;
                    }
                    if (_language.TwoLetterISOLanguageName.ToLower().Equals("en"))
                    {
                        filePath = string.Concat(_file, sourceExtension);
                    }
                    else
                    {
                        filePath = string.Concat(_file, ".", _language.TwoLetterISOLanguageName, sourceExtension);
                    }
                    filePath = filePath.Replace("..", ".");
                    if (File.Exists(filePath))
                    {
                        languageReturned = _language.TwoLetterISOLanguageName;
                        found            = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
                else
                {
                    asRequested = false;
                }
            }

            // if we found something to display
            if (found)
            {
                // get the Transformer
                string transformerCacheKey = string.Concat(cacheKeyRoot, "_", xslt);
                if (Context.Cache[transformerCacheKey] == null)
                {
                    try
                    {
                        xt   = new XslTransform();
                        xslt = this.Server.MapPath(xslt);
                        XmlUrlResolver xr = new XmlUrlResolver();
                        xt.Load(xslt, xr);
                        Context.Cache.Insert(transformerCacheKey, xt, new CacheDependency(xslt));
                    }
                    catch (Exception ex)
                    {
                        Rainbow.Framework.ErrorHandler.Publish(Rainbow.Framework.LogLevel.Error, "Failed in Help Transformer load - message was: " + ex.Message);
                        throw new Exception("Failed in Help Transformer load - message was: " + ex.Message);
                    }
                }
                else
                {
                    xt = (XslTransform)Context.Cache[transformerCacheKey];
                }

                // create the ArgList
                XsltArgumentList xa = new XsltArgumentList();
                XslHelper        xh = new XslHelper();
                xa.AddExtensionObject("urn:rainbow", xh);
                xa.AddParam("LanguageRequested", string.Empty, lang.Name);
                xa.AddParam("LanguageReturned", string.Empty, languageReturned);
                xa.AddParam("AsRequested", string.Empty, asRequested.ToString());
                //string rootFolder = Rainbow.Framework.Settings.Path.ApplicationRoot + "/rb_documentation/";
                //xa.AddParam("Location",string.Empty,rootFolder + loc);
                xa.AddParam("Location", string.Empty, loc);
                xa.AddParam("Title", string.Empty, this.PageTitle);
                string tocFile = string.Concat(loc.Substring(0, loc.IndexOf("/")), "/map.", languageReturned, sourceExtension);
                tocFile = tocFile.Replace("..", ".");
                tocFile = string.Concat("../", tocFile);
                xa.AddParam("TOCfile", string.Empty, tocFile);
                xa.AddParam("Viewer", string.Empty, this.Request.Url.AbsolutePath);
                xa.AddParam("myRoot", string.Empty, loc.Substring(0, loc.IndexOf("/")));

                // load up the Xml control
                myXml.DocumentSource        = filePath;
                myXml.Transform             = xt;
                myXml.TransformArgumentList = xa;
            }
            else
            {
                using (Localize errorMsg = new Localize())
                {
                    errorMsg.TextKey = "HELP_VIEWER_ERROR";
                    errorMsg.Text    = "Sorry - no help available";
                    using (HtmlGenericControl container = new HtmlGenericControl("div"))
                    {
                        container.Attributes.Add("style", "padding:3em;font-size:1.2em;text-align:center");
                        container.Controls.Add(errorMsg);
                        this.ContentHolder.Controls.Add(container);
                    }
                }
            }
        }
        /// <summary>
        /// The Page_Load event handler on this User Control obtains
        /// an xml document and xsl/t transform file location.
        /// It then sets these properties on an &lt;asp:Xml&gt; server control.
        /// Patch 11/11/2003 by Manu: Errors are logged.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            string xmlsrc     = string.Empty;
            string xmlsrcType = Settings["XML Type"].ToString();

            if (xmlsrcType == "File")
            {
                xmlsrc = Settings["XML File"].ToString();
            }
            else
            {
                xmlsrc = Settings["XML URL"].ToString();
            }


            string xslsrc     = string.Empty;
            string xslsrcType = Settings["XSL Type"].ToString();

            if (xslsrcType == "File")
            {
                xslsrc = Settings["XSL File"].ToString();
            }
            else
            {
                xslsrc = Settings["XSL Predefined"].ToString();
            }


            //Timeout
            int timeout = int.Parse(Settings["Timeout"].ToString());

            if ((xmlsrc != null) && (xmlsrc.Length != 0))
            {
                if (xmlsrcType == "File")
                {
                    PortalUrlDataType pathXml = new PortalUrlDataType();
                    pathXml.Value = xmlsrc;
                    xmlsrc        = pathXml.FullPath;

                    if (File.Exists(Server.MapPath(xmlsrc)))
                    {
                        xml1.DocumentSource = xmlsrc;
                    }
                    else
                    {
                        Controls.Add(
                            new LiteralControl("<br><div class='error'>File " + xmlsrc + " not found.<br></div>"));
                    }
                }
                else
                {
                    try
                    {
                        LogHelper.Log.Warn("XMLFeed - This should not done more than once in 30 minutes: '" + xmlsrc +
                                           "'");

                        // handle on the remote ressource
                        HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(xmlsrc);
                        //jes1111 - not needed: global proxy is set in Global class Application Start
                        //						if (ConfigurationSettings.AppSettings.Get("UseProxyServerForServerWebRequests") == "true")
                        //							wr.Proxy = PortalSettings.GetProxy();

                        // set the HTTP properties
                        wr.Timeout = timeout * 1000; // milliseconds to seconds
                        // Read the response
                        WebResponse resp = wr.GetResponse();
                        // Stream read the response
                        Stream stream = resp.GetResponseStream();
                        // Read XML data from the stream
                        XmlTextReader reader = new XmlTextReader(stream);
                        // ignore the DTD
                        reader.XmlResolver = null;
                        // Create a new document object
                        XmlDocument doc = new XmlDocument();
                        // Create the content of the XML Document from the XML data stream
                        doc.Load(reader);
                        // the XML control to hold the generated XML document
                        xml1.Document = doc;
                    }
                    catch (Exception ex)
                    {
                        // connectivity issues
                        Controls.Add(
                            new LiteralControl("<br><div class='error'>Error loading: " + xmlsrc + ".<br>" + ex.Message +
                                               "</div>"));
                        ErrorHandler.Publish(LogLevel.Error, "Error loading: " + xmlsrc + ".", ex);
                    }
                }
            }

            if (xslsrcType == "File")
            {
                PortalUrlDataType pathXsl = new PortalUrlDataType();
                pathXsl.Value = xslsrc;
                xslsrc        = pathXsl.FullPath;
            }
            else
            {
                //				if (ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder") != null)
                //				{
                //					if (ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder").ToString().Length > 0)
                //						xslsrc = ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder").ToString() + xslsrc;
                //					else
                //						xslsrc = "~/DesktopModules/CommunityModules/XmlFeed/" + xslsrc;
                //				}
                //				else
                //				{
                //					xslsrc = "~/DesktopModules/CommunityModules/XmlFeed/" + xslsrc;
                //				}
                if (Config.XMLFeedXSLFolder.Length == 0)
                {
                    xslsrc = Path.WebPathCombine(TemplateSourceDirectory, xslsrc);
                }
                else
                {
                    xslsrc = Path.WebPathCombine(Config.XMLFeedXSLFolder, xslsrc);
                }

                if (!xslsrc.EndsWith(".xslt"))
                {
                    xslsrc += ".xslt";
                }
            }

            if ((xslsrc != null) && (xslsrc.Length != 0))
            {
                if (File.Exists(Server.MapPath(xslsrc)))
                {
                    xml1.TransformSource = xslsrc;
                }
                else
                {
                    Controls.Add(new LiteralControl("<br><div class='error'>File " + xslsrc + " not found.<br></div>"));
                }
            }
        }
        /// <summary>
        /// Builds the HTML &lt;body&gt; element, adding meta tags, stylesheets and client scripts
        /// </summary>
        protected virtual void BuildHead()
        {
            this.Title = PageTitle;
            this.Header.Controls.Add(new LiteralControl("<meta name=\"generator\" content=\"Rainbow Portal - see http://www.rainbowportal.net\"/>\n"));

            if (PageMetaKeyWords.Length != 0)
            {
                this.Header.Controls.Add(new LiteralControl(string.Format("<meta name=\"keywords\" content=\"{0}\"/>\n", PageMetaKeyWords)));
            }

            if (PageMetaDescription.Length != 0)
            {
                this.Header.Controls.Add(new LiteralControl(string.Format("<meta name=\"description\" content=\"{0}\"/>\n", PageMetaDescription)));
            }

            if (PageMetaEncoding.Length != 0)
            {
                this.Header.Controls.Add(new LiteralControl(PageMetaEncoding + "\n"));
            }

            if (PageMetaOther.Length != 0)
            {
                this.Header.Controls.Add(new LiteralControl(PageMetaOther + "\n"));
            }

            // additional metas (added by code)
            foreach (string _metaElement in additionalMetaElements.Values)
            {
                this.Header.Controls.Add(new LiteralControl(_metaElement + "\n"));
            }

            // ADD THE CSS <LINK> ELEMENT(S)
            foreach (string _cssFile in cssFileList.Values)
            {
                this.Header.Controls.Add(new LiteralControl(string.Format("<link rel=\"stylesheet\" href=\"{0}\" type=\"text/css\"/>\n", _cssFile)));
            }

            this.Header.Controls.Add(new LiteralControl(string.Format("<link rel=\"SHORTCUT ICON\" href=\"{0}/portalicon.ico\"/>\n",
                                                                      Path.WebPathCombine(Path.ApplicationRoot, portalSettings.PortalPath))));

            if (cssImportList.Count > 0)
            {
                StringBuilder sb = new StringBuilder();

                sb.AppendLine("<style type=\"text/css\">");
                sb.AppendLine("<!--");
                foreach (string _cssBlock in cssImportList.Values)
                {
                    sb.AppendLine(_cssBlock);
                }
                sb.AppendLine("-->");
                sb.AppendLine("</style>");

                this.Header.Controls.Add(new LiteralControl(sb.ToString() + "\n"));
            }

            // ADD CLIENTSCRIPTS
            foreach (string _script in clientScripts.Values)
            {
                this.Header.Controls.Add(new LiteralControl(string.Format("<script type=\"text/javascript\" src=\"{0}\"></script>\n", _script)));
            }
        }