protected bool ShowSwitchLanguagesPanel()
        {
            if (this.PortalSettings.AllowUserUICulture && this.PortalSettings.ContentLocalizationEnabled)
            {
                if (this.CurrentUICulture == null)
                {
                    object oCulture = Personalization.GetProfile("Usability", "UICulture");

                    if (oCulture != null)
                    {
                        this.CurrentUICulture = oCulture.ToString();
                    }
                    else
                    {
                        var l = new Localization();
                        this.CurrentUICulture = l.CurrentUICulture;
                    }
                }

                IEnumerable <ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, this.CurrentUICulture, string.Empty, false);
                return(cultureListItems.Count() > 1);
            }

            return(false);
        }
        public string RaiseClientAPICallbackEvent(string eventArgument)
        {
            var dict = ParsePageCallBackArgs(eventArgument);

            if (dict.ContainsKey("type"))
            {
                if (DNNClientAPI.IsPersonalizationKeyRegistered(dict["namingcontainer"] + ClientAPI.CUSTOM_COLUMN_DELIMITER + dict["key"]) == false)
                {
                    throw new Exception(string.Format("This personalization key has not been enabled ({0}:{1}).  Make sure you enable it with DNNClientAPI.EnableClientPersonalization", dict["namingcontainer"], dict["key"]));
                }
                switch ((DNNClientAPI.PageCallBackType)Enum.Parse(typeof(DNNClientAPI.PageCallBackType), dict["type"]))
                {
                case DNNClientAPI.PageCallBackType.GetPersonalization:
                    return(Personalization.GetProfile(dict["namingcontainer"], dict["key"]).ToString());

                case DNNClientAPI.PageCallBackType.SetPersonalization:
                    Personalization.SetProfile(dict["namingcontainer"], dict["key"], dict["value"]);
                    return(dict["value"]);

                default:
                    throw new Exception("Unknown Callback Type");
                }
            }
            return("");
        }
示例#3
0
        public UserSettings GetPersonaBarUserSettings()
        {
            var settings = (UserSettings)Personalization.GetProfile(ContainerName, UserSettingsKey);

            FixUserSettingsDates(settings);
            return(settings ?? GetDefaultSettings());
        }
        protected void languagesGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            var gridItem = e.Item as GridDataItem;

            if (gridItem != null)
            {
                var locale = gridItem.DataItem as Locale;
                if (locale != null)
                {
                    var localizeLinkAlt = gridItem.FindControl("localizeLinkAlt") as HyperLink;
                    if (localizeLinkAlt != null)
                    {
                        localizeLinkAlt.NavigateUrl = ModuleContext.NavigateUrl(ModuleContext.TabId,
                                                                                "LocalizePages",
                                                                                false,
                                                                                "mid=" + ModuleContext.ModuleId,
                                                                                "locale=" + locale.Code);
                    }
                    var localizeLink = gridItem.FindControl("localizeLink") as HyperLink;
                    if (localizeLink != null)
                    {
                        CultureDropDownTypes DisplayType;
                        string _ViewType = Convert.ToString(Personalization.GetProfile("LanguageDisplayMode", "ViewType" + PortalId));
                        switch (_ViewType)
                        {
                        case "NATIVE":
                            DisplayType = CultureDropDownTypes.NativeName;
                            break;

                        case "ENGLISH":
                            DisplayType = CultureDropDownTypes.EnglishName;
                            break;

                        default:
                            DisplayType = CultureDropDownTypes.DisplayName;
                            break;
                        }

                        localizeLink.NavigateUrl = ModuleContext.NavigateUrl(ModuleContext.TabId,
                                                                             "LocalizePages",
                                                                             false,
                                                                             "mid=" + ModuleContext.ModuleId,
                                                                             "locale=" + locale.Code);

                        var publishButton = gridItem.FindControl("publishButton") as ImageButton;
                        if (publishButton != null)
                        {
                            string msgPublish = String.Format(LocalizeString("Publish.Confirm"), Localization.GetLocaleName(locale.Code, DisplayType));
                            msgPublish = msgPublish.Replace("'", "\'");
                            msgPublish = Localization.GetSafeJSString(msgPublish);
                            publishButton.Attributes.Add("onclick", "alert('" + msgPublish + "');");
                        }
                    }
                }
            }
        }
示例#5
0
        private void ProcessDragTipShown(Container moduleContainer)
        {
            var dragTipShown = Convert.ToString(Personalization.GetProfile("Usability", "DragTipShown" + PortalSettings.PortalId));

            if (string.IsNullOrEmpty(dragTipShown) && moduleContainer.Parent is HtmlContainerControl && Request.Cookies["noFloat"] == null)
            {
                Personalization.SetProfile("Usability", "DragTipShown" + PortalSettings.PortalId, "true");
                ((HtmlContainerControl)moduleContainer.Parent).Attributes["class"] += " dragtip";
            }
        }
示例#6
0
        public static bool MinMaxContentVisibile(Control objButton, int intModuleId, bool blnDefaultMin, MinMaxPersistanceType ePersistanceType)
        {
            if (HttpContext.Current != null)
            {
                switch (ePersistanceType)
                {
                case MinMaxPersistanceType.Page:
                    string sExpanded = ClientAPI.GetClientVariable(objButton.Page, objButton.ClientID + ":exp");
                    if (!string.IsNullOrEmpty(sExpanded))
                    {
                        return(sExpanded == "1" ? true : false);
                    }
                    else
                    {
                        return(!blnDefaultMin);
                    }

                case MinMaxPersistanceType.Cookie:
                    if (intModuleId != -1)
                    {
                        HttpCookie objModuleVisible = HttpContext.Current.Request.Cookies["_Module" + intModuleId + "_Visible"];
                        if (objModuleVisible != null)
                        {
                            return(objModuleVisible.Value != "false");
                        }
                        else
                        {
                            return(!blnDefaultMin);
                        }
                    }
                    else
                    {
                        return(true);
                    }

                case MinMaxPersistanceType.Personalization:
                    string strVisible = Convert.ToString(Personalization.GetProfile(Globals.GetAttribute(objButton, "userctr"), Globals.GetAttribute(objButton, "userkey")));
                    if (string.IsNullOrEmpty(strVisible))
                    {
                        return(blnDefaultMin);
                    }
                    else
                    {
                        return(Convert.ToBoolean(strVisible));
                    }

                default:
                    return(!blnDefaultMin);
                }
            }

            return(Null.NullBoolean);
        }
示例#7
0
        protected void Page_Init(Object sender, EventArgs e)
        {
            LogController l = new LogController();

            arrLogTypeInfo = l.GetLogTypeInfo();

            htLogTypeInfo = new Hashtable();

            int i;

            for (i = 0; i <= arrLogTypeInfo.Count - 1; i++)
            {
                LogTypeInfo objLogTypeInfo = (LogTypeInfo)arrLogTypeInfo[i];
                htLogTypeInfo.Add(objLogTypeInfo.LogTypeKey, objLogTypeInfo);
            }

            string ColorCoding;

            ColorCoding = Convert.ToString(Personalization.GetProfile("LogViewer", "ColorCoding"));
            if (ColorCoding == "0")
            {
                ColorCodingOn = false;
            }
            else if (ColorCoding == "1")
            {
                ColorCodingOn = true;
            }
            else
            {
                ColorCodingOn = true;
            }

            string ColorCodingLegend;

            ColorCodingLegend = Convert.ToString(Personalization.GetProfile("LogViewer", "ColorCodingLegend"));
            if (ColorCodingLegend == "0")
            {
                ColorCodingLegendOn = false;
            }
            else if (ColorCodingLegend == "1")
            {
                ColorCodingLegendOn = true;
            }
            else
            {
                ColorCodingLegendOn = true;
            }
        }
示例#8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   OnPreRender runs just before the control is rendered.
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (string.IsNullOrEmpty(this.Language))
            {
                this._Flag.ImageUrl = "~/images/Flags/none.gif";
            }
            else
            {
                this._Flag.ImageUrl = string.Format("~/images/Flags/{0}.gif", this.Language);
            }

            if (this.DisplayType == 0)
            {
                PortalSettings _PortalSettings             = PortalController.Instance.GetCurrentPortalSettings();
                string         _ViewTypePersonalizationKey = "ViewType" + _PortalSettings.PortalId;
                string         _ViewType = Convert.ToString(Personalization.GetProfile("LanguageDisplayMode", _ViewTypePersonalizationKey));
                switch (_ViewType)
                {
                case "NATIVE":
                    this.DisplayType = CultureDropDownTypes.NativeName;
                    break;

                case "ENGLISH":
                    this.DisplayType = CultureDropDownTypes.EnglishName;
                    break;

                default:
                    this.DisplayType = CultureDropDownTypes.DisplayName;
                    break;
                }
            }

            string localeName = null;

            if (string.IsNullOrEmpty(this.Language))
            {
                localeName = Localization.GetString("NeutralCulture", Localization.GlobalResourceFile);
            }
            else
            {
                localeName = Localization.GetLocaleName(this.Language, this.DisplayType);
            }

            this._Label.Text         = localeName;
            this._Flag.AlternateText = localeName;
        }
示例#9
0
        protected IEnumerable <string[]> LoadLanguagesList()
        {
            var result = new List <string[]>();

            if (PortalSettings.AllowUserUICulture)
            {
                if (CurrentUICulture == null)
                {
                    object oCulture = Personalization.GetProfile("Usability", "UICulture");

                    if (oCulture != null)
                    {
                        CurrentUICulture = oCulture.ToString();
                    }
                    else
                    {
                        var l = new Localization();
                        CurrentUICulture = l.CurrentUICulture;
                        SetLanguage(true, CurrentUICulture);
                    }
                }


                IEnumerable <ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CurrentUICulture, "", false);
                foreach (var cultureItem in cultureListItems)
                {
                    var      selected = cultureItem.Value == CurrentUICulture ? "true" : "false";
                    string[] p        = new string[]
                    {
                        cultureItem.Text,
                        cultureItem.Value,
                        selected
                    };
                    result.Add(p);
                }
            }

            return(result);
        }
示例#10
0
 private void AutoEditMode()
 {
     if (!Page.IsPostBack)
     {
         if (HttpContext.Current != null && HttpContext.Current.Request.IsAuthenticated)
         {
             var defaultMode = ModuleContext.PortalSettings.DefaultControlPanelMode;
             if (defaultMode == PortalSettings.Mode.Edit)
             {
                 string setting = Convert.ToString(Personalization.GetProfile("Usability", "UserMode" + PortalSettings.Current.PortalId));
                 //if (!IsPageAdmin() & IsModuleAdmin())
                 {
                     if (setting != "EDIT")
                     {
                         Personalization.SetProfile("Usability", "UserMode" + PortalSettings.Current.PortalId, "EDIT");
                         //Page.Response.AppendHeader("X-UserMode", setting + "/" + IsPageAdmin() + "/" + IsModuleAdmin());
                     }
                     JavaScript.RequestRegistration(CommonJs.DnnPlugins); // avoid js error
                 }
             }
         }
         //string  usermode = "" + DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UserMode" + PortalSettings.Current.PortalId);
     }
 }
示例#11
0
 private object GetUserSetting(string key)
 {
     return(Personalization.GetProfile(ModuleConfiguration.ModuleDefinition.FriendlyName, PersonalizationKey(key)));
 }
示例#12
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Loads suported locales and shows default values
        /// </summary>
        /// <param name = "sender"></param>
        /// <param name = "e"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///   [vmasanas]	04/10/2004	Created
        ///   [vmasanas]	25/03/2006	Modified to support new host resources and incremental saving
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                if (!Page.IsPostBack)
                {
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                    // init tree
                    LoadRootNodes();

                    Locale language = LocaleController.Instance.GetLocale(Locale);
                    languageLabel.Language = language.Code;

                    if (UserInfo.IsSuperUser)
                    {
                        string mode = Request.QueryString["mode"];
                        if (!string.IsNullOrEmpty(mode) && (rbMode.Items.FindByValue(mode) != null))
                        {
                            rbMode.SelectedValue = mode;
                        }
                        else
                        {
                            rbMode.SelectedValue = "Host";
                        }
                    }
                    else
                    {
                        rbMode.SelectedValue = "Portal";
                        rowMode.Visible      = false;
                    }

                    string PersonalHighlight = Convert.ToString(Personalization.GetProfile("LanguageEditor", "HighLight" + PortalId));
                    string highlight         = Request.QueryString["highlight"];
                    if (!string.IsNullOrEmpty(highlight) && highlight.ToLower() == "true")
                    {
                        chkHighlight.Checked = true;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(PersonalHighlight))
                        {
                            chkHighlight.Checked = Convert.ToBoolean(PersonalHighlight);
                        }
                    }

                    if (!string.IsNullOrEmpty(Request.QueryString["resourcefile"]))
                    {
                        SelectedResourceFile = Server.MapPath("~/" + Globals.QueryStringDecode(Request.QueryString["resourcefile"]));
                    }
                    else
                    {
                        SelectedResourceFile = Server.MapPath(Localization.GlobalResourceFile);
                    }

                    if (!string.IsNullOrEmpty(Request.QueryString["message"]))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString(Request.QueryString["message"], LocalResourceFile), ModuleMessage.ModuleMessageType.GreenSuccess);
                    }

                    BindGrid(!IsPostBack);
                }
                //Module failed to load
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#13
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                LocalizeCollapsePanels();

                //check VI for null then set information
                if (!Page.IsPostBack)
                {
                    LoadAuthorsList();
                    //set author
                    ddlAuthor.SelectedValue = VersionInfoObject.AuthorUserId > 0
                                                                           ? VersionInfoObject.AuthorUserId.ToString()
                                                                           : UserId.ToString();

                    //configure the author name (Text) if defined
                    //chkShowAuthor
                    ItemVersionSetting auNameSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "lblAuthorName", "Text", PortalId);
                    txtAuthorName.Text = auNameSetting != null ? auNameSetting.PropertyValue : ddlAuthor.SelectedItem.Text.Trim();


                    if (AllowRichTextDescriptions)
                    {
                        if (DefaultRichTextDescriptions)
                        {
                            teDescription.ChooseMode = true;
                            btnChangeDescriptionEditorMode.Visible = false;
                            teDescription.Visible  = true;
                            txtDescription.Visible = false;
                        }
                        else
                        {
                            //if their profile is set to basic text mode, we need to show the radio buttons so they can get to rich text mode.
                            teDescription.ChooseMode            = (string)Personalization.GetProfile("DotNetNuke.TextEditor", "PreferredTextEditor") == "BASIC";
                            btnChangeDescriptionEditorMode.Text = Localization.GetString("btnChangeDescriptionEditorMode_" + txtDescription.Visible, LocalResourceFile);
                        }
                    }
                    else
                    {
                        btnChangeDescriptionEditorMode.Visible = false;
                    }

                    if (Utility.HasValue(VersionInfoObject.MetaTitle) || Utility.HasValue(VersionInfoObject.MetaDescription) || Utility.HasValue(VersionInfoObject.MetaKeywords))
                    {
                        //chkSearchEngine.Checked = true;
                        //pnlSearchEngine.Visible = true;
                    }

                    txtDescription.Text = VersionInfoObject.Description;
                    teDescription.Text  = VersionInfoObject.Description;

                    txtMetaKeywords.Text    = VersionInfoObject.MetaKeywords;
                    txtMetaDescription.Text = VersionInfoObject.MetaDescription;
                    txtMetaTitle.Text       = VersionInfoObject.MetaTitle;

                    if (EnableDisplayNameAsHyperlink)
                    {
                        chkDisplayAsHyperlink.Checked = !VersionInfoObject.Disabled;
                    }
                    else
                    {
                        lblDisplayAsHyperlink.Visible = false;
                        chkDisplayAsHyperlink.Visible = false;
                        chkDisplayAsHyperlink.Checked = true;
                    }
                    if (Utility.HasValue(VersionInfoObject.StartDate))
                    {
                        txtStartDate.Text = Utility.GetCurrentCultureDateTime(VersionInfoObject.StartDate);
                    }
                    if (Utility.HasValue(VersionInfoObject.EndDate))
                    {
                        txtEndDate.Text = Utility.GetCurrentCultureDateTime(VersionInfoObject.EndDate);
                    }
                    txtName.Text = VersionInfoObject.Name;


                    thumbnailSelector.ThumbnailUrl = VersionInfoObject.Thumbnail;
                }
                else
                {
                    VersionInfoObject.Name        = txtName.Text;
                    VersionInfoObject.Description = DescriptionText;
                    VersionInfoObject.Thumbnail   = thumbnailSelector.ThumbnailUrl;//ctlMediaFile.Url;

                    //define author's name to display
                    _authorName = txtAuthorName.Text.Trim();

                    VersionInfoObject.MetaKeywords    = txtMetaKeywords.Text;
                    VersionInfoObject.MetaDescription = txtMetaDescription.Text;
                    VersionInfoObject.MetaTitle       = txtMetaTitle.Text;
                    VersionInfoObject.Disabled        = !chkDisplayAsHyperlink.Checked;

                    VersionInfoObject.Url = ctlUrlSelection.Url;


                    VersionInfoObject.NewWindow = chkNewWindow.Checked;
                    DateTime dt;
                    if (Utility.HasValue(txtStartDate.Text) && DateTime.TryParse(txtStartDate.Text, out dt))
                    {
                        if (!dt.Equals(DateTime.MinValue))
                        {
                            VersionInfoObject.StartDate = dt.ToString(CultureInfo.InvariantCulture);
                        }
                    }

                    if (Utility.HasValue(txtEndDate.Text) && DateTime.TryParse(txtEndDate.Text, out dt))
                    {
                        if (!dt.Equals(DateTime.MinValue))
                        {
                            VersionInfoObject.EndDate = dt.ToString(CultureInfo.InvariantCulture);
                        }
                    }
                    else
                    {
                        VersionInfoObject.EndDate = "";
                    }


                    VersionInfoObject.AuthorUserId   = Convert.ToInt32(ddlAuthor.SelectedValue);
                    VersionInfoObject.RevisingUserId = UserId;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        protected void languagesGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            var gridItem = e.Item as GridDataItem;

            if (gridItem != null)
            {
                var locale = gridItem.DataItem as Locale;
                if (locale != null)
                {
                    var localizeLinkAlt = gridItem.FindControl("localizeLinkAlt") as HyperLink;
                    if (localizeLinkAlt != null)
                    {
                        localizeLinkAlt.NavigateUrl = ModuleContext.NavigateUrl(ModuleContext.TabId,
                                                                                "LocalizePages",
                                                                                false,
                                                                                "mid=" + ModuleContext.ModuleId,
                                                                                "locale=" + locale.Code);
                    }
                    var localizeLink = gridItem.FindControl("localizeLink") as HyperLink;
                    if (localizeLink != null)
                    {
                        CultureDropDownTypes DisplayType;
                        string _ViewType = Convert.ToString(Personalization.GetProfile("LanguageDisplayMode", "ViewType" + PortalId));
                        switch (_ViewType)
                        {
                        case "NATIVE":
                            DisplayType = CultureDropDownTypes.NativeName;
                            break;

                        case "ENGLISH":
                            DisplayType = CultureDropDownTypes.EnglishName;
                            break;

                        default:
                            DisplayType = CultureDropDownTypes.DisplayName;
                            break;
                        }

                        localizeLink.NavigateUrl = ModuleContext.NavigateUrl(ModuleContext.TabId,
                                                                             "LocalizePages",
                                                                             false,
                                                                             "mid=" + ModuleContext.ModuleId,
                                                                             "locale=" + locale.Code);

                        var enabledCheckbox = gridItem.FindControl("enabledCheckbox") as CheckBox;
                        if (enabledCheckbox != null)
                        {
                            enabledCheckbox.Checked = IsLanguageEnabled(locale.Code);

                            if (enabledCheckbox.Checked)
                            {
                                string msg = String.Format(LocalizeString("Disable.Confirm"), Localization.GetLocaleName(locale.Code, DisplayType));
                                enabledCheckbox.Attributes.Add("onclick", "if (!confirm('" + Localization.GetSafeJSString(msg) + "')) return false;");
                            }
                        }

                        var publishedCheckbox = gridItem.FindControl("publishedCheckbox") as CheckBox;
                        if (publishedCheckbox != null)
                        {
                            publishedCheckbox.Checked = IsLanguagePublished(locale.Code);

                            if (publishedCheckbox.Checked)
                            {
                                string msg = String.Format(LocalizeString("Unpublish.Confirm"), Localization.GetLocaleName(locale.Code, DisplayType));
                                publishedCheckbox.Attributes.Add("onclick", "if (!confirm('" + Localization.GetSafeJSString(msg) + "')) return false;");
                            }
                        }
                    }
                }
            }
        }