예제 #1
0
        // If there will be a need for extending global SEO settings it would perhaps also need the usage of separate settings into groups.
        // See site settings (Orchard.Core.Settings.Controllers.AdminController and friends for how it is done.
        public ActionResult GlobalSettings()
        {
            if (!_authorizer.Authorize(Permissions.ManageSeo, T("You're not allowed to manage SEO settings.")))
            {
                return(new HttpUnauthorizedResult());
            }

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation, despite
            // being it highly unlikely with Onestop, just in case...
            return(View((object)_contentManager.BuildEditor(_seoSettingsManager.GetGlobalSettings())));
        }
예제 #2
0
        public string GenerateSeoParameter(SeoParameterType type, IContent content)
        {
            var globalSettings = _seoSettingsManager.GetGlobalSettings();
            var pattern        = globalSettings.GetSeoPattern(type, content.ContentItem.ContentType);

            if (String.IsNullOrEmpty(pattern))
            {
                return(null);
            }

            return(_tokenizer.Replace(
                       pattern,
                       new Dictionary <string, object> {
                { "Content", content }
            },
                       new ReplaceOptions {
                Encoding = ReplaceOptions.NoEncode
            }));
        }
예제 #3
0
        public static ISeoGlobalSettings GetGlobalSettingsDraftRequired(this ISeoSettingsManager settingsManager)
        {
            var settings = settingsManager.GetGlobalSettings();

            return(settings.ContentItem.ContentManager.Get <ISeoGlobalSettings>(settings.ContentItem.Id, VersionOptions.DraftRequired));
        }