protected void Page_Load(object sender, EventArgs e)
	{
        BXIBlock block = null;
		sectionId = base.GetRequestInt("id");
		if (sectionId > 0)
			hfSectionId.Value = sectionId.ToString();
        else
		    Int32.TryParse(hfSectionId.Value, out sectionId);

        iblockId = base.GetRequestInt("iblock_id");

		if (sectionId > 0)
		{
			//section = BXIBlockSection.GetById(sectionId,BXTextEncoder.EmptyTextEncoder);
            BXIBlockSectionCollection sectionCol = BXIBlockSection.GetList(
                new BXFilter(new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, sectionId)),
                null,
                iblockId > 0 ? new BXSelectAdd(BXIBlockSection.Fields.CustomFields[iblockId]) : null,
                null,
				BXTextEncoder.EmptyTextEncoder
                );
            if ((section = sectionCol.Count > 0 ? sectionCol[0] : null) == null)
			{
				sectionId = 0;
				hfSectionId.Value = sectionId.ToString();
			}
		}

		if (sectionId > 0)
		{
			iblockId = section.IBlockId;
			hfIBlockId.Value = iblockId.ToString();
			block = BXIBlock.GetById(iblockId, BXTextEncoder.EmptyTextEncoder);
			typeId = block.TypeId;
			hfTypeId.Value = typeId.ToString();
		}
		else
		{
			//iblockId = base.GetRequestInt("iblock_id");
			if (iblockId > 0)
				hfIBlockId.Value = iblockId.ToString();
            else
			    Int32.TryParse(hfIBlockId.Value, out iblockId);
			block = null;
			if (iblockId > 0)
			{
				block = BXIBlock.GetById(iblockId, BXTextEncoder.EmptyTextEncoder);
				if (block == null)
				{
					iblockId = 0;
					hfIBlockId.Value = iblockId.ToString();
				}
			}

			if (iblockId > 0)
			{
				typeId = block.TypeId;
				hfTypeId.Value = typeId.ToString();
			}
			else
			{
				typeId = base.GetRequestInt("type_id");
				Page.Response.Redirect(String.Format("IBlockAdmin.aspx?type_id={0}", typeId));
			}
		}
		propertyEntryName = BXIBlockSection.GetCustomFieldsKey(iblockId);
        currentIBlock = block;
		int sectionIdTmp = base.GetRequestInt("section_id");
		if (sectionIdTmp > 0)
		{
			redirectSectionId = sectionIdTmp;
			if (sectionId > 0 && section.SectionId != redirectSectionId)
				redirectSectionId = section.SectionId;
		}
		else
		{
			redirectSectionId = 0;
			if (sectionId > 0)
				redirectSectionId = section.SectionId;
		}

		if (!this.BXUser.IsCanOperate("IBlockView", "iblock", iblockId))
			BXAuthentication.AuthenticationRequired();

		currentUserCanModifySection = this.BXUser.IsCanOperate("IBlockModifyStructure", "iblock", iblockId.ToString());

		string success = base.GetRequestString("success");
		if ("Y".Equals(success, StringComparison.InvariantCultureIgnoreCase))
			successMessage.Visible = true;
		else
			successMessage.Visible = false;

		bxweDescription.Visible = BXIBlockModule.UseVisualEditor();
		tbDescription.Visible = !BXIBlockModule.UseVisualEditor();
		rblDescriptionType.Visible = !BXIBlockModule.UseVisualEditor();

		CustomFieldList1.EntityId = propertyEntryName;
        if (section != null)
            CustomFieldList1.Load(section.CustomValues);
	
		if (!Page.IsPostBack)
			LoadData();
	}
예제 #2
0
	protected void Page_Init(object sender, EventArgs e)
	{
		//AccessEdit.FillStandardRoles(false);

		//Context.Items["supa_editor"] = bxweDescription;
		hfIBlockId.Value = Request.Form[hfIBlockId.UniqueID];
		iblockId = GetRequestInt("id");
		if (iblockId > 0)
			hfIBlockId.Value = iblockId.ToString();
		Int32.TryParse(hfIBlockId.Value, out iblockId);
		if (iblockId > 0)
		{
			iblock = BXIBlock.GetById(iblockId, BXTextEncoder.EmptyTextEncoder);
			if (iblock == null)
			{
				iblockId = 0;
				hfIBlockId.Value = "0";
			}
		}

		if (iblockId > 0)
		{
			propertyEntryName = BXIBlockElement.GetCustomFieldsKey(iblockId);
			sectionPropertyEntryName = BXIBlockSection.GetCustomFieldsKey(iblockId);
			typeId = iblock.TypeId;
			hfTypeId.Value = typeId.ToString();
		}
		else
		{
			propertyEntryName = BXIBlockElement.GetCustomFieldsKey(0);
			sectionPropertyEntryName = BXIBlockSection.GetCustomFieldsKey(0);
			typeId = base.GetRequestInt("type_id");
			if (typeId > 0)
				hfTypeId.Value = typeId.ToString();
			Int32.TryParse(hfTypeId.Value, out typeId);
			BXInfoBlockTypeOld type = null;
			if (typeId > 0)
			{
				type = BXInfoBlockTypeManagerOld.GetById(typeId);
				if (type == null)
				{
					typeId = 0;
					hfTypeId.Value = typeId.ToString();
				}
			}

			if (typeId <= 0)
			{
				Page.Response.Redirect(String.Format("IBlockAdmin.aspx?type_id={0}", typeId));
			}
		}

		if (!this.BXUser.IsCanOperate(BXIBlock.Operations.IBlockAdminRead, "iblock", iblockId))
			BXAuthentication.AuthenticationRequired();

		if (iblockId > 0)
			currentUserCanModifyIBlock = this.BXUser.IsCanOperate(BXIBlock.Operations.IBlockManageAdmin, "iblock", iblockId);
		else
			currentUserCanModifyIBlock = this.BXUser.IsCanOperate(BXIBlock.Operations.IBlockManageAdmin);

		cfl.AllowDelete = currentUserCanModifyIBlock;
		cfls.AllowDelete = currentUserCanModifyIBlock;

		PrepareForInsertScript();

		PrepareAccessState();

		cfl.DialogPlaceholder = Dialogs;
		cfls.DialogPlaceholder = Dialogs;
	}
예제 #3
0
	private void InitPage()
	{
		if (initCalled)
			return;
		initCalled = true;

		iblockId = base.GetRequestInt("iblock_id");
		if (iblockId > 0)
			hfIBlockId.Value = iblockId.ToString();
		Int32.TryParse(hfIBlockId.Value, out iblockId);
		if (iblockId > 0)
		{
			iblock = BXIBlock.GetById(iblockId);
			if (iblock == null)
			{
				iblockId = 0;
				hfIBlockId.Value = iblockId.ToString();
			}
		}

		if (iblockId > 0)
		{
			typeId = iblock.TypeId;
			hfTypeId.Value = typeId.ToString();
			type = BXIBlockType.GetById(typeId);
			if (type == null)
				Response.Redirect("IBlockTypeList.aspx");
		}
		else
		{
			typeId = base.GetRequestInt("type_id");
			if (typeId > 0)
				hfTypeId.Value = typeId.ToString();
			Int32.TryParse(hfTypeId.Value, out typeId);
			Page.Response.Redirect(String.Format("IBlockAdmin.aspx?type_id={0}", typeId));
		}

		if (!BXIBlock.IsUserCanOperate(iblockId, BXIBlock.Operations.IBlockAdminRead))
			BXAuthentication.AuthenticationRequired();

		filterSectionId.Values.Add(new ListItem(GetMessageRaw("Any"), ""));
		filterSectionId.Values.Add(new ListItem(GetMessageRaw("TopLevel"), "0"));

		BXIBlockSectionCollection sections =  BXIBlockSection.GetList(
			new BXFilter(new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)),
			new BXOrderBy(new BXOrderByPair(BXIBlockSection.Fields.LeftMargin, BXOrderByDirection.Asc)),
			null,
			null,
			BXTextEncoder.EmptyTextEncoder
		);

		foreach (BXIBlockSection section in sections)
		{
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < section.DepthLevel; i++)
				sb.Append(" . ");
			sb.Append(section.Name);
			filterSectionId.Values.Add(new ListItem(sb.ToString(), section.Id.ToString()));
		}

		canModifySections = BXIBlock.IsUserCanOperate(iblockId, BXIBlock.Operations.IBlockModifySections);
		canModifyElements = BXIBlock.IsUserCanOperate(iblockId, BXIBlock.Operations.IBlockModifyElements);

		AddSectionButton.Visible = canModifySections;
		AddElementButton.Visible = canModifyElements;
        int sectionId = GetElementSectionId(0);
        currentSection = (sectionId == 0) ? null :BXIBlockSection.GetById(sectionId);
	}
예제 #4
0
	private bool CreateIBlock()
	{
		try
		{
			if (!currentUserCanModifyIBlock)
				throw new Exception(GetMessageRaw("Exception.YouDontHaveRightsToCreateNewTask"));

			BXFile fImage = SaveFile();

			List<string> sitesList = new List<string>();
			foreach (ListItem item in cblSites.Items)
				if (item.Selected)
					sitesList.Add(item.Value);

			int sort;
			int.TryParse(tbSort.Text, out sort);

			string descr = null;
			BXTextType descrType = BXTextType.Text;
			if (BXIBlockModule.UseVisualEditor())
			{
				descr = bxweDescription.Content;
				descrType = (bxweDescription.StartMode == BXWebEditor.StartModeType.PlainText) ? BXTextType.Text : BXTextType.Html;
			}
			else
			{
				descr = tbDescription.Text;
				descrType = ("text".Equals(rblDescriptionType.SelectedValue, StringComparison.InvariantCultureIgnoreCase) ? BXTextType.Text : BXTextType.Html);
			}

			iblock = new BXIBlock(typeId, tbName.Text);
			iblock.Code = tbCode.Text;
			iblock.Active = cbActive.Checked;
			iblock.Sort = sort > 0 ? sort : 500;
			iblock.ImageId = (fImage != null) ? fImage.Id : 0;
			iblock.DescriptionType = descrType;
			iblock.Description = descr;
			iblock.XmlId = tbXmlId.Text;
			//iblock.SectionName = tbSectionName.Text;
			//iblock.SectionsName = tbSectionsName.Text;
			//iblock.ElementName = tbElementName.Text;
			//iblock.ElementsName = tbElementsName.Text;

			iblock.CaptionsInfo.SectionName = tbSectionName.Text;
			iblock.CaptionsInfo.ElementName = tbElementName.Text;
			iblock.CaptionsInfo.SectionsName = tbSectionsName.Text;
			iblock.CaptionsInfo.ElementsName = tbElementsName.Text;

			iblock.CaptionsInfo.AddElement = tbAddElement.Text;
			iblock.CaptionsInfo.ChangeElement = tbChangeElement.Text;
			iblock.CaptionsInfo.DeleteElement = tbDeleteElement.Text;
			iblock.CaptionsInfo.AddSection = tbAddSection.Text;
			iblock.CaptionsInfo.ChangeSection = tbChangeSection.Text;
			iblock.CaptionsInfo.DeleteSection = tbDeleteSection.Text;

			iblock.CaptionsInfo.NewElement = tbNewElement.Text;
			iblock.CaptionsInfo.ElementList = tbElementList.Text;
			iblock.CaptionsInfo.ModifyingElement = tbModifyingElement.Text;
			iblock.CaptionsInfo.NewSection = tbNewSection.Text;
			iblock.CaptionsInfo.SectionList = tbSectionList.Text;
			iblock.CaptionsInfo.ModifyingSection = tbModifyingSection.Text;

			iblock.IndexContent = BXModuleManager.IsModuleInstalled("search") ? cbIndexContent.Checked : true;
			iblock.SetSiteIds(sitesList.ToArray());
			iblock.Create();
			
			if (iblock == null)
				throw new Exception(GetMessageRaw("Exception.BlockCreationFailed"));

			SaveAccessState();

			iblockId = iblock.Id;
			hfIBlockId.Value = iblockId.ToString();
			typeId = iblock.TypeId;
			hfTypeId.Value = typeId.ToString();

			return true;
		}
		catch (BXEventException e)
		{
			foreach (string s in e.Messages)
				errorMassage.AddErrorMessage(s);
		}
		catch (Exception e)
		{
			errorMassage.AddErrorMessage(e.Message);
		}
		return false;
	}