Example #1
0
        /// <summary>
        /// Renders appropriate view depending on the <see cref="TemplateName" />
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult" />.
        /// </returns>
        public ActionResult Index()
        {
            var viewModel = this.Model.GetViewModel();

            // Design mode should not show video, unless it's preview mode
            var canDisplayVideo = (!this.IsDesignMode || this.IsPreviewMode) && !this.IsInlineEditingMode;

            if (!canDisplayVideo && viewModel.HasSelectedVideo)
            {
                return(this.Content(Res.Get <VideoResources>().VideoWillNotBeDisplayed));
            }
            else if (this.IsDesignMode && !viewModel.HasSelectedVideo && this.Model.Id != Guid.Empty) // Design mode should display if a video has been removed
            {
                return(this.Content(Res.Get <VideoResources>().VideoNotSelectedOrDeleted));
            }
            else if (viewModel.HasSelectedVideo)
            {
                this.AddCacheDependencies(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(typeof(Video), this.Model.Id));

                this.AddVideoInMediaContext(viewModel);
                return(this.View(VideoController.TemplatePrefix + this.TemplateName, viewModel));
            }
            else
            {
                return(new EmptyResult());
            }
        }
Example #2
0
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <param name="viewModel">View model that will be used for displaying the data.</param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public override IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentListViewModel viewModel)
        {
            var result = new List <CacheDependencyKey>();

            viewModel.Items.ForEach(p => result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(this.ContentType, p.DataItem.Id)));

            return(result);
        }
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public virtual IList <CacheDependencyKey> GetKeysOfDependentObjects()
        {
            var result = new List <CacheDependencyKey>(1);

            if (this.IsShared())
            {
                result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(typeof(ContentItem), this.SharedContentID));
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <param name="viewModel">View model that will be used for displaying the data.</param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public override IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentListViewModel viewModel)
        {
            var    result          = base.GetKeysOfDependentObjects(viewModel);
            var    manager         = this.GetManager();
            string applicationName = manager != null && manager.Provider != null ? manager.Provider.ApplicationName : string.Empty;

            foreach (var key in OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(typeof(ListItem), applicationName))
            {
                result.Add(key);
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <param name="viewModel">View model that will be used for displaying the data.</param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public virtual IList <CacheDependencyKey> GetKeysOfDependentObjects(FormViewModel viewModel)
        {
            if (this.ContentType != null)
            {
                var contentResolvedType = this.ContentType;
                var result = new List <CacheDependencyKey>(1);
                if (viewModel != null && !string.IsNullOrWhiteSpace(viewModel.FormId))
                {
                    result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(contentResolvedType, viewModel.FormId));
                }

                return(result);
            }
            else
            {
                return(new List <CacheDependencyKey>(0));
            }
        }
Example #6
0
        /// <summary>
        /// Renders appropriate list view depending on the <see cref="TemplateName" />
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult" />.
        /// </returns>
        public ActionResult Index()
        {
            var viewModel = this.Model.GetViewModel();

            if (viewModel.Item.DataItem != null && viewModel.Item.DataItem.Id != Guid.Empty)
            {
                this.AddCacheDependencies(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(typeof(Image), this.Model.Id));

                return(this.View(this.TemplateName, viewModel));
            }
            else if (!this.IsEmpty && this.IsDesignMode && !SystemManager.IsInlineEditingMode)
            {
                return(this.Content(this.ImageWasNotSelectedOrHasBeenDeletedMessage));
            }
            else
            {
                return(new EmptyResult());
            }
        }
Example #7
0
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <param name="viewModel">View model that will be used for displaying the data.</param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public virtual IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentDetailsViewModel viewModel)
        {
            if (this.ContentType != null)
            {
                var contentResolvedType = this.ContentType;
                var result = new List <CacheDependencyKey>(1);
                if (viewModel.Item != null && viewModel.Item.Fields.Id != Guid.Empty)
                {
                    result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(contentResolvedType, viewModel.Item.Fields.Id));
                }

                this.AddCommonDependencies(result, this.ContentType, viewModel.Item);

                return(result);
            }
            else
            {
                return(new List <CacheDependencyKey>(0));
            }
        }
Example #8
0
        /// <summary>
        /// Gets a collection of <see cref="CacheDependencyNotifiedObject"/>.
        ///     The <see cref="CacheDependencyNotifiedObject"/> represents a key for which cached items could be subscribed for
        ///     notification.
        ///     When notified, all cached objects with dependency on the provided keys will expire.
        /// </summary>
        /// <param name="viewModel">View model that will be used for displaying the data.</param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public virtual IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentListViewModel viewModel)
        {
            if (this.ContentType != null)
            {
                var    contentResolvedType = this.ContentType;
                var    result          = new List <CacheDependencyKey>(1);
                var    manager         = this.GetManager();
                var    provider        = manager != null ? manager.Provider : null;
                string applicationName = provider != null ? provider.ApplicationName : string.Empty;

                result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(contentResolvedType, applicationName));

                this.AddCommonDependencies(result, this.ContentType);

                return(result);
            }
            else
            {
                return(new List <CacheDependencyKey>(0));
            }
        }
Example #9
0
        /// <inheritdoc />
        public override IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentListViewModel viewModel)
        {
            if (this.ContentType != null)
            {
                var    result          = new List <CacheDependencyKey>(2);
                var    manager         = this.GetManager();
                string applicationName = manager != null && manager.Provider != null ? manager.Provider.ApplicationName : string.Empty;

                result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(this.ContentType, applicationName));
                result.Add(new CacheDependencyKey()
                {
                    Key = this.ContentType.FullName, Type = typeof(DynamicModule)
                });

                this.AddCommonDependencies(result, this.ContentType);
                return(result);
            }
            else
            {
                return(new List <CacheDependencyKey>(0));
            }
        }
Example #10
0
        /// <inheritdoc />
        public override IList <CacheDependencyKey> GetKeysOfDependentObjects(ContentDetailsViewModel viewModel)
        {
            if (this.ContentType != null)
            {
                var result = new List <CacheDependencyKey>(2);
                if (viewModel.Item != null && viewModel.Item.Fields.Id != Guid.Empty)
                {
                    result.AddRange(OutputCacheDependencyHelper.GetPublishedContentCacheDependencyKeys(this.ContentType, viewModel.Item.Fields.Id));
                    result.Add(new CacheDependencyKey()
                    {
                        Key = this.ContentType.FullName, Type = typeof(DynamicModule)
                    });
                }

                this.AddCommonDependencies(result, this.ContentType, viewModel.Item);

                return(result);
            }
            else
            {
                return(new List <CacheDependencyKey>(0));
            }
        }