public static HtmlString RenderDate( this SC.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, string format = "D", bool disableWebEdit = false, bool setCulture = true, SC.Collections.SafeDictionary <string> parameters = null) { if (setCulture) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(SC.Context.Language.Name); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SC.Context.Language.Name); } if (parameters == null) { parameters = new SC.Collections.SafeDictionary <string>(); } parameters["format"] = format; return(RenderField( sitecoreHelper, fieldNameOrId, disableWebEdit, parameters)); }
public static HtmlString RenderField( this SC.Mvc.Helpers.SitecoreHelper sitecoreHelper, SC.Data.ID fieldId, bool disableWebEdit = false, SC.Collections.SafeDictionary <string> parameters = null) { return(RenderField( sitecoreHelper, fieldId.ToString(), disableWebEdit, parameters)); }
public static HtmlString RenderDate( this SC.Mvc.Helpers.SitecoreHelper sitecoreHelper, SC.Data.ID fieldId, string format = "D", bool disableWebEdit = false, bool setCulture = true, SC.Collections.SafeDictionary <string> parameters = null) { return(RenderDate( sitecoreHelper, fieldId.ToString(), format, disableWebEdit, setCulture, parameters)); }
public static HtmlString RenderField( this SC.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, bool disableWebEdit = false, SC.Collections.SafeDictionary <string> parameters = null) { if (parameters == null) { parameters = new SC.Collections.SafeDictionary <string>(); } return(sitecoreHelper.Field( fieldNameOrId, new { DisableWebEdit = disableWebEdit, Parameters = parameters })); }
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>"); } } } }
public static HtmlString TagField( this SC.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, string htmlElement, bool disableWebEdit = false, SC.Collections.SafeDictionary <string> parameters = null) { SC.Data.Items.Item item = SC.Mvc.Presentation.RenderingContext.Current.ContextItem; if (item == null || String.IsNullOrEmpty(item[fieldNameOrId])) { return(new HtmlString(String.Empty)); } string value = sitecoreHelper.RenderField( fieldNameOrId, disableWebEdit, parameters).ToString(); return(new HtmlString(String.Format( "<{0}>{1}</{0}>", htmlElement, value))); }
// rewrite the Source property // set selectFirstItem now rather than parsing again later protected void ProcessSource(string originalSource) { if ((!string.IsNullOrEmpty(originalSource)) && this.Source.Contains("{itemfield:")) { MatchCollection matches = Regex.Matches( originalSource, "(?<match>\\{itemfield\\:(?<field>[^\\}]+)})"); Assert.IsTrue(matches.Count > 0, "matches > 0"); foreach (Match match in matches) { foreach (Group group in match.Groups) { originalSource = originalSource.Replace( match.Groups["match"].Value, this.CurrentItem[match.Groups["field"].Value]); } } } // If the Source contains a single value, convert it to a // key=value pair. if (originalSource.StartsWith("query:") || originalSource.StartsWith("~") || originalSource.StartsWith("/") || originalSource.StartsWith(".")) { originalSource = "DataSource=" + originalSource; } SC.Collections.SafeDictionary <string> parameters = SC.Web.WebUtil.ParseQueryString(originalSource); string databaseName = parameters["DatabaseName"]; if (String.IsNullOrEmpty(databaseName)) { this.database = this.CurrentItem.Database; } else { this.database = SC.Configuration.Factory.GetDatabase(databaseName); SC.Diagnostics.Assert.IsNotNull(this.database, "database"); } string dataSource = parameters["DataSource"]; if (!(string.IsNullOrEmpty(dataSource) || dataSource.StartsWith("~"))) { parameters["DataSource"] = this.ExpandDataSource(dataSource); } string sortBy = parameters["SortBy"]; if (!string.IsNullOrEmpty(sortBy)) { this.SortBy = sortBy; parameters.Remove("SortBy"); } string display = parameters["Display"]; if (!string.IsNullOrEmpty(display)) { this.Display = display; parameters.Remove("Display"); } string displayInTree = parameters["DisplayInTree"]; if (displayInTree != null) { this.DisplayFieldName = displayInTree; parameters.Remove("DisplayInTree"); } string includeItemsForDisplay = parameters["IncludeItemsForDisplay"]; if ((!string.IsNullOrEmpty(includeItemsForDisplay) && includeItemsForDisplay.StartsWith("query:"))) { parameters["IncludeItemsForDisplay"] = this.CalculateIncludeItemsForDisplay(includeItemsForDisplay); } this.selectFirstItem = parameters["SelectFirstItem"]; this.Source = SC.Web.WebUtil.BuildQueryString(parameters, false); }
// rewrite the Source property // set selectFirstItem now rather than parsing again later protected void ProcessSource(string originalSource) { // If the Source contains a single value, convert it to a // key=value pair. if (originalSource.StartsWith("query:") || originalSource.StartsWith("~") || originalSource.StartsWith("/") || originalSource.StartsWith(".")) { originalSource = "DataSource=" + originalSource; } SC.Collections.SafeDictionary <string> parameters = SC.Web.WebUtil.ParseQueryString(originalSource); string databaseName = parameters["DatabaseName"]; if (String.IsNullOrEmpty(databaseName)) { this.database = this.CurrentItem.Database; } else { this.database = SC.Configuration.Factory.GetDatabase(databaseName); SC.Diagnostics.Assert.IsNotNull(this.database, "database"); } string dataSource = parameters["DataSource"]; if (!(string.IsNullOrEmpty(dataSource) || dataSource.StartsWith("~"))) { parameters["DataSource"] = this.ExpandDataSource(dataSource); } string sortBy = parameters["SortBy"]; if (!string.IsNullOrEmpty(sortBy)) { this.SortBy = sortBy; parameters.Remove("SortBy"); } string display = parameters["Display"]; if (!string.IsNullOrEmpty(display)) { this.Display = display; parameters.Remove("Display"); } string displayInTree = parameters["DisplayInTree"]; if (displayInTree != null) { this.DisplayFieldName = displayInTree; parameters.Remove("DisplayInTree"); } string includeItemsForDisplay = parameters["IncludeItemsForDisplay"]; if ((!string.IsNullOrEmpty(includeItemsForDisplay) && includeItemsForDisplay.StartsWith("query:"))) { parameters["IncludeItemsForDisplay"] = this.CalculateIncludeItemsForDisplay(includeItemsForDisplay); } this.selectFirstItem = parameters["SelectFirstItem"]; this.Source = SC.Web.WebUtil.BuildQueryString(parameters, false); }