Exemplo n.º 1
0
        private static void AfterMap(IMedia media, MediaItemDisplay display)
        {
            //map the tree node url
            if (HttpContext.Current != null)
            {
                var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));
                var url = urlHelper.GetUmbracoApiService<MediaTreeController>(controller => controller.GetTreeNode(display.Id.ToString(), null));
                display.TreeNodeUrl = url;
            }
            
            if (media.ContentType.IsContainer)
            {
                TabsAndPropertiesResolver.AddContainerView(display, "media");
            }

            TabsAndPropertiesResolver.MapGenericProperties(media, display);
        }
        private void ServerVariablesParserOnParsing(object sender, Dictionary<string, object> e) {

            // Create a new UrlHelper (can we grab the one from the DashboardContext?)
            UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext);

            // Get the default service URL
            string serviceUrl = url.GetUmbracoApiService<DashboardController>("ActionName").TrimEnd("ActionName");

            // Hijack/replace Umbraco's default dashboard controller
            Dictionary<string, object> umbracoUrls = e["umbracoUrls"] as Dictionary<string, object>;
            if (umbracoUrls != null) umbracoUrls["dashboardApiBaseUrl"] = serviceUrl;

            // Add our own server variables for the dashboard
            e.Add("SkybrudDashboard", new {
                serviceUrl
            });

        }
        /// <summary>
        /// Adds server variables for use by the JavaScript.
        /// </summary>
        private void AddServerVariables(object sender,
            Dictionary<string, object> e)
        {

            // Variables.
            var httpContext = new HttpContextWrapper(HttpContext.Current);
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext, routeData);
            var helper = new UrlHelper(requestContext);
            var key = Constants.PackageNameCamelCase;


            // Add server variables.
            e.Add(key, new Dictionary<string, string>()
            {
                { "DeleteForm",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.DeleteForm(null)) },
                { "PersistForm",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.PersistForm(null)) },
                { "GetFormInfo",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.GetFormInfo(null)) },
                { "DeleteLayout",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.DeleteLayout(null)) },
                { "PersistLayout",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.PersistLayout(null)) },
                { "GetLayoutInfo",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.GetLayoutInfo(null)) },
                { "DeleteValidation",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.DeleteValidation(null)) },
                { "PersistValidation",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.PersistValidation(null)) },
                { "GetValidationInfo",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.GetValidationInfo(null)) },
                { "GetValidationsInfo",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.GetValidationsInfo(null)) },
                { "PersistFolder",
                    helper.GetUmbracoApiService<FoldersController>(x =>
                        x.PersistFolder(null)) },
                { "GetFieldTypes",
                    helper.GetUmbracoApiService<FieldsController>(x =>
                        x.GetFieldTypes()) },
                { "PermitAccess",
                    helper.GetUmbracoApiService<SetupController>(x =>
                        x.PermitAccessToFormulate()) },
                { "GetEntityChildren",
                    helper.GetUmbracoApiService<EntitiesController>(x =>
                        x.GetEntityChildren(null)) },
                { "GetEntity",
                    helper.GetUmbracoApiService<EntitiesController>(x =>
                        x.GetEntity(null)) },
                { "EditLayoutBase", "/formulate/formulate/editLayout/" },
                { "EditValidationBase",
                    "/formulate/formulate/editValidation/" },
                { "Validation.RootId", ValidationConstants.Id }
            });

        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines if the authentication ticket should be renewed with a new timeout
        /// </summary>
        /// <param name="url"></param>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        /// <remarks>
        /// We do not want to renew the ticket when we are checking for the user's remaining timeout unless -
        /// UmbracoConfig.For.UmbracoSettings().Security.KeepUserLoggedIn == true
        /// </remarks>
        internal static bool ShouldIgnoreTicketRenew(Uri url, HttpContextBase httpContext)
        {
            //this setting will renew the ticket for all requests.
            if (UmbracoConfig.For.UmbracoSettings().Security.KeepUserLoggedIn)
            {
                return false;
            }

            //initialize the ignore ticket urls - we don't need to lock this, it's concurrent and a hashset
            // we don't want to have to gen the url each request so this will speed things up a teeny bit.
            if (IgnoreTicketRenewUrls.Any() == false)
            {                
                var urlHelper = new UrlHelper(new RequestContext(httpContext, new RouteData()));
                var checkSessionUrl = urlHelper.GetUmbracoApiService<AuthenticationController>(controller => controller.GetRemainingTimeoutSeconds());
                IgnoreTicketRenewUrls.Add(checkSessionUrl);
            }

            if (IgnoreTicketRenewUrls.Any(x => url.AbsolutePath.StartsWith(x)))
            {
                return true;
            }

            return false;            
        }
        /// <summary>
        /// Adds server variables for use by the JavaScript.
        /// </summary>
        private void AddServerVariables(object sender,
            Dictionary<string, object> e)
        {
            // Variables.
            var httpContext = new HttpContextWrapper(HttpContext.Current);
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext, routeData);
            var helper = new UrlHelper(requestContext);
            var key = Constants.PackageNameCamelCase;

            // Add server variables.
            e.Add(key, new Dictionary<string, string>()
            {
                { "DeleteForm",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.DeleteForm(null)) },
                { "PersistForm",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.PersistForm(null)) },
                { "GetFormInfo",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.GetFormInfo(null)) },
                { "MoveForm",
                    helper.GetUmbracoApiService<FormsController>(x =>
                        x.MoveForm(null)) },
                { "DeleteConfiguredForm",
                    helper.GetUmbracoApiService<ConfiguredFormsController>(x =>
                        x.DeleteConfiguredForm(null)) },
                { "PersistConfiguredForm",
                    helper.GetUmbracoApiService<ConfiguredFormsController>(x =>
                        x.PersistConfiguredForm(null)) },
                { "GetConfiguredFormInfo",
                    helper.GetUmbracoApiService<ConfiguredFormsController>(x =>
                        x.GetConfiguredFormInfo(null)) },
                { "DeleteLayout",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.DeleteLayout(null)) },
                { "PersistLayout",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.PersistLayout(null)) },
                { "GetLayoutInfo",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.GetLayoutInfo(null)) },
                { "GetLayoutKinds",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.GetLayoutKinds()) },
                { "MoveLayout",
                    helper.GetUmbracoApiService<LayoutsController>(x =>
                        x.MoveLayout(null)) },
                { "DeleteValidation",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.DeleteValidation(null)) },
                { "PersistValidation",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.PersistValidation(null)) },
                { "GetValidationInfo",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.GetValidationInfo(null)) },
                { "GetValidationsInfo",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.GetValidationsInfo(null)) },
                { "GetValidationKinds",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.GetValidationKinds()) },
                { "MoveValidation",
                    helper.GetUmbracoApiService<ValidationsController>(x =>
                        x.MoveValidation(null)) },
                { "DeleteDataValue",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.DeleteDataValue(null)) },
                { "PersistDataValue",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.PersistDataValue(null)) },
                { "GetDataValueInfo",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.GetDataValueInfo(null)) },
                { "GetDataValuesInfo",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.GetDataValuesInfo(null)) },
                { "GetDataValueKinds",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.GetDataValueKinds()) },
                { "GetDataValueSuppliers",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.GetDataValueSuppliers()) },
                { "MoveDataValue",
                    helper.GetUmbracoApiService<DataValuesController>(x =>
                        x.MoveDataValue(null)) },
                { "PersistFolder",
                    helper.GetUmbracoApiService<FoldersController>(x =>
                        x.PersistFolder(null)) },
                { "GetFolderInfo",
                    helper.GetUmbracoApiService<FoldersController>(x =>
                        x.GetFolderInfo(null)) },
                { "MoveFolder",
                    helper.GetUmbracoApiService<FoldersController>(x =>
                        x.MoveFolder(null)) },
                { "DeleteFolder",
                    helper.GetUmbracoApiService<FoldersController>(x =>
                        x.DeleteFolder(null)) },
                { "GetFieldTypes",
                    helper.GetUmbracoApiService<FieldsController>(x =>
                        x.GetFieldTypes()) },
                { "GetButtonKinds",
                    helper.GetUmbracoApiService<FieldsController>(x =>
                        x.GetButtonKinds()) },
                { "GetHandlerTypes",
                    helper.GetUmbracoApiService<HandlersController>(x =>
                        x.GetHandlerTypes()) },
                { "GetTemplates",
                    helper.GetUmbracoApiService<TemplatesController>(x =>
                        x.GetTemplates()) },
                { "PermitAccess",
                    helper.GetUmbracoApiService<SetupController>(x =>
                        x.PermitAccessToFormulate()) },
                { "GetEntityChildren",
                    helper.GetUmbracoApiService<EntitiesController>(x =>
                        x.GetEntityChildren(null)) },
                { "GetEntity",
                    helper.GetUmbracoApiService<EntitiesController>(x =>
                        x.GetEntity(null)) },
                { "GetSubmissions",
                    helper.GetUmbracoApiService<StoredDataController>(x =>
                        x.GetSubmissions(null)) },
                { "DownloadFile",
                    helper.GetUmbracoApiService<StoredDataDownloadController>(x =>
                        x.DownloadFile(null)) },
                { "EditLayoutBase", "/formulate/formulate/editLayout/" },
                { "EditValidationBase",
                    "/formulate/formulate/editValidation/" },
                { "EditDataValueBase",
                    "/formulate/formulate/editDataValue/" },
                { "Layout.RootId", LayoutConstants.Id },
                { "Validation.RootId", ValidationConstants.Id },
                { "DataValue.RootId", DataValueConstants.Id },
                { "Form.RootId", FormConstants.Id }
            });
        }