private void BindData() { MediaController ctlMedia = new MediaController(); List <string> lstMedia = ctlMedia.DisplayMedia(ModuleId, TabId, IsEditable, ModuleConfiguration, PortalSettings); if (string.IsNullOrEmpty(lstMedia[0])) { if (IsEditable) { // there is no media yet DNNSkins.Skin.AddModuleMessage(this, GetLocalizedString("NoMediaMessage.Text"), ModuleMessage.ModuleMessageType.BlueInfo); } else { // hide the module ContainerControl.Visible = false; } return; } if (!string.IsNullOrEmpty(lstMedia[2])) { // there's an error returned DNNSkins.Skin.AddModuleMessage(this, GetLocalizedString(lstMedia[1]), ModuleMessage.ModuleMessageType.YellowWarning); } else { // there's media to display MediaLiteral.Text = string.Format(MEDIA_WRAPPER_TAG, lstMedia[0]); if (!string.IsNullOrEmpty(lstMedia[1])) { MessageLiteral.Text = string.Format(MESSAGE_TAG, TabModuleId, HttpUtility.HtmlDecode(lstMedia[1])); } } }
/// <summary> /// Adds the media update to the journal /// </summary> /// <param name="oMedia"></param> private void AddMediaUpdateToJournal(MediaInfo oMedia) { MediaController ctlMedia = new MediaController(); // // Object Keys - great to GET data out of the journal // Create an oject key scheme unique to your data that will likely never change // var objectKey = MediaController.GetObjectKeyForJournal(ModuleId, UserId); // // Defensive coding to prevent duplicate journal entries // // attempt to get a reference to a journal item var ji = JournalController.Instance.GetJournalItemByKey(PortalId, objectKey); // delete the journal item if it already exists if (ji != null) { JournalController.Instance.DeleteJournalItemByKey(PortalId, objectKey); } // ensure we have a valid title for the journal status string tabTitle = PortalSettings.ActiveTab.Title; // if there isn't a Page Title in the Page Settings, use the Page Name if (string.IsNullOrEmpty(tabTitle)) { tabTitle = PortalSettings.ActiveTab.TabName; } // Method unique to the Media Module to generate Media markup for images, videos, music, etc. List <string> lstMedia = ctlMedia.DisplayMedia(ModuleId, TabId, IsEditable, ModuleConfiguration, PortalSettings); // // Create a journal item object // // If valid media was returned, create a new journal item object if (!string.IsNullOrEmpty(lstMedia[0])) { // ensure that an acceptable description is generated for the journal string desc = string.Empty; if (!Regex.IsMatch(oMedia.ContentType, @"^image/", RegexOptions.IgnoreCase)) { // use a generic placeholder for non-image media as a click-through desc = string.Format("<a href=\"{0}\"><img src=\"/DesktopModules/Media/Images/play-button.png\" alt=\"{1}\" /></a>", Common.Globals.NavigateURL(TabId), oMedia.Alt); } else { // use the saved media desc = lstMedia[0]; } // create a new journal item object ji = new JournalItem { PortalId = PortalId, // site id number ProfileId = UserId, // profile id that this should be posted under UserId = UserId, // id of the user account that generated the journal item ContentItemId = ModuleId, // ordinarily, this will be a contentID Title = oMedia.Alt, // title of the journal item in the meta data ItemData = new ItemData { ImageUrl = "\"/DesktopModules/Media/Images/play-button.png\"", Description = desc, Title = oMedia.Alt, Url = Common.Globals.NavigateURL(TabId) }, // used to populate the journal item template, depending on the journal type Summary = string.Format(GetLocalizedString("Journal.Status.Media.Updated"), oMedia.Alt, Common.Globals.NavigateURL(TabId), tabTitle), // the text shown in the journal status Body = null, // not really used in the default templates, but could be in your own JournalTypeId = MediaController.GetMediaJournalTypeID(PortalId), // local method to choose the journal type globally ObjectKey = objectKey, // your object key from above SecuritySet = "E," // valid values include: E = Everyone, F = Friends Only, U = Private, P = Profile Only, R[n] = Role Id }; } else { // create a generic journal item object for the media ji = new JournalItem { PortalId = PortalId, ProfileId = UserId, UserId = UserId, ContentItemId = ModuleId, // ordinarily, this will be a contentID Title = oMedia.Alt, Summary = string.Format(GetLocalizedString("Journal.Status.Media.Updated"), oMedia.Alt, Common.Globals.NavigateURL(TabId), tabTitle), Body = null, JournalTypeId = MediaController.GetMediaJournalTypeID(PortalId), ObjectKey = objectKey, SecuritySet = "E," }; } // send your new journal item to the feed JournalController.Instance.SaveJournalItem(ji, TabId); }