Exemplo n.º 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);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Provides version rollback. Called when the "Rollback version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool RollbackVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Prepare query parameters
            string where = "VersionObjectID =" + stylesheet.StylesheetID + " AND VersionObjectType = '" + stylesheet.ObjectType + "'";
            string orderBy = "VersionModifiedWhen ASC";
            int    topN    = 1;

            // Get dataset with versions according to the parameters
            DataSet versionDS = ObjectVersionHistoryInfoProvider.GetVersionHistories(where, orderBy, topN, null);

            if (!DataHelper.DataSourceIsEmpty(versionDS))
            {
                // Get version
                ObjectVersionHistoryInfo version = new ObjectVersionHistoryInfo(versionDS.Tables[0].Rows[0]);

                // Roll back
                ObjectVersionManager.RollbackVersion(version.VersionID);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Initializes HTML editor's settings.
    /// </summary>
    protected void InitHTMLeditor()
    {
        htmlEditor.AutoDetectLanguage = false;
        htmlEditor.DefaultLanguage    = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
        htmlEditor.ToolbarSet         = "BizForm";

        // Allow metafile attachments in media dialog
        if ((ObjectID > 0) && (!string.IsNullOrEmpty(ObjectType)) && (!string.IsNullOrEmpty(ObjectCategory)))
        {
            DialogConfiguration config = htmlEditor.MediaDialogConfig;
            config.MetaFileObjectID   = ObjectID;
            config.MetaFileObjectType = ObjectType;
            config.MetaFileCategory   = ObjectCategory;
            config.HideAttachments    = false;
        }

        // Load CSS style for editor area if any
        if (CssStyleSheetID > 0)
        {
            CssStylesheetInfo cssi = CssStylesheetInfoProvider.GetCssStylesheetInfo(CssStyleSheetID);
            if (cssi != null)
            {
                htmlEditor.EditorAreaCSS = CSSHelper.GetStylesheetUrl(cssi.StylesheetName);
            }
        }
    }
Exemplo n.º 4
0
    /// <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);
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // If ID�s not specified return
        if ((TemplateID == 0) || (GatewayID == 0))
        {
            return;
        }

        // Get gateway name
        NotificationGatewayInfo ngi = NotificationGatewayInfoProvider.GetNotificationGatewayInfo(GatewayID);

        if (ngi == null)
        {
            throw new Exception("NotificationGatewayInfo with this GatewayID does not exist.");
        }

        // Setup control according to NotificationGatewayInfo
        plcSubject.Visible   = ngi.GatewaySupportsEmail;
        plcPlainText.Visible = ngi.GatewaySupportsPlainText;
        plcHTMLText.Visible  = ngi.GatewaySupportsHTMLText;

        if (plcHTMLText.Visible)
        {
            // Initialize HTML editor
            htmlText.AutoDetectLanguage           = false;
            htmlText.DefaultLanguage              = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            htmlText.EditorAreaCSS                = CssStylesheetInfoProvider.GetHtmlEditorAreaCss(SiteContext.CurrentSiteName);
            htmlText.ToolbarSet                   = "Basic";
            htmlText.MediaDialogConfig.UseFullURL = true;
            htmlText.LinkDialogConfig.UseFullURL  = true;
            htmlText.QuickInsertConfig.UseFullURL = true;
        }

        // If gateway does not support any of text fields inform about it.
        if (!ngi.GatewaySupportsEmail && !ngi.GatewaySupportsHTMLText && !ngi.GatewaySupportsPlainText)
        {
            ShowWarning(string.Format(GetString("notifications.templatetext.notextbox"), HTMLHelper.HTMLEncode(ngi.GatewayDisplayName)));
        }

        // Get existing TemplateTextInfoObject or create new object
        NotificationTemplateTextInfo ntti = NotificationTemplateTextInfoProvider.GetNotificationTemplateTextInfo(GatewayID, TemplateID);

        if (ntti == null)
        {
            ntti = new NotificationTemplateTextInfo();
        }

        // Set edited object
        EditedObject = ntti;

        // Setup properties
        if (!URLHelper.IsPostback())
        {
            TemplateSubject   = ntti.TemplateSubject;
            TemplateHTMLText  = ntti.TemplateHTMLText;
            TemplatePlainText = ntti.TemplatePlainText;
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Deletes css stylesheet. Called when the "Delete stylesheet" button is pressed.
    /// Expects the CreateCssStylesheet method to be run first.
    /// </summary>
    private bool DeleteCssStylesheet()
    {
        // Get the css stylesheet
        CssStylesheetInfo deleteStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");

        // Delete the css stylesheet
        CssStylesheetInfoProvider.DeleteCssStylesheetInfo(deleteStylesheet);

        return(deleteStylesheet != null);
    }
 /// <summary>
 /// Handles the UniGrid's OnAction event.
 /// </summary>
 /// <param name="actionName">Name of item (button) that threw event</param>
 /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
 protected void UniGridRoles_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "edit")
     {
         URLHelper.Redirect("CssStylesheet_Edit.aspx?cssstylesheetid=" + actionArgument.ToString() + "&tabmode=1");
     }
     else if (actionName == "delete")
     {
         CssStylesheetInfoProvider.DeleteCssStylesheetInfo(Convert.ToInt32(actionArgument));
     }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Destroys version history. Called when the "Destroy history" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DestroyHistory()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Destroy version history
            ObjectVersionManager.DestroyObjectHistory(stylesheet.ObjectType, stylesheet.StylesheetID);

            return(true);
        }

        return(false);
    }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes HTML editor's settings.
 /// </summary>
 protected void InitHTMLEditor()
 {
     htmlContent.AutoDetectLanguage = false;
     htmlContent.DefaultLanguage    = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
     // Set direction
     htmlContent.ContentsLangDirection = LanguageDirection.LeftToRight;
     if (CultureHelper.IsPreferredCultureRTL())
     {
         htmlContent.ContentsLangDirection = LanguageDirection.RightToLeft;
     }
     if (SiteContext.CurrentSite != null)
     {
         htmlContent.EditorAreaCSS = CssStylesheetInfoProvider.GetHtmlEditorAreaCss(SiteContext.CurrentSiteName);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Returns CSS stylesheet for current page.
        /// Stylesheet can be:
        ///     - normal CSS of current page
        ///     - default CSS for all AMP pages
        ///     - CSS set as AMP stylesheet for current page
        /// </summary>
        private string GetStylesheetText()
        {
            string cssText = "";

            // Checking which CSS file to use
            ObjectQuery <AmpFilterInfo> q = AmpFilterInfoProvider.GetAmpFilters().WhereEquals("PageNodeGuid", DocumentContext.CurrentPageInfo.NodeGUID.ToString());
            AmpFilterInfo ampFilterInfo   = q.FirstOrDefault();

            bool useDefaultStylesheet = ampFilterInfo?.UseDefaultStylesheet ?? true;

            if (useDefaultStylesheet)
            {
                // Get the ID of default AMP CSS
                string defaultID = Settings.AmpFilterDefaultCSS;
                var    cssID     = ValidationHelper.GetInteger(defaultID, 0);

                // Default AMP CSS is not set, using ordinary CSS of current page
                if (cssID == 0)
                {
                    cssText = DocumentContext.CurrentDocumentStylesheet?.StylesheetText;
                }
                else
                {
                    // Use default AMP CSS stylesheet
                    var cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssID);
                    if (cssInfo != null)
                    {
                        cssText = cssInfo.StylesheetText;
                    }
                }
            }
            else
            {
                // Use specific AMP CSS set for this page
                int stylesheetID = ampFilterInfo?.StylesheetID ?? 0;
                var cssInfo      = CssStylesheetInfoProvider.GetCssStylesheetInfo(stylesheetID);
                if (cssInfo != null)
                {
                    cssText = cssInfo.StylesheetText;
                }
            }

            // Resolve macros
            cssText = MacroResolver.Resolve(cssText);

            // Resolve client URL
            return(HTMLHelper.ResolveCSSClientUrls(cssText, CMSHttpContext.Current.Request.Url.ToString()));
        }
Exemplo n.º 11
0
    /// <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);
    }
Exemplo n.º 12
0
    /// <summary>
    /// Handles OnBeforeDataLoad event of the UI form.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    protected void EditForm_OnBeforeDataLoad(object sender, EventArgs e)
    {
        if (!EditForm.IsInsertMode)
        {
            // Ensure that dynamic language exists
            string          lang = ValidationHelper.GetString(EditForm.GetDataValue("StylesheetDynamicLanguage"), String.Empty);
            CssPreprocessor prep = CssStylesheetInfoProvider.GetCssPreprocessor(lang);
            EditForm.Data["StylesheetDynamicLanguage"] = (prep != null) ? lang : CssStylesheetInfo.PLAIN_CSS;
        }

        // Set the flag in order to bypass additional logic in the case when no CSS preprocessor is registered
        if (CssStylesheetInfoProvider.CssPreprocessors.Count > 0)
        {
            plainCssOnly = false;
        }
    }
Exemplo n.º 13
0
    /// <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);
    }
Exemplo n.º 14
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);
    }
Exemplo n.º 15
0
    /// <summary>
    /// Retrieve the stylesheet either from the database or file if checked out.
    /// </summary>
    /// <param name="stylesheetName">Stylesheet's unique name</param>
    /// <returns>The stylesheet data (plain version only)</returns>
    private static CMSOutputResource GetStylesheet(string stylesheetName)
    {
        // Get the stylesheet
        CssStylesheetInfo stylesheetInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo(stylesheetName);

        if (stylesheetInfo == null)
        {
            return(null);
        }

        // Determine if the stylesheet is checked out or not
        string   checkedOutFile = URLHelper.GetPhysicalPath(stylesheetInfo.StylesheetCheckedOutFilename);
        string   stylesheet;
        DateTime lastModified;

        if ((stylesheetInfo.StylesheetCheckedOutByUserID > 0) &&
            (string.Equals(stylesheetInfo.StylesheetCheckedOutMachineName, HTTPHelper.MachineName, StringComparison.OrdinalIgnoreCase)) &&
            (File.Exists(checkedOutFile)))
        {
            // Read the stylesheet and timestamp from the checked out file
            using (StreamReader reader = StreamReader.New(checkedOutFile))
            {
                stylesheet = reader.ReadToEnd();
            }
            lastModified = File.GetLastWriteTime(checkedOutFile);
        }
        else
        {
            // Read the stylesheet and timestamp from database
            stylesheet   = stylesheetInfo.StylesheetText;
            lastModified = stylesheetInfo.StylesheetLastModified;
        }

        // Build the output
        CMSOutputResource resource = new CMSOutputResource()
        {
            Data         = HTMLHelper.ResolveCSSUrls(stylesheet, URLHelper.ApplicationPath),
            Name         = stylesheetInfo.StylesheetName,
            LastModified = lastModified,
            Etag         = stylesheetName,
        };

        return(resource);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Creates new version of the object. Called when the "Ensure version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool EnsureVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(stylesheet, CMSContext.CurrentSiteName))
            {
                // Ensure version
                ObjectVersionManager.EnsureVersion(stylesheet, false);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 17
0
    /// <summary>
    /// Deletes object. Called when the "Delete object" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DeleteObject()
    {
        // Get the css stylesheet
        CssStylesheetInfo deleteStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (deleteStylesheet != null)
        {
            // Check if restoring from recycle bin is allowed on current site
            if (ObjectVersionManager.AllowObjectRestore(deleteStylesheet, CMSContext.CurrentSiteName))
            {
                // Delete the css stylesheet
                CssStylesheetInfoProvider.DeleteCssStylesheetInfo(deleteStylesheet);

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// This method encapsulates both client- and server- side CSS processing.
    /// </summary>
    /// <param name="input">Stylesheet code in dynamic language syntax</param>
    /// <param name="language">CSS dynamic language</param>
    /// <param name="output">Plain CSS output</param>
    /// <param name="hiddenField">Hidden field that holds the result of client-side compilation</param>
    public static string ProcessCss(string input, string language, out string output, HiddenField hiddenField)
    {
        string          errorMessage = String.Empty;
        CssPreprocessor prep         = CssStylesheetInfoProvider.GetCssPreprocessor(language);

        EnsureClientSideCompiledCss(hiddenField);

        if (String.IsNullOrEmpty(CssPreprocessor.CurrentCompiledValue) || ((prep != null) && !prep.UsesClientSideCompilation))
        {
            // Parse the style sheet code server-side
            errorMessage = CssStylesheetInfoProvider.TryParseCss(input, language, out output);
            if (String.IsNullOrEmpty(errorMessage))
            {
                // Store last result
                CssPreprocessor.CurrentCompiledValue = output;
            }
        }
        else
        {
            // Use client-side parsed code
            output = CssPreprocessor.CurrentCompiledValue;

            // Check if client-side process result contains special sequence indicating that parser produced no output (this may not be an error)
            if (output.EqualsCSafe(BLANKOUTPUT))
            {
                output = String.Empty;
            }
            else
            {
                if ((prep != null) && (prep.GetErrorDescription != null))
                {
                    // Handle error
                    errorMessage = prep.GetErrorDescription(output);
                    if (!String.IsNullOrEmpty(errorMessage))
                    {
                        output = String.Empty;
                    }
                }
            }
        }

        return(errorMessage);
    }
Exemplo n.º 19
0
    /// <summary>
    /// Removes css stylesheet from site. Called when the "Remove stylesheet from site" button is pressed.
    /// Expects the AddCssStylesheetToSite method to be run first.
    /// </summary>
    private bool RemoveCssStylesheetFromSite()
    {
        // Get the css stylesheet
        CssStylesheetInfo removeStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");

        if (removeStylesheet != null)
        {
            int siteId = SiteContext.CurrentSiteID;

            // Get the binding
            CssStylesheetSiteInfo stylesheetSite = CssStylesheetSiteInfoProvider.GetCssStylesheetSiteInfo(removeStylesheet.StylesheetID, siteId);

            // Delete the binding
            CssStylesheetSiteInfoProvider.DeleteCssStylesheetSiteInfo(stylesheetSite);

            return(true);
        }

        return(false);
    }
Exemplo n.º 20
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);
    }
Exemplo n.º 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup the filesystem browser
        int cssStylesheetId = QueryHelper.GetInteger("cssstylesheetid", 0);

        if (cssStylesheetId > 0)
        {
            CssStylesheetInfo csi = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId);
            EditedObject = csi;

            if (csi != null)
            {
                // Ensure the theme folder
                themeElem.Path = csi.GetThemePath();
            }
        }
        else
        {
            EditedObject = null;
        }
    }
Exemplo n.º 22
0
    /// <summary>
    /// Returns the links to CSS files which should be used for displaying the page.
    /// </summary>
    private static string GetCssFileLink()
    {
        // Get stylesheet
        CssStylesheetInfo csi = null;

        if (CMSContext.CurrentPageInfo.DocumentStylesheetID > 0)
        {
            csi = CssStylesheetInfoProvider.GetCssStylesheetInfo(CMSContext.CurrentPageInfo.DocumentStylesheetID);
        }
        // If not found, get default stylesheet from the current site
        if ((csi == null) && (CMSContext.CurrentSite.SiteDefaultStylesheetID > 0))
        {
            csi = CssStylesheetInfoProvider.GetCssStylesheetInfo(CMSContext.CurrentSite.SiteDefaultStylesheetID);
        }
        // If stylesheet found, get the URL
        if (csi != null)
        {
            return(CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(csi.StylesheetName)));
        }
        return(null);
    }
Exemplo n.º 23
0
    /// <summary>
    /// Destroys latest version from history. Called when the "Destroy version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DestroyVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Get the latest version
            ObjectVersionHistoryInfo version = ObjectVersionManager.GetLatestVersion(stylesheet.ObjectType, stylesheet.StylesheetID);

            if (version != null)
            {
                // Destroy the latest version
                ObjectVersionManager.DestroyObjectVersion(version.VersionID);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 24
0
    /// <summary>
    /// Destroys object (without creating new version for recycle bin). Called when the "DestroyObject" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DestroyObject()
    {
        // Get the css stylesheet
        CssStylesheetInfo destroyStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (destroyStylesheet != null)
        {
            // Destroy the object (in action context with disabled creating of new versions for recycle bin)
            using (CMSActionContext context = new CMSActionContext())
            {
                // Disable creating of new versions
                context.CreateVersion = false;

                // Destroy the css stylesheet
                CssStylesheetInfoProvider.DeleteCssStylesheetInfo(destroyStylesheet);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 25
0
    /// <summary>
    /// Creates new version of the object. Called when the "Create version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool CreateVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo newStylesheetVersion = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (newStylesheetVersion != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(newStylesheetVersion, CMSContext.CurrentSiteName))
            {
                // Update the properties
                newStylesheetVersion.StylesheetDisplayName = newStylesheetVersion.StylesheetDisplayName.ToLower();

                // Create new version
                ObjectVersionManager.CreateVersion(newStylesheetVersion, true);

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Adds JavaScript code required for client-side compilation to the page.
    /// </summary>
    private void RegisterClientSideCompilationScript()
    {
        CssPreprocessor prep = CssStylesheetInfoProvider.GetCssPreprocessor(LanguageFieldValue);

        if (prep != null)
        {
            // Register client scripts
            if (prep.RegisterClientCompilationScripts != null)
            {
                prep.RegisterClientCompilationScripts();
            }
        }
        else
        {
            ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "CleanUpScript", "function GetCss() {}", true);
        }

        if (Editor != null)
        {
            ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "CompileScript", GetClientCompilationScript(Editor.ClientID, hidCompiledCss.ClientID), true);
        }
    }
Exemplo n.º 27
0
    /// <summary>
    /// Adds JavaScript code required for client-side compilation to the page.
    /// </summary>
    private void RegisterClientSideCompilationScript()
    {
        // Get dynamic language database value
        string originalLang = ValidationHelper.GetString(EditForm.GetDataValue("StylesheetDynamicLanguage"), CssStylesheetInfo.PLAIN_CSS);

        // Get dynamic language selected in the form
        string newLang = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicLanguage"), CssStylesheetInfo.PLAIN_CSS);

        CssPreprocessor prep = null;

        // Indicate post-back and that dynamic language has changed
        if (RequestHelper.IsPostBack() && !originalLang.EqualsCSafe(newLang, true))
        {
            /*
             * If the original language is plain CSS then load preprocessor according to new language. If the original language is dynamic then load
             * appropriate preprocessor and ignore selected new language.
             */
            prep = CssStylesheetInfoProvider.GetCssPreprocessor(originalLang) ?? CssStylesheetInfoProvider.GetCssPreprocessor(newLang);
        }
        else
        {
            prep = CssStylesheetInfoProvider.GetCssPreprocessor(newLang);
        }

        // Register client scripts for appropriate preprocessor
        if (prep != null)
        {
            if (prep.RegisterClientCompilationScripts != null)
            {
                prep.RegisterClientCompilationScripts(Page);
            }
        }

        if (Editor != null)
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "CompileScript", CSSStylesheetNewControlExtender.GetClientCompilationScript(Editor.ClientID, hidCompiledCss.ClientID), true);
        }
    }
Exemplo n.º 28
0
        /// <summary>
        /// Handles the Unigrid control's OnExternalDataBound event.
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="sourceName">Source name</param>
        /// <param name="parameter">Parameter object</param>
        private object Control_OnExternalDatabound(object sender, string sourceName, object parameter)
        {
            // Initializing variables
            string   nodeGuid;
            TreeNode tn;

            switch (sourceName)
            {
            case "pagename":
                // Gets the nodeGUID of the of the page
                nodeGuid = ValidationHelper.GetString(parameter, "");
                tn       = GetTreeNodeByGuid(nodeGuid);
                return(tn != null ? tn.DocumentName : nodeGuid);

            case "pagenamepath":
                // Gets the nodeGUID of the of the page
                nodeGuid = ValidationHelper.GetString(parameter, "");
                tn       = GetTreeNodeByGuid(nodeGuid);
                return(tn != null ? tn.DocumentNamePath : nodeGuid);

            case "pagecss":
                string cssName = "";
                // Gets the stylesheetID of the style assigned to current page
                int stylesheetID = ValidationHelper.GetInteger(parameter, 0);
                var cssInfo      = CssStylesheetInfoProvider.GetCssStylesheetInfo(stylesheetID);
                if (cssInfo != null)
                {
                    cssName = cssInfo.StylesheetDisplayName;
                }
                return((stylesheetID == 0) ? "" : cssName);

            case "usedefault":
                // Gets the nodeGUID of the of the page
                bool useDefault = ValidationHelper.GetBoolean(parameter, false);
                return(useDefault ? ResHelper.GetString("AcceleratedMobilePages.GridYes") : ResHelper.GetString("AcceleratedMobilePages.GridNo"));
            }
            return(parameter);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblAvialable.Text = GetString("CssStylesheet_Sites.Available");
        cssStylesheetId   = QueryHelper.GetInteger("cssstylesheetid", 0);
        if (cssStylesheetId > 0)
        {
            // Get the active sites
            DataSet ds = CssStylesheetSiteInfoProvider.GetCssStylesheetSites("SiteID", "StylesheetID = " + cssStylesheetId, null, 0);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "SiteID"));
            }

            if (!RequestHelper.IsPostBack())
            {
                usSites.Value = currentValues;
            }
        }

        usSites.IconPath            = GetImageUrl("Objects/CMS_Site/object.png");
        usSites.OnSelectionChanged += usSites_OnSelectionChanged;

        EditedObject = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId);
    }
Exemplo n.º 30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set control properties
        editor.AutoDetectLanguage = false;
        editor.DefaultLanguage    = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

        if (Form != null)
        {
            editor.DialogParameters = Form.DialogParameters;
        }

        // Get editor area toolbar
        editor.ToolbarSet      = DataHelper.GetNotEmpty(GetValue("toolbarset"), (Form != null) ? Form.HtmlAreaToolbar : String.Empty);
        editor.ToolbarLocation = DataHelper.GetNotEmpty(GetValue("toolbarlocation"), (Form != null) ? Form.HtmlAreaToolbarLocation : String.Empty);

        // Set form dimensions
        editor.Width  = Width;
        editor.Height = Height;

        // Get editor area starting path
        String startingPath = ValidationHelper.GetString(GetValue("startingpath"), String.Empty);

        editor.StartingPath = startingPath;

        // Set current context resolver
        editor.ResolverName = ResolverName;

        // Get editor area css file
        string cssStylesheet = ValidationHelper.GetString(GetValue("cssstylesheet"), String.Empty);

        if (!String.IsNullOrEmpty(cssStylesheet))
        {
            editor.EditorAreaCSS = CSSHelper.GetStylesheetUrl(cssStylesheet);
        }
        else if (SiteContext.CurrentSite != null)
        {
            editor.EditorAreaCSS = CssStylesheetInfoProvider.GetHtmlEditorAreaCss(SiteContext.CurrentSiteName);
        }

        // Set live site info
        editor.IsLiveSite = IsLiveSite;

        // Set direction
        editor.ContentsLangDirection = CultureHelper.IsPreferredCultureRTL() ? LanguageDirection.RightToLeft : LanguageDirection.LeftToRight;

        // Get dialog configuration
        DialogConfiguration mediaConfig = GetDialogConfiguration();

        if (mediaConfig != null)
        {
            // Override starting path from main configuration
            if (!String.IsNullOrEmpty(startingPath))
            {
                mediaConfig.ContentStartingPath = startingPath;
                mediaConfig.LibStartingPath     = startingPath;
            }

            // Set configuration for 'Insert image or media' dialog
            editor.MediaDialogConfig = mediaConfig;
            // Set configuration for 'Insert link' dialog
            editor.LinkDialogConfig = mediaConfig.Clone();
            // Set configuration for 'Quickly insert image' dialog
            editor.QuickInsertConfig = mediaConfig.Clone();
        }

        // Set CSS settings
        if (!String.IsNullOrEmpty(ControlStyle))
        {
            editor.Attributes.Add("style", ControlStyle);
            ControlStyle = null;
        }
        if (!String.IsNullOrEmpty(CssClass))
        {
            editor.CssClass = CssClass;
        }

        CheckRegularExpression = true;
        CheckFieldEmptiness    = true;

        if (ShowAddStampButton)
        {
            //Add stamp button
            RegisterAndShowStampButton();
        }
    }