public Answer(Sitecore.Data.Items.Item i) { this.i = i; Text = FieldRenderer.Render(i, "text"); Value = i["value"]; Id = i.ID.Guid; Checked = false; Tag = i.Parent["tag"]; }
/// <summary> /// Collect the latest language versions of the item /// </summary> /// <param name="sitecoreItem">The item</param> /// <returns>The language versions</returns> private Sitecore.Data.Items.Item[] GetLanguageVersions(Sitecore.Data.Items.Item sitecoreItem) { var languages = sitecoreItem.Languages; List <Sitecore.Data.Items.Item> versions = new List <Sitecore.Data.Items.Item>(); foreach (var language in languages) { var finalVersion = sitecoreItem.Versions.GetLatestVersion(language); if (finalVersion.Statistics.Created > DateTime.MinValue) { versions.Add(finalVersion); } } if (versions.Count == 0) { versions.Add(sitecoreItem); } return(versions.ToArray()); }
/// <summary> /// Build a publishing queue for the specified item to the specified publishing /// target. /// </summary> /// <param name="item">The item to publish.</param> /// <param name="target">The publishing target.</param> /// <returns>True on success, False on any type of failure.</returns> protected bool BuildQueue( Sitecore.Data.Items.Item item, Sitecore.Sharedsource.Publishing.PublishingTarget target) { if (this.HandlePublishingRestrictions(item, false, target)) { return(false); } target.CreatePublishingContext(item); if (this.PublishReferencedItems || this.PublishReferencedMedia) { if (this.HandleReferences(item, target)) { return(false); } } return(true); }
public override string GetItemUrl(Sitecore.Data.Items.Item item, UrlOptions options) { try { if (BucketManager.IsItemContainedWithinBucket(item)) { var bucketItem = item.GetParentBucketItemOrParent(); if (bucketItem != null && bucketItem.IsABucket()) { var bucketUrl = base.GetItemUrl(bucketItem, options); string itemName = MainUtil.EncodeName(item.Name); return(FileUtil.MakePath(bucketUrl, itemName)); } } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error(ex.Message, ex, this); } return(base.GetItemUrl(item, options)); }
public void HowToCreateTemplateWithStandardValues() { var templateId = new Sitecore.Data.TemplateID(Sitecore.Data.ID.NewID); using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db { // create template with field Title and standard value $name new Sitecore.FakeDb.DbTemplate("Sample", templateId) { { "Title", "$name" } } }) { // add item based on the template to the content root Sitecore.Data.Items.Item contentRoot = db.GetItem(Sitecore.ItemIDs.ContentRoot); Sitecore.Data.Items.Item item = contentRoot.Add("Home", templateId); // the Title field is set to 'Home' Xunit.Assert.Equal("Home", item["Title"]); } }
public void HowToCreateVersionedItem() { using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db { new Sitecore.FakeDb.DbItem("home") { new Sitecore.FakeDb.DbField("Title") { { "en", 1, "Hello!" }, { "en", 2, "Welcome!" } } } }) { Sitecore.Data.Items.Item home1 = db.GetItem("/sitecore/content/home", "en", 1); Xunit.Assert.Equal("Hello!", home1["Title"]); Sitecore.Data.Items.Item home2 = db.GetItem("/sitecore/content/home", "en", 2); Xunit.Assert.Equal("Welcome!", home2["Title"]); } }
protected override DateTime?GetItemDate(Sitecore.Data.Items.Item item) { System.Web.UI.Control feedRendering = Sitecore.Syndication.FeedUtil.GetFeedRendering(item); if (feedRendering == null) { return(null); } using (new Sitecore.Data.Items.ContextItemSwitcher(item)) { if (feedRendering is Sitecore.Web.UI.WebControls.FeedRenderer) { Sitecore.Web.UI.WebControls.FeedRenderer renderer = feedRendering as Sitecore.Web.UI.WebControls.FeedRenderer; renderer.Database = (Context.ContentDatabase ?? Context.Database).Name; return(new DateTime?(renderer.GetDate())); } } throw new InvalidOperationException( "FeedRenderer rendering must be of Sitecore.Web.UI.WebControls.FeedRenderer type"); }
protected void Page_Load(object sender, EventArgs e) { try { if (Parent is Sublayout) { this.dataSourceItem = Sitecore.Context.Database.GetItem(((Sublayout)Parent).DataSource); RenderPdfContent(); if (this.dataSourceItem == null) { litPdfViewMsg.Text = "Oops...Datasource is not yet configured."; } } } catch (Exception ex) { litPdfViewMsg.Text = ex.Message; } }
public Sitecore.Data.Items.Item[] ListQuery(Sitecore.Data.Items.Item item) { item.Fields.ReadAll(); return(item.Fields.Select(x => x.InnerItem).ToArray()); //List<TemplateItem> templates = new List<TemplateItem>(); //var template = item.Template; //if (template != null) //{ // if (template.ID == new ID("f4dbbc93-2591-4aa8-b71a-1dc4acd5c941")) // { // templates.Add(template); // } // foreach (var t in template.BaseTemplates) //} // return item.Parent.Children.ToArray(); }
public override void DoProcess(GetPresentationDataSourcesArgs args) { if (!(args.RawDataSource.StartsWith("query:fast:") || args.RawDataSource.StartsWith("fast:"))) { return; } string query = args.RawDataSource; if (query.StartsWith("query:fast:")) { query = query.Substring("query:fast:".Length); } if (query.StartsWith("fast:")) { query = query.Substring("fast:".Length); } SC.Data.Items.Item item = args.ContextItem; while (query.StartsWith("../")) { item = item.Parent; query = query.Substring("../".Length); } if (query.StartsWith("./")) { query = query.Substring("./".Length); } if (!query.StartsWith("/")) { query = item.Paths.FullPath + "/" + query; } args.DataSourceItems.AddRange(item.Database.SelectItems("fast:" + query)); }
/// <summary> /// Initializes the Channelizer settings. /// </summary> /// <returns></returns> private bool Initialize(DetermineChannelProcessorArgs args) { Sitecore.Diagnostics.Log.Debug($"{typeof(SetChannel).FullName} - Initializing module", this); var rootItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.RootPath); if (String.IsNullOrEmpty(rootItem[Templates.HasChannelizer.Fields.Channelizer])) { Sitecore.Diagnostics.Log.Warn($"Channelizer configuration item not selected.", this); return(false); } this.channelizerSettingsItem = new Sitecore.Data.Fields.ReferenceField(rootItem.Fields[Templates.HasChannelizer.Fields.Channelizer]).TargetItem; if (channelizerSettingsItem == null) { return(false); } if (!channelizerSettingsItem.DescendsFrom(Templates.ChannelizerSettings.TemplateId)) { Sitecore.Diagnostics.Log.Warn($"The selected item ({channelizerSettingsItem.Paths.FullPath}) is not deriving Channelizer settings template.", this); return(false); } String channelsSelectedToSkipProcessing = channelizerSettingsItem[Templates.ChannelizerSettings.Fields.DoNotProcessIfChannelsAlreadyAssigned]; if (!String.IsNullOrEmpty(channelsSelectedToSkipProcessing) && channelsSelectedToSkipProcessing.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Contains(args.ChannelId.ToString())) { Sitecore.Diagnostics.Log.Warn($"The assinged channel ({args.ChannelId}) from previous processor(s) is setup to terminate the process.", this); return(false); } if (!Sitecore.MainUtil.GetBool(channelizerSettingsItem[Templates.ChannelizerSettings.Fields.Active], false)) { Sitecore.Diagnostics.Log.Warn($"Channelizer is diabled. ({this.channelizerSettingsItem.Paths.FullPath})", this); return(false); } if (!this.channelizerSettingsItem.Children.Any(c => c.DescendsFrom(Templates.ChannelizerSettingItem.TemplateId))) { Sitecore.Diagnostics.Log.Warn($"Channelizer child setting items not found. ({this.channelizerSettingsItem.Paths.FullPath})", this); return(false); } return(true); }
public override void Execute(SC.Shell.Framework.Commands.CommandContext context) { SC.Diagnostics.Assert.IsNotNull(context, "context"); SC.Text.UrlString webSiteUrl = new SC.Text.UrlString("/"); webSiteUrl.Add("sc_debug", "1"); webSiteUrl.Add("sc_prof", "1"); webSiteUrl.Add("sc_trace", "1"); webSiteUrl.Add("sc_ri", "1"); SC.Data.Database db = SC.Context.ContentDatabase; SC.Globalization.Language lang = SC.Context.ContentLanguage; // if the context for invoking the command specifies exactly one item if (context.Items != null && context.Items.Length == 1 && context.Items[0] != null) { // ensure the user has saved the selected item SC.Context.ClientPage.ClientResponse.CheckModified(false); SC.Data.Items.Item item = context.Items[0]; db = item.Database; lang = item.Language; webSiteUrl.Add("sc_itemid", item.ID.ToString()); } if (db != null) { webSiteUrl.Add("sc_database", db.Name); } if (lang != null) { webSiteUrl.Add("sc_lang", lang.ToString()); } // without this, I didn't see the ribbon SC.Publishing.PreviewManager.RestoreUser(); SC.Context.ClientPage.ClientResponse.Eval( "window.open('" + webSiteUrl + "', '_blank')"); }
/// <summary> /// Handle the case that the specified item has publishing restrictions. /// </summary> /// <param name="item">The item to check.</param> /// <param name="requireLatest">Whether to also check that the version is the /// latest and does not have publishing restrictions.</param> /// <returns>True if the item or version has publishing restrictions, False /// otherwise.</returns> /// <exception cref="PublishingException"><c>PublishingException</c> - Any type of /// error.</exception> protected bool HandlePublishingRestrictions( Sitecore.Data.Items.Item item, bool requireLatest) { Sitecore.Diagnostics.Assert.IsNotNull(item, "item"); if (item.HasPublishingRestrictions(true, requireLatest)) { string message = this.Logger.Info( "{0} has publishing restrictions.", item); if (this.ThrowExceptions) { throw new PublishingException(message); } return(true); } return(false); }
private void RenderItems(HtmlTextWriter output) { SC.Diagnostics.Assert.ArgumentNotNull(output, "output"); SC.Collections.SafeDictionary <string> parameters = SC.Web.WebUtil.ParseQueryString(this.Source); string display = parameters["Display"]; foreach (string str in this.Value.Split(new char[] { '|' })) { if (!string.IsNullOrEmpty(str)) { SC.Data.Items.Item item = this.Database.GetItem(str); SC.Resources.ImageBuilder builder = new SC.Resources.ImageBuilder { Width = 0x10, Height = 0x10, Margin = "0px 4px 0px 0px", Align = "absmiddle" }; if (item == null) { builder.Src = "Applications/16x16/forbidden.png"; output.Write("<div>"); builder.Render(output); output.Write(SC.Globalization.Translate.Text("Item not found: {0}", new object[] { str })); output.Write("</div>"); } else { builder.Src = item.Appearance.Icon; output.Write("<div title=\"" + item.Paths.ContentPath + "\">"); builder.Render(output); output.Write(this.GetHeader(item, display)); output.Write("</div>"); } } } }
protected string GetHeader(SC.Data.Items.Item item, string display) { string result = item.DisplayName; if (!string.IsNullOrEmpty(display)) { if (display == "@name") { result = item.Name; } else if (display == "@path") { result = item.Paths.FullPath; } else if (!string.IsNullOrEmpty(item[display])) { result = item[display]; } } return(result); }
public override void Process( SC.Publishing.Pipelines.PublishItem.PublishItemContext context) { SC.Diagnostics.Assert.ArgumentNotNull(context, "context"); SC.Diagnostics.Assert.ArgumentNotNull(context.ItemId, "ItemId"); SC.Diagnostics.Assert.ArgumentNotNull( context.PublishOptions, "PublishOptions"); SC.Diagnostics.Assert.ArgumentNotNull( context.PublishOptions.TargetDatabase, "TargetDatabase"); // retrieve the item from the publishing target database SC.Data.Items.Item item = context.PublishOptions.TargetDatabase.GetItem( context.ItemId); // if the item does not exist (or the context user does not have read access) if (item == null) { return; } foreach (SC.Globalization.Language language in item.Languages) { SC.Data.Items.Item version = item.Database.GetItem( item.ID, language); if (version != null && version.Versions.Count > 0) { return; } } SC.Diagnostics.Log.Warn( this + " : delete " + item.Paths.FullPath + " from " + item.Database.Name, this); item.Delete(); }
private void HandleMedia(SC.Data.Items.Item item) { // for media itemns if (item.Paths.IsMediaItem && item.TemplateID != SC.TemplateIDs.MediaFolder) { // add a link to open the media item in a new window or tab HtmlTableRow linkRow = new HtmlTableRow(); linkRow.Cells.Add(new HtmlTableCell() { ColSpan = 2, InnerHtml = string.Format( "<a target=\"_blank\" href=\"{0}\">{0}</a>", SC.Resources.Media.MediaManager.GetMediaUrl(item)) }); this.Metadata.Rows.Add(linkRow); // for images, add an <img> element with a link that opens the image in a new window or tab if (!string.IsNullOrEmpty(item["extension"]) && SC.Configuration.Settings.ImageTypes.Contains("|" + item["extension"] + "|")) { HtmlTableRow previewRow = new HtmlTableRow(); previewRow.Cells.Add(new HtmlTableCell() { InnerHtml = " " }); previewRow.Cells.Add(new HtmlTableCell() { InnerHtml = string.Format( "<a target=\"_blank\" href=\"{0}\"><img src=\"{0}\" alt=\"{1}\" /></a>", SC.Resources.Media.MediaManager.GetMediaUrl(item, new SC.Resources.Media.MediaUrlOptions() { MaxWidth = 400 }), item["alt"]) }); this.Metadata.Rows.Add(previewRow); } } }
private void BuildNavigation(SC.Data.Items.Item item) { // for media folders, include a link to the parent // (should be equivalent to the browser back button) if (item.Parent != null) { if (item.Parent.ID != item.Database.GetRootItem().ID) { this.LinkList.Controls.Add(this.GetLink( item.Parent, ".. (" + item.Parent.Name + ")")); } else { string layout = SC.Configuration.Settings.DefaultLayoutFile; if (!string.IsNullOrEmpty(layout)) { this.LinkList.Controls.Add(new LiteralControl(string.Format( "<li><img src=\"{0}\"> <a href=\"{1}\">.. (/sitecore)</a></li>", this.GetIcon(item.Database.GetRootItem()), layout))); } } } // if the folder has no contents if (!item.HasChildren) { this.Heading.InnerText += " (" + SC.Globalization.Translate.Text("contains no items" + ")"); } else { foreach (SC.Data.Items.Item child in item.Children) { this.LinkList.Controls.Add(this.GetLink(child)); } } }
private void ExecutePublishItem(string sourceDBName, string targetDBName, Sitecore.Data.Items.Item rootItem, bool withChildren, bool isRepubish) { try { using (new UserSwitcher(@"sitecore\admin", true)) { var sourceDB = Database.GetDatabase(sourceDBName); var targetDB = Database.GetDatabase(targetDBName); Sitecore.Publishing.PublishOptions publishOptions = null; if (!isRepubish) { publishOptions = new Sitecore.Publishing.PublishOptions(sourceDB, targetDB, Sitecore.Publishing.PublishMode.Smart, rootItem.Language, System.DateTime.Now); } else { publishOptions = new Sitecore.Publishing.PublishOptions(sourceDB, targetDB, Sitecore.Publishing.PublishMode.Full, rootItem.Language, System.DateTime.Now); } Sitecore.Publishing.Publisher publisher = new Sitecore.Publishing.Publisher(publishOptions); publisher.Options.RootItem = rootItem; publisher.Options.Deep = withChildren; publisher.Publish(); } } catch (Exception x) { Log.Error(x.Message, this); } }
/// <summary> /// Archives the old version. /// </summary> /// <param name="version">The old version to archive.</param> public override void HandleVersion(SC.Data.Items.Item version) { Assert.ArgumentNotNull(version, "version"); SC.Data.Archiving.Archive archive = version.Database.Archives["archive"]; if (archive != null) { SC.Diagnostics.Log.Audit( new object(), "Archive version: {0}", new string[] { SC.Diagnostics.AuditFormatter.FormatItem(version) }); archive.ArchiveVersion(version); } else { SC.Diagnostics.Log.Audit( this, "Recycle version : {0}", new string[] { SC.Diagnostics.AuditFormatter.FormatItem(version) }); version.RecycleVersion(); } }
/// <summary> /// Checks to see if there is a catalog item that maps to the current id /// </summary> /// <param name="itemId">The ID of the catalog item.</param> /// <param name="catalogName">The name of the catalog that contains the catalog item.</param> /// <param name="isProduct">Specifies whether the item is a product.</param> /// <returns>An item if found, otherwise null</returns> public static Sitecore.Data.Items.Item ResolveCatalogItem(string itemId, string catalogName, bool isProduct) { Sitecore.Data.Items.Item foundItem = null; // If we make it here, the right route was used, but might have an empty value if (!string.IsNullOrEmpty(itemId)) { var cachekey = "FriendlyUrl-" + itemId + "-" + catalogName; ICacheProvider cacheProvider = CommerceTypeLoader.GetCacheProvider(CommerceConstants.KnownCacheNames.FriendlyUrlsCache); var id = cacheProvider.GetData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey); if (ID.IsNullOrEmpty(id) || id == ID.Undefined) { if (isProduct) { foundItem = SearchNavigation.GetProduct(itemId, catalogName); } else { foundItem = SearchNavigation.GetCategory(itemId, catalogName); } if (foundItem != null) { cacheProvider.AddData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey, foundItem.ID); } else { cacheProvider.AddData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey, ID.Undefined); } } else if (id != ID.Undefined && id != ID.Null) { foundItem = Context.Database.GetItem(id); } } return(foundItem); }
public ActionResult constructDataPromotion() { string _penawaran = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._penawaran] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._penawaran].ToLower() : string.Empty; string _category = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._category] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._category].ToLower() : string.Empty; string _keyword = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._keyword] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._keyword].ToLower() : string.Empty; Guid idPenawaran = new Guid(); //bool _penawaranValid = Guid.TryParse(_penawaran, out idPenawaran); _penawaran = Guid.TryParse(_penawaran, out idPenawaran) == true ? _penawaran : string.Empty; Guid idCategory = new Guid(); //bool _categoryValid = Guid.TryParse(_category, out idCategory); _category = Guid.TryParse(_category, out idCategory) == true ? _category : string.Empty; var PageSize = RenderingContext.Current.Rendering.GetIntegerParameter("Max Item", 8); //GetDataFrom Promotion Repository Sitecore.Data.Items.Item dataSourceItem = RenderingContext.Current.Rendering.Item; IEnumerable <Data.Items.Item> items = this.Repository.Get(Sitecore.Context.Database.GetItem(new Data.ID("{18DC3A7D-0FEF-44E0-B947-98CA942846E9}"))); items = filterItem360(items, _penawaran, _category, _keyword, dataSourceItem); PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>(); if (items != null && items.Count() > 0) { listItems.Data = items.Take(PageSize); listItems.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)items.Count() / PageSize)); listItems.CurrentPage = 1; listItems.PageSize = PageSize; } listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID; return(View("ProductList360", listItems)); }
public void HowToCreateItemWithSpecificTemplate() { Sitecore.Data.ID templateId = Sitecore.Data.ID.NewID; using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db { new Sitecore.FakeDb.DbTemplate("products", templateId) { "Name" }, new Sitecore.FakeDb.DbItem("Apple") { TemplateID = templateId } }) { Sitecore.Data.Items.Item item = db.GetItem("/sitecore/content/apple"); Xunit.Assert.Equal(templateId, item.TemplateID); Xunit.Assert.NotNull(item.Fields["Name"]); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!txtNode.Text.Equals(string.Empty)) { using (new Sitecore.SecurityModel.SecurityDisabler()) { Sitecore.Data.Items.Item myRootItem = myContentDatabase.Items.GetItem(txtNode.Text); if (myRootItem != null) { RecursiveUnlockItems(myRootItem); } else { Response.Write("Node doesn't exsist"); } } } else { Response.Write("Fill a node into the field"); } }
protected override void DoRender(System.Web.UI.HtmlTextWriter output) { if (!string.IsNullOrEmpty(this.Field)) { Sitecore.Data.Items.Item i = this.GetItem(); if (i != null) { LinkField lf = (LinkField)i.Fields[this.Field]; if (lf != null && !lf.IsInternal && !lf.IsMediaLink) { PJones.OEmbed.OEmbedEngine eng = new OEmbedEngine(); string embed = eng.Parse(lf.Url, MaxWidth, MaxHeight); output.Write(embed); } } return; } else { throw new InvalidOperationException("Field property is required. All field web controls require the field name to be set."); } }
public void Run() { // Get the path to the message items string pathToMessageItems = Sitecore.Configuration.Settings.GetSetting("Messenger.ItemsPath", MessageItemsDefaultPath); try { Sitecore.Data.Items.Item messagesRootItem = Sitecore.Context.Database.GetItem(pathToMessageItems); if (messagesRootItem != null) { // Assume that all child items are message items // Remove any item whose expiration date is earlier than now Sitecore.Collections.ChildList messageItems = messagesRootItem.Children; foreach (Sitecore.Data.Items.Item item in messageItems) { if (item == null) { continue; } if (!string.IsNullOrEmpty(item["Broadcast Expiration"])) { DateTime expirationDate = ((Sitecore.Data.Fields.DateField)item.Fields["Broadcast Expiration"]).DateTime; if (expirationDate.CompareTo(DateTime.Now) >= 0) { item.Delete(); } } } } } catch (Exception x) { Sitecore.Diagnostics.Log.Warn("Message Cleanup Agent", x, this); } }
/// <summary> /// Returns True if the publishing target contains the item. /// </summary> /// <param name="item">The item to evaluate.</param> /// <param name="checkRevision">Whether to check the revision identifier, or just /// the existence of the item.</param> /// <returns>True if the publishinng target contains the item.</returns> public bool ContainsItem( Sitecore.Data.Items.Item item, bool checkRevision) { Sitecore.Diagnostics.Assert.IsNotNull(item, "item"); Sitecore.Data.Items.Item targetItem = this.Database.GetItem( item.ID, item.Language, Sitecore.Data.Version.Latest); if (targetItem == null) { return(false); } if (checkRevision && !item.IsSameRevision(targetItem)) { return(false); } return(true); }
public override void DoProcess(GetPresentationDataSourcesArgs args) { if (!(args.RawDataSource.StartsWith("/") || args.RawDataSource.StartsWith("{"))) { return; } foreach (string identifier in args.RawDataSource.Split('|')) { string[] parts = identifier.Split(':'); SC.Diagnostics.Assert.IsTrue(parts.Length > 0, "parts > 0"); SC.Diagnostics.Assert.IsTrue(parts.Length < 3, "parts < 3"); SC.Data.Items.Item item = args.ContextItem.Database.GetItem(parts[0]); if (item != null) { if (parts.Length > 1) { SC.Data.Fields.MultilistField field = item.Fields[parts[1]]; if (field == null || string.IsNullOrEmpty(field.Value)) { continue; } args.DataSourceItems.AddRange(field.GetItems()); return; } if (args.DataSourceItems == null) { args.DataSourceItems = new List <SC.Data.Items.Item>(); } args.DataSourceItems.Add(item); } } }
/// <summary> /// Maps the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="destination">The destination.</param> private void Map([NotNull] Sitecore.Data.Items.Item source, [NotNull] State destination) { Debug.ArgumentNotNull(source, "source"); Debug.ArgumentNotNull(destination, "destination"); destination.Code = source.Fields[CodeFieldName].Value; destination.Name = source.Fields[NameFieldName].Value; destination.Substates.Clear(); Sitecore.Data.Items.Item[] substateItems = source.Axes.SelectItems(string.Format("./{0}/*", SubstateContainerName)); if (substateItems != null) { foreach (Sitecore.Data.Items.Item item in substateItems) { Substate substate = new Substate(); this.Map(item, substate); destination.Substates.Add(substate); } } }
/// <summary> /// Return the items selected in the multilist field in the order specified by the /// source property of the field definition item rather than the order selected by /// the user. /// </summary> /// <param name="me">The multilist field.</param> /// <returns>The items selected in the multilist field in the order specified by /// the source property of the field definition item.</returns> public static Sitecore.Data.Items.Item[] GetItemsBySourceOrder( this Sitecore.Data.Fields.MultilistField me) { Sitecore.Diagnostics.Assert.IsNotNull(me, "me"); List <Sitecore.Data.Items.Item> userOrdered = new List <Sitecore.Data.Items.Item>(me.GetItems()); if (me.Count < 2) { return(userOrdered.ToArray()); } Sitecore.Data.Items.Item source = userOrdered[0].Database.GetItem(me.InnerField.Source); if (source == null) { return(userOrdered.ToArray()); } return(GetChildrenInOrder(source, userOrdered)); }
public void Execute( XElement element, string name, SC.Text.UrlString parameters, string value) { SC.Diagnostics.Assert.ArgumentNotNull(element, "element"); SC.Diagnostics.Assert.ArgumentNotNull(name, "name"); SC.Diagnostics.Assert.ArgumentNotNull(parameters, "parameters"); SC.Diagnostics.Assert.ArgumentNotNull(value, "value"); SC.Diagnostics.Assert.IsNotNull( SC.Context.ContentDatabase, "Sitecore.Context.ContentDatabase"); SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions options = new SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions(); if (!String.IsNullOrEmpty(value)) { SC.Data.Items.Item item = Client.ContentDatabase.GetItem(value); if (item != null) { options.SelectedItem = item; } } options.Root = Client.ContentDatabase.GetItem(SC.ItemIDs.WorkflowRoot); SC.Data.Items.TemplateItem workflowCommandTemplate = SC.Context.ContentDatabase.GetTemplate( SC.TemplateIDs.WorkflowCommand); SC.Diagnostics.Assert.IsNotNull(workflowCommandTemplate, "workflowCommandTemplate"); options.IncludeTemplatesForSelection = SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions.GetTemplateList( workflowCommandTemplate.GetSelfAndDerivedTemplates()); options.Title = "Select Workflow Command"; options.Text = "Select the workflow command to use in this rule."; options.Icon = "Applications/16x16/nav_right_green.png"; SC.Web.UI.Sheer.SheerResponse.ShowModalDialog( options.ToUrlString().ToString(), true); }
public ItemAdapter(Sitecore.Data.Items.Item item) { m_item = item; }
public FixedSearchContext(Sitecore.Data.Items.Item item) { this._item = item; }
public FixedSearchContext(Sitecore.Security.Accounts.User user, Sitecore.Data.Items.Item item) { this._user = user; this._item = item; }
/// <summary> /// Initializes a new instance of the <see cref="VariantViewModel"/> class. /// </summary> /// <param name="item">The sitecore item for the related page</param> public VariantViewModel(Sitecore.Data.Items.Item item) { this._item = item; }