Пример #1
0
        /// <summary>
        /// Initialises the asset buttons control with the specified asset
        /// </summary>
        public void Initialise(Asset asset)
        {
            m_AssetId = asset.AssetId.GetValueOrDefault();

            // Get the URL to be used for the asset popup
            string showAssetInfoUrl = SiteUtils.GetShowAssetInfoUrl(m_AssetId);

            // Setup info button
            InfoHyperlink.Visible     = ShowButtons.IsSet(Buttons.Info);
            InfoHyperlink.NavigateUrl = showAssetInfoUrl;
            InfoHyperlink.ImageUrl    = SiteUtils.GetIconPath("info0.gif");

            // Setup download button
            DownloadHyperLink.Visible     = DisplayDownloadHyperlink(asset);
            DownloadHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(m_AssetId);
            DownloadHyperLink.ImageUrl    = SiteUtils.GetIconPath("download0.gif");

            // Setup lightbox button
            AddToLightboxImageButton.Visible         = (ShowButtons.IsSet(Buttons.Lightbox));
            AddToLightboxImageButton.CommandArgument = m_AssetId.ToString();
            InitialiseLightboxButton(m_AssetId);

            // Setup cart button
            AddToCartImageButton.Visible         = (ShowButtons.IsSet(Buttons.Cart));
            AddToCartImageButton.CommandArgument = m_AssetId.ToString();
            InitialiseCartButton(m_AssetId);

            // Setup restricted icon
            RestrictedImageIcon.Visible  = (EntitySecurityManager.IsAssetRestricted(CurrentUser, asset) && ShowButtons.IsSet(Buttons.Restricted));
            RestrictedImageIcon.ImageUrl = SiteUtils.GetIconPath("restricted0.gif");
        }
        protected void LightboxDataList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):

                Panel         LightboxAssetInfoPanel = (Panel)e.Item.FindControl("LightboxAssetInfoPanel");
                LightboxAsset lightboxAsset          = (LightboxAsset)e.Item.DataItem;

                if (lightboxAsset.IsNull)
                {
                    LightboxAssetInfoPanel.Visible = false;

                    // Clear the CSS class so the background doesnt show
                    WebControl wc = (WebControl)LightboxAssetInfoPanel.Parent;
                    wc.CssClass = string.Empty;
                }
                else
                {
                    Asset asset = lightboxAsset.Asset;

                    AssetThumbnail     AssetThumbnail1 = (AssetThumbnail)e.Item.FindControl("AssetThumbnail1");
                    HtmlGenericControl AssetIdLabel    = (HtmlGenericControl)e.Item.FindControl("AssetIdLabel");
                    HtmlGenericControl AssetTypeLabel  = (HtmlGenericControl)e.Item.FindControl("AssetTypeLabel");
                    Image     NotesImage        = (Image)e.Item.FindControl("NotesImage");
                    HyperLink DownloadHyperLink = (HyperLink)e.Item.FindControl("DownloadHyperLink");

                    AssetThumbnail1.HoverCaption = asset.Title;
                    AssetThumbnail1.HoverText    = GeneralUtils.GetNonEmptyString(lightboxAsset.Notes, "[Sender has not entered any notes]");
                    AssetThumbnail1.Initialise(asset);

                    AssetIdLabel.InnerText   = asset.AssetId.ToString();
                    AssetTypeLabel.InnerText = "(" + asset.AssetType.Name + ")";

                    NotesImage.AlternateText = Server.HtmlEncode(AssetThumbnail1.HoverText);
                    NotesImage.ToolTip       = Server.HtmlEncode(AssetThumbnail1.HoverText);

                    //check if light box was sent with download links enabled
                    //and double check that the sender was super admin
                    if (m_lightboxSent.DownloadLinks.GetValueOrDefault(false) &&
                        m_lightboxSent.Sender.UserRole == UserRole.SuperAdministrator)
                    {
                        DownloadHyperLink.Visible     = true;
                        DownloadHyperLink.NavigateUrl = AssetFileUrlHelper.GetExternalDownloadUrl(asset.AssetId, m_lightboxSent.LightboxSentId, m_lightboxSent.SenderId, m_lightboxSent.DateSent.Ticks);
                        DownloadHyperLink.ImageUrl    = SiteUtils.GetIconPath("download0.gif");
                    }
                    else
                    {
                        DownloadHyperLink.Visible = false;
                    }
                }

                break;
            }
        }
Пример #3
0
        private void SetImageProperties(Asset asset)
        {
            ImageUrl = Page.ResolveClientUrl(AssetFileUrlHelper.GetThumbnailUrl(asset.AssetId.GetValueOrDefault()));

            if (UseCacheBuster)
            {
                ImageUrl += string.Format("?cb={0}", DateTime.Now.Ticks);
            }

            if (ImageLinksToAssetInfo)
            {
                NavigateUrl = SiteUtils.GetShowAssetInfoUrl(asset.AssetId.GetValueOrDefault());
            }

            if (ShowInfoOnHover)
            {
                string captionTitle = SiteUtils.GetAssetHoverCaption(asset, HoverCaption);
                string captionText  = SiteUtils.GetAssetHoverText(asset, HoverText);

                if (!asset.IsPublishedAndAvailable())
                {
                    captionText += "<br/><br/>";

                    if (asset.PublishDate > DateTime.Now)
                    {
                        captionText += "<strong style='color:red'>Asset publish date is in the future</strong><br/>";
                    }

                    if (asset.ExpiryDate < DateTime.Now)
                    {
                        captionText += "<strong style='color:red'>Asset has expired</strong><br/>";
                    }

                    if (asset.AssetPublishStatus != AssetPublishStatus.Published)
                    {
                        captionText += "<strong style='color:red'>Asset is not published</strong><br/>";
                    }
                }

                captionTitle = SiteUtils.MakeJsSafe(captionTitle).Replace("\\n", "<br/>");
                captionText  = SiteUtils.MakeJsSafe(captionText).Replace("\\n", "<br/>");

                string       onmouseover = string.Format("showToolTip('{0}', '{1}')", captionTitle, captionText);
                const string onmouseout  = "hideToolTip();";

                Attributes.Add("onmouseover", onmouseover);
                Attributes.Add("onmouseout", onmouseout);
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (AssetWorkflowCommenter.IsNull)
                {
                    Response.Redirect("~/Admin/Assets/AssetList.aspx");
                }

                if (!StringUtils.IsBlank(AssetWorkflowCommenter.Comments))
                {
                    MessageLabel.SetErrorMessage("You have already commented on this workflow");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }

                if (AssetWorkflow.IsComplete)
                {
                    MessageLabel.SetErrorMessage("Asset workflow is complete and comments have been disabled");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }

                AssetWorkflowUserList.Repeater.DataSource = AssetWorkflow.AssetWorkflowUserList;
                AssetWorkflowUserList.Repeater.DataBind();

                Asset asset = AssetWorkflow.Asset;

                AssetReferenceLiteral.Text = asset.AssetId.ToString();
                UploadUserEmailHyperLink.SetNameEmail(asset.UploadedByUser.FullName, asset.UploadedByUser.Email);
                PublicationDateLiteral.Text        = asset.PublishDate.ToString(Global.DateFormat);
                DownloadAssetHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(asset.AssetId);
                AssetThumbnail.Initialise(asset);
                AssetButtons1.Initialise(asset);
                AssetTypeCell.InnerText           = asset.AssetType.Name;
                BrandCell.InnerText               = asset.BrandName;
                ShortDescriptionCell.InnerHtml    = SiteUtils.ConvertTextToHtml(asset.Description);
                UsageRestrictionsCell.InnerText   = asset.UsageRestrictions;
                InvitingUserName.Text             = AssetWorkflowCommenter.InvitingUser.FullName;
                InvitingUserMessageCell.InnerText = AssetWorkflowCommenter.InvitingUserMessage;
                ResponseTextArea.Text             = AssetWorkflowCommenter.Comments;

                SiteUtils.SetHyperLink("Assets.AssetForm", string.Format("?assetId={0}", asset.AssetId), EditAssetHyperLink);

                AssetWorkflowLog.Bind(AssetWorkflow.Asset);
            }
        }
Пример #5
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Asset.IsNull)
            {
                // No asset
                WriteImage(writer, "~/Images/Spacer.gif");
                return;
            }

            if (!EntitySecurityManager.CanUserViewAssetPreview(SessionInfo.Current.User, Asset))
            {
                // Access denied
                WriteImage(writer, "~/Images/Spacer.gif");
                return;
            }

            // The asset has not been marked as processed, so show a 'processing' image placeholder
            // instead, even if the filepath is not empty.  This is because the file may exist, but
            // may still have data being written to it by another process, so we don't have any
            // guarantee that it's safe to display to the user.
            if (!Asset.IsProcessed)
            {
                WriteImage(writer, "~/Images/Asset/Previews/Processing.gif");
                return;
            }

            // Get asset File Info
            AssetPreviewInfo info = new AssetPreviewInfo(Asset);

            // If we don't have an asset preview file. Show a placeholder image instead.
            if (!info.FileExists)
            {
                WriteImage(writer, "~/Images/Asset/Previews/Unavailable.gif");
                return;
            }

            // Setup variables to be replaced
            string assetPreviewFileExtension = StringUtils.GetFileExtension(info.FilePath);
            string assetPreviewUrl           = AssetFileUrlHelper.GetPreviewUrl(Asset.AssetId);
            string assetPreviewRelativeUrl   = ResolveUrl(assetPreviewUrl);
            string assetPreviewAbsoluteUrl   = SiteUtils.GetWebsiteUrl(assetPreviewUrl);
            string playerId            = ClientID + "_Preview";
            string rtmpStreamingServer = ConfigurationManager.AppSettings.GetValue("RTMPStreamingServer");

            // If the streaming server is enabled, then hack the file extension to get the correct markup
            if (assetPreviewFileExtension == "flv" && !StringUtils.IsBlank(rtmpStreamingServer))
            {
                assetPreviewFileExtension += "-streaming";
            }

            //get the plugin context type
            //use query string if specified otherwise use AdminSessionInfo
            ContextType contextType;

            if (HttpContext.Current.Request.QueryString["ctxt"] != null)
            {
                contextType = PluginManager.GetContextType(HttpContext.Current.Request.QueryString["ctxt"]);
            }
            else
            {
                contextType = SessionInfo.Current.AdminSessionInfo.AssetContext;
            }

            //get the plugin for the asset
            Plugin plugin = ContextInfo.PluginManager.GetPluginForAsset(Asset);

            //get the plugins relative URL
            string relativePluginUrl = ResolveUrl(plugin.RelativePath);

            // Get the HTML
            string markup = ContextInfo.PluginManager.GetMarkup(plugin, contextType);

            // We can override images
            if (StringUtils.IsBlank(markup) && AssetTypeChecker.IsImage(assetPreviewFileExtension))
            {
                WriteImage(writer, assetPreviewUrl);
                return;
            }

            // Otherwise, ensure we have markup
            if (string.IsNullOrEmpty(markup))
            {
                writer.Write(string.Format("[Unable to preview: {0}]", assetPreviewFileExtension));
                return;
            }

            // Replace params
            markup = markup.Replace("[ASSET-PREVIEW-URL]", assetPreviewUrl);
            markup = markup.Replace("[RELATIVE-PREVIEW-URL]", assetPreviewRelativeUrl);
            markup = markup.Replace("[ABSOLUTE-PREVIEW-URL]", assetPreviewAbsoluteUrl);
            markup = markup.Replace("[FOCUSOPEN-PREVIEW-FILENAME]", Path.GetFileName(info.FilePath));
            markup = markup.Replace("[PLAYER-ID]", playerId);
            markup = markup.Replace("[ASSET-ID]", Asset.AssetId.ToString());
            markup = markup.Replace("[ASSET-REFERENCE]", info.Asset.FileReference);
            markup = markup.Replace("[STREAMING-SERVER-URL]", rtmpStreamingServer);
            markup = markup.Replace("[USER-ID]", SessionInfo.Current.User.UserId.GetValueOrDefault().ToString());
            markup = markup.Replace("[PREVIEW-FILE-EXTENSION]", assetPreviewFileExtension);
            markup = markup.Replace("[ASSET-TYPE-ID]", Asset.AssetTypeId.ToString());
            markup = markup.Replace("[ASSET-TYPE-NAME]", Asset.AssetType.Name);
            markup = markup.Replace("[PREVIEW-AVAILABLE]", (info.PreviewAvailable ? "true" : "false"));
            markup = markup.Replace("[PLUGIN-URL]", relativePluginUrl);
            markup = markup.Replace("[SESSIONAPITOKEN]", SessionInfo.Current.User.SessionAPIToken);
            markup = markup.Replace("~/", WebUtils.GetApplicationPath());

            // Write the HTML to the page
            writer.Write(markup);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (Asset.IsNull)
            {
                // No asset

                WriteImage(writer, "~/Images/Asset/Previews/Unavailable.gif");
                return;
            }

            if (!EntitySecurityManager.CanUserViewAssetPreview(SessionInfo.Current.User, Asset))
            {
                // Access denied

                WriteImage(writer, "~/Images/Asset/Previews/Unavailable.gif");
                return;
            }

            // The asset has not been marked as processed, so show a 'processing' image placeholder
            // instead, even if the filepath is not empty.  This is because the file may exist, but
            // may still have data being written to it by another process, so we don't have any
            // guarantee that it's safe to display to the user.
            if (!Asset.IsProcessed)
            {
                WriteImage(writer, "~/Images/Asset/Previews/Processing.gif");
                return;
            }

            // Get asset File Info
            AssetPreviewInfo info = new AssetPreviewInfo(Asset);

            // If we don't have an asset preview file. Show a placeholder image instead.
            if (!info.FileExists)
            {
                WriteImage(writer, "~/Images/Asset/Previews/Unavailable.gif");
                return;
            }

            // Setup variables to be replaced
            string fileExtension       = StringUtils.GetFileExtension(info.FilePath);
            string assetPreviewUrl     = AssetFileUrlHelper.GetPreviewUrl(Asset.AssetId);
            string relativePreviewUrl  = ResolveUrl(assetPreviewUrl);
            string absolutePreviewUrl  = SiteUtils.GetWebsiteUrl(assetPreviewUrl);
            string playerId            = ClientID + "_Preview";
            string rtmpStreamingServer = ConfigurationManager.AppSettings.GetValue("RTMPStreamingServer");

            // If the streaming server is enabled, then hack the file extension to get the correct markup
            if (fileExtension == "flv" && !StringUtils.IsBlank(rtmpStreamingServer))
            {
                fileExtension += "-streaming";
            }

            //gets the plugin to be tested
            Plugin plugin = ContextInfo.PluginManager.GetAnyPluginById(PluginId);

            if (!plugin.IsNull && plugin.HasPluginFile)
            {
                //ensure asset is of the right file type or force preview set
                if (!plugin.PluginFile.FileExtensions.Contains(fileExtension, StringComparer.OrdinalIgnoreCase) && !plugin.PluginFile.ForcePreviewFormat)
                {
                    writer.Write(string.Format("[Plugin does not support file extension: {0}]", fileExtension));
                    return;
                }
            }
            else
            {
                writer.Write(string.Format("[Invalid plugin: {0}]", plugin.Name));
                return;
            }

            //get the plugins relative URL
            string relativePluginUrl = ResolveUrl(plugin.RelativePath);

            // Get the HTML
            string markup = ContextInfo.PluginManager.GetMarkup(plugin, ContextType);

            // Otherwise, ensure we have markup
            if (string.IsNullOrEmpty(markup))
            {
                writer.Write(string.Format("[Unable to preview asset: {0}]", Asset.AssetId));
                return;
            }

            // Replace params
            markup = markup.Replace("[ASSET-PREVIEW-URL]", assetPreviewUrl);
            markup = markup.Replace("[RELATIVE-PREVIEW-URL]", relativePreviewUrl);
            markup = markup.Replace("[ABSOLUTE-PREVIEW-URL]", absolutePreviewUrl);
            markup = markup.Replace("[FOCUSOPEN-PREVIEW-FILENAME]", Path.GetFileName(info.FilePath));
            markup = markup.Replace("[PLAYER-ID]", playerId);
            markup = markup.Replace("[ASSET-ID]", Asset.AssetId.ToString());
            markup = markup.Replace("[ASSET-REFERENCE]", info.Asset.FileReference);
            markup = markup.Replace("[STREAMING-SERVER-URL]", rtmpStreamingServer);
            markup = markup.Replace("[USER-ID]", SessionInfo.Current.User.UserId.GetValueOrDefault().ToString());
            markup = markup.Replace("[PREVIEW-FILE-EXTENSION]", fileExtension);
            markup = markup.Replace("[ASSET-TYPE-ID]", Asset.AssetTypeId.ToString());
            markup = markup.Replace("[ASSET-TYPE-NAME]", Asset.AssetType.Name);
            markup = markup.Replace("[PREVIEW-AVAILABLE]", (info.PreviewAvailable?"true":"false"));
            markup = markup.Replace("[PLUGIN-URL]", relativePluginUrl);
            markup = markup.Replace("~/", WebUtils.GetApplicationPath());

            // Write the HTML to the page
            writer.Write(markup);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ApproveRadioButton.Attributes.Add("onClick", "checkRadio()");
                RejectRadioButton.Attributes.Add("onClick", "checkRadio()");
                PendingRadioButton.Attributes.Add("onClick", "checkRadio()");
                InviteCommentsRadioButton.Attributes.Add("onClick", "checkRadio()");

                if (AssetWorkflowUser.IsNull)
                {
                    Response.Redirect("~/Admin/Assets/AssetList.aspx");
                }

                if (AssetWorkflow.IsComplete)
                {
                    MessageLabel.SetErrorMessage("Asset workflow is complete and comments have been disabled");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }
                else
                {
                    if (AssetWorkflowUser.AssetWorkflowUserStatus == AssetWorkflowUserStatus.Waiting)
                    {
                        MessageLabel.SetErrorMessage("You do not have permission to action this workflow yet");
                        MessageLabel.Pinned = true;
                        DisableUI();
                    }
                    else if (AssetWorkflowUser.AssetWorkflowUserStatus != AssetWorkflowUserStatus.Pending)
                    {
                        MessageLabel.SetErrorMessage("You have already actioned this workflow");
                        MessageLabel.Pinned = true;
                        DisableUI();
                    }
                }

                AssetWorkflowUserList.Repeater.DataSource = AssetWorkflow.AssetWorkflowUserList;
                AssetWorkflowUserList.Repeater.DataBind();

                Asset asset = AssetWorkflow.Asset;

                AssetReferenceLiteral.Text = asset.AssetId.ToString();
                UploadUserEmailHyperLink.SetNameEmail(asset.UploadedByUser.FullName, asset.UploadedByUser.Email);
                PublicationDateLiteral.Text        = asset.PublishDate.ToString(Global.DateFormat);
                DownloadAssetHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(asset.AssetId);
                AssetThumbnail.Initialise(asset);
                AssetButtons1.Initialise(asset);
                AssetTypeCell.InnerText         = asset.AssetType.Name;
                BrandCell.InnerText             = asset.BrandName;
                ShortDescriptionCell.InnerHtml  = SiteUtils.ConvertTextToHtml(asset.Description);
                UsageRestrictionsCell.InnerText = asset.UsageRestrictions;
                ResponseTextArea.Text           = AssetWorkflowUser.Comments;

                SiteUtils.SetHyperLink("Assets.AssetForm", string.Format("?assetId={0}", asset.AssetId), EditAssetHyperLink);

                switch (AssetWorkflowUser.AssetWorkflowUserStatus)
                {
                case (AssetWorkflowUserStatus.Pending):

                    PendingRadioButton.Checked = true;
                    break;

                case (AssetWorkflowUserStatus.Approved):

                    ApproveRadioButton.Checked = true;
                    break;

                case (AssetWorkflowUserStatus.Rejected):

                    RejectRadioButton.Checked = true;
                    break;
                }

                AssetWorkflowLog.Bind(asset);
            }
        }