/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Everest.Forms.ExtForm.Controls;
using Everest.Library.ExtensionMethod;
namespace Everest.Forms.ExtForm{
/// <summary>
///
/// </summary>
public class ExtControlFactory : IControlTypeFactory
{
static IDictionary<string, Type> columnControls = new Dictionary<string, Type>();
static ExtControlFactory()
{
columnControls.Add("display", typeof(Display));
columnControls.Add("text", typeof(TextBox));
columnControls.Add("hidden", typeof(Hidden));
columnControls.Add("number", typeof(Number));
columnControls.Add("checkbox", typeof(Checkbox));
columnControls.Add("time", typeof(TimeField));
columnControls.Add("date", typeof(Date));
columnControls.Add("datetime", typeof(DateTimeField));
columnControls.Add("textarea", typeof(TextArea));
columnControls.Add("file", typeof(File));
columnControls.Add("downloadablefile", typeof(DownloadableFile));
columnControls.Add("combobox", typeof(Combobox));
columnControls.Add("lovcombo", typeof(LovCombo));
columnControls.Add("button", typeof(Button));
columnControls.Add("radiogroup", typeof(RadioGroup));
columnControls.Add("checkboxgroup", typeof(CheckboxGroup));
columnControls.Add("fieldset", typeof(FieldSet));
columnControls.Add("generic", typeof(GenericField));
columnControls.Add("codeeditor", typeof(CodeEditor));
columnControls.Add("multiselect", typeof(MultiSelectField));
columnControls.Add("multifiles", typeof(MultiFilesField));
//columnControls.Add("htmleditorimage", typeof(HtmlEditorImage));
columnControls.Add("htmleditor", typeof(HtmlEditor));
var enableTinymce = ConfigurationManager.AppSettings["enableTinymce"];
if (string.IsNullOrEmpty(enableTinymce) ? false : (enableTinymce.ToLower() == "true"))
{
columnControls.Add("tinymce", typeof(Tinymce));
}
var enableCKEditor = ConfigurationManager.AppSettings["enableCKEditor"];
if (string.IsNullOrEmpty(enableCKEditor) ? false : (enableCKEditor.ToLower() == "true"))
{
columnControls.Add("ckeditor", typeof(CKEditor));
}
var radEditor = ConfigurationManager.AppSettings["enableRadEditor"];
if (string.IsNullOrEmpty(radEditor) ? false : (radEditor.ToLower() == "true"))
{
columnControls.Add("radeditor", typeof(RadEditor));
columnControls.Add("radeditorsimple", typeof(RadEditorSimple));
}
var enableFCKEditor = ConfigurationManager.AppSettings["enableFCKEditor"];
if (StringExtensions.IsTrue(enableFCKEditor))
{
columnControls.Add("fckeditor", typeof(FCKEditor));
}
}
#region IColumnControlTypeFactory Members
public void RegisterControlType(string name, Type controlType)
{
columnControls.Add(name, controlType);
}
public IControlType ResolveControl(string controlName)
{
controlName = controlName.ToLower();
if (columnControls.ContainsKey(controlName))
{
return (IControlType)Activator.CreateInstance(columnControls[controlName]);
}
else
throw new ArgumentException(new Everest.Library.Resource.TextResource("ControlTypeNotExsits", "Everest.Forms", controlName).ToString());
}
public IDictionary<string, Type> ResolveAllControlType()
{
return columnControls;
}
#endregion
}
}
|