Skip to content

Commit

Permalink
Merge pull request #15 from SCullman/FormTemplate
Browse files Browse the repository at this point in the history
DNN FnL 6.3 (meanwhile Fnl 6.4)
  • Loading branch information
EPTamminga authored May 19, 2018
2 parents f754038 + 885da7b commit 2a42d57
Show file tree
Hide file tree
Showing 52 changed files with 5,599 additions and 5,305 deletions.
20 changes: 16 additions & 4 deletions App_LocalResources/configuration.ascx.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Ascending.Text" xml:space="preserve">
<value>Ascending</value>
Expand Down Expand Up @@ -623,7 +623,19 @@
<data name="DisplaySettings.Text" xml:space="preserve">
<value>Current View Options </value>
</data>
<data name="noFormSettings.Text" xml:space="preserve">
<value>No settings for this configuration</value>
<data name="EnableFormTemplate.Text" xml:space="preserve">
<value>Enable Form Template</value>
</data>
<data name="FormTemplate.Text" xml:space="preserve">
<value>Form Template</value>
</data>
<data name="GenerateFormTemplate.Text" xml:space="preserve">
<value>Generate Template (optimized for Bootstrap) </value>
</data>
<data name="EnableFormTemplate.Help" xml:space="preserve">
<value>Override the rendering of the form.</value>
</data>
<data name="FormTemplate.Help" xml:space="preserve">
<value>The template is set as html. To insert labels, use the [label-for:Fieldname] token, for the input fields [editor-for:Fieldname]</value>
</data>
</root>
304 changes: 158 additions & 146 deletions App_LocalResources/form.ascx.resx

Large diffs are not rendered by default.

31 changes: 4 additions & 27 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.

// Die Werte der Assemblyattribute überprüfen

[assembly: AssemblyTitle("DotNetNuke.Modules.UserDefinedTable")]
[assembly: AssemblyDescription("ASP.NET Open Source Portal Application,Form and List Module")]
[assembly: AssemblyDescription("DNN Form and List ")]
[assembly: AssemblyCompany("DNN Corp")]
[assembly: AssemblyProduct("http://www.dotnetnuke.com")]
[assembly:
AssemblyCopyright("Portal engine source code is copyright &copy; 2002-YYYY by DotNetNuke. All Rights Reserved")]
[assembly: AssemblyCopyright("DotNetNuke® is copyright 2002-2016 by DNN Corp. All Rights Reserved.")]
[assembly: AssemblyTrademark("DotNetNuke")]
[assembly: ComVisible(false)]

//Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird

[assembly: Guid("334e9cee-0d47-4d70-924b-b5098a3432cb")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// <Assembly: AssemblyVersion("1.0.*")>

[assembly: AssemblyVersion("06.02.00.00")]
[assembly: AssemblyVersion("06.04.00.00")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyFileVersion("06.02.00.00")]
[assembly: AssemblyFileVersion("06.04.00.00")]

127 changes: 67 additions & 60 deletions BusinessController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Web;
using System.Xml;
Expand All @@ -11,35 +10,34 @@
using DotNetNuke.Modules.UserDefinedTable.Components;
using DotNetNuke.Modules.UserDefinedTable.Interfaces;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Search;
using DotNetNuke.Services.Search.Entities;
using Microsoft.VisualBasic;
using Globals = DotNetNuke.Common.Globals;

namespace DotNetNuke.Modules.UserDefinedTable
{
public class BusinessController : ISearchable, IPortable, IPortable2
public class BusinessController : ModuleSearchBase, IPortable, IPortable2
{
public enum SettingsType
{
ModuleSettings,
TabModuleSettings
}

static DataTable GetSettingsTable(int id, SettingsType type)
{
var modules = new ModuleController();
Hashtable settings = null;
static DataTable GetSettingsTable(Hashtable settings, SettingsType type)
{


DataTable returnValue = null;

switch (type)
{
case SettingsType.ModuleSettings:
settings = modules.GetModuleSettings(id);
case SettingsType.ModuleSettings:

returnValue = new DataTable(DataSetTableName.Settings);
break;
case SettingsType.TabModuleSettings:
settings = modules.GetTabModuleSettings(id);
case SettingsType.TabModuleSettings:

returnValue = new DataTable(DataSetTableName.TabSettings);
break;
}
Expand All @@ -52,38 +50,38 @@ static DataTable GetSettingsTable(int id, SettingsType type)
}


var dc = new DataColumn(SettingsTableColumn.Setting, typeof (string))
{ColumnMapping = MappingType.Attribute};
if (returnValue != null) returnValue.Columns.Add(dc);

dc = new DataColumn(SettingsTableColumn.Value, typeof (string)) {ColumnMapping = MappingType.Attribute};
if (returnValue != null)
{
returnValue.Columns.Add(dc);

foreach (var key in sortedSettings.Keys)
{
var row = returnValue.NewRow();
row[SettingsTableColumn.Setting] = key;
row[SettingsTableColumn.Value] = sortedSettings[key];
returnValue.Rows.Add(row);
}
return returnValue;
using (var nameCol = new DataColumn(SettingsTableColumn.Setting, typeof(string)) { ColumnMapping = MappingType.Attribute })
{
if (returnValue != null)
{
returnValue.Columns.Add(nameCol);
using (var valCol = new DataColumn(SettingsTableColumn.Value, typeof(string)) { ColumnMapping = MappingType.Attribute })
{
returnValue.Columns.Add(valCol);
foreach (var key in sortedSettings.Keys)
{
var row = returnValue.NewRow();
row[SettingsTableColumn.Setting] = key;
row[SettingsTableColumn.Value] = sortedSettings[key];
returnValue.Rows.Add(row);
}
}
}
}
return null;
return returnValue;
}

DataTable GetStylesheetTable(Components.Settings settings, int portalId)
{
var returnValue = new DataTable(DataSetTableName.Stylesheets);

returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.NameOfSetting, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.LocalFilePath, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.Stylesheet, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.NameOfSetting, typeof(string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.LocalFilePath, typeof(string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.Stylesheet, typeof(string)));

var renderMethod = string.Format("UDT_{0}", settings.RenderingMethod );
var renderMethod = string.Format("UDT_{0}", settings.RenderingMethod);
var listScript = renderMethod == SettingName.XslUserDefinedStyleSheet
? settings.ScriptByRenderingMethod( renderMethod )
? settings.ScriptByRenderingMethod(renderMethod)
: string.Empty;
if (listScript.Length > 0)
{
Expand All @@ -106,16 +104,16 @@ DataTable GetStylesheetTable(Components.Settings settings, int portalId)
}

return returnValue;
}

}

/// -----------------------------------------------------------------------------
/// <summary>
/// Implements the search interface for DotNetNuke
/// </summary>
/// -----------------------------------------------------------------------------
public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
{
var searchItemCollection = new SearchItemInfoCollection();
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc)
{
var searchDocuments = new List<SearchDocument>();
var udtController = new UserDefinedTableController(modInfo);

try
Expand All @@ -128,8 +126,7 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
var colnameChangedAt = udtController.ColumnNameByDataType(dsUserDefinedRows,
DataTypeNames.UDT_DataType_ChangedAt);

var moduleController = new ModuleController();
var settings = moduleController.GetModuleSettings(modInfo.ModuleID);
var settings = modInfo.ModuleSettings;
var includeInSearch = !(settings[SettingName.ExcludeFromSearch].AsBoolean());

if (includeInSearch)
Expand All @@ -139,11 +136,11 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
var changedDate = DateTime.Today;
var changedByUserId = 0;

if (colnameChangedAt != string.Empty && ! Information.IsDBNull(row[colnameChangedAt]))
if (colnameChangedAt != string.Empty && !Information.IsDBNull(row[colnameChangedAt]))
{
changedDate = Convert.ToDateTime(row[colnameChangedAt]);
}
if (colnameChangedBy != string.Empty && ! Information.IsDBNull(row[colnameChangedBy]))
if (colnameChangedBy != string.Empty && !Information.IsDBNull(row[colnameChangedBy]))
{
changedByUserId = ModuleSecurity.UserId(row[colnameChangedBy].ToString(), modInfo.PortalID);
}
Expand All @@ -163,11 +160,20 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
if (desc.EndsWith("<br/>"))
{
desc = desc.Substring(0, Convert.ToInt32(desc.Length - 5));
}
var searchItem = new SearchItemInfo(modInfo.ModuleTitle, desc, changedByUserId, changedDate,
modInfo.ModuleID, row[DataTableColumn.RowId].ToString(),
desc);
searchItemCollection.Add(searchItem);
}

var searchDoc = new SearchDocument
{
UniqueKey = row[DataTableColumn.RowId].ToString(),
PortalId = modInfo.PortalID,
Title = modInfo.ModuleTitle,
Description = desc,
Body = desc,
ModifiedTimeUtc = changedDate
};

searchDocuments.Add(searchDoc);

}
}
}
Expand All @@ -176,7 +182,7 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
Exceptions.LogException(ex);
}

return searchItemCollection;
return searchDocuments;
}


Expand Down Expand Up @@ -223,15 +229,16 @@ public DataSet ExportModuleDataSet(int moduleId, int tabId)
{
var udtController = new UserDefinedTableController(moduleId);
ds = udtController.GetDataSet(false);
ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
var moduleInfo = new ModuleController().GetModule(moduleId);
ds.Tables.Add(GetSettingsTable(moduleInfo.ModuleSettings, SettingsType.ModuleSettings));
}
else
{
var moduleInfo = new ModuleController().GetModule(moduleId, tabId);
var udtController = new UserDefinedTableController(moduleInfo);
ds = udtController.GetDataSet(false);
ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleID, SettingsType.TabModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.ModuleSettings, SettingsType.ModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleSettings, SettingsType.TabModuleSettings));
ds.Tables.Add(GetStylesheetTable(udtController.Settings, moduleInfo.PortalID));
}
return (ds);
Expand Down Expand Up @@ -277,7 +284,7 @@ public void ImportModule(int moduleId, int tabId, string content, string version
{
AddTabModuleSettings(modules, tabModuleId, ds);
}
if (! isInstance)
if (!isInstance)
{
AddModuleSettings(moduleId, modules, ds);
//Fields - first delete old Fields
Expand Down Expand Up @@ -348,7 +355,7 @@ static void ImportStyleSheet(int moduleId, bool isInstance, int tabModuleId, Mod
}
else
{
if (! isInstance)
if (!isInstance)
{
modules.UpdateModuleSetting(moduleId, settingName,
string.Format("{0}/{1}", Definition.XSLFolderName, fileName));
Expand All @@ -375,10 +382,10 @@ static void AddFields(int moduleId, DataSet ds)
var fieldSettings = ds.Tables[DataSetTableName.FieldSettings];
foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows)
{
var oldFieldId = row[FieldsTableColumn.Id].AsInt( );
var newFieldId=
var oldFieldId = row[FieldsTableColumn.Id].AsInt();
var newFieldId =
FieldController.AddField(moduleId, row[FieldsTableColumn.Title].ToString(),
row.AsString(FieldsTableColumn.Order).AsInt(fieldIndex ),
row.AsString(FieldsTableColumn.Order).AsInt(fieldIndex),
row.AsString((FieldsTableColumn.HelpText)),
row.AsString(FieldsTableColumn.Required).AsBoolean(),
row.AsString((FieldsTableColumn.Type)),
Expand All @@ -400,8 +407,8 @@ static void AddFields(int moduleId, DataSet ds)
foreach (DataRowView setting in fieldSettings.WithFieldId(oldFieldId))
{
FieldSettingsController.UpdateFieldSetting(
(string) setting["SettingName"],
(string) setting["SettingValue"],
(string)setting["SettingName"],
(string)setting["SettingValue"],
newFieldId);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Components/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ public Components.Settings Settings
if (_moduleSettings == null)
{
var mc = new ModuleController();
_moduleSettings = new Hashtable(mc.GetModuleSettings(ModuleId));
_configuration = mc.GetModule(ModuleId, TabModuleId);
_moduleSettings = new Hashtable(_configuration.ModuleSettings);
if (TabModuleId != Null.NullInteger)
{
var tabModuleSettings = mc.GetTabModuleSettings(TabModuleId);
var tabModuleSettings = _configuration.TabModuleSettings;
foreach (string strKey in tabModuleSettings.Keys)
{
_moduleSettings[strKey] = tabModuleSettings[strKey];
Expand Down
2 changes: 2 additions & 0 deletions Components/GlobalConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,7 @@ public class SettingName
public const string UponSubmitAction = "UDT_UponSubmitAction";
public const string UponSubmitRedirect = "UDT_UponSubmitRedirect";
public const string UseButtonsInForm = "UseButtonsInForm";
public const string FormTemplate = "FormTemplate";
public const string EnableFormTemplate = "EnableFormTemplate";
}
}
4 changes: 2 additions & 2 deletions Components/ModuleSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class ModuleSecurity
public ModuleSecurity(int moduleId, int tabId, Components.Settings settings)
{
var moduleController = new ModuleController();
Settings = settings ?? new Settings(moduleController.GetModuleSettings(moduleId));
var moduleInfo = moduleController.GetModule(moduleId, tabId);
var moduleInfo = moduleController.GetModule(moduleId, tabId);
Settings = settings ?? new Settings(moduleInfo.ModuleSettings);
if (moduleInfo == null) return;
var mp = moduleInfo.ModulePermissions;
_hasEditRowPermission = ModulePermissionController.HasModulePermission(mp, PermissionName.HasEditRowPermission);
Expand Down
Loading

0 comments on commit 2a42d57

Please sign in to comment.