Пример #1
0
    /// <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);
    }
Пример #2
0
    /// <summary>
    /// Adds css stylesheet to site. Called when the "Add stylesheet to site" button is pressed.
    /// Expects the CreateCssStylesheet method to be run first.
    /// </summary>
    private bool AddCssStylesheetToSite()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");

        if (stylesheet != null)
        {
            int stylesheetId = stylesheet.StylesheetID;
            int siteId       = SiteContext.CurrentSiteID;

            // Save the binding
            CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(stylesheetId, siteId);

            return(true);
        }

        return(false);
    }
Пример #3
0
    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);
    }
Пример #4
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);
                    CssStylesheetSiteInfoProvider.RemoveCssStylesheetFromSite(cssStylesheetId, siteId);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);
                    CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(cssStylesheetId, siteId);
                }
            }
        }

        lblInfo.Visible = true;
        lblInfo.Text    = GetString("General.ChangesSaved");
    }