private static void FilterWithRequiredPermissions(IEnumerable <ActionBase> actions, Content context) { foreach (var action in actions) { ActionFramework.CheckRequiredPermissions(action, context); } }
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 viewContent = Content.Create(view); 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 = viewContent.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); }
private static Dictionary <string, object> GetParameters(string parameters) { return(ActionFramework.ParseParameters(parameters)); }
protected virtual IEnumerable <ActionBase> CollectActions(Content context, string backUrl) { //customize action list in derived classes return(ActionFramework.GetActionsFromContentRepository(context, this.Name, backUrl)); }
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 == null ? new List <ContentType>() : gc.GetAllowedChildTypes().ToList(); 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.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(ResourceManager.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 = ResourceManager.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); }