コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #2
0
ファイル: Layout.ascx.cs プロジェクト: SMEWebmaster/Kentico16
    /// <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);
            }
        }
    }
コード例 #3
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);
    }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #5
0
ファイル: AmpFilter.cs プロジェクト: websedev/kentico-amp
        /// <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()));
        }
コード例 #6
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);
    }
コード例 #7
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);
    }
コード例 #8
0
ファイル: GetResource.ashx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #9
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #10
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #11
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);
    }
コード例 #12
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);
    }
コード例 #13
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #14
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;
        }
    }
コード例 #15
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #16
0
ファイル: Default.aspx.cs プロジェクト: kudutest2/Kentico
    /// <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);
    }
コード例 #17
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);
        }
コード例 #18
0
    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);
    }
コード例 #19
0
    protected override void OnPreInit(EventArgs e)
    {
        RequireSite = false;

        // Check for UI permissions
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design", "Design.EditCSSStylesheets" }, CMSContext.CurrentSiteName))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Properties;Properties.General;General.Design;Design.EditCSSStylesheets");
        }

        // Page has been opened in CMSDesk and only stylesheet style editing is allowed
        requiresDialog = QueryHelper.GetBoolean("editonlycode", false);

        if (requiresDialog)
        {
            // Check hash
            if (!QueryHelper.ValidateHash("hash", "saved;cssstylesheetid;selectorid;tabmode;siteid;aliaspath;line", true, true, true))
            {
                URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("dialogs.badhashtitle"), ResHelper.GetString("dialogs.badhashtext"))));
            }

            // Check 'Design Web site' permission if opened from CMS Desk
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Design", "Design"))
            {
                RedirectToCMSDeskAccessDenied("CMS.Design", "Design");
            }
        }
        else
        {
            CheckAccessToSiteManager();
        }

        string stylesheet = QueryHelper.GetString("cssstylesheetid", "0");

        // If default stylesheet defined and selected, choose it
        if (stylesheet == "default")
        {
            si = CMSContext.CurrentSiteStylesheet;
        }

        // Default stylesheet not selected try to find stylesheet selected
        if (si != null)
        {
            cssStylesheetId = si.StylesheetID;
        }
        else
        {
            cssStylesheetId = ValidationHelper.GetInteger(stylesheet, 0);
            if (cssStylesheetId > 0)
            {
                // Get the stylesheet
                si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId);
            }
        }

        SetEditedObject(si, "CssStylesheet_Edit.aspx");

        var checkSiteAssociation = QueryHelper.GetBoolean("checksiteassociation", true);

        if ((si != null) && requiresDialog && checkSiteAssociation)
        {
            // Check if stylesheet is under current site
            int siteId = (CurrentSite != null) ? CurrentSite.SiteID : 0;
            string where = SqlHelperClass.AddWhereCondition("SiteID = " + siteId, "StylesheetID = " + si.StylesheetID);
            DataSet ds = CssStylesheetSiteInfoProvider.GetCssStylesheetSites("StylesheetID", where, null, 1);
            if (DataHelper.DataSourceIsEmpty(ds))
            {
                URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("cssstylesheet.errorediting"), ResHelper.GetString("cssstylesheet.notallowedtoedit"))));
            }
        }

        base.OnPreInit(e);
    }
コード例 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var previewState = GetPreviewStateFromCookies(MASTERPAGE);

        // Keep current user
        var user = MembershipContext.AuthenticatedUser;

        // Get document node
        tree = new TreeProvider(user);
        node = UIContext.EditedObject as TreeNode;

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Register save changes
        ScriptHelper.RegisterSaveChanges(Page);

        // Save changes support
        bool   confirmChanges = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script  = "CMSContentManager.confirmLeave=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode), true, false) + "; \n";
            script += "CMSContentManager.confirmLeaveShort=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeaveShort", user.PreferredUICultureCode), true, false) + "; \n";
        }
        else
        {
            script += "CMSContentManager.confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", script, true);

        try
        {
            if (node != null)
            {
                DocumentContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, null, node.NodeID, false);

                // Title
                string title = DocumentContext.CurrentTitle;
                if (!string.IsNullOrEmpty(title))
                {
                    title = "<title>" + title + "</title>";
                }

                // Body class
                string bodyCss = DocumentContext.CurrentBodyClass;

                if (bodyCss != null && bodyCss.Trim() != "")
                {
                    bodyCss = "class=\"" + bodyCss + "\"";
                }
                else
                {
                    bodyCss = "";
                }

                // Metadata
                string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

                string description = DocumentContext.CurrentDescription;
                if (description != "")
                {
                    meta += "<meta name=\"description\" content=\"" + description + "\" />";
                }

                string keywords = DocumentContext.CurrentKeyWords;
                if (keywords != "")
                {
                    meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
                }

                // Site style sheet
                string cssSiteSheet = "";

                int stylesheetId = DocumentContext.CurrentPageInfo.DocumentStylesheetID;

                CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : SiteContext.CurrentSite.SiteDefaultStylesheetID);

                if (cssInfo != null)
                {
                    cssSiteSheet = CssLinkHelper.GetCssFileLink(CssLinkHelper.GetStylesheetUrl(cssInfo.StylesheetName));
                }

                // Theme CSS files
                string themeCssFiles = "";
                if (cssInfo != null)
                {
                    try
                    {
                        string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                        if (Directory.Exists(directory))
                        {
                            foreach (string file in Directory.GetFiles(directory, "*.css"))
                            {
                                themeCssFiles += CssLinkHelper.GetCssFileLink(CssLinkHelper.GetPhysicalCssUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Add values to page
                mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
                mBody = bodyCss;
            }
        }
        catch
        {
            ShowError(GetString("MasterPage.PageEditErr"));
        }

        LoadData();

        // Add save action
        SaveAction save = new SaveAction();

        save.CommandArgument = ComponentEvents.SAVE_DATA;
        save.CommandName     = ComponentEvents.SAVE_DATA;

        headerActions.ActionsList.Add(save);

        if (pti != null)
        {
            // Disable buttons for no-template
            bool actionsEnabled = (pti.PageTemplateId > 0);

            // Edit layout
            HeaderAction action = new HeaderAction
            {
                Text          = GetString("content.ui.pagelayout"),
                Tooltip       = GetString("pageplaceholder.editlayouttooltip"),
                OnClientClick = "EditLayout();return false;",
                Enabled       = actionsEnabled
            };
            headerActions.ActionsList.Add(action);

            string elemUrl = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", pti.PageTemplateId);

            // Edit page properties action
            action = new HeaderAction
            {
                Text          = GetString("PageProperties.EditTemplateProperties"),
                Tooltip       = GetString("PageProperties.EditTemplateProperties"),
                OnClientClick = "modalDialog('" + elemUrl + "', 'TemplateSelection', '85%', '85%');return false;",
                Enabled       = actionsEnabled
            };

            CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null);
            headerActions.ActionsList.Add(action);

            // Preview
            HeaderAction preview = new HeaderAction
            {
                Text          = GetString("general.preview"),
                OnClientClick = "performToolbarAction('split');return false;",
                Visible       = ((previewState == 0) && !PortalUIHelper.DisplaySplitMode),
                Tooltip       = GetString("preview.tooltip")
            };
            headerActions.ActionsList.Add(preview);

            headerActions.ActionPerformed += headerActions_ActionPerformed;
        }

        RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false);
    }
コード例 #21
0
ファイル: Layout.ascx.cs プロジェクト: tvelzy/RadstackMedia
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register a script file
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/AdminControls/Controls/Class/layout.js");

        // Add save action
        save = new SaveAction(Page);
        menu.ActionsList.Insert(0, save);

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        lblAvailableFields.Text    = GetString("DocumentType_Edit_Form.AvailableFields");
        btnGenerateLayout.Text     = GetString("DocumentType_Edit_Form.btnGenerateLayout");
        btnInsertLabel.Text        = GetString("DocumentType_Edit_Form.btnInsertLabel");
        btnInsertInput.Text        = GetString("DocumentType_Edit_Form.btnInsertInput");
        btnInsertValLabel.Text     = GetString("DocumentType_Edit_Form.InsertValidationLabel");
        btnInsertSubmitButton.Text = GetString("DocumentType_Edit_Form.InsertSubmitButton");
        btnInsertVisibility.Text   = GetString("DocumentType_Edit_Form.InsertVisibility");
        chkCustomLayout.Text       = GetString("DocumentType_Edit_Form.chkCustomLayout");

        // Alert messages for JavaScript
        ltlAlertExist.Text      = "<input type=\"hidden\" id=\"alertexist\" value=\"" + GetString("DocumentType_Edit_Form.AlertExist") + "\">";
        ltlAlertExistFinal.Text = "<input type=\"hidden\" id=\"alertexistfinal\" value=\"" + GetString("DocumentType_Edit_Form.AlertExistFinal") + "\">";
        ltlConfirmDelete.Text   = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("DocumentType_Edit_Form.ConfirmDelete") + "\">";

        // Element IDs
        ltlAvailFieldsElement.Text = ScriptHelper.GetScript("var lstAvailFieldsElem = document.getElementById('" + lstAvailableFields.ClientID + "'); ");
        ltlHtmlEditorID.Text       = ScriptHelper.GetScript("var ckEditorID = '" + htmlEditor.ClientID + "'; ");

        if (!RequestHelper.IsPostBack())
        {
            FillFieldsList();
            LoadData();
            chkCustomLayout.Checked = LayoutIsSet;
        }

        InitHTMLeditor();

        // 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);
            }
        }

        pnlCustomLayout.Visible = chkCustomLayout.Checked;

        // Custom table forms use default submit button in header actions
        plcSubmitButton.Visible = (FormType != FORMTYPE_CUSTOMTABLE);

        // Display button for inserting visibility macros only if enabled and the class is 'cms.user'
        if (IsAlternative)
        {
            DataClassInfo dci = DataClassInfoProvider.GetDataClass(DataClassID);
            if ((dci != null) && (dci.ClassName.ToLowerCSafe() == "cms.user"))
            {
                plcVisibility.Visible = true;
            }
        }
    }
コード例 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSContext.ViewMode = ViewModeEnum.MasterPage;

        // Keep current user
        user = CMSContext.CurrentUser;

        // Check UIProfile
        if (!user.IsAuthorizedPerUIElement("CMS.Content", "MasterPage"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "MasterPage");
        }

        // Check "Design" permission
        if (!user.IsAuthorizedPerResource("CMS.Design", "Design"))
        {
            RedirectToAccessDenied("CMS.Design", "Design");
        }

        // Register the scripts
        ScriptHelper.RegisterProgress(this);
        ScriptHelper.RegisterSaveShortcut(btnSave, null, false);

        // Save changes support
        bool   confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n";
        }
        else
        {
            script += "confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script));

        nodeId = QueryHelper.GetInteger("NodeId", 0);

        try
        {
            CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, "/", CMSContext.PreferredCultureCode, null, false);

            // Title
            string title = CMSContext.CurrentTitle;
            if (!string.IsNullOrEmpty(title))
            {
                title = "<title>" + title + "</title>";
            }

            // Body class
            string bodyCss = CMSContext.CurrentBodyClass;
            if (bodyCss != null && bodyCss.Trim() != "")
            {
                bodyCss = "class=\"" + bodyCss + "\"";
            }
            else
            {
                bodyCss = "";
            }

            // metadata
            string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

            string description = CMSContext.CurrentDescription;
            if (description != "")
            {
                meta += "<meta name=\"description\" content=\"" + description + "\" />";
            }

            string keywords = CMSContext.CurrentKeyWords;
            if (keywords != "")
            {
                meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
            }

            // Site style sheet
            string cssSiteSheet = "";

            CssStylesheetInfo cssInfo = null;
            int stylesheetId          = CMSContext.CurrentPageInfo.DocumentStylesheetID;

            cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID);

            if (cssInfo != null)
            {
                cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName));
            }

            // Theme css files
            string themeCssFiles = "";
            if (cssInfo != null)
            {
                try
                {
                    string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                    if (Directory.Exists(directory))
                    {
                        foreach (string file in Directory.GetFiles(directory, "*.css"))
                        {
                            themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                        }
                    }
                }
                catch
                {
                }
            }

            // Add values to page
            mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
            mBody = bodyCss;
        }
        catch
        {
            lblError.Visible = true;
            lblError.Text    = GetString("MasterPage.PageEditErr");
        }

        // Prepare the hints and typw dropdown
        lblType.Text = ResHelper.GetString("PageLayout.Type");

        if (drpType.Items.Count == 0)
        {
            drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Ascx"), TransformationTypeEnum.Ascx.ToString()));
            drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Html"), TransformationTypeEnum.Html.ToString()));
        }

        string lang = ValidationHelper.GetString(SettingsHelper.AppSettings["CMSProgrammingLanguage"], "C#");

        ltlDirectives.Text = "&lt;%@ Control Language=\"" + lang + "\" ClassName=\"Simple\" Inherits=\"CMS.PortalControls.CMSAbstractLayout\" %&gt;<br />&lt;%@ Register Assembly=\"CMS.PortalControls\" Namespace=\"CMS.PortalControls\" TagPrefix=\"cc1\" %&gt;";

        if (!SettingsKeyProvider.UsingVirtualPathProvider)
        {
            lblChecked.Visible = true;
            lblChecked.Text    = "<br />" + AddSpaces(2) + GetString("MasterPage.VirtualPathProviderNotRunning");
            txtLayout.ReadOnly = true;
        }

        LoadData();

        // Register synchronization script for split mode
        if (CMSContext.DisplaySplitMode)
        {
            RegisterSplitModeSync(true, false);
        }
    }
コード例 #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterResizeHeaders();

        CMSContext.ViewMode = ViewModeEnum.MasterPage;
        previewState        = GetPreviewStateFromCookies(MASTERPAGE);

        // Keep current user
        user = CMSContext.CurrentUser;

        // Get document node
        tree = new TreeProvider(user);
        node = CMSContext.EditedObject as TreeNode;

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Register save changes
        ScriptHelper.RegisterSaveChanges(Page);

        // Save changes support
        bool   confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n";
        }
        else
        {
            script += "confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script));

        try
        {
            if (node != null)
            {
                CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, node.NodeAliasPath, node.DocumentCulture, null, false);

                // Title
                string title = CMSContext.CurrentTitle;
                if (!string.IsNullOrEmpty(title))
                {
                    title = "<title>" + title + "</title>";
                }

                // Body class
                string bodyCss = CMSContext.CurrentBodyClass;
                if (bodyCss != null && bodyCss.Trim() != "")
                {
                    bodyCss = "class=\"" + bodyCss + "\"";
                }
                else
                {
                    bodyCss = "";
                }

                // Metadata
                string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

                string description = CMSContext.CurrentDescription;
                if (description != "")
                {
                    meta += "<meta name=\"description\" content=\"" + description + "\" />";
                }

                string keywords = CMSContext.CurrentKeyWords;
                if (keywords != "")
                {
                    meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
                }

                // Site style sheet
                string cssSiteSheet = "";

                int stylesheetId = CMSContext.CurrentPageInfo.DocumentStylesheetID;

                CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID);

                if (cssInfo != null)
                {
                    cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName));
                }

                // Theme CSS files
                string themeCssFiles = "";
                if (cssInfo != null)
                {
                    try
                    {
                        string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                        if (Directory.Exists(directory))
                        {
                            foreach (string file in Directory.GetFiles(directory, "*.css"))
                            {
                                themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Add values to page
                mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
                mBody = bodyCss;
            }
        }
        catch
        {
            ShowError(GetString("MasterPage.PageEditErr"));
        }


        LoadData();

        // Add save action
        SaveAction save = new SaveAction(Page);

        save.CommandArgument = ComponentEvents.SAVE_DATA;
        save.CommandName     = ComponentEvents.SAVE_DATA;

        headerActions.ActionsList.Add(save);

        if (pti != null)
        {
            // Edit layout
            HeaderAction action = new HeaderAction
            {
                Text          = GetString("content.ui.pagelayout"),
                Tooltip       = GetString("pageplaceholder.editlayouttooltip"),
                OnClientClick = "EditLayout();return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/Edit.png")
            };
            headerActions.ActionsList.Add(action);

            // Edit page properties action
            action = new HeaderAction
            {
                Text          = GetString("PageProperties.EditTemplateProperties"),
                Tooltip       = GetString("PageProperties.EditTemplateProperties"),
                OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "?templateid=" + pti.PageTemplateId + "&nobreadcrumbs=1&dialog=1', 'TemplateSelection', 850, 680, false);return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Template/edit.png")
            };

            CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null);
            headerActions.ActionsList.Add(action);

            // Preview
            HeaderAction preview = new HeaderAction
            {
                ControlType   = HeaderActionTypeEnum.LinkButton,
                Text          = GetString("general.preview"),
                OnClientClick = "performToolbarAction('split');return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/Preview.png"),
                SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/Preview.png"),
                Visible       = ((previewState == 0) && !CMSContext.DisplaySplitMode),
                Tooltip       = GetString("preview.tooltip")
            };
            headerActions.ActionsList.Add(preview);

            headerActions.ActionPerformed += new CommandEventHandler(headerActions_ActionPerformed);
        }

        RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false);
    }
コード例 #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblCssStylesheetDisplayName.Text = GetString("CssStylesheet_General.DisplayName");
        lblCssStylesheetName.Text        = GetString("CssStylesheet_General.Name");
        lblCssStylesheetText.Text        = GetString("CssStylesheet_General.Text");

        rfvDisplayName.ErrorMessage = GetString("CssStylesheet_General.EmptyDisplayName");
        rfvName.ErrorMessage        = GetString("CssStylesheet_General.EmptyName");

        if (QueryHelper.GetString("saved", string.Empty) != string.Empty)
        {
            ShowInformation(GetString("General.ChangesSaved"));

            // Reload header if changes were saved
            if (TabMode || !DialogMode)
            {
                ScriptHelper.RefreshTabHeader(Page, null);
            }
        }

        string            stylesheet = QueryHelper.GetString("cssstylesheetid", "0");
        CssStylesheetInfo si         = null;

        // If default stylesheet defined and selected, choose it
        if (stylesheet == "default")
        {
            si = CMSContext.CurrentSiteStylesheet;
        }

        // Default stylesheet not selected try to find stylesheet selected
        if (si != null)
        {
            cssStylesheetId = si.StylesheetID;
            SetEditedObject(si, "CssStylesheet_Edit.aspx");
        }
        else
        {
            cssStylesheetId = ValidationHelper.GetInteger(stylesheet, 0);
            if (cssStylesheetId > 0)
            {
                // Get the stylesheet
                si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId);
                SetEditedObject(si, "CssStylesheet_Edit.aspx");
            }
        }

        if (si != null)
        {
            // Page has been opened in CMSDesk and only stylesheet style editing is allowed
            if (DialogMode)
            {
                SetDialogMode(si);
            }
            else
            {
                // Otherwise the user must be global admin
                CheckGlobalAdministrator();
            }

            if (!RequestHelper.IsPostBack())
            {
                txtCssStylesheetDisplayName.Text = si.StylesheetDisplayName;
                txtCssStylesheetName.Text        = si.StylesheetName;
                txtCssStylesheetText.Text        = si.StylesheetText;
            }

            if (si.StylesheetCheckedOutByUserID > 0)
            {
                txtCssStylesheetText.ReadOnly = true;
                string   username = null;
                UserInfo ui       = UserInfoProvider.GetUserInfo(si.StylesheetCheckedOutByUserID);
                if (ui != null)
                {
                    username = HTMLHelper.HTMLEncode(ui.FullName);
                }

                // Checked out by current machine
                if (string.Equals(si.StylesheetCheckedOutMachineName, HTTPHelper.MachineName, StringComparison.OrdinalIgnoreCase))
                {
                    lblCheckOutInfo.Text = string.Format(GetString("CssStylesheet.CheckedOut"), Server.MapPath(si.StylesheetCheckedOutFilename));
                }
                else
                {
                    lblCheckOutInfo.Text = string.Format(GetString("CssStylesheet.CheckedOutOnAnotherMachine"), HTMLHelper.HTMLEncode(si.StylesheetCheckedOutMachineName), username);
                }
            }
            else
            {
                lblCheckOutInfo.Text = string.Format(GetString("CssStylesheet.CheckOutInfo"), Server.MapPath(CssStylesheetInfoProvider.GetVirtualStylesheetUrl(si.StylesheetName, null)));
            }
        }

        InitializeHeaderActions(si);
    }
コード例 #25
0
    /// <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);
    }
コード例 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register a script file
        ScriptHelper.RegisterScriptFile(this.Page, "~/CMSModules/AdminControls/Controls/Class/layout.js");

        mSave = GetString("general.save");

        lblAvailableFields.Text    = GetString("DocumentType_Edit_Form.AvailableFields");
        btnGenerateLayout.Text     = GetString("DocumentType_Edit_Form.btnGenerateLayout");
        btnInsertLabel.Text        = GetString("DocumentType_Edit_Form.btnInsertLabel");
        btnInsertInput.Text        = GetString("DocumentType_Edit_Form.btnInsertInput");
        btnInsertValLabel.Text     = GetString("DocumentType_Edit_Form.InsertValidationLabel");
        btnInsertSubmitButton.Text = GetString("DocumentType_Edit_Form.InsertSubmitButton");
        btnInsertVisibility.Text   = GetString("DocumentType_Edit_Form.InsertVisibility");
        chkCustomLayout.Text       = GetString("DocumentType_Edit_Form.chkCustomLayout");

        // Alert messages for JavaScript
        ltlAlertExist.Text      = "<input type=\"hidden\" id=\"alertexist\" value=\"" + GetString("DocumentType_Edit_Form.AlertExist") + "\">";
        ltlAlertExistFinal.Text = "<input type=\"hidden\" id=\"alertexistfinal\" value=\"" + GetString("DocumentType_Edit_Form.AlertExistFinal") + "\">";
        ltlConfirmDelete.Text   = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("DocumentType_Edit_Form.ConfirmDelete") + "\">";

        // Element IDs
        ltlAvailFieldsElement.Text = ScriptHelper.GetScript("var lstAvailFieldsElem = document.getElementById('" + lstAvailableFields.ClientID + "'); ");
        ltlHtmlEditorID.Text       = ScriptHelper.GetScript("var ckEditorID = '" + htmlEditor.ClientID + "'; ");

        if (!RequestHelper.IsPostBack())
        {
            InitHTMLeditor();
            FillFieldsList();
            LoadData();
            chkCustomLayout.Checked = LayoutIsSet;
        }

        // 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);
            }
        }

        // Saving when layout editor is hidden
        if (!CustomLayoutEnabled)
        {
            lnkSave.OnClientClick = " SaveDocument(); return false; ";
        }
        else
        {
            lnkSave.OnClientClick = " return CheckContent(); ";
        }

        pnlCustomLayout.Visible = chkCustomLayout.Checked;

        imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");

        lnkSave.Click += new EventHandler(lnkSave_Click);

        // Display button for inserting visibility macros only if enabled and the class is 'cms.user'
        if (IsAlternative)
        {
            DataClassInfo dci = DataClassInfoProvider.GetDataClass(DataClassID);
            if ((dci != null) && (dci.ClassName.ToLower() == "cms.user"))
            {
                plcVisibility.Visible = true;
            }
        }
    }
コード例 #27
0
    protected override void OnPreInit(EventArgs e)
    {
        RequireSite = false;

        CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser;

        // Check for UI permissions
        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design", "Design.EditCSSStylesheets" }, SiteContext.CurrentSiteName))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "Properties;Properties.General;General.Design;Design.EditCSSStylesheets");
        }

        // Page has been opened in CMSDesk and only stylesheet style editing is allowed
        isDialog = (QueryHelper.GetBoolean("dialog", false) || QueryHelper.GetBoolean("isindialog", false));

        // Prevent replacing of the master page with dialog master page
        RequiresDialog = false;

        if (isDialog)
        {
            // Check hash
            if (!QueryHelper.ValidateHash("hash", "objectid", true, true, true))
            {
                URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("dialogs.badhashtitle"), ResHelper.GetString("dialogs.badhashtext"))));
            }

            // Check 'Design Web site' permission
            if (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design"))
            {
                RedirectToAccessDenied("CMS.Design", "Design");
            }
        }
        else
        {
            CheckGlobalAdministrator();
        }

        string stylesheet = QueryHelper.GetString("objectid", "0");

        // If default stylesheet defined and selected, choose it
        if (stylesheet == "default")
        {
            si = PortalContext.CurrentSiteStylesheet;
        }

        // Default stylesheet not selected try to find stylesheet selected
        if (si != null)
        {
            cssStylesheetId = si.StylesheetID;
        }
        else
        {
            cssStylesheetId = ValidationHelper.GetInteger(stylesheet, 0);
            if (cssStylesheetId > 0)
            {
                // Get the stylesheet
                si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId);
            }
        }

        SetEditedObject(si, null);

        // Check site association in case that user is not admin
        var checkSiteAssociation = !currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin);

        if ((si != null) && isDialog && checkSiteAssociation)
        {
            // Check if stylesheet is under current site
            int     siteId = (CurrentSite != null) ? CurrentSite.SiteID : 0;
            DataSet ds     = CssStylesheetSiteInfoProvider.GetCssStylesheetSites()
                             .WhereEquals("SiteID", siteId)
                             .WhereEquals("StylesheetID", si.StylesheetID)
                             .TopN(1);

            if (DataHelper.DataSourceIsEmpty(ds))
            {
                URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("cssstylesheet.errorediting"), ResHelper.GetString("cssstylesheet.notallowedtoedit"))));
            }
        }

        base.OnPreInit(e);
    }