/// <summary> /// The init settings. /// </summary> private void InitSettings() { var settings = new ExtensionSettings(this) { IsScalar = true }; settings.AddParameter("CaptchaLabel", "Your captcha's label", 30, true, true, ParameterType.String); settings.AddValue("CaptchaLabel", "5+5 = "); settings.AddParameter( "CaptchaAnswer", "Your captcha's expected value", MaxCaptchaLength, true, true, ParameterType.String); settings.AddValue("CaptchaAnswer", "10"); settings.AddParameter( "ShowForAuthenticatedUsers", "Show Captcha For Authenticated Users", 1, true, false, ParameterType.Boolean); settings.AddValue("ShowForAuthenticatedUsers", false); settings.Help = @"To get started with SimpleCaptcha, just provide some captcha instructions for your users in the <b>CaptchaLabel</b> field and the value you require from your users in order to post a comment in the <b>CaptchaAnswer</b> field."; Settings = ExtensionManager.InitSettings("SimpleCaptcha", settings); ExtensionManager.SetStatus("SimpleCaptcha", false); }
/// <summary> /// Get list of custom filters /// </summary> /// <returns>List of filters</returns> public IEnumerable<CustomFilter> GetCustomFilters() { if (!Security.IsAuthorizedTo(Rights.AccessAdminPages)) throw new UnauthorizedAccessException(); var filterList = new List<CustomFilter>(); try { CustomFilters = ExtensionManager.GetSettings("MetaExtension", "BeCustomFilters"); DataTable dt = CustomFilters.GetDataTable(); foreach (DataRow row in dt.Rows) { var f = new CustomFilter { Name = row["Name"].ToString(), FullName = row["FullName"].ToString(), Checked = int.Parse(row["Checked"].ToString()), Spam = int.Parse(row["Cought"].ToString()), Mistakes = int.Parse(row["Reported"].ToString()) }; var ext = ExtensionManager.GetExtension(f.Name); f.Enabled = ext == null ? true : ext.Enabled; filterList.Add(f); } } catch (Exception ex) { Utils.Log("CustomFilterRepository.GetCustomFilters(): " + ex.Message); } return filterList; }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { Settings = ExtensionManager.GetSettings("Sponsor"); base.OnLoad(e); if (!IsPostBack) { BindGrid(); } }
/// <summary> /// Dynamically loads form controls or /// data grid and binds data to controls /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> protected void Page_Load(object sender, EventArgs e) { Security.DemandUserHasRight(BlogEngine.Core.Rights.AccessAdminPages, true); ExtensionName = System.Web.HttpUtility.UrlEncode(Request.QueryString["ext"]); SettingName = this.ID; if (string.IsNullOrEmpty(ExtensionName)) ExtensionName = SettingName; Settings = ExtensionManager.GetSettings(ExtensionName, SettingName); GenerateDeleteButton = Settings.ShowDelete; GenerateEditButton = Settings.ShowEdit; if (Settings.ShowAdd) { CreateFormFields(); } if (!this.Page.IsPostBack) { if (this.Settings.IsScalar) { this.BindScalar(); } else { this.CreateTemplatedGridView(); this.BindGrid(); } } if (this.Settings.IsScalar) { this.btnAdd.Text = labels.save; } else { if (this.Settings.ShowAdd) { this.grid.RowEditing += this.GridRowEditing; this.grid.RowUpdating += this.GridRowUpdating; this.grid.RowCancelingEdit += (o, args) => this.Response.Redirect(this.Request.RawUrl); this.grid.RowDeleting += this.GridRowDeleting; this.btnAdd.Text = labels.add; } else { this.btnAdd.Visible = false; } } this.btnAdd.Click += this.BtnAddClick; }
protected void Page_Load(object sender, EventArgs e) { // load settings Settings = ExtensionManager.GetSettings("AudioStream"); if (!Page.IsPostBack) { TxbHighStream.Text = Settings.GetSingleValue("HighStream"); TxbLowStream.Text = Settings.GetSingleValue("LowStream"); BindForm(); } }
/// <summary> /// Imports the settings. /// </summary> /// <param name="extensionName"> /// Name of the extension. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// If import settings works. /// </returns> public static bool ImportSettings(string extensionName, ExtensionSettings settings) { var ext = extensions.FirstOrDefault(x => x.Key == extensionName && !x.Value.Initialized(settings)); if (ext.Value != null) { ext.Value.InitializeSettings(settings); } SaveToCache(); // return SaveToStorage(); return(true); }
protected void Page_Load(object sender, EventArgs e) { // load settings Settings = ExtensionManager.GetSettings("Bovenhoek"); if (!Page.IsPostBack) { TxtUrl.Text = Settings.GetSingleValue("PeelUrl"); TxtImageUrl.Text = Settings.GetSingleValue("PeelImage"); TxtTarget.Text = Settings.GetSingleValue("PeelTarget"); BindForm(); } }
/// <summary> /// Add item /// </summary> /// <param name="item"></param> /// <returns>New item</returns> public CommentFilterItem Add(CommentFilterItem item) { if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages)) throw new System.UnauthorizedAccessException(); try { Filters = ExtensionManager.GetSettings("MetaExtension", "BeCommentFilters"); string id = Guid.NewGuid().ToString(); int parLen = Filters.Parameters[0].Values.Count; for (int i = 0; i < parLen; i++) { bool exists = Filters.Parameters[1].Values[i] == item.Action && Filters.Parameters[2].Values[i] == item.Subject && Filters.Parameters[3].Values[i] == item.Operation && Filters.Parameters[4].Values[i] == item.Filter; if (exists) { throw new System.ApplicationException("Item already exists"); } } string[] f = new string[] { id, item.Action, item.Subject, item.Operation, item.Filter }; Filters.AddValues(f); ExtensionManager.SaveSettings("MetaExtension", Filters); return new CommentFilterItem { Id = Guid.Parse(id), Action = item.Action, Subject = item.Subject, Operation = item.Operation, Filter = item.Filter }; } catch (Exception ex) { Utils.Log("Error adding new comment filter", ex); throw; } }
/// <summary> /// Method to cache and serialize settings object /// </summary> /// <param name="extensionSettings">The extension settings.</param> public void SaveSettings(ExtensionSettings extensionSettings) { if (string.IsNullOrEmpty(extensionSettings.Name)) { extensionSettings.Name = this.Name; } foreach (var setItem in this.settings.Where(setItem => setItem.Name == extensionSettings.Name)) { this.settings.Remove(setItem); break; } this.settings.Add(extensionSettings); }
/// <summary> /// Method to cache and serialize settings object /// </summary> /// <param name="extensionSettings">The extension settings.</param> public void SaveSettings(ExtensionSettings extensionSettings) { if (string.IsNullOrEmpty(extensionSettings.Name)) { extensionSettings.Name = this.Name; } foreach (var setItem in this.settings.Where(setItem => setItem.Name == extensionSettings.Name)) { this.settings.Remove(setItem); break; } this.settings.Add(extensionSettings); this.settings.Sort((s1, s2) => string.Compare(s1.Index.ToString(), s2.Index.ToString())); }
protected void Page_Load(object sender, EventArgs e) { WebUtils.CheckRightsForAdminSettingsPage(false); Filters = ExtensionManager.GetSettings("MetaExtension", "BeCommentFilters"); if (!IsPostBack) { BindFilters(); } Page.MaintainScrollPositionOnPostBack = true; Page.Title = Resources.labels.comments; btnSave.Click += btnSave_Click; btnSave.Text = Resources.labels.saveSettings; }
/// <summary> /// Comment filters list /// </summary> /// <param name="take"></param> /// <param name="skip"></param> /// <param name="filter"></param> /// <param name="order"></param> /// <returns>List of comment filters</returns> public IEnumerable<CommentFilterItem> Find(int take = 10, int skip = 0, string filter = "", string order = "") { if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages)) throw new System.UnauthorizedAccessException(); var filterList = new List<CommentFilterItem>(); try { Filters = ExtensionManager.GetSettings("MetaExtension", "BeCommentFilters"); DataTable dt = Filters.GetDataTable(); foreach (DataRow row in dt.Rows) { var f = new CommentFilterItem { Id = Guid.Parse(row["Id"].ToString()), Action = row["Action"].ToString(), Subject = row["Subject"].ToString(), Operation = row["Operator"].ToString(), Filter = row["Filter"].ToString() }; filterList.Add(f); } if (take == 0) take = filterList.Count; if (string.IsNullOrEmpty(filter)) filter = "1==1"; if (string.IsNullOrEmpty(order)) order = "Filter"; var items = new List<CommentFilterItem>(); var query = filterList.AsQueryable().Where(filter); foreach (var item in query.OrderBy(order).Skip(skip).Take(take)) items.Add(item); return items; } catch (Exception ex) { Utils.Log("CommentFilterRepository.Find(): " + ex.Message); } return filterList; }
/// <summary> /// Method to cache and serialize settings object /// </summary> /// <param name="extensionSettings">The extension settings.</param> public void SaveSettings(ExtensionSettings extensionSettings) { if (string.IsNullOrEmpty(extensionSettings.Name)) { extensionSettings.Name = this.Name; } if (!Blog.CurrentInstance.IsPrimary && SubBlogEnabled) { // update settings for sub-blog foreach (var setItem in this.settings.Where( setItem => setItem.Name == extensionSettings.Name && setItem.BlogId == extensionSettings.BlogId)) { this.settings.Remove(setItem); break; } } else { // update settings for primary blog var primId = Blog.Blogs.FirstOrDefault(b => b.IsPrimary).BlogId; extensionSettings.BlogId = primId; foreach (var setItem in this.settings.Where( setItem => setItem.Name == extensionSettings.Name && (setItem.BlogId == primId || setItem.BlogId == null))) { this.settings.Remove(setItem); break; } } settings.Add(extensionSettings); this.settings.Sort((s1, s2) => string.Compare(s1.Index.ToString(), s2.Index.ToString())); }
/// <summary> /// Will save settings (add to extension object, then /// cache and serialize all object hierarhy to XML) /// </summary> /// <param name="settings"> /// Settings object /// </param> public static void SaveSettings(ExtensionSettings settings) { SaveSettings(settings.Name, settings); }
/// <summary> /// Initializes settings by importing default parameters /// </summary> /// <param name="extensionName"> /// Extension Name /// </param> /// <param name="settings"> /// Settings object /// </param> /// <returns> /// The Extension Settings /// </returns> public static ExtensionSettings InitSettings(string extensionName, ExtensionSettings settings) { ImportSettings(extensionName, settings); return GetSettings(extensionName, settings.Name); }
/// <summary> /// Imports the settings. /// </summary> /// <param name="extensionName"> /// Name of the extension. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// If import settings works. /// </returns> public static bool ImportSettings(string extensionName, ExtensionSettings settings) { var ext = extensions.FirstOrDefault(x => x.Key == extensionName && !x.Value.Initialized(settings)); if (ext.Value != null) { ext.Value.InitializeSettings(settings); } SaveToCache(); // return SaveToStorage(); return true; }
/// <summary> /// Do initial import here. /// If already imported, let extension manager take care of settings /// To reset, blogger has to delete all settings in the manager /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The import settings. /// </returns> public static bool ImportSettings(ExtensionSettings settings) { return(ImportSettings(settings.Name, settings)); }
/// <summary> /// Initializes the settings. /// </summary> /// <param name="extensionSettings">The extension settings.</param> public void InitializeSettings(ExtensionSettings extensionSettings) { extensionSettings.Index = this.settings.Count; this.SaveSettings(extensionSettings); }
/// <summary> /// Determine if settings has been initialized with default /// values (first time new extension loaded into the manager) /// </summary> /// <param name="xs"> /// The ExtensionSettings. /// </param> /// <returns> /// True if initialized /// </returns> public bool Initialized(ExtensionSettings xs) { return(xs != null && this.settings.Where(setItem => setItem.Name == xs.Name).Any(setItem => setItem.Parameters.Count == xs.Parameters.Count)); }
public static List<PicasaAlbum> GetAlbums() { Settings = ExtensionManager.GetSettings("Picasa2"); if (string.IsNullOrEmpty(Settings.GetSingleValue("Account"))) return null; var service = new PicasaService("exampleCo-exampleApp-1"); string usr = Settings.GetSingleValue("Account") + "@gmail.com"; string pwd = Settings.GetSingleValue("Password"); service.setUserCredentials(usr, pwd); var query = new AlbumQuery(PicasaQuery.CreatePicasaUri(usr)); PicasaFeed feed = service.Query(query); var albums = new List<PicasaAlbum>(); foreach (PicasaEntry entry in feed.Entries) { var ac = new AlbumAccessor(entry); // thumbnail string albumUri = ((Google.GData.Client.AtomEntry)(entry)).AlternateUri.ToString(); string firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string; albums.Add(new PicasaAlbum() { Accessor = ac, ThumbNailURl = firstThumbUrl, AlbumUri = albumUri }); } return albums; }
protected void InitSettings() { var settings = new ExtensionSettings("Picasa2"); settings.AddParameter("Account"); settings.AddParameter("Password"); settings.AddParameter("ShowWidth"); settings.AddParameter("PicWidth"); settings.AddParameter("AutoPlay"); settings.AddValue("Account", ""); settings.AddValue("Password", "secret"); settings.AddValue("ShowWidth", "400"); settings.AddValue("PicWidth", "72"); settings.AddValue("AutoPlay", true); settings.IsScalar = true; ExtensionManager.ImportSettings(settings); ExtensionManager.SetAdminPage("Picasa2", "~/User controls/Picasa/Admin.aspx"); Settings = ExtensionManager.GetSettings("Picasa2"); }
private void Initialize() { ExtensionSettings settings = new ExtensionSettings(this); settings.IsScalar = true; settings.AddParameter("BaseUrl", "Feed Provider"); string[] providers = { "http://api.brafton.com/", "http://api.contentlead.com/", "http://api.castleford.com.au/" }; settings.AddValue("BaseUrl", providers, providers[0]); settings.AddParameter("ApiKey", "API Key", 36); settings.AddParameter("Interval", "Upload Interval (minutes)", 6, true); settings.AddValue("Interval", 180); settings.AddParameter("ImportedDate", "Imported Date"); settings.SetParameterType("ImportedDate", ParameterType.DropDown); string[] sortOptions = { "Published Date", "Created Date", "Last Modified Date" }; settings.AddValue("ImportedDate", sortOptions, sortOptions[0]); settings.AddParameter("LastUpload", "Time of last upload"); settings.AddValue("LastUpload", DateTime.MinValue.ToString("u")); settings.AddParameter("ImportContent", "Import Content"); settings.SetParameterType("ImportContent", ParameterType.DropDown); string[] contentTypes = { "Articles Only", "Videos Only", "Articles and Video" }; settings.AddValue("ImportContent", contentTypes, contentTypes[0]); settings.AddParameter("VideoPublicKey", "Public Key"); settings.AddParameter("VideoSecretKey", "Secret Key"); settings.AddParameter("VideoFeedNumber", "Feed Number"); settings.SetParameterType("VideoFeedNumber", ParameterType.Integer); _settings = ExtensionManager.InitSettings("BraftonArticleImporter", settings); }
/// <summary> /// Initializes settings by importing default parameters /// </summary> /// <param name="extensionName"> /// Extension Name /// </param> /// <param name="settings"> /// Settings object /// </param> /// <returns> /// The Extension Settings /// </returns> public static ExtensionSettings InitSettings(string extensionName, ExtensionSettings settings) { ImportSettings(extensionName, settings); return(GetSettings(extensionName, settings.Name)); }
/// <summary> /// The save settings. /// </summary> /// <param name="extensionName"> /// The extension name. /// </param> /// <param name="settings"> /// The settings. /// </param> public static void SaveSettings(string extensionName, ExtensionSettings settings) { var ext = extensions.FirstOrDefault(x => x.Key == extensionName); if (ext.Value != null) { ext.Value.SaveSettings(settings); } Save(); }
/// <summary> /// The init log settings. /// </summary> public void InitLogSettings() { var settings = new ExtensionSettings("RecaptchaLog"); settings.AddParameter("Response"); settings.AddParameter("Challenge"); settings.AddParameter("CommentID"); settings.AddParameter("TimeToComment"); settings.AddParameter("TimeToSolveCapcha"); settings.AddParameter("NumberOfAttempts"); settings.AddParameter("Enabled"); settings.AddParameter("Necessary"); settings.Hidden = true; ExtensionManager.InitSettings("Recaptcha", settings); }
/// <summary> /// The init custom filters. /// </summary> private static void InitCustomFilters() { var settings = new ExtensionSettings("BeCustomFilters"); settings.AddParameter("FullName", "Name", 100, true, true); settings.AddParameter("Name"); settings.AddParameter("Checked"); settings.AddParameter("Cought"); settings.AddParameter("Reported"); settings.AddParameter("Priority"); customFilters = ExtensionManager.InitSettings("MetaExtension", settings); if (customFilters == null) { return; } var dt = customFilters.GetDataTable(); var codeAssemblies = Utils.CodeAssemblies(); foreach (var type in codeAssemblies.Cast<Assembly>().Select(a => a.GetTypes()).SelectMany( types => (from type in types where type.GetInterface("BlogEngine.Core.ICustomFilter") != null let found = dt.Rows.Cast<DataRow>().Any(row => row[0].ToString() == type.Name) where !found select type))) { // if new filter found in the assembly, add it to settings if (!customFilters.IsKeyValueExists(type.FullName)) { customFilters.AddValues(new[] { type.FullName, type.Name, "0", "0", "0", "0" }); ExtensionManager.SaveSettings("MetaExtension", customFilters); } } }
/// <summary> /// Inits the filters. /// </summary> private static void InitFilters() { var settings = new ExtensionSettings("BeCommentFilters"); settings.AddParameter("ID", "ID", 20, true, true, ParameterType.Integer); settings.AddParameter("Action"); settings.AddParameter("Subject"); settings.AddParameter("Operator"); settings.AddParameter("Filter"); filters = ExtensionManager.InitSettings("MetaExtension", settings); }
/// <summary> /// Determine if settings has been initialized with default /// values (first time new extension loaded into the manager) /// </summary> /// <param name="xs"> /// The ExtensionSettings. /// </param> /// <returns> /// True if initialized /// </returns> public bool Initialized(ExtensionSettings xs) { return xs != null && this.settings.Where(setItem => setItem.Name == xs.Name).Any(setItem => setItem.Parameters.Count == xs.Parameters.Count); }
/// <summary> /// Do initial import here. /// If already imported, let extension manager take care of settings /// To reset, blogger has to delete all settings in the manager /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The import settings. /// </returns> public static bool ImportSettings(ExtensionSettings settings) { return ImportSettings(settings.Name, settings); }
/// <summary> /// The init settings. /// </summary> public void InitSettings() { var settings = new ExtensionSettings(this) { IsScalar = true }; settings.AddParameter("PublicKey", "Public Key", 50, true, true, ParameterType.String); settings.AddValue("PublicKey", "YOURPUBLICKEY"); settings.AddParameter("PrivateKey", "Private Key", 50, true, true, ParameterType.String); settings.AddValue("PrivateKey", "YOURPRIVATEKEY"); settings.AddParameter( "ShowForAuthenticatedUsers", "Show Captcha For Authenticated Users", 1, true, false, ParameterType.Boolean); settings.AddValue("ShowForAuthenticatedUsers", false); settings.AddParameter( "MaxLogEntries", "Logging: Maximum successful recaptcha attempts to store (set to 0 to disable logging)", 4, true, false, ParameterType.Integer); settings.AddValue("MaxLogEntries", 50); settings.AddParameter("Theme", "Theme", 20, true, false, ParameterType.DropDown); settings.AddValue("Theme", new[] { "red", "white", "blackglass", "clean" }, "white"); settings.AddParameter("Language", "Language", 5, true, false, ParameterType.DropDown); settings.AddValue("Language", new[] { "en|English", "nl|Dutch", "fr|French", "de|German", "pt|Portuguese", "ru|Russian", "es|Spanish", "tr|Turkish" }, "en"); settings.Help = string.Format( "\n<script type='text/javascript'>\n{0}\n</script>\nYou can create your own public key at <a href='http://www.Recaptcha.net'>http://www.Recaptcha.net</a>. This is used for communication between your website and the recapcha server.<br /><br />Please rememeber you need to <span style=\"color:red\">enable extension</span> for reCaptcha to show up on the comments form.<br /><br />You can see some statistics on Captcha solving by storing successful attempts. If you're getting spam, this should also confirm that the spammers are at least solving the captcha.<br /><br /><a href='../Pages/RecaptchaLogViewer.aspx' target='_blank' onclick='return showRecaptchaLog()'>Click here to view the log</a>", this.JScript); Settings = ExtensionManager.InitSettings("Recaptcha", settings); ExtensionManager.SetStatus("Recaptcha", false); }
/// <summary> /// The init settings. /// </summary> private void InitSettings() { var extensionSettings = new ExtensionSettings(this) { IsScalar = true }; extensionSettings.AddParameter("SiteURL", "Site URL"); extensionSettings.AddParameter("ApiKey", "API Key"); extensionSettings.AddValue("SiteURL", "http://example.com/blog"); extensionSettings.AddValue("ApiKey", "123456789"); settings = ExtensionManager.InitSettings("AkismetFilter", extensionSettings); ExtensionManager.SetStatus("AkismetFilter", false); }