public ActionResult WidgetsByZone(WidgetZone widgetZone) { //model var model = new List<WidgetModel>(); var widgets = _widgetService.GetAllWidgetsByZone(widgetZone); foreach (var widget in widgets) { var widgetPlugin = _widgetService.LoadWidgetPluginBySystemName(widget.PluginSystemName); if (widgetPlugin == null || !widgetPlugin.PluginDescriptor.Installed) continue; //don't throw an exception. just process next widget. var widgetModel = new WidgetModel(); string actionName; string controllerName; RouteValueDictionary routeValues; widgetPlugin.GetDisplayWidgetRoute(widget.Id, out actionName, out controllerName, out routeValues); widgetModel.ActionName = actionName; widgetModel.ControllerName = controllerName; widgetModel.RouteValues = routeValues; model.Add(widgetModel); } return PartialView(model); }
/// <summary> /// Save widget zone store mappings /// </summary> /// <param name="model">Widget zone model</param> /// <param name="widgetZone">Widget zone entity</param> protected virtual void SaveWidgetZoneStoreMappings(WidgetZoneModel model, WidgetZone widgetZone) { var existingStoreMappings = _storeMappingService.GetStoreMappings(widgetZone); var allStores = _storeService.GetAllStores(); //process store mappings foreach (var store in allStores) { if (model.SelectedStoreIds.Contains(store.Id)) { //add new store mapping if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0) { _storeMappingService.InsertStoreMapping(widgetZone, store.Id); } } else { //remove store mapping var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) { _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } } }
/// <summary> /// Prepare widget zone model /// </summary> /// <param name="widgetZone">Widget zone entity</param> /// <returns>Widget zone model</returns> public virtual WidgetZoneModel PrepareWidgetZoneModel(WidgetZone widgetZone) { var languageId = _workContext.WorkingLanguage.Id; var storeId = _storeContext.CurrentStore.Id; return(PrepareWidgetZoneModel(widgetZone, languageId, storeId)); }
public static void Initialize(HttpContext context) { if (_initializedAlready) { return; } lock (_SyncRoot) { if (_initializedAlready) { return; } WidgetZone.PreloadWidgetsAsync("be_WIDGET_ZONE"); Utils.LoadExtensions(); BlogEngineConfig.RegisterBundles(BundleTable.Bundles); BlogEngineConfig.RegisterWebApi(GlobalConfiguration.Configuration); RegisterUnity(GlobalConfiguration.Configuration); ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "~/Scripts/jquery-1.9.1.min.js", DebugPath = "~/Scripts/jquery-1.9.1.js", CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.9.1.min.js", CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.9.1.js" }); _initializedAlready = true; } }
/// <summary> /// Save widget zone ACL /// </summary> /// <param name="model">Widget zone model</param> /// <param name="widgetZone">Widget zone entity</param> protected virtual void SaveWidgetZoneAcl(WidgetZoneModel model, WidgetZone widgetZone) { var existingAclRecords = _aclService.GetAclRecords(widgetZone); var allCustomerRoles = _customerService.GetAllCustomerRoles(true); //processing customer roles dependencies foreach (var customerRole in allCustomerRoles) { if (model.SelectedCustomerRoleIds.Contains(customerRole.Id)) { //add new role dependecy if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0) { _aclService.InsertAclRecord(widgetZone, customerRole.Id); } } else { //remove role dependency var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id); if (aclRecordToDelete != null) { _aclService.DeleteAclRecord(aclRecordToDelete); } } } }
/// <summary> /// Prepare widget zone ACL model /// </summary> /// <param name="widgetZoneModel">Widget zone model</param> /// <param name="widgetZone">Widget zone entity</param> public virtual void PrepareAclModel(WidgetZoneModel widgetZoneModel, WidgetZone widgetZone) { if (widgetZoneModel == null) { throw new Exception("Widget zone model are null."); } //prepare widget zone customer roles if (widgetZone != null) { widgetZoneModel.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(widgetZone).ToList(); } //prepare available customer roles list var customerRoles = _customerService.GetAllCustomerRoles(true); widgetZoneModel.AvailableCustomerRoles = customerRoles.Select(x => { return(new SelectListItem() { Value = x.Id.ToString(), Text = x.Name, Selected = widgetZoneModel.SelectedCustomerRoleIds.Contains(x.Id) }); }).ToList(); }
/// <summary> /// Prepare widget zone store mappings /// </summary> /// <param name="widgetZoneModel">Widget zone model</param> /// <param name="widgetZone">Widget zone entity</param> public virtual void PrepareStoreMappings(WidgetZoneModel widgetZoneModel, WidgetZone widgetZone) { if (widgetZoneModel == null) { throw new Exception("Widget zone model are null."); } //load selected stores for current widget zone if (widgetZone != null) { widgetZoneModel.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(widgetZone).ToList(); } //get all available stores var availableStores = _storeService.GetAllStores(); widgetZoneModel.AvailableStores = availableStores.Select(x => { return(new SelectListItem() { Value = x.Id.ToString(), Text = x.Name, Selected = widgetZoneModel.SelectedStoreIds.Contains(x.Id) }); }).ToList(); }
public ActionResult WidgetsByZone(WidgetZone widgetZone) { //model var model = new List <WidgetModel>(); var widgets = _widgetService.GetAllWidgetsByZone(widgetZone); foreach (var widget in widgets) { var widgetPlugin = _widgetService.LoadWidgetPluginBySystemName(widget.PluginSystemName); if (widgetPlugin == null || !widgetPlugin.PluginDescriptor.Installed) { continue; //don't throw an exception. just process next widget. } var widgetModel = new WidgetModel(); string actionName; string controllerName; RouteValueDictionary routeValues; widgetPlugin.GetDisplayWidgetRoute(widget.Id, out actionName, out controllerName, out routeValues); widgetModel.ActionName = actionName; widgetModel.ControllerName = controllerName; widgetModel.RouteValues = routeValues; model.Add(widgetModel); } return(PartialView(model)); }
/// <summary> /// Gets all widgets by zone /// </summary> /// <param name="widgetZone">Widget zone</param> /// <returns>Widgets</returns> public virtual IList<Widget> GetAllWidgetsByZone(WidgetZone widgetZone) { var allWidgets = GetAllWidgets(); var widgets = allWidgets .Where(w => w.WidgetZone == widgetZone) .OrderBy(w => w.DisplayOrder) .ToList(); return widgets; }
/// <summary> /// Helper function to get the comma-separated <c>WidgetZone</c> property as an enumerable of strings. /// </summary> /// <returns>Widget zones.</returns> public IEnumerable <string> GetWidgetZones() { if (WidgetZone.IsEmpty()) { return(Enumerable.Empty <string>()); } return(WidgetZone.Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())); }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { var widgetZone = DatabaseHelper.GetSingle <WidgetZone, int, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, this.PageId, this.ColumnNo, LinqQueries.CompiledQuery_GetWidgetZoneByPageId_ColumnNo); this.WidgetZone = widgetZone; return(ActivityExecutionStatus.Closed); }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { var widgetZone = DatabaseHelper.GetSingle<WidgetZone, int, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, this.PageId, this.ColumnNo, LinqQueries.CompiledQuery_GetWidgetZoneByPageId_ColumnNo); this.WidgetZone = widgetZone; return ActivityExecutionStatus.Closed; }
/// <summary> /// Gets all widgets by zone /// </summary> /// <param name="widgetZone">Widget zone</param> /// <returns>Widgets</returns> public virtual IList <Widget> GetAllWidgetsByZone(WidgetZone widgetZone) { var allWidgets = GetAllWidgets(); var widgets = allWidgets .Where(w => w.WidgetZone == widgetZone) .OrderBy(w => w.DisplayOrder) .ToList(); return(widgets); }
public void DeleteColumn(int pageId, int columnNo) { var columnToDelete = this.columnRepository.GetColumnByTabId_ColumnNo(pageId, columnNo); WidgetZone widgetZone = this.widgetZoneRepository.GetWidgetZoneByTabId_ColumnNo(pageId, columnNo); var widgetInstances = this.GetWidgetInstancesInZoneWithWidget(widgetZone.ID); widgetInstances.Each((widgetInstance) => this.widgetInstanceRepository.Delete(widgetInstance.Id)); this.columnRepository.Delete(columnToDelete); this.widgetZoneRepository.Delete(widgetZone); }
protected virtual WidgetZoneModel PrepareSliderModel(WidgetZone widgetZone, int languageId, int storeId) { //prepare slider model var model = new WidgetZoneModel() { Id = widgetZone.Id, AutoPlay = widgetZone.AutoPlay, AutoPlayInterval = widgetZone.AutoPlayInterval, MinDragOffsetToSlide = widgetZone.MinDragOffsetToSlide, SlideDuration = widgetZone.SlideDuration, SlideSpacing = widgetZone.SlideSpacing, ArrowNavigation = widgetZone.ArrowNavigationDisplayingTypeId, BulletNavigation = widgetZone.BulletNavigationDisplayingTypeId, MinSliderWidth = widgetZone.MinSlideWidgetZoneWidth, MaxSliderWidth = widgetZone.MaxSlideWidgetZoneWidth }; //add slide models to widget zone slider var widgetZoneSlides = _widgetZoneSlideService.GetWidgetZoneSlides(widgetZone.Id).OrderBy(s => s.DisplayOrder); foreach (var widgetSlide in widgetZoneSlides) { var slide = _slideService.GetSlideById(widgetSlide.SlideId); //don't display unpublished slides if (!slide.Published) { continue; } var today = slide.PublishToday(); var acl = _aclService.Authorize(slide); var store = _storeMappingService.Authorize(slide, storeId); //don't display slides, which shouldn't displays today or not authorized via ACL or not authorized in store var display = slide.PublishToday() && _aclService.Authorize(slide) && _storeMappingService.Authorize(slide, storeId); if (!display) { continue; } //prepare slide model var slideModel = PrepareSlideModel(widgetSlide, slide, languageId); //add slide model to slider model.Slides.Add(slideModel); } return(model); }
public static List <WidgetZone> SubdivideZoneForWidget(WidgetZone zone, Widget widget) { List <WidgetZone> list = new List <WidgetZone>(); int x; int z; if (widget.SizeX <= zone.SizeX && widget.SizeZ <= zone.SizeZ) { widget.Rotate = false; x = zone.SizeX - widget.SizeX; z = zone.SizeZ - widget.SizeZ; } else { if (widget.SizeX > zone.SizeZ || widget.SizeZ > zone.SizeX) { return(null); } widget.Rotate = true; x = zone.SizeX - widget.SizeZ; z = zone.SizeZ - widget.SizeX; } int x2 = Random.Range(0, x + 1); int z2 = Random.Range(0, z + 1); int x3 = x - x2; int z3 = z - z2; list.Add(new WidgetZone(zone.Parent, zone.X + x2, zone.Z + z2, zone.NumX, zone.NumZ, zone.SizeX - x, zone.SizeZ - z)); if (x2 > 0) { list.Add(new WidgetZone(zone.Parent, zone.X, zone.Z, zone.NumX, zone.NumZ, x2, zone.SizeZ)); } if (z2 > 0) { list.Add(new WidgetZone(zone.Parent, zone.X + x2, zone.Z, zone.NumX, zone.NumZ, zone.SizeX - x, z2)); } if (x3 > 0) { list.Add(new WidgetZone(zone.Parent, zone.X + zone.SizeX - x + x2, zone.Z, zone.NumX, zone.NumZ, x - x2, zone.SizeZ)); } if (z3 > 0) { list.Add(new WidgetZone(zone.Parent, zone.X + x2, zone.Z + zone.SizeZ - z + z2, zone.NumX, zone.NumZ, zone.SizeX - x, z - z2)); } return(list); }
/// <summary> /// Prepare widget zone model /// </summary> /// <param name="model">Widget zone admin model</param> /// <param name="widgetZone">Widget zone entity</param> /// <returns>Prepared widget zone model</returns> public virtual WidgetZoneModel PrepareWidgetZoneModel(WidgetZoneModel model, WidgetZone widgetZone) { if (model == null) { throw new Exception("Widget zone model are nullable"); } //prepare widget zone model if widget zone entity are exist if (widgetZone != null) { model = new WidgetZoneModel() { ArrowNavigationDisplayingTypeId = widgetZone.ArrowNavigationDisplayingTypeId, AvailableArrowNavigations = NavigationType.Always.ToSelectList().ToList(), AutoPlay = widgetZone.AutoPlay, AutoPlayInterval = widgetZone.AutoPlayInterval, BulletNavigationDisplayingTypeId = widgetZone.BulletNavigationDisplayingTypeId, AvailableBulletNavigations = NavigationType.Always.ToSelectList().ToList(), Id = widgetZone.Id, MinDragOffsetToSlide = widgetZone.MinDragOffsetToSlide, MinSlideWidgetZoneWidth = widgetZone.MinSlideWidgetZoneWidth, MaxSlideWidgetZoneWidth = widgetZone.MaxSlideWidgetZoneWidth, Name = widgetZone.Name, Published = widgetZone.Published, SlideDuration = widgetZone.SlideDuration, SlideSpacing = widgetZone.SlideSpacing, SystemName = widgetZone.SystemName, }; //put widget zone id number for slide searhing model.SlideSearchModel.WidgetZoneId = widgetZone.Id; } //prepare list of availbale navigation types var navigationTypes = NavigationType.Always.ToSelectList(false).ToList(); model.AvailableArrowNavigations = navigationTypes; model.AvailableBulletNavigations = navigationTypes; //prepare slide search model model.SlideSearchModel.SetGridPageSize(); return(model); }
private static void ExecutePropertyTest(WidgetZone widget, String expected, Func <Widget, string> fieldValueDelegate) { string rootPath = $"C:\\{string.Empty.GetRandom()}"; var connectionString = new ConnectionStringBuilder("this") .AddFilePath(rootPath) .Build(); var fileSystem = new MockFileServiceBuilder() .AddWidget(widget) .Build(rootPath); var target = new ContentRepositoryBuilder() .AddFileService(fileSystem.Object) .UseGenericDirectory() .Build(connectionString); var actualWidgets = target.GetAllWidgets(); var actual = actualWidgets.Single(); Assert.Equal(expected, fieldValueDelegate(actual)); }
/// <summary> /// Prepare widget zone model /// </summary> /// <param name="widgetZone">Widget zone entity</param> /// <param name="storeId">Store id number</param> /// <param name="languageId">Language entity id number</param> /// <returns>Widget zone model</returns> public virtual WidgetZoneModel PrepareWidgetZoneModel(WidgetZone widgetZone, int languageId, int storeId) { if (widgetZone == null) { throw new Exception("Widget zone can't be null"); } var settings = _settingService.LoadSetting <qBoSliderSettings>(storeId); //1.0.5 all with Alc var customer = _workContext.CurrentCustomer; var customerRoles = _customerService.GetCustomerRoleIds(customer); var customerRolesString = string.Join(",", customerRoles); //prepare widget zone model with slide and prepare cache key to load slider faster next time var cacheKey = _cacheKeyService.PrepareKey(ModelCacheEventConsumer.PICTURE_URL_MODEL_KEY, widgetZone.Id, languageId, storeId, DateTime.UtcNow.ToShortDateString(), customerRolesString); //load model from cache or process it var model = settings.UseStaticCache ? _staticCacheManager.Get(cacheKey, () => { return(PrepareSliderModel(widgetZone, languageId, storeId)); }) : PrepareSliderModel(widgetZone, languageId, storeId); return(model); }
public virtual IActionResult Create(WidgetZoneModel model, bool continueEditing) { //return access denied page if customer has no permissions if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } //return view if model state isn't valid if (!ModelState.IsValid) { //prepare model values model = _widgetZoneModelFactory.PrepareWidgetZoneModel(model, null); //prepare widget zone ACL _widgetZoneModelFactory.PrepareAclModel(model, null); //prepare widget zone store mappings _widgetZoneModelFactory.PrepareStoreMappings(model, null); return(View("~/Plugins/Widgets.qBoSlider/Views/Admin/WidgetZone/Create.cshtml", model)); } var widgetZone = new WidgetZone() { //put slider properties ArrowNavigationDisplayingTypeId = model.ArrowNavigationDisplayingTypeId, BulletNavigationDisplayingTypeId = model.BulletNavigationDisplayingTypeId, AutoPlay = model.AutoPlay, AutoPlayInterval = model.AutoPlayInterval, MinDragOffsetToSlide = model.MinDragOffsetToSlide, MinSlideWidgetZoneWidth = model.MinSlideWidgetZoneWidth, MaxSlideWidgetZoneWidth = model.MaxSlideWidgetZoneWidth, SlideDuration = model.SlideDuration, SlideSpacing = model.SlideSpacing, //put widget zone properties Name = model.Name, SystemName = model.SystemName, LimitedToStores = model.SelectedStoreIds.Any(), SubjectToAcl = model.SelectedCustomerRoleIds.Any(), Published = model.Published, }; //insert new widget zone _widgetZoneService.InsertWidgetZone(widgetZone); //save acl SaveWidgetZoneAcl(model, widgetZone); //save store mappings SaveWidgetZoneStoreMappings(model, widgetZone); //clear cache _settingService.ClearCache(); //notify admin _notificationService.SuccessNotification(_localizationService.GetResource("Nop.Plugin.Baroque.Widgets.qBoSlider.Admin.WidgetZone.CreatedSuccessfully")); //redirect on widget zone list page if customer don't want's to contiu editing if (!continueEditing) { return(RedirectToAction("List")); } return(RedirectToAction("Edit", new { id = widgetZone.Id })); }
public static WidgetZone CreateWidgetZone(int id, string title, string uniqueID, int orderNo) { WidgetZone widgetZone = new WidgetZone(); widgetZone.ID = id; widgetZone.Title = title; widgetZone.UniqueID = uniqueID; widgetZone.OrderNo = orderNo; return widgetZone; }
public void AddToWidgetZones(WidgetZone widgetZone) { base.AddObject("WidgetZones", widgetZone); }
/// <summary> /// Delete already existing widget zone entity from database /// </summary> /// <param name="widgetZone">Widget zone entity</param> public virtual void DeleteWidgetZone(WidgetZone widgetZone) { _widgetZoneRepository.Delete(widgetZone); _eventPublisher.EntityDeleted(widgetZone); }
public bool IsRegistered(WidgetZone widgetZone) { return(Widgets.Contains(widgetZone)); }
public WidgetZone Insert(WidgetZone zone) { return(_database.Insert <WidgetZone>(zone)); }
public WidgetZone Insert(WidgetZone zone) { return _database.Insert<WidgetZone>(zone); }
public void Register(WidgetZone widgetZone) { Widgets.Add(widgetZone); }
public void Update(WidgetZone zone) { _database.Update<WidgetZone>(zone); }
/// <summary> /// Prepare widget zone model /// </summary> /// <param name="widgetZone">Widget zone entity</param> /// <returns>Widget zone model</returns> protected virtual AddSlideWidgetZoneModel.WidgetZoneModel PrepareWidgetZoneModel(WidgetZone widgetZone) { return(new AddSlideWidgetZoneModel.WidgetZoneModel() { Id = widgetZone.Id, Name = widgetZone.Name, SystemName = widgetZone.SystemName, Published = widgetZone.Published }); }
/// <summary> /// Update already existing widget zone entity /// </summary> /// <param name="widgetZone">Widget zone entity</param> public virtual void UpdateWidgetZone(WidgetZone widgetZone) { _widgetZoneRepository.Update(widgetZone); _eventPublisher.EntityUpdated(widgetZone); }
public WidgetFileBuilder AddWidget(WidgetZone widget) { _widgets.Add(widget); return(this); }
public void Delete(WidgetZone widgetZone) { _cacheResolver.Remove(CacheKeys.WidgetZoneKeys.WidgetInstancesInWidgetZone(widgetZone.ID)); _database.Delete<WidgetZone>(widgetZone); }
public void Update(WidgetZone zone) { _database.Update <WidgetZone>(zone); }
public void Layout_Change_Should_Move_Widgets_To_Last_Available_Column() { const int ColumnsBeforeChange = 3; const int ColumnsAfterChange = 2; const int LayoutType = 2; MembershipHelper.UsingNewAnonUser((profile) => SetupHelper.UsingNewAnonSetup(profile.UserName, (setup) => { int originalLayoutType = setup.CurrentPage.LayoutType; // Ensure there's widgets on the last column WidgetZone lastZone = DatabaseHelper.GetSingle<WidgetZone, int, int>(DatabaseHelper.SubsystemEnum.WidgetZone, setup.CurrentPage.ID, ColumnsBeforeChange-1, LinqQueries.CompiledQuery_GetWidgetZoneByPageId_ColumnNo); List<WidgetInstance> widgetsOnLastZone = DatabaseHelper.GetList<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, lastZone.ID, LinqQueries.CompiledQuery_GetWidgetInstancesByWidgetZoneId); Assert.AreNotEqual(0, widgetsOnLastZone.Count, "No widget found on last column to move"); // Change to 25%, 75% two column layout WorkflowTest.Run<ModifyPageLayoutWorkflow, ModifyTabLayoutWorkflowRequest, ModifyTabLayoutWorkflowResponse>( new ModifyTabLayoutWorkflowRequest { UserName = profile.UserName, LayoutType = LayoutType } ); // Get the page setup again to ensure the number of columns are changed var newSetup = WorkflowTest.Run<UserVisitWorkflow, UserVisitWorkflowRequest, UserVisitWorkflowResponse>( new UserVisitWorkflowRequest { IsAnonymous = true, PageName = "", UserName = profile.UserName } ); Assert.AreEqual(ColumnsAfterChange, newSetup.CurrentPage.ColumnCount, "Number of columns did not change"); // Get the columns to verify the column number are same and each column has the expected width set List<Column> columns = DatabaseHelper.GetList<Column, int>(DatabaseHelper.SubsystemEnum.Column, newSetup.CurrentPage.ID, LinqQueries.CompiledQuery_GetColumnsByPageId); Assert.AreEqual(ColumnsAfterChange, columns.Count, "There are still more columns in database"); int[] columnWidths = Page.GetColumnWidths(LayoutType); foreach (Column col in columns) Assert.AreEqual(columnWidths[col.ColumnNo], col.ColumnWidth, "Column width is not as expected for Column No: " + col.ColumnNo); // Ensure the last column does not have any widgets List<WidgetInstance> remainingWidgetsOnLastZone = DatabaseHelper.GetList<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, lastZone.ID, LinqQueries.CompiledQuery_GetWidgetInstancesByWidgetZoneId); Assert.AreEqual(0, remainingWidgetsOnLastZone.Count, "Widgets are still in the last column. {0}".FormatWith(lastZone.ID)); // Now change back to 3 column layout and ensure the last column is added WorkflowTest.Run<ModifyPageLayoutWorkflow, ModifyTabLayoutWorkflowRequest, ModifyTabLayoutWorkflowResponse>( new ModifyTabLayoutWorkflowRequest { UserName = profile.UserName, LayoutType = originalLayoutType } ); List<Column> originalColumns = DatabaseHelper.GetList<Column, int>(DatabaseHelper.SubsystemEnum.Column, setup.CurrentPage.ID, LinqQueries.CompiledQuery_GetColumnsByPageId); Assert.AreEqual(ColumnsBeforeChange, originalColumns.Count, "There are still more columns in database"); // and the column width distribution must have changed as well int[] originalColumnWidths = Page.GetColumnWidths(originalLayoutType); foreach (Column col in originalColumns) Assert.AreEqual(originalColumnWidths[col.ColumnNo], col.ColumnWidth, "Column width is not as expected for Column No: " + col.ColumnNo); }) ) ); }
public void Delete(WidgetZone widgetZone) { _cacheResolver.Remove(CacheKeys.WidgetZoneKeys.WidgetInstancesInWidgetZone(widgetZone.ID)); _database.Delete <WidgetZone>(widgetZone); }
public void Layout_Change_Should_Move_Widgets_To_Last_Available_Column_ByFacade() { const int ColumnsBeforeChange = 3; const int ColumnsAfterChange = 2; const int LayoutType = 2; Facade.BootStrap(); MembershipHelper.UsingNewAnonUser((profile) => SetupHelper.UsingNewAnonSetup_ByFacade(profile.UserName, (setup) => { using (var facade = new Facade(new AppContext(string.Empty, profile.UserName))) { int originalLayoutType = setup.CurrentPage.LayoutType; // Ensure there's widgets on the last column WidgetZone lastZone = DatabaseHelper.GetSingle<WidgetZone, int, int>(DatabaseHelper.SubsystemEnum.WidgetZone, setup.CurrentPage.ID, ColumnsBeforeChange - 1, LinqQueries.CompiledQuery_GetWidgetZoneByPageId_ColumnNo); List<WidgetInstance> widgetsOnLastZone = DatabaseHelper.GetList<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, lastZone.ID, LinqQueries.CompiledQuery_GetWidgetInstancesByWidgetZoneId); Assert.AreNotEqual(0, widgetsOnLastZone.Count, "No widget found on last column to move"); // Change to 25%, 75% two column layout facade.ModifyPageLayout(LayoutType); // Get the page setup again to ensure the number of columns are changed var userSetup = facade.RepeatVisitHomePage(profile.UserName, string.Empty, true, DateTime.Now, false); Assert.AreEqual(ColumnsAfterChange, userSetup.CurrentPage.ColumnCount, "Number of columns did not change"); // Get the columns to verify the column number are same and each column has the expected width set List<Column> columns = DatabaseHelper.GetList<Column, int>(DatabaseHelper.SubsystemEnum.Column, userSetup.CurrentPage.ID, LinqQueries.CompiledQuery_GetColumnsByPageId); Assert.AreEqual(ColumnsAfterChange, columns.Count, "There are still more columns in database"); int[] columnWidths = Page.GetColumnWidths(LayoutType); foreach (Column col in columns) Assert.AreEqual(columnWidths[col.ColumnNo], col.ColumnWidth, "Column width is not as expected for Column No: " + col.ColumnNo); // Ensure the last column does not have any widgets List<WidgetInstance> remainingWidgetsOnLastZone = DatabaseHelper.GetList<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance, lastZone.ID, LinqQueries.CompiledQuery_GetWidgetInstancesByWidgetZoneId); Assert.AreEqual(0, remainingWidgetsOnLastZone.Count, "Widgets are still in the last column. {0}".FormatWith(lastZone.ID)); // Now change back to 3 column layout and ensure the last column is added facade.ModifyPageLayout(originalLayoutType); List<Column> originalColumns = DatabaseHelper.GetList<Column, int>(DatabaseHelper.SubsystemEnum.Column, setup.CurrentPage.ID, LinqQueries.CompiledQuery_GetColumnsByPageId); Assert.AreEqual(ColumnsBeforeChange, originalColumns.Count, "There are still more columns in database"); // and the column width distribution must have changed as well int[] originalColumnWidths = Page.GetColumnWidths(originalLayoutType); foreach (Column col in originalColumns) Assert.AreEqual(originalColumnWidths[col.ColumnNo], col.ColumnWidth, "Column width is not as expected for Column No: " + col.ColumnNo); } }) ); }
/// <summary> /// Insert new widget zone in database /// </summary> /// <param name="widgetZone">Widget zone entity</param> public virtual void InsertWidgetZone(WidgetZone widgetZone) { _widgetZoneRepository.Insert(widgetZone); _eventPublisher.EntityInserted(widgetZone); }
/// <summary> /// Install plugin /// </summary> public override void Install() { //settings var settings = new qBoSliderSettings { }; _settingService.SaveSetting(settings); var widgetZone = new WidgetZone() { AutoPlay = true, AutoPlayInterval = 3000, SlideDuration = 500, MinDragOffsetToSlide = 20, MinSlideWidgetZoneWidth = 200, MaxSlideWidgetZoneWidth = 1920, SlideSpacing = 0, BulletNavigationDisplayingTypeId = 2, ArrowNavigationDisplayingTypeId = 1, Name = "Main homepage slider", SystemName = "home_page_top", Published = true }; _widgetZoneService.InsertWidgetZone(widgetZone); //install simple data //get sample pictures path var sampleImagesPath = CommonHelper.DefaultFileProvider.MapPath("~/Plugins/Widgets.qBoSlider/Content/sample-images/"); var picture1 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner1.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-1").Id; var slide1 = new Slide() { Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" + "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>NEW COMFORT MOUSE<br /></strong></span></p>" + "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>CHOOSE FROM HUNDREDS<br /></strong></span></p>" + "<p style='margin-top: 5px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>OF MODELS</strong></span></p>" + "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>FROM ONLY $59.00</span></p>" + "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p></div>", PictureId = picture1, Published = true }; _slideService.InsertSlide(slide1); var picture2 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner2.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-2").Id; var slide2 = new Slide() { Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" + "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>HD PRO WEBCAM H320<br /></strong></span></p>" + "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>720P FOR TRUE HD-QUALITY<br />VIDEO CHAT<br /></strong></span></p>" + "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>ONLY $79.00</span></p>" + "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p></div>", PictureId = picture2, Published = true, }; _slideService.InsertSlide(slide2); var picture3 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner3.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-3").Id; var slide3 = new Slide() { Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" + "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>COMPACT CAMERA SP120</strong></span></p>" + "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>20X WIDE ZOOM, 2.5 LCD, </strong></span></p>" + "<p style='margin-top: 5px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>720P HD VIDEO</strong></span></p>" + "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>ONLY $159.00</span></p>" + "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p>" + "</div>", PictureId = picture3, Published = true }; _slideService.InsertSlide(slide3); _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide() { SlideId = slide1.Id, WidgetZoneId = widgetZone.Id, DisplayOrder = 0 }); _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide() { SlideId = slide2.Id, WidgetZoneId = widgetZone.Id, DisplayOrder = 5 }); _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide() { SlideId = slide3.Id, WidgetZoneId = widgetZone.Id, DisplayOrder = 10 }); base.Install(); }