Ejemplo n.º 1
0
        /// <summary>
        /// Stores the theme for the given wiki.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        /// <param name="themeName">The name of the theme.</param>
        /// <param name="zipFile">The zipFile conteining the theme.</param>
        /// <returns><c>true</c> if the theme is saved, <c>false</c> otherwise.</returns>
        public static bool StoreTheme(string wiki, string themeName, byte[] zipFile)
        {
            string[] values   = themeName.Split('|');
            string   provider = values[0];
            string   theme    = values[values.Length - 1];
            IThemesStorageProviderV60 themeStorageProvider = Collectors.CollectorsBox.ThemesProviderCollector.GetProvider(provider, wiki);

            return(themeStorageProvider.StoreTheme(theme, zipFile));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the relative path of the theme with the given name for the given wiki.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        /// <param name="themeName">The name of the theme.</param>
        /// <returns>The relative path of the theme.</returns>
        public static string GetThemePath(string wiki, string themeName)
        {
            string[] values   = themeName.Split('|');
            string   provider = values[0];
            string   theme    = values[values.Length - 1];

            if (provider == "standard")
            {
                return("Content/Themes/" + GetRelativePath(Path.Combine(GlobalSettings.ThemesDirectory, theme), theme) + "/");
            }
            IThemesStorageProviderV60 themePathProvider = Collectors.CollectorsBox.ThemesProviderCollector.GetProvider(provider, wiki);

            return(themePathProvider.GetThemePath(theme));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves all files present in the selected theme.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        /// <param name="themeName">The name of the selected theme.</param>
        /// <param name="searchPattern">The search string to match against the name of files.</param>
        /// <returns>The list of files matching the searchPattern.</returns>
        public static List <string> ListThemeFiles(string wiki, string themeName, string searchPattern)
        {
            string provider = "";
            string theme    = "";

            string[] values = themeName.Split('|');
            string   path   = "";

            provider = values[0];
            theme    = values[values.Length - 1];
            if (values.Length > 1)
            {
                if (provider == "standard")
                {
                    foreach (string s in ListThemes(wiki, provider))
                    {
                        if (s == theme)
                        {
                            path = Path.Combine(GlobalSettings.ThemesDirectory, s);
                            List <string> files = new List <string>();
                            if (!String.IsNullOrEmpty(path) && Directory.Exists(path))
                            {
                                foreach (string file in Directory.GetFiles(path))
                                {
                                    if (file.Contains(searchPattern))
                                    {
                                        files.Add(file);
                                    }
                                }
                            }
                            else
                            {
                                return(null);
                            }
                            for (int i = 0; i < files.Count; i++)
                            {
                                files[i] = "Content/Themes/" + GetRelativePath(files[i], path).Replace(Path.DirectorySeparatorChar.ToString(), "/");
                            }
                            return(new List <string>(files));
                        }
                    }
                }
                else
                {
                    IThemesStorageProviderV60 themeListFileProvider = Collectors.CollectorsBox.ThemesProviderCollector.GetProvider(provider, wiki);
                    if (themeListFileProvider == null)
                    {
                        return(null);
                    }
                    List <string> lists = themeListFileProvider.ListThemeFiles(theme, searchPattern);
                    if ((lists == null) || (lists.Count == 0))
                    {
                        return(null);
                    }
                    else
                    {
                        return(lists);
                    }
                }
            }
            return(null);
        }