Ejemplo n.º 1
0
        private void SetFieldControlValue(object value)
        {
            ArrayList       list       = new ArrayList();
            HTML5VideoField videoField = null;

            if (videoPicker != null)
            {
                if (this.ControlMode == SPControlMode.New && videoPicker.Entities.Count == 0)
                {
                    videoField = new HTML5VideoField();
                    HTML5VideoPickerEntity defaultEntity = this.videoPicker.ValidateEntity(new HTML5VideoPickerEntity()
                    {
                        Key = videoField.Src
                    });
                    if (defaultEntity != null)
                    {
                        list.Add(defaultEntity);
                    }
                    videoPicker.Entities.Clear();
                    videoPicker.UpdateEntities(list);
                }

                if (value != null)
                {
                    ArrayList              entities = new ArrayList();
                    HTML5VideoField        field    = (HTML5VideoField)value;
                    HTML5VideoPickerEntity entity   = new HTML5VideoPickerEntity(field);
                    entities.Add(entity);
                    videoPicker.UpdateEntities(entities);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override PickerEntity ValidateEntity(PickerEntity entity)
        {
            if (entity != null)
            {
                HTML5VideoPickerEntity videoEntity = new HTML5VideoPickerEntity(entity);
                entity = ValidateEntity(videoEntity) as PickerEntity;

                if (!entity.IsResolved)
                {
                    PickerEntity[] resolved = ResolveErrorBySearch(entity.DisplayText);
                    if (resolved != null && resolved.Count() == 1)
                    {
                        return(resolved[0]);
                        //entity.IsResolved = true;
                    }
                    else
                    {
                        entity.MultipleMatches.Add(resolved);
                    }
                    return(entity);
                }
                else
                {
                    return(entity);
                }
            }
            else
            {
                return(entity);
            }
        }
Ejemplo n.º 3
0
        public HTML5VideoPickerEntity GetEntity(HTML5VideoDataSet.HTML5VideosRow dr)
        {
            // No datarow provided
            if (dr == null)
            {
                return(null);
            }

            // Create new picker
            HTML5VideoPickerEntity entity = new HTML5VideoPickerEntity();

            entity.Key         = dr.Src;
            entity.DisplayText = dr.Src;
            entity.Alt         = dr.Alt;
            entity.Src         = dr.Src;
            entity.Height      = dr.Height;
            entity.Width       = dr.Width;
            entity.Description = dr.Alt;
            entity.Web         = dr.Web;
            entity.List        = dr.List;
            entity.Preview     = dr.Preview;
            entity.IsResolved  = true;
            entity.ItemId      = dr.VideoId;

            return(entity);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Validate picker entity
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public HTML5VideoPickerEntity ValidateEntity(HTML5VideoPickerEntity entity)
        {
            //entity.IsResolved = true;
            return(entity);
            //entity.EntityData = videoEntity.EntityData;

            //return base.ValidateEntity(videoEntity);
        }
Ejemplo n.º 5
0
 public HTML5VideoField(HTML5VideoPickerEntity videoEntity)
 {
     // TODO: Complete member initialization
     ItemId           = videoEntity.ItemId;
     ListId           = videoEntity.ListId;
     WebId            = videoEntity.WebId;
     Src              = videoEntity.Src;
     this.videoEntity = videoEntity;
 }
Ejemplo n.º 6
0
        public override void UpdateFieldValueInItem()
        {
            EnsureChildControls();

            if (videoPicker.Enabled)
            {
                videoPicker.Validate();
                if (videoPicker.Entities.Count > 0)
                {
                    PickerEntity entity = null;
                    if (videoPicker.ResolvedEntities.Count == 1)
                    {
                        entity = (PickerEntity)videoPicker.ResolvedEntities[0];
                    }
                    else
                    {
                        entity = (PickerEntity)videoPicker.Entities[0];
                    }

                    HTML5VideoPickerEntity videoEntity = new HTML5VideoPickerEntity(entity);

                    HTML5VideoField itemFieldValue = (HTML5VideoField)this.ItemFieldValue;

                    if (videoEntity.IsResolved)
                    {
                        if (itemFieldValue == null)
                        {
                            itemFieldValue = new HTML5VideoField();
                        }

                        itemFieldValue.Src    = videoEntity.Src;
                        itemFieldValue.ItemId = videoEntity.ItemId;
                        itemFieldValue.WebId  = videoEntity.WebId;
                        itemFieldValue.ListId = videoEntity.ListId;

                        this.ItemFieldValue = itemFieldValue;

                        UpdateVideoElement();
                    }
                }
            }
        }
        private void CreateTable()
        {
            resultTable = new Table
            {
                Width       = Unit.Percentage(100.0),
                ID          = "resultTable",
                CssClass    = "ms-pickerresulttable",
                CellSpacing = 0,
                CellPadding = 0,
                BackColor   = Color.White
            };
            resultTable.ID = "resultTable";
            resultTable.Attributes.Add("hideFocus", "true");
            resultTable.Attributes.Add("EditorControlClientId", PickerDialog.EditorControl.ClientID);

            //Create Table Header Row
            TableRow child = null;

            if (PickerDialog.Results != null)
            {
                dt = PickerDialog.Results;


                child = new TableRow
                {
                    CssClass = "ms-pickerresultheadertr"
                };

                foreach (string column in columns)
                {
                    TableHeaderCell cell = new TableHeaderCell
                    {
                        CssClass = "ms-ph"
                    };
                    cell.Attributes.Add("UNSELECTABLE", "on");
                    Literal literal = new Literal
                    {
                        Text = SPHttpUtility.HtmlEncode(column)
                    };

                    cell.Controls.Add(literal);
                    child.Controls.Add(cell);
                }

                resultTable.Controls.Add(child);


                if (dt.Rows.Count == 0)
                {
                    child = new TableRow
                    {
                        CssClass = "ms-pickeremptyresulttexttr"
                    };

                    TableCell cell2 = new TableCell
                    {
                        CssClass   = "ms-descriptiontext",
                        ColumnSpan = columns.Length
                    };
                    Literal literal2 = new Literal
                    {
                        Text = SPHttpUtility.HtmlEncode("No search was given")
                    };
                    cell2.Controls.Add(literal2);
                    child.Controls.Add(cell2);
                    resultTable.Controls.Add(child);
                }
                else
                {
                    int    num          = 0;
                    string selectSingle = "PickerResultsSingleSelectOnClick(this);";
                    string selectDouble = "PickerResultsSingleSelectOnDblClick(this);";

                    foreach (HTML5VideoDataSet.HTML5VideosRow row in dt.Rows)
                    {
                        HTML5VideoPickerEntity entity = PickerDialog.QueryControl.GetEntity(row);

                        if (entity != null)
                        {
                            child = new TableRow
                            {
                                ID = string.Format(CultureInfo.InvariantCulture, "row{0}", new object[] { num })
                            };

                            child.Attributes.Add("tabindex", "-1");
                            child.Attributes.Add("resultRow", "resultRow");

                            if ((num % 2) == 0)
                            {
                                child.CssClass = "ms-alternating";
                            }

                            ArrayList entities = new ArrayList();

                            entities.Add(entity);

                            string callback = PickerDialog.EditorControl.GenerateCallbackData(entities, false);
                            child.Attributes.Add("entityXml", callback);
                            child.Attributes.Add("onmousedown", "return singleselectevent(event);");
                            child.Attributes.Add("onclick", selectSingle);
                            child.Attributes.Add("ondblclick", selectDouble);
                            child.Attributes.Add("onkeydown", "PickerResultsNameOnKeyDown(this, event,false);");
                            child.Attributes.Add("onfocus", "PickerResultsNameOnFocus(this, event, false);");

                            child.Attributes.Add("key", entity.Key);

                            for (int i = 0; i < columns.Length; i++)
                            {
                                this.RenderRowColumn(row, i, child);
                            }
                            resultTable.Controls.Add(child);
                            num++;
                        }
                    }

                    if (base.PickerDialog.Results.Rows.Count > 1)
                    {
                        child = new TableRow
                        {
                            CssClass = "ms-pickersearchsummarytr",
                            ID       = "PickerSearchResultSummaryRow"
                        };
                        TableCell cell3 = new TableCell
                        {
                            CssClass   = "ms-descriptiontext",
                            ColumnSpan = dt.Columns.Count
                        };
                        cell3.Controls.Add(new LiteralControl(SPHttpUtility.HtmlEncode(String.Format("{0} results found.", new object[] { base.PickerDialog.Results.Rows.Count }))));
                        child.Controls.Add(cell3);
                        resultTable.Controls.Add(child);
                    }

                    this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "__SELECTION__HELPER__", "<script type=\"text/javascript\">\r\n                // <![CDATA[\r\n                function " + SPHttpUtility.EcmaScriptStringLiteralEncode(PickerDialog.GetSelectedClientSideFunctionName) + "()\r\n                {\r\n                    var selKeys=new Array(selected.length);\r\n                    for(i=0;i<selected.length;i++)\r\n                    {\r\n                        var uniquekey=selected[i].getAttribute('key').toString();\r\n                        selKeys[i]=uniquekey;\r\n                    }\r\n                    return selKeys;\r\n                }\r\n                // ]]>\r\n                </script>");
                }
            }
        }
Ejemplo n.º 8
0
        protected override void CreateChildControls()
        {
            this.DisableInputFieldLabel = true;
            base.ControlMode            = SPContext.Current.FormContext.FormMode;
            base.CreateChildControls();


            videoField = (HTML5VideoField)ItemFieldValue;

            if (videoField == null)
            {
                videoField = new HTML5VideoField();
            }

            settings = new VideoSettings();
            settings = settings.Load();

            SPFolder folder = null;

            //SPWeb web = null;

            //image = (Hemrika.SharePresence.Html5.WebControls.Image)this.TemplateContainer.FindControl("html_image");
            videoPicker = (HTML5VideoPicker)this.TemplateContainer.FindControl("VideoPicker");
            video       = (Hemrika.SharePresence.Html5.WebControls.Video) this.TemplateContainer.FindControl("html_video");

            if (!ChildControlsCreated)
            {
                if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New)
                {
                    if (!Page.IsCallback)
                    {
                        HTML5VideoPropertyBag properties = new HTML5VideoPropertyBag();

                        if (folder != null)
                        {
                            properties.ItemId = folder.UniqueId;
                            properties.WebId  = folder.ParentWeb.ID;
                            properties.ListId = folder.ParentListId;
                        }
                        else
                        {
                            properties.WebId  = SPContext.Current.Web.ID;
                            properties.ListId = SPContext.Current.ListId;
                            properties.ItemId = SPContext.Current.ListItem.UniqueId;
                        }

                        if (videoPicker != null)
                        {
                            upload = (HyperLink)videoPicker.FindControl("upload");

                            if (upload != null)
                            {
                                upload.NavigateUrl = String.Format(upload.NavigateUrl, video.ClientID, videoPicker.ClientID, base.Web.ID);
                            }

                            videoPicker.OnValueChangedClientScript = "UpdateVideoAfterDialog('" + video.ClientID + "','" + videoPicker.ClientID + "');";
                            videoPicker.AfterCallbackClientScript  = "UpdateVideoAfterDialog('" + video.ClientID + "','" + videoPicker.ClientID + "');";

                            if (folder != null)
                            {
                                HTML5VideoPickerEntity entity = new HTML5VideoPickerEntity(folder.Item);

                                videoPicker.CustomProperty = properties.ToString();
                                videoPicker.Entities.Add(entity);
                                videoPicker.UpdateEntities(videoPicker.Entities);
                            }
                        }
                    }
                }

                if (video != null)
                {
                    videoField = (HTML5VideoField)ItemFieldValue;

                    if (videoField != null)
                    {
                        if (!Page.ClientScript.IsClientScriptIncludeRegistered("Video"))
                        {
                            Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5VideoControl), "Video", "/_layouts/Hemrika/Content/js/video.js");
                        }

                        CssRegistration.Register("/_layouts/Hemrika/Content/css/video-js.css");

                        if (!Page.ClientScript.IsClientScriptBlockRegistered("VideoFlash"))
                        {
                            Page.ClientScript.RegisterClientScriptBlock(typeof(HTML5VideoControl), "VideoFlash", "_V_.options.flash.swf = \"" + ItemContext.Site.Url + "/_layouts/Hemrika/Content/js/video-js.swf\";", true);
                        }

                        if (videoField.WebId != Guid.Empty && videoField.ItemId != Guid.Empty)
                        {
                            using (SPWeb web = SPContext.Current.Site.OpenWeb(videoField.WebId))
                            {
                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.ItemId);
                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                                else
                                {
                                    video.Visible = false;
                                }
                            }
                        }
                        else
                        {
                            bool useRoot = false;
                            using (SPWeb web = SPContext.Current.Site.OpenWeb(videoField.Src))
                            {
                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.Src);

                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                                else
                                {
                                    useRoot = true;
                                }
                            }

                            if (useRoot)
                            {
                                SPWeb web = SPContext.Current.Site.RootWeb;

                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.Src);

                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //ChildControlsCreated = true;
        }