示例#1
0
        /// <summary>
        /// 获取配置文件
        /// </summary>
        /// <returns></returns>
        public RatingSettings Get()
        {
            RatingSettings ratingSettings = new RatingSettings();

            ratingSettings.IsModify = true;
            return(ratingSettings);
        }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     settings        = new RatingSettings();
     settings        = settings.Load();
     btn_Save.Click += new EventHandler(btn_Save_Click);
 }
示例#3
0
        private void LoadRatingSettings(RatingBlock block)
        {
            // Use previously set value, if exists.
            RatingSettings = RatingSettings ?? new List <int>();

            // Return if ratings is not null and has value.
            if (block.RatingSettings?.Any() == true)
            {
                RatingSettings.AddRange(block.RatingSettings.Select(r => r.Value));
                RatingSettings.Sort();
            }
        }
        void btn_Save_Click(object sender, EventArgs e)
        {
            settings.Maximum = int.Parse(rtg_maximum.Value.ToString());
            settings.Minimum = int.Parse(rtg_minimum.Value.ToString());
            settings         = settings.Save();// (SPContext.Current.Site);

            var eventArgsJavaScript = String.Format("{{Message:'{0}',controlIDs:window.frameElement.dialogArgs}}", "The Properties have been updated.");

            ((EnhancedLayoutsPage)Page).EndOperation(ModalDialogResult.OK, eventArgsJavaScript);
            Context.Response.Flush();
            Context.Response.End();
        }
示例#5
0
        private void MicroDate()
        {
            if (settings == null)
            {
                settings = new RatingSettings();
                settings = settings.Load();
            }

            HtmlGenericControl itemprop = new HtmlGenericControl("div");

            itemprop.Attributes.Add("itemprop", "aggregateRating");
            itemprop.Attributes.Add("itemscope", "itemscope");
            itemprop.Attributes.Add("itemtype", "http://schema.org/AggregateRating");

            HtmlGenericControl worst = new HtmlGenericControl("meta");

            worst.Attributes.Add("itemprop", "worstRating");
            worst.Attributes.Add("datatype", "integer");
            worst.Attributes.Add("content", settings.Minimum.ToString());
            itemprop.Controls.Add(worst);

            HtmlGenericControl best = new HtmlGenericControl("meta");

            best.Attributes.Add("itemprop", "bestRating");
            best.Attributes.Add("datatype", "integer");
            best.Attributes.Add("content", settings.Maximum.ToString());
            itemprop.Controls.Add(best);

            HtmlGenericControl value = new HtmlGenericControl("meta");

            value.Attributes.Add("itemprop", "ratingValue");
            value.Attributes.Add("content", Rating.ToString("F2", CultureInfo.InvariantCulture));
            value.Attributes.Add("datatype", "float");
            itemprop.Controls.Add(value);

            HtmlGenericControl count = new HtmlGenericControl("meta");

            count.Attributes.Add("itemprop", "ratingCount");
            count.Attributes.Add("content", RatingField.Votes.ToString());
            count.Attributes.Add("datatype", "integer");
            itemprop.Controls.Add(count);

            this.Controls.Add(itemprop);
        }
示例#6
0
        protected override void CreateChildControls()
        {
            this.DisableInputFieldLabel = true;
            base.ControlMode            = SPContext.Current.FormContext.FormMode;

            if (base.ControlMode == SPControlMode.Display || base.ControlMode == SPControlMode.Invalid)
            {
                ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(this);
                //Page.RegisterRequiresPostBack(this);
                //Page.RegisterRequiresRaiseEvent(this);
            }

            base.CreateChildControls();
            RatingField = (HTML5RatingField)ItemFieldValue;

            if (RatingField == null)
            {
                try
                {
                    url = SPContext.Current.Web.Url;
                    Guid listId = this.ListId;
                    Guid itemId = this.ListItem.UniqueId;

                    using (SPSite site = new SPSite(url))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            SPListItem item = web.Lists[listId].Items[itemId];
                            //SPFile file = web.GetFile(itemId);
                            //SPListItem item = file.ListItemAllFields;

                            RatingField    = item[BuildFieldId.Rating] as HTML5RatingField;
                            ItemFieldValue = RatingField;
                        }
                    }
                }
                catch (Exception)
                {
                    RatingField = new HTML5RatingField();
                }
                if (RatingField == null)
                {
                    RatingField = new HTML5RatingField();
                }
            }

            if (settings == null)
            {
                settings = new RatingSettings();
                settings = settings.Load();
            }

            if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New)
            {
                RatingField.Maximum = settings.Maximum;
                RatingField.Minimum = settings.Minimum;
                RatingField.Step    = settings.Step;
            }
            else
            {
                input_rating = (RatingInput)this.TemplateContainer.FindControl("RatingInput");

                if (input_rating != null)
                {
                    if (!Page.ClientScript.IsClientScriptIncludeRegistered("jQuery"))
                    {
                        Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5RatingControl), "jQuery", "/_layouts/Hemrika/Content/js/jquery.min.js");
                    }

                    if (!Page.ClientScript.IsClientScriptIncludeRegistered("RateIt"))
                    {
                        Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5RatingControl), "RateIt", "/_layouts/Hemrika/Content/js/jquery.rateit.js");
                    }

                    CssRegistration.Register("/_layouts/Hemrika/Content/css/rateit.css");

                    input_rating.TextChanged += new EventHandler(input_rating_TextChanged);
                    input_rating.Step         = RatingField.Step;
                    input_rating.Maximum      = settings.Maximum;
                    input_rating.Minimum      = settings.Minimum;
                    input_rating.Votes        = RatingField.Votes;

                    if (RatingField.Votes > 0)
                    {
                        input_rating.Value = float.Parse((RatingField.Rating / RatingField.Votes).ToString());
                        input_rating.Text  = float.Parse((RatingField.Rating / RatingField.Votes).ToString()).ToString("F2", CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        input_rating.Value = 0.0f;
                        input_rating.Text  = "0.0";
                    }

                    //input_rating.Value = 0.0f;
                    //input_rating.Text = "0.0f";

                    HtmlGenericControl rating = new HtmlGenericControl("div");
                    rating.Attributes.Add("class", "rateit");
                    rating.Attributes.Add("data-rateit-backingfld", "#" + input_rating.ClientID);
                    rating.Attributes.Add("data-rateit-resetable", "false");

                    if (Page.IsPostBack || HasVote())
                    {
                        rating.Attributes.Add("data-rateit-readonly", "true");
                    }

                    this.Controls.Add(rating);
                    //ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(rating);
                }

                MicroDate();
            }
        }
示例#7
0
 public void Save(RatingSettings ratingSettings)
 {
     throw new System.NotImplementedException();
 }