Esempio n. 1
0
        /// <summary>
        /// build a getting-started url which is used to correctly show the user infos like
        /// warnings related to his dnn or 2sxc version
        /// infos based on his languages
        /// redirects based on the app he's looking at, etc.
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        private string IntroductionToAppUrl(IApp app)
        {
            var dnn = PortalSettings.Current;
            var mod = Request.FindModuleInfo();
            //int appId = sxc.AppId.Value;
            var gsUrl = "//gettingstarted.2sxc.org/router.aspx?" // change to use protocoll neutral base URL, also change to 2sxc

                                                                 // Add version & module infos
                        + "DnnVersion=" + Assembly.GetAssembly(typeof(Globals)).GetName().Version.ToString(4)
                        + "&2SexyContentVersion=" + Settings.ModuleVersion
                        + "&ModuleName=" + mod.DesktopModule.ModuleName
                        + "&ModuleId=" + mod.ModuleID
                        + "&PortalID=" + dnn.PortalId
                        + "&ZoneID=" + app.ZoneId
                        + "&DefaultLanguage=" + dnn.DefaultLanguage
                        + "&CurrentLanguage=" + dnn.CultureCode;

            // Add AppStaticName and Version
            if (mod.DesktopModule.ModuleName != "2sxc")
            {
                gsUrl += "&AppGuid=" + app.AppGuid;
                if (app.Configuration != null)
                {
                    gsUrl += "&AppVersion=" + app.Configuration.Version
                             + "&AppOriginalId=" + app.Configuration.OriginalId;
                }
            }

            var hostSettings = HostController.Instance.GetSettingsDictionary();

            gsUrl += hostSettings.ContainsKey("GUID") ? "&DnnGUID=" + hostSettings["GUID"] : "";
            return(gsUrl);
        }
Esempio n. 2
0
 public AppAssetsBackend Init(IApp app, IUser user, ILog parentLog)
 {
     Log.LinkTo(parentLog);
     _app  = app;
     _user = user;
     return(this);
 }
Esempio n. 3
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. 4
0
        // note: not sure yet where the best place for this method is, so it's here for now
        // will probably move again some day
        internal static LookUpEngine GetConfigProviderForModule(int moduleId, IApp app, IBlockBuilder blockBuilder)
        {
            var log = new Log("Stc.GetCnf", blockBuilder?.Log);

            // Find the standard DNN property sources if PortalSettings object is available (changed 2018-03-05)
            var dnnLookUps = Factory.Resolve <IGetEngine>().GetEngine(moduleId, blockBuilder?.Log);

            log.Add($"Environment provided {dnnLookUps.Sources.Count} sources");

            var provider = new LookUpEngine(dnnLookUps, blockBuilder?.Log);

            // only add these in running inside an http-context. Otherwise leave them away!
            if (HttpContext.Current != null)
            {
                log.Add("Found HttpContext, will ty to add params for querystring, server etc.");
                var request = HttpContext.Current.Request;

                // new
                var paramList = new NameValueCollection();
                if (blockBuilder?.Parameters != null)
                {
                    foreach (var pair in blockBuilder.Parameters)
                    {
                        paramList.Add(pair.Key, pair.Value);
                    }
                }
                else
                {
                    paramList = request.QueryString;
                }
                provider.Add(new LookUpInNameValueCollection("querystring", paramList));

                // old
                provider.Add(new LookUpInNameValueCollection("server", request.ServerVariables));
                provider.Add(new LookUpInNameValueCollection("form", request.Form));
            }
            else
            {
                log.Add("No HttpContext found, won't add http params to look-up");
            }


            provider.Add(new LookUpInAppProperty("app", app));

            // add module if it was not already added previously
            if (!provider.HasSource("module"))
            {
                var modulePropertyAccess = new LookUpInDictionary("module");
                modulePropertyAccess.Properties.Add("ModuleID", moduleId.ToString(CultureInfo.InvariantCulture));
                provider.Add(modulePropertyAccess);
            }

            // provide the current SxcInstance to the children where necessary
            if (!provider.HasSource(LookUpConstants.InstanceContext) && blockBuilder != null)
            {
                var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, blockBuilder);
                provider.Add(blockBuilderLookUp);
            }
            return(provider);
        }
Esempio n. 5
0
 protected override void PrepCore(IApp app, Guid entityGuid, string fieldName, bool usePortalRoot)
 {
     Log.Add("PrepCore(...)");
     AdamAppContext = new AdamAppContext <TFolderId, TFileId>();
     AdamAppContext.Init(Permissions.Context.Tenant, app, Block, 10, Log);
     ContainerContext = usePortalRoot
         ? new AdamOfTenant <TFolderId, TFileId>(AdamAppContext) as AdamOfBase <TFolderId, TFileId>
         : new AdamOfField <TFolderId, TFileId>(AdamAppContext, entityGuid, fieldName);
 }
Esempio n. 6
0
 public AdamAppContext(ITenant tenant, IApp app, IBlockBuilder blockBuilder, int compatibility, ILog parentLog) : base("Adm.ApCntx", parentLog, "starting")
 {
     Tenant             = tenant;
     _app               = app;
     AppRuntime         = new AppRuntime(app, blockBuilder?.UserMayEdit ?? false, null);
     BlockBuilder       = blockBuilder;
     CompatibilityLevel = compatibility;
     EnvironmentFs      = Factory.Resolve <IEnvironmentFileSystem>();
 }
Esempio n. 7
0
 public virtual AdamAppContext Init(ITenant tenant, IApp app, IBlock block, int compatibility, ILog parentLog)
 {
     Log.LinkTo(parentLog);
     Tenant             = tenant;
     _app               = app;
     Block              = block;
     AppRuntime         = new AppRuntime(app, block?.EditAllowed ?? false, null);
     CompatibilityLevel = compatibility;
     return(this);
 }
Esempio n. 8
0
        private void PrepCore(IApp app, Guid entityGuid, string fieldName, bool usePortalRoot)
        {
            Log.Add("PrepCore(...)");
            var dnn    = new DnnContext(BlockBuilder?.Container);
            var tenant = new DnnTenant(dnn.Portal);

            AdamAppContext   = new AdamAppContext(tenant, app, BlockBuilder, 10, Log);
            ContainerContext = usePortalRoot
                ? new ContainerOfTenant(AdamAppContext) as ContainerBase
                : new ContainerOfField(AdamAppContext, entityGuid, fieldName);
        }
Esempio n. 9
0
        protected MultiPermissionsApp(IBlockBuilder blockBuilder, int zoneId, int appId, ILog parentLog)
            : base("Api.Perms", parentLog)
        {
            var wrapLog = Log.Call($"..., appId: {appId}, ...");

            BlockBuilder = blockBuilder;
            var tenant        = new DnnTenant(PortalSettings.Current);
            var environment   = Factory.Resolve <IEnvironmentFactory>().Environment(Log);
            var contextZoneId = environment.ZoneMapper.GetZoneId(tenant.Id);

            App = new App(tenant, zoneId, appId,
                          ConfigurationProvider.Build(blockBuilder, true),
                          false, Log);
            SamePortal             = contextZoneId == zoneId;
            PortalForSecurityCheck = SamePortal ? PortalSettings.Current : null;
            wrapLog($"ready for z/a:{zoneId}/{appId} t/z:{tenant.Id}/{contextZoneId} same:{SamePortal}");
        }
Esempio n. 10
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. 11
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();
        }
Esempio n. 12
0
 internal void LateAttachApp(IApp app) => App = app;
Esempio n. 13
0
        // note: not sure yet where the best place for this method is, so it's here for now
        // will probably move again some day
        internal LookUpEngine GetConfigProviderForModule(IContextOfSite context, IApp appForLookup, IBlock blockForLookup)
        {
            var modId = (context as ContextOfBlock)?.Module.Id ?? 0;

            var wrapLog = Log.Call <LookUpEngine>($"{modId}, ..., ...");


            // Find the standard DNN property sources if PortalSettings object is available
            var envLookups = _getEngineLazy.Value.Init(Log).GetLookUpEngine(modId);

            Log.Add($"Environment provided {envLookups.Sources.Count} sources");

            var provider = new LookUpEngine(envLookups, Log);

            // Add QueryString etc. when running inside an http-context. Otherwise leave them away!
            var http = _httpLazy.Value;

            if (http.Current != null)
            {
                Log.Add("Found Http-Context, will ty to add params for querystring, server etc.");

                // new
                var paramList   = new NameValueCollection();
                var ctxWithPage = context as IContextOfBlock;
                if (ctxWithPage?.Page.Parameters != null)
                {
                    foreach (var pair in ctxWithPage.Page.Parameters)
                    {
                        paramList.Add(pair.Key, pair.Value);
                    }
                }
                else
                {
                    paramList = http.QueryStringParams;
                }
                provider.Add(new LookUpInNameValueCollection("querystring", paramList));

                // old
#if NET451
                provider.Add(new LookUpInNameValueCollection("server", http.Request.ServerVariables));
                provider.Add(new LookUpInNameValueCollection("form", http.Request.Form));
#else
                // "Not Yet Implemented in .net standard #TodoNetStandard" - might not actually support this
#endif
            }
            else
            {
                Log.Add("No Http-Context found, won't add http params to look-up");
            }


            provider.Add(new LookUpInAppProperty("app", appForLookup));

            // add module if it was not already added previously
            if (!provider.HasSource(CmsBlock.InstanceLookupName))
            {
                var modulePropertyAccess = new LookUpInDictionary(CmsBlock.InstanceLookupName);
                modulePropertyAccess.Properties.Add(CmsBlock.InstanceIdKey, modId.ToString(CultureInfo.InvariantCulture));
                provider.Add(modulePropertyAccess);
            }

            // provide the current SxcInstance to the children where necessary
            if (!provider.HasSource(LookUpConstants.InstanceContext) && blockForLookup != null)
            {
                var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, blockForLookup);
                provider.Add(blockBuilderLookUp);
            }
            return(wrapLog("ok", provider));
        }
Esempio n. 14
0
        // note: not sure yet where the best place for this method is, so it's here for now
        // will probably move again some day
        internal static LookUpEngine GetConfigProviderForModule(int moduleId, IApp app, IBlock block)
        {
            var log = new Log("Stc.GetCnf", block?.Log);

            // Find the standard DNN property sources if PortalSettings object is available
            var envLookups = Factory.Resolve <IGetEngine>().GetEngine(moduleId, block?.Log);

            log.Add($"Environment provided {envLookups.Sources.Count} sources");

            var provider = new LookUpEngine(envLookups, block?.Log);

            // Add QueryString etc. when running inside an http-context. Otherwise leave them away!
            var http = Factory.Resolve <IHttp>();

            if (http.Current != null)
            {
                log.Add("Found Http-Context, will ty to add params for querystring, server etc.");

                // new
                var paramList = new NameValueCollection();
                if (block?.Context.Page.Parameters != null)
                {
                    foreach (var pair in block.Context.Page.Parameters)
                    {
                        paramList.Add(pair.Key, pair.Value);
                    }
                }
                else
                {
                    paramList = http.QueryString;
                }
                provider.Add(new LookUpInNameValueCollection("querystring", paramList));

                // old
#if NET451
                provider.Add(new LookUpInNameValueCollection("server", http.Request.ServerVariables));
                provider.Add(new LookUpInNameValueCollection("form", http.Request.Form));
#else
                // "Not Yet Implemented in .net standard #TodoNetStandard" - might not actually support this
#endif
            }
            else
            {
                log.Add("No Http-Context found, won't add http params to look-up");
            }


            provider.Add(new LookUpInAppProperty("app", app));

            // add module if it was not already added previously
            if (!provider.HasSource(CmsBlock.InstanceLookupName /* "module"*/))
            {
                var modulePropertyAccess = new LookUpInDictionary(CmsBlock.InstanceLookupName /*"module"*/);
                modulePropertyAccess.Properties.Add(CmsBlock.InstanceIdKey /*"ModuleID"*/, moduleId.ToString(CultureInfo.InvariantCulture));
                provider.Add(modulePropertyAccess);
            }

            // provide the current SxcInstance to the children where necessary
            if (!provider.HasSource(LookUpConstants.InstanceContext) && block != null)
            {
                var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, block);
                provider.Add(blockBuilderLookUp);
            }
            return(provider);
        }