Example #1
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>();

			if (context.GetViewPreference(engine.Config.Sections.Management.Versions.DefaultViewMode) == ViewPreference.Published)
				data.Flags.Add("ViewPublished");
			else
				data.Flags.Add("ViewDraft");

			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");

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

			return data;
		}
        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");
            }

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

            return(data);
        }