public static GetTheme ( string nspace ) : string | ||
nspace | string | The namespace ( |
return | string |
protected void rptNamespaces_DataBinding(object sender, EventArgs e) { List <NamespaceInfo> namespaces = Pages.GetNamespaces(); List <NamespaceRow> result = new List <NamespaceRow>(namespaces.Count); bool canSetPermissions = AdminMaster.CanManagePermissions(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()); PageInfo defaultPage = Pages.FindPage(Settings.DefaultPage); // Inject the root namespace as first entry, retrieving the default page in Settings result.Add(new NamespaceRow(new NamespaceInfo(RootName, defaultPage.Provider, defaultPage), Settings.GetTheme(null), Pages.GetPages(null).Count, Pages.GetCategories(null).Count, canSetPermissions, txtCurrentNamespace.Value == RootName)); foreach (NamespaceInfo ns in namespaces) { result.Add(new NamespaceRow(ns, Settings.GetTheme(ns.Name), Pages.GetPages(ns).Count, Pages.GetCategories(ns).Count, canSetPermissions, txtCurrentNamespace.Value == ns.Name)); } rptNamespaces.DataSource = result; }
protected void btnRename_Click(object sender, EventArgs e) { lblRenameResult.CssClass = ""; lblRenameResult.Text = ""; txtNewName.Text = txtNewName.Text.Trim(); Page.Validate("rename"); if (!Page.IsValid) { return; } NamespaceInfo nspace = Pages.FindNamespace(txtCurrentNamespace.Value); string theme = Settings.GetTheme(nspace.Name); if (Pages.RenameNamespace(nspace, txtNewName.Text)) { Settings.SetTheme(txtNewName.Text, theme); RefreshList(); lblRenameResult.CssClass = "resultok"; lblRenameResult.Text = Properties.Messages.NamespaceRenamed; ReturnToList(); } else { lblRenameResult.CssClass = "resulterror"; lblRenameResult.Text = Properties.Messages.CouldNotRenameNamespace; } }
protected void rptNamespaces_ItemCommand(object sender, RepeaterCommandEventArgs e) { txtCurrentNamespace.Value = e.CommandArgument as string; string currentWiki = DetectWiki(); NamespaceInfo nspace = txtCurrentNamespace.Value != RootName? Pages.FindNamespace(currentWiki, txtCurrentNamespace.Value) : null; if (e.CommandName == "Select") { // rptNamespaces.DataBind(); Not needed because the list is hidden on select txtName.Enabled = false; txtName.Text = nspace != null ? nspace.Name : RootNameUnescaped; txtNewName.Text = ""; cvName.Enabled = false; cvName2.Enabled = false; LoadDefaultPages(); btnCreate.Visible = false; btnSave.Visible = true; btnDelete.Visible = true; // Cannot delete root namespace btnDelete.Enabled = nspace != null; // Cannot rename root namespace btnRename.Enabled = nspace != null; pnlList.Visible = false; pnlEditNamespace.Visible = true; lblResult.Text = ""; lblResult.CssClass = ""; string[] theme = Settings.GetTheme(currentWiki, nspace != null ? nspace.Name : null).Split(new char[] { '|' }); providerThSelector.SelectedProvider = theme[0]; providerThSelector.SelectedThemes = theme[1]; } else if (e.CommandName == "Perms") { if (!AdminMaster.CanManagePermissions(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki))) { return; } permissionsManager.CurrentResourceName = nspace != null ? nspace.Name : null; lblNamespaceName.Text = nspace != null ? nspace.Name : RootName; pnlList.Visible = false; pnlPermissions.Visible = true; lblResult.Text = ""; lblResult.CssClass = ""; } }
private void FillThemes(string provider) { lstThemes.Items.Clear(); lstThemes.Items.Add(new ListItem(Properties.Messages.SelectTheme, "")); foreach (string th in Themes.ListThemes(currentWiki, provider)) { ListItem item = new ListItem(th, th); if (th == Settings.GetTheme(currentWiki, null).Split(new char[] { '|' })[1]) { item.Selected = true; } lstThemes.Items.Add(item); } }
/// <summary> /// Loads the content configuration. /// </summary> /// <param name="currentWiki">The wiki.</param> private void LoadContentConfig(string currentWiki) { string[] theme = Settings.GetTheme(currentWiki, null).Split(new char[] { '|' }); ThemeRootSelector.SelectedProvider = theme[0]; ThemeRootSelector.SelectedThemes = theme[1]; PopulateMainPages(Settings.GetDefaultPage(currentWiki)); txtDateTimeFormat.Text = Settings.GetDateTimeFormat(currentWiki); PopulateDateTimeFormats(); PopulateLanguages(Settings.GetDefaultLanguage(currentWiki)); PopulateTimeZones(Settings.GetDefaultTimezone(currentWiki)); txtMaxRecentChangesToDisplay.Text = Settings.GetMaxRecentChangesToDisplay(currentWiki).ToString(); lstRssFeedsMode.SelectedIndex = -1; switch (Settings.GetRssFeedsMode(currentWiki)) { case RssFeedsMode.FullText: lstRssFeedsMode.SelectedIndex = 0; break; case RssFeedsMode.Summary: lstRssFeedsMode.SelectedIndex = 1; break; case RssFeedsMode.Disabled: lstRssFeedsMode.SelectedIndex = 2; break; } chkEnableDoubleClickEditing.Checked = Settings.GetEnableDoubleClickEditing(currentWiki); chkEnableSectionEditing.Checked = Settings.GetEnableSectionEditing(currentWiki); chkEnableSectionAnchors.Checked = Settings.GetEnableSectionAnchors(currentWiki); chkEnablePageToolbar.Checked = Settings.GetEnablePageToolbar(currentWiki); chkEnableViewPageCode.Checked = Settings.GetEnableViewPageCodeFeature(currentWiki); chkEnablePageInfoDiv.Checked = Settings.GetEnablePageInfoDiv(currentWiki); chkEnableBreadcrumbsTrail.Checked = !Settings.GetDisableBreadcrumbsTrail(currentWiki); chkAutoGeneratePageNames.Checked = Settings.GetAutoGeneratePageNames(currentWiki); chkProcessSingleLineBreaks.Checked = Settings.GetProcessSingleLineBreaks(currentWiki); chkUseVisualEditorAsDefault.Checked = Settings.GetUseVisualEditorAsDefault(currentWiki); if (Settings.GetKeptBackupNumber(currentWiki) == -1) { txtKeptBackupNumber.Text = ""; } else { txtKeptBackupNumber.Text = Settings.GetKeptBackupNumber(currentWiki).ToString(); } chkDisplayGravatars.Checked = Settings.GetDisplayGravatars(currentWiki); txtListSize.Text = Settings.GetListSize(currentWiki).ToString(); }
/// <summary> /// Loads the content configuration. /// </summary> private void LoadContentConfig() { PopulateThemes(Settings.GetTheme(null)); PopulateMainPages(Settings.DefaultPage); txtDateTimeFormat.Text = Settings.DateTimeFormat; PopulateDateTimeFormats(); PopulateLanguages(Settings.DefaultLanguage); PopulateTimeZones(Settings.DefaultTimezone.ToString()); txtMaxRecentChangesToDisplay.Text = Settings.MaxRecentChangesToDisplay.ToString(); lstRssFeedsMode.SelectedIndex = -1; switch (Settings.RssFeedsMode) { case RssFeedsMode.FullText: lstRssFeedsMode.SelectedIndex = 0; break; case RssFeedsMode.Summary: lstRssFeedsMode.SelectedIndex = 1; break; case RssFeedsMode.Disabled: lstRssFeedsMode.SelectedIndex = 2; break; } chkEnableDoubleClickEditing.Checked = Settings.EnableDoubleClickEditing; chkEnableSectionEditing.Checked = Settings.EnableSectionEditing; chkEnableSectionAnchors.Checked = Settings.EnableSectionAnchors; chkEnablePageToolbar.Checked = Settings.EnablePageToolbar; chkEnableViewPageCode.Checked = Settings.EnableViewPageCodeFeature; chkEnablePageInfoDiv.Checked = Settings.EnablePageInfoDiv; chkEnableBreadcrumbsTrail.Checked = !Settings.DisableBreadcrumbsTrail; chkAutoGeneratePageNames.Checked = Settings.AutoGeneratePageNames; chkProcessSingleLineBreaks.Checked = Settings.ProcessSingleLineBreaks; chkUseVisualEditorAsDefault.Checked = Settings.UseVisualEditorAsDefault; if (Settings.KeptBackupNumber == -1) { txtKeptBackupNumber.Text = ""; } else { txtKeptBackupNumber.Text = Settings.KeptBackupNumber.ToString(); } chkDisplayGravatars.Checked = Settings.DisplayGravatars; txtListSize.Text = Settings.ListSize.ToString(); }
private static bool IsThemeInUse(string wiki, string themeName) { List <NamespaceInfo> namespaces = Pages.GetNamespaces(wiki); bool result = false; if (themeName == Settings.GetTheme(wiki, null)) { return(true); } foreach (NamespaceInfo ns in namespaces) { if (themeName == Settings.GetTheme(wiki, ns.Name)) { return(true); } } return(result); }
/// <summary> /// Reloads this instance. /// </summary> public void Reload() { IProviderV40[] allProviders = null; allProviders = Collectors.CollectorsBox.ThemesProviderCollector.GetAllProviders(currentWiki); lstThemesProviders.Items.Clear(); lstThemesProviders.Items.Add(new ListItem("standard", "standard")); foreach (IProviderV40 prov in allProviders) { string typeName = prov.GetType().FullName; ListItem item = new ListItem(prov.Information.Name, typeName); if (typeName == Settings.GetTheme(currentWiki, null).Split(new char[] { '|' })[0]) { item.Selected = true; } lstThemesProviders.Items.Add(item); } }
/// <summary> /// Gets all the included files for the HTML Head, such as CSS, JavaScript and Icon pluginAssemblies, for a namespace. /// </summary> /// <param name="nspace">The namespace (<c>null</c> for the root).</param> /// <returns>The includes.</returns> public static string GetIncludes(string nspace, string themeOverride = null) { var themePath = Settings.GetThemePath(nspace); var theme = Settings.GetTheme(nspace); if (!string.IsNullOrEmpty(themeOverride)) { themePath = Settings.ThemesDirectoryName + "/" + themeOverride + "/"; theme = themeOverride; } var result = new StringBuilder(300); result.Append(GetJavaScriptIncludes()); var themeDir = Settings.ThemesDirectory + theme; if (!Directory.Exists(themeDir)) { themeDir = Settings.ThemesDirectory + "Default"; } var css = Directory.GetFiles(themeDir, "*.css"); string firstChunk; for (var i = 0; i < css.Length; i++) { if (Path.GetFileName(css[i]).IndexOf("_") != -1) { firstChunk = Path.GetFileName(css[i]).Substring(0, Path.GetFileName(css[i]).IndexOf("_")).ToLowerInvariant(); if (firstChunk.Equals("screen") || firstChunk.Equals("print") || firstChunk.Equals("all") || firstChunk.Equals("aural") || firstChunk.Equals("braille") || firstChunk.Equals("embossed") || firstChunk.Equals("handheld") || firstChunk.Equals("projection") || firstChunk.Equals("tty") || firstChunk.Equals("tv")) { result.Append(@"<link rel=""stylesheet"" media=""" + firstChunk + @""" href=""" + themePath + Path.GetFileName(css[i]) + @""" type=""text/css"" />" + "\n"); } else { result.Append(@"<link rel=""stylesheet"" href=""" + themePath + Path.GetFileName(css[i]) + @""" type=""text/css"" />" + "\n"); } } else { result.Append(@"<link rel=""stylesheet"" href=""" + themePath + Path.GetFileName(css[i]) + @""" type=""text/css"" />" + "\n"); } } var customEditorCss = Path.Combine(themeDir, "Editor.css"); if (File.Exists(customEditorCss)) { result.AppendFormat(@"<link rel=""stylesheet"" href=""{0}Editor.css"" type=""text/css"" />" + "\n", themePath); } else { result.Append(@"<link rel=""stylesheet"" href=""Themes/Editor.css"" type=""text/css"" />" + "\n"); } // OpenSearch result.AppendFormat(@"<link rel=""search"" href=""Search.aspx?OpenSearch=1"" type=""application/opensearchdescription+xml"" title=""{1}"" />", Settings.MainUrl, Settings.WikiTitle + " - Search"); var js = Directory.GetFiles(themeDir, "*.js"); for (var i = 0; i < js.Length; i++) { result.Append(@"<script src=""" + themePath + Path.GetFileName(js[i]) + @""" type=""text/javascript""></script>" + "\n"); } var icons = Directory.GetFiles(themeDir, "Icon.*"); if (icons.Length > 0) { result.Append(@"<link rel=""shortcut icon"" href=""" + themePath + Path.GetFileName(icons[0]) + @""" type="""); switch (Path.GetExtension(icons[0]).ToLowerInvariant()) { case ".ico": result.Append("image/x-icon"); break; case ".gif": result.Append("image/gif"); break; case ".png": result.Append("image/png"); break; } result.Append(@""" />" + "\n"); } // Include HTML Head result.Append(Settings.Provider.GetMetaDataItem(MetaDataItem.HtmlHead, nspace)); return(result.ToString()); }
protected void rptNamespaces_ItemCommand(object sender, RepeaterCommandEventArgs e) { txtCurrentNamespace.Value = e.CommandArgument as string; NamespaceInfo nspace = txtCurrentNamespace.Value != RootName? Pages.FindNamespace(txtCurrentNamespace.Value) : null; if (e.CommandName == "Select") { // rptNamespaces.DataBind(); Not needed because the list is hidden on select string theme = Settings.GetTheme(nspace != null ? nspace.Name : null); txtName.Enabled = false; txtName.Text = nspace != null ? nspace.Name : RootNameUnescaped; txtNewName.Text = ""; cvName.Enabled = false; cvName2.Enabled = false; LoadDefaultPages(); lstTheme.SelectedIndex = -1; foreach (ListItem item in lstTheme.Items) { if (item.Value == theme) { item.Selected = true; break; } } providerSelector.SelectedProvider = nspace != null?nspace.Provider.ToString() : Settings.DefaultPagesProvider; providerSelector.Enabled = false; btnCreate.Visible = false; btnSave.Visible = true; btnDelete.Visible = true; // Cannot delete root namespace btnDelete.Enabled = nspace != null; // Cannot rename root namespace btnRename.Enabled = nspace != null; pnlList.Visible = false; pnlEditNamespace.Visible = true; lblResult.Text = ""; lblResult.CssClass = ""; } else if (e.CommandName == "Perms") { if (!AdminMaster.CanManagePermissions(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { return; } permissionsManager.CurrentResourceName = nspace != null ? nspace.Name : null; lblNamespaceName.Text = nspace != null ? nspace.Name : RootName; pnlList.Visible = false; pnlPermissions.Visible = true; lblResult.Text = ""; lblResult.CssClass = ""; } }
/// <summary> /// Gets all the included files for the HTML Head, such as CSS, JavaScript and Icon pluginAssemblies, for a wiki and namespace. /// </summary> /// <param name="wiki">The wiki.</param> /// <param name="nspace">The namespace (<c>null</c> for the root).</param> /// <returns>The includes.</returns> public static string GetIncludes(string wiki, string nspace) { StringBuilder result = new StringBuilder(300); string nameTheme = Settings.GetTheme(wiki, nspace); result.Append(GetJavaScriptIncludes()); List <string> cssList = Themes.ListThemeFiles(wiki, nameTheme, ".css"); string firstChunk; if (cssList != null) { foreach (string cssFile in cssList) { if (Path.GetFileName(cssFile).IndexOf("_") != -1) { firstChunk = Path.GetFileName(cssFile).Substring(0, Path.GetFileName(cssFile).IndexOf("_")).ToLowerInvariant(); if (firstChunk.Equals("screen") || firstChunk.Equals("print") || firstChunk.Equals("all") || firstChunk.Equals("aural") || firstChunk.Equals("braille") || firstChunk.Equals("embossed") || firstChunk.Equals("handheld") || firstChunk.Equals("projection") || firstChunk.Equals("tty") || firstChunk.Equals("tv")) { result.Append(@"<link rel=""stylesheet"" media=""" + firstChunk + @""" href=""" + cssFile + @""" type=""text/css"" />" + "\n"); } else { result.Append(@"<link rel=""stylesheet"" href=""" + cssFile + @""" type=""text/css"" />" + "\n"); } } else { result.Append(@"<link rel=""stylesheet"" href=""" + cssFile + @""" type=""text/css"" />" + "\n"); } } } List <string> customEditorCss = Themes.ListThemeFiles(wiki, nameTheme, "Editor.css"); if (customEditorCss != null && customEditorCss.Count > 0) { result.AppendFormat(@"<link rel=""stylesheet"" href=""{0}"" type=""text/css"" />" + "\n", customEditorCss[0]); } else { result.Append(@"<link rel=""stylesheet"" href=""Themes/Editor.css"" type=""text/css"" />" + "\n"); } // OpenSearch result.AppendFormat(@"<link rel=""search"" href=""Search.aspx?OpenSearch=1"" type=""application/opensearchdescription+xml"" title=""{0}"" />", Settings.GetWikiTitle(wiki) + " - Search"); List <string> jsFiles = Themes.ListThemeFiles(wiki, nameTheme, ".js"); if (jsFiles != null) { foreach (string jsFile in jsFiles) { result.Append(@"<script src=""" + jsFile + @""" type=""text/javascript""></script>" + "\n"); } } List <string> iconsList = Themes.ListThemeFiles(wiki, nameTheme, "Icon."); if (iconsList != null) { string[] icons = iconsList.ToArray(); if (icons.Length > 0) { result.Append(@"<link rel=""shortcut icon"" href=""" + icons[0] + @""" type="""); switch (icons[0].Substring(icons[0].LastIndexOf('.')).ToLowerInvariant()) { case ".ico": result.Append("image/x-icon"); break; case ".gif": result.Append("image/gif"); break; case ".png": result.Append("image/png"); break; } result.Append(@""" />" + "\n"); } } // Include HTML Head result.Append(Settings.GetProvider(wiki).GetMetaDataItem(MetaDataItem.HtmlHead, nspace)); return(result.ToString()); }