Пример #1
0
    public BlogWrapper(BXBlog charge, BXAdminPage parentPage)
    {
        if (charge == null)
            throw new ArgumentNullException("charge");

        if (parentPage == null)
            throw new ArgumentNullException("parentPage");

        _charge = charge;
        _parentPage = parentPage;
    }
Пример #2
0
	private void TryLoadBlog()
	{
        int id = BlogId;
        if (id <= 0)
        {
            _editorMode = BlogEditorMode.Creation;
            _blog = new BXBlog();
        }
        else
        {
            _editorMode = BlogEditorMode.Modification;
            #region OLD
            //if ((_blog = BXBlog.GetById(id, BXTextEncoder.EmptyTextEncoder)) == null)
            //{
            //    _errorMessage = string.Format(GetMessageRaw("Error.UnableToFindBlog"), id);
            //    _editorError = BlogEditorError.BlogIsNotFound;
            //    return;
            //}
            #endregion
            BXBlogCollection blogCol = BXBlog.GetList(
                new BXFilter(new BXFilterItem(BXBlog.Fields.Id, BXSqlFilterOperators.Equal, id)),
                null,
                new BXSelectAdd(
					BXBlog.Fields.CustomFields.DefaultFields,
					BXBlog.Fields.Settings),
                null);

            if ((_blog = blogCol.Count > 0 ? blogCol[0] : null) == null)
            {
                _errorMessage = string.Format(GetMessageRaw("Error.UnableToFindBlog"), id);
                _editorError = BlogEditorError.BlogIsNotFound;
                return;
            }
        }

		if (_editorMode == BlogEditorMode.Modification)
        {
            BlogActive.Checked = _blog.Active;
            BlogName.Text = _blog.TextEncoder.Decode(_blog.Name);
            BlogSlug.Text = _blog.Slug;
            BlogDescription.Text = _blog.TextEncoder.Decode(_blog.Description);
            BlogSort.Text = _blog.Sort.ToString();
            BlogNotifyOfComments.Checked = _blog.NotifyOfComments;
			BlogIsTeam.Checked = _blog.IsTeam;
            BlogXmlId.Text = _blog.TextEncoder.Decode(_blog.XmlId);
			BlogIndexContent.SelectedValue = _blog.IndexContent.ToString();
            ListItemCollection categoryItems = BlogCategories.Items;
            int[] categoryIds = _blog.GetCategoryIds();
            foreach (int categoryId in categoryIds)
            {
                ListItem li = categoryItems.FindByValue(categoryId.ToString());
                if (li != null)
                    li.Selected = true;
            }

            #region OLD
            /*
            if (!_blog.IsNew)
            {
                ListItemCollection userItems = BlogOwner.Items;
                ListItem userItem = userItems.FindByValue(_blog.OwnerId.ToString());
                if (userItem != null)
                    userItem.Selected = true;
            }
            */
            #endregion

            if (!_blog.IsNew)
            {
                BXBlogUser owner = _blog.Owner;
                FindUserAutocomplete.HiddenValue = _blog.OwnerId.ToString();
				string firstName = owner.User.TextEncoder.Decode(owner.User.FirstName);
				firstName = (String.IsNullOrEmpty(firstName)) ? String.Empty : firstName.Trim();

				string lastName = owner.User.TextEncoder.Decode(owner.User.LastName);
                lastName = 
					String.IsNullOrEmpty(lastName)
					? String.Empty 
					: (
						string.IsNullOrEmpty(firstName) 
						? lastName.Trim() + " " 
						: " " + lastName + " "
					);
                FindUserAutocomplete.TextBoxValue = firstName + lastName + "(" + owner.TextEncoder.Decode(owner.GetUserName()) + ")";
            }

            EnableSyndication.Checked = Syndication.Enabled;
            SyndicationRssFeedUrl.Text = Syndication.FeedUrl;
            SyndicationUpdateable.Checked = Syndication.Updateable;
            SyndicationRedirectToComments.Checked = Syndication.RedirectToComments;

            SyndicationRssFeedUrlRequired.Enabled = Syndication.Enabled;
            SyndicationRssFeedUrlRegex.Enabled = Syndication.Enabled;

            #region DEFERRED
            /*
            ListItem postVisibilityModeItem = BlogPostVisibilityMode.Items.FindByValue(_blog.PostVisibilityMode.ToString("G"));
            if (postVisibilityModeItem != null)
                postVisibilityModeItem.Selected = true;

            ListItem addCommentPermissionItem = BlogAddCommentPermission.Items.FindByValue(_blog.AddCommentPermission.ToString("G"));
            if (addCommentPermissionItem != null)
                addCommentPermissionItem.Selected = true;

            ListItem commentApprovalItem = BlogCommentApproval.Items.FindByValue(_blog.CommentApproval.ToString("G"));
            if (commentApprovalItem != null)
                commentApprovalItem.Selected = true;
            */
            #endregion

			BXBlogSettings settings = _blog.Settings ?? new BXBlogSettings(_blog.Id);

			EnableCommentModeration.Checked = settings.EnableCommentModeration;
			ListItem moderationMode = CommentModerationMode.Items.FindByValue(settings.CommentModerationMode.ToString("G").ToUpperInvariant());
			if(moderationMode != null)
				moderationMode.Selected = true;
			CommentPremoderationFilterLinkThresholdTbx.Text = settings.CommentModerationFilter.LinkThreshold.ToString();
			StringBuilder sb = new StringBuilder();
			foreach(string stopListItem in settings.CommentModerationFilter.StopList)
				sb.AppendLine(stopListItem);
			CommentPremoderationFilterStopListTbx.Text = sb.ToString();
        }
        else
        {
			BlogActive.Checked = true;
			BlogSort.Text = "10";
			BlogNotifyOfComments.Checked = true;
			BlogIndexContent.SelectedValue = BXBlogIndexContentMode.All.ToString();
			EnableCommentModeration.Checked = false;
			ListItem moderationMode = CommentModerationMode.Items.FindByValue(BXBlogCommentModerationMode.All.ToString("G").ToUpperInvariant());
			if(moderationMode != null)
				moderationMode.Selected = true;
			CommentPremoderationFilterLinkThresholdTbx.Text = "0";
			CommentPremoderationFilterStopListTbx.Text = string.Empty;
        }
	}