protected virtual void GetContextMenu(string where) { Assert.ArgumentNotNullOrEmpty(where, "where"); IDataView dataView = this.GetDataView(); if (dataView != null) { string source = Sitecore.Context.ClientPage.ClientRequest.Source; string control = Sitecore.Context.ClientPage.ClientRequest.Control; int num = source.LastIndexOf("_"); Assert.IsTrue(num >= 0, "Invalid source ID"); string id = ShortID.Decode(StringUtil.Mid(source, num + 1)); Item item = dataView.GetItem(id); if (item != null) { SheerResponse.DisableOutput(); Sitecore.Shell.Framework.ContextMenu menu = new Sitecore.Shell.Framework.ContextMenu(); CommandContext context = new CommandContext(item); Sitecore.Web.UI.HtmlControls.Menu contextMenu = menu.Build(context); contextMenu.AddDivider(); contextMenu.Add("__Refresh", "Refresh", "Applications/16x16/refresh.png", string.Empty, string.Concat(new object[] { "javascript:Sitecore.Treeview.refresh(\"", source, "\",\"", control, "\",\"", item.ID.ToShortID(), "\")" }), false, string.Empty, MenuItemType.Normal); SheerResponse.EnableOutput(); SheerResponse.ShowContextMenu(control, where, contextMenu); } } }
protected override string GetMediaPath(string localPath) { int indexA = -1; string strB = string.Empty; foreach (string str in MediaManager.Provider.Config.MediaPrefixes) { indexA = localPath.IndexOf(str, StringComparison.InvariantCultureIgnoreCase); if (indexA >= 0) { strB = str; break; } } if (indexA < 0 || string.Compare(localPath, indexA, strB, 0, strB.Length, true, CultureInfo.InvariantCulture) != 0) { return(string.Empty); } string id = StringUtil.Divide(StringUtil.Mid(localPath, indexA + strB.Length), '.', true)[0]; if (id.EndsWith("/", StringComparison.InvariantCulture)) { return(string.Empty); } if (ShortID.IsShortID(id)) { return(ShortID.Decode(id)); } //2014-06-16 - Removed decode call below return("/sitecore/media library/" + id.TrimStart(new char[1] { '/' }));; }
private void Jump(object sender, Message message, int offset) { string control = Context.ClientPage.ClientRequest.Control; string workflowID = ShortID.Decode(control.Substring(0, 0x20)); string stateID = ShortID.Decode(control.Substring(0x21, 0x20)); control = control.Substring(0, 0x41); IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider; Error.Assert(workflowProvider != null, "Workflow provider for database \"" + Context.ContentDatabase.Name + "\" not found."); IWorkflow workflow = workflowProvider.GetWorkflow(workflowID); Error.Assert(workflow != null, "Workflow \"" + workflowID + "\" not found."); Assert.IsNotNull(workflow, "workflow"); WorkflowState state = workflow.GetState(stateID); Error.Assert(state != null, "Workflow state \"" + stateID + "\" not found."); Border border = new Border { ID = control + "_content" }; DataUri[] items = this.GetItems(state, workflow); this.DisplayState(workflow, state, items, border, offset, this.PageSize); Context.ClientPage.ClientResponse.SetOuterHtml(control + "_content", border); }
protected void Node_Selected() { string selected = WebUtil.GetFormValue("categoryTreeview_Selected"); selected = ShortID.Decode(StringUtil.Mid(selected, 1)); if (Sitecore.Data.ID.IsID(selected)) { UrlHandle handle = UrlHandle.Get(); Database db = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database; Item selectedItem = db.GetItem(new ID(selected)); Item rootItem = db.GetItem(new ID(handle["categoriesRootId"])); if (selectedItem.TemplateID.ToString() != "{A69C0097-5CE1-435B-99E9-FA2B998D1C70}") { SheerResponse.Eval("enableButton_Ok();"); } else { SheerResponse.Eval("disableButton_Ok();"); } string categoryPath = selectedItem.Paths.Path.Substring(rootItem.Paths.Path.Length); newTagParentLiteral.Text = string.Format("{0}", categoryPath); createTagBtn.Disabled = !(selectedItem.Access.CanCreate() && selectedItem.Access.CanWrite()); } }
/// <summary> /// Gets the publishing targets. /// /// </summary> /// /// <returns> /// The publishing targets. /// /// </returns> /// <contract><ensures condition="not null"/></contract> private static List <Item> GetPublishingTargets() { var list = new List <Item>(); foreach (string str in Context.ClientPage.ClientRequest.Form.Keys) { if (str != null && str.StartsWith("pb_", StringComparison.InvariantCulture)) { Item obj = Context.ContentDatabase.Items[ShortID.Decode(str.Substring(3))]; Assert.IsNotNull(obj, typeof(Item), "Publishing group not found.", new object[0]); var targetList = obj["Publishing Targets"]; if (targetList == null || targetList == "") { list.Add(obj); } else { var targets = targetList.Split('|'); foreach (var child in targets) { var targetItem = Context.ContentDatabase.GetItem(child); list.Add(targetItem); } } } } return(list); }
protected void Remove_Click() { Item itemFromQueryString = UIUtil.GetItemFromQueryString(Context.ContentDatabase); Error.AssertItemFound(itemFromQueryString); ArrayList arrayList = new ArrayList(); foreach (System.Web.UI.Control control in this.ExistingAliases.Selected) { string path = ShortID.Decode(StringUtil.Mid(control.ID.Split(MultiSiteAliases.Constants.HypenSplitChar).LastOrDefault(), 0)); Item obj = itemFromQueryString.Database.GetItem(path); if (obj != null) { arrayList.Add((object)obj); } } if (arrayList.Count == 0) { SheerResponse.Alert(MultiSiteAliases.Constants.AliasesNotSelected); } else { foreach (Item obj in arrayList) { obj.Delete(); Log.Audit((object)this, MultiSiteAliases.Constants.RemoveAliases, AuditFormatter.FormatItem(obj)); } RefreshPostDeletion(itemFromQueryString); } }
protected string GetParameterValue(CommandContext context) { var id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID")); var layoutDefinition = GetLayoutDefinition(); if (layoutDefinition == null) { return(string.Empty); } var device = layoutDefinition.GetDevice(id); var renderingByUniqueId = device?.GetRenderingByUniqueId(context.Parameters["referenceId"]); if (renderingByUniqueId == null) { return(string.Empty); } if (string.IsNullOrEmpty(renderingByUniqueId.Parameters)) { return(string.Empty); } var parameters = WebUtil.ParseUrlParameters(renderingByUniqueId.Parameters); return(parameters[this.ParamKey]); }
protected void Add_Click() { string str = this.NewAlias.Value; if (str.Length == 0) { SheerResponse.Alert(MultiSiteAliases.Constants.InputFieldValueMissing); } else { AliasInfo aliasInfo = new AliasInfo(str); foreach (string input in aliasInfo.AscendersAndName) { if (!Regex.IsMatch(input, Settings.ItemNameValidation, RegexOptions.ECMAScript)) { SheerResponse.Alert(MultiSiteAliases.Constants.InvalidName); return; } if (input.Length > Settings.MaxItemNameLength) { SheerResponse.Alert(MultiSiteAliases.Constants.MaxLength, Settings.MaxItemNameLength.ToString()); return; } } Item itemFromQueryString = UIUtil.GetItemFromQueryString(Context.ContentDatabase); Error.AssertItemFound(itemFromQueryString); ArrayList arrayList = new ArrayList(); foreach (ListItem control in this.NewAliases.Selected) { var test = control.Value.Split(MultiSiteAliases.Constants.HypenSplitChar); string path = ShortID.Decode(StringUtil.Mid(test.LastOrDefault(), 0)); Item obj = itemFromQueryString.Database.GetItem(path); if (obj != null) { arrayList.Add((object)new Aliases() { SiteName = string.Join(MultiSiteAliases.Constants.HypenSplit, test.Take(test.Count() - 1).ToArray()), Item = obj }); } } if (arrayList.Count == 0) { SheerResponse.Alert(MultiSiteAliases.Constants.SiteNotSelected); return; } foreach (Aliases eachItem in arrayList) { this.CreateAlias(aliasInfo, itemFromQueryString, eachItem.Item, eachItem.SiteName); } this.NewAlias.Value = string.Empty; SheerResponse.SetModified(false); } }
/// <summary> /// Get Rendering /// </summary> /// <param name="renderingId"> /// The rendering Id. /// </param> /// <returns> /// returns Rendering as RenderingDefinition /// </returns> private static RenderingDefinition GetRendering(string renderingId) { var formValue = WebUtil.GetFormValue("scLayout"); var id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID")); var layoutDefinition = WebEditUtil.ConvertJSONLayoutToXML(formValue); var parsedLayout = LayoutDefinition.Parse(layoutDefinition); var device = parsedLayout.GetDevice(id); var index = device.GetIndex(renderingId); return((RenderingDefinition)device.Renderings[index]); }
public override void Execute(CommandContext context) { string formValue = WebUtil.GetFormValue("scLayout"); string xml = WebEditUtil.ConvertJSONLayoutToXML(formValue); string id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID")); LayoutDefinition layoutDefinition = LayoutDefinition.Parse(xml); if (layoutDefinition == null) { ReturnLayout(); return; } DeviceDefinition device = layoutDefinition.GetDevice(id); if (device == null) { ReturnLayout(); return; } string uniqueId = Guid.Parse(context.Parameters["renderingUid"]).ToString("B").ToUpperInvariant(); RenderingDefinition renderingByUniqueId = device.GetRenderingByUniqueId(uniqueId); if (renderingByUniqueId == null) { ReturnLayout(); return; } if (string.IsNullOrEmpty(renderingByUniqueId.Parameters)) { if (!string.IsNullOrEmpty(renderingByUniqueId.ItemID)) { RenderingItem renderingItem = Client.ContentDatabase.GetItem(renderingByUniqueId.ItemID); renderingByUniqueId.Parameters = ((renderingItem != null) ? renderingItem.Parameters : string.Empty); } else { renderingByUniqueId.Parameters = string.Empty; } } NameValueCollection nameValueCollection = WebUtil.ParseUrlParameters(renderingByUniqueId.Parameters); string input = nameValueCollection["FieldNames"]; string text = context.Parameters["variant"]; if (Guid.TryParse(input, out Guid result) && result == Guid.Parse(text)) { ReturnLayout(); return; } nameValueCollection["FieldNames"] = text; renderingByUniqueId.Parameters = new UrlString(nameValueCollection.EscapeDataValues()).GetUrl(); formValue = WebEditUtil.ConvertXMLLayoutToJSON(layoutDefinition.ToXml()); ReturnLayout(formValue); }
protected IWishList GetWishList(SearchResultItem searchResultItem) { var item = searchResultItem.GetItem(); return(new WishList { ID = searchResultItem.ItemId.ToGuid(), CustomerId = ShortID.Decode(item["CustomerId"]).ToUpper(), // DeNormalize CustomerId ShopContext = Sitecore.Context.Site.Name, IsPublic = MainUtil.GetBool(item["IsPublic"], false), LastModified = DateUtil.ParseDateTime(item["LastModified"], DateTime.Now), Name = item["Name"], WishListLines = new List <IWishListLine>() }); }
private static string GetDragID(string id) { Assert.ArgumentNotNull(id, "id"); int num = id.LastIndexOf("_"); if (num >= 0) { id = StringUtil.Mid(id, num + 1); } if (ShortID.IsShortID(id)) { id = ShortID.Decode(id); } return(id); }
public override void Execute(CommandContext context) { var id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID")); var layoutDefinition = GetLayoutDefinition(); if (layoutDefinition == null) { this.ReturnLayout(); } else { var device = layoutDefinition.GetDevice(id); if (device == null) { this.ReturnLayout(); } else { var renderingByUniqueId = device.GetRenderingByUniqueId(context.Parameters["referenceId"]); if (renderingByUniqueId == null) { this.ReturnLayout(); } else { if (string.IsNullOrEmpty(renderingByUniqueId.Parameters)) { if (!string.IsNullOrEmpty(renderingByUniqueId.ItemID)) { var renderingItem = (RenderingItem)Sitecore.Client.ContentDatabase.GetItem(renderingByUniqueId.ItemID); renderingByUniqueId.Parameters = renderingItem != null ? renderingItem.Parameters : string.Empty; } else { renderingByUniqueId.Parameters = string.Empty; } } var parameters = WebUtil.ParseUrlParameters(renderingByUniqueId.Parameters); parameters[this.ParamKey] = this.ParamValue as string; renderingByUniqueId.Parameters = new UrlString(parameters).GetUrl(); this.ReturnLayout(WebEditUtil.ConvertXMLLayoutToJSON(layoutDefinition.ToXml())); } } } }
private static List <Item> GetPublishingTargets() { List <Item> list = new List <Item>(); foreach (string str in Context.ClientPage.ClientRequest.Form.Keys) { if ((str != null) && str.StartsWith("pb_", StringComparison.InvariantCulture)) { string str2 = ShortID.Decode(str.Substring(3)); Item item = Context.ContentDatabase.Items[str2]; Assert.IsNotNull(item, typeof(Item), "Publishing target not found.", new object[0]); list.Add(item); } } return(list); }
public string Execute([NotNull] string text, [NotNull] string id, [NotNull] string databaseName) { Assert.ArgumentNotNull(databaseName, nameof(databaseName)); Assert.ArgumentNotNull(id, nameof(id)); Assert.ArgumentNotNull(text, nameof(text)); var database = Factory.GetDatabase(databaseName); if (database == null) { throw new Exception("Database not found"); } if (ShortID.IsShortID(id)) { id = ShortID.Decode(id); } var start = database.GetItem(id); var item = start; if (item == null) { item = database.GetRootItem(); } var result = FindItem(item, ID.Null, text); if (result == null && start != null) { result = FindItem(database.GetRootItem(), start.ID, text); } if (result != null) { return(result.ID.ToString()); } return(string.Empty); }
public List <Item> GetSelectedItems(Language language) { List <Item> objList = new List <Item>(); var selectionItems = GetSelectedIDs(); if (selectionItems == null) { return(objList); } var isRootSelected = false; foreach (var selectedId in selectionItems) { if (!string.IsNullOrEmpty(selectedId) && selectedId == Configuration.Settings.TreeviewRootDefaultValue) { isRootSelected = true; break; } else { string id = ShortID.Decode(selectedId); Item obj = RecommendedRenderingsContext.Database.GetItem(id, language); if (obj != null) { objList.Add(obj); } } } if (isRootSelected) { if (DataSource != null && DataSource.Items != null) { return(DataSource.Items); } } return(objList); }
public Item[] GetSelectedItems(Language language, Sitecore.Data.Version version) { List <Item> list = new List <Item>(); IDataView dataView = this.GetDataView(); if (dataView != null) { foreach (string str in this.GetSelectedIDs()) { if (!string.IsNullOrEmpty(str) && !(str == this.ID)) { string id = ShortID.Decode(str); Item item = dataView.GetItem(id, language, version); if (item != null) { list.Add(item); } } } } return(list.ToArray()); }
private string GetMediaPath(string localPath) { int num = -1; string text = string.Empty; foreach (string current in MediaManager.Provider.Config.MediaPrefixes) { num = localPath.IndexOf(current, System.StringComparison.InvariantCultureIgnoreCase); if (num >= 0) { text = current; break; } } if (num < 0) { return(string.Empty); } if (string.Compare(localPath, num, text, 0, text.Length, true, System.Globalization.CultureInfo.InvariantCulture) != 0) { return(string.Empty); } string text2 = StringUtil.Divide(StringUtil.Mid(localPath, num + text.Length), '.', true)[0]; if (text2.EndsWith("/")) { return(string.Empty); } if (ShortID.IsShortID(text2)) { return(ShortID.Decode(text2)); } char[] trimChars = new char[] { '/' }; return("/sitecore/media library/" + text2.TrimStart(trimChars)); }
protected override void OK_Click() { string selected = WebUtil.GetFormValue("categoryTreeview_Selected"); selected = ShortID.Decode(StringUtil.Mid(selected, 1)); if (string.IsNullOrEmpty(selected)) { SheerResponse.Alert("Please select a category."); return; } if (Sitecore.Data.ID.IsID(selected)) { UrlHandle handle = UrlHandle.Get(); Database db = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database; Item selectedItem = db.GetItem(new ID(selected)); Item rootItem = db.GetItem(new ID(handle["categoriesRootId"])); if (selectedItem.TemplateID.ToString() != "{A69C0097-5CE1-435B-99E9-FA2B998D1C70}") { string taxValue = handle["value"]; if (taxValue.Contains(selectedItem.ID.ToString())) { SheerResponse.Alert("Selected category is already assigned.\nPlease select another category."); return; } if (!string.IsNullOrEmpty(taxValue)) { List <string> conflictCategoryNames = new List <string>(); List <ID> tagConflicts = TaxonomyEngine.GetConflictTags(selectedItem.ID).ToList(); if (tagConflicts.Count > 0) { foreach (ID itemTagId in StringUtil.Split(taxValue, '|', true).Select(id => new ID(StringUtil.GetPrefix(id, ':')))) { if (tagConflicts.Contains(itemTagId)) { CategoryItem categoryItem = new CategoryItem(Client.ContentDatabase.GetItem(itemTagId)); conflictCategoryNames.Add(categoryItem.CategoryName); } } } if (conflictCategoryNames.Count > 0) { CategoryItem categoryItem = new CategoryItem(selectedItem); if (conflictCategoryNames.Count > 3) { SheerResponse.Alert( string.Format( Messages.CategoryConflictsWithAlreadyAssignedMoreThanThree, categoryItem.CategoryName, StringUtil.Join(conflictCategoryNames.Take(3).Select(categoryName => " -" + categoryName + "\n"), string.Empty), conflictCategoryNames.Count - 3)); } else { SheerResponse.Alert( string.Format( Messages.CategoryConflictsWithAlreadyAssigned, categoryItem.CategoryName, StringUtil.Join(conflictCategoryNames.Select(categoryName => " -" + categoryName + "\n"), string.Empty))); } return; } } SheerResponse.SetDialogValue(selected); base.OK_Click(); } else { SheerResponse.Alert("Please select a category."); } } }
/// <summary> /// Run Form /// </summary> /// <param name="args"> /// The args. /// </param> protected void Run(ClientPipelineArgs args) { if (!args.IsPostBack) { var rendering = GetRendering(ShortID.Decode(args.Parameters["uniqueid"])); if (rendering == null) { return; } var urlString = new UrlString(UIUtil.GetUri("control:MediaFramework.EmbedMedia")); urlString["mo"] = "webedit"; if (!string.IsNullOrEmpty(rendering.Parameters)) { var collection = StringUtil.GetNameValues(rendering.Parameters, '=', '&'); foreach (string key in collection) { urlString[key] = collection[key]; } } if (ID.IsID(rendering.Datasource)) { urlString[Constants.PlayerParameters.ItemId] = rendering.Datasource; } string activePage = args.Parameters[Constants.PlayerParameters.ActivePage]; if (!string.IsNullOrEmpty(activePage)) { urlString[Constants.PlayerParameters.ActivePage] = activePage; } Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "1100", "600", string.Empty, true); args.WaitForPostBack(); } else { Assert.ArgumentNotNull(args, "args"); if (args.HasResult) { var formValue = WebUtil.GetFormValue("scLayout"); var id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID")); var uniqueId = ShortID.Decode(args.Parameters["uniqueid"]); var layoutDefinition = WebEditUtil.ConvertJSONLayoutToXML(formValue); var parsedLayout = LayoutDefinition.Parse(layoutDefinition); var device = parsedLayout.GetDevice(id); var deviceIndex = parsedLayout.Devices.IndexOf(device); var index = device.GetIndex(uniqueId); var rendering = (RenderingDefinition)device.Renderings[index]; UrlString url = new UrlString(this.GetParameters(args.Result)); string itemId = url[Constants.PlayerParameters.ItemId]; url.Remove(Constants.PlayerParameters.ItemId); rendering.Datasource = new ID(itemId).ToString(); rendering.Parameters = url.ToString(); parsedLayout.Devices[deviceIndex] = device; var updatedLayout = parsedLayout.ToXml(); var layout = GetLayout(updatedLayout); SheerResponse.SetAttribute("scLayoutDefinition", "value", layout); SheerResponse.Eval("window.parent.Sitecore.PageModes.ChromeManager.handleMessage('chrome:rendering:propertiescompleted');"); } } }