Beispiel #1
0
        private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
        {
            if (node.TreeType.ToLower() == "content")
            {
                try
                {
                    Document document = new Document(Convert.ToInt32(node.NodeID));

                    //this changes the create action b/c of the UI.xml entry
                    if (CreateDocTypes.Contains(document.ContentType.Alias))
                    {
                        node.NodeType = "uNews";
                    }

                    if (RemoveCreateDocTypes.Contains(document.ContentType.Alias))
                    {
                        node.Menu.Remove(ActionNew.Instance);
                    }
                }

                catch (Exception e2)
                {

                }
            }
        }
        protected override void OnRenderFileNode(ref XmlTreeNode xNode)
        {

            xNode.Action = xNode.Action.Replace("openFile", "openDLRScript");
            string ex = xNode.Text.Substring(xNode.Text.LastIndexOf('.')).Trim('.').ToLower();
            string icon = "developerScript.gif";

            switch (ex)
            {
                case "rb":
                    icon = "developerRuby.gif";
                    break;
                case "py":
                    icon = "developerPython.gif";
                    break;
                case "config":
                    //remove all config files
                    xNode = null;
                    return;
                default:
                    icon = "developerScript.gif";
                    break;
            }

            xNode.Icon = icon;
            xNode.OpenIcon = icon;
        }
 void FileSystemTree_AfterNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
 {
     if (node.TreeType == "scripts" && new Core().GetPossibleExtensions(Enums.TranslatorType.Script).Contains(Path.GetExtension(node.NodeID)))
     {
         sender.Remove(node);
     }
 }
Beispiel #4
0
 private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
 {
     if (node.Menu == null || node.NodeType.ToLower() != "content") return;
     node.Menu.Insert(3, new TranslationCreationAction());
     node.Menu.Insert(3, ContextMenuSeperator.Instance);
     node.Menu.Insert(5, ContextMenuSeperator.Instance);
 }
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Icon = FolderIcon;
     rootNode.OpenIcon = FolderIconOpen;
     rootNode.NodeType = "init" + TreeAlias;
     rootNode.NodeID = "init";
 }
 protected override void OnRenderFileNode(ref XmlTreeNode xNode)
 {
     xNode.Action = xNode.Action.Replace("openFile", "openConfigEditor");
     xNode.Menu = new List<IAction>();
     xNode.Icon = "../../images/umbraco/settingCss.gif";
     xNode.OpenIcon = xNode.Icon;
 }
 public LegacyTreeController(XmlTreeNode xmlTreeNode, string treeAlias, string currentSection, UrlHelper urlHelper)
 {
     _xmlTreeNode = xmlTreeNode;
     _treeAlias = treeAlias;
     _currentSection = currentSection;
     _rootDisplay = xmlTreeNode.Text;
     Url = urlHelper;
 }
Beispiel #8
0
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {            

            if (this.IsDialog)
                rootNode.Action = "javascript:openMedia(-1);";
            else
                rootNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard("Media");
        }
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.NodeID = System.Guid.NewGuid().ToString();
     rootNode.Action = "javascript:openExportToWordPage()";
     rootNode.Menu.Clear();
     rootNode.Menu.Add(ActionRefresh.Instance);
     rootNode.Icon = "../../plugins/AsposeMemberExportToWord/Images/aspose.ico";
     rootNode.OpenIcon = "../../plugins/AsposeMemberExportToWord/Images/aspose.ico";
 }
Beispiel #10
0
        private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
        {
            //LogHelper.Info<AddTranslationAction>(node.NodeType.ToLower());

            switch (node.NodeType.ToLower())
            {
                case "content":
                    try
                    {
                        var document = ApplicationContext.Current.Services.ContentService.GetById(Convert.ToInt32(node.NodeID));

                        var translationDocType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(document.ContentType.Alias + BabelFishCreateTranslation.PropertySuffix);

                        /*
                        LogHelper.Info<AddTranslationAction>("translationDocType=>" + (translationDocType == null).ToString());
                        LogHelper.Info<AddTranslationAction>("document.ContentType=>" + (document.ContentType == null).ToString());
                        LogHelper.Info<AddTranslationAction>("translationDocType.ParentId=>" + (translationDocType.ParentId).ToString());
                        LogHelper.Info<AddTranslationAction>("document.ContentType.Id=>" + (document.ContentType.Id).ToString());
                        LogHelper.Info<AddTranslationAction>("translationDocType.PropertyTypeExists=>" + translationDocType.PropertyTypeExists(BabelFishCreateTranslation.LanguagePropertyAlias).ToString());
                        */

                        if (
                            translationDocType != null &&
                            document.ContentType != null &&
                            (translationDocType.ParentId == document.ContentType.Id) &&
                            translationDocType.PropertyTypeExists(BabelFishCreateTranslation.LanguagePropertyAlias))
                        {
                            node.Menu.Insert(7, ContextMenuSeperator.Instance);
                            node.Menu.Insert(8, ActionCreateTranslation.Instance);
                        }

                        //remove 'create' for 'BabelFishTranslationFolder'
                        if (document.ContentType.Alias == BabelFishCreateTranslation.BabelFishFolderDocTypeAlias)
                        {
                            node.Menu.Remove(ActionNew.Instance);
                        }

                        //remove 'create' for 'Translation' doctype
                        if (document.ContentType.Alias.EndsWith(BabelFishCreateTranslation.PropertySuffix))
                        {
                            node.Menu.Remove(ActionNew.Instance);

                            try
                            {
                                node.Icon = document.GetValue<string>(BabelFishCreateTranslation.LanguagePropertyAlias) + ".png";
                            }
                            catch {}
                        }
                    }
                    catch (Exception e2)
                    {
                        LogHelper.Error<AddTranslationAction>(e2.Message, e2);
                    }

                    break;
            }
        }
Beispiel #11
0
        public LegacyTree(ITree tree, string application, XmlTreeNode rootNode)
            : base(application)
        {
            _tree = tree;
            _rootNode = rootNode;

            //we need to re-initialize the class now that we have a root node
            Initialize();
        }
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Text = "Less Files";
     rootNode.Icon = ".sprTreeFolder";
     rootNode.OpenIcon = ".sprTreeFolder_o";
     rootNode.NodeID = "initConfigFiles";
     rootNode.NodeType = rootNode.NodeID + "_" + TreeAlias;
     rootNode.Menu = new List<IAction> { ActionRefresh.Instance };
 }
Beispiel #13
0
    private void BaseContentTreeOnAfterNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs eventArgs)
    {
        if (node.IsProtected.GetValueOrDefault(true) && umbraco.helper.GetCurrentUmbracoUser().UserType.Alias == "trainer")
        {
            //Writers cannot see protected pages
            //sender.
            string nodeType = node.NodeType;

        }
    }
Beispiel #14
0
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Icon = FolderIcon;
            rootNode.OpenIcon = FolderIconOpen;
            rootNode.NodeType = TreeAlias;
            rootNode.NodeID = "-1";

            rootNode.Menu.Clear();
            rootNode.Menu.Add(ActionRefresh.Instance);
        }
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     // if we're using 3rd party membership providers we should use the Role terminology
     if (!Member.IsUsingUmbracoRoles())
     {
         rootNode.Text = ui.Text("memberRoles");
     }
     rootNode.NodeType = "init" + TreeAlias;
     rootNode.NodeID = "init";
 }
 void BaseContentTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
 {
     if (node.NodeType == "content")
     {
         try
         {
             int index = node.Menu.FindIndex(delegate(IAction a) { return a.Alias == "publish"; }) + 1;
             node.Menu.Insert(index, MailingAction.Instance);
         }
         catch { }
     }
 }
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {                              
            // only show member types if we're using umbraco members on the website
            if (Member.InUmbracoMemberMode())
            {
				rootNode.NodeType = "init" + TreeAlias;
				rootNode.NodeID = "init";
            }
            else
            {
                rootNode = null;
            }
        }
 /// <summary>
 /// Creates the root node.
 /// </summary>
 /// <param name="rootNode">The root node.</param>
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     if (!this.SetNullTreeRootNode(StartNodeID, ref rootNode, app))
     {
         rootNode.Action = "javascript:openContent(-1);";
         rootNode.Source = this.GetTreeServiceUrlWithParams(StartNodeID, this.GetDataTypeId());
         if (StartNodeID > 0)
         {
             var startNode = new Document(StartNodeID);
             rootNode.Text = startNode.Text;
             rootNode.Icon = startNode.ContentTypeIcon;
         }
     }
 }
        protected void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
        {
            XmlNode xmlNode = null;

            switch (node.NodeType.ToUpper())
            {
                case "content":
                    xmlNode = this.GetContentXmlNode(node.NodeID);
                    break;

                case "media":
                    xmlNode = this.GetMediaXmlNode(node.NodeID);
                    break;

                case "member":
                    xmlNode = this.GetMemberXmlNode(node.NodeID);
                    break;

                default:
                    break;
            }

            // if we have an XML node...
            if (xmlNode != null && PageStateIconsConfigurationSection.Instance != null)
            {
                // ... match rules
                foreach (RuleElement rule in PageStateIconsConfigurationSection.Instance.Rules)
                {
                    // apply XPath
                    var xpath = string.Concat("self::*[", rule.XPath, "]");
                    if (xmlNode.SelectSingleNode(xpath) != null)
                    {
                        switch (rule.IconType)
                        {
                            case IconType.overlay:
                                // add custom class for overlay
                                node.Style.AddCustom(string.Format("overlay-{0}", Casing.SafeAlias(rule.Name)));
                                break;

                            case IconType.icon:
                                node.Icon = rule.IconPath;
                                break;

                            default:
                                break;
                        }
                    }
                }
            }
        }
Beispiel #20
0
		protected override void CreateRootNode(ref XmlTreeNode rootNode)
		{
			rootNode.Icon = "bin_empty.png";
			rootNode.OpenIcon = "bin.png";
			//we made this alias the same as media, so the node name would be media,
			//we need to make it recycle bin
			TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(this);
			rootNode.Text = rootNode.Text = GetTreeHeader(treeDef.Tree.Alias);
			if (new RecycleBin(Media._objectType, RecycleBin.RecycleBinType.Media).Smells())
			{
				rootNode.Icon = "bin.png";
			}
			else
				rootNode.Source = null;
		}
        void BaseContentTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
        {
            if (node.Menu!= null && node.NodeType =="content")
             {
                 //Find the publish action and add 1 for the index, so the position of the ubpublish  is direct after the publish menu item
                 IAction action = node.Menu.Find(p => p.Alias == "rights");
                 if (action != null)
                 {
                     int index = node.Menu.FindIndex(p => p.Alias == "rights");
                    //Insert unpublish action
                     node.Menu.Insert(index, UsergroupPermissions.Instance);
                     node.Menu.Insert(index, ContextMenuSeperator.Instance);
                 }

             }
        }
Beispiel #22
0
        /// <summary>
        /// creates a new XmlTreeNode with the default parameters for the BaseTree root node
        /// </summary>
        /// <param name="bTree"></param>
        /// <returns></returns>
        public static XmlTreeNode CreateRoot(BaseTree bTree)
        {
            XmlTreeNode xNode = new XmlTreeNode();

            xNode.NodeID   = bTree.StartNodeID.ToString();
            xNode.Source   = bTree.GetTreeServiceUrl();
            xNode.Menu     = bTree.RootNodeActions.FindAll(delegate(IAction a) { return(true); });        //return a duplicate copy of the list
            xNode.NodeType = bTree.TreeAlias;
            xNode.Text     = BaseTree.GetTreeHeader(bTree.TreeAlias);
            //by default, all root nodes will open the dashboard to their application
            xNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard(bTree.app);
            xNode.IsRoot = true;
            //generally the tree type and node type are the same but in some cased they are not.
            xNode.m_treeType = bTree.TreeAlias;
            return(xNode);
        }
 private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
 {
     if (node.TreeType.ToLower() == "content")
     {
         Document document = new Document(Convert.ToInt32(node.NodeID));
         if (document.ContentType.Alias == "SimpleForm" || document.ContentType.Alias == "SimpleFormTranslation")
         {
             //here we are using the context menu as the only means to differentiate whether we are on the permissions page or the usual content page.  Both permissions and the content sections report the tree type as 'content'.
             var contextMenu = HttpContext.Current.Request.QueryString["contextMenu"];
             if (contextMenu != null && Convert.ToBoolean(contextMenu))
             {
                 //Log.Add(LogTypes.Custom, 0, "page=>" + HttpContext.Current.Request.QueryString["contextMenu"]);
                 node.Action = "javascript:parent.right.document.location.href='/umbraco/plugins/SimpleForms/editform.aspx?id=" + node.NodeID + "'";
             }
         }
     }
 }
Beispiel #24
0
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Icon     = "bin_empty.png";
            rootNode.OpenIcon = "bin.png";
            //we made this alias the same as media, so the node name would be media,
            //we need to make it recycle bin
            TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(this);

            rootNode.Text = rootNode.Text = GetTreeHeader(treeDef.Tree.Alias);
            if (new RecycleBin(Media._objectType, RecycleBin.RecycleBinType.Media).Smells())
            {
                rootNode.Icon = "bin.png";
            }
            else
            {
                rootNode.Source = null;
            }
        }
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            //if the _rootNode is not defined yet, just return an empty one
            if (_rootNode == null)
            {
                NullTree nullTree = new NullTree(this.app);
                _rootNode = XmlTreeNode.CreateRoot(nullTree);
            }

            rootNode.Menu     = _rootNode.Menu;
            rootNode.Text     = _rootNode.Text;
            rootNode.Action   = _rootNode.Action;
            rootNode.Source   = _rootNode.Source;
            rootNode.Icon     = _rootNode.Icon;
            rootNode.OpenIcon = _rootNode.OpenIcon;
            rootNode.NodeType = _rootNode.NodeType;
            rootNode.NodeID   = _rootNode.NodeID;
        }
Beispiel #26
0
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            //if the _rootNode is not defined yet, just return an empty one
            if (_rootNode == null)
            {
                NullTree nullTree = new NullTree(this.app);
                _rootNode = XmlTreeNode.CreateRoot(nullTree);
            }                

            rootNode.Menu = _rootNode.Menu;
            rootNode.Text = _rootNode.Text;
            rootNode.Action = _rootNode.Action;
            rootNode.Source = _rootNode.Source;
            rootNode.Icon = _rootNode.Icon;
            rootNode.OpenIcon = _rootNode.OpenIcon;
            rootNode.NodeType = _rootNode.NodeType;
            rootNode.NodeID = _rootNode.NodeID;
        }
Beispiel #27
0
        /// <summary>
        /// creates a new XmlTreeNode with the default parameters for the BaseTree root node
        /// </summary>
        /// <param name="bTree"></param>
        /// <returns></returns>
        public static XmlTreeNode CreateRoot(BaseTree bTree)
        {
            XmlTreeNode xNode = new XmlTreeNode();

            xNode.NodeID   = bTree.StartNodeID.ToString();
            xNode.Source   = bTree.GetTreeServiceUrl();
            xNode.Menu     = bTree.RootNodeActions.FindAll(delegate(IAction a) { return(true); });        //return a duplicate copy of the list
            xNode.NodeType = bTree.TreeAlias;
            xNode.Text     = BaseTree.GetTreeHeader(bTree.TreeAlias);

            // By default the action from the trees.config will be used, if none is specified then the apps dashboard will be used.
            var appTreeItem = umbraco.BusinessLogic.ApplicationTree.getByAlias(bTree.TreeAlias);

            xNode.Action = appTreeItem == null || String.IsNullOrEmpty(appTreeItem.Action) ? "javascript:" + ClientTools.Scripts.OpenDashboard(bTree.app) : "javascript:" + appTreeItem.Action;

            xNode.IsRoot = true;
            //generally the tree type and node type are the same but in some cased they are not.
            xNode.m_treeType = bTree.TreeAlias;
            return(xNode);
        }
Beispiel #28
0
        public override void Render(ref XmlTree tree)
        {
            foreach (umbraco.BusinessLogic.User user in umbraco.BusinessLogic.User.getAll())
            {
                if (user.Id > 0 && !user.Disabled)
                {
                    XmlTreeNode node = XmlTreeNode.Create(this);
                    node.NodeID = user.Id.ToString();
                    node.Text   = user.Name;
                    node.Action = "javascript:openUserPermissions('" + user.Id.ToString() + "');";
                    node.Icon   = "user.gif";

                    OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        tree.Add(node);
                        OnAfterNodeRender(ref tree, ref node, EventArgs.Empty);
                    }
                }
            }
        }
Beispiel #29
0
        protected XmlTreeNode CreateNode(Document dd, List <IAction> allowedUserOptions)
        {
            XmlTreeNode node = XmlTreeNode.Create(this);

            SetMenuAttribute(ref node, allowedUserOptions);
            node.NodeID = dd.Id.ToString();
            node.Text   = dd.Text;
            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.Published)
            {
                node.Style.DimNode();
            }
            return(node);
        }
        /// <summary>
        /// Converts an ITree into a BaseTree. This is used for Legacy trees that don't inherit from BaseTree already.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="alias"></param>
        /// <param name="appAlias"></param>
        /// <param name="iconClosed"></param>
        /// <param name="iconOpened"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static BaseTree FromITree(ITree tree, string alias, string appAlias, string iconClosed, string iconOpened, string action)
        {
            TreeService treeSvc = new TreeService(null, alias, null, null, TreeDialogModes.none, appAlias);
            //create the generic XmlTreeNode and fill it with the properties from the db
            NullTree    nullTree = new NullTree(appAlias);
            XmlTreeNode node     = XmlTreeNode.CreateRoot(nullTree);

            node.Text     = BaseTree.GetTreeHeader(alias);;
            node.Action   = action;
            node.Source   = treeSvc.GetServiceUrl();
            node.Icon     = iconClosed;
            node.OpenIcon = iconOpened;
            node.NodeType = "init" + alias;
            node.NodeType = alias;
            node.NodeID   = "init";
            node.Menu     = BaseTree.GetDefaultRootNodeActions();

            //convert the tree to a LegacyTree
            LegacyTree bTree = new LegacyTree(tree, appAlias, node);

            return(bTree);
        }
Beispiel #31
0
        public override void Render(ref XmlTree tree)
        {
            List <UserType> userTypes = UserType.GetAllUserTypes();

            foreach (UserType userType in userTypes)
            {
                if (userType.Id > 1) //don't show the admin user type, they should always have full permissions
                {
                    XmlTreeNode node = XmlTreeNode.Create(this);
                    node.NodeID = userType.Id.ToString();
                    node.Action = string.Format("javascript:openUserTypes({0})", userType.Id.ToString());
                    node.Icon   = "user.gif";
                    node.Text   = userType.Alias;

                    OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        tree.Add(node);
                        OnAfterNodeRender(ref tree, ref node, EventArgs.Empty);
                    }
                }
            }
        }
Beispiel #32
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);
                }
            }
        }
Beispiel #33
0
        //Updated Render method for improved performance, but currently not usable because of backwards compatibility
        //with the OnBeforeTreeRender/OnAfterTreeRender events, which sends an array for legacy Media items.
        public override void Render(ref XmlTree tree)
        {
            //_timer = DisposableTimer.Start(x => LogHelper.Debug<BaseMediaTree>("Media tree loaded" + " (took " + x + "ms)"));

            var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Media).ToArray();

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(entities, args, false);

            foreach (UmbracoEntity entity in entities)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = entity.Id.ToString(CultureInfo.InvariantCulture);
                xNode.Text   = entity.Name;

                xNode.HasChildren = entity.HasChildren;
                xNode.Source      = this.IsDialog ? GetTreeDialogUrl(entity.Id) : GetTreeServiceUrl(entity.Id);

                xNode.Icon     = entity.ContentTypeIcon;
                xNode.OpenIcon = entity.ContentTypeIcon;

                if (IsDialog == false)
                {
                    if (this.ShowContextMenu == false)
                    {
                        xNode.Menu = null;
                    }
                    xNode.Action = "javascript:openMedia(" + entity.Id + ");";
                }
                else
                {
                    xNode.Menu = this.ShowContextMenu ? new List <IAction>(new IAction[] { ActionRefresh.Instance }) : null;
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(entity);
                        if (string.IsNullOrEmpty(nodeLink) == false)
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            if (string.Equals(entity.ContentTypeAlias, Constants.Conventions.MediaTypes.Folder, StringComparison.OrdinalIgnoreCase))
                            {
                                //#U4-2254 - Inspiration to use void from here: http://stackoverflow.com/questions/4924383/jquery-object-object-error
                                xNode.Action = "javascript:void jQuery('.umbTree #" + entity.Id.ToString(CultureInfo.InvariantCulture) + "').click();";
                            }
                            else
                            {
                                xNode.Action = null;
                                xNode.Style.DimNode();
                            }
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + entity.Id.ToString(CultureInfo.InvariantCulture) + "');";
                    }
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }

            //stop the timer and log the output
            //_timer.Dispose();

            OnAfterTreeRender(entities, args, false);
        }
Beispiel #34
0
 protected override void OnBeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
 {
     base.OnBeforeNodeRender(ref sender, ref node, e);
     node.Style.DimNode();
 }
Beispiel #35
0
 protected void SetMenuAttribute(ref XmlTreeNode treeElement, List <IAction> allowedUserActions)
 {
     //clear menu if we're to hide it
     treeElement.Menu = this.ShowContextMenu == false ? null : RemoveDuplicateMenuDividers(GetUserAllowedActions(AllowedActions, allowedUserActions));
 }
Beispiel #36
0
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path    = "";

            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath  = this.NodeKey;
                path     = IOHelper.MapPath(FilePath + orgPath);
                orgPath += "/";
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);

            DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
                    xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text        = dir.Name;
                    xDirNode.Action      = string.Empty;
                    xDirNode.Source      = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon        = FolderIcon;
                    xDirNode.OpenIcon    = FolderIconOpen;
                    xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;

                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                }
            }
            FileInfo[] fileInfo = dirInfo.GetFiles(FileSearchPattern);
            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
                    xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text   = file.Name;
                    if (!((orgPath == "")))
                    {
                        xFileNode.Action = "javascript:openFile('" + orgPath + file.Name + "');";
                    }
                    else
                    {
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    }
                    xFileNode.Icon     = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(dirInfo, args);
        }
Beispiel #37
0
 protected override abstract void CreateRootNode(ref XmlTreeNode rootNode);
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Action = "javascript:openTranslationOverview(" + currentUser().Id + ",'open');";
     rootNode.Text = ui.Text("translation", "assignedTasks");
 }
		protected override void OnRenderFileNode(ref XmlTreeNode xNode)
		{
			ChangeNodeAction(xNode);
			xNode.Icon = "settingView.gif";
			xNode.OpenIcon = "settingView.gif";
		}
 /// <summary>
 /// Creates the root node.
 /// </summary>
 /// <param name="rootNode">The root node.</param>
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Text = "uImageResizer";
     rootNode.Icon = "../../plugins/uImageResizer/TreeIcon.gif";
     rootNode.OpenIcon = FolderIconOpen;
     rootNode.NodeID = "initConfigFiles";
     rootNode.Action = "javascript:openuImageResizer();";
     rootNode.NodeType = String.Concat(rootNode.NodeID, "_", this.TreeAlias);
     rootNode.Menu = new List<IAction>(new IAction[] { ActionRefresh.Instance });
 }
Beispiel #41
0
 public void Remove(XmlTreeNode obj)
 {
     treeCollection.Remove(obj);
 }
Beispiel #42
0
 public void Add(XmlTreeNode obj)
 {
     treeCollection.Add(obj);
 }
Beispiel #43
0
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Text = ui.Text("user", "userTypes");
 }
Beispiel #44
0
 internal void SetSourcesAttributes(ref XmlTreeNode treeElement, UmbracoEntity dd)
 {
     treeElement.HasChildren = dd.HasChildren;
     treeElement.Source      = IsDialog == false?GetTreeServiceUrl(dd.Id) : GetTreeDialogUrl(dd.Id);
 }
 public void SetRootNode(XmlTreeNode rootNode)
 {
     _rootNode = rootNode;
 }
		protected virtual void ChangeNodeAction(XmlTreeNode xNode)
		{
			xNode.Action = xNode.Action.Replace("openFile", "openPartialView");
		}
Beispiel #47
0
        /// <summary>
        /// Serializes an XmlTreeNode object with the relevant values.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="serializer"></param>
        /// <returns></returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            XmlTreeNode node = obj as XmlTreeNode;

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (node != null)
            {
                //the data object to build the node
                Dictionary <string, object> data = new Dictionary <string, object>();

                data.Add("title", node.Text);



                //the attributes object fot the tree node link (a) object created
                Dictionary <string, object> dataAttributes = new Dictionary <string, object>();
                string cssClass = "";
                if (node.Icon.StartsWith(".spr"))
                {
                    cssClass = "sprTree " + node.Icon.TrimStart('.');
                }
                else
                {
                    //there is no sprite so add the noSpr class
                    cssClass = "sprTree noSpr";
                    data.Add("icon", IconPath + node.Icon);
                }
                dataAttributes.Add("class", cssClass + (string.IsNullOrEmpty(node.IconClass) ? "" : " " + node.IconClass));
                dataAttributes.Add("href", node.Action);

                //add a metadata dictionary object, we can store whatever we want in this!
                //in this case we're going to store permissions & the tree type & the child node source url
                //For whatever reason jsTree requires this JSON output to be quoted!?!
                //This also needs to be stored in the attributes object with the class above.
                Dictionary <string, object> metadata = new Dictionary <string, object>();
                //the menu:
                metadata.Add("menu", node.Menu == null ? "" : umbraco.BusinessLogic.Actions.Action.ToString(node.Menu));
                //the tree type:
                metadata.Add("nodeType", node.NodeType);
                //the data url for child nodes:
                metadata.Add("source", node.Source);

                //the metadata/jsTree requires this property to be in a quoted JSON syntax
                JSONSerializer jsSerializer = new JSONSerializer();
                string         strMetaData  = jsSerializer.Serialize(metadata).Replace("\"", "'");
                dataAttributes.Add("umb:nodedata", strMetaData);

                data.Add("attributes", dataAttributes);

                //add the data structure
                result.Add("data", data);

                //state is nothing if no children
                if ((node.HasChildren || node.IsRoot) && !string.IsNullOrEmpty(node.Source))
                {
                    result.Add("state", "closed");
                }

                //the attributes object for the tree node (li) object created
                Dictionary <string, object> attributes = new Dictionary <string, object>();
                attributes.Add("id", node.NodeID);
                attributes.Add("class", string.Join(" ", node.Style.AppliedClasses.ToArray()));

                if (node.IsRoot)
                {
                    attributes.Add("rel", "rootNode");
                }
                else
                {
                    attributes.Add("rel", "dataNode");
                }

                //the tree type should always be set, however if some developers have serialized their tree into an XmlTree
                //then there is no gaurantees that this will be set if they didn't use the create methods of XmlTreeNode.
                //So, we'll set the treetype to the nodetype if it is null, this means that the tree on the front end may
                //not function as expected when reloding a node.
                attributes.Add("umb:type", string.IsNullOrEmpty(node.TreeType) ? node.NodeType : node.TreeType);

                result.Add("attributes", attributes);

                return(result);
            }

            return(null);
        }
Beispiel #48
0
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     
 }
Beispiel #49
0
        public override void Render(ref XmlTree tree)
        {
            Media[] docs = new Media(m_id).Children;

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(docs, args);

            foreach (Media dd in docs)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = dd.Id.ToString();
                xNode.Text   = dd.Text;

                // Check for dialog behaviour
                if (!this.IsDialog)
                {
                    if (!this.ShowContextMenu)
                    {
                        xNode.Menu = null;
                    }
                    xNode.Action = "javascript:openMedia(" + dd.Id + ");";
                }
                else
                {
                    if (this.ShowContextMenu)
                    {
                        xNode.Menu = new List <IAction>(new IAction[] { ActionRefresh.Instance });
                    }
                    else
                    {
                        xNode.Menu = null;
                    }
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(dd, dd.Id.ToString());
                        if (!String.IsNullOrEmpty(nodeLink))
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            xNode.Action = null;
                            xNode.DimNode();
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');";
                    }
                }

                xNode.HasChildren = dd.HasChildren;
                if (this.IsDialog)
                {
                    xNode.Source = GetTreeDialogUrl(dd.Id);
                }
                else
                {
                    xNode.Source = GetTreeServiceUrl(dd.Id);
                }

                if (dd.ContentType != null)
                {
                    xNode.Icon     = dd.ContentType.IconUrl;
                    xNode.OpenIcon = dd.ContentType.IconUrl;
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }
            OnAfterTreeRender(docs, args);
        }
Beispiel #50
0
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Menu = null;
     rootNode.Text = "Error";
 }
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path    = "";

            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath = this.NodeKey.EnsureEndsWith('/');
                path    = IOHelper.MapPath($"{FilePath.EnsureEndsWith('/')}{orgPath}");
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);


            DirectoryInfo[] dirInfos = dirInfo.Exists ? dirInfo.GetDirectories() : new DirectoryInfo[] { };

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
                    xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text        = dir.Name;
                    xDirNode.Action      = string.Empty;
                    xDirNode.Source      = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon        = FolderIcon;
                    xDirNode.OpenIcon    = FolderIconOpen;
                    xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;

                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                }
            }

            //this is a hack to enable file system tree to support multiple file extension look-up
            //so the pattern both support *.* *.xml and xml,js,vb for lookups
            string[] allowedExtensions          = new string[0];
            bool     filterByMultipleExtensions = FileSearchPattern.Contains(",");

            FileInfo[] fileInfo;

            if (filterByMultipleExtensions)
            {
                fileInfo          = dirInfo.Exists ? dirInfo.GetFiles() : new FileInfo[] {};
                allowedExtensions = FileSearchPattern.ToLower().Split(',');
            }
            else
            {
                fileInfo = dirInfo.Exists ? dirInfo.GetFiles(FileSearchPattern) : new FileInfo[] { };
            }

            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    if (filterByMultipleExtensions && Array.IndexOf <string>(allowedExtensions, file.Extension.ToLower().Trim('.')) < 0)
                    {
                        continue;
                    }

                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
                    xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text   = file.Name;
                    if (!((orgPath == "")))
                    {
                        xFileNode.Action = "javascript:openFile('" + orgPath + file.Name + "');";
                    }
                    else
                    {
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    }
                    xFileNode.Icon     = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(dirInfo, args);
        }
Beispiel #52
0
 /// <summary>
 /// Inheritors can override this method to modify the folder node that is created.
 /// </summary>
 /// <param name="xNode"></param>
 protected virtual void OnRenderFolderNode(ref XmlTreeNode xNode)
 {
 }
Beispiel #53
0
 protected override void OnRenderNode(ref XmlTreeNode xNode, Document doc)
 {
     xNode.Style.DimNode();
 }
Beispiel #54
0
 protected override void CreateRootNode(ref XmlTreeNode rootNode)
 {
     rootNode.Text = ui.Text("user", "userPermissions");
 }
Beispiel #55
0
 protected void SetSourcesAttributes(ref XmlTreeNode treeElement, Document dd)
 {
     treeElement.HasChildren = dd.ContentType.IsContainerContentType == false && dd.HasChildren;
     treeElement.Source      = IsDialog == false?GetTreeServiceUrl(dd.Id) : GetTreeDialogUrl(dd.Id);
 }
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.NodeType = "init" + TreeAlias; 
			rootNode.NodeID = "init";
        }
Beispiel #57
0
 /// <summary>
 /// Inheritors override this method to modify the content node being created
 /// </summary>
 /// <param name="xNode"></param>
 /// <param name="doc"></param>
 protected virtual void OnRenderNode(ref XmlTreeNode xNode, Document doc)
 {
 }