forked from DNN-Connect/CKEditorProvider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CKEditorOptions.ascx.cs
3579 lines (2942 loc) · 142 KB
/
CKEditorOptions.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using DNNConnect.CKEditorProvider.Constants;
using DNNConnect.CKEditorProvider.Controls;
using DNNConnect.CKEditorProvider.Extensions;
using DNNConnect.CKEditorProvider.Objects;
using DNNConnect.CKEditorProvider.Utilities;
using DotNetNuke.Collections;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Definitions;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Framework.Providers;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Installer.Packages;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.Utilities;
using DotNetNuke.Web.Client.ClientResourceManagement;
using Globals = DotNetNuke.Common.Globals;
namespace DNNConnect.CKEditorProvider
{
/// <summary>
/// The CKEditor options page.
/// </summary>
public partial class CKEditorOptions : PortalModuleBase
{
#region Constants and Fields
/// <summary>
/// The provider type.
/// </summary>
private const string ProviderType = "htmlEditor";
/// <summary>
/// The provider config.
/// </summary>
private readonly ProviderConfiguration provConfig = ProviderConfiguration.GetProviderConfiguration(ProviderType);
/// <summary>
/// The request.
/// </summary>
private readonly HttpRequest request = HttpContext.Current.Request;
/// <summary>
/// The _portal settings.
/// </summary>
private PortalSettings _portalSettings;
/// <summary>
/// Override Default Config Folder from Web.config
/// </summary>
private string configFolder = string.Empty;
/// <summary>
/// The list toolbars.
/// </summary>
private List<ToolbarSet> listToolbars;
/// <summary>
/// The list of all available toolbar buttons.
/// </summary>
private List<ToolbarButton> listButtons;
/// <summary>
/// The list of all available toolbar buttons.
/// </summary>
private List<ToolbarButton> allListButtons;
private EditorProviderSettings currentSettings;
/// <summary>
/// The module instance name
/// </summary>
private string moduleInstanceName;
/// <summary>
/// Gets or sets The Full Toolbar Set
/// </summary>
private ToolbarSet toolbarSets;
#endregion
#region Properties
/// <summary>
/// Gets or sets a value indicating whether this instance is host mode.
/// </summary>
/// <value>
/// <c>true</c> if this instance is host mode; otherwise, <c>false</c>.
/// </value>
public bool IsHostMode
{
get
{
return ViewState["IsHostMode"] != null && (bool)ViewState["IsHostMode"];
}
set
{
ViewState["IsHostMode"] = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [current portal only].
/// </summary>
/// <value>
/// <c>true</c> if [current portal only]; otherwise, <c>false</c>.
/// </value>
public bool CurrentPortalOnly
{
get
{
return ViewState["CurrentPortalOnly"] != null && (bool)ViewState["CurrentPortalOnly"];
}
set
{
ViewState["CurrentPortalOnly"] = value;
}
}
/// <summary>
/// Gets or sets the Current or selected Tab ID.
/// </summary>
public int CurrentOrSelectedTabId
{
get
{
var o = ViewState["CurrentTabId"];
if (o != null)
{
return (int)o;
}
return 1;
}
set
{
ViewState["CurrentTabId"] = value;
}
}
/// <summary>
/// Gets or sets the Current or selected Portal ID.
/// </summary>
public int CurrentOrSelectedPortalId
{
get
{
return ViewState["CurrentPortalId"] != null ? (int)ViewState["CurrentPortalId"] : 0;
}
set
{
ViewState["CurrentPortalId"] = value;
}
}
/// <summary>
/// Gets or sets the default host load mode.
/// </summary>
/// <value>
/// The default host load mode.
/// </value>
public int DefaultHostLoadMode
{
get
{
return ViewState["DefaultHostLoadMode"] != null ? (int)ViewState["DefaultHostLoadMode"] : 0;
}
set
{
ViewState["DefaultHostLoadMode"] = value;
}
}
/// <summary>
/// Gets Current Language from Url
/// </summary>
protected string LangCode
{
get
{
return !string.IsNullOrEmpty(request.QueryString["langCode"])
? request.QueryString["langCode"]
: CultureInfo.CurrentCulture.Name;
}
}
/// <summary>
/// Gets the Name for the Current Resource file name
/// </summary>
protected string ResXFile
{
get
{
return
ResolveUrl(
string.Format(
"~/Providers/HtmlEditorProviders/DNNConnect.CKE/{0}/Options.aspx.resx",
Localization.LocalResourceDirectory));
}
}
/// <summary>
/// Gets or sets the current settings mode
/// </summary>
private SettingsMode CurrentSettingsMode
{
get
{
return (SettingsMode)ViewState["CurrentSettingsMode"];
}
set
{
ViewState["CurrentSettingsMode"] = value;
}
}
/// <summary>
/// Gets the Config Url Control.
/// </summary>
private UrlControl ConfigUrl
{
get
{
return ctlConfigUrl;
}
}
/// <summary>
/// Gets the CSS Url Control.
/// </summary>
private UrlControl CssUrl
{
get
{
return ctlCssurl;
}
}
/// <summary>
/// Gets the Import File Url Control.
/// </summary>
private UrlControl ImportFile
{
get
{
return ctlImportFile;
}
}
/// <summary>
/// Gets the Template Url Control.
/// </summary>
private UrlControl TemplUrl
{
get
{
return ctlTemplUrl;
}
}
/// <summary>
/// Gets the Custom JS File Url Control.
/// </summary>
private UrlControl CustomJsFile
{
get
{
return ctlCustomJsFile;
}
}
private ModuleInfo _currentModule;
private ModuleInfo CurrentModule
{
get
{
if (_currentModule != null)
{
return _currentModule;
}
if (ModuleConfiguration != null && !Null.IsNull(ModuleConfiguration.ModuleID))
{
_currentModule = ModuleConfiguration;
return _currentModule;
}
_currentModule = new ModuleController().GetModule(
Request.QueryString.GetValueOrDefault("ModuleId", -1),
TabId,
false);
return _currentModule;
}
}
#endregion
#region Methods
/// <summary>
/// Binds the options data.
/// </summary>
/// <param name="reloadOptionsfromModule">if set to <c>true</c> [reload options from module].</param>
internal void BindOptionsData(bool reloadOptionsfromModule = false)
{
// Check if Options Window is in Host Page
if (IsHostMode)
{
if (!Page.IsPostBack)
{
LastTabId.Value = "0";
}
_portalSettings = GetPortalSettings();
FillFolders();
RenderUrlControls(true);
FillRoles();
BindUserGroupsGridView();
lblSetFor.Visible = false;
rBlSetMode.Visible = false;
lnkRemoveAll.Visible = false;
InfoTabLi.Visible = false;
InfoTabHolder.Visible = false;
if (DefaultHostLoadMode.Equals(0))
{
lblSettings.Text = string.Format(
"{0} - <em>{1} {2} - Portal ID: {3}</em>",
Localization.GetString("lblSettings.Text", ResXFile, LangCode),
Localization.GetString("lblPortal.Text", ResXFile, LangCode),
_portalSettings.PortalName,
CurrentOrSelectedPortalId);
}
else if (DefaultHostLoadMode.Equals(1))
{
lblSettings.Text = string.Format(
"{0} - <em>{1} {2} - TabID: {3}</em>",
Localization.GetString("lblSettings.Text", ResXFile, LangCode),
Localization.GetString("lblPage.Text", ResXFile, LangCode),
new TabController().GetTab(CurrentOrSelectedTabId, _portalSettings.PortalId, false)
.TabName,
CurrentOrSelectedTabId);
}
else
{
lblSettings.Text = Localization.GetString("lblSettings.Text", ResXFile, LangCode);
}
LoadSettings(DefaultHostLoadMode);
}
else
{
var pageKey = string.Format("DNNCKT#{0}#", CurrentOrSelectedTabId);
var moduleKey = string.Format("DNNCKMI#{0}#INS#{1}#", ModuleId, moduleInstanceName);
if (SettingsUtil.CheckExistsModuleInstanceSettings(moduleKey, ModuleId))
{
LoadSettings(2);
}
else
{
var settingsDictionary = EditorController.GetEditorHostSettings();
LoadSettings(SettingsUtil.CheckExistsPortalOrPageSettings(settingsDictionary, pageKey) ? 1 : 0);
}
}
}
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit(EventArgs e)
{
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Handles the Load event of the Page control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void Page_Load(object sender, EventArgs e)
{
AddJavaScripts();
if (Utility.IsInRoles(_portalSettings.AdministratorRoleName, _portalSettings))
{
if (Page.IsPostBack)
{
return;
}
SetLanguage();
FillInformations();
// Load Skin List
FillSkinList();
FillFolders();
RenderUrlControls();
FillRoles();
BindUserGroupsGridView();
BindOptionsData();
// Remove CKFinder from the Browser list if not installed
if (
!File.Exists(Globals.ApplicationMapPath + "/Providers/HtmlEditorProviders/DNNConnect.CKE/ckfinder/ckfinder.js"))
{
ddlBrowser.Items.RemoveAt(2);
}
}
else
{
Visible = false;
Page.ClientScript.RegisterStartupScript(
GetType(),
"errorcloseScript",
string.Format(
"javascript:alert('{0}');self.close();",
Localization.GetString("Error1.Text", ResXFile, LangCode)),
true);
}
LocalResourceFile = ResXFile;
}
/// <summary>
/// Adds the Java scripts.
/// </summary>
private void AddJavaScripts()
{
ClientResourceManager.RegisterStyleSheet(
Page,
ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/css/jquery.notification.css"));
ClientResourceManager.RegisterStyleSheet(
Page,
ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/css/Options.css"));
JavaScript.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn_dom);
JavaScript.RequestRegistration(CommonJs.jQuery);
JavaScript.RequestRegistration(CommonJs.jQueryMigrate);
JavaScript.RequestRegistration(CommonJs.jQueryUI);
JavaScript.RequestRegistration(CommonJs.DnnPlugins);
ScriptManager.RegisterClientScriptInclude(
this,
typeof(Page),
"jquery.notification",
ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/jquery.notification.js"));
ScriptManager.RegisterClientScriptInclude(
this,
typeof(Page),
"OptionsJs",
ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/Options.js"));
}
/// <summary>
/// Import Current Settings
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void Import_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(ImportFile.Url))
{
return;
}
string sXmlImport = ImportFile.Url;
upOptions.Update();
// RESET Dialog
ImportFile.Url = null;
int imageFileId = int.Parse(sXmlImport.Substring(7));
// FileInfo objFileInfo = objFileController.GetFileById(imageFileId, this._portalSettings.PortalId);
var objFileInfo = FileManager.Instance.GetFile(imageFileId);
sXmlImport = _portalSettings.HomeDirectoryMapPath + objFileInfo.Folder + objFileInfo.FileName;
try
{
ImportXmlFile(sXmlImport);
ShowNotification(Localization.GetString("Imported.Text", ResXFile, LangCode), "success");
}
catch (Exception)
{
ShowNotification(
Localization.GetString("BadImportXml.Text", ResXFile, LangCode), "error");
}
}
/// <summary>
/// Export Current Settings
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void Export_Click(object sender, EventArgs e)
{
var exportSettings = ExportSettings();
// Save XML file
try
{
var serializer = new XmlSerializer(typeof(EditorProviderSettings));
var xmlFileName = !string.IsNullOrEmpty(ExportFileName.Text.Trim())
? ExportFileName.Text
: string.Format("CKEditorSettings-{0}.xml", exportSettings.SettingMode);
if (!xmlFileName.EndsWith(".xml"))
{
xmlFileName += ".xml";
}
var exportFolderInfo = FolderManager.Instance.GetFolder(Convert.ToInt32(ExportDir.SelectedValue));
var textWriter = ExportDir.SelectedValue.Equals("-1")
? new StreamWriter(
Path.Combine(_portalSettings.HomeDirectoryMapPath, xmlFileName))
: new StreamWriter(Path.Combine(exportFolderInfo.PhysicalPath, xmlFileName));
serializer.Serialize(textWriter, exportSettings);
textWriter.Close();
ShowNotification(Localization.GetString("Export.Text", ResXFile, LangCode), "success");
}
catch (Exception exception)
{
ShowNotification(exception.Message, "error");
}
upOptions.Update();
}
/// <summary>
/// Imports the XML file.
/// </summary>
/// <param name="xmlFilePath">The XML file path.</param>
/// <param name="changeMode">if set to <c>true</c> [change mode].</param>
private void ImportXmlFile(string xmlFilePath, bool changeMode = true)
{
var serializer = new XmlSerializer(typeof(EditorProviderSettings));
var textReader = new StreamReader(xmlFilePath);
var importedSettings = (EditorProviderSettings)serializer.Deserialize(textReader);
if (!string.IsNullOrEmpty(importedSettings.EditorWidth))
{
importedSettings.Config.Width = importedSettings.EditorWidth;
}
if (!string.IsNullOrEmpty(importedSettings.EditorHeight))
{
importedSettings.Config.Height = importedSettings.EditorHeight;
}
textReader.Close();
FillSettings(importedSettings, changeMode);
}
/// <summary>
/// Fills the setting controls with the loaded Setting Values.
/// </summary>
/// <param name="importedSettings">The imported settings.</param>
/// <param name="changeMode">if set to <c>true</c> [change mode].</param>
private void FillSettings(EditorProviderSettings importedSettings, bool changeMode = true)
{
// Editor config settings
foreach (
PropertyInfo info in
SettingsUtil.GetEditorConfigProperties())
{
object value = null;
if (!info.Name.Equals("CodeMirror") && !info.Name.Equals("WordCount"))
{
value = info.GetValue(importedSettings.Config, null);
if (value == null)
{
continue;
}
}
switch (info.PropertyType.Name)
{
case "Decimal":
case "Int32":
case "String":
{
var textBox = Utility.FindControl<TextBox>(EditorConfigHolder, info.Name);
if (textBox != null)
{
textBox.Text = value.ToString();
}
}
break;
case "Boolean":
{
var checkBox = Utility.FindControl<CheckBox>(EditorConfigHolder, info.Name);
if (checkBox != null)
{
checkBox.Checked = (bool)value;
}
}
break;
}
switch (info.Name)
{
case "ContentsLangDirection":
case "EnterMode":
case "ShiftEnterMode":
case "ToolbarLocation":
case "DefaultLinkType":
{
var dropDownList = Utility.FindControl<DropDownList>(EditorConfigHolder, info.Name);
if (dropDownList != null)
{
if (dropDownList.Items.FindByValue(value.ToString()) != null)
{
dropDownList.ClearSelection();
dropDownList.Items.FindByValue(value.ToString()).Selected = true;
}
}
}
break;
case "CodeMirror":
{
foreach (
var codeMirrorInfo in
typeof(CodeMirror).GetProperties()
.Where(codeMirrorInfo => !codeMirrorInfo.Name.Equals("Theme")))
{
value = codeMirrorInfo.GetValue(importedSettings.Config.CodeMirror, null);
if (value == null)
{
continue;
}
switch (codeMirrorInfo.PropertyType.Name)
{
case "String":
{
var textBox = Utility.FindControl<TextBox>(EditorConfigHolder, codeMirrorInfo.Name);
if (textBox != null)
{
textBox.Text = value.ToString();
}
}
break;
case "Boolean":
{
var checkBox = Utility.FindControl<CheckBox>(EditorConfigHolder, codeMirrorInfo.Name);
if (checkBox != null)
{
checkBox.Checked = (bool)value;
}
}
break;
}
}
}
break;
case "WordCount":
{
foreach (var wordCountInfo in typeof(WordCountConfig).GetProperties())
{
value = wordCountInfo.GetValue(importedSettings.Config.WordCount, null);
if (value == null)
{
continue;
}
switch (wordCountInfo.PropertyType.Name)
{
case "String":
{
var textBox = Utility.FindControl<TextBox>(EditorConfigHolder, wordCountInfo.Name);
if (textBox != null)
{
textBox.Text = value.ToString();
}
}
break;
case "Boolean":
{
var checkBox = Utility.FindControl<CheckBox>(EditorConfigHolder, wordCountInfo.Name);
if (checkBox != null)
{
checkBox.Checked = (bool)value;
}
}
break;
}
}
}
break;
}
}
///////////////////
if (!string.IsNullOrEmpty(importedSettings.Config.Skin)
&& ddlSkin.Items.FindByValue(importedSettings.Config.Skin) != null)
{
ddlSkin.ClearSelection();
ddlSkin.SelectedValue = importedSettings.Config.Skin;
}
if (!string.IsNullOrEmpty(importedSettings.Config.CodeMirror.Theme)
&& CodeMirrorTheme.Items.FindByValue(importedSettings.Config.CodeMirror.Theme) != null)
{
CodeMirrorTheme.ClearSelection();
CodeMirrorTheme.SelectedValue = importedSettings.Config.CodeMirror.Theme;
}
if (!string.IsNullOrEmpty(importedSettings.Browser)
&& ddlBrowser.Items.FindByValue(importedSettings.Browser) != null)
{
ddlBrowser.ClearSelection();
ddlBrowser.SelectedValue = importedSettings.Browser;
}
FileListPageSize.Text = importedSettings.FileListPageSize.ToString();
FileListViewMode.SelectedValue = importedSettings.FileListViewMode.ToString();
DefaultLinkMode.SelectedValue = importedSettings.DefaultLinkMode.ToString();
UseAnchorSelector.Checked = importedSettings.UseAnchorSelector;
ShowPageLinksTabFirst.Checked = importedSettings.ShowPageLinksTabFirst;
cbBrowserDirs.Checked = importedSettings.SubDirs;
OverrideFileOnUpload.Checked = importedSettings.OverrideFileOnUpload;
BrowserRootDir.SelectedValue =
BrowserRootDir.Items.FindByValue(importedSettings.BrowserRootDirId.ToString()) != null
? importedSettings.BrowserRootDirId.ToString()
: "-1";
UploadDir.SelectedValue = UploadDir.Items.FindByValue(importedSettings.UploadDirId.ToString())
!= null
? importedSettings.UploadDirId.ToString()
: "-1";
var configFolderInfo =
Utility.ConvertFilePathToFolderInfo(
!string.IsNullOrEmpty(configFolder)
? Path.Combine(_portalSettings.HomeDirectoryMapPath, configFolder)
: _portalSettings.HomeDirectoryMapPath,
_portalSettings);
ExportDir.SelectedValue = configFolderInfo != null
&&
ExportDir.Items.FindByValue(configFolderInfo.FolderID.ToString())
!= null
? configFolderInfo.FolderID.ToString()
: "-1";
ExportFileName.Text = string.Format("CKEditorSettings-{0}.xml", importedSettings.SettingMode);
switch (importedSettings.SettingMode)
{
case SettingsMode.Portal:
ExportFileName.Text = string.Format(
"CKEditorSettings-{0}-{1}.xml", importedSettings.SettingMode, _portalSettings.PortalId);
break;
case SettingsMode.Page:
ExportFileName.Text = string.Format(
"CKEditorSettings-{0}-{1}.xml", importedSettings.SettingMode, CurrentOrSelectedTabId);
break;
case SettingsMode.ModuleInstance:
ExportFileName.Text = string.Format(
"CKEditorSettings-{0}-{1}.xml", importedSettings.SettingMode, ModuleId);
break;
}
txtResizeHeight.Text = importedSettings.ResizeWidth.ToString();
txtResizeHeight.Text = importedSettings.ResizeHeight.ToString();
InjectSyntaxJs.Checked = importedSettings.InjectSyntaxJs;
if (Utility.IsUnit(importedSettings.Config.Width))
{
txtWidth.Text = importedSettings.Config.Width;
}
if (Utility.IsUnit(importedSettings.Config.Height))
{
txtHeight.Text = importedSettings.Config.Height;
}
if (!string.IsNullOrEmpty(importedSettings.BlankText))
{
txtBlanktext.Text = importedSettings.BlankText;
}
var imporUploadSizeRoles = importedSettings.UploadSizeRoles;
// Load Upload Size Setting for Each Portal Role
foreach (var uploadSizeRole in imporUploadSizeRoles)
{
if (uploadSizeRole.RoleId.Equals(-1))
{
for (int i = 0; i < UploadFileLimits.Rows.Count; i++)
{
Label label = (Label)UploadFileLimits.Rows[i].Cells[0].FindControl("lblRoleName");
if (label == null || !label.Text.Equals("Unauthenticated Users"))
{
continue;
}
var sizeLimit =
(TextBox)UploadFileLimits.Rows[i].Cells[1].FindControl("SizeLimit");
sizeLimit.Text = uploadSizeRole.UploadFileLimit.ToString();
}
}
else
{
RoleInfo objRole = RoleController.Instance.GetRoleById(_portalSettings.PortalId, uploadSizeRole.RoleId);
if (objRole == null)
{
continue;
}
for (int i = 0; i < UploadFileLimits.Rows.Count; i++)
{
Label label = (Label)UploadFileLimits.Rows[i].Cells[0].FindControl("lblRoleName");
if (label == null || !label.Text.Equals(objRole.RoleName))
{
continue;
}
var sizeLimit =
(TextBox)UploadFileLimits.Rows[i].Cells[1].FindControl("SizeLimit");
sizeLimit.Text = uploadSizeRole.UploadFileLimit.ToString();
}
}
}
if (!string.IsNullOrEmpty(importedSettings.Config.ContentsCss))
{
CssUrl.Url = ReFormatURL(importedSettings.Config.ContentsCss);
}
if (!string.IsNullOrEmpty(importedSettings.Config.Templates_Files))
{
TemplUrl.Url = ReFormatURL(importedSettings.Config.Templates_Files);
}
if (!string.IsNullOrEmpty(importedSettings.CustomJsFile))
{
CustomJsFile.Url = ReFormatURL(importedSettings.CustomJsFile);
}
if (!string.IsNullOrEmpty(importedSettings.Config.CustomConfig))
{
ConfigUrl.Url = ReFormatURL(importedSettings.Config.CustomConfig);
}
if (!string.IsNullOrEmpty(importedSettings.BrowserRoles))
{
string sRoles = importedSettings.BrowserRoles;
if (sRoles.Length >= 1 && sRoles.Contains(";"))
{
string[] roles = sRoles.Split(';');
foreach (string sRoleName in roles)
{
if (Utility.IsNumeric(sRoleName))
{
if (chblBrowsGr.Items.FindByValue(sRoleName) != null)
{
chblBrowsGr.Items.FindByValue(sRoleName).Selected = true;
}
}
else
{
if (chblBrowsGr.Items.FindByText(sRoleName) != null)
{
chblBrowsGr.Items.FindByText(sRoleName).Selected = true;
}
}
}
}
}
if (!changeMode)
{
return;
}
switch (importedSettings.SettingMode)
{
case SettingsMode.Portal:
rBlSetMode.SelectedIndex = 0;
break;
case SettingsMode.Page:
rBlSetMode.SelectedIndex = 1;
break;
case SettingsMode.ModuleInstance:
rBlSetMode.SelectedIndex = 2;
break;
}
}
/// <summary>
/// Bind User Groups to GridView
/// </summary>
private void BindUserGroupsGridView()
{
var lic = new ListItemCollection();
foreach (var roleItem in
from RoleInfo objRole in RoleController.Instance.GetRoles(_portalSettings.PortalId)
select new ListItem { Text = objRole.RoleName, Value = objRole.RoleID.ToString() })
{
lic.Add(roleItem);
}
lic.Add(new ListItem { Text = "Unauthenticated Users", Value = "-1" });
gvToolbars.DataSource = lic;
gvToolbars.DataBind();