예제 #1
0
    protected void Behaviour_Yes(object sender, EventArgs e)
    {
        try
        {
            BXUser.DemandOperations(BXRoleOperation.Operations.FileManage);

            if (string.IsNullOrEmpty(mPath))
                throw new InvalidOperationException("Could not find path!");

            string phPath = BXPath.ToPhysicalPath(mPath);
            FileInfo fi = new FileInfo(phPath);
            if (!fi.Exists)
                Close(GetMessage("PATH_IS_NOT_EXISTS"), BXDialogGoodbyeWindow.LayoutType.Error, -1);

            string ext = fi.Extension;

            if (string.Compare(ext, ".aspx", StringComparison.OrdinalIgnoreCase) != 0)
                Close(GetMessage("FILE_HAS_INVALID_EXTENSION"), BXDialogGoodbyeWindow.LayoutType.Error, -1);

            if (string.IsNullOrEmpty(mDirectoryPath))
                throw new InvalidOperationException("Could not find directory path!");

            //если удаляем страницу по умолчанию, то текущим каталогом сразу становиться родительский каталог
            //if(string.Equals(mFileName, BXConfigurationUtility.Constants.DefaultPage, StringComparison.InvariantCultureIgnoreCase))
            //    mDirectoryPath = VirtualPathUtility.GetDirectory(mDirectoryPath);
            //mDirectoryPath = VirtualPathUtility.AppendTrailingSlash(mDirectoryPath);

            //пытаемся перенаправить пользователя на страницу по умолчанию текущего каталога, если её не существует поднимаемся выше по дереву каталогов
            //если удаляем страницу по умолчанию, то текущим каталогом сразу становиться родительский каталог

            string redirectionDirPath = 
				string.Equals(mFileName, BXConfigurationUtility.Constants.DefaultPage, StringComparison.InvariantCultureIgnoreCase) 
				? VirtualPathUtility.GetDirectory(mDirectoryPath) : 
				mDirectoryPath;

            redirectionDirPath = VirtualPathUtility.AppendTrailingSlash(redirectionDirPath);
            string redirectionPath = VirtualPathUtility.Combine(redirectionDirPath, BXConfigurationUtility.Constants.DefaultPage);
            while (!BXSecureIO.FileExists(redirectionPath) && !string.Equals(redirectionDirPath, "~/", StringComparison.Ordinal)) 
            {
                redirectionDirPath = VirtualPathUtility.GetDirectory(redirectionDirPath);
                redirectionPath = VirtualPathUtility.Combine(redirectionDirPath, BXConfigurationUtility.Constants.DefaultPage);
            }

            StringBuilder sb = new StringBuilder(BXSite.GetUrlForPath(redirectionDirPath, null));
            string showModeParamValue = BXConfigurationUtility.GetShowModeParamValue(BXConfigurationUtility.GetShowMode(sb.ToString()));
            sb.Append('?');
            sb.Append(HttpUtility.UrlEncode(BXConfigurationUtility.Constants.ShowModeParamName));
            sb.Append('=');
            sb.Append(HttpUtility.UrlEncode(showModeParamValue));

			BXUndoPageDeletionOperation undoOperation = new BXUndoPageDeletionOperation();
			undoOperation.FileVirtualPath = mPath;
			undoOperation.FileEncodingName = BXConfigurationUtility.DefaultEncoding.WebName;
			undoOperation.FileContent = BXSecureIO.FileReadAllText(mPath, BXConfigurationUtility.DefaultEncoding);
			BXSite site = BXSite.GetCurrentSite(mPath, Bitrix.Services.BXSefUrlManager.CurrentUrl.Host);
			undoOperation.SiteId = site != null ? site.Id : BXSite.DefaultSite.Id;

            BXSecureIO.FileDelete(phPath);

            if (deleteMenuItemChkBx.Checked)
            {
                if (mPathList != null && mPathList.Count > 0)
                    mPathList.Clear();

				string unmapped = Bitrix.Services.BXSiteRemapUtility.UnmapVirtualPath(mPath, site);
			    RemovePathFromMenus(site.DirectoryVirtualPath, site.UrlVirtualPath, site, undoOperation);
            }

			BXUndoInfo undo = new BXUndoInfo();
			undo.Operation = undoOperation;
			undo.Save();

			BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
				GetMessageRaw("OPERATION_IS_COMPLETED_SUCCESSFULLY_UNDO"), 
				string.Concat(undo.GetClientScript(), " return false;"), 
				"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
			BXDialogGoodbyeWindow.SetCurrent(goodbye);

            Redirect(sb.ToString(), string.Empty);
        }
        catch (System.Threading.ThreadAbortException /*exception*/)
        {
            //...игнорируем, вызвано Close();
        }
        catch (Exception exception)
        {
            ShowError(exception.Message);
        }
    }
예제 #2
0
	void wizard_ButtonClick(object sender, BXPageAsDialogButtonClickEventArgs e)
	{
		try
		{
			if (!BXUser.IsCanOperate(BXRoleOperation.Operations.FileManage))
			{
				Close(GetMessage("ACCESS_DENIED"), BXDialogGoodbyeWindow.LayoutType.Error, -1);
				return;
			}

			if (!IsValid)
				return;

			if (e.ButtonEntry != BXPageAsDialogButtonEntry.Done)
				return;

			if (string.IsNullOrEmpty(_clientFileName))
			{
				ShowError(GetMessage("EmptyFileName"));
				return;
			}

			string initClientFileName = _clientFileName;

			if (_clientFileName.EndsWith("."))
				_clientFileName = _clientFileName.Remove(_clientFileName.Length - 1);

			string fnExt = VirtualPathUtility.GetExtension(_clientFileName);
			if (string.IsNullOrEmpty(fnExt))
			{
				_clientFileName = string.Format("{0}.aspx", _clientFileName);
			}
			else if (string.Compare(fnExt, ".aspx", StringComparison.Ordinal) != 0)
			{
				_clientFileName = string.Format("{0}.aspx", _clientFileName);
			}

			//имя 
			string pageNameExtensionless = _clientFileName.Remove(_clientFileName.Length - 5);

			tbxPageName.Text = pageNameExtensionless;
			_clientVirtualPath = VirtualPathUtility.Combine(VirtualPathUtility.AppendTrailingSlash(_clientVirtualDirPath), _clientFileName);

			if (BXSecureIO.FileExists(_clientVirtualPath))
			{
				ShowError(String.Format("{0}: {1}", GetMessage("FileAlreadyExists"), _clientVirtualPath));
				return;
			}

			string menuTypeId = null;
			MenuTypeInfo info = null;
			if (chbxAddToMenu.Checked && ((info = CheckMenuTypeInfo(out menuTypeId)) == null || menuTypeId == null))
			{
				ShowError(GetMessageRaw("Error.YourAccountDontHasTheRightToModifyMenu"));
				return;
			}

			string content = Bitrix.Services.Text.BXDefaultFiles.BuildAspx(!string.IsNullOrEmpty(tbxTitle.Text) ? Encode(tbxTitle.Text) : GetMessage("NoTitle"), _clientVirtualPath, null);

			Bitrix.DataTypes.BXParamsBag<string> keywordBag = new Bitrix.DataTypes.BXParamsBag<string>();

			foreach (string keywordKey in _keywords.Keys)
			{
				if (!IsKeywordValueChanged(keywordKey))
					continue;

				string keywordValue = string.Empty;
				_keywords[keywordKey].TryGetValue("value", out keywordValue);

				if (string.IsNullOrEmpty(keywordValue))
					continue;

				keywordBag.Add(keywordKey, keywordValue);
			}

			content = BXParser.PersistPageKeywords(content, keywordBag);

			BXSecureIO.FileWriteAllText(_clientVirtualPath, content, Bitrix.Configuration.BXConfigurationUtility.DefaultEncoding);

			if (chbxAddToMenu.Checked)
				AddToMenu(menuTypeId, info, pageNameExtensionless);

			BXUndoPageCreationOperation undoOperation = new BXUndoPageCreationOperation();
			undoOperation.FileVirtualPath = _clientVirtualPath;
			undoOperation.MenuTypeId = menuTypeId;

			BXUndoInfo undo = new BXUndoInfo();
			undo.Operation = undoOperation;
			undo.Save();

			BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
				GetMessageRaw("NewPageIsSuccessfullyCreated"), 
				string.Concat(undo.GetClientScript(), " return false;"), 
				"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
			BXDialogGoodbyeWindow.SetCurrent(goodbye);

			if (chbxEditAfterSave.Checked)
			{
				BXDialogSettings dlgSetting = new BXDialogSettings();
				dlgSetting.Height = 604;
				dlgSetting.Width = 968;
				dlgSetting.MinHeight = 400;
				dlgSetting.MinWidth = 780;

				SwitchToDialog(string.Format("{0}?path={1}&clientType=WindowManager&forcedRedirection=&noundo=", VirtualPathUtility.ToAbsolute("~/bitrix/dialogs/VisualPageEditor.aspx"), HttpUtility.UrlEncode(_clientVirtualPath)), dlgSetting, GetMessage("NewPageIsSuccessfullyCreatedShowEditDialog"), BXDialogGoodbyeWindow.LayoutType.Success, 2000);				
				return;
			}
			Redirect(BXSite.GetUrlForPath(_clientVirtualPath, null), string.Empty, BXDialogGoodbyeWindow.LayoutType.Success);
			return;
		}
		catch (System.Threading.ThreadAbortException)
		{
			//...игнорируем, вызвано Close();
		}
		catch (Exception ex)
		{
			Close(ex.Message, BXDialogGoodbyeWindow.LayoutType.Error, -1);
		}
	}
    protected void Behaviour_Save(object sender, EventArgs e)
    {
        BXUser.DemandOperations(BXRoleOperation.Operations.ProductSettingsManage);

        if(!IsValid || ErrorsCount > 0)
            return;

        try
        {
            #region Processing of the template
            string siteTemplateName = GetOwnerSiteTemplateName();

            string sourcePath = string.IsNullOrEmpty(siteTemplateName)
                ? BXPath.Combine(
                    GetComponentTemplatesPath(null),
                    TemplateName
                  )
                : BXPath.Combine(
                    GetSiteComponentTemplatesPath(siteTemplateName, null),
                    TemplateName
                  );

            string destinationSiteTemplateName = SiteTemplateNameForNewItem;
            string destinationSiteTemplatePath = GetSiteTemplatePath(destinationSiteTemplateName);


            if (!BXSecureIO.DirectoryExists(destinationSiteTemplatePath))
            {
                ShowError(string.Format(GetMessageRaw("ERROR_FORMATTED_SITE_TEMPLATE_IS_NOT_FOUND"), destinationSiteTemplateName));
                return;
            }
            string destinationPath = BXPath.Combine(
                GetSiteComponentTemplatesPath(destinationSiteTemplateName, null),
                NameForNewItem
                );

            if (BXSecureIO.DirectoryExists(destinationPath))
            {
                ShowError(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_TEMPLATE_ALREADY_EXISTS"), NameForNewItem, destinationSiteTemplateName));
                return;
            }

            BXSecureIO.DirectoryCopy(sourcePath, destinationPath);
            #endregion

			BXUndoCTCopyOperation undo = new BXUndoCTCopyOperation();
			undo.TemplateVirtualPath = VirtualPathUtility.AppendTrailingSlash(destinationPath);

            #region Processing of dependencies
            string dependenciesFileName = "dependencies.config";
            string dependenciesFilePath = VirtualPathUtility.Combine(
                    VirtualPathUtility.AppendTrailingSlash(destinationPath),
                    dependenciesFileName
                    );

            if (BXSecureIO.FileExists(dependenciesFilePath))
            {
                List<Dictionary<string, string>> dependencyList = null;
                using (TextReader tr = BXSecureIO.FileReadToTextReader(dependenciesFilePath))
                {
                    XmlReaderSettings xrSettings = new XmlReaderSettings();
                    xrSettings.IgnoreComments = true;
                    xrSettings.IgnoreProcessingInstructions = true;
                    xrSettings.IgnoreWhitespace = true;
                    using (XmlReader xr = XmlReader.Create(tr, xrSettings))
                    {
                        string name = null,
                            template = null;
                        while (xr.Read())
                        {
                            if (xr.NodeType != XmlNodeType.Element
                                || !string.Equals(xr.Name, "component", StringComparison.InvariantCultureIgnoreCase))
                                continue;

                            name = xr.MoveToAttribute("name") ? xr.Value : null;
                            template = xr.MoveToAttribute("template") ? xr.Value : null;

                            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(template))
                            {
                                Dictionary<string, string> dependencyDic = new Dictionary<string, string>();
                                dependencyDic.Add("name", name);
                                dependencyDic.Add("template", template);

                                if (dependencyList == null)
                                    dependencyList = new List<Dictionary<string, string>>();
                                dependencyList.Add(dependencyDic);
                            }
                            xr.MoveToElement();
                        }
                    }
                }
                if (dependencyList != null)
                {
                    string parentMacroParameter = "%PARENT%";
                    foreach (Dictionary<string, string> dependency in dependencyList)
                    {
                        string name = dependency["name"],
                            template = dependency["template"];
                        string sourceDir = BXComponentManager.GetTemplateVirtualDir(name, template.Replace(parentMacroParameter, TemplateName), siteTemplateName, null);
                        if (string.IsNullOrEmpty(sourceDir))
                            continue;


                        //string destinationDir = BXPath.Combine(GetSiteComponentTemplatesPath(destinationSiteTemplateName, name), template.Replace(parentMacroParameter, NameForNewItem));
                        string destinationDir = BXPath.Combine(destinationPath, GetComponentTemplatePartialPath(name, template.Replace(parentMacroParameter, NameForNewItem)));

                        if (BXSecureIO.DirectoryExists(destinationDir))
                            continue;

                        BXSecureIO.DirectoryEnsureExists(destinationDir);
                        BXSecureIO.DirectoryCopy(sourceDir, destinationDir);
                    }
                }

                if (BXSecureIO.FileExists(dependenciesFilePath))
                    BXSecureIO.FileDelete(dependenciesFilePath);
            }

            #endregion

            #region Pocessing of the target file


            if (chbxApply.Checked
                && (IsDefaultSiteActive ? rbtnDefaultSiteTemplate.Checked : rbtnActiveSiteTemplate.Checked))
            {
				undo.PageUndo = new BXUndoPageModificationOperation();
				IList<BXSite> sites = BXSite.GetSitesForPath(TargetFileAppRelPath);
				undo.PageUndo.SiteId = (sites.Count > 0 ? sites[0]  : BXSite.DefaultSite).Id;
				undo.PageUndo.FileVirtualPath = TargetFileAppRelPath;
				undo.PageUndo.FileEncodingName = BXConfigurationUtility.DefaultEncoding.WebName;
				undo.PageUndo.FileContent = BXSecureIO.FileReadAllText(undo.PageUndo.FileVirtualPath, BXConfigurationUtility.DefaultEncoding);

                BXPageProxy page = BXPageProxy.Create(TargetFileAppRelPath);
                BXComponentProxy proxy = page.ResolveControlId(TargetElementID);
                proxy.Parameters["Template"].SelectedValue = NameForNewItem;

                if (page.IsDirty)
                    page.Save();
            }
            #endregion

			BXUndoInfo undoInfo = new BXUndoInfo();
			undoInfo.Operation = undo;
			undoInfo.Save();

			BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
				GetMessageRaw("NewTemplateIsSuccessfullyCreated"), 
				string.Concat(undoInfo.GetClientScript(), " return false;"), 
				"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
			BXDialogGoodbyeWindow.SetCurrent(goodbye);

            #region Redirect to new template modification and completion
            if (chbxGo2Modification.Checked)
            {
                string componentTemplateFileName = VirtualPathUtility.GetFileName(TemplatePath);
                string destinationTemplateFilePath = VirtualPathUtility.Combine(VirtualPathUtility.AppendTrailingSlash(destinationPath), componentTemplateFileName);

                if (!BXSecureIO.FileExists(destinationTemplateFilePath))
                {
                    ShowError(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_TEMPLATE_IS_NOT_FOUND_IN_SITE_TEMPLATE"), NameForNewItem, destinationSiteTemplateName));
                    return;
                }

                /*string redirectionUrl = string.Format(
                    "{0}?path={1}&{2}={3}",
                    VirtualPathUtility.ToAbsolute("~/bitrix/admin/FileManEdit.aspx"),
                    HttpUtility.UrlEncode(destinationTemplateFilePath),
                    BXConfigurationUtility.Constants.BackUrl,
                    HttpUtility.UrlEncode(BackUrl));

                Redirect(redirectionUrl, string.Format("{0}. {1}...", GetMessageRaw("OPERATION_COMPLETED_SUCCESSFULLY"), GetMessageRaw("EDITOR_OPENING")), BXDialogGoodbyeWindow.LayoutType.Success, 800);
				*/

				BXDialogSettings dlgSetting = new BXDialogSettings();
				dlgSetting.Height = 604;
				dlgSetting.Width = 968;
				dlgSetting.MinHeight = 400;
				dlgSetting.MinWidth = 780;

				SwitchToDialog(
					string.Format(
						"{0}?path={1}&clientType=WindowManager&vpe_mode=PlainText&noundo=", 
						VirtualPathUtility.ToAbsolute("~/bitrix/dialogs/VisualPageEditor.aspx"), 
						HttpUtility.UrlEncode(destinationTemplateFilePath)), 
						dlgSetting, 
						GetMessage("NewTemplateIsSuccessfullyCreatedShowEditDialog"), 
						BXDialogGoodbyeWindow.LayoutType.Success, 2000);				
            }

			Refresh(string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, -1);
            #endregion
        }
        catch (System.Threading.ThreadAbortException)
        {
            //...игнорируем, вызвано Close();
        }
        catch (Exception exc)
        {
            Close(exc.Message, BXDialogGoodbyeWindow.LayoutType.Error, -1);
        }
    }
예제 #4
0
    protected void Behaviour_Save(object sender, EventArgs e)
    {
        try
        {
            BXUser.DemandOperations(BXRoleOperation.Operations.FileManage);
            if (string.IsNullOrEmpty(mPath))
                throw new InvalidOperationException("Path is not defined!");

            bool isNew = AboutCreationNewFile;

            if (!isNew && !BXSecureIO.FileExists(mPath))
                throw new InvalidOperationException(string.Format("Could not find file by path specified: '{0}'!", mPath));

            //if(!BXPath.IsPage(mPath))
            //    throw new InvalidOperationException(string.Format("Specified file name is not allowed for page: '{0}'!", mPath));

			if (!IsPathFileExtensionAllowed())
				Close(string.Format(GetMessage("FILE_NAME_HAS_NOT_ALLOWED_EXTENSION"), VirtualPathUtility.GetFileName(mPath)), BXDialogGoodbyeWindow.LayoutType.Error, -1);

            if (!isNew)
            {
                Encoding contentEncoding = mContentEncoding != null ? mContentEncoding : BXConfigurationUtility.DefaultEncoding;

				if(Request.QueryString["noundo"] == null)
				{
					BXUndoPageModificationOperation undoOperation = new BXUndoPageModificationOperation();
					undoOperation.FileVirtualPath = mPath;
					undoOperation.FileEncodingName = contentEncoding.WebName;
					undoOperation.FileContent = BXSecureIO.FileReadAllText(mPath, contentEncoding);

					BXUndoInfo undo = new BXUndoInfo();
					undo.Operation = undoOperation;
					undo.Save();

					BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
						GetMessageRaw("OPERATION_HAS_BEEN_COMPLETED_SUCCESSFULLY_UNDO"), 
						string.Concat(undo.GetClientScript(), " return false;"), 
						"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
					BXDialogGoodbyeWindow.SetCurrent(goodbye);
				}

                int i = 0;
                while (BXSecureIO.FileExists(mPath + "." + i))
                    i++;
                string tempFile = mPath + "." + i;

                string content = mMode == VisualPageEditorMode.Standard ? VisualEditor.Content : TextEditor.Text;

                BXSecureIO.FileMove(mPath, tempFile);

                if (IsPathFileExtensionPage())
                    BXSecureIO.SaveAspx(mPath, content, null, contentEncoding);
                else
                    BXSecureIO.FileWriteAllText(mPath, content, contentEncoding);

                BXSecureIO.FileDelete(tempFile);
            }
            else
            {
                if (BXSecureIO.FileExists(mPath))
                    Close(string.Format(GetMessageRaw("FILE_ALREADY_EXISTS"), mPath));

                string content = mMode == VisualPageEditorMode.Standard ? VisualEditor.Content : TextEditor.Text;
                Encoding contentEncoding = mContentEncoding != null ? mContentEncoding : BXConfigurationUtility.DefaultEncoding;

				DirectoryInfo di = new DirectoryInfo(HostingEnvironment.MapPath(mDirectoryPath));
				if(!di.Exists)
					di.Create();

				FileInfo fi = new FileInfo(HostingEnvironment.MapPath(mPath));
				using(FileStream fs = fi.Open(FileMode.CreateNew, FileAccess.Write, FileShare.None))
					using(StreamWriter sw = new StreamWriter(fs, contentEncoding))
						sw.Write(content);
            }

            string returnUrl = ReturnUrl;
            if (string.IsNullOrEmpty(returnUrl))
				returnUrl = IsPathFileExtensionPage() ? (!string.IsNullOrEmpty(mQueryString) ? string.Concat(BXSite.GetUrlForPath(mPath, null), "?", mQueryString) : BXSite.GetUrlForPath(mPath, null)) : string.Empty;
            Redirect(returnUrl, string.Empty, BXDialogGoodbyeWindow.LayoutType.Success);        
		}
        catch (System.Threading.ThreadAbortException)
        {
            //...игнорируем, вызвано Reload();
        }
        catch (Exception ex)
        {
            ShowError(ex.Message);
        }
    }
예제 #5
0
	protected void Behaviour_Save(object sender, EventArgs e)
	{
		try
		{
			bool canOperate = 
				string.IsNullOrEmpty(SiteId) 
				? BXUser.IsCanOperate(BXRoleOperation.Operations.MenuItemsEdit)
				: BXUser.IsCanOperate(BXRoleOperation.Operations.MenuItemsEdit, "main", SiteId);

			if (!canOperate)
				BXSecureIO.DemandWrite(BXPath.Combine(curDir, curMenuType + ".menu"));

			BXUndoMenuModificationOperation undoOperation = new BXUndoMenuModificationOperation();
			undoOperation.SiteId = SiteId;
			undoOperation.DirectoryVirtualPath = VirtualPathUtility.AppendTrailingSlash(curDir);
			undoOperation.MenuTypeId = curMenuType;
			undoOperation.SetMenuItems(BXPublicMenu.Menu.Load(curDir, curMenuType));

			BXUndoInfo undo = new BXUndoInfo();
			undo.Operation = undoOperation;
			undo.Save();

            BXPublicMenu.Menu.Save(curDir, curMenuType, MenuItemCollection);

			BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
				GetMessageRaw("MenuIsSuccessfullyModified"), 
				string.Concat(undo.GetClientScript(), " return false;"), 
				"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
			BXDialogGoodbyeWindow.SetCurrent(goodbye);

			Refresh(string.Empty, BXDialogGoodbyeWindow.LayoutType.Success, -1);
		}
        catch (System.Threading.ThreadAbortException /*ex*/)
        {
            //...игнорируем, вызвано Reload();
        }
		catch (Exception ex)
		{
			ShowError(ex.Message);
		}
	}
예제 #6
0
	void wizard_ButtonClick(object sender, BXPageAsDialogButtonClickEventArgs e)
	{
		try
		{
			if (!BXUser.IsCanOperate(BXRoleOperation.Operations.FileManage))
			{
				Close(GetMessage("ACCESS_DENIED"), BXDialogGoodbyeWindow.LayoutType.Error, -1);
				return;
			}

			if (!IsValid)
				return;

			if (e.ButtonEntry != BXPageAsDialogButtonEntry.Done)
				return;

			if (string.IsNullOrEmpty(_clientDirectoryName))
				throw new InvalidOperationException("ClientDirectoryName is not assigned!");

			if (string.IsNullOrEmpty(_clientVirtualParentDirPath))
				throw new InvalidOperationException("ClientVirtualParentDirPath is not assigned!");

			string clientVirtualSavingPath = VirtualPathUtility.Combine(VirtualPathUtility.AppendTrailingSlash(_clientVirtualPath), _clientDirectoryName);

			if (BXSecureIO.FileExists(clientVirtualSavingPath) || BXSecureIO.DirectoryExists(clientVirtualSavingPath))
			{
				ShowError(String.Format("{0}", GetMessage("FS_ENTITY_ALREADY_EXISTS")));
				return;
			}

			string menuTypeId = null;
			MenuTypeInfo info = null;
			if (chbxAddToMenu.Checked && ((info = CheckMenuTypeInfo(out menuTypeId)) == null || menuTypeId == null))
			{
				ShowError(GetMessageRaw("Error.YourAccountDontHasTheRightToModifyMenu"));
				return;
			}

			BXSecureIO.DirectoryCreate(clientVirtualSavingPath);

			BXSectionInfo dirInfo = BXSectionInfo.GetSection(clientVirtualSavingPath);
			dirInfo.Name = _clientTitle;
			if (_keywords == null)
				throw new InvalidOperationException("Keywords is not assinned!");

			foreach (string keywordKey in _keywords.Keys)
			{
				if (!IsKeywordValueChanged(keywordKey))
					continue;

				string keywordValue = string.Empty;
				_keywords[keywordKey].TryGetValue("value", out keywordValue);
				if (string.IsNullOrEmpty(keywordValue))
					continue;
				dirInfo.Keywords[keywordKey] = keywordValue;
			}

			dirInfo.Save();

			if (chbxAddToMenu.Checked)
				AddToMenu(menuTypeId, info, clientVirtualSavingPath);

			string defaultPagePath = BXPath.Combine(clientVirtualSavingPath, _defaultPageName + ".aspx");

			try
			{
				try
				{
					string content = Bitrix.Services.Text.BXDefaultFiles.BuildAspx(!string.IsNullOrEmpty(_clientTitle) ? Encode(_clientTitle) : Encode(GetMessage("DEFAULT_TITLE")), defaultPagePath, null);
					BXSecureIO.FileWriteAllText(defaultPagePath, content, BXConfigurationUtility.DefaultEncoding);
				}
				catch
				{
					ShowError(String.Format("{0}: '{1}'!", GetMessage("CREATION_OF_DEFAULT_PAGE_IS_FILED"), defaultPagePath));
					return;
				}

				BXUndoSectionCreationOperation undoOperation = new BXUndoSectionCreationOperation();
				undoOperation.SectionVirtualPath = clientVirtualSavingPath;
				undoOperation.MenuTypeId = menuTypeId;

				BXUndoInfo undo = new BXUndoInfo();
				undo.Operation = undoOperation;
				undo.Save();

				BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
					GetMessageRaw("NewFolderIsSuccessfullyCreated"), 
					string.Concat(undo.GetClientScript(), " return false;"), 
					"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
				BXDialogGoodbyeWindow.SetCurrent(goodbye);

				if (chbxEditAfterSave.Checked)
				{
					SwitchToDialog(
						string.Format("{0}?path={1}&clientType=WindowManager&returnUrl={2}&forcedRedirection=&noundo=",
							VirtualPathUtility.ToAbsolute("~/bitrix/dialogs/VisualPageEditor.aspx"),
							HttpUtility.UrlEncode(defaultPagePath),
							HttpUtility.UrlEncode(BXSite.GetUrlForPath(VirtualPathUtility.AppendTrailingSlash(clientVirtualSavingPath), null))
						),
						null,
						GetMessage("NEW_FOLDER_IS_SUCCESSFULLY_CREATED_LOADING_EDITOR"),
						BXDialogGoodbyeWindow.LayoutType.Success, 2000
						);
					return;
				}
			}
			catch (System.Threading.ThreadAbortException /*ex*/)
			{
				//...игнорируем, вызвано response.End();
			}
			catch (Exception ex)
			{
				throw ex;
			}
			Redirect(BXSite.GetUrlForPath(defaultPagePath, null), GetMessage("NEW_FOLDER_IS_SUCCESSFULLY_CREATED_REDIRECTION"), BXDialogGoodbyeWindow.LayoutType.Success);
			return;
		}
		catch (System.Threading.ThreadAbortException /*ex*/)
		{
			//...игнорируем, вызвано Close();
		}
		catch (Exception ex)
		{
			Close(ex.Message, BXDialogGoodbyeWindow.LayoutType.Error, -1);
		}
	}
    protected void Behaviour_Save(object sender, EventArgs e)
    {
        BXUser.DemandOperations(BXRoleOperation.Operations.FileManage);
		BXSecureIO.DemandWrite(TargetFileAppRelPath);
        try 
        {
			BXUndoPageModificationOperation undoOperation = new BXUndoPageModificationOperation();
			undoOperation.FileVirtualPath = TargetFileAppRelPath;
			undoOperation.FileEncodingName = Encoding.UTF8.WebName;
			undoOperation.FileContent = BXSecureIO.FileReadAllText(TargetFileAppRelPath, Encoding.UTF8);

			BXUndoInfo undo = new BXUndoInfo();
			undo.Operation = undoOperation;
			undo.Save();

            BXPageProxy pageProxy = BXPageProxy.Create(TargetFileAppRelPath);
            BXComponent component = Component;
            Bitrix.Components.BXComponentProxy componentProxy = pageProxy.ResolveControlId(component.ID);
            foreach (KeyValuePair<string, BXParam> kv in component.ParamsDefinition)
            {
                if (componentProxy.Parameters.ContainsKey(kv.Key))
                    componentProxy.Parameters.Remove(kv.Key);
                
				BXParam param = kv.Value;
				componentProxy.Parameters.Add(kv.Key, param);
                
				string val;
				if (component.Parameters.TryGetValue(kv.Key, out val))
                {
                    param.SelectedValue = val;
                    param.IsDirty = true;
                }
            }

            if (pageProxy.IsDirty)
                pageProxy.Save();

			BXDialogGoodbyeWindow goodbye = new BXDialogGoodbyeWindow(string.Format(
				GetMessageRaw("OPERATION_HAS_BEEN_COMPLETED_SUCCESSFULLY_UNDO"), 
				string.Concat(undo.GetClientScript(), " return false;"), 
				"#"), -1, BXDialogGoodbyeWindow.LayoutType.Success);
			BXDialogGoodbyeWindow.SetCurrent(goodbye);

            Refresh(string.Empty, BXDialogGoodbyeWindow.LayoutType.Success);
        }
        catch (System.Threading.ThreadAbortException)
        {
            //...игнорируем, вызвано Close();
        }
        catch (Exception exc)
        {
            Close(exc.Message, BXDialogGoodbyeWindow.LayoutType.Error, -1);
        }
    }