dictionaryItems, int level) {
string style = "style='padding-left: " + level * 10 + "px;'";
- foreach (Dictionary.DictionaryItem di in items) {
- lt_table.Text += "| " + di.key + " | ";
- foreach (cms.businesslogic.language.Language lang in _languages) {
+ foreach (var di in dictionaryItems) {
+ lt_table.Text += "
|---|
| " + di.ItemKey + " | ";
+
+ foreach (var lang in _languages) {
lt_table.Text += "";
- if (string.IsNullOrEmpty(di.Value(lang.id)))
+ var trans = di.Translations.FirstOrDefault(x => x.LanguageId == lang.id);
+
+ if (trans == null || string.IsNullOrEmpty(trans.Value))
lt_table.Text += "";
else
lt_table.Text += "";
@@ -49,8 +54,9 @@ namespace umbraco.presentation.settings {
}
lt_table.Text += " |
";
- if (di.hasChildren)
- ProcessKeys(di.Children, (level+1));
+ var children = Services.LocalizationService.GetDictionaryItemChildren(di.Key);
+ if (children.Any())
+ ProcessKeys(children, (level+1));
}
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
index 2d63a6593b..affa0451aa 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
@@ -1,8 +1,10 @@
using System;
+using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.cms.presentation.Trees;
using Umbraco.Core;
+using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.UI;
@@ -19,15 +21,15 @@ namespace umbraco.settings
protected LiteralControl keyTxt = new LiteralControl();
protected uicontrols.TabView tbv = new uicontrols.TabView();
private System.Collections.ArrayList languageFields = new System.Collections.ArrayList();
- private cms.businesslogic.Dictionary.DictionaryItem currentItem;
+ private IDictionaryItem currentItem;
protected void Page_Load(object sender, System.EventArgs e)
{
- currentItem = new cms.businesslogic.Dictionary.DictionaryItem(int.Parse(Request.QueryString["id"]));
+ currentItem = Services.LocalizationService.GetDictionaryItemById(int.Parse(Request.QueryString["id"]));
// Put user code to initialize the page here
Panel1.hasMenu = true;
- Panel1.Text = Services.TextService.Localize("editdictionary") + ": " + currentItem.key;
+ Panel1.Text = Services.TextService.Localize("editdictionary") + ": " + currentItem.ItemKey;
uicontrols.Pane p = new uicontrols.Pane();
@@ -39,7 +41,7 @@ namespace umbraco.settings
save.ButtonType = uicontrols.MenuButtonType.Primary;
Literal txt = new Literal();
- txt.Text = "" + Services.TextService.Localize("dictionaryItem/description", new[] { currentItem.key }) + "
";
+ txt.Text = "" + Services.TextService.Localize("dictionaryItem/description", new[] { currentItem.ItemKey }) + "
";
p.addProperty(txt);
foreach (cms.businesslogic.language.Language l in cms.businesslogic.language.Language.getAll)
@@ -50,8 +52,10 @@ namespace umbraco.settings
languageBox.ID = l.id.ToString();
languageBox.CssClass = "umbEditorTextFieldMultiple";
- if (!IsPostBack)
- languageBox.Text = currentItem.Value(l.id);
+ if (!IsPostBack)
+ {
+ languageBox.Text = currentItem.GetTranslatedValue(l.id);
+ }
languageFields.Add(languageBox);
p.addProperty(l.FriendlyName, languageBox);
@@ -70,10 +74,10 @@ namespace umbraco.settings
Panel1.Controls.Add(p);
}
- private string BuildPath(cms.businesslogic.Dictionary.DictionaryItem current)
+ private string BuildPath(IDictionaryItem current)
{
- var parentPath = current.IsTopMostItem() ? "" : BuildPath(current.Parent) + ",";
- return parentPath + current.id;
+ var parentPath = current.ParentId.HasValue == false ? "" : BuildPath(current) + ",";
+ return parentPath + current.Id;
}
void save_Click(object sender, EventArgs e)
@@ -82,10 +86,16 @@ namespace umbraco.settings
{
//check for null but allow empty string!
// http://issues.umbraco.org/issue/U4-1931
- if (t.Text != null)
- {
- currentItem.setValue(int.Parse(t.ID),t.Text);
- }
+ if (t.Text != null)
+ {
+ Services.LocalizationService.AddOrUpdateDictionaryValue(
+ currentItem,
+ Services.LocalizationService.GetLanguageById(int.Parse(t.ID)),
+ t.Text);
+
+ Services.LocalizationService.Save(currentItem);
+
+ }
}
ClientTools.ShowSpeechBubble(SpeechBubbleIcon.Save, Services.TextService.Localize("speechBubbles/dictionaryItemSaved"), "");
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/translation/preview.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/translation/preview.aspx.cs
index 457e2eb5f9..9b2fc161e7 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/translation/preview.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/translation/preview.aspx.cs
@@ -1,17 +1,7 @@
using System;
-using System.Data;
-using System.Configuration;
-using System.Collections;
-using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
-using System.Web.UI.HtmlControls;
-using umbraco.BusinessLogic;
+using System.Linq;
using umbraco.cms.businesslogic.task;
using umbraco.cms.businesslogic.web;
-using umbraco.cms.businesslogic.relation;
using Umbraco.Core;
using Umbraco.Web;
@@ -37,10 +27,11 @@ namespace umbraco.presentation.translation
translatedUrl = string.Format("../dialogs/preview.aspx?id={0}", translated.Id.ToString());
- var orgRel = Relation.GetRelations(t.Node.Id, RelationType.GetByAlias("relateDocumentOnCopy"));
+ var orgRel = Services.RelationService.GetByParentOrChildId(t.Node.Id, "relateDocumentOnCopy").ToArray();
+
if (orgRel.Length > 0)
{
- var original = new Document(orgRel[0].Parent.Id);
+ var original = new Document(orgRel[0].ParentId);
originalUrl = String.Format("../dialogs/preview.aspx?id={0}", original.Id.ToString());
}
else
diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs
index 9aada0acd6..061337521c 100644
--- a/src/umbraco.cms/businesslogic/CMSNode.cs
+++ b/src/umbraco.cms/businesslogic/CMSNode.cs
@@ -506,12 +506,7 @@ order by level,sortOrder";
///
public virtual void delete()
{
- // remove relations
- var rels = Relations;
- foreach (relation.Relation rel in rels)
- {
- rel.Delete();
- }
+
//removes tasks
foreach (Task t in Tasks)
@@ -739,16 +734,6 @@ order by level,sortOrder";
get { return _nodeObjectType; }
}
- ///
- /// Besides the hierarchy it's possible to relate one CMSNode to another, use this for alternative
- /// non-strict hierarchy
- ///
- /// The relations.
- public relation.Relation[] Relations
- {
- get { return relation.Relation.GetRelations(this.Id); }
- }
-
///
/// Returns all tasks associated with this node
///
diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs
index 05df73b1b5..52955089f3 100644
--- a/src/umbraco.cms/businesslogic/ContentType.cs
+++ b/src/umbraco.cms/businesslogic/ContentType.cs
@@ -416,11 +416,10 @@ namespace umbraco.cms.businesslogic
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- if (Dictionary.DictionaryItem.hasKey(_description.Substring(1, _description.Length - 1)))
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(_description.Substring(1, _description.Length - 1)))
{
- var di =
- new Dictionary.DictionaryItem(_description.Substring(1, _description.Length - 1));
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(_description.Substring(1, _description.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
@@ -495,10 +494,11 @@ namespace umbraco.cms.businesslogic
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- if (Dictionary.DictionaryItem.hasKey(tempText.Substring(1, tempText.Length - 1)))
+
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(tempText.Substring(1, tempText.Length - 1)))
{
- var di = new Dictionary.DictionaryItem(tempText.Substring(1, tempText.Length - 1));
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(tempText.Substring(1, tempText.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
@@ -1468,7 +1468,11 @@ namespace umbraco.cms.businesslogic
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- return new Dictionary.DictionaryItem(tempCaption.Substring(1, tempCaption.Length - 1)).Value(lang.id);
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(tempCaption.Substring(1, tempCaption.Length - 1)))
+ {
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(tempCaption.Substring(1, tempCaption.Length - 1));
+ return di.GetTranslatedValue(lang.id);
+ }
}
return "[" + tempCaption + "]";
}
@@ -1625,10 +1629,10 @@ namespace umbraco.cms.businesslogic
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- if (Dictionary.DictionaryItem.hasKey(_caption.Substring(1, _caption.Length - 1)))
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(_caption.Substring(1, _caption.Length - 1)))
{
- var di = new Dictionary.DictionaryItem(_caption.Substring(1, _caption.Length - 1));
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(_caption.Substring(1, _caption.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
diff --git a/src/umbraco.cms/businesslogic/Dictionary.cs b/src/umbraco.cms/businesslogic/Dictionary.cs
deleted file mode 100644
index f043ddca80..0000000000
--- a/src/umbraco.cms/businesslogic/Dictionary.cs
+++ /dev/null
@@ -1,395 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Concurrent;
-using System.ComponentModel;
-using System.Data;
-using System.Globalization;
-using System.Threading;
-using System.Xml;
-using System.Linq;
-using Umbraco.Core;
-using umbraco.cms.businesslogic.language;
-using Umbraco.Core.Models;
-using Umbraco.Core.Services;
-using umbraco.DataLayer;
-using umbraco.BusinessLogic;
-using System.Runtime.CompilerServices;
-using Umbraco.Core.Xml;
-using Language = umbraco.cms.businesslogic.language.Language;
-
-namespace umbraco.cms.businesslogic
-{
- [Obsolete("Obsolete, Umbraco.Core.Services.ILocalizationService")]
- public class Dictionary
- {
- private static readonly Guid TopLevelParent = new Guid(Constants.Conventions.Localization.DictionaryItemRootId);
-
- [Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database")]
- protected static ISqlHelper SqlHelper
- {
- get { return LegacySqlHelper.SqlHelper; }
- }
-
- ///
- /// Retrieve a list of toplevel DictionaryItems
- ///
- public static DictionaryItem[] getTopMostItems
- {
- get
- {
- return ApplicationContext.Current.Services.LocalizationService.GetRootDictionaryItems()
- .Select(x => new DictionaryItem(x))
- .ToArray();
- }
- }
-
- ///
- /// A DictionaryItem is basically a key/value pair (key/language key/value) which holds the data
- /// associated to a key in various language translations
- ///
- public class DictionaryItem
- {
- public DictionaryItem()
- {
-
- }
-
- internal DictionaryItem(IDictionaryItem item)
- {
- _dictionaryItem = item;
- }
-
- private readonly IDictionaryItem _dictionaryItem;
- private DictionaryItem _parent;
-
- public DictionaryItem(string key)
- {
- _dictionaryItem = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(key);
-
- if (_dictionaryItem == null)
- {
- throw new ArgumentException("No key " + key + " exists in dictionary");
- }
- }
-
- public DictionaryItem(Guid id)
- {
- _dictionaryItem = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemById(id);
-
- if (_dictionaryItem == null)
- {
- throw new ArgumentException("No unique id " + id + " exists in dictionary");
- }
- }
-
- public DictionaryItem(int id)
- {
- _dictionaryItem = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemById(id);
-
- if (_dictionaryItem == null)
- {
- throw new ArgumentException("No id " + id + " exists in dictionary");
- }
- }
-
- [Obsolete("This is no longer used and will be removed from the codebase in future versions")]
- public bool IsTopMostItem()
- {
- return _dictionaryItem.ParentId.HasValue == false;
- }
-
- ///
- /// Returns the parent.
- ///
- public DictionaryItem Parent
- {
- get
- {
- //EnsureCache();
- if (_parent == null && _dictionaryItem.ParentId.HasValue)
- {
- var p = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemById(_dictionaryItem.ParentId.Value);
-
- if (p == null)
- {
- throw new ArgumentException("Top most dictionary items doesn't have a parent");
- }
- else
- {
- _parent = new DictionaryItem(p);
- }
- }
-
- return _parent;
- }
- }
-
- ///
- /// The primary key in the database
- ///
- public int id
- {
- get { return _dictionaryItem.Id; }
- }
-
- public DictionaryItem[] Children
- {
- get
- {
- return ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemChildren(_dictionaryItem.Key)
- .WhereNotNull()
- .Select(x => new DictionaryItem(x))
- .ToArray();
- }
- }
-
- public static bool hasKey(string key)
- {
- return ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(key);
- }
-
- public bool hasChildren
- {
- get { return Children.Any(); }
- }
-
- ///
- /// Returns or sets the key.
- ///
- public string key
- {
- get { return _dictionaryItem.ItemKey; }
- set
- {
- if (hasKey(value) == false)
- {
- _dictionaryItem.ItemKey = value;
- }
- else
- throw new ArgumentException("New value of key already exists (is key)");
- }
- }
-
- public string Value(int languageId)
- {
- if (languageId == 0)
- return Value();
-
- var translation = _dictionaryItem.Translations.FirstOrDefault(x => x.Language.Id == languageId);
- return translation == null ? string.Empty : translation.Value;
- }
-
- public void setValue(int languageId, string value)
- {
- ApplicationContext.Current.Services.LocalizationService.AddOrUpdateDictionaryValue(
- _dictionaryItem,
- ApplicationContext.Current.Services.LocalizationService.GetLanguageById(languageId),
- value);
-
- Save();
- }
-
- ///
- /// Returns the default value based on the default language for this item
- ///
- ///
- public string Value()
- {
- var defaultTranslation = _dictionaryItem.Translations.FirstOrDefault(x => x.Language.Id == 1);
- return defaultTranslation == null ? string.Empty : defaultTranslation.Value;
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- [Obsolete("This is not used and should never be used, it will be removed from the codebase in future versions")]
- public void setValue(string value)
- {
- if (Item.hasText(_dictionaryItem.Key, 0))
- Item.setText(0, _dictionaryItem.Key, value);
- else
- Item.addText(0, _dictionaryItem.Key, value);
-
- Save();
- }
-
- public static int addKey(string key, string defaultValue, string parentKey)
- {
- //EnsureCache();
-
- if (hasKey(parentKey))
- {
- int retval = CreateKey(key, new DictionaryItem(parentKey)._dictionaryItem.Key, defaultValue);
- return retval;
- }
- else
- throw new ArgumentException("Parentkey doesnt exist");
- }
-
- public static int addKey(string key, string defaultValue)
- {
- int retval = CreateKey(key, TopLevelParent, defaultValue);
- return retval;
- }
-
- public void delete()
- {
- OnDeleting(EventArgs.Empty);
-
- ApplicationContext.Current.Services.LocalizationService.Delete(_dictionaryItem);
-
- OnDeleted(EventArgs.Empty);
- }
-
- ///
- /// ensures events fire after setting proeprties
- ///
- public void Save()
- {
- OnSaving(EventArgs.Empty);
-
- ApplicationContext.Current.Services.LocalizationService.Save(_dictionaryItem);
- }
-
-
- public XmlNode ToXml(XmlDocument xd)
- {
- var serializer = new EntityXmlSerializer();
- var xml = serializer.Serialize(_dictionaryItem);
- var xmlNode = xml.GetXmlNode(xd);
- if (this.hasChildren)
- {
- foreach (var di in this.Children)
- {
- xmlNode.AppendChild(di.ToXml(xd));
- }
- }
- return xmlNode;
- }
-
- public static DictionaryItem Import(XmlNode xmlData)
- {
- return Import(xmlData, null);
- }
-
- public static DictionaryItem Import(XmlNode xmlData, DictionaryItem parent)
- {
- string key = xmlData.Attributes["Key"].Value;
-
- XmlNodeList values = xmlData.SelectNodes("./Value");
- XmlNodeList childItems = xmlData.SelectNodes("./DictionaryItem");
- DictionaryItem newItem;
- bool retVal = false;
-
- if (!hasKey(key))
- {
- if (parent != null)
- addKey(key, " ", parent.key);
- else
- addKey(key, " ");
-
- if (values.Count > 0)
- {
- //Set language values on the dictionary item
- newItem = new DictionaryItem(key);
- foreach (XmlNode xn in values)
- {
- string cA = xn.Attributes["LanguageCultureAlias"].Value;
- string keyValue = XmlHelper.GetNodeValue(xn);
-
- Language valueLang = Language.GetByCultureCode(cA);
-
- if (valueLang != null)
- {
- newItem.setValue(valueLang.id, keyValue);
- }
- }
- }
-
- if (parent == null)
- retVal = true;
- }
-
- newItem = new DictionaryItem(key);
-
- foreach (XmlNode childItem in childItems)
- {
- Import(childItem, newItem);
- }
-
- if (retVal)
- return newItem;
- else
- return null;
- }
-
- private static int CreateKey(string key, Guid parentId, string defaultValue)
- {
- if (!hasKey(key))
- {
- var item = ApplicationContext.Current.Services.LocalizationService.CreateDictionaryItemWithIdentity(
- key,
- parentId == TopLevelParent ? (Guid?)null : parentId,
- defaultValue);
-
- return item.Id;
- }
- else
- {
- throw new ArgumentException("Key being added already exists!");
- }
- }
-
- #region Events
- public delegate void SaveEventHandler(DictionaryItem sender, EventArgs e);
- public delegate void NewEventHandler(DictionaryItem sender, EventArgs e);
- public delegate void DeleteEventHandler(DictionaryItem sender, EventArgs e);
-
- public static event SaveEventHandler Saving;
- protected virtual void OnSaving(EventArgs e)
- {
- if (Saving != null)
- Saving(this, e);
- }
-
- public static event NewEventHandler New;
- protected virtual void OnNew(EventArgs e)
- {
- if (New != null)
- New(this, e);
- }
-
- public static event DeleteEventHandler Deleting;
- protected virtual void OnDeleting(EventArgs e)
- {
- if (Deleting != null)
- Deleting(this, e);
- }
-
- public static event DeleteEventHandler Deleted;
- protected virtual void OnDeleted(EventArgs e)
- {
- if (Deleted != null)
- Deleted(this, e);
- }
- #endregion
- }
-
- // zb023 - utility method
- public static string ReplaceKey(string text)
- {
- if (text.StartsWith("#") == false)
- return text;
-
- var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
-
- if (lang == null)
- return "[" + text + "]";
-
- if (DictionaryItem.hasKey(text.Substring(1, text.Length - 1)) == false)
- return "[" + text + "]";
-
- var di = new DictionaryItem(text.Substring(1, text.Length - 1));
- return di.Value(lang.id);
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/umbraco.cms/businesslogic/Packager/PackageInstance/CreatedPackage.cs b/src/umbraco.cms/businesslogic/Packager/PackageInstance/CreatedPackage.cs
index 32c406d100..b757e60dc3 100644
--- a/src/umbraco.cms/businesslogic/Packager/PackageInstance/CreatedPackage.cs
+++ b/src/umbraco.cms/businesslogic/Packager/PackageInstance/CreatedPackage.cs
@@ -250,8 +250,10 @@ namespace umbraco.cms.businesslogic.packager
{
if (int.TryParse(dictionaryId, out outInt))
{
- var di = new Dictionary.DictionaryItem(outInt);
- dictionaryItems.AppendChild(di.ToXml(_packageManifest));
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemById(outInt);
+ var entitySerializer = new EntityXmlSerializer();
+ var xmlNode = entitySerializer.Serialize(di).GetXmlNode(_packageManifest);
+ dictionaryItems.AppendChild(xmlNode);
}
}
AppendElement(dictionaryItems);
diff --git a/src/umbraco.cms/businesslogic/member/Member.cs b/src/umbraco.cms/businesslogic/member/Member.cs
index 2fd03ea8d3..f84803dc92 100644
--- a/src/umbraco.cms/businesslogic/member/Member.cs
+++ b/src/umbraco.cms/businesslogic/member/Member.cs
@@ -56,7 +56,7 @@ namespace umbraco.cms.businesslogic.member
#region Private members
- private Hashtable _groups = null;
+ private Dictionary _groups = null;
protected internal IMember MemberItem;
#endregion
@@ -510,7 +510,7 @@ namespace umbraco.cms.businesslogic.member
///
/// A list of groups the member are member of
///
- public Hashtable Groups
+ public Dictionary Groups
{
get
{
@@ -671,14 +671,20 @@ namespace umbraco.cms.businesslogic.member
private void PopulateGroups()
{
- var temp = new Hashtable();
+ var temp = new Dictionary();
using (var dr = SqlHelper.ExecuteReader(
"select memberGroup from cmsMember2MemberGroup where member = @id",
SqlHelper.CreateParameter("@id", Id)))
{
while (dr.Read())
- temp.Add(dr.GetInt("memberGroup"),
- new MemberGroup(dr.GetInt("memberGroup")));
+ {
+ var group = ApplicationContext.Current.Services.MemberGroupService.GetById(dr.GetInt("memberGroup"));
+ if (group != null)
+ {
+ temp.Add(dr.GetInt("memberGroup"), group);
+ }
+ }
+
}
_groups = temp;
}
diff --git a/src/umbraco.cms/businesslogic/member/MemberGroup.cs b/src/umbraco.cms/businesslogic/member/MemberGroup.cs
deleted file mode 100644
index 1c055b0f50..0000000000
--- a/src/umbraco.cms/businesslogic/member/MemberGroup.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using System;
-using System.Linq;
-using Umbraco.Core.Models;
-using Umbraco.Core.Persistence.Querying;
-using Umbraco.Core;
-using Umbraco.Core.Models.Membership;
-
-namespace umbraco.cms.businesslogic.member
-{
- ///
- /// Membergroups are used for grouping Umbraco Members
- ///
- /// A Member can exist in multiple groups.
- ///
- /// It's possible to protect webpages/documents by membergroup.
- ///
- public class MemberGroup : CMSNode
- {
- private static readonly Guid MemberGroupObjectType = new Guid(Constants.ObjectTypes.MemberGroup);
-
- private IMemberGroup _memberGroupItem;
-
- internal MemberGroup(IMemberGroup memberGroup)
- : base(memberGroup)
- {
- _memberGroupItem = memberGroup;
- }
-
- ///
- /// Initialize a new object of the MemberGroup class
- ///
- /// Membergroup id
- public MemberGroup(int id): base(id)
- {
-
- }
-
- ///
- /// Initialize a new object of the MemberGroup class
- ///
- /// Membergroup id
- public MemberGroup(Guid id) : base(id)
- {
-
- }
-
- public override string Text
- {
- get
- {
- return _memberGroupItem.Name;
- }
- set
- {
- _memberGroupItem.Name = value;
- }
- }
-
- ///
- /// Deltes the current membergroup
- ///
- [Obsolete("Use System.Web.Security.Role.DeleteRole")]
- public override void delete()
- {
-
- if (_memberGroupItem != null)
- {
- ApplicationContext.Current.Services.MemberGroupService.Delete(_memberGroupItem);
- }
- else
- {
- var memberGroup = ApplicationContext.Current.Services.MemberGroupService.GetById(Id);
- ApplicationContext.Current.Services.MemberGroupService.Delete(memberGroup);
- }
-
- // Delete all content and cmsnode specific data!
- base.delete();
- }
-
-
- ///
- /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility
- ///
- public override void Save()
- {
-
- ApplicationContext.Current.Services.MemberGroupService.Save(_memberGroupItem);
-
- }
-
- ///
- /// Retrieve a list of all existing MemberGroups
- ///
- [Obsolete("Use System.Web.Security.Role.GetAllRoles")]
- public static MemberGroup[] GetAll
- {
- get
- {
- var result = ApplicationContext.Current.Services.MemberGroupService.GetAll();
- return result.Select(x => new MemberGroup(x)).ToArray();
- }
- }
-
- public int[] GetMembersAsIds()
- {
- var result = ApplicationContext.Current.Services.MemberService.GetMembersInRole(_memberGroupItem.Name);
- return result.Select(x => x.Id).ToArray();
- }
-
- [Obsolete("Use System.Web.Security.Roles.FindUsersInRole")]
- public Member[] GetMembers()
- {
- var result = ApplicationContext.Current.Services.MemberService.GetMembersInRole(_memberGroupItem.Name);
- return result.Select(x => new Member(x)).ToArray();
- }
-
- public Member[] GetMembers(string usernameToMatch)
- {
-
- var result = ApplicationContext.Current.Services.MemberService.FindMembersInRole(
- _memberGroupItem.Name, usernameToMatch, StringPropertyMatchType.StartsWith);
-
- return result.Select(x => new Member(x)).ToArray();
- }
-
- public bool HasMember(int memberId)
- {
- return SqlHelper.ExecuteScalar("select count(member) from cmsMember2MemberGroup where member = @member and memberGroup = @memberGroup",
- SqlHelper.CreateParameter("@member", memberId),
- SqlHelper.CreateParameter("@memberGroup", Id)) > 0;
- }
-
- ///
- /// Get a membergroup by it's name
- ///
- /// Name of the membergroup
- /// If a MemberGroup with the given name exists, it will return this, else: null
- public static MemberGroup GetByName(string name)
- {
- var found = ApplicationContext.Current.Services.MemberGroupService.GetByName(name);
- if (found == null) return null;
- return new MemberGroup(found);
- }
-
-
- ///
- /// Create a new MemberGroup
- ///
- /// The name of the MemberGroup
- /// The creator of the MemberGroup
- /// The new MemberGroup
- public static MemberGroup MakeNew(string Name, IUser u)
- {
- var group = new global::Umbraco.Core.Models.MemberGroup {Name = Name};
- ApplicationContext.Current.Services.MemberGroupService.Save(group);
-
- var mg = new MemberGroup(group);
- return mg;
- }
-
- protected override void setupNode()
- {
- if (Id == -1)
- {
- base.setupNode();
- return;
- }
-
- var group = ApplicationContext.Current.Services.MemberGroupService.GetById(Id);
-
- if (group == null)
- throw new ArgumentException(string.Format("No Member exists with id '{0}'", Id));
-
- SetupNode(group);
- }
-
- private void SetupNode(IMemberGroup group)
- {
- _memberGroupItem = group;
-
- //Setting private properties
- base.PopulateCMSNodeFromUmbracoEntity(_memberGroupItem, MemberGroupObjectType);
- }
-
-
- }
-}
diff --git a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs
index b9d8d20a44..613a374f00 100644
--- a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs
+++ b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs
@@ -156,11 +156,11 @@ namespace umbraco.cms.businesslogic.propertytype
Language lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- if (Dictionary.DictionaryItem.hasKey(_description.Substring(1, _description.Length - 1)))
+
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(_description.Substring(1, _description.Length - 1)))
{
- var di =
- new Dictionary.DictionaryItem(_description.Substring(1, _description.Length - 1));
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(_description.Substring(1, _description.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
}
@@ -224,10 +224,11 @@ namespace umbraco.cms.businesslogic.propertytype
Language lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
{
- if (Dictionary.DictionaryItem.hasKey(_name.Substring(1, _name.Length - 1)))
+
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(_name.Substring(1, _name.Length - 1)))
{
- var di = new Dictionary.DictionaryItem(_name.Substring(1, _name.Length - 1));
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(_name.Substring(1, _name.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
diff --git a/src/umbraco.cms/businesslogic/relation/Relation.cs b/src/umbraco.cms/businesslogic/relation/Relation.cs
deleted file mode 100644
index 533ebfa870..0000000000
--- a/src/umbraco.cms/businesslogic/relation/Relation.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Data;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Collections.Generic;
-using Umbraco.Core;
-using Umbraco.Core.Models;
-using umbraco.DataLayer;
-using umbraco.BusinessLogic;
-
-namespace umbraco.cms.businesslogic.relation
-{
- ///
- /// Summary description for Relation.
- ///
- [Obsolete("Use the IRelationService instead")]
- public class Relation
- {
- private CMSNode _parentNode;
- private CMSNode _childNode;
-
- internal IRelation RelationEntity;
-
- internal Relation(IRelation relation)
- {
- RelationEntity = relation;
- }
-
- public Relation(int Id)
- {
- var found = ApplicationContext.Current.Services.RelationService.GetById(Id);
- if (found == null)
- {
- throw new NullReferenceException("No relation found with id " + Id);
- }
- RelationEntity = found;
- }
-
- protected static ISqlHelper SqlHelper
- {
- get { return LegacySqlHelper.SqlHelper; }
- }
-
- public CMSNode Parent
- {
- get { return _parentNode ?? (_parentNode = new CMSNode(RelationEntity.ParentId)); }
- set
- {
- _parentNode = value;
- RelationEntity.ParentId = value.Id;
- }
- }
-
- public CMSNode Child
- {
- get { return _childNode ?? (_childNode = new CMSNode(RelationEntity.ChildId)); }
- set
- {
- _childNode = value;
- RelationEntity.ChildId = value.Id;
- }
- }
-
- public string Comment
- {
- get {return RelationEntity.Comment;}
- set { RelationEntity.Comment = value; }
- }
-
- public DateTime CreateDate
- {
- get {return RelationEntity.CreateDate;}
- }
-
- public RelationType RelType
- {
- get { return new RelationType(RelationEntity.RelationType); }
- set { RelationEntity.RelationType = value.RelationTypeEntity; }
- }
-
- public int Id
- {
- get {return RelationEntity.Id;}
- }
-
- ///
- /// Used to persist object changes to the database
- ///
- public virtual void Save()
- {
- ApplicationContext.Current.Services.RelationService.Save(RelationEntity);
- }
-
- public void Delete()
- {
- ApplicationContext.Current.Services.RelationService.Delete(RelationEntity);
- }
-
- public static Relation MakeNew(int ParentId, int ChildId, RelationType RelType, string Comment)
- {
- var relation = new Umbraco.Core.Models.Relation(ParentId, ChildId, RelType.RelationTypeEntity)
- {
- Comment = Comment
- };
- ApplicationContext.Current.Services.RelationService.Save(relation);
- return new Relation(relation);
- }
-
- public static List GetRelationsAsList(int NodeId)
- {
- return ApplicationContext.Current.Services.RelationService.GetByParentOrChildId(NodeId)
- .Select(x => new Relation(x))
- .ToList();
- }
-
- public static bool IsRelated(int ParentID, int ChildId)
- {
- return ApplicationContext.Current.Services.RelationService.AreRelated(ParentID, ChildId);
- }
-
- public static bool IsRelated(int ParentID, int ChildId, RelationType Filter)
- {
- return ApplicationContext.Current.Services.RelationService.AreRelated(ParentID, ChildId, Filter.Alias);
- }
-
- public static Relation[] GetRelations(int NodeId)
- {
- return GetRelationsAsList(NodeId).ToArray();
- }
-
- public static Relation[] GetRelations(int NodeId, RelationType Filter)
- {
- return ApplicationContext.Current.Services.RelationService.GetByParentOrChildId(NodeId, Filter.RelationTypeEntity.Alias)
- .Select(x => new Relation(x))
- .ToArray();
- }
- }
-}
diff --git a/src/umbraco.cms/businesslogic/relation/RelationType.cs b/src/umbraco.cms/businesslogic/relation/RelationType.cs
deleted file mode 100644
index ed5b1a741a..0000000000
--- a/src/umbraco.cms/businesslogic/relation/RelationType.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System;
-using System.Data;
-using System.Linq;
-using System.Web;
-using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Models;
-using System.Collections.Generic;
-using umbraco.cms.businesslogic.web;
-
-namespace umbraco.cms.businesslogic.relation
-{
- ///
- /// Summary description for RelationType.
- ///
- [Obsolete("Use the IRelationService instead")]
- public class RelationType
- {
- #region Declarations
-
- internal IRelationType RelationTypeEntity;
-
- #endregion
-
- #region Constructors
-
- ///
- /// Internal constructor to create a new relation type
- ///
- internal RelationType(IRelationType rt)
- {
- RelationTypeEntity = rt;
- }
-
- public RelationType(int id)
- {
- RelationTypeEntity = ApplicationContext.Current.Services.RelationService.GetRelationTypeById(id);
- if (RelationTypeEntity == null) throw new NullReferenceException("No relation type found with id " + id);
- }
-
- #endregion
-
- #region Properties
-
- public int Id
- {
- get { return RelationTypeEntity.Id; }
- }
-
- public string Name
- {
- get { return RelationTypeEntity.Name; }
- set { RelationTypeEntity.Name = value; }
- }
-
- public string Alias
- {
- get { return RelationTypeEntity.Alias; }
- set { RelationTypeEntity.Alias = value; }
- }
-
- public bool Dual
- {
- get { return RelationTypeEntity.IsBidirectional; }
- set { RelationTypeEntity.IsBidirectional = value; }
- }
-
- #endregion
-
- #region Methods
-
- ///
- /// Used to persist object changes to the databasey
- ///
- public virtual void Save()
- {
- ApplicationContext.Current.Services.RelationService.Save(RelationTypeEntity);
- }
-
- ///
- /// Return all relation types
- ///
- ///
- public static IEnumerable GetAll()
- {
- return ApplicationContext.Current.Services.RelationService.GetAllRelationTypes()
- .Select(x => new RelationType(x));
- }
-
- public static RelationType GetById(int id)
- {
- var found = ApplicationContext.Current.Services.RelationService.GetRelationTypeById(id);
- return found == null ? null : new RelationType(found);
- }
-
- public static RelationType GetByAlias(string Alias)
- {
- var found = ApplicationContext.Current.Services.RelationService.GetRelationTypeByAlias(Alias);
- return found == null ? null : new RelationType(found);
- }
-
- #endregion
-
- }
-}
\ No newline at end of file
diff --git a/src/umbraco.cms/businesslogic/template/Template.cs b/src/umbraco.cms/businesslogic/template/Template.cs
index e45fdec3cb..aca2b5ce9b 100644
--- a/src/umbraco.cms/businesslogic/template/Template.cs
+++ b/src/umbraco.cms/businesslogic/template/Template.cs
@@ -88,12 +88,11 @@ namespace umbraco.cms.businesslogic.template
{
language.Language lang = language.Language.GetByCultureCode(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
if (lang != null)
- {
- if (Dictionary.DictionaryItem.hasKey(tempText.Substring(1, tempText.Length - 1)))
+ {
+ if (ApplicationContext.Current.Services.LocalizationService.DictionaryItemExists(tempText.Substring(1, tempText.Length - 1)))
{
- Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(tempText.Substring(1, tempText.Length - 1));
- if (di != null)
- return di.Value(lang.id);
+ var di = ApplicationContext.Current.Services.LocalizationService.GetDictionaryItemByKey(tempText.Substring(1, tempText.Length - 1));
+ return di.GetTranslatedValue(lang.id);
}
}
diff --git a/src/umbraco.cms/umbraco.cms.csproj b/src/umbraco.cms/umbraco.cms.csproj
index b5ff0e5430..bd2127bb77 100644
--- a/src/umbraco.cms/umbraco.cms.csproj
+++ b/src/umbraco.cms/umbraco.cms.csproj
@@ -194,9 +194,6 @@
Code
-
- Code
-
Code
@@ -231,9 +228,6 @@
Code
-
- Code
-
Code
@@ -246,12 +240,6 @@
Code
-
- Code
-
-
- Code
-