/// <summary> /// Gets and bulk updates css stylesheets. Called when the "Get and bulk update stylesheets" button is pressed. /// Expects the CreateCssStylesheet method to be run first. /// </summary> private bool GetAndBulkUpdateCssStylesheets() { // Prepare the parameters string where = "StylesheetName LIKE N'MyNewStylesheet%'"; // Get the data DataSet stylesheets = CssStylesheetInfoProvider.GetCssStylesheets().Where(where); if (!DataHelper.DataSourceIsEmpty(stylesheets)) { // Loop through the individual items foreach (DataRow stylesheetDr in stylesheets.Tables[0].Rows) { // Create object from DataRow CssStylesheetInfo modifyStylesheet = new CssStylesheetInfo(stylesheetDr); // Update the properties modifyStylesheet.StylesheetDisplayName = modifyStylesheet.StylesheetDisplayName.ToUpper(); // Save the changes CssStylesheetInfoProvider.SetCssStylesheetInfo(modifyStylesheet); } return(true); } return(false); }
/// <summary> /// Creates versioned css stylesheet. Called when the "Create versioned object" button is pressed. /// </summary> private bool CreateVersionedObject() { // Create new css stylesheet object CssStylesheetInfo newStylesheet = new CssStylesheetInfo(); // Check if object versioning of stylesheet objects is allowed on current site if (ObjectVersionManager.AllowObjectVersioning(newStylesheet, CMSContext.CurrentSiteName)) { // Set the properties newStylesheet.StylesheetDisplayName = "My new versioned stylesheet"; newStylesheet.StylesheetName = "MyNewVersionedStylesheet"; newStylesheet.StylesheetText = "Some versioned CSS code"; // Save the css stylesheet CssStylesheetInfoProvider.SetCssStylesheetInfo(newStylesheet); // Add css stylesheet to site int stylesheetId = newStylesheet.StylesheetID; int siteId = CMSContext.CurrentSiteID; CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(stylesheetId, siteId); return(true); } return(false); }
/// <summary> /// Creates css stylesheet. Called when the "Create stylesheet" button is pressed. /// </summary> private bool CreateCssStylesheet() { // Create new css stylesheet object CssStylesheetInfo newStylesheet = new CssStylesheetInfo(); // Set the properties newStylesheet.StylesheetDisplayName = "My new stylesheet"; newStylesheet.StylesheetName = "MyNewStylesheet"; newStylesheet.StylesheetText = "Some CSS code"; // Save the css stylesheet CssStylesheetInfoProvider.SetCssStylesheetInfo(newStylesheet); return(true); }
/// <summary> /// Gets and updates css stylesheet. Called when the "Get and update stylesheet" button is pressed. /// Expects the CreateCssStylesheet method to be run first. /// </summary> private bool GetAndUpdateCssStylesheet() { // Get the css stylesheet CssStylesheetInfo updateStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet"); if (updateStylesheet != null) { // Update the properties updateStylesheet.StylesheetDisplayName = updateStylesheet.StylesheetDisplayName.ToLower(); // Save the changes CssStylesheetInfoProvider.SetCssStylesheetInfo(updateStylesheet); return(true); } return(false); }
protected int SaveNewCssStylesheet() { CssStylesheetInfo cs = new CssStylesheetInfo { StylesheetDisplayName = txtDisplayName.Text, StylesheetName = txtName.Text, StylesheetText = txtText.Text }; CssStylesheetInfoProvider.SetCssStylesheetInfo(cs); // Stylesheet is assigned to site if checkbox is showed and checked or in dialog mode(stylesheet is assigned to specified or current site) if (((chkAssign.Visible && chkAssign.Checked) || dialogMode) && (CurrentSite != null) && (cs.StylesheetID > 0)) { // Add new stylesheet to the actual site CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(cs.StylesheetID, CurrentSite.SiteID); } return(cs.StylesheetID); }
/// <summary> /// Saves the stylesheet, returns true if successful. /// </summary> private bool Save() { string result = new Validator() .NotEmpty(txtCssStylesheetDisplayName.Text, GetString("CssStylesheet_General.EmptyDisplayName")) .NotEmpty(txtCssStylesheetName.Text, GetString("CssStylesheet_General.EmptyName")) .IsCodeName(txtCssStylesheetName.Text, GetString("general.invalidcodename")) .NotEmpty(txtCssStylesheetText.Text.Trim(), GetString("CssStylesheet_General.EmptyText")) .Result; if (result != string.Empty) { ShowError(result); return(false); } CssStylesheetInfo si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId); if (si != null) { si.StylesheetDisplayName = txtCssStylesheetDisplayName.Text; si.StylesheetName = txtCssStylesheetName.Text; si.StylesheetID = cssStylesheetId; if (si.StylesheetCheckedOutByUserID <= 0) { si.StylesheetText = txtCssStylesheetText.Text; } try { CssStylesheetInfoProvider.SetCssStylesheetInfo(si); ShowInformation(GetString("General.ChangesSaved")); // Reload header if changes were saved if (TabMode || !DialogMode) { ScriptHelper.RefreshTabHeader(Page, null); } // Ensure that selector has actual values if (DialogMode) { string selector = QueryHelper.GetString("selectorid", string.Empty); if (!string.IsNullOrEmpty(selector)) { // Selects newly created container in the UniSelector string script = string.Format(@"var wopener = window.top.opener ? window.top.opener : window.top.dialogArguments if (wopener && wopener.US_SelectNewValue_{0}) {{ wopener.US_SelectNewValue_{0}('{1}'); }}" , selector, QueryHelper.GetInteger("cssstylesheetid", -1)); ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", script, true); } } } catch (Exception ex) { ShowError(ex.Message.Replace("%%name%%", txtCssStylesheetName.Text)); return(false); } return(true); } return(false); }