private void BuildSiteMap(string sitename, string sitemapUrlNew) { Site site = Sitecore.Sites.SiteManager.GetSite(sitename); SiteContext siteContext = Factory.GetSite(sitename); string rootPath = siteContext.StartPath; List <Item> items = GetSitemapItems(rootPath); string fullPath = MainUtil.MapPath(string.Concat("/", sitemapUrlNew)); string xmlContent = this.BuildSitemapXML(items, site); StreamWriter strWriter = new StreamWriter(fullPath, false); strWriter.Write(xmlContent); strWriter.Close(); }
public override string GetMediaUrl(MediaItem item, MediaUrlOptions options) { Assert.ArgumentNotNull((object)item, nameof(item)); Assert.ArgumentNotNull((object)options, nameof(options)); Assert.IsTrue(this.Config.MediaPrefixes[0].Length > 0, "media prefixes are not configured properly."); string str1 = this.MediaLinkPrefix; if (options.AbsolutePath) { str1 = options.VirtualFolder + str1; } else if (str1.StartsWith("/", StringComparison.InvariantCulture)) { str1 = StringUtil.Mid(str1, 1); } string part2 = MainUtil.EncodePath(str1, '/'); if (options.AlwaysIncludeServerUrl) { part2 = FileUtil.MakePath(string.IsNullOrEmpty(options.MediaLinkServerUrl) ? WebUtil.GetServerUrl() : options.MediaLinkServerUrl, part2, '/'); } string str2 = StringUtil.EnsurePrefix('.', StringUtil.GetString(options.RequestExtension, item.Extension, "ashx")); string str3 = options.ToString(); if (options.AlwaysAppendRevision) { string str4 = Guid.Parse(item.InnerItem.Statistics.Revision).ToString("N"); str3 = string.IsNullOrEmpty(str3) ? "rev=" + str4 : str3 + "&rev=" + str4; } if (str3.Length > 0) { str2 = str2 + "?" + str3; } string str5 = "/sitecore/media library/"; string path = item.InnerItem.Paths.Path; string str6 = MainUtil.EncodePath(!options.UseItemPath || !path.StartsWith(str5, StringComparison.OrdinalIgnoreCase) ? item.ID.ToShortID().ToString() : StringUtil.Mid(path, str5.Length), '/'); string mediaUrl = part2 + str6 + (options.IncludeExtension ? str2 : string.Empty); if (options.LowercaseUrls) { return(this.GetMediaUrl(mediaUrl.ToLowerInvariant(), item)); } return(this.GetMediaUrl(mediaUrl, item)); }
/// <summary>Gets the selected items.</summary> /// <param name="sources">The sources. Never used</param> /// <param name="selected">The selected.</param> /// <param name="unselected">The unselected.</param> /// <contract> /// <requires name="sources" condition="not null" /> /// </contract> protected override void GetSelectedItems(Item[] sources, out ArrayList selected, out IDictionary unselected) { //Assert.ArgumentNotNull((object)sources, "sources"); var roles = Roles.GetAllRoles(); ListString listString = new ListString(this.Value); unselected = (IDictionary) new SortedList((IComparer)StringComparer.Ordinal); selected = new ArrayList(listString.Count); for (int index = 0; index < listString.Count; ++index) { selected.Add((object)listString[index]); } foreach (var role in roles) { int index = listString.IndexOf(role); if (index >= 0) { selected[index] = (object)role; } else { unselected.Add((object)MainUtil.GetSortKey(role), (object)role); } } //---------------------------------------------------------------------- //ListString listString = new ListString(this.Value); //unselected = (IDictionary)new SortedList((IComparer)StringComparer.Ordinal); //selected = new ArrayList(listString.Count); //for (int index = 0; index < listString.Count; ++index) // selected.Add((object)listString[index]); //foreach (Item source in sources) //{ // string @string = source.ID.ToString(); // int index = listString.IndexOf(@string); // if (index >= 0) // selected[index] = (object)source; // else // unselected.Add((object)MainUtil.GetSortKey(source.Name), (object)source); //} }
private void BuildSiteMap(string Sitename, string FileName, string IsSeparatelanguagefile) { List <Item> sitemapItems; Site site = SiteManager.GetSite(Sitename); SiteContext siteContext = Factory.GetSite(Sitename); XmlDocument xDoc = null; List <(XmlDocument doc, string lang)> sitedetails = new List <(XmlDocument doc, string lang)>(); List <string> enabledLanguages = BuildListFromString(siteContext.Properties["enabledLanguages"], '|'); if (enabledLanguages.Count == 0) { //if the config doesn't specify any enabled languages, use the current context to retrieve items sitemapItems = this.GetSitemapItems(siteContext.StartPath, null); xDoc = StartSitemapXML(); xDoc = this.BuildSitemapXML(xDoc, sitemapItems, site, null); sitedetails.Add((xDoc, "")); } else { //For each language supported by the site, retrieve the items using the language and build out sitemap links foreach (var language in enabledLanguages) { sitemapItems = this.GetSitemapItems(siteContext.StartPath, Sitecore.Globalization.Language.Parse(language)); xDoc = StartSitemapXML(); xDoc = this.BuildSitemapXML(xDoc, sitemapItems, site, Sitecore.Globalization.Language.Parse(language)); if (IsSeparatelanguagefile.ToLower() == "yes") { sitedetails.Add((xDoc, language)); } else { sitedetails.Add((xDoc, "")); } } } foreach (var details in sitedetails) { string str = String.Empty; string filename = !String.IsNullOrWhiteSpace(details.lang) ? String.Format("{0}-{1}.xml", FileName, details.lang) : FileName; str = MainUtil.MapPath(string.Concat("/", filename)); StreamWriter streamWriter = new StreamWriter(str, false); streamWriter.Write(details.doc.OuterXml); streamWriter.Close(); } }
/// <summary> /// Initialize the Video Model /// </summary> /// <param name="rendering">The Rendering to use</param> public void Initialize(Rendering rendering) { Item = !string.IsNullOrWhiteSpace(rendering.DataSource) ? Context.Database.GetItem(rendering.DataSource) : Context.Item; if (Item == null) { return; } VideoPath = MediaManager.GetMediaUrl(Item); VideoType = Item.MimeType; Loop = MainUtil.GetBool(rendering.Parameters[ParameterConstants.Video.Loop], false); Autoplay = MainUtil.GetBool(rendering.Parameters[ParameterConstants.Video.Autoplay], false); Mute = MainUtil.GetBool(rendering.Parameters[ParameterConstants.Video.Mute], false); }
protected Item GetItem(RenderFieldArgs args) { if (args is CustomRenderFieldArgs || args.Item.Database.Name != this.SourceDB || this.ExcludeFieldTypes.Contains(args.FieldTypeKey) || (!Sitecore.Context.PageMode.IsPreview) || (!MainUtil.GetBool(Sitecore.Web.WebUtil.GetQueryString("sc_compare"), false))) { return(null); } Database target = Configuration.Factory.GetDatabase(this.TargetDB); Assert.IsNotNull(target, "target"); Item item = target.GetItem(args.Item.ID, args.Item.Language); return(item == null || item.Statistics.Revision == args.Item.Statistics.Revision ? null : item); }
protected void RenameRuleClick([NotNull] Message message) { Assert.ArgumentNotNull(message, "message"); var id = message.Arguments["ruleId"]; var newName = message.Arguments["name"]; Assert.ArgumentNotNull(id, "id"); if (!string.IsNullOrEmpty(newName)) { var ruleSet = FilterSet; var rule = GetFilterById(ruleSet, id); if (rule != null) { rule.SetAttributeValue("name", MainUtil.EscapePling(newName)); FilterSet = ruleSet; } } }
/// <summary> /// The form load event handler. /// </summary> /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param> /// <param name="args">The Render Form arguments.</param> public void Load(bool isPostback, RenderFormArgs args) { HtmlFormModifier form = new HtmlFormModifier(args); if (!MainUtil.IsLoggedIn()) { form.ChangeFormIntroduction(string.Empty); } else { ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >(); string name = customerManager.CurrentUser.BillingAddress.Name; form.ChangeFormTitle(string.Format("{0} {1}.", Translate.Text(Examples.Texts.Welcome), name)); form.HideSectionByField("Returning customer", "UserName"); //Note: hiding of submit form button :) form.HideElement("div", "class", "scfSubmitButtonBorder"); } }
/// <summary> /// Updates the context result with the given Language Collection /// </summary> /// <param name="result"></param> /// <param name="context"></param> private static void UpdateContext(LanguageCollection result, CallContext context) { if (result != null) { LanguageCollection currentResult = context.CurrentResult as LanguageCollection; if (currentResult != null) { Language[] languageArray = (Language[])MainUtil.AddArrays(currentResult.ToArray(), result.ToArray(), typeof(Language)); result = new LanguageCollection(); for (int i = 0; i < languageArray.Length; i++) { result.Add(languageArray[i]); } } context.CurrentResult = result; } context.SetNextIndex(context.Index + 1); }
protected Item GetItem(RenderFieldArgs args) { if (args is CustomRenderFieldArgs || args.Item.Database.Name != SourceDb || ExcludeFieldTypes.Contains(args.FieldTypeKey) || !Context.PageMode.IsPreview || !MainUtil.GetBool(WebUtil.GetQueryString("sc_compare"), false)) { return(null); } var target = Factory.GetDatabase(TargetDb); Assert.IsNotNull(target, "target"); var item = target.GetItem(args.Item.ID, args.Item.Language); return(item == null || item.Statistics.Revision == args.Item.Statistics.Revision ? null : item); }
/// <summary> /// Sends the email. /// </summary> private void SendEmail() { try { var message = new MailMessage(SettingsFixed.SettingsFromMaster.MailFrom, SettingsFixed.SettingsFromMaster.MailTo) { Subject = SettingsFixed.SettingsFromMaster.MailSubject.Replace("[date]", DateUtil.IsoDateToDateTime(Nexus.LicenseApi.Expiration).ToLongDateString()).Replace("[url]", _url), Body = SettingsFixed.SettingsFromMaster.MailContent.Replace("[date]", DateUtil.IsoDateToDateTime(Nexus.LicenseApi.Expiration).ToLongDateString()).Replace("[url]", _url), IsBodyHtml = true }; MainUtil.SendMail(message); } catch (Exception exception) { Log.Error("SitecoreLicenseExpirationAgent failure", exception, this); } }
protected override void DoProcess(FieldSerializationPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.ValueSerialized != null || string.IsNullOrWhiteSpace(args.ValueNormal) || !MainUtil.Split(args.ValueNormal, '|').All(ID.IsID)) { return; } ID[] parsed = ID.ParseArray(args.ValueNormal); args.ValueSerialized = string.Concat( Environment.NewLine, string.Join(Environment.NewLine, parsed.Select(id => id.ToGuid().ToString())), Environment.NewLine); args.FieldSerializationType = FieldSerializationType.IdList; }
/// <summary> /// Add shipping optin by configuration setting /// </summary> /// <param name="configNode">The configuration node.</param> public virtual void AddShippingOption(XmlNode configNode) { Assert.ArgumentNotNull(configNode, "configNode"); string value = XmlUtil.GetAttribute("value", configNode); Assert.IsNotNullOrEmpty(value, "value"); int key = MainUtil.GetInt(value, 0); if (!this.ShippingOptionList.ContainsKey(key)) { var shippingOption = new ShippingOption(); switch (key) { case 1: shippingOption.ShippingOptionType = ShippingOptionType.ShipToAddress; shippingOption.Name = Globalization.Translate.Text(Texts.ShipToNewAddress); shippingOption.Description = Globalization.Translate.Text(Texts.ShipToNewAddress); break; case 2: shippingOption.ShippingOptionType = ShippingOptionType.PickupFromStore; shippingOption.Name = Globalization.Translate.Text(Texts.PickupFromStore); shippingOption.Description = Globalization.Translate.Text(Texts.PickupFromStore); break; case 3: shippingOption.ShippingOptionType = ShippingOptionType.ElectronicDelivery; shippingOption.Name = Globalization.Translate.Text(Texts.EmailDelivery); shippingOption.Description = Globalization.Translate.Text(Texts.EmailDelivery); break; default: shippingOption.ShippingOptionType = ShippingOptionType.None; shippingOption.Name = Globalization.Translate.Text(Texts.NoDeliveryPreference); shippingOption.Description = Globalization.Translate.Text(Texts.NoDeliveryPreference); break; } this.ShippingOptionList[key] = shippingOption; } }
public static string AddShortUrl(this Item item, UrlOptions options) { if (item != null && item.Parent != null && item.Parent.IsABucketFolder()) { try { string shortUrl = item.ResolveShortUrl(options); if (string.IsNullOrEmpty(shortUrl)) { return(null); } if (options.EncodeNames) { shortUrl = MainUtil.EncodePath(shortUrl, '/'); } if (options.LowercaseUrls) { shortUrl = shortUrl.ToLowerInvariant(); } if (!shortUrl.EndsWith(".aspx") && options.AddAspxExtension) { shortUrl += ".aspx"; } ShortUrlTable.RemoveID(Prefix, item.ID); ShortUrlTable.Add(Prefix, shortUrl, item.ID); return(shortUrl); } catch (Exception exception) { Log.Fatal( string.Format("Short Url Manager: cannot add short url for item {0} {1} {2}", item.Uri, exception.Message, exception.StackTrace), new object()); return(null); } } return(null); }
/// <summary> /// Changes the width. /// </summary> protected void ChangeWidth() { if (this.ImageWidth == 0) { return; } var num = MainUtil.GetInt(this.WidthEdit.Text, 0); if (num > 0) { if (!string.IsNullOrWhiteSpace(Ratio.Value)) { return; } if (num > 8192) { num = 8192; this.WidthEdit.Text = "8192"; SheerResponse.SetAttribute(this.WidthEdit.ClientID, "value", this.WidthEdit.Text); } if (this.Aspect.Checked) { if (!string.IsNullOrEmpty(this.X2.Text) && !string.IsNullOrEmpty(this.X1.Text) && !string.IsNullOrEmpty(this.Y2.Text) && !string.IsNullOrEmpty(this.Y2.Text)) { var croppedWidth = Math.Round((decimal)(int.Parse(this.X2.Text) - int.Parse(this.X1.Text))); var croppedHeight = Math.Round((decimal)(int.Parse(this.Y2.Text) - int.Parse(this.Y1.Text))); if (croppedHeight > 0 && croppedWidth > 0) { this.HeightEdit.Text = ((int)(croppedHeight * num / croppedWidth)).ToString(); } else { this.HeightEdit.Text = string.Empty; } } else { this.HeightEdit.Text = ((int)((double)num / (double)this.ImageWidth * (double)this.ImageHeight)).ToString(); } SheerResponse.SetAttribute(this.HeightEdit.ClientID, "value", this.HeightEdit.Text); } } SheerResponse.SetReturnValue(true); }
public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); try { if (SalesforceSettings.Disabled) { LogHelper.Info("Salesforce connector is disabled.", this); return; } if (MainUtil.GetBool(config["disabled"], false)) { LogHelper.Info(string.Format("Provider is disabled. Provider name: {0}", this.Name), this); return; } var configuration = SalesforceManager.GetConfiguration(name); if (configuration == null) { LogHelper.Error("Initialization failed. Configuration is null.", this); return; } this.ContactsApi = configuration.Api.ContactsApi; this.FieldMapping = configuration.FieldMapping; this.ProfileConfiguration = configuration.Profile; this.Cache = configuration.Cache; this.SaleforcePropertyNames = configuration.Profile.Properties.Select(i => i.SalesforceName).ToArray(); this.ApplicationName = config["applicationName"]; this.ReadOnly = MainUtil.GetBool(config["readOnly"], false); this.Initialized = true; } catch (Exception ex) { this.Initialized = false; LogHelper.Error(string.Format("Provider initialization error. Provider name: {0}", this.Name), this, ex); } }
private static int[] ReadSize(string value, int[] defaultValue) { if (defaultValue == null || defaultValue.Length != 2) { defaultValue = new[] { 400, 300 }; } if (!string.IsNullOrEmpty(value)) { string[] sizeArray = value.Split(new[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries); if (sizeArray.Length == 2) { return(new[] { MainUtil.GetInt(sizeArray[0], defaultValue[0]), MainUtil.GetInt(sizeArray[1], defaultValue[1]) }); } } return(defaultValue); }
public void EmailReports(Item[] itemarray, CommandItem commandItem, ScheduleItem scheduleItem) { var item = commandItem.InnerItem; if (item["active"] != "1") { return; } Log("Starting task"); MultilistField mf = item.Fields["reports"]; if (mf == null) { return; } var force = item["sendempty"] == "1"; var filePaths = mf.GetItems().Select(i => runReport(i, force)); var mailMessage = new MailMessage { From = new MailAddress(item["from"]), Subject = item["subject"], }; var senders = item["to"].Split(','); foreach (var sender in senders) { mailMessage.To.Add(sender); } mailMessage.Body = Sitecore.Web.UI.WebControls.FieldRenderer.Render(item, "text"); mailMessage.IsBodyHtml = true; foreach (var path in filePaths.Where(st => !string.IsNullOrEmpty(st))) { mailMessage.Attachments.Add(new Attachment(path)); } Log("attempting to send message"); MainUtil.SendMail(mailMessage); Log("task finished"); }
/// <summary> /// Gets the query string device. /// </summary> /// <param name="database">The database.</param> /// <returns>Resolved device</returns> private static DeviceItem GetQueryStringDevice(Database database) { string queryString = WebUtil.GetQueryString("sc_device"); if (String.IsNullOrEmpty(queryString)) { return(null); } DeviceItem item = database.Resources.Devices[queryString]; Error.AssertNotNull(item, "Could not retrieve device: " + queryString + " (database: " + database.Name + ")"); if (item != null && MainUtil.GetBool(WebUtil.GetQueryString(PersistedDeviceParameter), false)) { HttpContext.Current.Response.Cookies.Add(new HttpCookie(DeviceCookieName, item.Name)); } return(item); }
protected override void MapCore(User user, ClaimCollection claimCollection) { Assert.ArgumentNotNull((object)user, nameof(user)); Assert.ArgumentNotNull((object)claimCollection, nameof(claimCollection)); base.MapCore(user, claimCollection); var isAdminGroup = claimCollection.Any(e => e.Value.Contains("2ea20d7b-4cd3-4a36-b760-39208ef50290")); var isOktaAdminGroup = claimCollection.Any(e => e.Value.Contains("OktaAdmins")); var claim = claimCollection.Single(e => e.Type == "idp"); var isAzureAd = claim.Value == AzureAdClaimName; var isOkta = claim.Value == OktaClaimName; if (isAzureAd) { if (!user.RuntimeSettings.IsVirtual && (isAdminGroup)) { if (MainUtil.GetBool(user.Profile.GetCustomProperty("IsAdminMapped"), false)) { user.Profile.RemoveCustomProperty("IsAdminMapped"); } user.Profile.IsAdministrator = true; user.Profile.SetCustomProperty("IsAdminMapped", "True"); } } else if (isOkta) { if (isOktaAdminGroup) { if (MainUtil.GetBool(user.Profile.GetCustomProperty("IsAdminMapped"), false)) { user.Profile.RemoveCustomProperty("IsAdminMapped"); } user.Profile.IsAdministrator = true; user.Profile.SetCustomProperty("IsAdminMapped", "True"); } } user.Profile.Save(); }
protected virtual void AdjustImageSize(ImageField imageField, float imageScale, int imageMaxWidth, int imageMaxHeight, ref int w, ref int h) { Assert.ArgumentNotNull(imageField, "imageField"); var int1 = MainUtil.GetInt(imageField.Width, 0); var int2 = MainUtil.GetInt(imageField.Height, 0); if (int1 == 0 || int2 == 0) { return; } var size = new Size(w, h); var imageSize = new Size(int1, int2); var maxSize = new Size(imageMaxWidth, imageMaxHeight); var finalImageSize = GetFinalImageSize(GetInitialImageSize(imageSize, imageScale, size), size, maxSize); w = finalImageSize.Width; h = finalImageSize.Height; }
private void LiteralControlDataBinding(object sender, EventArgs e) { var target = (Literal)sender; Control container = target.NamingContainer; var dataItem = DataBinder.GetDataItem(container) as BaseItem; if (dataItem != null) { long fileSize = MainUtil.GetLong(dataItem[this.FieldName], 0); if (dataItem is FolderItem) { target.Text = string.Empty; } else { target.Text = MainUtil.FormatSize(fileSize); } } }
/// <summary> /// Locates changed configs installed by the package installer /// </summary> private void FindAndUpdateChangedConfigs(string installPackageName) { string appConfigFolder = MainUtil.MapPath("/"); foreach (string newConfigFile in Directory.GetFiles(appConfigFolder, "*.config." + installPackageName, SearchOption.AllDirectories)) { Log.Info(string.Format("Found changed config {0}", newConfigFile), this); int configExtensionPos = newConfigFile.LastIndexOf(".config") + 7; string oldConfigFile = Path.Combine(Path.GetDirectoryName(newConfigFile), newConfigFile.Substring(0, configExtensionPos)); string backupConfigFile = newConfigFile + string.Format(".backup{0:yyyyMMddhhmmss}", DateTime.Now); //Backup the existing config file if (File.Exists(oldConfigFile)) { if (File.Exists(backupConfigFile)) { File.Delete(backupConfigFile); } Log.Info(string.Format("Backing up config file {0} as {1}", oldConfigFile, backupConfigFile), this); File.Move(oldConfigFile, backupConfigFile); } Log.Info(string.Format("Copying new config file from {0} to {1}", newConfigFile, oldConfigFile), this); //Move the new file into place File.Copy(newConfigFile, oldConfigFile); //Someone didn't cleanup their handle to the new config file. This waits for it to be cleaned up GC.WaitForPendingFinalizers(); try { File.Delete(newConfigFile); } catch (Exception) { Log.Warn(string.Format("Can't delete file {0}", newConfigFile), this); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (AjaxScriptManager.IsEvent) { return; } ItemID = WebUtil.GetQueryString("id"); FieldID = WebUtil.GetQueryString("fid"); Language = WebUtil.GetQueryString("lang"); this.Version = WebUtil.GetQueryString("ver"); RawSource = WebUtil.GetQueryString("s"); ControlID.Value = WebUtil.GetQueryString("cid"); Disabled = MainUtil.GetBool(WebUtil.GetQueryString("d"), false); RenderItems(); }
/// <summary>Called when the files has cancelled.</summary> /// <param name="packet">The packet.</param> /// <contract> /// <requires name="packet" condition="not null" /> /// </contract> protected void OnFilesCancelled(string packet) { Assert.ArgumentNotNullOrEmpty(packet, "packet"); ListString listString = new ListString(packet); Assert.IsTrue(listString.Count > 0, "Zero cancelled files posted"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("The following files are too big to be uploaded:"); stringBuilder.Append("\n\n"); foreach (string str in listString.Items) { stringBuilder.Append(str + "\n"); } string str1 = MainUtil.FormatSize(Math.Min(Settings.Media.MaxSizeInDatabase, Settings.Runtime.EffectiveMaxRequestLengthBytes)); stringBuilder.Append(Translate.Text("The maximum size of a file that can be uploaded is {0}.", (object)str1)); SheerResponse.Alert(stringBuilder.ToString()); }
/// <summary> /// Processes the specified GetPageItem pipeline arguments. /// </summary> /// <param name="args">The pipeline arguments.</param> public override void Process(GetPageItemArgs args) { Assert.ArgumentNotNull(args, nameof(args)); // Ignore requests if it should not be applied (see method for details). if (this.IgnoreRequest(args)) { return; } // Get cache to determine if item has been resolved var isResolved = MainUtil.GetBool(Context.Items[Constants.CustomUrlResloverCacheKey], false); if (isResolved) { // Item has previously been resolved args.Result = Context.Item; } }
protected void StartGeneration(Message message) { var packageGeneratorFolder = Settings.GetSetting("PackageGeneratorFolder"); var filename = FileUtil.MakePath(Settings.PackagePath, string.Format(@"\{0}\{1}", packageGeneratorFolder, this.PackageFile.Value)); this.ResultFile = MainUtil.MapPath(string.Format("{0}/{1}/{2}.zip", Settings.PackagePath, packageGeneratorFolder, this.PackageName.Value)); if (FileUtil.IsFile(filename)) { this.StartTask(filename); } else { Context.ClientPage.ClientResponse.Alert("Package not found"); this.Active = "Ready"; this.BackButton.Disabled = true; } }
public override void Apply(T ruleContext) { if (ID.IsNullOrEmpty(StatusCodeId)) { Log.Warn($"EndResponseWithStatusCodeAction for page '{Context.Item.Paths.FullPath}' - no status selected", this); return; } var statusCodeItem = Context.Database.GetItem(StatusCodeId); if (statusCodeItem == null) { Log.Warn($"EndResponseWithStatusCodeAction for page '{Context.Item.Paths.FullPath}' - status code item does not exist", this); return; } HttpContext.Current.Response.StatusCode = MainUtil.GetInt(statusCodeItem[StatusCodeFieldName], 200); HttpContext.Current.Response.End(); }
protected void Initialize() { string queryString = Attributes["sc_parameters"]; if (!string.IsNullOrEmpty(queryString)) { NameValueCollection param = Sitecore.Web.WebUtil.ParseUrlParameters(queryString); if (string.IsNullOrEmpty(this.Web)) { if (string.IsNullOrEmpty(param["Web"]) && string.IsNullOrEmpty(param["Server"])) { this.Web = SharepointUtils.CurrentWebPath; } else { this.Web = param["Web"]; } } if (!string.IsNullOrEmpty(param["Server"])) { this.Server = param["Server"]; } if (string.IsNullOrEmpty(this.ListName)) { this.ListName = param["List"]; this.ListName = this.ListName.Replace("%2b", " "); this.ListName = this.ListName.Replace("+", " "); } this.ShowIfEmpty = MainUtil.GetBool(param["ShowIfEmpty"], false); } this.context = SpContextProviderBase.Instance.CreateUIContext(this.Server, this.Web); NetworkCredential headerCredential = SharepointExtension.GetCredentialsFromHeader(Request); if (headerCredential != null) { this.context.Credentials = headerCredential; } }
/// <summary> /// Resolves the display name of the using. /// </summary> /// <param name="itemPath">The item path.</param> /// <returns>The resolved item.</returns> protected virtual Item ResolveUsingDisplayName(string itemPath) { Assert.ArgumentNotNull(itemPath, "UrlItemPath"); using (new SecurityDisabler()) { if (string.IsNullOrEmpty(itemPath) || (itemPath[0] != '/')) { return(null); } int index = itemPath.IndexOf('/', 1); if (index < 0) { return(null); } Item root = ItemManager.GetItem(itemPath.Substring(0, index), Language.Current, Sitecore.Data.Version.Latest, Sitecore.Context.Database, SecurityCheck.Disable); if (root == null) { return(null); } string path = MainUtil.DecodeName(itemPath.Substring(index)); Item child = root; foreach (string itemName in path.Split(new[] { '/' })) { if (itemName.Length == 0) { continue; } child = this.GetChildFromNameOrDisplayName(child, itemName); if (child == null) { return(null); } } return(child); } }