Example #1
0
        public static ServiceAction GetServiceAction(Content context, string backUrl, string methodName, string title, string iconName, int index)
        {
            var act = ActionFramework.GetAction("ServiceAction", context, backUrl, new { path = context.Path }) as ServiceAction;

            if (act != null)
            {
                act.Name        = methodName;
                act.ServiceName = "ContentStore.mvc";
                act.MethodName  = methodName;
                act.Text        = title;
                act.Icon        = iconName;
                act.Index       = index;
            }

            return(act);
        }
Example #2
0
        private static ServiceAction GetServiceAction(Content context, Node view, bool addFullPath, string portletId, string selectedView, string backUrl)
        {
            // create app-less action for view selection
            var act = ActionFramework.GetAction("ServiceAction", context, backUrl,
                                                new
            {
                uiContextId = portletId ?? string.Empty,
                view        = addFullPath ? view.Path : view.Name,
            }) as ServiceAction;

            if (act == null)
            {
                return(null);
            }

            var gc          = view as GenericContent;
            var viewContent = Content.Create(view);
            var icon        = gc != null ? gc.Icon : string.Empty;

            if (string.IsNullOrEmpty(icon))
            {
                icon = "views";
            }

            act.Name        = "ServiceAction";
            act.ServiceName = ODataTools.GetODataUrl(context.Path);
            act.MethodName  = "ContentListViewSetView";
            act.Text        = viewContent.DisplayName;
            act.Icon        = icon;

            if (string.Compare(selectedView, view.Name, StringComparison.InvariantCultureIgnoreCase) == 0 ||
                string.Compare(selectedView, view.Path, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                act.CssClass  = (act.CssClass + " sn-actionlink-selectedview").TrimStart(' ');
                act.Forbidden = true;
            }
            return(act);
        }
Example #3
0
        private static ServiceAction GetServiceAction(Content context, Node view, bool addFullPath, string portletId, string selectedView, string backUrl)
        {
            //create app-less action for view selection
            var act = ActionFramework.GetAction("ServiceAction", context, backUrl,
                                                new
            {
                path        = context.Path,
                uiContextId = portletId ?? string.Empty,
                view        = addFullPath ? view.Path : view.Name
            }) as ServiceAction;

            if (act == null)
            {
                return(null);
            }

            var gc   = view as GenericContent;
            var icon = gc != null ? gc.Icon : string.Empty;

            if (string.IsNullOrEmpty(icon))
            {
                icon = "views";
            }

            act.Name        = "ServiceAction";
            act.ServiceName = "ContentListViewHelper.mvc";
            act.MethodName  = "SetView";
            act.Text        = view.DisplayName;
            act.Icon        = icon;

            if (selectedView.CompareTo(view.Name) == 0 || selectedView.CompareTo(view.Path) == 0)
            {
                act.CssClass  = (act.CssClass + " sn-actionlink-selectedview").TrimStart(new[] { ' ' });
                act.Forbidden = true;
            }
            return(act);
        }
        protected override IEnumerable <ActionBase> CollectActions(Content context, string backUrl)
        {
            var actList = new List <ActionBase>();

            if (context == null)
            {
                return(actList);
            }

            // gather Add actions
            var gc           = context.ContentHandler as GenericContent;
            var contentTypes = gc?.GetAllowedChildTypes().ToList() ?? new List <ContentType>();
            var addActions   = new List <ActionBase>();
            var app          = ApplicationStorage.Instance.GetApplication("Add", context, PortalContext.Current.DeviceName);

            if (app != null)
            {
                new List <string> {
                    "Workspace", "DocumentLibrary", "CustomList", "ItemList"
                }.ForEach(
                    delegate(string contentTypeName)
                {
                    if (contentTypes.All(ct => ct.Name != contentTypeName))
                    {
                        return;
                    }

                    var cnt          = ContentType.GetByName(contentTypeName);
                    var name         = ContentTemplate.HasTemplate(contentTypeName) ? ContentTemplate.GetTemplate(contentTypeName).Path : cnt.Name;
                    var addNewAction = app.CreateAction(context, backUrl, new { ContentTypeName = name, backtarget = "newcontent" });
                    if (addNewAction == null)
                    {
                        return;
                    }

                    addNewAction.Text = string.Concat(SenseNetResourceManager.Current.GetString("Portal", "AddNewActionPrefix"), Content.Create(cnt).DisplayName);
                    addNewAction.Icon = cnt.Icon;

                    addActions.Add(addNewAction);
                });
            }

            // sort add actions by text
            addActions.Sort(new ActionComparerByText());

            actList.AddRange(addActions);

            // 'Create other' action
            if (contentTypes.Count > 0)
            {
                var createOtherAction = ActionFramework.GetAction("Create", context, backUrl, null);
                if (createOtherAction != null)
                {
                    createOtherAction.Text = SenseNetResourceManager.Current.GetString("Portal", "CreateOtherActionText");
                    actList.Add(createOtherAction);
                }
            }

            // get all remaining actions and sort them using the regular comparer (by Index)
            var baseActions = base.CollectActions(context, backUrl).ToList();

            baseActions.Sort(new ActionComparer());

            actList.AddRange(baseActions);

            return(actList);
        }
        protected override IEnumerable <ActionBase> CollectActions(Content context, string backUrl)
        {
            var actList = new List <ActionBase>();

            if (context == null)
            {
                return(actList);
            }

            // Create other action
            var gc           = context.ContentHandler as GenericContent;
            var contentTypes = gc == null ? new List <ContentType>() : gc.GetAllowedChildTypes().ToList();

            if (PortalContext.Current.ArbitraryContentTypeCreationAllowed || contentTypes.Count > 0)
            {
                var createOtherAction = ActionFramework.GetAction("Create", context, backUrl, null);
                if (createOtherAction != null)
                {
                    createOtherAction.Text = SenseNetResourceManager.Current.GetString("Portal", "CreateOtherActionText");
                    actList.Add(createOtherAction);
                }
            }

            // Open in Content Explorer action
            var exa = ActionFramework.GetAction("Explore", context, backUrl, null);

            if (exa != null)
            {
                var ea = new ExploreAction(context);
                ea.Initialize(context, backUrl, null, null);

                actList.Add(ea);
            }

            var app = ApplicationStorage.Instance.GetApplication("Add", context, PortalContext.Current.DeviceName);

            if (app != null)
            {
                new List <string> {
                    "Workspace", "DocumentLibrary", "ItemList"
                }.ForEach(
                    delegate(String contentTypeName)
                {
                    if (!contentTypes.Any(ct => ct.Name == contentTypeName))
                    {
                        return;
                    }

                    var cnt          = ContentType.GetByName(contentTypeName);
                    var name         = ContentTemplate.HasTemplate(contentTypeName) ? ContentTemplate.GetTemplate(contentTypeName).Path : cnt.Name;
                    var addNewAction = app.CreateAction(context, backUrl, new { ContentTypeName = name, backtarget = "newcontent" });
                    if (addNewAction != null)
                    {
                        addNewAction.Text = String.Concat(SenseNetResourceManager.Current.GetString("Portal", "AddNewActionPrefix"), cnt.DisplayName);
                        addNewAction.Icon = cnt.Icon;

                        actList.Add(addNewAction);
                    }
                });
            }

            var notifAction = ActionFramework.GetAction("Notifications", Content.Create(User.Current as Node), backUrl, null);

            if (notifAction != null)
            {
                actList.Add(notifAction);
            }

            actList.AddRange(base.CollectActions(context, backUrl));

            return(actList);
        }