public void Initialize(Engine.IEngine engine)
        {
            var routes      = engine.Resolve <IProvider <RouteCollection> >().Get();
            var viewEngines = engine.Resolve <IProvider <ViewEngineCollection> >().Get();

            RegisterArea(routes, viewEngines, engine);
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Pragma", "no-cache");
            context.Response.AddHeader("Cache-Control", "private, no-cache");

            ValidateTicket(context.Request["ticket"]);

            SelectionUtility selection = new SelectionUtility(context, engine);
            var fs = engine.Resolve <IFileSystem>();

            List <FilesStatus> statuses;

            var headers = context.Request.Headers;

            if (string.IsNullOrEmpty(headers["X-File-Name"]))
            {
                statuses = UploadWholeFile(context, fs, selection).ToList();
            }
            else
            {
                statuses = UploadPartialFile(headers["X-File-Name"], context, fs, selection).ToList();
            }

            WriteJsonIframeSafe(context, statuses);
        }
Exemple #3
0
 public void Initialize(Engine.IEngine engine)
 {
     if (engine.Config.Sections.Web.Tokens.BuiltInEnabled)
     {
         var viewEngines = engine.Resolve <IProvider <ViewEngineCollection> >().Get();
         viewEngines.RegisterTokenViewEngine();
     }
 }
        private ExtendedContentInfo CreateExtendedContextData(ContentItem item, bool resolveVersions = false)
        {
            if (item == null)
            {
                return(null);
            }

            var data = new ExtendedContentInfo
            {
                Created       = item.Created.ToString("o"),
                Expires       = item.Expires.HasValue ? item.Expires.Value.ToString("o") : null,
                IsPage        = item.IsPage,
                Published     = item.Published.HasValue ? item.Published.Value.ToString("o") : null,
                SavedBy       = item.SavedBy,
                Updated       = item.Updated.ToString("o"),
                Visible       = item.Visible,
                ZoneName      = item.ZoneName,
                VersionIndex  = item.VersionIndex,
                Url           = item.Url,
                ReadProtected = !engine.SecurityManager.IsAuthorized(item, new GenericPrincipal(new GenericIdentity(""), null)),
                TypeName      = item.GetContentType().Name
            };

            if (resolveVersions)
            {
                var draftInfo = engine.Resolve <DraftRepository>().GetDraftInfo(item);
                data.Draft = CreateExtendedContextData(draftInfo != null ? engine.Resolve <IVersionManager>().GetVersion(item, draftInfo.VersionIndex) : null);
                if (data.Draft != null)
                {
                    data.Draft.SavedBy = draftInfo.SavedBy;
                    data.Draft.Updated = draftInfo.Saved.ToString("o");
                }
                data.VersionOf = CreateExtendedContextData(item.VersionOf);
            }
            ;
            if (item.State == ContentState.Waiting)
            {
                DateTime?futurePublishDate = (DateTime?)item["FuturePublishDate"];
                if (futurePublishDate.HasValue)
                {
                    data.FuturePublishDate = futurePublishDate.Value.ToString("o");
                }
            }
            return(data);
        }
Exemple #5
0
        public virtual ContextData GetInterfaceContextData(HttpContextBase context, SelectionUtility selection)
        {
            var item = selection.ParseSelectionFromRequest();

            Url selectedUrl = context.Request["selectedUrl"];

            if (item == null && selectedUrl != null)
            {
                item = selection.ParseUrl(selectedUrl);
            }

            var data = new ContextData();

            if (item != null)
            {
                var adapter = engine.GetContentAdapter <NodeAdapter>(item);
                data.CurrentItem  = adapter.GetTreeNode(item);
                data.ExtendedInfo = CreateExtendedContextData(item, resolveVersions: true);
                var l = adapter.GetLanguage(item);
                if (l != null)
                {
                    data.Language = new ContextLanguage {
                        IconClass = "sprite " + (l.LanguageCode.Split('-').LastOrDefault() ?? string.Empty).ToLower(), LanguageCode = l.LanguageCode, LanguageTitle = l.LanguageTitle
                    }
                }
                ;
                data.Flags = adapter.GetNodeFlags(item).ToList();
            }
            else
            {
                data.Flags = new List <string>();
            }

            var mangementUrl = "{ManagementUrl}".ResolveUrlTokens();

            if (!selectedUrl.IsEmpty())
            {
                data.ReturnUrl = HttpUtility.UrlDecode(selectedUrl["returnUrl"]);
                var isOrganizing = selectedUrl["edit"] == "drag";
                if (selectedUrl.Path.StartsWith(mangementUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    data.Flags.Add("Management");
                    data.Flags.Add(selectedUrl.Path.Substring(mangementUrl.Length).ToUrl().PathWithoutExtension.Replace("/", ""));
                    if (isOrganizing)
                    {
                        data.Flags.Add("Organize");
                    }
                }
                else if (isOrganizing)
                {
                    data.Flags.Add("Management");
                    data.Flags.Add("Organize");
                }
            }

            if (new[] { "MyselfRoot", "ContentEditRecursive", "ContentTemplatesDefault", "ContentWizardDefault", "UsersUsers" }.Intersect(data.Flags).Any() == false)
            {
                data.Flags.Add("ContentPages");
            }

            data.Actions = CreateActions(context);

            var collaborationContext = CollaborationContext.Create(engine.Resolve <IProfileRepository>(), item, context);

            data.Messages = engine.Resolve <N2.Edit.Collaboration.ManagementMessageCollector>().GetMessages(collaborationContext).ToList();
            data.Flags.AddRange(engine.Resolve <N2.Edit.Collaboration.ManagementFlagCollector>().GetFlags(collaborationContext));

            if (ContextBuilt != null)
            {
                ContextBuilt(this, new ContextBuiltEventArgs {
                    Data = data
                });
            }

            return(data);
        }
        public void Initialize(Engine.IEngine engine)
        {
            var viewEngines = engine.Resolve <IProvider <ViewEngineCollection> >().Get();

            viewEngines.RegisterTokenViewEngine();
        }