コード例 #1
0
		protected void Page_Load(object sender, EventArgs e) {

			try {
				//get the current item and database
				currentDB = Sitecore.Configuration.Factory.GetDatabase("master");
				currentItem = new PlaylistItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
				Item acct = currentItem.playlistItem.Parent.Parent;
				//if current parent isn't the account then it's the parent of the folder
				if (!acct.TemplateName.Equals("Account Folder")) {
					acct = acct.Parent;
				}
				accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
				bc = new BCAPI(accountItem.PublisherID);
				
				if (!IsPostBack) {
					loadFormWithCurrentValues();

					//load non-editable information
					ltlPlaylistID.Text = currentItem.PlaylistID.ToString();
					ltlVideos.Text = currentItem.VideoIds.Count.ToString(); 
					ltlAccount.Text = currentItem.AccountId.ToString();
				}
			}
			catch (Exception ex) {
				ltlError.Text = ex.ToString();
			}
		}
コード例 #2
0
		public static UpdateInsertPair<PlaylistItem> ImportToSitecore(this AccountItem account, List<BCPlaylist> Playlists, UpdateType utype) {

			UpdateInsertPair<PlaylistItem> uip = new UpdateInsertPair<PlaylistItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists) {
				if (!ht.ContainsKey(exPlay.playlistItem.ToString())) {
					//set as string, Item pair
					ht.Add(exPlay.PlaylistID.ToString(), exPlay);
				}
			}

			//Loop through the data source and add them
			foreach (BCPlaylist play in Playlists) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						PlaylistItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (PlaylistItem)ht[play.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
							currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
					}
				} catch (System.Exception ex) {
					throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
コード例 #3
0
		protected void Page_Load(object sender, EventArgs e) {

			try {
				//get the current item and database
				currentDB = Sitecore.Configuration.Factory.GetDatabase("master");
				currentItem = new PlaylistItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]);
				Item acct = currentItem.playlistItem.Parent.Parent;
				//if current parent isn't the account then it's the parent of the folder
				if (!acct.TemplateName.Equals("Account Folder")) {
					acct = acct.Parent;
				}
				accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database);
				bc = new BCAPI(accountItem.PublisherID);
		
				if (!currentItem.ThumbnailURL.Equals("")) {
					pnlThumb.Visible = true;
					imgThumb.ImageUrl = currentItem.ThumbnailURL;
				}
			}
			catch (Exception ex) {
				ltlError.Text = ex.ToString();
			}
		}
コード例 #4
0
		/// <summary>
		/// this makes sure you've selected an item from the video treeview
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		protected override void OnOK(object sender, EventArgs args) {
			Assert.ArgumentNotNull(sender, "sender");
			Assert.ArgumentNotNull(args, "args");

			//get the selected playlist
			Item player = masterDB.Items[PlayerTreeview.Value];
			if (player == null || !player.TemplateName.Equals(Constants.PlayerTemplate)) {
				SheerResponse.Alert("Select a player.", new string[0]);
				return;
			}
            
			//get the selected video
			Item video = masterDB.Items[VideoTreeview.Value];
			string videoid = "";
			if (video != null && video.TemplateName.Equals(Constants.VideoTemplate)) {
				VideoItem vid = new VideoItem(video);
                videoid = vid.VideoID.ToString();
			}
			
			//get the selected playlists
			Item[] playlists = this.PlaylistTreeview.GetSelectedItems();
			PlayerItem vpl = new PlayerItem(player);
					
			//set the playlists
			StringBuilder playlistStr = new StringBuilder();
			int plistCount = 0;
			foreach (Item p in playlists) {
                if (p.TemplateName.Equals(Constants.PlaylistTemplate)) {
					PlaylistItem pl = new PlaylistItem(p);
                    if (playlistStr.Length > 0) {
						playlistStr.Append(",");
					}
					playlistStr.Append(pl.PlaylistID.ToString());
					plistCount++;
				}
			}

			//check if the player can handle the playlists selected
			if (vpl.PlaylistType.Equals(PlayerPlaylistType.None) && plistCount > 0) {
				SheerResponse.Alert("This player does not support playlists.\nTo deselect, select the Brightcove Media item.", new string[0]);
				return;
			} else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) && plistCount > 1) {
				SheerResponse.Alert("This player only supports one playlist.", new string[0]);
				return;
			} else if ((vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) ||
				vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox) ||
				vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)) && !videoid.Equals("")) {
				SheerResponse.Alert("This player does not support videos. \nTo deselect, select the Brightcove Media item.", new string[0]);
				return;
			}
			
			//build link then send it back
			StringBuilder mediaUrl = new StringBuilder();
			mediaUrl.Append("<bc:VideoPlayerWebControl runat=\"server\" class=\"BrightcoveVideo\" xmlns:bc=\"http://www.sitecore.net/xhtml\" ");
			mediaUrl.Append("player=\"" + vpl.PlayerID + "\" ");
			mediaUrl.Append("autostart=\"" + chkAutoStart.Checked.ToString().ToLower() + "\" ");
			mediaUrl.Append("bgcolor=\"" + txtBGColor.Value + "\" ");
			mediaUrl.Append("wmode=\"" + WMode.SelectedItem.Header + "\" ");
			
			//determine what kind of playlist
			if (vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox)) {
				mediaUrl.Append("playlistcombo=\"" + playlistStr.ToString() + "\" ");
			}else if (vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)){
				mediaUrl.Append("playlisttabs=\"" + playlistStr.ToString() + "\" "); 
			}else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList)){
				mediaUrl.Append("videolist=\"" + playlistStr.ToString() + "\" "); 	
			}else if (vpl.PlaylistType.Equals(PlayerPlaylistType.None)){
				mediaUrl.Append("video =\"" + videoid + "\" ");
			}
			
			//close the tag
			mediaUrl.Append("></bc:VideoPlayer>");
			
			//send it back
			if (this.Mode == "webedit") {
				SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(mediaUrl.ToString()));
				base.OnOK(sender, args);
			} else {
				SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(mediaUrl.ToString()) + "," + StringUtil.EscapeJavascriptString(player.DisplayName) + ")");
			}
		}
コード例 #5
0
		/// <summary>
		/// this makes sure you've selected an item from the video treeview
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		protected override void OnOK(object sender, EventArgs args) {
			Assert.ArgumentNotNull(sender, "sender");
			Assert.ArgumentNotNull(args, "args");
			
			//get the selected player
			Item player = masterDB.Items[PlayerTreeview.Value];
			if (player == null || !player.TemplateName.Equals(Constants.PlayerTemplate)) {
				SheerResponse.Alert("Select a player.", new string[0]);
				return;
			}
			PlayerItem vpl = new PlayerItem(player);

			//get the selected video
			Item video = masterDB.Items[VideoTreeview.Value];
			VideoItem vid = null;
			string videoid = "";
			if (video != null && video.TemplateName.Equals(Constants.VideoTemplate)) {
				vid = new VideoItem(video);
                videoid = vid.VideoID.ToString(); 
			}
			
			//get the selected playlists
			Item[] playlists = this.PlaylistTreeview.GetSelectedItems();
			
			//set the playlists
			StringBuilder playlistStr = new StringBuilder();
			int plistCount = 0;
			foreach (Item p in playlists) {
				if (p.TemplateName.Equals(Constants.PlaylistTemplate)) {
					PlaylistItem pl = new PlaylistItem(p);
                    if (playlistStr.Length > 0) {
                        playlistStr.Append(",");
                    }
                    playlistStr.Append(pl.PlaylistID.ToString());
                    plistCount++;
				}
			}

			//check if the player can handle the playlists selected
			if (vpl.PlaylistType.Equals(PlayerPlaylistType.None) && plistCount > 0) {
				SheerResponse.Alert("This player does not support playlists.\nTo deselect, select the Brightcove Media item.", new string[0]);
				return;
			} else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) && plistCount > 1) {
				SheerResponse.Alert("This player only supports one playlist.", new string[0]);
				return;
			} else if ((vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) ||
				vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox) ||
				vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)) && !videoid.Equals("")) {
				SheerResponse.Alert("This player does not support videos. \nTo deselect, select the Brightcove Media item.", new string[0]);
				return;
			}

			//use settings to determine what kind of modal window to use like thickbox or prettyphoto
			//id = {3EE8D1E1-1421-4546-8127-4D576FB8DA5F}
            ModalLinkSettings settings = ModalLinkSettings.GetModalLinkSettings(HttpContext.Current.Request.Url.Host.ToLower(), masterDB);
            StringBuilder sbAttr = new StringBuilder();
			StringBuilder sbQstring = new StringBuilder();
			if (settings != null) {
				foreach(Item child in settings.thisItem.GetChildren()){
					if(child.TemplateName.Equals(Constants.LinkAttributeTemplate)){
						sbAttr.Append(" " + child["Key"] + "=\"" + child["Value"] + "\"");
					}
					else if(child.TemplateName.Equals(Constants.LinkQuerystringTemplate)){
						sbQstring.Append("&" + child["Key"] + "=" + child["Value"]);
					}
				}
			}
			
			//build link then send it back
			StringBuilder mediaUrl = new StringBuilder();
			mediaUrl.Append("<a href=\"/BrightcoveVideo.ashx?video=" + videoid + "&player=" + vpl.PlayerID);
			mediaUrl.Append("&playlists=" + playlistStr.ToString());
			mediaUrl.Append("&autoStart=" + chkAutoStart.Checked.ToString().ToLower());
			mediaUrl.Append("&bgcolor=" + txtBGColor.Value.Replace("#", ""));
			mediaUrl.Append("&wmode=" + WMode.SelectedItem.Header);
			mediaUrl.Append("&oparams=" + txtOParams.Value);
			mediaUrl.Append(sbQstring.ToString());
			mediaUrl.Append("&height=" + (vpl.Height + 20).ToString() + "&width=" + (vpl.Width + 20).ToString() + "\"" + sbAttr.ToString() + " title=\"" + txtLinkText.Value + "\">" + txtLinkText.Value + "</a>");
						
			if (this.Mode == "webedit") {
				SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(mediaUrl.ToString()));
				base.OnOK(sender, args);
			} else {
				SheerResponse.Eval("scCloseLink(" + StringUtil.EscapeJavascriptString(mediaUrl.ToString()) + ")");
			}
		}
コード例 #6
0
		protected void SetVideoPlayer() {

			VideoItem vp = new VideoItem(currentDB.Items[ddlVideo.SelectedValue]);
			vpPlayer.PlayerID = currentItem.PlayerID;
			vpPlayer.VideoID = vp.VideoID;
			vpPlayer.PlayerName = currentItem.Name;
			vpPlayer.Height = currentItem.Height;
			vpPlayer.Width = currentItem.Width;
			if (chkAutoStart.Checked) {
				vpPlayer.AutoStart = true;
			}
			vpPlayer.WMode = ddlWMode.SelectedValue;
						
			IEnumerable<string> selected = from li in cblPlaylist.Items.Cast<ListItem>() where li.Selected == true select li.Value;
			vpPlayer.VideoList = -1;
			vpPlayer.PlaylistCombos.Clear();
			vpPlayer.PlaylistTabs.Clear();
			vpPlayer.CssClass = "BrightcoveExperience";

			WMode wmode = WMode.Window;
			try {
				wmode = (WMode)Enum.Parse(wmode.GetType(), ddlWMode.SelectedValue, true);
			}catch{}
			
			switch (currentItem.PlaylistType) {
				case PlayerPlaylistType.VideoList:
					if (selected.Count() > 0) {
						PlaylistItem p = new PlaylistItem(currentDB.Items[selected.First()]);
						vpPlayer.VideoList = p.PlaylistID;
						pnlVideo.Visible = false;
					}
					break;
				case PlayerPlaylistType.Tabbed:
					List<long> pids = new List<long>();
					foreach (string pID in selected) {
						PlaylistItem p = new PlaylistItem(currentDB.Items[pID]);
						vpPlayer.PlaylistTabs.Add(new PlaylistTab(p.PlaylistID));
						pids.Add(p.PlaylistID);
					}
					pnlVideo.Visible = false;
					break;
				case PlayerPlaylistType.ComboBox:
					List<long> cpids = new List<long>();
					foreach (string pID in selected) {
						PlaylistItem p = new PlaylistItem(currentDB.Items[pID]);
						vpPlayer.PlaylistCombos.Add(new PlaylistCombo(p.PlaylistID));
						cpids.Add(p.PlaylistID);
					}
					pnlVideo.Visible = false;
					break;
				case PlayerPlaylistType.None:
					pnlPlaylist.Visible = false;
					break;
			}
		}