Exemplo n.º 1
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);
    }