Пример #1
0
 protected string GetBodyClass()
 {
     if (CurrentItem != null)
     {
         string className = CurrentItem.GetContentType().Name;
         return(className.Substring(0, 1).ToLower() + className.Substring(1));
     }
     return(null);
 }
Пример #2
0
 protected void AddEditable()
 {
     editable = GetEditable(CurrentItem.GetContentType());
     editor   = editable.AddTo(this);
     if (!Page.IsPostBack)
     {
         editable.UpdateEditor(CurrentItem, editor);
     }
 }
        //// Actions ////

        /// <summary>By default the templates index method renders a view located in ~/Views/SharedPages/{ContentType}.aspx or partial view located in ¨~/Views/SharedPages/{ContentType}.ascx.</summary>
        /// <returns></returns>
        public override ActionResult Index()
        {
            var templateName = CurrentItem is ModelBase
                               ? (CurrentItem as ModelBase).ViewTemplate
                               : CurrentItem.GetContentType().Name;

            return(CurrentItem.IsPage
                ? View(string.Format("PageTemplates/{0}", templateName), CurrentItem)
                : PartialView(string.Format("PartTemplates/{0}", templateName), CurrentItem));
        }
Пример #4
0
        //// Actions ////

        /// <summary>By default the templates index method renders a view located in ~/Views/SharedPages/{ContentType}.aspx or partial view located in ¨~/Views/SharedPages/{ContentType}.ascx.</summary>
        /// <returns></returns>
        public override System.Web.Mvc.ActionResult Index()
        {
            if (CurrentItem.IsPage)
            {
                return(View(string.Format("PageTemplates/{0}", CurrentItem.GetContentType().Name), CurrentItem));
            }
            else
            {
                return(PartialView(string.Format("PartTemplates/{0}", CurrentItem.GetContentType().Name), CurrentItem));
            }
        }
Пример #5
0
        private void RenderDisplayable(TextWriter writer)
        {
            var displayable = DefinitionMap.Instance.GetOrCreateDefinition(CurrentItem).Displayables.FirstOrDefault(d => d.Name == propertyName);

            if (displayable == null)
            {
                if (isOptional || swallowExceptions)
                {
                    return;
                }

                throw new N2Exception("No attribute implementing IDisplayable found on the property '{0}' of the item #{1} of type {2}", propertyName, CurrentItem.ID, CurrentItem.GetContentType());
            }

            if (Wrapper != null)
            {
                writer.Write(Wrapper.ToString(TagRenderMode.StartTag));
            }

            var ctx = new RenderingContext
            {
                Content      = CurrentItem,
                Displayable  = displayable,
                Html         = Html,
                PropertyName = propertyName,
                IsEditable   = isEditable && ControlPanelExtensions.GetControlPanelState(Html) == ControlPanelState.DragDrop
            };

            Html.ResolveService <DisplayableRendererSelector>()
            .Render(ctx, writer);

            if (Wrapper != null)
            {
                writer.Write(Wrapper.ToString(TagRenderMode.EndTag));
            }
        }
Пример #6
0
        private void RenderDisplayable()
        {
            var displayable = DefinitionMap.Instance.GetOrCreateDefinition(CurrentItem).Displayables.FirstOrDefault(d => d.Name == propertyName);

            if (displayable == null)
            {
                if (!swallowExceptions)
                {
                    throw new N2Exception("No attribute implementing IDisplayable found on the property '{0}' of the item #{1} of type {2}", propertyName, CurrentItem.ID, CurrentItem.GetContentType());
                }
                return;
            }

            var writer = Html.ViewContext.Writer;

            if (Wrapper != null)
            {
                writer.Write(Wrapper.ToString(TagRenderMode.StartTag));
            }

            var ctx = new RenderingContext {
                Content = CurrentItem, Displayable = displayable, Html = Html, PropertyName = propertyName
            };

            Html.ResolveService <DisplayableRendererSelector>()
            .Render(ctx, writer);

            if (Wrapper != null)
            {
                writer.Write(Wrapper.ToString(TagRenderMode.EndTag));
            }
        }
Пример #7
0
        public override void Render(TextWriter writer)
        {
            if (state == ControlPanelState.DragDrop)
            {
                if (ZoneName.IndexOfAny(new[] { '.', ',', ' ', '\'', '"', '\t', '\r', '\n' }) >= 0)
                {
                    throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters.");
                }

                writer.Write("<div class='" + ZoneName + " dropZone'");
                writer.WriteAttribute(PartUtilities.PathAttribute, CurrentItem.Path)
                .WriteAttribute(PartUtilities.ZoneAttribute, ZoneName)
                .WriteAttribute(PartUtilities.AllowedAttribute, PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Html.ViewContext.HttpContext.User)))
                .WriteAttribute("title", ZoneTitle ?? DroppableZone.GetToolTip(Html.ResolveService <IDefinitionManager>().GetDefinition(CurrentItem.GetContentType()), ZoneName))
                .Write(">");

                if (string.IsNullOrEmpty(Html.ViewContext.HttpContext.Request["preview"]))
                {
                    base.Render(writer);
                }
                else
                {
                    string preview = Html.ViewContext.HttpContext.Request["preview"];
                    RenderReplacingPreviewed(writer, preview);
                }

                writer.Write("</div>");
            }
            else
            {
                base.Render(writer);
            }
        }
Пример #8
0
        //// Actions ////

        /// <summary>By default the templates index method renders a (partial) view located in (see below).</summary>
        /// <returns></returns>
        public override ActionResult Index()
        {
            return(CurrentItem.IsPage
                ? View(string.Format("PageTemplates/{0}", CurrentItem.GetContentType().Name), CurrentItem)
                : PartialView(string.Format("PartTemplates/{0}", CurrentItem.GetContentType().Name), CurrentItem));
        }