internal void CreateNewWorkspace()
        {
            try
            {
                var state          = WizardState;
                var newName        = state.WorkspaceNewName;
                var sourceNodePath = state.SelectedWorkspacePath;
                var targetNode     = PortalContext.Current.ContextNodeHead ?? NodeHead.Get(TargetPath);

                var sourceNode      = Node.LoadNode(sourceNodePath);
                var contentTypeName = sourceNode.Name;


                Content workspace = null;

                workspace = ContentTemplate.HasTemplate(contentTypeName)
                    ? ContentTemplate.CreateTemplated(Node.LoadNode(targetNode.Id), ContentTemplate.GetTemplate(contentTypeName), newName)
                    : Content.CreateNew(contentTypeName, Node.LoadNode(targetNode.Id), newName);

                workspace.Fields["Description"].SetData(state.WorkspaceNewDescription);
                workspace.Save();

                var newPath = new StringBuilder(PortalContext.Current.OriginalUri.GetLeftPart(UriPartial.Authority)).Append(targetNode.Path).Append("/").Append(newName);
                NewWorkspaceLink.HRef = newPath.ToString();
            }
            catch (Exception exc) //logged
            {
                Logger.WriteException(exc);
                HasError = true;
                ErrorMessageControl.Visible = true;
                ErrorMessageControl.Text    = exc.Message;
                // log exception
            }
        }
        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);
        }