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 = $"{RepositoryStructure.ContentViewFolderName}/{newContent.ContentType.Name}/{"StartWorkflow.ascx"}";
                string resolvedPath;
                if (!SkinManagerBase.TryResolve(viewPath, out resolvedPath))
                {
                    resolvedPath = RepositoryPath.Combine(RepositoryStructure.SkinGlobalFolderPath,
                                                          SkinManagerBase.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));
        }
示例#2
0
        public static string RenderCell(string fieldFullName, string contentListPath)
        {
            if (string.IsNullOrEmpty(fieldFullName))
            {
                return(string.Empty);
            }

            try
            {
                var          bindingName = FieldSetting.GetBindingNameFromFullName(fieldFullName);
                FieldSetting fieldSetting;
                var          pathList = GetCellTemplatePaths(fieldFullName, contentListPath, out fieldSetting);
                if (pathList.Count > 0)
                {
                    // get the template with the system account
                    using (new SystemAccount())
                    {
                        foreach (var templatePath in pathList)
                        {
                            var actualPath = SkinManagerBase.Resolve(templatePath);
                            if (!Node.Exists(actualPath))
                            {
                                continue;
                            }

                            var template = Node.Load <File>(actualPath);
                            if (template == null)
                            {
                                continue;
                            }

                            // replace the template parameters
                            var templateString = RepositoryTools.GetStreamString(template.Binary.GetStream())
                                                 .Replace("@@bindingName@@", bindingName)
                                                 .Replace("@@fullName@@", fieldFullName);

                            if (fieldSetting != null)
                            {
                                templateString = templateString.Replace("@@fieldName@@", fieldSetting.Name);
                            }

                            return(templateString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SnLog.WriteException(ex);
            }

            // default behavior: simple text rendering
            return(string.Format("<%# Eval(\"{0}\") %>", FieldSetting.GetBindingNameFromFullName(fieldFullName)));
        }
示例#3
0
        // ================================================================================= Static API

        public static string GetActionLinkTemplate(string templateName)
        {
            using (new SystemAccount())
            {
                // As this is an SN7 feature, we use TryResolve instead of Resolve because we
                // do not want to look for the path in the Global folder, only under skins.
                string actionTemplatePath;
                if (SkinManagerBase.TryResolve(RepositoryPath.Combine(ACTIONTEMPLATEFOLDERPATH, templateName), out actionTemplatePath))
                {
                    var template = Node.Load <HtmlTemplate>(actionTemplatePath);
                    if (template != null)
                    {
                        return(template.TemplateText);
                    }
                }
            }

            return(string.Empty);
        }
 public Module(ITinyMessengerHub messageHub, ISkinSwitcher skinSwitcher, IResourceManager resourceManager)
 {
     this.messageHub   = messageHub;
     this.skinSwitcher = skinSwitcher;
     this.skinManager  = new ControlLibrarySkinManager(messageHub, resourceManager);
 }
示例#5
0
 public static string GetDefaultGroupAvatarPath()
 {
     return(SkinManagerBase.Resolve("$skin/images/default_groupavatar.png"));
 }