Example #1
0
        protected virtual void AddXsltParameters(System.Xml.Xsl.XsltArgumentList argumentList)
        {
            var currentList = ContentList.GetContentListByParentWalk(this);
            var listPath    = currentList == null ? string.Empty : currentList.Path;

            argumentList.AddParam("listPath", "", listPath);
        }
Example #2
0
        //========================================================================================= Helper methods

        private static void AddContentListField(ContentRepository.Content content)
        {
            if (content == null)
            {
                return;
            }

            var contentList = ContentList.GetContentListByParentWalk(content.ContentHandler);

            if (contentList == null)
            {
                return;
            }

            //build longtext field for custom status messages
            var fs = new LongTextFieldSetting
            {
                ShortName = "LongText",
                Name      =
                    "#" + ContentNamingHelper.GetNameFromDisplayName(content.Name, content.DisplayName) +
                    "_status",
                DisplayName = content.DisplayName + " status",
                Icon        = content.Icon
            };

            contentList.AddOrUpdateField(fs);
        }
Example #3
0
        public void SetAsDefault()
        {
            var clist = ContentList.GetContentListByParentWalk(this);

            clist.DefaultView = this.Name;
            clist.Save();
        }
Example #4
0
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            this.IncludeBackUrl = true;

            var clv = context.ContentHandler as ViewBase;

            if (clv == null)
            {
                this.Forbidden = true;
                return;
            }

            var cl = ContentList.GetContentListByParentWalk(clv);

            if (cl == null)
            {
                this.Forbidden = true;
                return;
            }

            if (string.IsNullOrEmpty(cl.DefaultView))
            {
                return;
            }

            // if this view is the default, the action is meaningless
            if (string.Compare(cl.DefaultView, context.Name, StringComparison.InvariantCulture) == 0)
            {
                this.Forbidden = true;
            }
        }
        protected virtual void ValidateWorkflow()
        {
            if (this.ContentView?.Content == null)
            {
                return;
            }

            var workflow = this.ContentView.Content.ContentHandler as WorkflowHandlerBase;
            var refNode  = workflow?.RelatedContent;

            if (refNode == null)
            {
                return;
            }

            var contentList = ContentList.GetContentListByParentWalk(this.ContextNode);

            if (contentList == null)
            {
                return;
            }

            if (!workflow.Path.StartsWith(RepositoryPath.Combine(contentList.Path, "Workflows") + "/"))
            {
                throw new InvalidOperationException(string.Format("Workflow must be under the list ({0})",
                                                                  workflow.Path));
            }

            if (!refNode.Path.StartsWith(contentList.Path + "/"))
            {
                throw new InvalidOperationException(string.Format("Related content must be in the list ({0})",
                                                                  refNode.Path));
            }
        }
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            if (context == null)
            {
                this.Visible = false;
                return;
            }

            // if the Views folder does not exist, we have to create it
            // (but only in case of a content list)
            var cl = ContentList.GetContentListByParentWalk(context.ContentHandler);

            if (cl != null)
            {
                var viewsFolderPath = RepositoryPath.Combine(cl.Path, ViewManager.VIEWSFOLDERNAME);
                if (!Node.Exists(viewsFolderPath))
                {
                    using (new SystemAccount())
                    {
                        RepositoryTools.CreateStructure(viewsFolderPath, "SystemFolder");
                    }
                }
            }
        }
Example #7
0
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            var clv = context.ContentHandler as Portal.UI.ContentListViews.Handlers.ViewBase;

            if (clv == null)
            {
                this.Forbidden = true;
                return;
            }

            var cl = ContentList.GetContentListByParentWalk(clv);

            if (cl == null)
            {
                this.Forbidden = true;
                return;
            }

            if (string.IsNullOrEmpty(cl.DefaultView))
            {
                return;
            }

            //if this view is the default, the action is meaningless
            if (cl.DefaultView.CompareTo(context.Name) == 0)
            {
                this.Forbidden = true;
            }
        }
Example #8
0
        protected override ContentView GetContentView(Content newContent)
        {
            if (!string.IsNullOrEmpty(ContentViewPath))
            {
                return(base.GetContentView(newContent));
            }

            var contentList = ContentList.GetContentListByParentWalk(GetContextNode());

            if (contentList != null)
            {
                //try to find a content view at /Root/.../MyList/WorkflowTemplates/MyWorkflow.ascx
                var wfTemplatesPath = RepositoryPath.Combine(contentList.Path, "WorkflowTemplates");
                var viewPath        = RepositoryPath.Combine(wfTemplatesPath, newContent.Name + ".ascx");

                if (Node.Exists(viewPath))
                {
                    return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath));
                }

                //try to find it by type name, still locally
                viewPath = RepositoryPath.Combine(wfTemplatesPath, newContent.ContentType.Name + ".ascx");

                if (Node.Exists(viewPath))
                {
                    return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath));
                }

                //last attempt: global view for the workflow type
                return(ContentView.Create(newContent, Page, ViewMode.InlineNew, "StartWorkflow.ascx"));
            }
            else
            {
                var viewPath     = string.Format("{0}/{1}/{2}", Repository.ContentViewFolderName, newContent.ContentType.Name, "StartWorkflow.ascx");
                var resolvedPath = string.Empty;
                if (!SkinManager.TryResolve(viewPath, out resolvedPath))
                {
                    resolvedPath = RepositoryPath.Combine(Repository.SkinGlobalFolderPath,
                                                          SkinManager.TrimSkinPrefix(viewPath));

                    if (!Node.Exists(resolvedPath))
                    {
                        resolvedPath = string.Empty;
                    }
                }

                if (!string.IsNullOrEmpty(resolvedPath))
                {
                    return(ContentView.Create(newContent, Page, ViewMode.InlineNew, resolvedPath));
                }
            }

            return(base.GetContentView(newContent));
        }
Example #9
0
        public static string GetColumnTitle(string fieldFullName, Node contextNode)
        {
            ContentList cl = null;

            if (contextNode != null)
            {
                cl = ContentList.GetContentListForNode(contextNode) ??
                     ContentList.GetContentListByParentWalk(contextNode);
            }

            return(GetColumnTitle(fieldFullName, cl != null ? cl.Path : string.Empty));
        }
Example #10
0
        protected override void OnModified(object sender, ContentRepository.Storage.Events.NodeEventArgs e)
        {
            base.OnModified(sender, e);

            var cdName = e.ChangedData.FirstOrDefault(cd => cd.Name == "Name");

            if (cdName != null)
            {
                var cl = ContentList.GetContentListByParentWalk(this);
                if (cl != null && !string.IsNullOrEmpty(cl.DefaultView) && cl.DefaultView.CompareTo(cdName.Original) == 0)
                {
                    cl.DefaultView = this.Name;
                    cl.Save(SavingMode.KeepVersion);
                }
            }
        }
Example #11
0
        protected virtual Node GetBindingRoot()
        {
            if (BindTarget != null)
            {
                var value = (SenseNet.Portal.UI.PortletFramework.BindTarget)Enum.Parse(typeof(SenseNet.Portal.UI.PortletFramework.BindTarget), BindTarget);
                switch (value)
                {
                case SenseNet.Portal.UI.PortletFramework.BindTarget.Unselected:
                    return(Content.CreateNew("Folder", Repository.Root, "DummyNode").ContentHandler);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentSite:
                    //return PortalContext.Current.Site;
                    return(SenseNet.Portal.Site.GetSiteByNode(PortalContext.Current.ContextNode));

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentPage:
                    return(PortalContext.Current.Page);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentUser:
                    return(HttpContext.Current.User.Identity as User);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CustomRoot:
                    return(Node.LoadNode(this.CustomRootPath));

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentStartPage:
                    return(PortalContext.Current.Site.StartPage as Node ?? PortalContext.Current.Site as Node);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.Breadcrumb:
                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentContent:
                    return(PortalContext.Current.ContextNode ?? Repository.Root);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentWorkspace:
                    return((Node)PortalContext.Current.ContextWorkspace ?? PortalContext.Current.Site);

                case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentList:
                    return(ContentList.GetContentListByParentWalk(PortalContext.Current.ContextNode));

                default:
                    throw new NotImplementedException(BindTarget.ToString());
                }
            }
            else
            {
                return(PortalContext.Current.ContextNode ?? Repository.Root);
            }
        }
Example #12
0
        public override object Execute(Content content, params object[] parameters)
        {
            var ctxView = content?.ContentHandler as ViewBase;

            if (ctxView != null)
            {
                var list = ContentList.GetContentListByParentWalk(ctxView);
                if (list != null)
                {
                    list.DefaultView = ctxView.Name;
                    list.Save(SavingMode.KeepVersion);
                }
            }

            var backUrl = PortalContext.Current.BackUrl;
            var back    = string.IsNullOrWhiteSpace(backUrl) ? "/" : backUrl;

            HttpContext.Current.Response.Redirect(back, true);
            return(null);
        }
Example #13
0
        protected override IEnumerable <ActionBase> CollectActions(Content context, string backUrl)
        {
            var actList = new List <ActionBase>();

            _collectedViews = new List <int>();

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

            var list         = context.ContentHandler as ContentList;
            var hash         = ViewFrame.GetHashCode(context.Path, PortletId);
            var selectedView = string.IsNullOrEmpty(hash) ? string.Empty : ViewFrame.GetSelectedView(hash) ?? (DefaultView ?? string.Empty);

            if (string.IsNullOrEmpty(selectedView) && list != null)
            {
                selectedView = list.DefaultView ?? string.Empty;
            }

            if (!string.IsNullOrEmpty(DefaultView) && DefaultView.StartsWith("/Root/"))
            {
                var view = Node.Load <File>(DefaultView);
                if (view != null && !_collectedViews.Contains(view.Id))
                {
                    _collectedViews.Add(view.Id);
                    var act = GetServiceAction(context, view, true, PortletId, selectedView, backUrl);
                    if (act != null)
                    {
                        actList.Add(act);
                    }
                }
            }

            foreach (var view in ViewManager.GetViewsForContainer(context.ContentHandler))
            {
                if (_collectedViews.Contains(view.Id))
                {
                    continue;
                }

                _collectedViews.Add(view.Id);

                //add local views with only name
                var act = GetServiceAction(context, view, false, PortletId, selectedView, backUrl);
                if (act != null)
                {
                    actList.Add(act);
                }
            }

            var contentList = ContentList.GetContentListByParentWalk(context.ContentHandler);

            if (contentList != null)
            {
                foreach (var view in contentList.AvailableViews)
                {
                    if (_collectedViews.Contains(view.Id))
                    {
                        continue;
                    }

                    _collectedViews.Add(view.Id);

                    //add global views with full path
                    var act = GetServiceAction(context, view, true, PortletId, selectedView, backUrl);
                    if (act != null)
                    {
                        actList.Add(act);
                    }
                }
            }

            return(actList);
        }