protected void Page_Load(object sender, EventArgs e) { string CurrentUserLogin = ""; if (Bitrix.Security.BXPrincipal.Current.Identity.IsAuthenticated && OrdersIBlockId>0) { CurrentUserLogin = Bitrix.Security.BXPrincipal.Current.Identity.Name.Trim(); BXFilterItem[] AgrimentsFilter = new BXFilterItem[1]; if (Bitrix.Security.BXPrincipal.Current.IsInRole("Admin")) { AgrimentsFilter[0] = new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, OrdersIBlockId); } else { AgrimentsFilter = new BXFilterItem[2]; AgrimentsFilter[0] = new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, OrdersIBlockId); AgrimentsFilter[1] = new BXFilterItem(new BXSchemeCustomField(BXIBlockElement.GetCustomFieldsKey(OrdersIBlockId), "LOGIN", BXIBlockElement.Fields.ID), BXSqlFilterOperators.Equal, CurrentUserLogin); } elements = BXIBlockElement.GetList( new BXFilter(AgrimentsFilter), new BXOrderBy(new BXOrderByPair(BXIBlockElement.Fields.CreateDate, BXOrderByDirection.Desc)), null, new BXQueryParams(new BXPagingOptions(0, Count)) ); } IncludeComponentTemplate(); }
protected void Page_Load(object sender, EventArgs e) { Size = Parameters.Get("Size", 2); if (EnableSef) { MapVariable(Parameters.Get<string>("SEFFolder", "/photogallery"), Parameters.Get<string>("SEF_Photo"), Results); } else { BXParamsBag<string> variableAlias = new BXParamsBag<string>(); variableAlias["PhotoId"] = Parameters.Get<string>("ParamPhoto", "photo"); MapVariable(variableAlias, Results); } if (PhotoId > 0) { BXIBlockElement photoItem = BXIBlockElement.GetById(PhotoId); if (photoItem != null) { if (photoItem.Sections.Count > 0) { int albumId = photoItem.Sections[0].SectionId; BXFilter photoFilter = new BXFilter(); photoFilter.Add(new BXFilterItem(BXIBlockElement.Fields.Sections.Section.ID, BXSqlFilterOperators.Equal, albumId)); PhotoItems = BXIBlockElement.GetList(photoFilter,null,new BXSelectAdd(BXIBlockElement.Fields.DetailImage,BXIBlockElement.Fields.PreviewImage),null); } else { PhotoItems = new BXIBlockElementCollection(); PhotoItems.Add(photoItem); } foreach (BXIBlockElement photo in PhotoItems) { if (PhotoId == photo.Id) SelectedIndex = PhotoItems.IndexOf(photo); Results["Preview" + photo.Id.ToString()] = string.Empty; BXFile image = photo.DetailImageId > 0 ? photo.DetailImage : photo.PreviewImage; if (image == null) continue; BXParamsBag<object> vars = new BXParamsBag<object>(); vars["PhotoId"] = photo.Id; Results["PHOTO_LINK_" + photo.Id.ToString()] = MakeLink(Parameters.Get<string>("UrlTemplatePhoto", BXConfigurationUtility.Constants.ErrorHref), vars); // if we've found preview file with needed dimensions stored in cash folder, we return it Bitrix.Services.Image.BXImageInfo imageInfo = Bitrix.Services.Image. BXImageUtility.GetResizedImage(image, PreviewWidth, PreviewHeight); Results["Preview" + photo.Id.ToString()] = imageInfo.GetUri(); Results["PreviewWidth" + photo.Id.ToString()] = imageInfo.Width; Results["PreviewHeight" + photo.Id.ToString()] = imageInfo.Height; } } if (Size > PhotoItems.Count) Size = PhotoItems.Count; IncludeComponentTemplate(); } }