Beispiel #1
0
        private void PopulateControls()
        {
            if (Page.IsPostBack)
            {
                return;
            }

            BindImageList();

            ISettingControl rolesControl = this.arTemplate as ISettingControl;

            if (templateGuid == Guid.Empty)
            {
                if (rolesControl != null)
                {
                    rolesControl.SetValue(defaultTemplateRoles);
                }
                return;
            }

            ContentTemplate contentTemplate = ContentTemplate.Get(templateGuid);

            if (contentTemplate == null)
            {
                return;
            }

            if (contentTemplate.SiteGuid != siteSettings.SiteGuid)
            {
                contentTemplate = null; return;
            }


            txtTitle.Text      = contentTemplate.Title.ToString();
            edDescription.Text = contentTemplate.Description.ToString();
            edTemplate.Text    = contentTemplate.Body.ToString();

            if (rolesControl != null)
            {
                rolesControl.SetValue(contentTemplate.AllowedRoles);
            }

            ListItem item = ddImage.Items.FindByValue(contentTemplate.ImageFileName);

            if (item != null)
            {
                ddImage.ClearSelection();
                item.Selected = true;
            }

            imgTemplate.Src = imageBaseUrl + contentTemplate.ImageFileName;
        }
Beispiel #2
0
        private void PopulateControls()
        {
            Forum forum = new Forum(itemId);

            if (forum.ModuleId != moduleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            this.lblCreatedDate.Text = forum.CreatedDate.AddHours(timeOffset).ToString();
            edContent.Text           = forum.Description;
            this.txtTitle.Text       = forum.Title;
            this.chkIsActive.Checked = forum.IsActive;
            //this.chkAllowAnonymousPosts.Checked = forum.AllowAnonymousPosts;
            this.chkIsModerated.Checked = forum.IsModerated;
            this.txtSortOrder.Text      = forum.SortOrder.ToString();
            this.txtPostsPerPage.Text   = forum.PostsPerPage.ToString();
            this.txtThreadsPerPage.Text = forum.ThreadsPerPage.ToString();
            allowedPostRolesSetting     = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);

            moderatorRolesSetting = moderatorRoles as AllowedRolesSetting;
            moderatorRolesSetting.SetValue(forum.RolesThatCanModerate);

            chkRequireModForNotify.Checked      = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            txtModeratorNotifyEmail.Text        = forum.ModeratorNotifyEmail;
            chkIncludeInGoogleMap.Checked       = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked           = forum.AddNoIndexMeta;
            chkClosed.Checked  = forum.Closed;
            chkVisible.Checked = forum.Visible;
        }
Beispiel #3
0
        private void ShowNewForumControls()
        {
            this.btnDelete.Visible      = false;
            this.btnUpdate.Text         = ForumResources.ForumEditCreateButton;
            this.chkIsActive.Checked    = true;
            this.txtSortOrder.Text      = "100";
            this.txtPostsPerPage.Text   = "10";
            this.txtThreadsPerPage.Text = "40";
            Forum forum = new Forum();

            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);
            chkIncludeInGoogleMap.Checked       = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked           = forum.AddNoIndexMeta;
            chkRequireModForNotify.Checked      = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            chkVisible.Checked = forum.Visible;
        }
Beispiel #4
0
        private void PopulateControls()
        {
            this.lnkChangePassword.NavigateUrl = SiteRoot + "/Secure/ChangePassword.aspx";
            this.lnkChangePassword.Text        = Resource.UserChangePasswordLabel;
            ListItem listItem;

            if (allowUserSkin)
            {
                if (siteUser != null)
                {
                    SkinSetting.SetValue(siteUser.Skin);
                }
            }

            if ((siteSettings.AllowUserEditorPreference) && (siteUser != null) && (siteUser.EditorPreference.Length > 0))
            {
                listItem = ddEditorProviders.Items.FindByValue(siteUser.EditorPreference);
                if (listItem != null)
                {
                    ddEditorProviders.ClearSelection();
                    listItem.Selected = true;
                }
            }



            if (siteUser != null)
            {
#if !MONO
                ISettingControl setting = timeZoneSetting as ISettingControl;
                if (setting != null)
                {
                    setting.SetValue(siteUser.TimeZoneId);
                }
#endif

                txtName.Text      = SecurityHelper.RemoveMarkup(siteUser.Name);
                txtName.Enabled   = siteSettings.AllowUserFullNameChange;
                lblLoginName.Text = SecurityHelper.RemoveMarkup(siteUser.LoginName);
                txtEmail.Text     = siteUser.Email;
                //gravatar1.Email = siteUser.Email;
                lblOpenID.Text           = siteUser.OpenIdUri;
                txtPasswordQuestion.Text = siteUser.PasswordQuestion;
                txtPasswordAnswer.Text   = siteUser.PasswordAnswer;
                lblCreatedDate.Text      = siteUser.DateCreated.AddHours(timeOffset).ToString();
                lblTotalPosts.Text       = siteUser.TotalPosts.ToString();
                lnkUserPosts.UserId      = siteUser.UserId;
                lnkUserPosts.TotalPosts  = siteUser.TotalPosts;
                //lnkPublicProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();
                lnkPubProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();

                if (divLiveMessenger.Visible)
                {
                    WindowsLiveLogin     wl = WindowsLiveHelper.GetWindowsLiveLogin();
                    WindowsLiveMessenger m  = new WindowsLiveMessenger(wl);

                    if (WebConfigSettings.TestLiveMessengerDelegation)
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.ConsentOptInUrl;
                    }
                    else
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.NonDelegatedSignUpUrl;
                    }

                    if (siteUser.LiveMessengerId.Length > 0)
                    {
                        chkEnableLiveMessengerOnProfile.Checked = siteUser.EnableLiveMessengerOnProfile;
                        chkEnableLiveMessengerOnProfile.Enabled = true;
                    }
                    else
                    {
                        chkEnableLiveMessengerOnProfile.Checked = false;
                        chkEnableLiveMessengerOnProfile.Enabled = false;
                    }
                }


                //if ((!allowGravatars)&&(!disableAvatars))
                //{
                //    if (siteUser.AvatarUrl.Length > 0)
                //    {
                //        imgAvatar.Src = avatarPath + siteUser.AvatarUrl;
                //    }
                //    else
                //    {
                //        imgAvatar.Src = Page.ResolveUrl(WebConfigSettings.DefaultBlankAvatarPath);
                //    }
                //}

                userAvatar.UseGravatar      = allowGravatars;
                userAvatar.Email            = siteUser.Email;
                userAvatar.UserName         = siteUser.Name;
                userAvatar.UserId           = siteUser.UserId;
                userAvatar.AvatarFile       = siteUser.AvatarUrl;
                userAvatar.MaxAllowedRating = MaxAllowedGravatarRating;
                userAvatar.Disable          = disableAvatars;
                userAvatar.SiteId           = siteSettings.SiteId;
                userAvatar.UseLink          = false;
            }

            // this doesn't work
            //DoTabSelection();
        }
        public static void SetupPropertyControl(
            Page currentPage,
            Panel parentControl,
            mojoProfilePropertyDefinition propertyDefinition,
            String propertyValue,
            Double legacyTimeZoneOffset,
            TimeZoneInfo timeZone,
            string siteRoot)
        {
            if (propertyValue == null)
            {
                propertyValue = String.Empty;
            }

            string validatorSkinID = "Profile";

            if (currentPage is mojoPortal.Web.UI.Pages.Register)
            {
                validatorSkinID = "Registration";
            }

            Literal rowOpenTag = new Literal();

            rowOpenTag.Text = "<div class='settingrow " + propertyDefinition.CssClass + "'>";
            parentControl.Controls.Add(rowOpenTag);

            SiteLabel label = new SiteLabel();

            label.ResourceFile = propertyDefinition.ResourceFile;
            // if key isn't in resource file use assume the resource hasn't been
            //localized and just use the key as the resource
            label.ShowWarningOnMissingKey = false;
            label.ConfigKey = propertyDefinition.LabelResourceKey;
            label.CssClass  = "settinglabel";

            if (propertyDefinition.ISettingControlSrc.Length > 0)
            {
                Control c = null;
                if (propertyDefinition.ISettingControlSrc.EndsWith(".ascx"))
                {
                    c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc);
                }
                else
                {
                    try
                    {
                        c = Activator.CreateInstance(System.Type.GetType(propertyDefinition.ISettingControlSrc)) as Control;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }

                if ((c != null) && (c is ISettingControl))
                {
                    c.ID = "isc" + propertyDefinition.Name;
                    parentControl.Controls.Add(label);

                    ISettingControl settingControl = (ISettingControl)c;

                    settingControl.SetValue(propertyValue);
                    parentControl.Controls.Add(c);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }
                }
            }
            else if (propertyDefinition.OptionList.Count > 0)
            {
                if (propertyDefinition.Type == "CheckboxList")
                {
                    CheckBoxList cbl = CreateCheckBoxListQuestion(propertyDefinition, propertyValue);
                    cbl.ID            = "cbl" + propertyDefinition.Name;
                    cbl.EnableTheming = false;
                    cbl.CssClass      = "forminput";

                    cbl.TabIndex     = 10;
                    label.ForControl = cbl.ID;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(cbl);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        CheckBoxListValidator rfv = new CheckBoxListValidator();
                        rfv.SkinID            = validatorSkinID;
                        rfv.ControlToValidate = cbl.ID;

                        rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                         ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfv.Display = ValidatorDisplay.None;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }
                }
                else
                {
                    // add a dropdownlist with the options

                    DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue);
                    dd.ID            = "dd" + propertyDefinition.Name;
                    dd.EnableTheming = false;
                    dd.CssClass      = "forminput " + propertyDefinition.CssClass;

                    dd.TabIndex      = 10;
                    label.ForControl = dd.ID;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(dd);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDd = new RequiredFieldValidator();
                        rfvDd.SkinID            = validatorSkinID;
                        rfvDd.ControlToValidate = dd.ID;
                        //if(dd.Items.Count > 0)
                        //{
                        //    rfvDd.InitialValue = dd.Items[0].Value;
                        //}


                        rfvDd.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                           ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));


                        rfvDd.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDd);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.SkinID               = validatorSkinID;
                        regexValidator.ControlToValidate    = dd.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidator.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidator);
                    }
                }
            }
            else
            {
                switch (propertyDefinition.Type)
                {
                case "System.Boolean":
                    CheckBox checkBox = new CheckBox();
                    checkBox.TabIndex = 10;
                    checkBox.ID       = "chk" + propertyDefinition.Name;
                    checkBox.CssClass = "forminput " + propertyDefinition.CssClass;
                    label.ForControl  = checkBox.ID;
                    parentControl.Controls.Add(label);
                    parentControl.Controls.Add(checkBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.ToLower() == "true")
                    {
                        checkBox.Checked = true;
                    }
                    break;

                case "System.DateTime":
                    // TODO: to really make this culture aware we should store the users
                    // culture as well and use the user's culture to
                    // parse the date
                    DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, legacyTimeZoneOffset, timeZone, siteRoot);

                    datePicker.TabIndex = 10;
                    datePicker.ID       = "dp" + propertyDefinition.Name;
                    datePicker.CssClass = "forminput " + propertyDefinition.CssClass;
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(datePicker);


                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDate = new RequiredFieldValidator();
                        rfvDate.SkinID            = validatorSkinID;
                        rfvDate.ControlToValidate = datePicker.ID;

                        rfvDate.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                             ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfvDate.Display = ValidatorDisplay.None;
                        rfvDate.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDate);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator();
                        regexValidatorDate.SkinID               = validatorSkinID;
                        regexValidatorDate.ControlToValidate    = datePicker.ID;
                        regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidatorDate.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidatorDate.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidatorDate);
                    }

                    break;

                case "System.String":
                default:

                    TextBox textBox = new TextBox();
                    textBox.TabIndex = 10;
                    textBox.ID       = "txt" + propertyDefinition.Name;
                    textBox.CssClass = "forminput " + propertyDefinition.CssClass;
                    label.ForControl = textBox.ID;
                    parentControl.Controls.Add(label);

                    if (propertyDefinition.MaxLength > 0)
                    {
                        textBox.MaxLength = propertyDefinition.MaxLength;
                    }

                    if (propertyDefinition.Columns > 0)
                    {
                        textBox.Columns = propertyDefinition.Columns;
                    }

                    if (propertyDefinition.Rows > 1)
                    {
                        textBox.TextMode = TextBoxMode.MultiLine;
                        textBox.Rows     = propertyDefinition.Rows;
                    }

                    parentControl.Controls.Add(textBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.Length > 0)
                    {
                        textBox.Text = propertyValue;
                    }
                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                        rfv.SkinID            = validatorSkinID;
                        rfv.ControlToValidate = textBox.ID;

                        rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat,
                                                         ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey));

                        //rfv.Display = ValidatorDisplay.None;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.SkinID               = validatorSkinID;
                        regexValidator.ControlToValidate    = textBox.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);
                        }

                        //regexValidator.Display = ValidatorDisplay.None;
                        parentControl.Controls.Add(regexValidator);
                    }

                    break;
                }
            }


            Literal rowCloseTag = new Literal();

            rowCloseTag.Text = "</div>";
            parentControl.Controls.Add(rowCloseTag);
        }
        private void PopulateControls()
        {
            if (Page.IsPostBack)
            {
                return;
            }

            if ((store != null) && (order != null))
            {
                if (orderUser != null)
                {
                    lblSiteUser.Text = orderUser.LoginName + " " + orderUser.Name + " " + orderUser.Email;
                    if (WebUser.IsAdmin)
                    {
                        lnkUser.Text        = WebStoreResources.ManageUserLink;
                        lnkUser.NavigateUrl = SiteRoot + "/Admin/ManageUsers.aspx?userid=" + orderUser.UserId.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        lnkUser.Text        = WebStoreResources.UserProfileLink;
                        lnkUser.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + orderUser.UserId.ToString(CultureInfo.InvariantCulture);
                    }
                }

                Title           = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
                lblOrderId.Text = order.OrderGuid.ToString();
                ISettingControl setting = orderStatusControl as ISettingControl;
                setting.SetValue(order.StatusGuid.ToString());

                litSubTotal.Text      = order.SubTotal.ToString("c", currencyCulture);
                litDiscount.Text      = order.Discount.ToString("c", currencyCulture);
                litShippingTotal.Text = order.ShippingTotal.ToString("c", currencyCulture);
                litTaxTotal.Text      = order.TaxTotal.ToString("c", currencyCulture);
                litOrderTotal.Text    = order.OrderTotal.ToString("c", currencyCulture);

                pnlDiscount.Visible      = (order.Discount > 0);
                pnlShippingTotal.Visible = (order.ShippingTotal > 0);
                pnlTaxTotal.Visible      = (order.TaxTotal > 0);

                if ((order.ShippingTotal == 0) && (order.TaxTotal == 0) && (order.Discount == 0))
                {
                    pnlSubTotal.Visible = false;
                }

                lblCustomerAddressLine1.Text   = order.CustomerAddressLine1;
                lblCustomerAddressLine2.Text   = order.CustomerAddressLine2;
                lblCustomerCity.Text           = order.CustomerCity;
                lblCustomerCompany.Text        = order.CustomerCompany;
                lblCustomerCountry.Text        = order.CustomerCountry;
                lblCustomerEmail.Text          = order.CustomerEmail;
                lblCustomerGeoZone.Text        = order.CustomerState;
                lblCustomerName.Text           = order.CustomerFirstName + " " + order.CustomerLastName;
                lblCustomerPostalCode.Text     = order.CustomerPostalCode;
                lblCustomerSuburb.Text         = order.CustomerSuburb;
                lblCustomerTelephoneDay.Text   = order.CustomerTelephoneDay;
                lblCustomerTelephoneNight.Text = order.CustomerTelephoneNight;
                lblDiscountCodes.Text          = order.DiscountCodesCsv;
                lblCustomData.Text             = order.CustomData;

                using (IDataReader reader = order.GetProducts())
                {
                    rptOrderItems.DataSource = reader;
                    rptOrderItems.DataBind();
                }

                grdDownloadTickets.DataSource = order.GetDownloadTickets();
                grdDownloadTickets.DataBind();
                pnlDownloadTickets.Visible = (grdDownloadTickets.Rows.Count > 0);

                litPaymentMethod.Text = ResourceHelper.GetResourceString("WebStoreResources", order.PaymentMethod);

                Control c = Page.LoadControl("~/Controls/GCheckoutLogList.ascx");
                if (c != null)
                {
                    GCheckoutLogList googleLog = c as GCheckoutLogList;
                    googleLog.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(googleLog);
                }

                c = Page.LoadControl("~/Controls/PayPalLogList.ascx");
                if (c != null)
                {
                    PayPalLogList logList = c as PayPalLogList;
                    logList.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(logList);
                }

                c = Page.LoadControl("~/Controls/PaymentLogList.ascx");
                if (c != null)
                {
                    PaymentLogList logList = c as PaymentLogList;
                    logList.CartGuid = order.OrderGuid;
                    pnlCheckoutLog.Controls.Add(logList);
                }

                //c = Page.LoadControl("~/Controls/AuthorizeNetLogList.ascx");
                //if (c != null)
                //{
                //    AuthorizeNetLogList logList = c as AuthorizeNetLogList;
                //    logList.CartGuid = order.OrderGuid;
                //    pnlCheckoutLog.Controls.Add(logList);
                //}
                //c = Page.LoadControl("~/Controls/PlugNPayLogList.ascx");
                //if (c != null)
                //{
                //    PlugNPayLogList logList = c as PlugNPayLogList;
                //    logList.CartGuid = order.OrderGuid;
                //    pnlCheckoutLog.Controls.Add(logList);
                //}
            }
        }
Beispiel #7
0
 private void ShowNewForumControls()
 {
     this.btnDelete.Visible = false;
     this.btnUpdate.Text = ForumResources.ForumEditCreateButton;
     this.chkIsActive.Checked = true;
     this.txtSortOrder.Text = "100";
     this.txtPostsPerPage.Text = "10";
     this.txtThreadsPerPage.Text = "40";
     Forum forum = new Forum();
     allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
     allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);
     chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap;
     chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta;
     chkRequireModForNotify.Checked = forum.RequireModForNotify;
     chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
     chkVisible.Checked = forum.Visible;
 }
Beispiel #8
0
        private void PopulateControls()
        {
            Forum forum = new Forum(itemId);

            if (forum.ModuleId != moduleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            this.lblCreatedDate.Text = forum.CreatedDate.AddHours(timeOffset).ToString();
            edContent.Text = forum.Description;
            this.txtTitle.Text = forum.Title;
            this.chkIsActive.Checked = forum.IsActive;
            //this.chkAllowAnonymousPosts.Checked = forum.AllowAnonymousPosts;
            this.chkIsModerated.Checked = forum.IsModerated;
            this.txtSortOrder.Text = forum.SortOrder.ToString();
            this.txtPostsPerPage.Text = forum.PostsPerPage.ToString();
            this.txtThreadsPerPage.Text = forum.ThreadsPerPage.ToString();
            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            allowedPostRolesSetting.SetValue(forum.RolesThatCanPost);

            moderatorRolesSetting = moderatorRoles as AllowedRolesSetting;
            moderatorRolesSetting.SetValue(forum.RolesThatCanModerate);

            chkRequireModForNotify.Checked = forum.RequireModForNotify;
            chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify;
            txtModeratorNotifyEmail.Text = forum.ModeratorNotifyEmail;
            chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap;
            chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta;
            chkClosed.Checked = forum.Closed;
            chkVisible.Checked = forum.Visible;
        }
        private void AddSettingControl(CustomModuleSetting s)
        {
            if (s.SettingName == "WebPartModuleWebPartSetting")
            {
                // Special handling for this one
                this.divWebParts.Visible = true;
                using (IDataReader reader = WebPartContent.SelectBySite(siteSettings.SiteId))
                {
                    this.ddWebParts.DataSource = reader;
                    this.ddWebParts.DataBind();
                }
                if (s.SettingValue.Length == 36)
                {
                    ListItem listItem = ddWebParts.Items.FindByValue(s.SettingValue);
                    if (listItem != null)
                    {
                        ddWebParts.ClearSelection();
                        listItem.Selected = true;
                    }
                }
            }
            else
            {
                if (s.SettingControlType == string.Empty)
                {
                    return;
                }

                String settingLabel = s.SettingName;
                String resourceFile = "Resource";
                if (s.ResourceFile.Length > 0)
                {
                    resourceFile = s.ResourceFile;
                }

                try
                {
                    settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString();
                }
                catch (NullReferenceException ex)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("ModuleSettings.aspx.cs error getting resource for s.SettingName " + s.SettingName, ex);
                    }
                }

                Panel panel = new Panel();
                panel.CssClass = "settingrow";
                Literal label = new Literal();
                label.Text = "<label class='settinglabel' >" + settingLabel + "</label>";
                panel.Controls.Add(label);

                if ((s.SettingControlType == "TextBox") || (s.SettingControlType == string.Empty))
                {
                    Literal textBox = new Literal();
                    textBox.Text = "<input name=\""
                                   + s.SettingName + this.moduleId.ToInvariantString()
                                   + "\" type='text' class=\"forminput\" value=\"" + s.SettingValue.HtmlEscapeQuotes()
                                   + "\" size=\"45\" id=\"" + s.SettingName + this.moduleId.ToInvariantString() + "\" />";

                    panel.Controls.Add(textBox);
                }

                if (s.SettingControlType == "CheckBox")
                {
                    Literal checkBox  = new Literal();
                    String  isChecked = String.Empty;

                    if (string.Equals(s.SettingValue, "true", StringComparison.InvariantCultureIgnoreCase))
                    {
                        isChecked = "checked";
                    }

                    checkBox.Text = "<input id='"
                                    + s.SettingName + this.moduleId.ToInvariantString()
                                    + "' type='checkbox' class='forminput' " + isChecked
                                    + " name='" + s.SettingName + this.moduleId.ToInvariantString() + "' />";

                    panel.Controls.Add(checkBox);
                }

                if (s.SettingControlType == "ISettingControl")
                {
                    if (s.ControlSrc.Length > 0)
                    {
                        Control uc = Page.LoadControl(s.ControlSrc);
                        if (uc is ISettingControl)
                        {
                            ISettingControl sc = uc as ISettingControl;
                            if (!IsPostBack)
                            {
                                sc.SetValue(s.SettingValue);
                            }

                            uc.ID = "uc" + moduleId.ToString(CultureInfo.InvariantCulture) + s.SettingName;
                            panel.Controls.Add(uc);
                        }
                    }
                    else
                    {
                        log.Error("could not add setting control for ISettingControl, missing controlsrc for " + s.SettingName);
                    }
                }

                if (s.HelpKey.Length > 0)
                {
                    CHelpLink.AddHelpLink(panel, s.HelpKey);
                }

                this.PlaceHolderAdvancedSettings.Controls.Add(panel);
            }
        }
        public static void SetupPropertyControl(
            Page currentPage,
            Panel parentControl,
            CProfilePropertyDefinition propertyDefinition,
            String propertyValue,
            Double timeZoneOffset,
            string siteRoot)
        {
            if (propertyValue == null)
            {
                propertyValue = String.Empty;
            }

            Literal rowOpenTag = new Literal();

            rowOpenTag.Text = "<div class='settingrow'>";
            parentControl.Controls.Add(rowOpenTag);

            SiteLabel label = new SiteLabel();

            label.ResourceFile = propertyDefinition.ResourceFile;
            // if key isn't in resource file use assume the resource hasn't been
            //localized and just use the key as the resource
            label.ShowWarningOnMissingKey = false;
            label.ConfigKey = propertyDefinition.LabelResourceKey;
            label.CssClass  = "settinglabel";

            if (propertyDefinition.ISettingControlSrc.Length > 0)
            {
                Control c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc);

                if ((c != null) && (c is ISettingControl))
                {
                    c.ID = "isc" + propertyDefinition.Name;
                    parentControl.Controls.Add(label);

                    ISettingControl settingControl = (ISettingControl)c;

                    settingControl.SetValue(propertyValue);
                    parentControl.Controls.Add(c);

                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }
                }
            }
            else if (propertyDefinition.OptionList.Count > 0)
            {
                // add a dropdownlist with the options

                DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue);
                dd.ID            = "dd" + propertyDefinition.Name;
                dd.EnableTheming = false;
                dd.CssClass      = "forminput";

                dd.TabIndex      = 10;
                label.ForControl = dd.ID;
                parentControl.Controls.Add(label);

                parentControl.Controls.Add(dd);

                if (propertyDefinition.IncludeHelpLink)
                {
                    AddHelpLink(parentControl, propertyDefinition);
                }
            }
            else
            {
                switch (propertyDefinition.Type)
                {
                case "System.Boolean":
                    CheckBox checkBox = new CheckBox();
                    checkBox.TabIndex = 10;
                    checkBox.ID       = "chk" + propertyDefinition.Name;
                    checkBox.CssClass = "forminput";
                    label.ForControl  = checkBox.ID;
                    parentControl.Controls.Add(label);
                    parentControl.Controls.Add(checkBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.ToLower() == "true")
                    {
                        checkBox.Checked = true;
                    }
                    break;

                case "System.DateTime":
                    // TODO: to really make this culture aware we should store the users
                    // culture as well and use the user's culture to
                    // parse the date
                    DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, timeZoneOffset, siteRoot);

                    datePicker.TabIndex = 10;
                    datePicker.ID       = "dp" + propertyDefinition.Name;
                    datePicker.CssClass = "forminput";
                    parentControl.Controls.Add(label);

                    parentControl.Controls.Add(datePicker);


                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfvDate = new RequiredFieldValidator();
                        rfvDate.ControlToValidate = datePicker.ID;

                        rfvDate.ErrorMessage    = Resources.ProfileResource.RequiredLabel;
                        rfvDate.Display         = ValidatorDisplay.Dynamic;
                        rfvDate.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfvDate);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator();
                        regexValidatorDate.ControlToValidate    = datePicker.ID;
                        regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidatorDate.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);

                            //object o = HttpContext.GetGlobalResourceObject(
                            //    propertyDefinition.ResourceFile,
                            //    propertyDefinition.RegexValidationErrorResourceKey);

                            //if (o != null)
                            //{
                            //    regexValidatorDate.ErrorMessage = o.ToString();
                            //}
                            //else
                            //{
                            //    regexValidatorDate.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey;
                            //}
                        }

                        regexValidatorDate.Display = ValidatorDisplay.Dynamic;
                        parentControl.Controls.Add(regexValidatorDate);
                    }

                    break;

                case "System.String":
                default:

                    TextBox textBox = new TextBox();
                    textBox.TabIndex = 10;
                    textBox.ID       = "txt" + propertyDefinition.Name;
                    textBox.CssClass = "forminput";
                    label.ForControl = textBox.ID;
                    parentControl.Controls.Add(label);

                    if (propertyDefinition.MaxLength > 0)
                    {
                        textBox.MaxLength = propertyDefinition.MaxLength;
                    }

                    if (propertyDefinition.Columns > 0)
                    {
                        textBox.Columns = propertyDefinition.Columns;
                    }

                    if (propertyDefinition.Rows > 1)
                    {
                        textBox.TextMode = TextBoxMode.MultiLine;
                        textBox.Rows     = propertyDefinition.Rows;
                    }

                    parentControl.Controls.Add(textBox);
                    if (propertyDefinition.IncludeHelpLink)
                    {
                        AddHelpLink(parentControl, propertyDefinition);
                    }

                    if (propertyValue.Length > 0)
                    {
                        textBox.Text = propertyValue;
                    }
                    if (propertyDefinition.RequiredForRegistration)
                    {
                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                        rfv.ControlToValidate = textBox.ID;

                        rfv.ErrorMessage    = Resources.ProfileResource.RequiredLabel;
                        rfv.Display         = ValidatorDisplay.Dynamic;
                        rfv.ValidationGroup = "profile";
                        parentControl.Controls.Add(rfv);
                    }

                    if (propertyDefinition.RegexValidationExpression.Length > 0)
                    {
                        RegularExpressionValidator regexValidator = new RegularExpressionValidator();
                        regexValidator.ControlToValidate    = textBox.ID;
                        regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression;
                        regexValidator.ValidationGroup      = "profile";
                        if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0)
                        {
                            regexValidator.ErrorMessage = ResourceHelper.GetResourceString(
                                propertyDefinition.ResourceFile,
                                propertyDefinition.RegexValidationErrorResourceKey);

                            //object o = HttpContext.GetGlobalResourceObject(
                            //    propertyDefinition.ResourceFile,
                            //    propertyDefinition.RegexValidationErrorResourceKey);

                            //if (o != null)
                            //{
                            //    regexValidator.ErrorMessage = o.ToString();
                            //}
                            //else
                            //{
                            //    regexValidator.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey;
                            //}
                        }

                        regexValidator.Display = ValidatorDisplay.Dynamic;
                        parentControl.Controls.Add(regexValidator);
                    }

                    break;
                }
            }


            Literal rowCloseTag = new Literal();

            rowCloseTag.Text = "</div>";
            parentControl.Controls.Add(rowCloseTag);
        }