Exemple #1
0
        public void RegisterRoutes(string route)
        {
            ScsModelBinder.Default             = ModelBinders.Binders.DefaultBinder;
            ModelBinders.Binders.DefaultBinder = new ScsModelBinder();
            var routes = RouteTable.Routes;

            using (routes.GetWriteLock())
            {
                routes.MapRoute("scs", "scs/platform/{action}", new { controller = "SitecoreSidekick.Handlers.ScsMainController, SitecoreSidekick", action = "scs" });
                routes.MapRoute("scsresources", "scs/platform/{action}/{filename}", new { controller = $"SitecoreSidekick.Handlers.ScsMainController, SitecoreSidekick", action = "resources" });
            }
            foreach (var sidekick in _registration.GetAllSidekicks().Where(x => x.Name != "Sitecore Sidekick"))
            {
                sidekick.RegisterRoutes();
            }
        }
        private string GetAllSidekickDirectives()
        {
            ScsMainRegistration sidekick = _registration.GetScsRegistration <ScsMainRegistration>();
            var basicAngularIf           = $"!vm.sidekick || ({"vm.sidekick != '" + string.Join("' && vm.sidekick != '", _registration.GetAllSidekicks().Select(x => x.Name).ToArray())}')";
            var sb = new StringBuilder($"<div ng-style=\"({basicAngularIf}) && {{'width':'{sidekick.CssStyle}', 'background-color':'white'}}\"><h3 id=\"sidekickHeader\" ng-if=\"{basicAngularIf}\">{sidekick.Name}<span class='close' onclick='window.top.document.getElementById(\"scs\").style.display=\"none\";'></span></h3>");

            foreach (var sk in _registration.GetAllSidekicks().Where(x => x.ApplicableSidekick() && x.Name != "Sitecore Sidekick"))
            {
                sb.Append(
                    $"<div ng-if=\"{basicAngularIf}\" ng-click=\"vm.selectSidekick('{sk.Name}')\" class=\"btn scsbtn\"><img ng-src=\"{sk.Icon}\" width=\"32\" height=\"32\" class=\"scContentTreeNodeIcon\" border=\"0\"><div>{sk.Name}</div></div>");
                sb.Append($"<div id=\"{sk.Name.Replace(" ", string.Empty).ToLower()}\" ng-if=\"vm.sidekick == '{sk.Name}'\" targetWidth=\"{sk.CssStyle}\"><div id=\"desktopSidekickHeader\"><span class=\"back\" ng-click=\"vm.goHome()\"><svg class=\"icon icon-arrow-left\"><use xlink:href=\"#icon-arrow-left\"></use></svg> Return Home</span><span class=\"subheader-logo\">{sk.Name}</span><span class='close' onclick='window.top.document.getElementById(\"scs\").style.display=\"none\";'></span></div><h3 id=\"sidekickHeader\">{sk.Name}<span class=\"back\" ng-click=\"vm.goHome()\">Return Home</span><span class='close' onclick='window.top.document.getElementById(\"scs\").style.display=\"none\";'></span></h3><div class=\"scs-form\"><{sk.Directive} ");
                if (sk.DirectiveAttributes != null && sk.DirectiveAttributes.Count > 0)
                {
                    foreach (var key in sk.DirectiveAttributes.AllKeys)
                    {
                        sb.Append($"{key}=\"{sk.DirectiveAttributes[key]}\" ");
                    }
                }
                sb.Append($"></{sk.Directive}></div></div>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }