Ejemplo n.º 1
0
        public PartialViewResult Internal(Widget widget)
        {
            _widgetUIService.SetAppDataToken(RouteData, widget);

            return PartialView(!string.IsNullOrWhiteSpace(widget.CustomLayout)
                ? widget.CustomLayout
                : widget.WidgetType,
                _widgetUIService.GetModel(widget));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Widget widget,
            string returnUrl = null)
        {
            _widgetService.SaveWidget(widget);

            return string.IsNullOrWhiteSpace(returnUrl)
                ? widget.Webpage != null
                    ? RedirectToAction("Edit", "Webpage", new {id = widget.Webpage.Id})
                    : (ActionResult) RedirectToAction("Edit", "LayoutArea", new {id = widget.LayoutArea.Id})
                : Redirect(returnUrl);
        }
Ejemplo n.º 3
0
        public ViewResultBase Edit_Get(Widget widget, string returnUrl = null)
        {
            widget.SetViewData(ViewData);

            if (!string.IsNullOrEmpty(returnUrl))
                ViewData["return-url"] = Referrer;
            else
                ViewData["return-url"] = returnUrl;

            return View(widget);
        }
Ejemplo n.º 4
0
 private GetWidgetModelBase GetRetriever(Widget widget)
 {
     using (MiniProfiler.Current.Step("Get Retriever"))
     {
         if (widget == null) return DefaultGetWidgetModel.Instance;
         GetWidgetModelBase retriever = null;
         string typeName = widget.GetType().FullName;
         if (WidgetModelRetrievers.ContainsKey(typeName))
         {
             retriever = _kernel.Get(WidgetModelRetrievers[typeName]) as GetWidgetModelBase;
         }
         return retriever ?? DefaultGetWidgetModel.Instance;
     }
 }
Ejemplo n.º 5
0
 private static string GetCacheKey(Widget widget, OutputCacheableAttribute attribute)
 {
     var cacheKey = "Widget." + widget.Id;
     if (attribute.PerPage)
     {
         var page = CurrentRequestData.CurrentPage;
         if (page != null)
         {
             cacheKey += ".Page:" + page.Id;
         }
     }
     if (attribute.PerUser)
     {
         cacheKey += ".User:" + CurrentRequestData.UserGuid;
     }
     return cacheKey;
 }
Ejemplo n.º 6
0
 public CachingInfo Get(Widget widget)
 {
     using (MiniProfiler.Current.Step("Get caching info"))
     {
         if (widget == null)
         {
             return CachingInfo.DoNotCache;
         }
         var attribute = widget.GetType().GetCustomAttribute<OutputCacheableAttribute>();
         if (attribute == null)
         {
             return CachingInfo.DoNotCache;
         }
         var shouldCache = widget.Cache && widget.CacheLength > 0;
         return new CachingInfo(shouldCache, GetCacheKey(widget, attribute),
             TimeSpan.FromSeconds(widget.CacheLength),
             widget.CacheExpiryType);
     }
 }
Ejemplo n.º 7
0
 public ActionResult Show(Widget widget)
 {
     return _widgetUIService.GetContent(this, widget, helper => helper.Action("Internal", "Widget", new {widget}));
 }
Ejemplo n.º 8
0
 public void SetAppDataToken(RouteData routeData, Widget widget)
 {
     if (MrCMSApp.AppWidgets.ContainsKey(widget.Unproxy().GetType()))
         routeData.DataTokens["app"] = MrCMSApp.AppWidgets[widget.Unproxy().GetType()];
 }
Ejemplo n.º 9
0
 public object GetModel(Widget widget)
 {
     return _widgetModelService.GetModel(widget);
 }
Ejemplo n.º 10
0
 public ActionResult GetContent(Controller controller, Widget widget, Func<HtmlHelper, MvcHtmlString> func)
 {
     return _htmlCacheService.GetContent(controller, _getWidgetCachingInfo.Get(widget), func);
 }
Ejemplo n.º 11
0
 public override object GetModel(Widget widget)
 {
     return widget;
 }
Ejemplo n.º 12
0
 public object GetModel(Widget widget)
 {
     GetWidgetModelBase retriever = GetRetriever(widget);
     return retriever.GetModel(widget);
 }
Ejemplo n.º 13
0
 public abstract void AssignViewDataBase(Widget widget, ViewDataDictionary viewData);
Ejemplo n.º 14
0
 public abstract object GetModel(Widget widget);
Ejemplo n.º 15
0
        public ActionResult Delete(Widget widget, string returnUrl)
        {
            int webpageId = 0;
            int layoutAreaId = 0;
            if (widget.Webpage != null)
                webpageId = widget.Webpage.Id;
            if (widget.LayoutArea != null)
                layoutAreaId = widget.LayoutArea.Id;
            _widgetService.DeleteWidget(widget);

            return !string.IsNullOrWhiteSpace(returnUrl) &&
                   !returnUrl.Contains("widget/edit/", StringComparison.OrdinalIgnoreCase)
                ? (ActionResult) Redirect(returnUrl)
                : webpageId > 0
                    ? RedirectToAction("Edit", "Webpage", new {id = webpageId, layoutAreaId})
                    : RedirectToAction("Edit", "LayoutArea", new {id = layoutAreaId});
        }
Ejemplo n.º 16
0
 public ActionResult Delete_Get(Widget widget)
 {
     return PartialView(widget);
 }