Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CustomItemGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@
<ItemGroup>
<Reference Include="Sitecore.Client, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Sitecore.Client.dll</HintPath>
<HintPath>..\CustomItemGeneratorMaster\bin\Sitecore.Client.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Kernel, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Sitecore.Kernel.dll</HintPath>
<HintPath>..\CustomItemGeneratorMaster\bin\Sitecore.Kernel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sitecore.Logging, Version=1.2.0.30715, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Sitecore.Logging.dll</HintPath>
<HintPath>..\CustomItemGeneratorMaster\bin\Sitecore.Logging.dll</HintPath>
</Reference>
<Reference Include="Sitecore.NVelocity, Version=0.4.2.8580, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Sitecore.NVelocity.dll</HintPath>
<HintPath>..\CustomItemGeneratorMaster\bin\Sitecore.NVelocity.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
Expand Down Expand Up @@ -104,6 +104,7 @@
<Compile Include="Fields\ListTypes\CustomTreeListField.cs" />
<Compile Include="Interfaces\ICustomItemFolderPathProvider.cs" />
<Compile Include="Interfaces\ICustomItemNamespaceProvider.cs" />
<Compile Include="Pipelines\AutoUpdate.cs" />
<Compile Include="Providers\TemplatePathFilePathProvider.cs" />
<Compile Include="Providers\TemplatePathNameSpaceProvider.cs" />
<Compile Include="Settings\CustomItemSettings.cs" />
Expand Down
Binary file modified Data/Packages/Custom Item Generator-1.0.zip
Binary file not shown.
9 changes: 7 additions & 2 deletions Fields/SimpleTypes/CustomCheckboxField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public CustomCheckboxField(Item item, CheckboxField field)
{
}

public static implicit operator bool(CustomCheckboxField dateField)
public static implicit operator bool(CustomCheckboxField checkboxField)
{
return dateField.Checked;
return checkboxField.Checked;
}

public bool Checked
Expand All @@ -24,5 +24,10 @@ public bool Checked
return ((CheckboxField)item.Fields[field.InnerField.Name]).Checked;
}
}

public override string ToString()
{
return Checked.ToString();
}
}
}
5 changes: 5 additions & 0 deletions Fields/SimpleTypes/CustomDateField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ public DateTime DateTime
return ((DateField)item.Fields[field.InnerField.Name]).DateTime;
}
}

public override string ToString()
{
return DateTime.ToString();
}
}
}
5 changes: 5 additions & 0 deletions Fields/SimpleTypes/CustomIntegerField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ public int Integer
return int.MinValue;
}
}

public override string ToString()
{
return Integer.ToString();
}
}
}
5 changes: 5 additions & 0 deletions Fields/SimpleTypes/CustomTextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ public string Text
{
get { return Rendered; }
}

public override string ToString()
{
return Text.ToString();
}
}
}
42 changes: 42 additions & 0 deletions Pipelines/AutoUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Web;
using CustomItemGenerator.Settings;
using CustomItemGenerator.SitecoreApp;
using Sitecore.Web.UI.Sheer;
using Sitecore.Web.UI.HtmlControls;
using System.IO;
using CustomItemGenerator.Util;
using Sitecore.Data.Items;

namespace CustomItemGenerator.Pipelines {
public class AutoUpdate : CustomItemCodeBeside {
protected void OnItemSaved(object sender, EventArgs args) {

CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);

// Only continue if we have valid args, auto update is set to true, and the file exists already
if (args != null && settings.AutoUpdate) {

// Get the template destination
Item _temp = masterDb.GetItem(GetCurrentContentGuid());
if (_temp != null) {
string file_path = FileUtil.GetClassFilePath(CodeUtil.GetClassNameForTemplate(_temp), settings.BaseFileOutputPath);

// Make sure the template already exists
if (File.Exists(file_path)) {

// Set these up since we don't have the editor open
CustomItemNamespace = new Edit();
CustomItemFilePath = new Edit();

// Call the current code beside
OnLoad(args);
OnOK(sender, args);
}
}
}

return;
}
}
}
8 changes: 7 additions & 1 deletion Settings/CustomItemSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CustomItemSettings
public string NamespaceProvider { get; private set; }
public string FilepathProvider { get; private set; }
public List<FieldMapping> FieldMappings { get; private set; }
public bool AutoUpdate { get; set; }

public CustomItemSettings(HttpContext httpContext)
: this(httpContext.Server.MapPath("/"))
Expand All @@ -33,7 +34,7 @@ public CustomItemSettings(string basePath)
NamespaceProvider = string.Empty;
FilepathProvider = string.Empty;
FieldMappings = new List<FieldMapping>();

bool update = false;
NvelocityTemplatePath = basePath + @"\sitecore modules\Shell\CustomItemGenerator\Nvelocity Templates";

foreach (XmlNode childNode in elementsByTagName[0].ChildNodes)
Expand Down Expand Up @@ -67,6 +68,11 @@ public CustomItemSettings(string basePath)
}

break;

case "AutoUpdate":
bool.TryParse(childNode.Attributes["onSave"].Value, out update);
AutoUpdate = update;
break;
}
}
}
Expand Down
25 changes: 16 additions & 9 deletions SitecoreApp/CustomItemCodeBeside.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CustomItemCodeBeside : DialogForm
protected Database masterDb = Factory.GetDatabase("master");
protected Edit CustomItemNamespace;
protected Edit CustomItemFilePath;
private TemplateItem template;
protected TemplateItem template;

private Checkbox GenerateBaseFile;
private Checkbox GenerateInstanceFile;
Expand Down Expand Up @@ -51,9 +51,11 @@ protected override void OnLoad(EventArgs args)
}
else
{
if (!Context.ClientPage.IsEvent)

CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);

if (settings.AutoUpdate || !Context.ClientPage.IsEvent)
{
CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);

string defaultNamespace = settings.BaseNamespace;
string defaultFilePath = settings.BaseFileOutputPath;
Expand Down Expand Up @@ -91,14 +93,19 @@ protected override void OnOK(object sender, EventArgs args)
ICustomItemNamespaceProvider namespaceProvider = AssemblyUtil.GetNamespaceProvider(settings.NamespaceProvider);
ICustomItemFolderPathProvider filePathProvider = AssemblyUtil.GetFilePathProvider(settings.FilepathProvider);

CustomItemInformation customItemInformation = new CustomItemInformation(template, CustomItemNamespace.Value,
CustomItemFilePath.Value, filePathProvider, namespaceProvider);
CodeGenerator codeGenerator = new CodeGenerator(customItemInformation,
GenerateBaseFile.Checked, GenerateInstanceFile.Checked, GenerateInterfaceFile.Checked, GenerateStaticFile.Checked);
codeGenerator.GenerateCode();
CustomItemInformation customItemInformation = new CustomItemInformation(template, CustomItemNamespace.Value,
CustomItemFilePath.Value, filePathProvider, namespaceProvider);

SheerResponse.Alert(codeGenerator.GenerationMessage, new string[0]);
if (settings.AutoUpdate) {
new CodeGenerator(customItemInformation, true, false, false, false).GenerateCode();
}
else {
CodeGenerator codeGenerator = new CodeGenerator(customItemInformation,
GenerateBaseFile.Checked, GenerateInstanceFile.Checked, GenerateInterfaceFile.Checked, GenerateStaticFile.Checked);
codeGenerator.GenerateCode();

SheerResponse.Alert(codeGenerator.GenerationMessage, new string[0]);
}
base.OnOK(sender, args);
}
}
Expand Down