Пример #1
0
 internal void SetSourcesAttributes(ref XmlTreeNode treeElement, UmbracoEntity dd)
 {
     treeElement.HasChildren = dd.HasChildren;
     treeElement.Source = IsDialog == false ? GetTreeServiceUrl(dd.Id) : GetTreeDialogUrl(dd.Id);
 }
Пример #2
0
 /// <summary>
 /// NOTE: New implementation of the legacy GetLinkValue. This is however a bit quirky as a media item can have multiple "Linkable DataTypes".
 /// Returns the value for a link in WYSIWYG mode, by default only media items that have a 
 /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides
 /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes
 /// list on application startup.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 internal virtual string GetLinkValue(UmbracoEntity entity)
 {
     foreach (var property in entity.UmbracoProperties)
     {
         //required for backwards compatibility with v7 with changing the GUID -> alias
         var controlId = LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(property.PropertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.ReturnNull);
         if (controlId != null)
         {
             if (LinkableMediaDataTypes.Contains(controlId.Value) &&
                string.IsNullOrEmpty(property.Value) == false)
                 return property.Value;   
         }                
     }
     return "";
 }
Пример #3
0
 internal void SetProtectedAttribute(ref XmlTreeNode treeElement, UmbracoEntity dd)
 {
     if (Access.IsProtected(dd.Id, dd.Path))
         treeElement.IsProtected = true;
     else
         treeElement.IsProtected = false;
 }
Пример #4
0
        internal void SetActionAttribute(ref XmlTreeNode treeElement, UmbracoEntity dd)
        {

            // Check for dialog behaviour
            if (this.DialogMode == TreeDialogModes.fulllink)
            {
                string nodeLink = CreateNodeLink(dd);
                treeElement.Action = String.Format("javascript:openContent('{0}');", nodeLink);
            }
            else if (this.DialogMode == TreeDialogModes.locallink)
            {
                string nodeLink = string.Format("{{localLink:{0}}}", dd.Id);
                string nodeText = dd.Name.Replace("'", "\\'");
                // try to make a niceurl too
                string niceUrl = umbraco.library.NiceUrl(dd.Id).Replace("'", "\\'"); ;
                if (niceUrl != "#" || niceUrl != "")
                {
                    nodeLink += "|" + niceUrl + "|" + HttpContext.Current.Server.HtmlEncode(nodeText);
                }
                else
                {
                    nodeLink += "||" + HttpContext.Current.Server.HtmlEncode(nodeText);
                }

                treeElement.Action = String.Format("javascript:openContent('{0}');", nodeLink);
            }
            else if (this.DialogMode == TreeDialogModes.id || this.DialogMode == TreeDialogModes.none)
            {
                treeElement.Action = String.Format("javascript:openContent('{0}');", dd.Id.ToString(CultureInfo.InvariantCulture));
            }
            else if (this.IsDialog == false || (this.DialogMode == TreeDialogModes.id))
            {
                if (CurrentUser.GetPermissions(dd.Path).Contains(ActionUpdate.Instance.Letter.ToString(CultureInfo.InvariantCulture)))
                {
                    treeElement.Action = String.Format("javascript:openContent({0});", dd.Id);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Builds a string of actions that the user is able to perform on the current document.
        /// The list of actions is subject to the user's rights assigned to the document and also
        /// is dependant on the type of node.
        /// </summary>
        /// <param name="dd"></param>
        /// <returns></returns>
        internal List<IAction> GetUserActionsForNode(UmbracoEntity dd)
        {
            List<IAction> actions = umbraco.BusinessLogic.Actions.Action.FromString(CurrentUser.GetPermissions(dd.Path));

            // A user is allowed to delete their own stuff
            if (dd.CreatorId == CurrentUser.Id && actions.Contains(ActionDelete.Instance) == false)
                actions.Add(ActionDelete.Instance);

            return actions;
        }
Пример #6
0
 internal void SetNonPublishedAttribute(ref XmlTreeNode treeElement, UmbracoEntity dd)
 {
     treeElement.NotPublished = false;
     if (dd.IsPublished)
         treeElement.NotPublished = dd.HasPendingChanges;
     else
         treeElement.NotPublished = true;
 }
Пример #7
0
        /// <summary>
        /// Determins if the user has access to view the node/document
        /// </summary>
        /// <param name="doc">The Document to check permissions against</param>
        /// <param name="allowedUserOptions">A list of IActions that the user has permissions to execute on the current document</param>
        /// <remarks>By default the user must have Browse permissions to see the node in the Content tree</remarks>
        /// <returns></returns>        
        internal virtual bool CanUserAccessNode(UmbracoEntity doc, List<IAction> allowedUserOptions)
        {
            if (allowedUserOptions.Contains(ActionBrowse.Instance))
                return true;

            return false;
        }
Пример #8
0
 /// <summary>
 /// Creates the link for the current UmbracoEntity 
 /// </summary>
 /// <param name="dd"></param>
 /// <returns></returns>
 internal string CreateNodeLink(UmbracoEntity dd)
 {
     string nodeLink = library.NiceUrl(dd.Id);
     if (nodeLink == "")
     {
         nodeLink = "/" + dd.Id;
         if (GlobalSettings.UseDirectoryUrls == false)
             nodeLink += ".aspx";
     }
     return nodeLink;
 }
Пример #9
0
        /// <summary>
        /// Creates an XmlTreeNode based on the passed in UmbracoEntity
        /// </summary>
        /// <param name="dd"></param>
        /// <param name="allowedUserOptions"></param>
        /// <returns></returns>
        internal XmlTreeNode CreateNode(UmbracoEntity dd, List<IAction> allowedUserOptions)
        {
            XmlTreeNode node = XmlTreeNode.Create(this);
            SetMenuAttribute(ref node, allowedUserOptions);
            node.NodeID = dd.Id.ToString();
            node.Text = dd.Name;
            SetNonPublishedAttribute(ref node, dd);
            SetProtectedAttribute(ref node, dd);
            SetActionAttribute(ref node, dd);
            SetSourcesAttributes(ref node, dd);
            if (dd.ContentTypeIcon != null)
            {
                node.Icon = dd.ContentTypeIcon;
                node.OpenIcon = dd.ContentTypeIcon;
            }

            if (dd.IsPublished == false)
                node.Style.DimNode();

            if (dd.HasPendingChanges)
                node.Style.HighlightNode();

            return node;
        }
Пример #10
0
 /// <summary>
 /// NOTE: New implementation of the legacy GetLinkValue. This is however a bit quirky as a media item can have multiple "Linkable DataTypes".
 /// Returns the value for a link in WYSIWYG mode, by default only media items that have a 
 /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides
 /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes
 /// list on application startup.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 internal virtual string GetLinkValue(UmbracoEntity entity)
 {
     foreach (var property in entity.UmbracoProperties)
     {
         if (LinkableMediaDataTypes.Contains(property.DataTypeControlId) &&
             string.IsNullOrEmpty(property.Value) == false)
             return property.Value;
     }
     return "";
 }
Пример #11
0
            internal UmbracoEntity Map(dynamic a, UmbracoPropertyDto p)
            {
                // Terminating call.  Since we can return null from this function
                // we need to be ready for PetaPoco to callback later with null
                // parameters
                if (a == null)
                    return Current;

                // Is this the same UmbracoEntity as the current one we're processing
                if (Current != null && Current.Key == a.uniqueID)
                {
                    // Yes, just add this UmbracoProperty to the current UmbracoEntity's collection
                    if (Current.UmbracoProperties == null)
                    {
                        Current.UmbracoProperties = new List<UmbracoEntity.UmbracoProperty>();
                    }
                    Current.UmbracoProperties.Add(new UmbracoEntity.UmbracoProperty
                        {
                            PropertyEditorAlias = p.PropertyEditorAlias,
                            Value = p.UmbracoFile
                        });
                    // Return null to indicate we're not done with this UmbracoEntity yet
                    return null;
                }

                // This is a different UmbracoEntity to the current one, or this is the 
                // first time through and we don't have a Tab yet

                // Save the current UmbracoEntityDto
                var prev = Current;

                // Setup the new current UmbracoEntity
                
                Current = _factory.BuildEntityFromDynamic(a);

                //add the property/create the prop list if null
                Current.UmbracoProperties = new List<UmbracoEntity.UmbracoProperty>
                    {
                        new UmbracoEntity.UmbracoProperty
                            {
                                PropertyEditorAlias = p.PropertyEditorAlias,
                                Value = p.UmbracoFile
                            }
                    };

                // Return the now populated previous UmbracoEntity (or null if first time through)
                return prev;
            }