public string UpgradeModule(string Version) { // Upgrade 03.02.00 // Sets the Modules with Image to Media if (string.Equals(Version, "03.02.00")) { try { MediaController objMC = new MediaController(); objMC.UpgradeMedia(GetModuleDefID("DNN_Image"), GetModuleDefID("DNN_Media")); // clear entire cache DataCache.ClearHostCache(true); return("True"); } catch (Exception ex) { Exceptions.LogException(ex); return("False"); } } return("True"); }
private string FormatURL(string Link, bool TrackClicks, int TabId, int ModuleId) { if (TrackClicks) { return(MediaController.EncodeUrl(Globals.LinkClick(Link, TabId, ModuleId, TrackClicks))); } else { return(MediaController.EncodeUrl(Link)); } }
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); }
private void SaveMedia() { var objMediaController = new MediaController(); var objMedia = new MediaInfo(); try { // Update settings in the database if (this.radMediaType.SelectedIndex == 0) // standard file system { if (string.Equals(ctlURL.UrlType, "F")) { IFileInfo objFile = FileManager.Instance.GetFile(int.Parse(Regex.Match(this.ctlURL.Url, "\\d+").Value, System.Globalization.NumberStyles.Integer)); if (objFile != null) { if (string.IsNullOrEmpty(this.txtWidth.Text)) { this.txtWidth.Text = objFile.Width.ToString(); } if (string.IsNullOrEmpty(this.txtHeight.Text)) { this.txtHeight.Text = objFile.Height.ToString(); } } } } var sec = new PortalSecurity(); objMedia.ModuleID = ModuleId; objMedia.MediaType = this.radMediaType.SelectedIndex; switch (this.radMediaType.SelectedIndex) { case 0: // standard file system objMedia.Src = this.ctlURL.Url; break; case 1: // embed code objMedia.Src = this.txtEmbed.Text; break; case 2: // oembed url objMedia.Src = this.txtOEmbed.Text; break; } // ensure that youtube gets formatted correctly objMedia.Src = ReformatForYouTube(objMedia.Src); objMedia.Alt = sec.InputFilter(this.txtAlt.Text, PortalSecurity.FilterFlag.NoMarkup); if (!(string.IsNullOrEmpty(this.txtWidth.Text))) { objMedia.Width = int.Parse(sec.InputFilter(this.txtWidth.Text, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer); } if (!(string.IsNullOrEmpty(this.txtHeight.Text))) { objMedia.Height = int.Parse(sec.InputFilter(this.txtHeight.Text, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer); } objMedia.NavigateUrl = sec.InputFilter(this.ctlNavigateUrl.Url, PortalSecurity.FilterFlag.NoMarkup); objMedia.MediaAlignment = int.Parse(sec.InputFilter(this.ddlImageAlignment.SelectedValue, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer); objMedia.AutoStart = this.chkAutoStart.Checked; objMedia.MediaLoop = this.chkLoop.Checked; objMedia.LastUpdatedBy = this.UserId; objMedia.MediaMessage = sec.InputFilter(this.txtMessage.Text, PortalSecurity.FilterFlag.NoScripting); // url tracking var objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, this.ctlNavigateUrl.Url, this.ctlNavigateUrl.UrlType, this.ctlNavigateUrl.Log, this.ctlNavigateUrl.Track, ModuleId, this.ctlNavigateUrl.NewWindow); // update settings/preferences SaveMediaSettings(); // add/update if (p_isNew) { // add new media objMediaController.AddMedia(objMedia); } else { // update existing media objMediaController.UpdateMedia(objMedia); } // save the update into the journal if (PostToJournal) { AddMediaUpdateToJournal(objMedia); } // notify the site administrators if (NotifyOnUpdate) { SendNotificationToMessageCenter(objMedia); } } catch (Exception exc) //Module failed to load { Exceptions.LogException(exc); //ProcessModuleLoadException(Me, exc) } }
private void BindData() { this.LocalizeModule(); // Obtain a single row of text information MediaController objMediaController = new MediaController(); MediaInfo objMedia = objMediaController.GetMedia(ModuleId); this.BindControls(); if (objMedia != null && objMedia.ModuleID > Null.NullInteger) { p_isNew = false; this.ddlImageAlignment.SelectedValue = objMedia.MediaAlignment.ToString(); this.ToggleFileTypeView(objMedia.MediaType); switch (objMedia.MediaType) { case 0: // local file system this.ctlURL.Url = objMedia.Src; break; case 1: // embed code this.txtEmbed.Text = System.Web.HttpUtility.HtmlDecode(objMedia.Src); break; case 2: // embedable url this.txtOEmbed.Text = objMedia.Src; break; } this.txtAlt.Text = objMedia.Alt; if (objMedia.Width != Null.NullInteger) { this.txtWidth.Text = objMedia.Width.ToString(); } if (objMedia.Height != Null.NullInteger) { this.txtHeight.Text = objMedia.Height.ToString(); } this.ctlNavigateUrl.Url = objMedia.NavigateUrl; this.ctlTracking.URL = objMedia.NavigateUrl; this.ctlTracking.ModuleID = ModuleId; this.chkAutoStart.Checked = objMedia.AutoStart; this.chkLoop.Checked = objMedia.MediaLoop; this.txtMessage.Text = objMedia.MediaMessage; } else { p_isNew = true; } // populate the setting controls BindSettings(); // populate the support file types in the UI this.BindSupportedFileTypes(); ToggleSettingViews(); // only show the side-wide settings when Admnistrators are logged in liSideWideJournalSetting.Visible = UserInfo.IsInRole(PortalSettings.AdministratorRoleName); liNotifyOnUpdate.Visible = liSideWideJournalSetting.Visible; }