private void BuildCheckList() { this.FlushTargets.Controls.Clear(); string str2 = Settings.DefaultPublishingTargets.ToLowerInvariant(); ListString str = new ListString(Registry.GetString("/Current_User/Publish/Targets")); // add master database Sitecore.Publishing.PublishManager.GetPublishingTargets(Context.ContentDatabase).ForEach(target => { string str3 = "pb_" + ShortID.Encode(target.ID); HtmlGenericControl child = new HtmlGenericControl("input"); this.FlushTargets.Controls.Add(child); child.Attributes["type"] = "checkbox"; child.ID = str3; bool flag = str2.IndexOf('|' + target.Key + '|', StringComparison.InvariantCulture) >= 0; if (str.Contains(target.ID.ToString())) { flag = true; } if (flag) { child.Attributes["checked"] = "checked"; } child.Disabled = !target.Access.CanWrite(); HtmlGenericControl control2 = new HtmlGenericControl("label"); this.FlushTargets.Controls.Add(control2); control2.Attributes["for"] = str3; control2.InnerText = target.DisplayName; this.FlushTargets.Controls.Add(new LiteralControl("<br>")); }); }
public static IEnumerable <Item> GetItemsInCategories([NotNull] IEnumerable <ID> categories) { Assert.ArgumentNotNull(categories, "categories"); var index = SearchManager.SystemIndex; if (index == null) { return(new Item[0]); } var query = new CombinedQuery(); foreach (var id in categories) { query.Add(new FieldQuery("_categories", ShortID.Encode(id)), QueryOccurance.Must); } SearchResultCollection collection; using (var context = index.CreateSearchContext()) { collection = context.Search(query).FetchResults(0, int.MaxValue); } return(collection.Select(result => SearchManager.GetObject(result)).OfType <Item>()); }
public override object GetFieldValue(IIndexableDataField indexableField) { Field field = indexableField as SitecoreItemDataField; var list = new List <string>(); var multiField = FieldTypeManager.GetField(field) as MultilistField; if (multiField != null) { foreach (string key in multiField.List) { string itm = key; if (ID.IsID(itm)) { itm = ShortID.Encode(itm).ToLowerInvariant(); list.Add(itm); } } return(list); } return(list); }
/// <summary> /// Adds all fields. /// </summary> /// <param name="document"> /// The document. /// </param> /// <param name="item"> /// The item. /// </param> /// <param name="versionSpecific"> /// Ignored, must always be true. /// </param> protected override void AddAllFields([NotNull] Document document, [NotNull] Item item, bool versionSpecific) { Assert.ArgumentNotNull(document, "document"); Assert.ArgumentNotNull(item, "item"); base.AddAllFields(document, item, versionSpecific); if (item.Name == "__Standard Values") { return; } var fields = item.Fields; fields.ReadAll(); foreach (Data.Fields.Field field in fields) { if (string.IsNullOrEmpty(field.Key)) { continue; } if (field.Type == "Classification") { var relations = TaxonomyEngine.GetAllCategories(field.Item, field.Value); foreach (var info in relations.Values) { document.Add(CreateTextField("_categories", ShortID.Encode(info.Category))); continue; } } } }
protected string GetItemID(ID id, string language, string version) { Assert.ArgumentNotNull(id, "id"); Assert.ArgumentNotNull(language, "language"); Assert.ArgumentNotNull(version, "version"); return(ShortID.Encode(id) + language + "%" + version); }
protected virtual string GetItemId(ID id, string language, string version) { Assert.ArgumentNotNull((object)id, "id"); Assert.ArgumentNotNull((object)language, "language"); Assert.ArgumentNotNull((object)version, "version"); return(ShortID.Encode(id) + language + "%" + version); }
/// <summary> /// Renders the control page design mode. /// /// </summary> /// <param name="output">The output.</param><param name="isDesignAllowed">if set to <c>true</c> [is design allowed].</param><param name="control">The control.</param> private void RenderControlPageDesignMode(HtmlTextWriter output, bool isDesignAllowed, Control control) { Assert.ArgumentNotNull((object)output, "output"); Assert.ArgumentNotNull((object)control, "control"); RenderingReference renderingReference = Client.Page.GetRenderingReference(control); bool flag = false; if (renderingReference != null) { string uniqueId = renderingReference.UniqueId; if (Sitecore.Data.ID.IsID(uniqueId)) { string controlId = ShortID.Encode(uniqueId); Item obj = this.GetItem(); Assert.IsNotNull((object)obj, "item"); ChromeData controlData = Placeholder72.GetControlData(renderingReference, obj); output.Write(Placeholder72.GetControlStartMarker(controlId, controlData, isDesignAllowed)); control.RenderControl(output); output.Write(Placeholder72.GetControlEndMarker(controlData)); flag = true; } } if (flag) { return; } control.RenderControl(output); }
private static string NormalizeGuid(string guid) { if (!string.IsNullOrEmpty(guid) && guid.StartsWith("{")) { return(ShortID.Encode(guid)); } return(guid); }
/// <summary> /// Adds the base template for products. /// </summary> /// <param name="document">The document.</param> /// <param name="item">The item to proceed.</param> protected virtual void AddBaseTemplateForProducts(Document document, Item item) { ID productBaseTemplateId = new ID(Settings.GetSetting("Ecommerce.Product.BaseTemplateId")); if (item.Template.BaseTemplates.Any(bt => bt.ID.Equals(productBaseTemplateId))) { document.Add(CreateTextField(BuiltinFields.ProductBaseTemplate, ShortID.Encode(productBaseTemplateId))); } }
protected virtual Query GetDescendantsQuery(ID itemID) { Assert.ArgumentNotNull(itemID, "itemID"); BooleanQuery query = new BooleanQuery(); query.Add(new TermQuery(new Term(BuiltinFields.Path, ShortID.Encode(itemID))), BooleanClause.Occur.MUST); this.AddMatchCriteria(query); return(query); }
public static string NormalizeGuid(string guid, bool lowercase) { if (!string.IsNullOrEmpty(guid)) { var shortId = ShortID.Encode(guid); return(lowercase ? shortId.ToLowerInvariant() : shortId); } return(guid); }
/// <summary> /// Converts a GUID into ShortID. /// </summary> /// <param name="guid">String that contains a GUID.</param> /// <returns></returns> public static string NormalizeGuid(string guid) { // checking if it is not a short guid if (!String.IsNullOrEmpty(guid) && guid.StartsWith("{")) { return(ShortID.Encode(guid)); } return(guid); }
/// <summary> /// Adds the boosted fields. /// </summary> /// <param name="document">The document.</param> /// <param name="item">The item to proceed.</param> protected override void AddSpecialFields(Document document, Item item) { base.AddSpecialFields(document, item); document.Add(CreateTextField(Sitecore.Search.BuiltinFields.Template, ShortID.Encode(item.TemplateID))); this.AddBaseTemplateForProducts(document, item); StringBuilder result = new StringBuilder(); this.GetAllBaseTemplates(item.Template, ref result); document.Add(CreateTextField(Sitecore.Search.BuiltinFields.AllTemplates, result.ToString())); }
protected void AddItemIdentifiers(Item item, Document document) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(document, "document"); document.Add(base.CreateValueField(BuiltinFields.Database, item.Database.Name)); document.Add(base.CreateValueField(BuiltinFields.ID, ShortID.Encode(item.ID))); document.Add(base.CreateValueField(BuiltinFields.Language, "neutral")); document.Add(base.CreateTextField(BuiltinFields.Template, ShortID.Encode(item.TemplateID))); document.Add(base.CreateDataField(BuiltinFields.Url, new ItemUri(item.ID, item.Database).ToString(), 0f)); document.Add(base.CreateDataField(BuiltinFields.Group, ShortID.Encode(item.ID), 0f)); }
protected string GetItemLinks(Item item) { Assert.ArgumentNotNull((object)item, "item"); StringBuilder stringBuilder = new StringBuilder(); foreach (ItemLink itemLink in item.Links.GetAllLinks(false)) { stringBuilder.Append(" "); stringBuilder.Append(ShortID.Encode(itemLink.TargetItemID)); } return(((object)stringBuilder).ToString()); }
protected virtual void DisplayStates(IWorkflow workflow, XmlControl placeholder) { this._stateNames = null; foreach (WorkflowState state in workflow.GetStates()) { if (WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(state.StateID)).Length > 0) { string str2; DataUri[] items = this.GetItems(state, workflow); string str = ShortID.Encode(workflow.WorkflowID) + "_" + ShortID.Encode(state.StateID); Section section2 = new Section { ID = str + "_section" }; Section control = section2; control.Attributes["Width"] = "100%"; placeholder.AddControl(control); int length = items.Length; if (length <= 0) { str2 = Translate.Text("None"); } else if (length == 1) { str2 = string.Format("1 {0}", Translate.Text("item")); } else { str2 = string.Format("{0} {1}", length, Translate.Text("items")); } str2 = string.Format("<span style=\"font-weight:normal\"> - ({0})</span>", str2); control.Header = state.DisplayName + str2; control.Icon = state.Icon; if (Settings.ClientFeeds.Enabled) { FeedUrlOptions options2 = new FeedUrlOptions("/sitecore/shell/~/feed/workflowstate.aspx") { UseUrlAuthentication = true }; FeedUrlOptions options = options2; options.Parameters["wf"] = workflow.WorkflowID; options.Parameters["st"] = state.StateID; control.FeedLink = options.ToString(); } control.Collapsed = length <= 0; Border child = new Border(); control.Controls.Add(child); child.ID = str + "_content"; this.DisplayState(workflow, state, items, child, 0, this.PageSize); this.CreateNavigator(control, str + "_navigator", length); } } }
/// <summary> /// Builds the publishing targets. /// /// </summary> private void BuildPublishingTargets() { this.PublishingTargets.Controls.Clear(); Item itemNotNull = Sitecore.Client.GetItemNotNull("/sitecore/system/publishing targets"); ListString listString = new ListString(Registry.GetString("/Current_User/Publish/Targets")); string str1 = Settings.DefaultPublishingTargets.ToLowerInvariant(); ChildList children = itemNotNull.Children; if (children.Count <= 0) { this.SettingsPane.Visible = false; this.NoPublishingTarget.Visible = true; this.NextButton.Disabled = true; } else { HtmlGenericControl htmlGenericControl1 = (HtmlGenericControl)null; foreach (Item obj in children) { string str2 = "pb_" + ShortID.Encode(obj.ID); htmlGenericControl1 = new HtmlGenericControl("input"); this.PublishingTargets.Controls.Add((System.Web.UI.Control)htmlGenericControl1); htmlGenericControl1.Attributes["type"] = "checkbox"; htmlGenericControl1.ID = str2; bool flag = false;// str1.IndexOf((string)(object)'|' + (object)obj.Key + (string)(object)'|', StringComparison.InvariantCulture) >= 0; if (listString.Contains(obj.ID.ToString())) { flag = true; } if (flag) { htmlGenericControl1.Attributes["checked"] = "checked"; } htmlGenericControl1.Disabled = children.Count == 1 || !obj.Access.CanWrite(); HtmlGenericControl htmlGenericControl2 = new HtmlGenericControl("label"); this.PublishingTargets.Controls.Add((System.Web.UI.Control)htmlGenericControl2); htmlGenericControl2.Attributes["for"] = str2; htmlGenericControl2.InnerText = obj.DisplayName; this.PublishingTargets.Controls.Add((System.Web.UI.Control) new LiteralControl("<br>")); } if (children.Count != 1) { return; } this.PublishingTargetsPanel.Disabled = true; if (htmlGenericControl1 == null) { return; } htmlGenericControl1.Attributes["checked"] = "checked"; } }
protected virtual void AddVersionIdentifiers(Item item, Document document) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(document, "document"); document.Add(CreateValueField(BuiltinFields.Database, item.Database.Name)); var itemId = GetItemId(item.ID, item.Language.ToString(), item.Version.ToString()); document.Add(CreateValueField(BuiltinFields.ID, itemId)); document.Add(CreateDataField(BuiltinFields.ID, itemId)); document.Add(CreateValueField(BuiltinFields.Language, item.Language.ToString())); document.Add(CreateTextField(BuiltinFields.Template, ShortID.Encode(item.TemplateID))); document.Add(CreateDataField(BuiltinFields.Url, item.Uri.ToString())); }
protected virtual void AddMatchCriteria(BooleanQuery query) { Assert.ArgumentNotNull(query, "query"); query.Add(new TermQuery(new Term(BuiltinFields.Database, this._root.Database.Name)), BooleanClause.Occur.MUST); query.Add(new TermQuery(new Term(BuiltinFields.Path, ShortID.Encode(this._root.ID))), BooleanClause.Occur.MUST); if (this._hasIncludes || this._hasExcludes) { foreach (KeyValuePair <string, bool> pair in this._templateFilter) { query.Add(new TermQuery(new Term(BuiltinFields.Template, ShortID.Encode(pair.Key))), pair.Value ? BooleanClause.Occur.SHOULD : BooleanClause.Occur.MUST_NOT); } } }
/// <summary> /// Gets the item links. /// </summary> /// <param name="item">The item.</param> /// <returns>The string of the item's links.</returns> protected string GetItemLinks(Item item) { Assert.ArgumentNotNull(item, "item"); var builder = new StringBuilder(); foreach (ItemLink link in item.Links.GetAllLinks(false)) { builder.Append(" "); builder.Append(ShortID.Encode(link.TargetItemID)); } return(builder.ToString()); }
/// <summary> /// Builds the publishing target groups. /// /// </summary> private void BuildPublishingTargetGroups() { this.PublishingTargetGroups.Controls.Clear(); Item publishTargetsItem = Sitecore.Client.GetItemNotNull("/sitecore/system/publishing groups"); string defaultPublishingTargets = Settings.GetSetting("DefaultPublishingTargetGroups").ToLowerInvariant(); ChildList children = publishTargetsItem.Children; if (children.Count <= 0) { this.PublishingTargetGroupsPanel.Visible = false; this.PublishingTargetsPanel.Visible = true; BuildPublishingTargets(); } else { HtmlGenericControl checkboxControl = null; foreach (Item item in children) { string id = "pb_" + ShortID.Encode(item.ID); checkboxControl = new HtmlGenericControl("input"); this.PublishingTargetGroups.Controls.Add(checkboxControl); checkboxControl.Attributes["type"] = "checkbox"; checkboxControl.ID = id; bool targetChecked = defaultPublishingTargets.IndexOf("|" + item.Key + "|", StringComparison.InvariantCulture) >= 0; if (targetChecked) { checkboxControl.Attributes["checked"] = "checked"; } checkboxControl.Disabled = children.Count == 1 || !item.Access.CanWrite(); var labelControl = new HtmlGenericControl("label"); this.PublishingTargetGroups.Controls.Add(labelControl); labelControl.Attributes["for"] = id; labelControl.InnerText = item.DisplayName; this.PublishingTargetGroups.Controls.Add(new LiteralControl("<br>")); } if (children.Count != 1) { return; } this.PublishingTargetGroupsPanel.Disabled = true; if (checkboxControl == null) { return; } checkboxControl.Attributes["checked"] = "checked"; } }
protected string GetAllTemplates(Item item) { Assert.ArgumentNotNull((object)item, "item"); Assert.IsNotNull((object)item.Template, "Item's template is null."); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(ShortID.Encode(item.TemplateID)); stringBuilder.Append(" "); foreach (TemplateItem templateItem in item.Template.BaseTemplates) { stringBuilder.Append(ShortID.Encode(templateItem.ID)); stringBuilder.Append(" "); } return(((object)stringBuilder).ToString()); }
/// <summary> /// Gets all base templates. /// </summary> /// <param name="item">The item.</param> /// <param name="result">The result.</param> protected virtual void GetAllBaseTemplates(TemplateItem item, ref StringBuilder result) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(result, "result"); result.Append(ShortID.Encode(item.ID)); result.Append(" "); List <TemplateItem> templates = item.BaseTemplates.Where(template => template.BaseTemplates.Count() > 0 && template.ID != TemplateIDs.StandardTemplate).ToList(); foreach (TemplateItem template in templates) { this.GetAllBaseTemplates(template, ref result); } }
private static string NormalizeGuid(string guid, bool lowercase) { if (string.IsNullOrEmpty(guid)) { return(guid); } string str = ShortID.Encode(guid); if (!lowercase) { return(str); } return(str.ToLowerInvariant()); }
protected void AddVersionIdentifiers(Item item, Item latestVersion, Document document) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(latestVersion, "latestVersion"); Assert.ArgumentNotNull(document, "document"); document.Add(base.CreateValueField(BuiltinFields.Database, item.Database.Name)); document.Add(base.CreateValueField(BuiltinFields.ID, this.GetItemID(item.ID, item.Language.ToString(), item.Version.ToString()))); document.Add(base.CreateValueField(BuiltinFields.Language, item.Language.ToString())); document.Add(base.CreateTextField(BuiltinFields.Template, ShortID.Encode(item.TemplateID))); if (item.Version.Number == latestVersion.Version.Number) { document.Add(base.CreateValueField(BuiltinFields.LatestVersion, "1")); } document.Add(base.CreateDataField(BuiltinFields.Url, item.Uri.ToString())); document.Add(base.CreateDataField(BuiltinFields.Group, ShortID.Encode(item.ID))); }
protected virtual void AddDecorations(BooleanQuery result) { Assert.ArgumentNotNull(result, "result"); global::Sitecore.Security.Accounts.User user = this.User; if (user != null) { result.Add(new TermQuery(new Term(BuiltinFields.Creator, user.Name)), Occur.SHOULD); result.Add(new TermQuery(new Term(BuiltinFields.Editor, user.Name)), Occur.SHOULD); } global::Sitecore.Data.Items.Item item = this.Item; if (item != null) { result.Add(new TermQuery(new Term(BuiltinFields.Path, ShortID.Encode(item.ID).ToLowerInvariant())), Occur.MUST); result.Add(new TermQuery(new Term(BuiltinFields.Database, item.Database.Name.ToLowerInvariant())), Occur.MUST); if (this.ContentLanguages.Count == 0) { result.Add(new TermQuery(new Term(BuiltinFields.Language, item.Language.ToString().ToLowerInvariant())), Occur.MUST); } } if (this.ContentLanguages.Count > 0) { var langQuery = new BooleanQuery(true); this.ContentLanguages.ForEach(lang => langQuery.Add(new TermQuery(new Term(BuiltinFields.Language, lang.ToString().ToLowerInvariant())), Occur.SHOULD)); result.Add(langQuery, Occur.MUST); } if (!this.IgnoreContentEditorOptions) { if (!UserOptions.View.ShowHiddenItems) { result.Add(new TermQuery(new Term(BuiltinFields.Hidden, "1")), Occur.MUST_NOT); } if (!UserOptions.View.ShowEntireTree && (item != null)) { global::Sitecore.Data.Items.Item item2 = item.Database.GetItem(RootSections.GetSection(item)); if (item2 != null) { result.Add(new TermQuery(new Term(BuiltinFields.Path, ShortID.Encode(item2.ID).ToLowerInvariant())), Occur.MUST); } } } if (TemplateID != default(Guid)) { result.Add(new TermQuery(new Term(BuiltinFields.Template, new ShortID(TemplateID).ToString().ToLowerInvariant())), Occur.MUST); } }
/// <summary> /// Gets all templates. /// </summary> /// <param name="item">The item.</param> /// <returns>The string of all item's templates.</returns> protected string GetAllTemplates(Item item) { Assert.ArgumentNotNull(item, "item"); Assert.IsNotNull(item.Template, "Item's template is null."); var builder = new StringBuilder(); builder.Append(ShortID.Encode(item.TemplateID)); builder.Append(" "); foreach (TemplateItem item2 in item.Template.BaseTemplates) { builder.Append(ShortID.Encode(item2.ID)); builder.Append(" "); } return(builder.ToString()); }
/// <summary> /// Builds the query. /// </summary> /// <param name="searchWords">The search words.</param> /// <returns>Return the lucene search query.</returns> protected virtual Lucene.Net.Search.Query BuildQuery(string searchWords) { BusinessCatalogSettings businessCatalogSettings = Sitecore.Ecommerce.Context.Entity.GetConfiguration <BusinessCatalogSettings>(); string productRepository = businessCatalogSettings.ProductsLink; BooleanQuery query = new BooleanQuery(); query.Add(new BooleanClause(new PrefixQuery(new Term(Sitecore.Search.BuiltinFields.Content, searchWords.ToLower())), Occur.MUST)); query.Add(new TermQuery(new Term(Sitecore.Search.BuiltinFields.Language, Sitecore.Context.Language.Name)), Occur.MUST); ////we should avoid search hits from product repository. if (!string.IsNullOrEmpty(productRepository)) { productRepository = ShortID.Encode(new ID(productRepository)).ToLowerInvariant(); query.Add(new BooleanClause(new PrefixQuery(new Term(Sitecore.Search.BuiltinFields.Path, productRepository)), Occur.MUST_NOT)); } return(query); }
/// <summary> /// The get field value. /// </summary> /// <param name="field"> /// The field. /// </param> /// <returns> /// The <see cref="object" />. /// </returns> public override object GetFieldValue(IIndexableDataField indexableField) { Field field = indexableField as SitecoreItemDataField; var list = new List <string>(); if (field != null) { foreach (string key in field.Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { string itm = key; if (ID.IsID(itm)) { itm = ShortID.Encode(itm).ToLowerInvariant(); list.Add(itm); } } } return(list); }
/// <summary> /// Renders available publishing targets. /// </summary> private void BuildPublishingTargets() { ItemList publishingTargets = PublishManager.GetPublishingTargets(_database); if (publishingTargets == null) { Log.Warn("Scheduled Publish: No publish targets found", this); return; } foreach (Item target in publishingTargets) { string id = string.Format("pt_{0}", ShortID.Encode(target.ID)); Database database = Database.GetDatabase(target[FieldIDs.PublishingTargetDatabase]); if (database == null) { continue; } HtmlGenericControl targetInput = new HtmlGenericControl("input"); targetInput.ID = id; targetInput.Attributes["type"] = "checkbox"; targetInput.Disabled = !target.Access.CanWrite(); if (publishingTargets.Count == 1) { targetInput.Attributes["checked"] = "checked"; } PublishingTargets.Controls.Add(targetInput); HtmlGenericControl targetLabel = new HtmlGenericControl("label"); targetLabel.Attributes["for"] = id; targetLabel.InnerText = string.Format("{0} ({1})", target.DisplayName, database.Name); PublishingTargets.Controls.Add(targetLabel); PublishingTargets.Controls.Add(new LiteralControl("<br/>")); } }