Exemple #1
0
        /// <summary>
        /// Initialize Rendering
        /// </summary>
        /// <param name="rendering">Rendering to intialize
        /// </param>
        public override void Initialize(Rendering rendering)
        {
            base.Initialize(rendering);
            NameValueCollection parameters = null;

            if (!string.IsNullOrEmpty(rendering["Parameters"]))
            {
                parameters = WebUtil.ParseUrlParameters(rendering["Parameters"]);
            }

            if (parameters == null || parameters.Count <= 0)
            {
                return;
            }

            TitleColor    = parameters["TitleColor"];
            TitleFontSize = parameters["TitleFontSize"];
            Background    = parameters["Background"];
            DivHeight     = parameters["CompHeight"];
            ImageHeight   = !string.IsNullOrEmpty(parameters["ImageHeight"]) ? parameters["ImageHeight"] : "auto";
            CssClass      = MainUtil.GetBool(parameters["Image Left"], false) ? string.Empty : "image-right";

            if (!string.IsNullOrEmpty(parameters["ImageWidth"]))
            {
                ImageWidth = parameters["ImageWidth"];
            }
            else
            {
                ImageHeight = "auto";
            }
        }
        /// <summary>
        /// The parse node.
        /// </summary>
        /// <param name="attributes">
        /// The attributes.
        /// </param>
        private void ParseNode(SafeDictionary <string, string> attributes)
        {
            Assert.ArgumentNotNull(attributes, "attributes");
            string str = Extract(attributes, new[] { "outputMethod" });

            this.xhtml             = (str == "xhtml") || (Settings.Rendering.ImagesAsXhtml && (str != "html"));
            this.src               = Extract(attributes, new[] { "src" }) ?? this.src;
            this.border            = Extract(attributes, new[] { "border" }) ?? this.border;
            this.altText           = Extract(attributes, new[] { "alt", "AltText" }) ?? this.altText;
            this.hSpace            = Extract(attributes, new[] { "hspace" }) ?? this.hSpace;
            this.vSpace            = Extract(attributes, new[] { "vspace" }) ?? this.vSpace;
            this.CssClass          = Extract(attributes, new[] { "class" }) ?? this.CssClass;
            this.width             = Extract(attributes, new[] { "width", "w" }) ?? this.width;
            this.height            = Extract(attributes, new[] { "height", "h" }) ?? this.height;
            this.scale             = Extract(attributes, new[] { "scale", "sc" }) ?? this.scale;
            this.maxWidth          = Extract(attributes, new[] { "maxWidth", "mw" }) ?? this.maxWidth;
            this.maxHeight         = Extract(attributes, new[] { "maxHeight", "mh" }) ?? this.maxHeight;
            this.database          = Extract(attributes, new[] { "database", "db" }) ?? this.database;
            this.language          = Extract(attributes, new[] { "language", "la" }) ?? this.language;
            this.version           = Extract(attributes, new[] { "version", "vs" }) ?? this.version;
            this.bgcolor           = Extract(attributes, new[] { "backgroundColor", "bc" }) ?? this.bgcolor;
            this.allowstretch      = MainUtil.GetBool(Extract(attributes, new[] { "allowStretch", "as", "autoscale" }), true);
            this.disablemediacache = MainUtil.GetBool(Extract(attributes, new[] { "disableMediaCache" }), false);
            this.thumbnail         = MainUtil.GetBool(Extract(attributes, new[] { "thumbnail", "thn" }), true);

            if (string.IsNullOrEmpty(this.border) && !this.xhtml)
            {
                this.border = "0";
            }
        }
Exemple #3
0
        protected virtual void ParseNode(SafeDictionary <string> attributes)
        {
            Assert.ArgumentNotNull(attributes, "attributes");
            var str = Extract(attributes, "outputMethod");

            xhtml     = str == "xhtml" || Settings.Rendering.ImagesAsXhtml && str != "html";
            source    = Extract(attributes, "src");
            alt       = Extract(attributes, "alt");
            border    = Extract(attributes, "border");
            hspace    = Extract(attributes, "hspace");
            vspace    = Extract(attributes, "vspace");
            className = Extract(attributes, "class");
            if (string.IsNullOrEmpty(border) && !xhtml)
            {
                border = "0";
            }
            allowStretch      = MainUtil.GetBool(Extract(attributes, ref asSet, "allowStretch", "as"), false);
            ignoreAspectRatio = MainUtil.GetBool(Extract(attributes, "ignoreAspectRatio", "iar"), false);
            width             = MainUtil.GetInt(Extract(attributes, ref widthSet, "width", "w"), 0);
            height            = MainUtil.GetInt(Extract(attributes, ref heightSet, "height", "h"), 0);
            scale             = MainUtil.GetFloat(Extract(attributes, ref scaleSet, "scale", "sc"), 0.0f);
            maxWidth          = MainUtil.GetInt(Extract(attributes, ref maxWidthSet, "maxWidth", "mw"), 0);
            maxHeight         = MainUtil.GetInt(Extract(attributes, ref maxHeightSet, "maxHeight", "mh"), 0);
            thumbnail         = MainUtil.GetBool(Extract(attributes, ref thumbnailSet, "thumbnail", "thn"), false);
            backgroundColor   = Extract(attributes, "backgroundColor", "bc") ?? string.Empty;
            database          = Extract(attributes, "database", "db");
            language          = Extract(attributes, "language", "la");
            version           = Extract(attributes, "version", "vs");
            disableMediaCache = MainUtil.GetBool(Extract(attributes, ref disableMediaCacheSet, "disableMediaCache"), false);
        }
Exemple #4
0
        protected override void OnLoad(EventArgs e)
        {
            string queryString = Attributes["sc_parameters"];

            if (!string.IsNullOrEmpty(queryString))
            {
                NameValueCollection param = WebUtil.ParseUrlParameters(queryString);

                if (!string.IsNullOrEmpty(param["Web"]))
                {
                    this.Web = param["Web"];
                }

                if (string.IsNullOrEmpty(this.Web))
                {
                    this.Web = SharepointUtils.CurrentWebPath;
                }

                if (!string.IsNullOrEmpty(param["Server"]))
                {
                    this.Server = param["Server"];
                }

                if (string.IsNullOrEmpty(this.ListName))
                {
                    this.ListName = param["List"];
                }

                this.ShowIfEmpty = MainUtil.GetBool(param["ShowIfEmpty"], false);
            }

            this.context = SpContextProviderBase.Instance.CreateUIContext(this.Server, this.Web);
        }
Exemple #5
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Log.Debug("Processing file upload to CDN", this);
            var sw = new Stopwatch();

            sw.Start();

            foreach (Item file in args.UploadedItems.Where(file => file.Paths.IsMediaItem))
            {
                /* NOTE: We don't deal with versioned files, should prepend file.Language and file.Version... */

                // delete if previously uploaded
                if (MainUtil.GetBool(file[FieldNameConstants.MediaItem.UploadedToCloud], false))
                {
                    cloudStorage.Delete(file);
                }

                // upload to CDN
                string filename = cloudStorage.Put(file);

                // delete the existing file from disk
                FileUtil.Delete(StringUtil.EnsurePrefix('/', file[FieldNameConstants.MediaItem.FilePath]));

                // update the item file location to CDN
                using (new EditContext(file, SecurityCheck.Disable))
                {
                    file[FieldNameConstants.MediaItem.FilePath]        = filename;
                    file[FieldNameConstants.MediaItem.UploadedToCloud] = "1";
                }
            }

            sw.Stop();
            Log.Debug("File Upload process to CDN complete: " + sw.Elapsed, this);
        }
Exemple #6
0
        /// <summary>
        /// Is this media item publicly accessible by the anonymous user?
        /// </summary>
        /// <param name="media"></param>
        /// <returns></returns>
        public virtual bool IsMediaPubliclyAccessible(MediaItem media)
        {
            string cacheKey = media.ID.ToString() + "_public";
            string cached   = _cache.GetUrl(cacheKey);
            bool   output   = true;

            // cached result
            if (!string.IsNullOrEmpty(cached))
            {
                output = MainUtil.GetBool(cached, true);
            }
            else
            {
                //replaced obsolete method for getting the domain
                Domain domain = Sitecore.Context.Domain ?? DomainManager.GetDomain("extranet");
                var    anon   = domain.GetAnonymousUser();
                if (anon != null)
                {
                    output = media.InnerItem.Security.CanRead(anon);
                }

                _cache.SetUrl(cacheKey, output.ToString());
            }
            return(output);
        }
        /// <summary>
        /// Initialize the LinkProvider
        /// </summary>
        /// <param name="name"></param>
        /// <param name="config"></param>
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            // Load forceFriendlyUrl attribute value
            this.ForceFriendlyUrl = MainUtil.GetBool(config["forceFriendlyUrl"], false);

            // Load trailingSlash attribute value
            this.TrailingSlash = MainUtil.GetBool(config["trailingSlash"], false);

            // Load onlyApplyForSiteContent attribute value.
            this.OnlyApplyForSiteContent = MainUtil.GetBool(config["onlyApplyForSiteContent"], false);

            // Load applyForSites attribute value
            string attr = StringUtil.GetString((object)config["applyForSites"], string.Empty);

            if (!string.IsNullOrEmpty(attr))
            {
                this.ApplyForSites = StringUtil.GetString((object)config["applyForSites"], string.Empty)
                                     .Replace(" ", string.Empty)
                                     .ToLower()
                                     .Split(',');
            }

            // Load ignoreForSites attribute value
            attr = StringUtil.GetString((object)config["ignoreForSites"], string.Empty);

            if (!string.IsNullOrEmpty(attr))
            {
                this.IgnoreForSites = StringUtil.GetString((object)config["ignoreForSites"], string.Empty)
                                      .Replace(" ", string.Empty)
                                      .ToLower()
                                      .Split(',');
            }
        }
Exemple #8
0
        /// <summary>
        /// Parse the component parameters to get the correct display for the component
        /// </summary>
        /// <param name="rendering">The rendering to initialize</param>
        public override void Initialize(Rendering rendering)
        {
            base.Initialize(rendering);

            Testimonials = new List <Item>();

            if (!string.IsNullOrEmpty(rendering["Parameters"]))
            {
                NameValueCollection parameters = WebUtil.ParseUrlParameters(rendering["Parameters"]);

                if (parameters == null || parameters.Count <= 0)
                {
                    return;
                }

                DisplayStars       = MainUtil.GetBool(parameters["Show Star Rating"], false);
                TextBalloonVariant = MainUtil.GetBool(parameters["TitleFontSize"], false);
            }

            if (Item != null)
            {
                MultilistField field = Item.Fields[FieldConstants.TeaserGroup.Source];
                if (field != null)
                {
                    Testimonials = field.GetItems();
                }
            }
        }
        private void ParseParameters(string source)
        {
            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters[FROM_FIELD_NAME]))
            {
                From = MainUtil.GetInt(parameters.Parameters[FROM_FIELD_NAME], 0);
            }
            else
            {
                From = 1;
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[TO_FIELD_NAME]))
            {
                To = MainUtil.GetInt(parameters.Parameters[TO_FIELD_NAME], 100);
            }
            else
            {
                To = 100;
            }
            // TO SHOW RAW VALUES
            if (!string.IsNullOrEmpty(parameters.Parameters[IS_DEBUG_FIELD_NAME]))
            {
                IsDebug = MainUtil.GetBool(parameters.Parameters[IS_DEBUG_FIELD_NAME], false);
            }
        }
Exemple #10
0
        public virtual System.Web.UI.Control GetMenuButtons(Item fieldTypeItem, string editorId)
        {
            Item menu = fieldTypeItem.Children["Menu"];

            if (menu != null && menu.HasChildren)
            {
                using (HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()))
                {
                    writer.Write("<div class=\"scContentButtons\">");
                    foreach (Item item in menu.Children)
                    {
                        if (MainUtil.GetBool(item["Show In Field Editor"], false))
                        {
                            writer.Write(string.Format("<a href=\"#\" class=\"scContentButton\" onclick=\"{0}\">",
                                                       Sitecore.Context.ClientPage.GetClientEvent(item["Message"]).Replace("$Target", editorId)));
                            writer.Write(item["Display Name"]);
                            writer.Write("</a>");
                        }
                    }
                    writer.Write("</div>");
                    return(new LiteralWithViewState(writer.InnerWriter.ToString()));
                }
            }
            return(new LiteralWithViewState());
        }
Exemple #11
0
        IEnumerable <RedirectMapping> BuildMap()
        {
            var siteRoot = Context.Site.GetRootItem();

            if (siteRoot != null)
            {
                var item = siteRoot.Children.FirstOrDefault(ent => ent.IsDerived(Templates.RedirectMapGrouping.ID));
                if (item != null)
                {
                    return(item.Axes.GetDescendants()
                           .Where(i => i.IsDerived(Templates.RedirectMap.ID))
                           .SelectMany(ent =>
                    {
                        if (!Enum.TryParse <RedirectType>(ent[Templates.RedirectMap.Fields.RedirectType], out var redirectType))
                        {
                            Log.Info(string.Format("Redirect map '{0}' does not specify redirect type.", ent.Paths.FullPath), this);

                            return null;
                        }

                        var urlString = new UrlString
                        {
                            Query = ent[Templates.RedirectMap.Fields.UrlMapping]
                        };

                        return urlString.Parameters.Keys
                        .Cast <string>()
                        .Where(k => !string.IsNullOrEmpty(k) && !string.IsNullOrEmpty(urlString.Parameters[k]))
                        .ToDictionary(k => k, k => urlString.Parameters[k])
                        .Select(kvp =>
                        {
                            var pattern = kvp.Key.ToLower();

                            var isRegex = pattern.StartsWith("^", StringComparison.Ordinal) && pattern.EndsWith("$", StringComparison.Ordinal);
                            if (!isRegex)
                            {
                                pattern = EnsureSlashes(pattern);
                            }

                            var target = (HttpUtility.UrlDecode(kvp.Value.ToLower()) ?? string.Empty)
                                         .TrimStart(new char[] { '^' })
                                         .TrimEnd(new char[] { '$' });

                            return new RedirectMapping
                            {
                                RedirectType = redirectType,
                                PreserveQueryString = MainUtil.GetBool(ent[Templates.RedirectMap.Fields.PreserveQueryString], false),
                                Pattern = pattern,
                                Target = target,
                                IsRegex = isRegex
                            };
                        });
                    })
                           .Where(ent => ent != null)
                           .ToList());
                }
            }

            return(Enumerable.Empty <RedirectMapping>());
        }
        private void ParseParameters(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                return;
            }

            LatitiudeFieldName = "Latitude";
            LongitudeFieldName = "Longitude";

            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters[OVERRIDEZOOM]))
            {
                int zoomValue;
                int.TryParse(parameters.Parameters[OVERRIDEZOOM], out zoomValue);

                if (zoomValue < 0 || zoomValue > 20)
                {
                    zoomValue = DEFAULT_ZOOM;
                }

                OverrideZoom = zoomValue;
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[ADDRESSFIELDNAME]))
            {
                AddressFieldName = parameters.Parameters[ADDRESSFIELDNAME];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[LONGITUDE_FIELD_NAME]))
            {
                LongitudeFieldName = parameters.Parameters[LONGITUDE_FIELD_NAME];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[LATITIUDE_FIELD_NAME]))
            {
                LatitiudeFieldName = parameters.Parameters[LATITIUDE_FIELD_NAME];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[APIKEY]))
            {
                APIKey = parameters.Parameters[APIKEY];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[LABELFIELDNAME]))
            {
                LabelFieldName = parameters.Parameters[LABELFIELDNAME];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[COLOR]))
            {
                _mapLabelColor = parameters.Parameters[COLOR];
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[ISDEBUG]))
            {
                Debug = MainUtil.GetBool(parameters.Parameters[ISDEBUG], false);
            }
        }
        public override void Process(HttpRequestArgs args)
        {
            var enableHandleCustomErrors = MainUtil.GetBool(Context.Site.Properties[Constants.SiteInfo.Properties.EnableHandleCustomErrors], false);

            if (!enableHandleCustomErrors)
            {
                return;
            }
            if (IsValidContextItemResolved() || StartsWithPrefixToIgnore(args.LocalPath))
            {
                return;
            }
            var notFoundContent = GetNotFoundPageContent(args);

            if (!string.IsNullOrWhiteSpace(notFoundContent))
            {
                args.Context.Response.TrySkipIisCustomErrors = true;
                args.Context.Response.StatusCode             = 404;
                args.Context.Response.StatusDescription      = "Page Not Found";
                args.Context.Response.Write(notFoundContent);
                args.Context.Response.End();
            }

            Log.Warn($"The not found page: {args.Url} shows no content when rendered!", args.Url);
        }
Exemple #14
0
        /// <summary>
        /// Parses the parameters supplied as field source.
        /// </summary>
        /// <remarks>
        /// Both "40" and "Limit=40" are supported for specifing maximum number of characters the field should accept
        /// </remarks>
        /// <param name="source">The source.</param>
        void ParseParameters(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                return;
            }

            if (!source.Contains("="))
            {
                CharacterLimit = int.Parse(source);
                return;
            }

            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters["Limit"]))
            {
                CharacterLimit = int.Parse(parameters.Parameters["Limit"]);
            }

            if (!string.IsNullOrEmpty(parameters.Parameters["PreventTyping"]))
            {
                PreventTyping = MainUtil.GetBool(parameters.Parameters["PreventTyping"], false);
            }
        }
        private bool IncludeInNavigation(Item item, bool forceShowInMenu = false)
        {
            var result = item.HasContextLanguage() &&
                         (item.IsDerived(Templates.Navigable.ID) || item.IsDerived(Templates.NavigationRoot.ID)) &&
                         (forceShowInMenu || MainUtil.GetBool(item[Templates.Navigable.Fields.ShowInNavigation], false));

            return(result);
        }
        protected override void InitItemProperties(Item item)
        {
            Assert.ArgumentNotNull(item, nameof(item));
            base.InitItemProperties(item);

            ShowEmptyItem = MainUtil.GetBool(item.Fields["Show Empty Item"]?.Value, defaultValue: false);
            ShowValues    = MainUtil.GetBool(item.Fields["Show Values"]?.Value, defaultValue: false);
        }
 public static bool IsChecked(this Field checkboxField)
 {
     if (checkboxField == null)
     {
         throw new ArgumentNullException(nameof(checkboxField));
     }
     return(MainUtil.GetBool(checkboxField.Value, false));
 }
Exemple #18
0
 public static bool GetBool(this Item item, string fieldID)
 {
     if (string.IsNullOrEmpty(item.GetString(fieldID)))
     {
         return(false);
     }
     return(MainUtil.GetBool(item[new ID(fieldID)], false));
 }
 protected override void InitItemProperties(Item item)
 {
     base.InitItemProperties(item);
     IsTrackingEnabled = MainUtil.GetBool(item.Fields["Is Tracking Enabled"]?.Value, false);
     Required          = MainUtil.GetBool(item.Fields["Required"]?.Value, false);
     AllowSave         = MainUtil.GetBool(item.Fields["Allow Save"]?.Value, false);
     InitializeValidations(item);
 }
        /// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            base.Initialize(name, config);

            this.IncludeCatalog      = MainUtil.GetBool(config[IncludeCatalogsAttribute], IncludeCatalogsDefault);
            this.UseShopLinks        = MainUtil.GetBool(config[UseShopLinksAttribute], UseShopLinksDefault);
            this.IncludeFriendlyName = MainUtil.GetBool(config[IncludeFriendlyNameAttribute], IncludeFriendlyNameDefault);
        }
Exemple #21
0
        public override void Process(GetPageItemArgs args)
        {
            var resolved = Context.Items[Sitecore.Demo.Foundation.SitecoreExtensions.Constants.WildCardItemResolvedKey];

            if (MainUtil.GetBool(resolved, false))
            {
                args.Result = Context.Item;
            }
        }
        public static bool IsChecked(this Field checkboxField)
        {
            if (checkboxField == null)
            {
                return(false);
            }

            return(MainUtil.GetBool(checkboxField.Value, false));
        }
Exemple #23
0
        public void Configure(IServiceCollection serviceCollection)
        {
            if (!MainUtil.GetBool(System.Configuration.ConfigurationManager.AppSettings.Get("AppInsights:enabled"), true))
            {
                TelemetryConfiguration.Active.DisableTelemetry = true;
            }

            //makes it persist instant
            TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = IsDebug;
        }
        /// <summary>
        /// Initialize the rendering
        /// </summary>
        /// <param name="rendering">The rendering to initialize</param>
        public override void Initialize(Rendering rendering)
        {
            base.Initialize(rendering);

            if (!string.IsNullOrEmpty(rendering["Parameters"]))
            {
                NameValueCollection parameters = WebUtil.ParseUrlParameters(rendering["Parameters"]);
                ShowButton = MainUtil.GetBool(parameters["Show Button"], false);
            }
        }
        protected virtual bool IncludeInNavigation(Item item, bool forceShowInMenu = false)
        {
            if (item.InheritsFrom(Templates.MenuLink.TemplateId) || item.InheritsFrom(Templates.MenuFolder.TemplateId))
            {
                return(true);
            }

            return(item.InheritsFrom(Templates._Navigable.TemplateId) &&
                   (forceShowInMenu || MainUtil.GetBool(item[Templates._Navigable.FieldNames.ShowInNavigation], false)));
        }
 /// <summary>
 /// Returns the boolean value associated with the current request for the
 /// property provided.
 /// </summary>
 /// <remarks>
 /// Method assumes that if device detection is enabled the capabilities
 /// provider being used for requests is configured to provider results for
 /// the property name.
 /// </remarks>
 /// <param name="propertyName">Name of the property required</param>
 /// <returns>
 /// The boolean value of the property, or false if property not available
 /// or invalid boolean type
 /// </returns>
 internal static bool GetBoolProperty(string propertyName)
 {
     try
     {
         return(MainUtil.GetBool(HttpContext.Current.Request.Browser[propertyName], false));
     }
     catch (Exception)
     {
         return(false);
     }
 }
        protected override void OnInit(EventArgs e)
        {
            PopupPage popupPage = this.Page as PopupPage;

            if (popupPage != null && !string.IsNullOrEmpty(popupPage.Parameters["FrameSrc"]))
            {
                this.Src = popupPage.Parameters["FrameSrc"];
                this.preventPeUnloadMessage = MainUtil.GetBool(popupPage.Parameters["PreventPeUnloadMessage"], false);
            }
            base.OnInit(e);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ItemID        = WebUtil.GetQueryString("id");
            RawSource     = WebUtil.GetQueryString("s");
            FieldID.Value = WebUtil.GetQueryString("fid");
            Disabled      = MainUtil.GetBool(WebUtil.GetQueryString("d"), false);

            RenderCarousel();
        }
            void checkBox_DataBinding(object sender, EventArgs e)
            {
                var     target    = (Literal)sender;
                Control container = target.NamingContainer;
                var     dataItem  = DataBinder.GetDataItem(container) as BaseItem;

                if (dataItem != null)
                {
                    bool fieldValue = MainUtil.GetBool(dataItem[this.FieldName], false);
                    target.Text = fieldValue ? Translate.Text(UIMessages.Yes) : string.Empty;
                }
            }
Exemple #30
0
        /// <summary>
        /// Is this media item Tracked by DMS?
        /// </summary>
        /// <param name="media"></param>
        /// <returns></returns>
        public virtual bool IsMediaAnalyticsTracked(MediaItem media)
        {
            try
            {
                //Replaced old way to know if analytics is enabled
                string analyticsSetting = "Xdb.Enabled";
                if (!Settings.GetBoolSetting(analyticsSetting, true))
                {
                    return(false);
                }

                string cacheKey = media.ID.ToString() + "_tracked";
                string cached   = _cache.GetUrl(cacheKey);
                bool   output   = false;

                // cached result
                if (!string.IsNullOrEmpty(cached))
                {
                    output = MainUtil.GetBool(cached, true);
                }
                else
                {
                    string aData = media.InnerItem["__Tracking"];

                    if (string.IsNullOrEmpty(aData))
                    {
                        output = false;
                    }
                    else
                    {
                        XElement el     = XElement.Parse(aData);
                        var      ignore = el.Attribute("ignore");

                        if (ignore != null && ignore.Value == "1")
                        {
                            output = false;
                        }
                        else
                        {
                            // if the tracking element has any events, campaigns or profiles.
                            output = el.Elements("event").Any() || el.Elements("campaign").Any() || el.Elements("profile").Any();
                        }
                    }
                    _cache.SetUrl(cacheKey, output.ToString());
                }
                return(output);
            }
            catch (Exception ex)
            {
                Log.Error("IsMediaAnalyticsTracked", ex, this);
                return(false);
            }
        }