Beispiel #1
0
        public bool AddEverything()
        {
            var wrapLog = Log.Call <bool>();

            // normal scripts
            var editJs = BlockBuilder?.UiAddEditApi ?? false;
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            var readJs  = BlockBuilder?.UiAddJsApi ?? editJs;
            var editCss = BlockBuilder?.UiAddEditUi ?? false;

            if (!readJs && !editJs && !editCss)
            {
                return(wrapLog("nothing added", true));
            }

            Log.Add("user is editor, or template requested js/css, will add client material");

            // register scripts and css
            RegisterClientDependencies(Page, readJs, editJs, editCss);

            // New in 11.11.02 - DNN has a strange behavior where the current language isn't known till PreRender
            // so we have to move adding the header to here.
            // MustAddHeaders may have been set earlier by the engine, or now by the various js added
            Log.Add($"{nameof(MustAddHeaders)}={MustAddHeaders}");
            if (MustAddHeaders)
            {
                Header.AddHeaders();
            }

            return(wrapLog("ok", true));
        }
        public void EnsurePre1025Behavior()
        {
            // new in 10.25 - by default jQuery isn't loaded!
            // but any old behaviour, incl. no-view defined, etc. should activate compatibility
            var addAntiForgeryToken = BlockBuilder
                                      ?.GetEngine(Purpose.WebView)
                                      ?.CompatibilityAutoLoadJQueryAndRVT
                                      ?? true;

            if (!addAntiForgeryToken)
            {
                return;
            }
            Log.Add(nameof(EnsurePre1025Behavior) + ": Activate Anti-Forgery for compatibility with old behavior");
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            Header.AddHeaders();
        }