protected new void Run(ClientPipelineArgs args) { Item obj1 = Database.GetItem(ItemUri.Parse(args.Parameters["uri"])); if (obj1 == null) { SheerResponse.Alert("Item not found."); } else { string str = obj1.ID.ToString(); if (args.IsPostBack) { if (args.Result != "yes") { return; } Item obj2 = Context.ContentDatabase.GetItem(LinkManager.GetPreviewSiteContext(obj1).StartPath); if (obj2 == null) { SheerResponse.Alert("Start item not found."); return; } str = obj2.ID.ToString(); } else if (!HasPresentationPipeline.Run(obj1)) { SheerResponse.Confirm("The current item cannot be previewed because it has no layout for the current device.\n\nDo you want to preview the start Web page instead?"); args.WaitForPostBack(); return; } SheerResponse.CheckModified(false); SiteContext previewSiteContext = LinkManager.GetPreviewSiteContext(obj1); if (previewSiteContext == null) { SheerResponse.Alert(Translate.Text("Site \"{0}\" not found", Settings.Preview.DefaultSite)); } else { WebUtil.SetCookieValue(previewSiteContext.GetCookieKey("sc_date"), string.Empty); PreviewManager.StoreShellUser(Settings.Preview.AsAnonymous); UrlString urlString = new UrlString("/"); urlString["sc_itemid"] = str; urlString["sc_mode"] = "preview"; urlString["sc_compare"] = "true"; urlString["sc_lang"] = obj1.Language.ToString(); urlString["sc_site"] = previewSiteContext.Name; DeviceSimulationUtil.DeactivateSimulators(); if (UIUtil.IsChrome()) { SheerResponse.Eval("setTimeout(function () { window.open('" + urlString + "', '_blank');}, 0);"); } else { SheerResponse.Eval("window.open('" + urlString + "', '_blank');"); } } } }
protected new void Run(ClientPipelineArgs args) { var contentItem = Database.GetItem(ItemUri.Parse(args.Parameters["uri"])); if (contentItem == null) { SheerResponse.Alert("Item not found."); } else { var itemId = contentItem.ID.ToString(); if (args.IsPostBack) { if (args.Result != "yes") { return; } var startItem = Context.ContentDatabase.GetItem(Context.Site.StartPath); if (startItem == null) { SheerResponse.Alert("Start item not found."); return; } if (!HasPresentationPipeline.Run(startItem)) { SheerResponse.Alert("The start item cannot be previewed because it has no layout for the current device.\n\nPreview cannot be started."); return; } itemId = startItem.ID.ToString(); } else if (!HasPresentationPipeline.Run(contentItem)) { SheerResponse.Confirm("The current item cannot be previewed because it has no layout for the current device.\n\nDo you want to preview the start Web page instead?"); args.WaitForPostBack(); return; } SheerResponse.CheckModified(false); //Dynamically Speaking, we want the site of the item as it relates to a home Item. //If not found, fallback to default functionalty. var site = DynamicSiteManager.GetSiteContextByContentItem(contentItem) ?? Factory.GetSite(Settings.Preview.DefaultSite); Assert.IsNotNull(site, "Site \"{0}\" not found", Settings.Preview.DefaultSite); WebUtil.SetCookieValue(site.GetCookieKey("sc_date"), string.Empty); PreviewManager.StoreShellUser(Settings.Preview.AsAnonymous); var webSiteUrl = SiteContext.GetWebSiteUrl(); webSiteUrl["sc_itemid"] = itemId; webSiteUrl["sc_mode"] = "preview"; webSiteUrl["sc_lang"] = contentItem.Language.ToString(); DeviceSimulationUtil.DeacitvateSimulators(); SheerResponse.Eval("window.open('" + webSiteUrl + "', '_blank')"); } }
/// <summary> /// Executes the command in the specified context. /// </summary> /// <param name="context">The context.</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if ((int)context.Items.Length != 1) { return; } DeviceSimulationUtil.DeactivateSimulators(); Item items = context.Items[0]; ShortID shortID = items.ID.ToShortID(); string str = string.Concat("SEO Check", shortID); if ((new EditorTabsClientManager()).ShowEditorTabs.Any <ShowEditorTab>((ShowEditorTab tab) => { if (tab.Command != "contenteditor:seocheck") { return(false); } return(tab.Id == str); })) { SheerResponse.Eval(string.Concat("scContent.onEditorTabClick(null, null, '", str, "')")); return; } var url = LinkManager.GetItemUrl(items, new UrlOptions() { AlwaysIncludeServerUrl = true }); Uri myUri = new Uri(url); UrlString urlString = new UrlString(myUri.Host + "/sitecore/shell/-/xaml/Sitecore.Shell.Applications.ContentEditor.Editors.Preview.aspx"); items.Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); WebClient client = new WebClient(); String htmlCode = client.DownloadString(urlString.ToString()); //Below code is to open the SEO Report //SheerResponse.Eval((new ShowEditorTab() //{ // Command = "contenteditor:seocheck", // Header = Translate.Text("SEO Check"), // Title = string.Concat(Translate.Text("SEO Check"), ": ", (!UserOptions.View.UseDisplayName ? items.Name : items.DisplayName)), // Icon = Images.GetThemedImageSource("Network/16x16/environment.png"), // Url = urlString.ToString(), // Id = str, // Closeable = true, // Activate = true, // Language = items.Language, // Version = items.Version //}).ToString()); }
public void Process(RenderLayoutArgs args) { if (Context.Site.Name == "shell") { return; } try { var head = WebUtil.FindControlOfType(Context.Page.Page, typeof(HtmlHead)); if (head != null) { if (!head.TemplateSourceDirectory.Contains("speak")) { var currentSimulatorId = DeviceSimulationUtil.GetCurrentSimulatorId(); if (currentSimulatorId.IsNull || currentSimulatorId == NoneSimulator.Id || currentSimulatorId == ID.Null) { var filesJs = Directory.GetFiles(HttpContext.Current.Server.MapPath(Constants.FolderJs)); foreach (var fileJs in filesJs) { var extension = Path.GetExtension(fileJs); if (extension != null && extension.Contains(".js")) { var fileName = Path.GetFileNameWithoutExtension(fileJs); if (fileName != null && fileName.IndexOf('-') > 1) { fileName = fileName.Remove(fileName.IndexOf('-')); } if (!IsFileExistOnPage(head, fileName)) { IncludeJsToControl(head, Constants.FolderJs + Path.GetFileName(fileJs)); } } } } } } } catch (Exception exception) { Log.Error("Feedback Module, InjectJs: ", exception, this); } }