Esempio n. 1
0
        public void Init(Template template, App app, ModuleInfo hostingModule, IDataSource dataSource, InstancePurposes instancePurposes, SxcInstance sexy)
        {
            var templatePath = VirtualPathUtility.Combine(Internal.TemplateManager.GetTemplatePathRoot(template.Location, app) + "/", template.Path);

            // Throw Exception if Template does not exist
            if (!File.Exists(HostingEnvironment.MapPath(templatePath)))
                // todo: rendering exception
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");

            Template = template;
            TemplatePath = templatePath;
            App = app;
            ModuleInfo = hostingModule;
            DataSource = dataSource;
            InstancePurposes = instancePurposes;
            Sexy = sexy;

            // check common errors
            CheckExpectedTemplateErrors();

            // check access permissions - before initializing or running data-code in the template
            CheckTemplatePermissions(sexy.AppPortalSettings);

            // Run engine-internal init stuff
            Init();

            // call engine internal feature to optionally change what data is actually used or prepared for search...
            CustomizeData();

            // check if rendering is possible, or throw exceptions...
            CheckExpectedNoRenderConditions();

            if(PreRenderStatus == RenderStatusType.Unknown)
                PreRenderStatus = RenderStatusType.Ok;
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void Init(IBlock block, Purpose purpose, ILog parentLog)
        {
            Block = block;
            var view = Block.View;

            Log.LinkTo(parentLog);

            var root         = Helpers.TemplateHelpers.Init(Block.App, Log).AppPathRoot(view.IsShared, PathTypes.PhysRelative);
            var subPath      = view.Path;
            var templatePath = TryToFindPolymorphPath(root, view, subPath)
                               ?? Helpers.LinkPaths.ToAbsolute(root + "/", subPath);

            // Throw Exception if Template does not exist
            if (!File.Exists(Helpers.ServerPaths.FullAppPath(templatePath)))
            {
                // todo: change to some kind of "rendering exception"
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");
            }

            Template     = view;
            TemplatePath = templatePath;
            App          = Block.App;
            DataSource   = Block.Data;
            Purpose      = purpose;

            // check common errors
            CheckExpectedTemplateErrors();

            // check access permissions - before initializing or running data-code in the template
            CheckTemplatePermissions(Block.Context.User);

            // Run engine-internal init stuff
            Init();
        }
Esempio n. 3
0
        public void Init(Template template, App app, ModuleInfo hostingModule, IDataSource dataSource, InstancePurposes instancePurposes, SexyContent sexy)
        {
            var templatePath = VirtualPathUtility.Combine(SexyContent.GetTemplatePathRoot(template.Location, app) + "/", template.Path);

            // Throw Exception if Template does not exist
            if (!File.Exists(HostingEnvironment.MapPath(templatePath)))
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");

            Template = template;
            TemplatePath = templatePath;
            App = app;
            ModuleInfo = hostingModule;
            DataSource = dataSource;
            InstancePurposes = instancePurposes;
            Sexy = sexy;

            Init();
        }
Esempio n. 4
0
        /// <inheritdoc />
        public void Init(IBlockBuilder blockBuilder, Purpose purpose, ILog parentLog)
        {
            BlockBuilder = blockBuilder;
            var view = BlockBuilder.View;

            Log.LinkTo(parentLog);


            var    root         = TemplateHelpers.GetTemplatePathRoot(view.Location, blockBuilder.App);
            var    subPath      = view.Path;
            string templatePath = null;

            if (enablePolymorphism)
            {
                templatePath = TryToFindPolymorphPath(root, view, subPath);
            }

            if (templatePath == null)
            {
                templatePath = VirtualPathUtility.Combine(root + "/", subPath);
            }

            // Throw Exception if Template does not exist
            if (!File.Exists(HostingEnvironment.MapPath(templatePath)))
            {
                // todo: change to some kind of "rendering exception"
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");
            }

            Template     = view;
            TemplatePath = templatePath;
            App          = blockBuilder.App;
            DataSource   = blockBuilder.Block.Data;
            Purpose      = purpose;

            // check common errors
            CheckExpectedTemplateErrors();

            // check access permissions - before initializing or running data-code in the template
            CheckTemplatePermissions(blockBuilder.Block.Tenant);

            // Run engine-internal init stuff
            Init();
        }
Esempio n. 5
0
        public void Init(Template template, App app, ModuleInfo hostingModule, IDataSource dataSource, InstancePurposes instancePurposes, SexyContent sexy)
        {
            var templatePath = VirtualPathUtility.Combine(SexyContent.GetTemplatePathRoot(template.Location, app) + "/", template.Path);

            // Throw Exception if Template does not exist
            if (!System.IO.File.Exists(HostingEnvironment.MapPath(templatePath)))
            {
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");
            }

            Template         = template;
            TemplatePath     = templatePath;
            App              = app;
            ModuleInfo       = hostingModule;
            DataSource       = dataSource;
            InstancePurposes = instancePurposes;
            Sexy             = sexy;

            this.Init();
        }
Esempio n. 6
0
        public void Init(Template template, App app, IInstanceInfo hostingModule, IDataSource dataSource, InstancePurposes instancePurposes, SxcInstance sxcInstance, Log parentLog)
        {
            var templatePath = VirtualPathUtility.Combine(Internal.TemplateHelpers.GetTemplatePathRoot(template.Location, app) + "/", template.Path);

            Log = new Log("Htm.RendEn", parentLog);

            // Throw Exception if Template does not exist
            if (!File.Exists(HostingEnvironment.MapPath(templatePath)))
            {
                // todo: change to some kind of "rendering exception"
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");
            }

            Template         = template;
            TemplatePath     = templatePath;
            App              = app;
            InstInfo         = hostingModule;
            DataSource       = dataSource;
            InstancePurposes = instancePurposes;
            Sexy             = sxcInstance;

            // check common errors
            CheckExpectedTemplateErrors();

            // check access permissions - before initializing or running data-code in the template
            CheckTemplatePermissions(sxcInstance.Tenant);

            // Run engine-internal init stuff
            Init();

            // call engine internal feature to optionally change what data is actually used or prepared for search...
            CustomizeData();

            // check if rendering is possible, or throw exceptions...
            CheckExpectedNoRenderConditions();

            if (PreRenderStatus == RenderStatusType.Unknown)
            {
                PreRenderStatus = RenderStatusType.Ok;
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        public void Init(IBlock block, Purpose purpose, ILog parentLog)
        {
            //BlockBuilder = blockBuilder;
            Block = block;
            var view = Block.View;

            Log.LinkTo(parentLog);


            var root         = TemplateHelpers.GetTemplatePathRoot(view.Location, Block.App);
            var subPath      = view.Path;
            var templatePath = TryToFindPolymorphPath(root, view, subPath)
                               ?? Http.Combine(root + "/", subPath);

            // Throw Exception if Template does not exist
            if (!File.Exists(Http.MapPath(templatePath)))
            {
                // todo: change to some kind of "rendering exception"
                throw new SexyContentException("The template file '" + templatePath + "' does not exist.");
            }

            Template     = view;
            TemplatePath = templatePath;
            App          = Block.App;
            DataSource   = Block.Data;
            Purpose      = purpose;

            // check common errors
            CheckExpectedTemplateErrors();

            // check access permissions - before initializing or running data-code in the template
            CheckTemplatePermissions(Block.Context.Tenant);

            // Run engine-internal init stuff
            Init();
        }