Esempio n. 1
0
	private string PrepareSefMode()
	{
		if (!Parameters.ContainsKey("ProfilePath"))
			Parameters["ProfilePath"] = string.Empty;

		Results["PasswordRecoveryPath"] = CombineLink(SefFolder,  Parameters.GetString("PasswordRecoveryTemplate"));
		Results["PasswordRecoveryCodePath"] = CombineLink(SefFolder,  Parameters.GetString("PasswordResetTemplate"));
		Results["RegisterPath"] = CombineLink(SefFolder,  Parameters.GetString("RegisterTemplate"));
		Results["LoginRedirectPath"] = Request["back_url"] ?? CombineLink(SefFolder, "");
		Results["LoginPath"] =  CombineLink(SefFolder, "");
		Results["LoginLink"] = Results["LoginPath"];

		BXParamsBag<string> sefMap = new BXParamsBag<string>();
		if (Parameters.GetBool("RegistrationAllow"))
			sefMap.Add("register", Parameters.GetString("RegisterTemplate", ""));
		sefMap.Add("PasswordRecovery", Parameters.GetString("PasswordRecoveryTemplate", ""));
		sefMap.Add("PasswordRecoveryCode", Parameters.GetString("PasswordResetTemplate", ""));
		if (SendConfirmationRequest)
		{
			sefMap.Add("confirmation", Parameters.GetString("ConfirmationTemplate", ""));
			Results["UrlToConfirmationPage"] = CombineLink(SefFolder, Parameters.GetString("ConfirmationTemplate"));
		}
		
		return BXSefUrlUtility.MapVariable(SefFolder, sefMap, ComponentCache, "login", null, null);
	}
Esempio n. 2
0
	//private void RegisterJavaScript()
	//{
	//    StringBuilder s = new StringBuilder();
	//    s.Append("if(!isNaN(args.Value)){");
	//    s.Append("var i=parseInt(args.Value);");
		
	//    s.AppendFormat("var tb=document.getElementById('{0}');", MinValue.ClientID);
	//    s.Append("if(tb&&!isNaN(tb.value)){");
	//    s.Append("var j=parseInt(tb.value);");
	//    s.Append("if (i<j)return;");
	//    s.Append("}");

	//    s.AppendFormat("var tb=document.getElementById('{0}');", MaxValue.ClientID);
	//    s.Append("if(tb&&!isNaN(tb.value)){");
	//    s.Append("var j=parseInt(tb.value);");
	//    s.Append("if (i>j)return;");
	//    s.Append("}");

	//    s.Append("}");

	//    DefaultValueConditions.ClientValidationFunction = ClientID + "_ValidateDefault";
	//    string js = string.Format("function {0}(source,args){{args.IsValid=false;{1}args.IsValid=true}}\n", DefaultValueConditions.ClientValidationFunction, s.ToString());
		
	//    ScriptManager.RegisterClientScriptBlock(Page, GetType(), ClientID, js, true);
	//}

	#region IBXCustomTypeSetting Members

	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> result = new BXParamsBag<object>();
		int i;
		if (int.TryParse(TextBoxSize.Text, out i))
			result.Add("TextBoxSize", i);
		if (int.TryParse(ddlIBlock.SelectedValue, out i))
			result.Add("IBlockId", i);
		return result;
	}
Esempio n. 3
0
	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> result = new BXParamsBag<object>();
		int i;
		if (int.TryParse(DefaultValue.Text, out i))
			result.Add("DefaultValue", i);
		if (int.TryParse(TextBoxSize.Text, out i))
			result.Add("TextBoxSize", i);
		if (int.TryParse(MinValue.Text, out i))
			result.Add("MinValue", i);
		if (int.TryParse(MaxValue.Text, out i))
			result.Add("MaxValue", i);
		return result;
	}
Esempio n. 4
0
	public BXParamsBag<object> GetSettings()
	{
        BXParamsBag<object> settings = new BXParamsBag<object>();

        if (rbList.Checked)
            settings.Add("ViewMode", "list");

        int listSize;

        if (int.TryParse(ListSize.Text, out listSize))
            settings.Add("ListSize", listSize);
        else
            settings.Add("ListSize", 5);

        return settings;
	}
Esempio n. 5
0
	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> settings = new BXParamsBag<object>();

        if (rbCheckbox.Checked)
            settings.Add("view", 0);

        if (rbRadiobuttons.Checked)
            settings.Add("view", 1);

        if (rbDropDown.Checked)
            settings.Add("view", 2);

        settings.Add("default",DefaultValue.SelectedIndex);

		return settings;
	}
Esempio n. 6
0
	public BXParamsBag<object> GetSettings()
	{
        BXParamsBag<object> settings = new BXParamsBag<object>();

        if (rbCurrent.Checked)
            settings.Add("current", "true");

		settings.Add("showTime", showTime.Checked);

        if (rbCustom.Checked)
        {
            IBXCalendar cal = Calendar1 as IBXCalendar;
            if (cal != null && !cal.Date.Equals(DateTime.MinValue))
                settings.Add("default", cal.Date);
        }

        return settings;
	}
Esempio n. 7
0
	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> result = new BXParamsBag<object>();
		
		int i;
		if (int.TryParse(TextBoxSize.Text, out i))
			result.Add("TextBoxSize", i);
		if (int.TryParse(MaxSize.Text, out i))
			result.Add("MaxSize", i);
		
		string e = AllowedExtensions.Text.Trim();
		string[] es = e.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
		List<string> l = new List<string>();
		foreach(string ext in es) 
		{
			string item = ext.Trim().ToLowerInvariant();
			if (!String.IsNullOrEmpty(item) && !l.Contains(item))
				l.Add(item);
		}
		if (l.Count > 0)
			result.Add("AllowedExtensions", l.ToArray());
		result.Add("AddDescription", AddDescription.Checked);
		return result;
	}
Esempio n. 8
0
	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> result = new BXParamsBag<object>();
		int i;
		result.Add("DefaultValue", DefaultValue.Text);
		if (int.TryParse(TextBoxSize.Text, out i))
			result.Add("TextBoxSize", i);
		if (int.TryParse(RowsCount.Text, out i))
			result.Add("RowsCount", i);
		if (int.TryParse(MinLength.Text, out i))
			result.Add("MinLength", i);
		if (int.TryParse(MaxLength.Text, out i))
			result.Add("MaxLength", i);

		result.Add("TextType", PatternButton.Checked ? "pattern" : HtmlButton.Checked ? "html" : "text");
        result.Add("Pattern", Pattern.Text);
		result.Add("ValidationRegex", ValidationRegex.Text);
		return result;
	}
Esempio n. 9
0
	public BXParamsBag<object> GetSettings()
	{
		BXParamsBag<object> result = new BXParamsBag<object>();
		int i;
		if (int.TryParse(Precision.Text, out i))
			if (i > 0)
				result.Add("Precision", i);
			else
				result.Add("Precision", 0);
		else
			result.Add("Precision", 0);

		double val;
		if (TryParseDouble(DefaultValue.Text, out val))
			result.Add("DefaultValue", val);
		if (int.TryParse(TextBoxSize.Text, out i))
			result.Add("TextBoxSize", i);
		if (TryParseDouble(MinValue.Text, out val))
			result.Add("MinValue", val);
		if (TryParseDouble(MaxValue.Text, out val))
			result.Add("MaxValue", val);
		return result;
	}
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        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)
        {
            Photo = BXIBlockElement.GetById(PhotoId);
			if (EnableComments && IsForumInstalled && !String.IsNullOrEmpty(CommentStoragePropertyName)) // комментарии включены, нужно получить ID темы комментариев чтобы отдать компоненту комментариев
			{

					ComponentCache["IdentityPropertyName"] = CommentStoragePropertyName;
					ComponentCache["IdentityPropertyValue"] = PhotoId;
					ComponentCache["IdentityPropertyTypeName"] = "Bitrix.System.Int";
					int commentId = Parameters.Get<int>("CommentId",0);
					ComponentCache["PostId"] = commentId;

					BXParamsBag<object> replace = new BXParamsBag<object>();
					replace.Add("PHOTOID", PhotoId);

					ComponentCache["UrlPhoto"] = ResolveTemplateUrl(Parameters.Get("UrlTemplatePhoto", "/photo/#PHOTOID#/"), replace);
					ComponentCache["PostReadPageUrlTemplate"] = ResolveTemplateUrl(Parameters.Get<string>("CommentReadPageUrlTemplate",String.Empty), replace);
					ComponentCache["PostReadUrlTemplate"] = ResolveTemplateUrl(Parameters.Get<string>("CommentReadUrlTemplate",string.Empty), replace);
					ComponentCache["PostOperationUrlTemplate"] = ResolveTemplateUrl(Parameters.Get<string>("CommentOperationUrlTemplate",string.Empty), replace);
					
				//}
			}
            if (Photo != null)
            {
                AlbumId = Photo.Sections.Count > 0 ? Photo.Sections[0].SectionId : 0;
                PhotoAuthor = (Photo.ModifiedByUser == null )? String.Empty : Photo.ModifiedByUser.UserName;

                if (Photo != null || Photo.DetailImageId > 0)
                    imageInfo = Bitrix.Services.Image.
                        BXImageUtility.GetResizedImage(Photo.DetailImage, PhotoWidth, PhotoHeight);

                if (BXIBlock.GetById(Photo.IBlockId).IsUserCanOperate("IBlockModifyElements"))
                    ModifyElements = true;

                Page.Title = Server.HtmlDecode(Photo.Name);
                PhotoTitle = Photo.Name;
                Description = Photo.DetailText ?? String.Empty;
                PhotoOriginalUrl = BXUri.ToRelativeUri(Photo.DetailImage.TextEncoder.Decode(Photo.DetailImage.FilePath));
                PhotoOriginalSizeText = string.Format(GetMessage("FormatOriginalSize"), Photo.DetailImage.Width, Photo.DetailImage.Height);

                //if (Photo.DetailImageId > 0)
                //{
                //    PhotoUrl = string.Format(
                //            "{0}ImageResizer.ashx?path={1}&width={2}&height={3}&fit=true",
                //            BXUri.ToRelativeUri("~/bitrix/handlers/Main/"),
                //			  UrlEncode(Photo.DetailImage.FileVirtualPath),
                //            Parameters.Get("PhotoWidth", 150),
                //            Parameters.Get("PhotoHeight", 150));
                //}


                EditUrl = MakeLink(Parameters.Get("UrlTemplatePhotoEdit", BXConfigurationUtility.Constants.ErrorHref), Results);

                if (Photo.Sections.Count > 0)
                {
                    BXIBlockSectionCollection navChain = BXIBlockSection.GetNavChain(Photo.Sections[0].SectionId);
                    for (int i = 0; i < navChain.Count; i++)
                    {
                        //AlbumId = navChain[i].SectionId;
                        string albumUrl = MakeLink(Parameters.Get<string>("UrlTemplateAlbum", BXConfigurationUtility.Constants.ErrorHref), Results);

                        string parentAlbumUrl;

                        if (i != 0)
                        {
                            // AlbumId = navChain[i].SectionId;
                            parentAlbumUrl = MakeLink(Parameters.Get<string>("UrlTemplateAlbum", BXConfigurationUtility.Constants.ErrorHref), Results);
                        }
                        else
                        {
                            parentAlbumUrl = Parameters.Get<string>("GalleryRoot");
                        }

                        BXSiteMapManager.AddNode(
                            parentAlbumUrl,
                            albumUrl,
                            navChain[i].Name);
                    }
                }

                BXSiteMapManager.AddNode(
                        BackUrl,
                        MakeLink(Parameters.Get<string>("UrlTemplatePhoto", BXConfigurationUtility.Constants.ErrorHref), Results),
                        Photo.Name);


            }
            else
            {

                Results.Add("AlbumId", 0);
                Page.Title = GetMessage("Photo");
            }

       } 
        else
        {
            Results.Add("AlbumId", 0);
            Page.Title = GetMessage("Photo");
        }

        BackUrl = MakeLink(Parameters.Get("UrlTemplateAlbum", BXConfigurationUtility.Constants.ErrorHref), Results);
        IncludeComponentTemplate();
    }
Esempio n. 11
0
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        paramsBag.Add(deleteMenuItemChkBx.ID, deleteMenuItemChkBx.Checked.ToString());
    }
    /// <summary>
    /// ExternalizeParameters
    /// Выгрузить параметры
    /// </summary>
    /// <param name="paramsBag"></param>
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        paramsBag.Add(tbxNewTemplateName.ID, tbxNewTemplateName.Text);

        if(rbtnDefaultSiteTemplate.Checked)
            paramsBag.Add(rbtnDefaultSiteTemplate.ID, string.Empty);

        if (rbtnActiveSiteTemplate.Checked)
            paramsBag.Add(rbtnActiveSiteTemplate.ID, string.Empty);

        if (rbtnAnotherSiteTemplate.Checked)
        {
            paramsBag.Add(rbtnAnotherSiteTemplate.ID, string.Empty);
            paramsBag.Add(ddlSiteTemplateName.ID, ddlSiteTemplateName.Value);
        }

        paramsBag.Add(chbxApply.ID, chbxApply.Checked.ToString());
        paramsBag.Add(chbxGo2Modification.ID, chbxGo2Modification.Checked.ToString());
    }
	protected override void SaveDialogData()
	{
		if(!SaveSection())
			return;

		string backUrl = Request[BXConfigurationUtility.Constants.BackUrl];
		if(string.IsNullOrEmpty(backUrl))
			Refresh(string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, 0);

		BXParamsBag<object> replace = new BXParamsBag<object>();
		replace.Add("SectionId", this.sectionId.ToString());
		replace.Add("SECTION_ID", this.sectionId.ToString());
		replace.Add("SectionCode", this.sectionId.ToString());
		replace.Add("SECTION_CODE", this.sectionId.ToString());
		Redirect(BXSefUrlUtility.MakeLink(backUrl, replace), string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, 0);
	}
Esempio n. 14
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Visible =
                IsSearch
                || !string.IsNullOrEmpty(RssBlogPostsUrlTemplate)
                || Blog.Owner != null && Blog.Owner.User != null && Blog.Owner.User.Image != null
                || Auth.CanEditThisBlogSettings || Auth.CanCreatePost || Auth.CanReadThisBlogDrafts;

            replace = new BXParamsBag<object>();
            replace.Add("UserId", Blog.OwnerId);
            replace.Add("BlogSlug", Blog.Slug);
            replace.Add("BlogId", Blog.Id);

            if (!string.IsNullOrEmpty(RssBlogPostsUrlTemplate))
            {
                BXPage.RegisterLink(
                    "alternate",
                    "application/rss+xml",
                    ResolveTemplateUrl(RssBlogPostsUrlTemplate, replace),
                    new KeyValuePair<string, string>("title", Blog.TextEncoder.Decode(Blog.Name))
                );
            }
        }
Esempio n. 15
0
    public override void ProcessMessage(BXCommand cmd, bool executionContext, string executionVirtualPath)
    {
        #region Search
        if (cmd.Action == "Bitrix.Search.ProvideUrl")
        {
            string moduleId = cmd.Parameters.Get("moduleId", string.Empty);
            if (string.Equals(moduleId, "forum", StringComparison.OrdinalIgnoreCase) 
                && AllowComments 
                && BXModuleManager.IsModuleInstalled("Forum"))
            {
                //Поиск по комментариям к новостям
                int blockId = IBlockId;
                int forumId = cmd.Parameters.GetInt("itemGroup", 0);
                int postId = cmd.Parameters.GetInt("itemId", 0);
                int topicId = cmd.Parameters.GetInt("param1");


                if (blockId == 0 || !string.Equals(moduleId, "forum", StringComparison.OrdinalIgnoreCase) || forumId <= 0 || postId <= 0)
                    return;

                BXFilter f = new BXFilter(
                        new BXFilterItem(BXIBlockElement.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockElement.Fields.ActiveDate, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, blockId),
                        new BXFilterItem(BXIBlockElement.Fields.CustomFields[blockId].GetFieldByKey(CommentCustomPropertyName), BXSqlFilterOperators.Equal, topicId)
                        );

                string siteId = DesignerSite;
                if (!string.IsNullOrEmpty(siteId))
                    f.Add(new BXFilterItem(BXIBlockElement.Fields.IBlock.Sites.SiteId, BXSqlFilterOperators.Equal, siteId));

                BXIBlockElementCollection c = BXIBlockElement.GetList(f, null);
                if (c.Count == 0)
                    return;

                BXIBlockElement el = c[0];
                //формируем постоянную ссылку на комментарий
                string commentUrl = string.Empty;
                if (!EnableSef)
                    commentUrl = string.Format("{0}?{1}={2}&{3}={4}#comment{4}", BXSite.GetUrlForPath(executionVirtualPath, null, cmd.SiteId), ParamNews, el.Id.ToString(), ParamComment, postId.ToString());
                else
                {
                    BXParamsBag<object> commentSefParams = new BXParamsBag<object>();
                    commentSefParams["SectionId"] = string.Empty;
                    commentSefParams["ElementId"] = el.Id.ToString();
                    commentSefParams["CommentId"] = postId.ToString();
                    string t = SefDetailCommentRead;
                    if (t.IndexOf("##") < 0)
                        t = string.Concat(t, "##comment#CommentId#");
                    commentUrl = BXSefUrlUtility.MakeLink(CombineLink(SefFolder, t), commentSefParams).Replace("//", "/");
                }
                cmd.AddCommandResult(string.Concat("bitrix:forum@", executionVirtualPath), new BXCommandResult(BXCommandResultType.Ok, commentUrl));                    
                return;
            }

            if (!string.Equals(moduleId, "iblock", StringComparison.OrdinalIgnoreCase))
                return;

            if (IBlockId < 0 || cmd.Parameters.Get<int>("itemGroup") != IBlockId)
                return;

            int elementId = cmd.Parameters.Get("itemId", -1);
            if (elementId < 0)
                return;

            BXIBlockElement elm = BXIBlockElement.GetById(elementId);
            if (elm == null) return;
            BXParamsBag<object> p = new BXParamsBag<object>();
            p.Add("ElementId", elementId);
            p.Add("SectionId", elm.Sections.Count > 0 ? elm.Sections[0].SectionId.ToString() : String.Empty);
            string url;
            if (EnableSef)
            {
                url = MakeLink(SefFolder, SefNews, p);
                if (elm.Sections.Count == 0)
                    url = url.Replace("//", "/");
            }
            else
                url = MakeLink(string.Format("{0}?{1}=#ElementId#", BXSite.GetUrlForPath(executionVirtualPath, null, cmd.SiteId), ParamNews), p);
            cmd.AddCommandResult("bitrix:news@" + executionVirtualPath, new BXCommandResult(BXCommandResultType.Ok, url));
        }
        #endregion

        if (cmd.Action == "Bitrix.Main.GeneratePublicMenu")
        {
            //Совпадает ли тип меню в параметрах компонента с типом, который запрашивает система.
            if (!Parameters.Get("GenerateMenuType", "left").Equals(cmd.Parameters.Get<string>("menuType"), StringComparison.InvariantCultureIgnoreCase))
                return;

            //Генерируем меню только для тех адресов, которые выводит сам компонент.
            if (!Parameters.Get<bool>("EnableSEF") && !BXSiteRemapUtility.UnmapVirtualPath(executionVirtualPath).Equals(cmd.Parameters.Get<string>("uriPath"), StringComparison.InvariantCultureIgnoreCase))
                return;
            else if (Parameters.Get<bool>("EnableSEF") && !cmd.Parameters.Get<string>("uriPath").StartsWith(Bitrix.IO.BXPath.ToVirtualRelativePath(SefFolder.TrimStart('\\', '/')) + "/", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (IBlockId < 0)
                return;

            BXParamsBag<object> request = new BXParamsBag<object>();
            BXParamsBag<string> urlToPage = new BXParamsBag<string>();

            if (EnableSef)
            {
                urlToPage["detail"] = SefNews;
                urlToPage["section"] = SefSection;
                urlToPage["news.page"] = SefPage;
                urlToPage["news.showall"] = SefShowAll;
                urlToPage["rss"] = Parameters.Get("Sef_Rss", String.Empty);
                urlToPage["sectionrss"] = Parameters.Get("Sef_Rss_Section", String.Empty);

                MapVariable(SefFolder, urlToPage, request, String.Empty, BXUri.ToRelativeUri(cmd.Parameters.Get<string>("uri")));
            }
            else
            {
                BXParamsBag<string> variableAlias = new BXParamsBag<string>();
                variableAlias["ElementId"] = ParamNews;
                variableAlias["SectionId"] = ParamSection;

                MapVariable(variableAlias, request, BXUri.ToRelativeUri(cmd.Parameters.Get<string>("uri")));
            }

            //Определим уровень доступа пунктов
            if ((menuItemPermisson = (string)BXCacheManager.MemoryCache.Get(PermissionCacheKey)) == null)
            {
                menuItemPermisson = String.Empty;
                StringBuilder menuItemRoles = new StringBuilder();
                if (Parameters.Get<bool>("UsePermissions"))
                {
                    foreach (string permission in Parameters.GetList("GroupPermissions", new List<object>()))
                    {
                        menuItemRoles.Append(permission);
                        menuItemRoles.Append(";");
                    }

                    if (menuItemRoles.Length > 0)
                        menuItemRoles.Append("Admin");
                }
                else
                {
                    BXRoleCollection iblockRoles = BXRoleManager.GetAllRolesForOperation("IBlockRead", "iblock", IBlockId.ToString());
                    foreach (BXRole role in iblockRoles)
                    {
                        //Если доступно всем
                        if (role.RoleName == "Guest")
                        {
                            menuItemRoles = null;
                            break;
                        }
                        //Если доступно группе User, значит достаточно проверить только для этой группы
                        else if (role.RoleName == "User")
                        {
                            menuItemRoles = null;
                            menuItemPermisson = "User";
                            break;
                        }
                        else
                        {
                            menuItemRoles.Append(role.RoleName);
                            menuItemRoles.Append(";");
                        }
                    }
                }

                if (menuItemRoles != null && menuItemRoles.Length > 0)
                    menuItemPermisson = menuItemRoles.ToString();

                BXCacheManager.MemoryCache.Insert(PermissionCacheKey, menuItemPermisson);
            }

            int elementId = 0, sectionId = 0;
            elementId = request.Get<int>("ElementId", elementId);
            sectionId = request.Get<int>("SectionId", sectionId);

            string parentLevelUri = null;
            List<BXPublicMenuItem> menuList = null;

            if (elementId > 0 && sectionId > 0)
            {
                parentLevelUri = MakeMenuUri(executionVirtualPath, sectionId);
            }
            //Если указан только элемент
            else if (elementId > 0)
            {
                BXFilter elementFilter = new BXFilter(
                    new BXFilterItem(BXIBlockElement.Fields.ID, BXSqlFilterOperators.Equal, elementId),
                    new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId)
                );

                if (Parameters.Get<bool>("ShowActiveElements", true))
                {
                    elementFilter.Add(new BXFilterItem(BXIBlockElement.Fields.Active, BXSqlFilterOperators.Equal, "Y"));
                    elementFilter.Add(new BXFilterItem(BXIBlockElement.Fields.ActiveDate, BXSqlFilterOperators.Equal, "Y"));
                }

                BXIBlockElementCollection element = BXIBlockElement.GetList(elementFilter, null);
                if (element != null && element.Count > 0)
                {
                    BXIBlockElement.BXInfoBlockElementSectionCollection sections = element[0].Sections;
                    if (sections != null && sections.Count > 0)
                    {
                        sectionId = sections[0].SectionId;
                        parentLevelUri = MakeMenuUri(executionVirtualPath, sectionId); //Меню строится для раздела, к которому привязан элемент
                    }
                }
            }

            //Если указан раздел выводим его дочерние разделы
            if (parentLevelUri == null && sectionId > 0)
            {
                BXIBlockSectionCollection sectionList = BXIBlockSection.GetList(
                    new BXFilter(
                        new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId),
                        new BXFilterItem(BXIBlockSection.Fields.SectionId, BXSqlFilterOperators.Equal, sectionId)
                    ),
                    new BXOrderBy(
                        new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
                        new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
                    )
                );

                menuList = ExtractMenuItemsFromCollection(sectionList, executionVirtualPath);

                //Если нет дочерних разделов, то меню строится для родителя указанного раздела 
                if (menuList == null)
                {
                    sectionList = BXIBlockSection.GetList(
                        new BXFilter(
                            new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
                            new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
                            new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId),
                            new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, sectionId)
                        ),
                        new BXOrderBy(
                            new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
                            new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
                        )
                    );

                    if (sectionList != null && sectionList.Count > 0 && sectionList[0].SectionId > 0)
                    {
                        parentLevelUri = MakeMenuUri(executionVirtualPath, sectionList[0].SectionId);
                    }
                    else
                    {
                        //Если такой раздел не существует или это раздел корневой (нет родителя)
                        if (Parameters.Get<bool>("EnableSEF"))
                            parentLevelUri = SefFolder;
                        else
                            parentLevelUri = BXSiteRemapUtility.UnmapVirtualPath(executionVirtualPath);
                    }
                }
            }

            //Если ничего не указано выводим корневые разделы
            Dictionary<string, BXPublicMenu.BXLoadMenuCommandParameter> menuTree = new Dictionary<string, BXPublicMenu.BXLoadMenuCommandParameter>();
            if (parentLevelUri == null && menuList == null)
            {

                /*BXIBlockSectionCollection sectionList = BXIBlockSection.GetList(
                    new BXFilter(
                        new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId),
                        new BXFilterItem(BXIBlockSection.Fields.SectionId, BXSqlFilterOperators.Equal, null)
                    ),

                    new BXOrderBy(
                        new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
                        new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
                    )
                );

                            menuList = ExtractMenuItemsFromCollection(sectionList, executionVirtualPath);
            */
                BXIBlockSectionCollection sectionsList = BXIBlockSection.GetList(
                    new BXFilter(
                        new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
                        new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId)
                    ),
                    new BXOrderBy(
                        new BXOrderByPair(BXIBlockSection.Fields.LeftMargin, BXOrderByDirection.Asc),
                        new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
                        new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
                    )
                );

                Dictionary<int, List<BXPublicMenuItem>> sectionTree = new Dictionary<int, List<BXPublicMenuItem>>();
                foreach (BXIBlockSection section in sectionsList)
                {
                    if (!sectionTree.ContainsKey(section.SectionId))
                        sectionTree.Add(section.SectionId, new List<BXPublicMenuItem>());

                    BXPublicMenuItem menuItem = new BXPublicMenuItem();
                    menuItem.Title = section.Name;
                    menuItem.Links.Add(MakeMenuUri(executionVirtualPath, section.Id));
                    menuItem.Sort = section.Sort;
                    if (!String.IsNullOrEmpty(menuItemPermisson))
                    {
                        menuItem.ConditionType = ConditionType.Group;
                        menuItem.Condition = menuItemPermisson;
                    }
                    sectionTree[section.SectionId].Add(menuItem);
                }

                foreach (KeyValuePair<int, List<BXPublicMenuItem>> submenuList in sectionTree)
                {
                    string url = null;
                    if (submenuList.Key > 0)
                    {
                        url = MakeMenuUri(executionVirtualPath, submenuList.Key);
                    }
                    else
                    {
                        if (Parameters.Get<bool>("EnableSEF"))
                            url = SefFolder;
                        else
                            url = BXSiteRemapUtility.UnmapVirtualPath(executionVirtualPath);
                    }

                    menuTree.Add(url, new BXPublicMenu.BXLoadMenuCommandParameter(submenuList.Value, true, null));
                }
            }

            if (menuTree.Count > 0)
                cmd.AddCommandResult("bitrix:news@" + executionVirtualPath, new BXCommandResult(BXCommandResultType.Ok, menuTree));
            else
            {
                BXPublicMenu.BXLoadMenuCommandParameter menuResult = new BXPublicMenu.BXLoadMenuCommandParameter(menuList, true, parentLevelUri);
                cmd.AddCommandResult("bitrix:news@" + executionVirtualPath, new BXCommandResult(BXCommandResultType.Ok, menuResult));
            }


        }
    }
Esempio n. 16
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string templateName = "list";
            string action = string.Empty;

            if (EnableSef)
            {
                BXParamsBag<string> sefTemplates = new BXParamsBag<string>();
                sefTemplates.Add("list$page", SefTemplatePageIndex);
                sefTemplates.Add("list$all", SefTemplateShowAll);
                sefTemplates.Add("form$new", SefTemplateCreateElement);
                sefTemplates.Add("form$edit", SefTemplateModifyElement);


                string code = MapVariable(SefFolder, sefTemplates, ComponentCache, "list");

                int position = code.IndexOf('$');
                if (position > 0)
                {
                    templateName = code.Substring(0, position);
                    action = code.Substring(position + 1);
                }
                else
                {
                    templateName = code;
                    action = string.Empty;
                }


                if (string.Equals(templateName, "form", StringComparison.InvariantCultureIgnoreCase))
                {
                    if ((string.Equals(action, "edit", StringComparison.InvariantCultureIgnoreCase) && !InternalBehaviour.IsElementModificationAllowed()) ||
                        (string.Equals(action, "new", StringComparison.InvariantCultureIgnoreCase) && !InternalBehaviour.IsElementCreationAllowed())
                        )
                    {
                        templateName = "list";
                        action = string.Empty;
                    }
                }


                if (string.Equals(templateName, "list", StringComparison.InvariantCultureIgnoreCase))
                {
                    BXParamsBag<object> replaceItems = new BXParamsBag<object>(ComponentCache);
                    replaceItems.Remove("PageID");  

                    replaceItems["IblockId"] = replaceItems["IBLOCK_ID"] = IBlockId.ToString();

                    ComponentCache["PagingIndexTemplate"] = CombineLink(SefFolder, string.Empty);
                    ComponentCache["PagingPageTemplate"] = CombineLink(SefFolder, MakeLink(SefTemplatePageIndex, replaceItems));
                    ComponentCache["PagingShowAllTemplate"] = CombineLink(SefFolder, MakeLink(SefTemplateShowAll, replaceItems));
                    ComponentCache["ShowAll"] = string.Equals(code, "list$all", StringComparison.Ordinal) ? "y" : "n";
                    ComponentCache["ElementCreationUrl"] = CombineLink(SefFolder, MakeLink(SefTemplateCreateElement, replaceItems));
                    ComponentCache["ElementModificationUrl"] = CombineLink(SefFolder, MakeLink(SefTemplateModifyElement, replaceItems));
                }
                else if (string.Equals(templateName, "form", StringComparison.InvariantCultureIgnoreCase))
                    Parameters["RedirectPageUrl"] = CombineLink(SefFolder, string.Empty);
            }
            else
            {
                bool aboutCreateEl = false,
                        aboutModifyEl = false;
                string createElParName = RequestParamNameCreateElement,
                        modifyElParName = RequestParamNameModifyElement;

                if (!string.IsNullOrEmpty(modifyElParName))
                {
                    string elementID = Request.QueryString.Get(modifyElParName);
                    if (!string.IsNullOrEmpty(elementID))
                    {
                        aboutModifyEl = true;
                        ComponentCache["ElementID"] = elementID;
                    }
                }

                if (!aboutModifyEl && !string.IsNullOrEmpty(createElParName))
                {
                    int keyCount = Request.QueryString.Count;
                    for (int i = 0; i < keyCount; i++)
                    {
                        if (!string.Equals(Request.QueryString[i], createElParName, StringComparison.InvariantCultureIgnoreCase))
                            continue;
                        aboutCreateEl = true;
                        ComponentCache["ElementID"] = "0";
                        break;
                    }
                }

                if ((aboutModifyEl && InternalBehaviour.IsElementModificationAllowed()) || (aboutCreateEl && InternalBehaviour.IsElementCreationAllowed()))
                {
                    templateName = "form";
                    Parameters["RedirectPageUrl"] = BXSefUrlManager.CurrentUrl.AbsolutePath;
                }
                else
                {
                    BXParamsBag<string> requestParamAliases = new BXParamsBag<string>();
                    requestParamAliases["PageID"] = RequestParamNamePageIndex;
                    requestParamAliases["ShowAll"] = RequestParamNameShowAll;
                    BXComponentManager.MapVariable(requestParamAliases, ComponentCache, true);

                    if (ComponentCache.ContainsKey("ShowAll") && string.IsNullOrEmpty(ComponentCache.GetString("ShowAll", null)))
                        ComponentCache["ShowAll"] = "y";

                    string filePath = BXSefUrlManager.CurrentUrl.AbsolutePath;

                    ComponentCache["PagingIndexTemplate"] = filePath;
                    ComponentCache["PagingPageTemplate"] = String.Format("{0}?{1}=#PageId#", filePath, RequestParamNamePageIndex);
                    ComponentCache["PagingShowAllTemplate"] = String.Format("{0}?{1}", filePath, RequestParamNameShowAll);

                    ComponentCache["ElementCreationUrl"] = !string.IsNullOrEmpty(createElParName) ? string.Concat("?", createElParName) : string.Empty;
                    ComponentCache["ElementModificationUrl"] = !string.IsNullOrEmpty(modifyElParName) ? string.Concat("?", modifyElParName, "=#ElementID#") : string.Empty;
                }
            }
            IncludeComponentTemplate(templateName);
        }
	protected override void SaveDialogData()
	{
		if (!SaveIBlockElement())
			return;

		string backUrl = Request[BXConfigurationUtility.Constants.BackUrl];
		if (string.IsNullOrEmpty(backUrl))
			Refresh(string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, 0);

		if (element == null)
			throw new InvalidOperationException("Could not find element!");

		string sectionId = this.element.Sections != null && this.element.Sections.Count > 0 ? this.element.Sections[0].SectionId.ToString() : string.Empty;

		BXParamsBag<object> replace = new BXParamsBag<object>();
		replace.Add("IblockId", this.element.IBlockId);
		replace.Add("IBLOCK_ID", this.element.IBlockId);
		replace.Add("IblockCode", this.element.Code);
		replace.Add("IBLOCK_CODE", this.element.Code);
		replace.Add("ELEMENT_ID", this.element.Id);
		replace.Add("ElementId", this.element.Id);
		replace.Add("ElementCode", this.element.Code);
		replace.Add("ELEMENT_CODE", this.element.Code);
		replace.Add("SectionId", sectionId);
		replace.Add("SECTION_ID", sectionId);
		replace.Add("SectionCode", sectionId);
		replace.Add("SECTION_CODE", sectionId);
		Redirect(BXSefUrlUtility.MakeLink(backUrl, replace), string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, 0);
	}
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        string content = mMode == VisualPageEditorMode.Standard ? VisualEditor.Content : TextEditor.Text;
        paramsBag.Add("content", content);
    }
Esempio n. 19
0
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        BXPublicMenuItemCollection menuItemCollection = MenuItemCollection;
        int menuItemsCount = menuItemCollection.Count;
        if (menuItemsCount == 0)
            return;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < menuItemsCount; i++)
        {
            if (sb.Length > 0)
                sb.Append(';');
            sb.Append(Serialize(menuItemCollection[i]));
        }
        paramsBag.Add(menuItemCollection.ID, sb.ToString());
    }
Esempio n. 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region HackUnSef

        BXParamsBag<string> urlToPage = new BXParamsBag<string>();
        BXParamsBag<object> request = new BXParamsBag<object>();
        string PageKey = String.Empty;        

        urlToPage.Add("ElementTOP", TOPElementURL);
        urlToPage.Add("SectionPage", SectionPageURL);
        urlToPage.Add("Element", ElementURL);
        urlToPage.Add("Section", SectionURL);

        if (EnableSef)
        {
            PageKey = MapVariable(SEFFolder, urlToPage, request, String.Empty);

            Results["ParamSectionId"] = ParamSectionId;
            Results["ParamElementId"] = ParamElementId;
            Results["ParamPageId"] = ParamPageId;
            Results["ParamElementCode"] = ParamElementCode;
            Results["ParamSectionCode"] = ParamSectionCode;
        }
        else
        {
            BXParamsBag<string> variableAliases = new BXParamsBag<string>();
            variableAliases.Add(ParamSectionId, AliasSectionId);
            variableAliases.Add(ParamElementId, AliasElementId);
            variableAliases.Add(ParamPageId, AliasPageId);
            variableAliases.Add(ParamSectionCode, AliasSectionCode);
            variableAliases.Add(ParamElementCode, AliasElementCode);
            MapVariable(variableAliases, request);

            Results["ParamSectionId"] = AliasSectionId;
            Results["ParamElementId"] = AliasElementId;
            Results["ParamPageId"] = AliasPageId;
            Results["ParamElementCode"] = AliasElementCode;
            Results["ParamSectionCode"] = AliasSectionCode;
        }

        SectionId = request.Get(ParamSectionId, SectionId);
        ElementId = request.Get(ParamElementId, ElementId);
        PageId = request.Get(ParamPageId, PageId);
        ElementCode = request.Get(ParamElementCode, ElementCode);
        SectionCode = request.Get(ParamSectionCode, SectionCode);

        if (!EnableSef)
        {
            if (PageId > 0) PageKey = "SectionPage";
            else if (ElementId > 0 || !String.IsNullOrEmpty(ElementCode)) PageKey = "Element";
            else if (SectionId > 0 || !String.IsNullOrEmpty(SectionCode)) PageKey = "Section";
        }

        #endregion

        if (String.IsNullOrEmpty(SectionCode) && SectionId <= 0 && IBlockId > 0)
        {
            Results["ShowTopElements"] = true;
        }
        
        Results["SectionURL"] = SectionURL;
        Results["SectionPageURL"] = SectionPageURL;
        Results["ElementURL"] = ElementURL;
        Results["TOPElementURL"] = TOPElementURL;

        Results["SectionId"] = SectionId;
        Results["ElementId"] = ElementId;
        Results["PageId"] = PageId;
        Results["ElementCode"] = ElementCode;
        Results["SectionCode"] = SectionCode;

        Results["PageKey"] = PageKey;

        if (String.IsNullOrEmpty(PageKey))
            IncludeComponentTemplate();
        else if (PageKey == "Element" || PageKey == "ElementTOP")
            IncludeComponentTemplate("element");
        else
            IncludeComponentTemplate();
    }
Esempio n. 21
0
    public override void ProcessMessage(BXCommand cmd, bool executionContext, string executionVirtualPath)
    {
        if (cmd.Action == "Bitrix.Search.ProvideUrl")
        {
            if (cmd.Parameters.Get<string>("moduleId") != "iblock")
                return;
            int iblockId = Parameters.Get("IBlockId", -1);
            if (iblockId < 0 || cmd.Parameters.Get<int>("itemGroup") != iblockId)
                return;
            int elementId = cmd.Parameters.Get("itemId", -1);
            if (elementId < 0)
                return;

            BXIBlockElement ibe = BXIBlockElement.GetById(elementId);
            BXIBlockSection ibs = null;
            if (ibe != null)
                foreach (int sid in ibe.Sections.ToList())
                {
                    ibs = BXIBlockSection.GetById(sid);
                    if (ibs != null)
                        break;
                }
            if (ibe == null || ibs == null)
                return;

            Results["SECTION_ID"] = ibs.Id;
            Results["ELEMENT_ID"] = ibe.Id;
            Results["SECTION_CODE"] = ibs.Code ?? string.Empty;
            Results["ELEMENT_CODE"] = ibe.Code ?? string.Empty;

            string url;
            if (Parameters.Get<bool>("EnableSEF"))
                url =
                    MakeLink(Parameters.Get<string>("SEFFolder"),
                             Parameters.Get<string>("SEF_URL_TEMPLATES_element", "#SECTION_ID#/#ELEMENT_ID#/"));
            else
                url = MakeLink(string.Format(
                                   "{0}?{1}=#SECTION_ID#&{2}=#ELEMENT_ID#",
                                   VirtualPathUtility.ToAbsolute(executionVirtualPath),
                                   Parameters.Get<string>("VARIABLE_ALIASES_SECTION_ID", "SECTION_ID"),
                                   Parameters.Get<string>("VARIABLE_ALIASES_ELEMENT_ID", "ELEMENT_ID")
                                   ));
            cmd.AddCommandResult("bitrix:catalog@" + executionVirtualPath,
                                 new BXCommandResult(BXCommandResultType.Ok, url));
        }

		if (cmd.Action == "Bitrix.Main.GeneratePublicMenu")
		{
			//Bitrix.Diagnostics.BXDump.ToFile(
			//    String.Format(
			//        "executionVirtualPath={0}, uriPath={1}, uri={2}, SefFolder={3}, GenerateMenuType={4}, menuType={5}", 
			//        executionVirtualPath, 
			//        cmd.Parameters.Get<string>("uriPath"), 
			//        cmd.Parameters.Get<string>("uri"), 
			//        Bitrix.IO.BXPath.ToVirtualRelativePath(SEFFolder.TrimStart('\\', '/')),
			//        Parameters.Get("GenerateMenuType", "left"),
			//        cmd.Parameters.Get<string>("menuType")
			//    )
			//);

			//if (!cmd.Parameters.Get<string>("uriPath").StartsWith(Bitrix.IO.BXPath.ToVirtualRelativePath(SEFFolder.TrimStart('\\', '/')) + "/", StringComparison.InvariantCultureIgnoreCase))
				//return;

			//Генерируем меню только для тех адресов, которые выводит сам компонент.
			if (!Parameters.Get<bool>("EnableSEF") && !executionVirtualPath.Equals(cmd.Parameters.Get<string>("uriPath"), StringComparison.InvariantCultureIgnoreCase))
				return;
			else if (Parameters.Get<bool>("EnableSEF") && !cmd.Parameters.Get<string>("uriPath").StartsWith(Bitrix.IO.BXPath.ToVirtualRelativePath(SEFFolder.TrimStart('\\', '/')) + "/", StringComparison.InvariantCultureIgnoreCase))
				return;

			if (!Parameters.Get("GenerateMenuType", "left").Equals(cmd.Parameters.Get<string>("menuType"), StringComparison.InvariantCultureIgnoreCase))
				return;

			int iblockId = Parameters.Get("IBlockId", -1);
			if (iblockId < 0)
			    return;

			BXParamsBag<string> urlToPage = new BXParamsBag<string>();
			BXParamsBag<object> request = new BXParamsBag<object>();
			string PageKey = String.Empty;

			urlToPage.Add("ElementTOP", TOPElementURL.TrimEnd('/', '\\'));
			urlToPage.Add("SectionPage", SectionPageURL.TrimEnd('/', '\\'));
			urlToPage.Add("Element", ElementURL.TrimEnd('/', '\\'));
			urlToPage.Add("Section", SectionURL.TrimEnd('/', '\\'));

			if (EnableSef)
			{
				PageKey = MapVariable(SEFFolder, urlToPage, request, String.Empty, BXUri.ToRelativeUri(cmd.Parameters.Get<string>("uri")));
			}
			else
			{
				BXParamsBag<string> variableAliases = new BXParamsBag<string>();
				variableAliases.Add(ParamSectionId, AliasSectionId);
				variableAliases.Add(ParamElementId, AliasElementId);
				variableAliases.Add(ParamPageId, AliasPageId);
				variableAliases.Add(ParamSectionCode, AliasSectionCode);
				variableAliases.Add(ParamElementCode, AliasElementCode);

				MapVariable(variableAliases, request, BXUri.ToRelativeUri(cmd.Parameters.Get<string>("uri")));
			}

			SectionId = request.Get(ParamSectionId, SectionId);
			ElementId = request.Get(ParamElementId, ElementId);
			PageId = request.Get(ParamPageId, PageId);
			ElementCode = request.Get(ParamElementCode, ElementCode);
			SectionCode = request.Get(ParamSectionCode, SectionCode);

			List<BXPublicMenuItem> resultList = null;
			string parentLevelUri = null;

			if (ElementId > 0 || !String.IsNullOrEmpty(ElementCode))
			{
				if (SectionId > 0 || !String.IsNullOrEmpty(SectionCode))
				{
					BXParamsBag<object> p = new BXParamsBag<object>();
					p["SECTION_ID"] = SectionId;
					p["SECTION_CODE"] = SectionCode;
					parentLevelUri = MakeMenuUri(executionVirtualPath, p);
				}
				else
				{
					BXFilter elFilter = new BXFilter(
						new BXFilterItem(BXIBlockElement.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
						new BXFilterItem(BXIBlockElement.Fields.ActiveDate, BXSqlFilterOperators.Equal, "Y")
					);
					if (ElementId > 0)
						elFilter.Add(new BXFilterItem(BXIBlockElement.Fields.ID, BXSqlFilterOperators.Equal, ElementId));
					else
						elFilter.Add(new BXFilterItem(BXIBlockElement.Fields.Code, BXSqlFilterOperators.Equal, ElementCode));

					BXIBlockElementCollection collElement = BXIBlockElement.GetList(elFilter, null);
					if (collElement != null)
					{
						if (collElement.Count > 0)
						{
							BXIBlockElement.BXInfoBlockElementSectionCollection es = collElement[0].Sections;
							if (es != null)
							{
								if (es.Count > 0)
								{
									SectionId = es[0].SectionId;

									BXParamsBag<object> p = new BXParamsBag<object>();
									p["SECTION_ID"] = SectionId;

									if (Parameters.Get<bool>("EnableSEF") && SectionURL.Contains("#SECTION_CODE#"))
									{
										BXIBlockSectionCollection collSection = BXIBlockSection.GetList(
											new BXFilter(
												new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
												new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
												new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, SectionId),
												new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
											),
											null
										);
										if (collSection != null)
										{
											if (collSection.Count > 0)
											{
												SectionCode = collSection[0].Code;
												p["SECTION_CODE"] = SectionCode;
											}
										}
									}

									parentLevelUri = MakeMenuUri(executionVirtualPath, p);
								}
							}
						}
					}
				}
			}

			if (parentLevelUri == null)
			{
				if (SectionId > 0 || !String.IsNullOrEmpty(SectionCode))
				{
					int parentSectionId = 0;
					bool parentSectionFound = false;

					if (SectionId <= 0)
					{
						BXIBlockSectionCollection coll = BXIBlockSection.GetList(
							new BXFilter(
								new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
								new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
								new BXFilterItem(BXIBlockSection.Fields.Code, BXSqlFilterOperators.Equal, SectionCode),
								new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
							),
							null
						);
						if (coll != null)
						{
							if (coll.Count > 0)
							{
								SectionId = coll[0].Id;
								parentSectionId = coll[0].SectionId;
								parentSectionFound = true;
							}
						}
					}

					if (SectionId > 0)
					{
						BXIBlockSectionCollection coll = BXIBlockSection.GetList(
							new BXFilter(
								new BXFilterItem(BXIBlockSection.Fields.SectionId, BXSqlFilterOperators.Equal, SectionId),
								new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
								new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
								new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
							),
							new BXOrderBy(
								new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
								new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
							)
						);

						resultList = ExtractMenuItemsFromCollection(executionVirtualPath, resultList, coll);

						if (resultList == null)
						{
							if (!parentSectionFound)
							{
								coll = BXIBlockSection.GetList(
									new BXFilter(
										new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
										new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
										new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, SectionId),
										new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
									),
									null
								);
								if (coll != null)
								{
									if (coll.Count > 0)
									{
										parentSectionFound = true;
										parentSectionId = coll[0].SectionId;
									}
								}
							}

							if (parentSectionFound && parentSectionId > 0)
							{
								BXParamsBag<object> p = new BXParamsBag<object>();
								p["SECTION_ID"] = parentSectionId;

								if (Parameters.Get<bool>("EnableSEF") && SectionURL.Contains("#SECTION_CODE#"))
								{
									coll = BXIBlockSection.GetList(
										new BXFilter(
											new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
											new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
											new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, parentSectionId),
											new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
										),
										null
									);
									if (coll != null)
									{
										if (coll.Count > 0)
											p["SECTION_CODE"] = coll[0].Code;
									}
								}

								parentLevelUri = MakeMenuUri(executionVirtualPath, p);
							}
							else
							{
								if (Parameters.Get<bool>("EnableSEF"))
									parentLevelUri = MakeLink(Parameters.Get<string>("SEFFolder"), "");
								else
									parentLevelUri = BXUri.ToAppRelativeUri(executionVirtualPath);
							}
						}
					}
				}
			}

			if (parentLevelUri == null)
			{
				if (resultList == null)
				{
					BXIBlockSectionCollection coll = BXIBlockSection.GetList(
						new BXFilter(
							new BXFilterItem(BXIBlockSection.Fields.SectionId, BXSqlFilterOperators.Equal, null),
							new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"),
							new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y"),
							new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
						),
						new BXOrderBy(
							new BXOrderByPair(BXIBlockSection.Fields.Sort, BXOrderByDirection.Asc),
							new BXOrderByPair(BXIBlockSection.Fields.Name, BXOrderByDirection.Asc)
						)
					);

					resultList = ExtractMenuItemsFromCollection(executionVirtualPath, resultList, coll);
				}
			}

			BXPublicMenu.BXLoadMenuCommandParameter r = new BXPublicMenu.BXLoadMenuCommandParameter(resultList, true, parentLevelUri);
			cmd.AddCommandResult("bitrix:catalog@" + executionVirtualPath, new BXCommandResult(BXCommandResultType.Ok, r));
		}
	}
	public object GetSettings()
	{
		if (!initialized)
			BindField();
		List<BXParamsBag<object>> storage = new List<BXParamsBag<object>>();

		for (int i = 2; i < ListValue.Rows.Count; i++)
		{
			if (((CheckBox)ListValue.Rows[i].Cells[5].Controls[0]).Checked)
				continue;


			string xmlId = ((TextBox)ListValue.Rows[i].Cells[1].Controls[0]).Text;

			string value = ((TextBox)ListValue.Rows[i].Cells[2].Controls[0]).Text;

			string sortStr = ((TextBox)ListValue.Rows[i].Cells[3].Controls[0]).Text;

			int sort;
			if (!int.TryParse(sortStr, out sort))
				sort = 100;

			bool isDefault = ((CheckBox)ListValue.Rows[i].Cells[4].Controls[0]).Checked;


			if (string.IsNullOrEmpty(xmlId)
			|| string.IsNullOrEmpty(value))
				continue;

			BXParamsBag<object> data = new BXParamsBag<object>();
			//data.Add("Id", )
			data.Add("XmlId", xmlId);
			data.Add("Value", value);
			data.Add("Default", isDefault);
			data.Add("Sort", sort);

			storage.Add(data);
		}
		return storage;
	}
		public void Store(BXCustomField field, BXCustomType type)
		{
			if (field == null)
			{
				State.Value = string.Empty;
				return;
			}
			BXParamsBag<object> state = new BXParamsBag<object>();
			state.Add("Settings", field.Settings);
			state.Add("CustomTypeId", field.CustomTypeId);
			state.Add("EditInList", field.EditInList);
			state.Add("FieldName", field.Name);
			state.Add("IsSearchable", field.IsSearchable);
			state.Add("Mandatory", field.Mandatory);
			state.Add("Multiple", field.Multiple);
			state.Add("ShowInFilter", (int)field.ShowInFilter);
			state.Add("ShowInList", field.ShowInList);
			state.Add("Sort", field.Sort);
			state.Add("XmlId", field.XmlId);

			foreach (BXCustomFieldLocalization l in field.Localization)
			{
				string[] phrases = new string[5];
				phrases[0] = l.TextEncoder.Decode(l.EditFormLabel);
				phrases[1] = l.TextEncoder.Decode(l.ErrorMessage);
				phrases[2] = l.TextEncoder.Decode(l.HelpMessage);
				phrases[3] = l.TextEncoder.Decode(l.ListColumnLabel);
				phrases[4] = l.TextEncoder.Decode(l.ListFilterLabel);

				state.Add("Loc." + l.LanguageId, phrases);
			}

			if (type != null)
			{

				IBXCustomTypeAdvancedSetting adv = null;
				try
				{
					adv = type.AdvancedSettings as IBXCustomTypeAdvancedSetting;
				}
				catch
				{
				}
				if (adv != null)
				{
					adv.Initialize(field);
					state.Add("Extras", adv.GetSettings());
				}
			}

			Store(state);
		}
Esempio n. 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region SetupParameters
        SectionId = Parameters.Get("SectionId", 0);

        ShowSubelements = Parameters.Get("ShowSubelements", true);

        SortBy1 = Parameters.Get("SortBy1", "sort");
        SortOrder1 = Parameters.Get("SortOrder1", "Desc");

        PerPageCount = Parameters.Get("PerPageCount", 30);
        PerLineCount = Parameters.Get("PerLineCount", 3);
        Properties = Parameters.GetListString("Properties");

        string PropertyKeywords = Parameters.Get("PropertyKeywords", "-");
        string PropertyDescription = Parameters.Get("PropertyDescription", "-");
        bool AddAdminPanelButtons = Parameters.Get("AddAdminPanelButtons", false);
        bool ShowCompareButton = Parameters.Get("ShowCompareButton", false);
        bool SetPageTitle = Parameters.Get("SetPageTitle", true);
        bool CacheOnFilter = Parameters.Get("CacheOnFilter", false);

		Parameters["PagingAllowAll"] = false.ToString();
        /*bool PagerOverList = Parameters.GetBool("PagerOverList", false);
        bool PagerUnderList = Parameters.GetBool("PagerUnderList", false);
        string CategoryTitle = Parameters.GetString("CategoryTitle", "");
        bool PagerAlways = Parameters.GetBool("PagerAlways", true);
        string TemplateTitle = Parameters.GetString("TemplateTitle", "");
        bool UseInvertedNavigation = Parameters.GetBool("UseInvertedNavigation", false);
        int CacheTimeOnInvertedNavigation = Parameters.GetInt("CacheTimeOnInvertedNavigation", 36000);*/
        #endregion
        
        #region HackUnSef
        string PageKey = String.Empty;

        BXParamsBag<object> request = new BXParamsBag<object>();
        BXParamsBag<string> urlToPage = new BXParamsBag<string>();
        urlToPage.Add("SectionPage", SectionPageURL);
        urlToPage.Add("Section", SectionURL);
        
        if (EnableSef)
        {
            PageKey = MapVariable(SEFFolder, urlToPage, request, String.Empty);

            Results["ParamSectionId"] = ParamSectionId;
            Results["ParamElementId"] = ParamElementId;
            Results["ParamPageId"] = ParamPageId;
            Results["ParamElementCode"] = ParamElementCode;
            Results["ParamSectionCode"] = ParamSectionCode;
        }
        else
        {
            BXParamsBag<string> variableAliases = new BXParamsBag<string>();
			variableAliases.Add(ParamSectionId, AliasSectionId);
			variableAliases.Add(ParamElementId, AliasElementId);
			variableAliases.Add(ParamPageId, AliasPageId);
			variableAliases.Add(ParamSectionCode, AliasSectionCode);
			variableAliases.Add(ParamElementCode, AliasElementCode);
            MapVariable(variableAliases, request);

            Results["ParamSectionId"] = AliasSectionId;
            Results["ParamElementId"] = AliasElementId;
            Results["ParamPageId"] = AliasPageId;
            Results["ParamElementCode"] = AliasElementCode;
            Results["ParamSectionCode"] = AliasSectionCode;
        }

        SectionId = request.Get(ParamSectionId, SectionId);
        //ElementId = request.Get(ParamElementId, ElementId);
        PageId = request.Get(ParamPageId, PageId);
        ElementCode = request.Get<string>(ParamElementCode, ElementCode);
        SectionCode = request.Get<string>(ParamSectionCode, SectionCode);

        // Rewrite default variables
        request.Add(ParamSectionId, SectionId);
        //request.Add(ParamElementId, ElementId);
        request.Add(ParamElementCode, ElementCode);
        request.Add(ParamSectionCode, SectionCode);

        if (!EnableSef)
        {
            if (PageId > 0) PageKey = "SectionPage";
            //else if (ElementId > 0 || !String.IsNullOrEmpty(ElementCode)) PageKey = "Element";
            else if (SectionId > 0 || !String.IsNullOrEmpty(SectionCode)) PageKey = "Section";
        }

        Results["SectionURL"] = SectionURL;
        Results["SectionPageURL"] = SectionPageURL;
        Results["ElementURL"] = ElementURL;

        Results["SectionId"] = SectionId;
        //Results["ElementId"] = ElementId;
        Results["PageId"] = PageId;
        Results["ElementCode"] = ElementCode;
        Results["SectionCode"] = SectionCode;

        Results["PageKey"] = PageKey;
        #endregion

        if (!IsCached(IBlockTypeId, IBlockId, SectionId, PageId, SectionCode))
        {
			if (IBlockId > 0)
			{
				#region MakeComponentDataFilter
				BXIBlockElementCollection es = null;

				BXFilter esf = new BXFilter();
				BXOrderBy eso = new BXOrderBy();

				esf.Add(new BXFilterItem(BXIBlockElement.Fields.Active, BXSqlFilterOperators.Equal, "Y"));

				eso.Add(BXIBlockElement.Fields, String.Format("{0} {1}", SortBy1, SortOrder1));

				if (IBlockId > 0)
				{
					esf.Add(new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId));
				}
				if (!String.IsNullOrEmpty(SectionCode))
				{
					esf.Add(new BXFilterItem(BXIBlockElement.Fields.Sections.Section.Code, BXSqlFilterOperators.Equal, SectionCode));
					if (ShowSubelements)
					{
						esf.Add(new BXFilterItem(BXIBlockElement.Fields.IncludeParentSections, BXSqlFilterOperators.Equal, "Y"));
					}
				}
				else if (SectionId > 0)
				{
					esf.Add(new BXFilterItem(BXIBlockElement.Fields.Sections.Section.ID, BXSqlFilterOperators.Equal, SectionId));
					if (ShowSubelements)
					{
						esf.Add(new BXFilterItem(BXIBlockElement.Fields.IncludeParentSections, BXSqlFilterOperators.Equal, "Y"));
					}
				}
				else
				{
					if (ShowSubelements)
					{
						esf.Add(new BXFilterItem(BXIBlockElement.Fields.IncludeParentSections, BXSqlFilterOperators.Equal, "Y"));
					}
					else
						esf.Add(new BXFilterItem(BXIBlockElement.Fields.Sections.Section.ID, BXSqlFilterOperators.Equal, "0"));
				}
				#endregion

				#region Paging Operations
				string PageUrlTemplate = String.Empty;
				string DefaultPageUrl = String.Empty;
				if (EnableSef)
				{
					DefaultPageUrl = BXComponentManager.MakeLink(SEFFolder, SectionURL);
					PageUrlTemplate = BXComponentManager.MakeLink(SEFFolder, SectionPageURL);
				}
				else
				{
					DefaultPageUrl = SectionURL;
					PageUrlTemplate = SectionPageURL;
				}

				BXQueryParams queryParams = PreparePaging(
					delegate
					{
						return BXIBlockElement.Count(esf);
					},
					request,
					Results.Get<string>("ParamPageId"),
					false,
					DefaultPageUrl,
					PageUrlTemplate,
					string.Empty
				);
				es = BXIBlockElement.GetList(esf, eso, null, queryParams);

				#endregion

				#region SetPageTitle
				if (SetPageTitle)
				{
					string PageTitle = Parameters.Get<string>("SectionTitle", String.Empty);
					if (String.IsNullOrEmpty(PageTitle))
					{
						BXIBlockSection rootSection = null;
						if (!String.IsNullOrEmpty(SectionCode))
						{
							BXFilter sParentFilter = new BXFilter(
									new BXFilterItem(BXIBlockSection.Fields.Code, BXSqlFilterOperators.Equal, SectionCode),
									new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y")
									);

							BXIBlockSectionCollection sCol = BXIBlockSection.GetList(sParentFilter, null);
							if (sCol != null && sCol.Count > 0)
								rootSection = sCol[0];
						}
						else if (SectionId > 0)
							rootSection = BXIBlockSection.GetById(SectionId);

						if (rootSection != null)
							PageTitle = rootSection.Name;
						else
						{
							BXIBlock iblock = BXIBlock.GetById(IBlockId);
							if (iblock != null)
								PageTitle = iblock.Name;
						}
					}

					Results["SectionName"] = PageTitle;
				}
				#endregion

				if (es != null)
				{
					Results["DataVolume"] = es.Count;
				}

				if (es != null && es.Count > 0)
				{
					List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
					foreach (BXIBlockElement el in es)
					{
						Dictionary<string, string> v = new Dictionary<string, string>();

						string imageUrl = String.Empty;
						BXFile image = el.DetailImageId > 0 ? el.DetailImage : el.PreviewImage;

						if (image != null)
							imageUrl = String.Format(
							"{0}ImageResizer.ashx?path={1}&width={2}&height={3}&fit={4}",
							BXUri.ToAbsoluteUri("~/bitrix/handlers/Main/"),
							UrlEncode(image.FileVirtualPath),
							Parameters.Get("PreviewWidth", 150),
							Parameters.Get("PreviewHeight", 150),
							!Parameters.Get<bool>("FlickrMode", false));

						v.Add("Id", el.Id.ToString());
						v.Add("Title", el.Name);
						v.Add("PreviewText", el.PreviewText);
						v.Add("PreviewTextType", el.PreviewTextType.ToString());
						v.Add("PreviewImage", imageUrl);

						request.Add(ParamElementId, el.Id);
						request.Add(ParamElementCode, String.IsNullOrEmpty(el.Code) ? String.Empty : el.Code);
						if (EnableSef)
							v.Add("ElementLink", BXStringUtility.HtmlEncodeEx(MakeLink(SEFFolder, ElementURL, request)));
						else
							v.Add("ElementLink", BXStringUtility.HtmlEncodeEx(MakeLink(ElementURL, request)));

						data.Add(v);

						Dictionary<string, BXCustomProperty> v2 = new Dictionary<string, BXCustomProperty>();
						BXCustomPropertyCollection props = el.Properties;
						if (props != null)
							foreach (KeyValuePair<string, BXCustomProperty> kcs in props)
								if (Properties.Exists(delegate(string x)
								{
									return x.Equals(kcs.Key, StringComparison.InvariantCultureIgnoreCase);
								}))
									v2[kcs.Key] = kcs.Value;

						Results["DataProperties_" + el.Id] = v2;
					}

					Results["Data"] = data;
				}

				Results["EnableAjaxA"] = Parameters.Get<bool>("EnableAjax", false) ? "EnableAjax=\"True\"" : "";
			}
			IncludeComponentTemplate();
        }

		if (SetPageTitle && Results.ContainsKey("SectionName") && Results["SectionName"] != null)
		{
			string PageTitle = Results.Get<string>("SectionName");

			if (Page is BXPublicPage)
				(Page as BXPublicPage).BXTitle = PageTitle;
		}
	}
Esempio n. 25
0
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        paramsBag.Add("pageTitle", mClientPageTitle ?? string.Empty);

        LoadKeywords();
        foreach (KeyValuePair<string, Dictionary<string, string>> keywordPair in _keywords)
        {
            string keywordValue;
            if (!keywordPair.Value.TryGetValue("value", out keywordValue))
                continue;
            paramsBag.Add(string.Format("keyword[{0}]", keywordPair.Key), keywordValue);
        }
    }
    protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
    {
        if (paramsBag == null)
            throw new ArgumentNullException("paramsBag");

        paramsBag.Add(textEditor.ID, Request.Form[textEditor.UniqueID]);
    }
Esempio n. 27
0
	protected override void ExternalizeParameters(BXParamsBag<string> paramsBag)
	{
		if (paramsBag == null)
			throw new ArgumentNullException("paramsBag");

		paramsBag.Add(tbxPageName.ID, tbxPageName.Text);
		paramsBag.Add(tbxTitle.ID, tbxTitle.Text);
		paramsBag.Add(chbxEditAfterSave.ID, chbxEditAfterSave.Checked.ToString());
		paramsBag.Add(chbxAddToMenu.ID, chbxAddToMenu.Checked.ToString());
		paramsBag.Add(tbxMenuName.ID, tbxMenuName.Text);

		paramsBag.Add(ddlMenuTypes.ID, Request.Form[ddlMenuTypes.UniqueID] ?? string.Empty);
		paramsBag.Add(ddlMenuItems.ID, Request.Form[ddlMenuItems.UniqueID] ?? string.Empty);

		//при попытке получения неавторизированным пользователем ёще неясно появится ли право на модификацию меню после авторизации 
		if (!BXUser.Identity.IsAuthenticated && !IsPostBack)
			paramsBag.Add("checkForGrantMenuModification", true.ToString());

		LoadKeywords();
		foreach (KeyValuePair<string, Dictionary<string, string>> keywordPair in _keywords)
		{
			string keywordValue;
			if (!keywordPair.Value.TryGetValue("value", out keywordValue))
				continue;
			paramsBag.Add(string.Format("keyword[{0}]", keywordPair.Key), keywordValue);
		}
	}
Esempio n. 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region InitializeStartup
        SectionId = Parameters.Get("SectionId", 0);

        bool COUNT_ELEMENTS = Parameters.Get<bool>("COUNT_ELEMENTS", false);
        string SortByWhat = Parameters.Get<string>("SortBy", "sort");
        string OrderByWhat = Parameters.Get<string>("OrderBy", "asc");
        #endregion

        BXParamsBag<object> request = new BXParamsBag<object>();

        if (EnableSef)
        {
            BXParamsBag<string> urlToPage = new BXParamsBag<string>();
            urlToPage.Add("Catalog.List0", SectionURL);
            urlToPage.Add("Catalog.List1", SectionPageURL);

            MapVariable(SEFFolder, urlToPage, request);

            Results["ParamSectionId"] = ParamSectionId;
            Results["ParamSectionCode"] = ParamSectionCode;
        }
        else
        {
            BXParamsBag<string> variableAlias = new BXParamsBag<string>();
            variableAlias[ParamSectionId] = AliasSectionId;
            variableAlias[ParamSectionCode] = AliasSectionCode;

            MapVariable(variableAlias, request);

            Results["ParamSectionId"] = AliasSectionId;
            Results["ParamSectionCode"] = AliasSectionCode;
        }

        //IBlockId = request.Get("iblock_id", IBlockId);
        SectionId = request.Get(ParamSectionId, SectionId);
        SectionCode = request.Get<string>(ParamSectionCode, SectionCode);

        // Rewrite default variables
        request.Add(ParamSectionId, SectionId);
        request.Add(ParamSectionCode, SectionCode);        

        Results["SectionURL"] = SectionURL;

        Results["SectionId"] = SectionId;
        Results["SectionCode"] = SectionCode;

        if (EnableSef)
            Results["CatalogRoot"] = BXPath.ToVirtualAbsolutePath(SEFFolder);
        else
            Results["CatalogRoot"] = Parameters.Get<string>("CatalogRoot", BXSefUrlManager.CurrentUrl.AbsolutePath);

        if (!IsCached(IBlockId, SectionId, SectionCode))
        {
            if (IBlockId > 0)
            {
                List<Dictionary<string, string>> sList = new List<Dictionary<string, string>>();
                                        
                int i = 0, baseDepth = 0;
                BXIBlockSectionCollection sections = null;


                if (SectionId <= 0 && String.IsNullOrEmpty(SectionCode))
                {
                    sections = BXIBlockSection.GetTree(IBlockId, Depth + 1);
                }
                else
                {
                    #region SectionList
                    BXOrderBy sOrder = new BXOrderBy();
					sOrder.Add(BXIBlockSection.Fields, String.Format("{0} {1}", SortByWhat, OrderByWhat));
					//sOrder.Add(BXIBlockSection.Fields, String.Format("{0} {1}", "id", "asc"));
                    BXIBlockSection parentSection = null;

                    if (String.IsNullOrEmpty(SectionCode))
                    {
                        if (SectionId > 0)
                            parentSection = BXIBlockSection.GetById(SectionId);
                    }
                    else
                    {
                        BXFilter sParentFilter = new BXFilter(
							new BXFilterItem(BXIBlockSection.Fields.Code, BXSqlFilterOperators.Equal, SectionCode),
							new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y")
                            );

                        BXIBlockSectionCollection sCol = BXIBlockSection.GetList(sParentFilter, null);
                        if (sCol != null && sCol.Count > 0)
                            parentSection = sCol[0];
                    }

                    BXFilter sFilter = new BXFilter(
							new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, IBlockId),
							new BXFilterItem(BXIBlockSection.Fields.Active, BXSqlFilterOperators.Equal, "Y")
                        );

                    if (parentSection != null)
                    {
                        ParentSectionId = parentSection.Id;                        
                        baseDepth = parentSection.DepthLevel;

						sFilter.Add(new BXFilterItem(BXIBlockSection.Fields.LeftMargin, BXSqlFilterOperators.GreaterOrEqual, parentSection.LeftMargin));
						sFilter.Add(new BXFilterItem(BXIBlockSection.Fields.RightMargin, BXSqlFilterOperators.Less, parentSection.RightMargin));
						sFilter.Add(new BXFilterItem(BXIBlockSection.Fields.DepthLevel, BXSqlFilterOperators.LessOrEqual, parentSection.DepthLevel + Depth));

                        sections = BXIBlockSection.GetList(sFilter, sOrder);
                    }
                    #endregion
                    #region NavChain
                    BXIBlockSectionCollection navChain = null;

                    if (SectionId > 0)
                    {
                        navChain = BXIBlockSection.GetNavChain(SectionId);
                    }
                    else if (ParentSectionId > 0)
                    {
                        navChain = BXIBlockSection.GetNavChain(ParentSectionId);                        
                    }

                    Results["NavChain"] = navChain;
                    SetupNavchain(navChain, request);  
                    #endregion
                }
                Results["DataVolume"] = (sections != null) ? sections.Count : 0;
				if (sections != null)
				{
					string str = String.Empty;
					if (EnableSef)
						str = String.Concat(SEFFolder, "/", SectionURL);
					else
						str = SectionURL;

					foreach (BXIBlockSection s in sections)
					{
						Dictionary<string, string> v = new Dictionary<string, string>();
						if (s.DepthLevel == 1)
						{
							i++;
							v.Add("I", (i < 10) ? "0" + i : i.ToString());
						}
						v.Add("SectionId", s.Id.ToString());
						v.Add("Depth", (s.DepthLevel - baseDepth).ToString());
						v.Add("Name", s.Name);
						if (COUNT_ELEMENTS)
							v.Add("ElementsCount", s.ElementsCount.ToString());
						if (!String.IsNullOrEmpty(SectionURL))
						{
							request["iblock_id"] = s.IBlockId;
							request["section_id"] = s.Id;
							request["section_code"] = String.IsNullOrEmpty(s.Code) ? String.Empty : s.Code;
							v.Add("Path", BXUri.ToRelativeUri(MakeLink(str, request)));
						}
						sList.Add(v);
					}
				}

                Results["Section"] = sList;

                Results["EnableAjaxA"] = Parameters.Get<bool>("EnableAjax", false)?
                    "EnableAjax=\"True\"": "";
            }

            IncludeComponentTemplate();
        }
        else
        {
             // 1. NavChain
            if (Results.ContainsKey("NavChain")) SetupNavchain((BXIBlockSectionCollection)Results["NavChain"], request);
        }
	}
Esempio n. 29
0
	BXParamsBag<object> Gather()
	{
		BXParamsBag<object> storage = new BXParamsBag<object>();

		storage.Add("CustomTypeId", UserTypeIdTextBox.SelectedValue);
		storage.Add("EditInList", !DontEditInList.Checked);
		storage.Add("FieldName", FieldNameTextBox.Text);
		storage.Add("IsSearchable", IsSearchable.Checked);
		storage.Add("Mandatory", Mandatory.Checked);
		storage.Add("Multiple", MultipleCheckBox.Checked);
		storage.Add("ShowInFilter", (int)Enum.Parse(typeof(BXCustomFieldFilterVisibility), ShowFilter.SelectedValue));
		storage.Add("ShowInList", !DontShowInList.Checked);
		storage.Add("Sort", Sort.Text);
		storage.Add("XmlId", XmlId.Text);

		foreach (KeyValuePair<string, Dictionary<string, TextBox>> l in locControls)
		{
			string key = "Loc." + l.Key;
			storage[key] = new string[] 
			{
				l.Value["EditFormLabel"].Text,
				l.Value["ErrorMessage"].Text,
				l.Value["HelpMessage"].Text,
				l.Value["ListColumnLabel"].Text,
				l.Value["ListFilterLabel"].Text
			};
		}

		/*
		if (userTypeId != null)
			storage.Add("@CustomTypeId", userTypeId);
		if (fieldName != null)
			storage.Add("@FieldName", fieldName);
		if (multiple != null)
			storage.Add("@Multiple", multiple.Value);
		*/

		if (settings != null)
			storage.Add("Settings", settings.GetSettings());
		if (extraSettings != null)
			storage.Add("Extras", extraSettings.GetSettings());

		storage.Add("@Sender", StoredSender.Value);

		return storage;
	}
Esempio n. 30
0
	private BXParamsBag<string> GetPageSettings()
	{
		BXParamsBag<string> settings = new BXParamsBag<string>();
		foreach (KeyValuePair<string, TextBox> p in keywordsControls)
			settings.Add(p.Key, p.Value.Text);
		return settings;
	}