private void AddMyProperties() { string propDefinitionKey = DefinitionsHelper.GetPropertiesDefinitionKey <Artech.Architecture.Common.Objects.KBModel>(); PropertiesDefinition myTrnProperties = new PropertiesDefinition(propDefinitionKey); PropDefinition myBool = new PropDefinition("Code Review Tool", typeof(Tool), null, "Tool for code review"); myTrnProperties.Add(myBool); base.AddPropertiesDefinition(propDefinitionKey, myTrnProperties); }
/// <summary> /// Initializes the controls. /// </summary> /// <param name="container">The controls container.</param> /// <param name="definition">The content view definition.</param> protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition) { var masterDefinition = definition as IContentViewMasterDefinition; if (masterDefinition != null) { var query = this.Manager.GetProducts(); if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value) { query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Taxonomy", string.Empty, typeof(ProductItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } int?totalCount = 0; int?itemsToSkip = 0; if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value) { itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } CultureInfo uiCulture = null; if (AppSettings.CurrentSettings.Multilingual) { uiCulture = System.Globalization.CultureInfo.CurrentUICulture; } //the filter is adapted to the implementation of ILifecycleDataItemGeneric, so the culture is taken in advance when filtering published items. this.FilterExpression = ContentHelper.AdaptMultilingualFilterExpression(this.FilterExpression); var filterExpression = DefinitionsHelper.GetFilterExpression(this.FilterExpression, this.AdditionalFilter); query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions( query, filterExpression, masterDefinition.SortExpression, uiCulture, itemsToSkip, masterDefinition.ItemsPerPage, ref totalCount); this.IsEmptyView = (totalCount == 0); if (totalCount == 0) { this.NewsList.Visible = false; } else { this.ConfigurePager(totalCount.Value, masterDefinition); this.NewsList.DataSource = query.ToList(); this.NewsList.PreRender += new EventHandler(NewsList_PreRender); } } }
/// <summary> /// Initializes the controls. /// </summary> /// <param name="container">The controls container.</param> /// <param name="definition">The content view definition.</param> protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition) { var masterDefinition = definition as IContentViewMasterDefinition; if (masterDefinition != null) { var query = this.Manager.GetAgents(); if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value) { query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Taxonomy", "", typeof(AgentItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } int?totalCount = 0; int?itemsToSkip = 0; if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value) { itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } CultureInfo uiCulture = null; if (Config.Get <ResourcesConfig>().Multilingual) { uiCulture = System.Globalization.CultureInfo.CurrentUICulture; } var filterExpression = DefinitionsHelper.GetFilterExpression(masterDefinition); query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions( query, filterExpression, masterDefinition.SortExpression, uiCulture, itemsToSkip, masterDefinition.ItemsPerPage, ref totalCount); this.IsEmptyView = (totalCount == 0); if (totalCount == 0) { this.AgentsListControl.Visible = false; } else { this.ConfigurePager(totalCount.Value, masterDefinition); this.librariesManager.Provider.SuppressSecurityChecks = true; this.AgentsListControl.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(AgentsListControl_ItemDataBound); this.AgentsListControl.DataSource = query.ToList(); } } }
public static CommandWidgetElement CreateActionMenuCommand( ConfigElement parent, string name, HtmlTextWriterTag wrapperTagKey, string commandName, string text, string resourceClassId, string cssClass) { var commandWidgetElement = DefinitionsHelper.CreateActionMenuCommand(parent, name, wrapperTagKey, commandName, text, resourceClassId); commandWidgetElement.CssClass = cssClass; return(commandWidgetElement); }
/// <summary> /// Defines the jobs backend content view. /// </summary> /// <param name="parent">The parent.</param> /// <returns></returns> public static ContentViewControlElement DefineJobsBackendContentView(ConfigElement parent) { // define content view control var backendContentView = new ContentViewControlElement(parent) { ControlDefinitionName = BackendDefinitionName, ContentType = typeof(JobApplication) }; // define views var jobsGridView = new MasterGridViewElement(backendContentView.ViewsConfig) { ViewName = JobsDefinitions.BackendListViewName, ViewType = typeof(MasterGridView), AllowPaging = true, DisplayMode = FieldDisplayMode.Read, ItemsPerPage = 50, ResourceClassId = typeof(JobsResources).Name, Title = "JobsViewTitle", WebServiceBaseUrl = "~/Sitefinity/Services/Content/Jobs.svc/", }; // define columns var gridMode = new GridViewModeElement(jobsGridView.ViewModesConfig) { Name = "Grid", }; jobsGridView.ViewModesConfig.Add(gridMode); DataColumnElement firstNameColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "FirstName", HeaderText = Res.Get <JobsResources>().FirstName, ClientTemplate = "<span>{{FirstName}}</span>", HeaderCssClass = "sfRegular", ItemCssClass = "sfRegular" }; gridMode.ColumnsConfig.Add(firstNameColumn); DataColumnElement lastNameColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "LastName", HeaderText = Res.Get <JobsResources>().LastName, ClientTemplate = "<span>{{LastName}}</span>", HeaderCssClass = "sfRegular", ItemCssClass = "sfRegular" }; gridMode.ColumnsConfig.Add(lastNameColumn); DataColumnElement phoneColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "Phone", HeaderText = Res.Get <JobsResources>().PhoneNumber, ClientTemplate = "<span>{{Phone}}</span>", HeaderCssClass = "sfRegular", ItemCssClass = "sfRegular" }; gridMode.ColumnsConfig.Add(phoneColumn); DataColumnElement refferalColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "Refferal", HeaderText = Res.Get <JobsResources>().Referrer, ClientTemplate = "<span>{{Referral}}</span>", HeaderCssClass = "sfRegular", ItemCssClass = "sfRegular" }; gridMode.ColumnsConfig.Add(refferalColumn); ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig) { Name = "Actions", HeaderText = Res.Get <Labels>().Actions, HeaderCssClass = "sfMoreActions", ItemCssClass = "sfMoreActions" }; FillActionMenuItems(actionsColumn.MenuItems, actionsColumn, typeof(JobsResources).Name); gridMode.ColumnsConfig.Add(actionsColumn); DataColumnElement authorColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "Author", HeaderText = Res.Get <Labels>().Author, ClientTemplate = "<span>{{Author}}</span>", HeaderCssClass = "sfRegular", ItemCssClass = "sfRegular" }; gridMode.ColumnsConfig.Add(authorColumn); DataColumnElement dateColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "Date", HeaderText = Res.Get <Labels>().Date, ClientTemplate = "<span>{{ (DateCreated) ? DateCreated.sitefinityLocaleFormat('dd MMM, yyyy hh:mm:ss'): '-' }}</span>", HeaderCssClass = "sfDate", ItemCssClass = "sfDate" }; gridMode.ColumnsConfig.Add(dateColumn); backendContentView.ViewsConfig.Add(jobsGridView); var parameters = string.Concat( "?ControlDefinitionName=", JobsDefinitions.BackendDefinitionName, "&ViewName=", JobsDefinitions.BackendEditViewName); DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement( jobsGridView.DialogsConfig, DefinitionsHelper.EditCommandName, "ContentViewEditDialog", parameters); jobsGridView.DialogsConfig.Add(editDialogElement); var jobsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig) { Title = "EditItem", ViewName = JobsDefinitions.BackendEditViewName, ViewType = typeof(DetailFormView), ShowSections = true, DisplayMode = FieldDisplayMode.Write, ShowTopToolbar = true, ResourceClassId = typeof(JobsResources).Name, WebServiceBaseUrl = "~/Sitefinity/Services/Content/Jobs.svc/", IsToRenderTranslationView = false, UseWorkflow = false }; backendContentView.ViewsConfig.Add(jobsEditDetailView); JobsDefinitions.CreateBackendSections(jobsEditDetailView, FieldDisplayMode.Write); JobsDefinitions.CreateBackendFormToolbar(jobsEditDetailView, typeof(JobsResources).Name, false); return(backendContentView); }
/// <summary> /// Defines the locations backend content view (control panel and views). /// </summary> /// <param name="parent">The parent element hosting the backend content view.</param> /// <returns></returns> public static ContentViewControlElement DefineLocationsBackendContentView(ConfigElement parent) { // initialize the content view; this is the element that will be returned to the page and holds all views of the admin panel var backendContentView = new ContentViewControlElement(parent) { ControlDefinitionName = BackendDefinitionName, ContentType = typeof(LocationItem), UseWorkflow = false }; // GridView element serves as the "List View" for the item list. Grid columns are defined later var locationsGridView = new MasterGridViewElement(backendContentView.ViewsConfig) { ViewName = LocationsDefinitions.BackendListViewName, ViewType = typeof(MasterGridView), AllowPaging = true, DisplayMode = FieldDisplayMode.Read, ItemsPerPage = 50, SearchFields = "Title", SortExpression = "Title ASC", Title = "Locations", WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/" }; backendContentView.ViewsConfig.Add(locationsGridView); #region Module Main Toolbar definition // Toolbar is the top menu with action buttons such as Create, Delete, Search, etc. var masterViewToolbarSection = new WidgetBarSectionElement(locationsGridView.ToolbarConfig.Sections) { Name = "Toolbar" }; // "Create" Button for Toolbar var createLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items) { Name = "CreateLocationsCommandWidget", ButtonType = CommandButtonType.Create, CommandName = DefinitionsHelper.CreateCommandName, Text = "Create Location", CssClass = "sfMainAction", WidgetType = typeof(CommandWidget) }; masterViewToolbarSection.Items.Add(createLocationsWidget); // "Delete" button for Toolbar var deleteLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items) { Name = "DeleteLocationsCommandWidget", ButtonType = CommandButtonType.Standard, CommandName = DefinitionsHelper.GroupDeleteCommandName, Text = "Delete", WidgetType = typeof(CommandWidget), CssClass = "sfGroupBtn" }; masterViewToolbarSection.Items.Add(deleteLocationsWidget); // "Search" button for toolbar masterViewToolbarSection.Items.Add(DefinitionsHelper.CreateSearchButtonWidget(masterViewToolbarSection.Items, typeof(LocationItem))); locationsGridView.ToolbarConfig.Sections.Add(masterViewToolbarSection); #endregion #region Locations Grid (List View) // Define GridView mode var gridMode = new GridViewModeElement(locationsGridView.ViewModesConfig) { Name = "Grid" }; locationsGridView.ViewModesConfig.Add(gridMode); #region Locations Grid Columns // Title column DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig) { Name = "Title", HeaderText = "Title", HeaderCssClass = "sfTitleCol", ItemCssClass = "sfTitleCol", ClientTemplate = @"<a sys:href='javascript:void(0);' sys:class=""{{ 'sf_binderCommand_edit sfItemTitle sfpublished""> <strong>{{Title}}</strong></a>" }; gridMode.ColumnsConfig.Add(titleColumn); ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig) { Name = "Actions", HeaderText = "Actions", HeaderCssClass = "sfMoreActions", ItemCssClass = "sfMoreActions" }; actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "View", HtmlTextWriterTag.Li, "preview", "View", string.Empty)); actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "Delete", HtmlTextWriterTag.Li, "delete", "Delete", string.Empty)); gridMode.ColumnsConfig.Add(actionsColumn); #endregion #endregion #region Dialog Window definitions #region Insert Item Dialog // Insert Item Parameters var parameters = string.Concat( "?ControlDefinitionName=", LocationsDefinitions.BackendDefinitionName, "&ViewName=", LocationsDefinitions.BackendInsertViewName); // Insert Item Dialog DialogElement createDialogElement = DefinitionsHelper.CreateDialogElement( locationsGridView.DialogsConfig, DefinitionsHelper.CreateCommandName, "ContentViewInsertDialog", parameters); // add dialog to Backend locationsGridView.DialogsConfig.Add(createDialogElement); #endregion #region Edit Item Dialog // "Edit Item" Parameters parameters = string.Concat( "?ControlDefinitionName=", LocationsDefinitions.BackendDefinitionName, "&ViewName=", LocationsDefinitions.BackendEditViewName); // "Edit Item" Dialog DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement( locationsGridView.DialogsConfig, DefinitionsHelper.EditCommandName, "ContentViewEditDialog", parameters); // Add Dialog to Backend locationsGridView.DialogsConfig.Add(editDialogElement); #endregion #region Preview Item Dialog // "Preview Item" parameters parameters = string.Concat( "?ControlDefinitionName=", LocationsDefinitions.BackendDefinitionName, "&ViewName=", LocationsDefinitions.BackendPreviewName, "&backLabelText=", "BacktoItems", "&SuppressBackToButtonLabelModify=true"); // Preview Item Dialog DialogElement previewDialogElement = DefinitionsHelper.CreateDialogElement( locationsGridView.DialogsConfig, DefinitionsHelper.PreviewCommandName, "ContentViewEditDialog", parameters); // Add Dialog to Backend locationsGridView.DialogsConfig.Add(previewDialogElement); #endregion #endregion #region Admin Forms Views #region Create Item Form View // bind create item view to web service var locationsInsertDetailView = new DetailFormViewElement(backendContentView.ViewsConfig) { Title = "Create Location", ViewName = LocationsDefinitions.BackendInsertViewName, ViewType = typeof(DetailFormView), ShowSections = true, DisplayMode = FieldDisplayMode.Write, ShowTopToolbar = true, WebServiceBaseUrl = "~/Sitefinity/Services/Content/locations.svc/", IsToRenderTranslationView = false, UseWorkflow = false }; backendContentView.ViewsConfig.Add(locationsInsertDetailView); #endregion #region Edit Item Form View // bind Edit item form to web service var locationsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig) { Title = "Edit Location", ViewName = LocationsDefinitions.BackendEditViewName, ViewType = typeof(DetailFormView), ShowSections = true, DisplayMode = FieldDisplayMode.Write, ShowTopToolbar = true, WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/", IsToRenderTranslationView = false, UseWorkflow = false }; backendContentView.ViewsConfig.Add(locationsEditDetailView); #endregion #region Preview Item Form View // bind Preview Form to web service var locationsPreviewDetailView = new DetailFormViewElement(backendContentView.ViewsConfig) { Title = "Location Preview", ViewName = LocationsDefinitions.BackendPreviewName, ViewType = typeof(DetailFormView), ShowSections = true, DisplayMode = FieldDisplayMode.Read, ShowTopToolbar = true, ShowNavigation = true, WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/", UseWorkflow = false }; backendContentView.ViewsConfig.Add(locationsPreviewDetailView); #endregion #endregion #region Locations Backend Forms Definition #region Insert Form LocationsDefinitions.CreateBackendSections(locationsInsertDetailView, FieldDisplayMode.Write); LocationsDefinitions.CreateBackendFormToolbar(locationsInsertDetailView, true, true); #endregion #region Edit Form LocationsDefinitions.CreateBackendSections(locationsEditDetailView, FieldDisplayMode.Write); LocationsDefinitions.CreateBackendFormToolbar(locationsEditDetailView, false, true); #endregion #region Preview Form CreateBackendSections(locationsPreviewDetailView, FieldDisplayMode.Read); #endregion #endregion return(backendContentView); }
private void BindItems() { isThumbView = this.IsThumbView(); int itemsPerPage = ItemsPerPage(); string sortBy = SortBy(); string sortDir = SortDir(); lbnItemPerPage_Nine.CssClass = string.Empty; lbnItemPerPage_Eighteen.CssClass = string.Empty; lbnItemPerPage_Twentyseven.CssClass = string.Empty; switch (itemsPerPage) { case 9: lbnItemPerPage_Nine.CssClass = "current"; break; case 18: lbnItemPerPage_Eighteen.CssClass = "current"; break; case 27: lbnItemPerPage_Twentyseven.CssClass = "current"; break; } if (sortBy.Equals("price", StringComparison.OrdinalIgnoreCase)) { if (sortDir.Equals("desc", StringComparison.OrdinalIgnoreCase)) { lbnSortBy_Price.CssClass = "arrow-down current"; } else { lbnSortBy_Price.CssClass = "arrow-up current"; } } var masterDefinition = this.MasterViewDefinition as IContentViewMasterDefinition; if (masterDefinition != null) { var query = this.Manager.GetItems(); if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value) { query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); query = this.EvaluateUrl(query, "Taxonomy", "", typeof(RealEstateItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } int?totalCount = 0; int?itemsToSkip = 0; if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value) { itemsToSkip = this.GetItemsToSkipCount(ItemsPerPage(), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix); } CultureInfo uiCulture = null; if (Config.Get <ResourcesConfig>().Multilingual) { uiCulture = System.Globalization.CultureInfo.CurrentUICulture; } string sortExpression = "Price "; if (sortBy.Equals("location", StringComparison.OrdinalIgnoreCase)) { sortExpression = "Locations "; } sortExpression += sortDir; var filterExpression = DefinitionsHelper.GetFilterExpression(masterDefinition); query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions( query, filterExpression, SortBy() + " " + SortDir(), uiCulture, itemsToSkip, itemsPerPage, ref totalCount); this.IsEmptyView = (totalCount == 0); if (totalCount == 0) { this.ItemsList_Flow.Visible = false; this.ItemsList_Thumb.Visible = false; } else { this.ConfigurePager(totalCount.Value, masterDefinition); this.librariesManager.Provider.SuppressSecurityChecks = true; if (this.IsThumbView()) { this.ItemsList_Thumb.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(ItemsListControl_ItemDataBound); this.ItemsList_Thumb.DataSource = query; this.ItemsList_Thumb.Visible = true; this.ItemsList_Flow.Visible = false; lbnThumbnailView.CssClass = "thumbnails current"; lbnListView.CssClass = "list"; } else { this.ItemsList_Flow.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(ItemsListControl_ItemDataBound); this.ItemsList_Flow.DataSource = query; this.ItemsList_Flow.Visible = true; this.ItemsList_Thumb.Visible = false; lbnListView.CssClass = "list current"; lbnThumbnailView.CssClass = "thumbnails"; } } } }