public bool IsLocalizationTable()
 {
     return(Manager.IsLocalizationTable());
 }
Ejemplo n.º 2
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("/", true);
            }

            if (!User.IsInRole("Admin"))
            {
                Response.Redirect("/", true);
            }

            // *** On callbacks we don't need to populate any data since they are
            // *** raw method calls. Callback routes to parser from here
            if (Callback.IsCallback)
            {
                return;
            }

            Response.Expires = 0;

            if (!Manager.IsLocalizationTable(null))
            {
                ErrorDisplay.ShowError(WebUtils.LRes("ResourceTableDoesntExist"));
                btnCreateTable.Visible = true;
                return;
            }

            GetResourceSet();

            ListItem[] items = Manager.GetAllResourceIdsForHtmlDisplay(ResourceSet);
            lstResourceIds.Items.AddRange(items);


            //DataTable dt = Manager.GetAllResourceIds(ResourceSet);
            //if (dt == null)
            //{
            //    this.ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
            //    return;
            //}
            //this.lstResourceIds.DataSource = dt;
            //this.lstResourceIds.DataValueField = "ResourceId";
            //this.lstResourceIds.DataBind();


            if (lstResourceIds.Items.Count > 0)
            {
                lstResourceIds.SelectedIndex = 0;
            }

            DataTable dt = Manager.GetAllLocaleIds(ResourceSet);

            if (dt == null)
            {
                ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
                return;
            }

            foreach (DataRow row in dt.Rows)
            {
                string      Code = row["LocaleId"] as string;
                CultureInfo ci   = CultureInfo.GetCultureInfo(Code.Trim());

                if (Code != "")
                {
                    row["Language"] = ci.DisplayName + " (" + ci.Name + ")";
                }
                else
                {
                    row["Language"] = "Invariant";
                }
            }

            lstLanguages.DataSource     = dt;
            lstLanguages.DataValueField = "LocaleId";
            lstLanguages.DataTextField  = "Language";
            lstLanguages.DataBind();

            if (lstLanguages.Items.Count > 0)
            {
                lstLanguages.SelectedIndex = 0;
            }
            else
            {
                lstLanguages.Items.Add(new ListItem("Invariant", ""));
            }
        }