Skip to content

Commit b8016f7

Browse files
committed
Changes to BlogRoll widget (still in progress) (3.2.1.7)
1 parent 31978ec commit b8016f7

16 files changed

Lines changed: 283 additions & 1196 deletions

File tree

BlogEngine/BlogEngine.Core/BlogEngine.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<Compile Include="Data\Contracts\IWidgetsRepository.cs" />
119119
<Compile Include="Data\Contracts\IDashboardRepository.cs" />
120120
<Compile Include="Data\Services\TagCloud.cs" />
121+
<Compile Include="Data\ViewModels\BlogRollVM.cs" />
121122
<Compile Include="Data\WidgetsRepository.cs" />
122123
<Compile Include="Data\DashboardRepository.cs" />
123124
<Compile Include="Data\Models\EditorOptions.cs" />

BlogEngine/BlogEngine.Core/BlogRollItem.cs

Lines changed: 18 additions & 294 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,23 @@
11
namespace BlogEngine.Core
22
{
33
using System;
4-
using System.Collections.Generic;
5-
6-
using BlogEngine.Core.Providers;
74

85
/// <summary>
9-
/// BlogRolls are links to outside blogs.
6+
/// Blog roll item
107
/// </summary>
11-
[Serializable]
12-
public class BlogRollItem : BusinessBase<BlogRollItem, Guid>, IComparable<BlogRollItem>
8+
public class BlogRollItem
139
{
14-
#region Constants and Fields
15-
16-
/// <summary>
17-
/// The sync root.
18-
/// </summary>
19-
private static readonly object SyncRoot = new object();
20-
21-
/// <summary>
22-
/// The blog rolls.
23-
/// </summary>
24-
private static Dictionary<Guid, List<BlogRollItem>> blogRolls;
25-
26-
/// <summary>
27-
/// The blog url.
28-
/// </summary>
29-
private Uri blogUrl;
30-
31-
/// <summary>
32-
/// The description.
33-
/// </summary>
34-
private string description;
35-
36-
/// <summary>
37-
/// The feed url.
38-
/// </summary>
39-
private Uri feedUrl;
40-
41-
/// <summary>
42-
/// The sort index.
43-
/// </summary>
44-
private int sortIndex;
45-
46-
/// <summary>
47-
/// The title.
48-
/// </summary>
49-
private string title;
50-
51-
/// <summary>
52-
/// The xfn string.
53-
/// </summary>
54-
private string xfn;
55-
56-
#endregion
57-
5810
#region Constructors and Destructors
5911

6012
/// <summary>
6113
/// Initializes a new instance of the <see cref = "BlogRollItem" /> class.
6214
/// </summary>
6315
public BlogRollItem()
6416
{
65-
this.Id = Guid.NewGuid();
17+
Id = Guid.NewGuid();
18+
Title = "";
19+
Description = "";
20+
Xfn = "";
6621
}
6722

6823
/// <summary>
@@ -79,281 +34,50 @@ public BlogRollItem()
7934
/// </param>
8035
public BlogRollItem(string title, string description, Uri blogUrl)
8136
{
82-
this.Id = Guid.NewGuid();
83-
this.Title = title;
84-
this.Description = description;
85-
this.BlogUrl = blogUrl;
86-
}
87-
88-
static BlogRollItem()
89-
{
90-
Blog.Saved += (s, e) =>
91-
{
92-
if (e.Action == SaveAction.Delete)
93-
{
94-
Blog blog = s as Blog;
95-
if (blog != null)
96-
{
97-
// remove deleted blog from static 'blogRolls'
98-
99-
if (blogRolls != null && blogRolls.ContainsKey(blog.Id))
100-
blogRolls.Remove(blog.Id);
101-
}
102-
}
103-
};
37+
Id = Guid.NewGuid();
38+
Title = title;
39+
Description = description;
40+
BlogUrl = blogUrl;
10441
}
10542

10643
#endregion
10744

10845
#region Properties
10946

11047
/// <summary>
111-
/// Gets all of the BlogRollItems from the data store.
48+
/// Item ID
11249
/// </summary>
113-
public static List<BlogRollItem> BlogRolls
114-
{
115-
get
116-
{
117-
Blog blog = Blog.CurrentInstance;
118-
119-
if (blogRolls == null || !blogRolls.ContainsKey(blog.Id))
120-
{
121-
lock (SyncRoot)
122-
{
123-
if (blogRolls == null || !blogRolls.ContainsKey(blog.Id))
124-
{
125-
if (blogRolls == null)
126-
blogRolls = new Dictionary<Guid, List<BlogRollItem>>();
127-
128-
blogRolls[blog.Id] = BlogService.FillBlogRolls();
129-
130-
if(blogRolls[blog.Id] != null)
131-
blogRolls[blog.Id].Sort();
132-
}
133-
}
134-
}
135-
136-
return blogRolls[blog.Id];
137-
}
138-
}
50+
public Guid Id { get; set; }
13951

14052
/// <summary>
14153
/// Gets or sets the BlogUrl of the object.
14254
/// </summary>
143-
public Uri BlogUrl
144-
{
145-
get
146-
{
147-
return this.blogUrl;
148-
}
149-
150-
set
151-
{
152-
base.SetValue("BlogUrl", value, ref this.blogUrl);
153-
}
154-
}
55+
public Uri BlogUrl { get; set; }
15556

15657
/// <summary>
15758
/// Gets or sets the Description of the object.
15859
/// </summary>
159-
public string Description
160-
{
161-
get
162-
{
163-
return this.description;
164-
}
165-
166-
set
167-
{
168-
base.SetValue("Description", value, ref this.description);
169-
}
170-
}
60+
public string Description { get; set; }
17161

17262
/// <summary>
17363
/// Gets or sets the FeedUrl of the object.
17464
/// </summary>
175-
public Uri FeedUrl
176-
{
177-
get
178-
{
179-
return this.feedUrl;
180-
}
181-
182-
set
183-
{
184-
base.SetValue("FeedUrl", value, ref this.feedUrl);
185-
}
186-
}
65+
public Uri FeedUrl { get; set; }
18766

18867
/// <summary>
18968
/// Gets or sets the SortIndex of the object.
19069
/// </summary>
191-
public int SortIndex
192-
{
193-
get
194-
{
195-
return this.sortIndex;
196-
}
197-
198-
set
199-
{
200-
base.SetValue("SortIndex", value, ref this.sortIndex);
201-
}
202-
}
70+
public int SortIndex { get; set; }
20371

20472
/// <summary>
20573
/// Gets or sets the Title of the object.
20674
/// </summary>
207-
public string Title
208-
{
209-
get
210-
{
211-
return this.title;
212-
}
213-
214-
set
215-
{
216-
base.SetValue("Title", value, ref this.title);
217-
}
218-
}
75+
public string Title { get; set; }
21976

22077
/// <summary>
22178
/// Gets or sets the Xfn of the object.
22279
/// </summary>
223-
public string Xfn
224-
{
225-
get
226-
{
227-
return this.xfn;
228-
}
229-
230-
set
231-
{
232-
base.SetValue("Xfn", value, ref this.xfn);
233-
}
234-
}
235-
236-
#endregion
237-
238-
#region Public Methods
239-
240-
/// <summary>
241-
/// Gets the BlogRollItem from the data store.
242-
/// </summary>
243-
/// <param name="id">The blogroll item id.</param>
244-
/// <returns>The blogroll item.</returns>
245-
public static BlogRollItem GetBlogRollItem(Guid id)
246-
{
247-
return BlogRolls.Find(br => br.Id == id);
248-
}
249-
250-
/// <summary>
251-
/// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
252-
/// </summary>
253-
/// <returns>
254-
/// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
255-
/// </returns>
256-
public override string ToString()
257-
{
258-
return this.Title;
259-
}
260-
261-
#endregion
262-
263-
#region Implemented Interfaces
264-
265-
#region IComparable<BlogRollItem>
266-
267-
/// <summary>
268-
/// Compares the current object with another object of the same type.
269-
/// </summary>
270-
/// <param name="other">
271-
/// An object to compare with this object.
272-
/// </param>
273-
/// <returns>
274-
/// A 32-bit signed integer that indicates the relative order of the objects being compared.
275-
/// The return value has the following meanings: Value Meaning Less than zero This object is
276-
/// less than the other parameter.Zero This object is equal to other. Greater than zero This object is greater than other.
277-
/// </returns>
278-
public int CompareTo(BlogRollItem other)
279-
{
280-
return this.SortIndex.CompareTo(other.SortIndex);
281-
}
282-
283-
#endregion
284-
285-
#endregion
286-
287-
#region Methods
288-
289-
/// <summary>
290-
/// Deletes the object from the data store.
291-
/// </summary>
292-
protected override void DataDelete()
293-
{
294-
OnSaving(this, SaveAction.Delete);
295-
if (this.Deleted)
296-
{
297-
BlogService.DeleteBlogRoll(this);
298-
}
299-
300-
BlogRolls.Remove(this);
301-
OnSaved(this, SaveAction.Delete);
302-
303-
this.Dispose();
304-
}
305-
306-
/// <summary>
307-
/// Inserts a new object to the data store.
308-
/// </summary>
309-
protected override void DataInsert()
310-
{
311-
OnSaving(this, SaveAction.Insert);
312-
if (this.New)
313-
{
314-
BlogService.InsertBlogRoll(this);
315-
}
316-
317-
OnSaved(this, SaveAction.Insert);
318-
}
319-
320-
/// <summary>
321-
/// Retrieves the object from the data store and populates it.
322-
/// </summary>
323-
/// <param name="id">
324-
/// The unique identifier of the object.
325-
/// </param>
326-
/// <returns>
327-
/// The object that was selected from the data store.
328-
/// </returns>
329-
protected override BlogRollItem DataSelect(Guid id)
330-
{
331-
return BlogService.SelectBlogRoll(id);
332-
}
333-
334-
/// <summary>
335-
/// Updates the object in its data store.
336-
/// </summary>
337-
protected override void DataUpdate()
338-
{
339-
OnSaving(this, SaveAction.Update);
340-
if (this.IsChanged)
341-
{
342-
BlogService.UpdateBlogRoll(this);
343-
}
344-
345-
OnSaved(this, SaveAction.Update);
346-
}
347-
348-
/// <summary>
349-
/// Reinforces the business rules by adding additional rules to the
350-
/// broken rules collection.
351-
/// </summary>
352-
protected override void ValidationRules()
353-
{
354-
this.AddRule("Title", "Title must be set", string.IsNullOrEmpty(this.Title));
355-
this.AddRule("BlogUrl", "BlogUrl must be set", this.BlogUrl == null);
356-
}
80+
public string Xfn { get; set; }
35781

35882
#endregion
35983
}

BlogEngine/BlogEngine.Core/BlogSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ public DateTime ToUtc(DateTime ? localTime = null)
10591059

10601060
var zone = string.IsNullOrEmpty(Instance.TimeZoneId) ? "UTC" : Instance.TimeZoneId;
10611061
var tz = TimeZoneInfo.FindSystemTimeZoneById(zone);
1062+
localTime = DateTime.SpecifyKind(localTime.Value, DateTimeKind.Unspecified);
10621063

10631064
return TimeZoneInfo.ConvertTimeToUtc(localTime.Value, tz);
10641065
}

0 commit comments

Comments
 (0)