Пример #1
0
        private string RenderFacebookLike()
        {
            string facebook = string.Empty;

            if (WebConfigSettings.DisableFacebookLikeButton)
            {
                return(facebook);
            }

            string facebookWidgets = "<script type=\"text/javascript\">\n"
                                     + "(function (d, s, id) {\n"
                                     + "var js, fjs = d.getElementsByTagName(s)[0];\n"
                                     + "if (d.getElementById(id)) return;\n"
                                     + "js = d.createElement(s); js.id = id\n"
                                     + "js.async=true;\n"
                                     + "js.src = \"//connect.facebook.net/en_US/all.js#xfbml=1\";\n"
                                     + "fjs.parentNode.insertBefore(js, fjs);\n"
                                     + "} (document, 'script', 'facebook-jssdk'));\n"
                                     + "</script>\n";

            Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                        "facebookwidgets", facebookWidgets);

            facebook  = "<a class='fb-like'";
            facebook += " data-href='" + NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID) + "'";
            facebook += " data-send='false'";
            facebook += " data-layout='button_count'";
            facebook += " data-width='100'";
            facebook += " data-show-faces='false'";
            facebook += "></a>";

            return(facebook);
        }
Пример #2
0
        private string RenderTweetThis()
        {
            string twitterWidgets = "<script type=\"text/javascript\">\n"
                                    + "!function (d, s, id) {\n"
                                    + "var js, fjs = d.getElementsByTagName(s)[0];\n"
                                    + "if (!d.getElementById(id)) {\n"
                                    + "js = d.createElement(s);\n"
                                    + "js.id = id; js.src = \"//platform.twitter.com/widgets.js\";\n"
                                    + "fjs.parentNode.insertBefore(js, fjs);\n"
                                    + "}\n"
                                    + "} (document, \"script\", \"twitter-wjs\");"
                                    + "</script>\n";

            Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                        "twitterwidgets", twitterWidgets);

            string twitterUrl = "https://twitter.com/share";

            string tweetThis = "<a class='twitter-share-button'";

            tweetThis += " title='Tweet This'";
            tweetThis += " href='" + twitterUrl + "'";
            tweetThis += " data-url='" + NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID) + "'";
            tweetThis += " data-text='" + news.Title + "'";
            tweetThis += " data-count='horizontal'";
            tweetThis += "></a>";

            return(tweetThis);
        }
Пример #3
0
        public bool DeleteContent(string newsId)
        {
            try
            {
                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                News         news         = new News(siteSettings.SiteId, Convert.ToInt32(newsId));

                if (news != null && news.NewsID != -1)
                {
                    NewsHelper.DeleteFolder(siteSettings.SiteId, news.NewsID);

                    ContentMedia.DeleteByContent(news.NewsGuid);

                    var listAtributes = ContentAttribute.GetByContentAsc(news.NewsGuid);
                    foreach (ContentAttribute item in listAtributes)
                    {
                        ContentLanguage.DeleteByContent(item.Guid);
                    }
                    ContentAttribute.DeleteByContent(news.NewsGuid);
                    ContentLanguage.DeleteByContent(news.NewsGuid);

                    news.Delete();
                    FriendlyUrl.DeleteByPageGuid(news.NewsGuid);

                    FileAttachment.DeleteByItem(news.NewsGuid);
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
Пример #4
0
        public override bool UserHasPermission()
        {
            if (!Request.IsAuthenticated)
            {
                return(false);
            }

            bool hasPermission = false;

            EnsureConfiguration();

            if (config.Position > 0)
            {
                if (WebUser.IsAdminOrContentAdmin && SiteUtils.UserIsSiteEditor())
                {
                    if (config.NewsType > 0)
                    {
                        string chooseNewsLabel = NewsHelper.GetNameByNewsType(config.NewsType, NewsResources.NewsSelectFormat, NewsResources.NewsSelectLabel);
                        this.LiteralExtraMarkup = "<dd><a class='ActionLink choosenewslink' href='"
                                                  + SiteRoot
                                                  + "/News/NewsSpecial.aspx?type=" + config.NewsType + "&pos=" + config.Position.ToString() + "'>" + chooseNewsLabel + "</a></dd>";
                    }
                    else
                    {
                        this.LiteralExtraMarkup = "<dd><a class='ActionLink choosenewslink' href='"
                                                  + SiteRoot
                                                  + "/News/NewsSpecial.aspx?pos=" + config.Position.ToString() + "'>" + NewsResources.NewsSelectLabel + "</a></dd>";
                    }

                    hasPermission = true;
                }
            }

            return(hasPermission);
        }
Пример #5
0
        public void BuildNextPreviousXml(
            XmlDocument doc,
            XmlElement root)
        {
            news.LoadNextPrevious(languageId);

            if ((news.PreviousNewsId > -1) || (news.PreviousNewsUrl.Length > 0))
            {
                XmlHelper.AddNode(doc, root, "PreviousLink", "<a href='" + NewsHelper.FormatNewsUrl(news.PreviousNewsUrl, news.PreviousNewsId, news.PreviousZoneId) + "' title='" + news.PreviousNewsTitle + "'>" + NewsResources.NewsPreviousLink + "</a>");
                XmlHelper.AddNode(doc, root, "PreviousUrl", NewsHelper.FormatNewsUrl(news.PreviousNewsUrl, news.PreviousNewsId, news.PreviousZoneId));
                XmlHelper.AddNode(doc, root, "PreviousNewsTitle", news.PreviousNewsTitle);
                XmlHelper.AddNode(doc, root, "PreviousTitle", NewsResources.NewsPreviousLink.Replace("<<", "").Replace(">>", ""));
                XmlHelper.AddNode(doc, root, "IsFirstNews", news.IsFirstNews.ToString().ToLower());
                XmlHelper.AddNode(doc, root, "IsLastNews", news.IsLastNews.ToString().ToLower());
            }
            if ((news.NextNewsId > -1) || (news.NextNewsUrl.Length > 0))
            {
                XmlHelper.AddNode(doc, root, "NextLink", "<a href='" + NewsHelper.FormatNewsUrl(news.NextNewsUrl, news.NextNewsId, news.NextZoneId) + "' title='" + news.NextNewsTitle + "'>" + NewsResources.NewsNextLink + "</a>");
                XmlHelper.AddNode(doc, root, "NextUrl", NewsHelper.FormatNewsUrl(news.NextNewsUrl, news.NextNewsId, news.NextZoneId));
                XmlHelper.AddNode(doc, root, "NextNewsTitle", news.NextNewsTitle);
                XmlHelper.AddNode(doc, root, "NextTitle", NewsResources.NewsNextLink.Replace("<<", "").Replace(">>", ""));
                XmlHelper.AddNode(doc, root, "IsFirstNews", news.IsFirstNews.ToString().ToLower());
                XmlHelper.AddNode(doc, root, "IsLastNews", news.IsLastNews.ToString().ToLower());
            }
        }
Пример #6
0
        private void PopulateControls()
        {
            XmlDocument doc = GetPageXml(zoneId, pageNumber, config.PageSize, out totalPages);

            if (NewsHelper.IsAjaxRequest(Request) && WebUtils.ParseBoolFromQueryString("isajax", false))
            {
                Response.Write(XmlHelper.TransformXML(SiteUtils.GetXsltBasePath("news", config.XsltFileName), doc));
                Response.End();
                return;
            }

            XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("news", config.XsltFileName), doc);

            string pageUrlLeaveOutPageNumber = SiteUtils.BuildUrlLeaveOutParam(Request.RawUrl, "pagenumber");
            string pageUrl = pageUrlLeaveOutPageNumber;

            if (pageUrl.Contains("?"))
            {
                pageUrl += "&amp;pagenumber={0}";
            }
            else
            {
                pageUrl += "?pagenumber={0}";
            }

            pgr.PageURLFormat = pageUrl;
            pgr.ShowFirstLast = true;
            pgr.PageSize      = config.PageSize;
            pgr.PageCount     = totalPages;
            pgr.CurrentIndex  = pageNumber;
            divPager.Visible  = (totalPages > 1);

            // Canonical pagin
            string nextUrl     = string.Format(pageUrl, pageNumber + 1).Replace("&amp;pagenumber=", "&pagenumber=");
            string previousUrl = string.Format(pageUrl, pageNumber - 1).Replace("&amp;pagenumber=", "&pagenumber=");

            if (totalPages > 1)
            {
                if (pageNumber == 1) // first page
                {
                    basePage.AdditionalMetaMarkup += "\n<link rel='next' href='" + nextUrl + "' />";
                }
                else if (pageNumber == totalPages) // last page
                {
                    basePage.AdditionalMetaMarkup += "\n<link rel='prev' href='" + previousUrl + "' />";
                }
                else //other pages
                {
                    basePage.AdditionalMetaMarkup += "\n<link rel='prev' href='" + previousUrl + "' />";
                    basePage.AdditionalMetaMarkup += "\n<link rel='next' href='" + nextUrl + "' />";
                }
            }

            if (WebUtils.ParseInt32FromQueryString("pagenumber", -1) == 1)
            {
                basePage.AdditionalMetaMarkup += "\n<link rel=\"canonical\" href=\"" + pageUrlLeaveOutPageNumber + "\" />";
            }
        }
Пример #7
0
        public static XmlDocument BuildNewsDataXml(XmlDocument doc, XmlElement newsXml, News news, TimeZoneInfo timeZone, double timeOffset, string editLink)
        {
            XmlHelper.AddNode(doc, newsXml, "Title", news.Title);
            XmlHelper.AddNode(doc, newsXml, "SubTitle", news.SubTitle);
            XmlHelper.AddNode(doc, newsXml, "Url", NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID));
            XmlHelper.AddNode(doc, newsXml, "Target", NewsHelper.GetNewsTarget(news.OpenInNewWindow));
            XmlHelper.AddNode(doc, newsXml, "ShowOption", news.ShowOption.ToString());
            XmlHelper.AddNode(doc, newsXml, "NewsId", news.NewsID.ToString()); //2016-08-11

            string imageFolderPath          = NewsHelper.MediaFolderPath(news.SiteId, news.NewsID);
            string thumbnailImageFolderPath = imageFolderPath + "thumbs/";

            if (news.ImageFile.Length > 0)
            {
                XmlHelper.AddNode(doc, newsXml, "ImageUrl", VirtualPathUtility.ToAbsolute(imageFolderPath + news.ImageFile));
            }
            if (news.ThumbnailFile.Length > 0)
            {
                XmlHelper.AddNode(doc, newsXml, "ThumbnailUrl", VirtualPathUtility.ToAbsolute(thumbnailImageFolderPath + news.ThumbnailFile));
            }

            XmlHelper.AddNode(doc, newsXml, "EditLink", editLink);

            XmlHelper.AddNode(doc, newsXml, "BriefContent", news.BriefContent);
            XmlHelper.AddNode(doc, newsXml, "FullContent", news.FullContent);
            XmlHelper.AddNode(doc, newsXml, "ViewCount", news.Viewed.ToString());
            XmlHelper.AddNode(doc, newsXml, "CommentCount", news.CommentCount.ToString());
            XmlHelper.AddNode(doc, newsXml, "FileUrl", news.FileAttachment);

            object startDate = news.StartDate;

            XmlHelper.AddNode(doc, newsXml, "CreatedDate", FormatDate(startDate, timeZone, timeOffset, ResourceHelper.GetResourceString("NewsResources", "NewsDateFormat")));
            XmlHelper.AddNode(doc, newsXml, "CreatedTime", FormatDate(startDate, timeZone, timeOffset, ResourceHelper.GetResourceString("NewsResources", "NewsTimeFormat")));
            XmlHelper.AddNode(doc, newsXml, "CreatedDD", FormatDate(startDate, timeZone, timeOffset, "dd"));
            XmlHelper.AddNode(doc, newsXml, "CreatedYY", FormatDate(startDate, timeZone, timeOffset, "yy"));
            XmlHelper.AddNode(doc, newsXml, "CreatedYYYY", FormatDate(startDate, timeZone, timeOffset, "yyyy"));
            XmlHelper.AddNode(doc, newsXml, "CreatedMM", FormatDate(startDate, timeZone, timeOffset, "MM"));
            if (System.Globalization.CultureInfo.CurrentCulture.Name.ToLower() == "vi-vn")
            {
                string monthVI = "Tháng " + FormatDate(startDate, timeZone, timeOffset, "MM");
                XmlHelper.AddNode(doc, newsXml, "CreatedMMM", monthVI);
                XmlHelper.AddNode(doc, newsXml, "CreatedMMMM", monthVI);
            }
            else
            {
                XmlHelper.AddNode(doc, newsXml, "CreatedMMM", FormatDate(startDate, timeZone, timeOffset, "MMM"));
                XmlHelper.AddNode(doc, newsXml, "CreatedMMMM", FormatDate(startDate, timeZone, timeOffset, "MMMM"));
            }

            if (news.EndDate != DateTime.MaxValue)
            {
                XmlHelper.AddNode(doc, newsXml, "EndDate", FormatDate(news.EndDate, timeZone, timeOffset, ResourceHelper.GetResourceString("NewsResources", "NewsDateFormat")));
            }

            return(doc);
        }
Пример #8
0
        public override bool UserHasPermission()
        {
            if (!Request.IsAuthenticated)
            {
                return(false);
            }

            bool hasPermission = false;

            EnsureNewsConfiguration();

            if (NewsPermission.CanCreate)
            {
                if (config.NewsType > 0)
                {
                    this.EditUrl = SiteRoot + "/News/NewsEdit.aspx?type=" + config.NewsType.ToString() + "&start=" + CurrentZone.ZoneId;
                }
                else
                {
                    this.EditUrl = SiteRoot + "/News/NewsEdit.aspx?start=" + CurrentZone.ZoneId;
                }

                this.EditText = NewsResources.NewsInsertLabel;

                hasPermission = true;
            }

            if (NewsPermission.CanViewList)
            {
                if (config.NewsType > 0)
                {
                    string newsListLabel = NewsHelper.GetNameByNewsType(config.NewsType, NewsResources.NewsListFormat, NewsResources.NewsList);

                    this.LiteralExtraMarkup =
                        "<dd><a class='ActionLink newslistlink' href='"
                        + SiteRoot
                        + "/News/NewsList.aspx?type=" + config.NewsType + "&start=" + CurrentZone.ZoneId + "'>"
                        + newsListLabel + "</a></dd>";
                }
                else
                {
                    this.LiteralExtraMarkup =
                        "<dd><a class='ActionLink newslistlink' href='"
                        + SiteRoot
                        + "/News/NewsList.aspx?start=" + CurrentZone.ZoneId + "'>"
                        + NewsResources.NewsList + "</a></dd>";
                }

                hasPermission = true;
            }

            return(hasPermission);
        }
Пример #9
0
        private string RenderPlusOne()
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page),
                                                    "gplusone", "\n<script type=\"text/javascript\" src=\""
                                                    + "https://apis.google.com/js/plusone.js" + "\"></script>", false);

            string plusOne = "<div class='g-plusone' data-size='medium' data-count='true'";

            plusOne += " data-href='" + NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID);
            plusOne += "'></div>";

            return(plusOne);
        }
Пример #10
0
        public void BuildNewsImagesXml(
            XmlDocument doc,
            XmlElement root)
        {
            string imageFolderPath          = NewsHelper.MediaFolderPath(basePage.SiteId, news.NewsID);
            string thumbnailImageFolderPath = imageFolderPath + "thumbs/";
            string siteRoot = WebUtils.GetSiteRoot();

            int    defaultLanguageId = -1;
            string defaultCulture    = WebConfigSettings.DefaultLanguageCulture;

            if (defaultCulture.Length > 0)
            {
                defaultLanguageId = LanguageHelper.GetLanguageIdByCulture(defaultCulture);
            }

            List <int>          listDisplayOrder = new List <int>();
            List <ContentMedia> listMedia        = ContentMedia.GetByContentDesc(news.NewsGuid);

            foreach (ContentMedia media in listMedia)
            {
                if (media.LanguageId == -1 || media.LanguageId == languageId || (languageId == -1 && media.LanguageId == defaultLanguageId))
                {
                    BuildNewsImagesXml(doc, root, media, imageFolderPath, thumbnailImageFolderPath);

                    if (displaySettings.ShowGroupImages)
                    {
                        if (!listDisplayOrder.Contains(media.DisplayOrder))
                        {
                            listDisplayOrder.Add(media.DisplayOrder);
                            XmlElement groupImages = doc.CreateElement("GroupImages");
                            root.AppendChild(groupImages);
                            XmlHelper.AddNode(doc, groupImages, "DisplayOrder", media.DisplayOrder.ToString());

                            foreach (ContentMedia media2 in listMedia)
                            {
                                if ((media2.LanguageId == -1 || media2.LanguageId == languageId || (languageId == -1 && media2.LanguageId == defaultLanguageId)) &&
                                    (media2.DisplayOrder == media.DisplayOrder))
                                {
                                    BuildNewsImagesXml(doc, groupImages, media2, imageFolderPath, thumbnailImageFolderPath);
                                }
                            }
                        }
                    }

                    string relativePath = siteRoot + Page.ResolveUrl(imageFolderPath + media.MediaFile);
                    basePage.AdditionalMetaMarkup += "\n<meta property=\"og:image\" content=\"" + relativePath + "\" />";
                    basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"image\" content=\"" + relativePath + "\" />";
                }
            }
        }
Пример #11
0
        private void PopulateLabels()
        {
            heading.Text = NewsHelper.GetNameByNewsType(newsType, NewsResources.NewsListFormat, NewsResources.NewsList);
            Page.Title   = SiteUtils.FormatPageTitle(siteSettings, heading.Text);

            breadcrumb.CurrentPageTitle = heading.Text;
            breadcrumb.CurrentPageUrl   = GetNewsListBreadCrumb();

            UIHelper.DisableButtonAfterClick(
                btnUpdate,
                NewsResources.ButtonDisabledPleaseWait,
                Page.ClientScript.GetPostBackEventReference(this.btnUpdate, string.Empty)
                );

            UIHelper.AddConfirmationDialog(btnDelete, NewsResources.NewsDeleteMultiWarning);
        }
Пример #12
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                bool isDeleted = false;

                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int intNewsID     = Convert.ToInt32(data.GetDataKeyValue("NewsID"));
                    int newsCommentID = Convert.ToInt32(data.GetDataKeyValue("NewsCommentID"));

                    string virtualPath    = NewsHelper.AttachmentsPath(siteSettings.SiteId, intNewsID);
                    string fileSystemPath = HostingEnvironment.MapPath(virtualPath);

                    try
                    {
                        NewsHelper.DeleteDirectory(fileSystemPath);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            System.Threading.Thread.Sleep(0);
                            Directory.Delete(fileSystemPath, false);
                        }
                        catch (Exception)
                        {
                        }
                    }

                    News.DeleteNewsComment(newsCommentID);
                    isDeleted = true;
                }

                if (isDeleted)
                {
                    PopulateControls();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Пример #13
0
        private void LoadSettings()
        {
            newsId = WebUtils.ParseInt32FromQueryString("NewsID", newsId);

            siteSettings = CacheHelper.GetCurrentSiteSettings();

            news = new News(siteSettings.SiteId, newsId, WorkingCulture.LanguageId);

            if (news == null || news.NewsID == -1)
            {
                news = null;
                return;
            }

            url = WebUtils.ParseStringFromQueryString("u", string.Empty);
            if (url.Length == 0)
            {
                url = NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID);
            }

            basePage.Title           = SiteUtils.FormatPageTitle(siteSettings, news.Title);
            basePage.MetaDescription = news.MetaDescription;
            basePage.MetaKeywords    = news.MetaKeywords;

            currentUser = SiteUtils.GetCurrentSiteUser();

            pnlAntiSpam.Visible = false;
            captcha.Visible     = false;
            captcha.Enabled     = false;

            uplAttachFile1.MaxFileSize           = NewsConfiguration.JobApplyAttachFileSize * 1048576;
            uplAttachFile1.AllowedFileExtensions = NewsConfiguration.JobApplyAttachFileExtensions.Replace(".", string.Empty).Split('|');
            uplAttachFile2.MaxFileSize           = uplAttachFile1.MaxFileSize;
            uplAttachFile2.AllowedFileExtensions = uplAttachFile1.AllowedFileExtensions;

            var litAttachFileNote1 = this.FindControl("litAttachFileNote1") as System.Web.UI.WebControls.Literal;
            var litAttachFileNote2 = this.FindControl("litAttachFileNote2") as System.Web.UI.WebControls.Literal;

            if (litAttachFileNote1 != null && litAttachFileNote2 != null)
            {
                litAttachFileNote1.Text = NewsConfiguration.JobApplyAttachFileNote;
                litAttachFileNote2.Text = NewsConfiguration.JobApplyAttachFileNote;
            }
        }
Пример #14
0
        private void PopulateLabels()
        {
            heading.Text = NewsHelper.GetNameByNewsType(newsType, Resources.NewsResources.NewsSpecialTilteFormat, Resources.NewsResources.NewsSpecialTilte);
            Page.Title   = SiteUtils.FormatPageTitle(siteSettings, heading.Text);

            //btnRight.ImageUrl = "~/Data/SiteImages/rt2.gif";
            //btnLeft.ImageUrl = "~/Data/SiteImages/lt2.gif";

            if (NewsPermission.CanViewList)
            {
                breadcrumb.ParentTitle = NewsHelper.GetNameByNewsType(newsType, Resources.NewsResources.NewsListFormat, Resources.NewsResources.NewsList);
                breadcrumb.ParentUrl   = GetNewsListBreadCrumb();
            }

            breadcrumb.CurrentPageTitle = heading.Text;
            breadcrumb.CurrentPageUrl   = GetNewsSpecialBreadCrumb();

            lblPosition.ConfigKey = "";
            lblPosition.Text      = Resources.NewsResources.NewsSelectedListLabel;
            ddlPosition.Style.Add("display", "none");
        }
Пример #15
0
        private void PopulateLabels()
        {
            heading.Text = NewsHelper.GetNameByNewsType(newsType, Resources.NewsResources.NewsMoveTilteFormat, Resources.NewsResources.NewsMoveTilte);
            Page.Title   = SiteUtils.FormatPageTitle(siteSettings, heading.Text);

            //btnRight.ImageUrl = "~/Data/SiteImages/rt2.gif";
            //btnRight.AlternateText = Resources.NewsResources.NewsMoveRightAlternateText;
            btnRight.ToolTip = Resources.NewsResources.NewsMoveRightAlternateText;

            //btnLeft.ImageUrl = "~/Data/SiteImages/lt2.gif";
            //btnLeft.AlternateText = Resources.NewsResources.NewsMoveLeftAlternateText;
            btnLeft.ToolTip = Resources.NewsResources.NewsMoveLeftAlternateText;

            if (NewsPermission.CanViewList)
            {
                breadcrumb.ParentTitle = NewsHelper.GetNameByNewsType(newsType, Resources.NewsResources.NewsListFormat, Resources.NewsResources.NewsList);
                breadcrumb.ParentUrl   = GetNewsListBreadCrumb();
            }

            breadcrumb.CurrentPageTitle = heading.Text;
            breadcrumb.CurrentPageUrl   = GetNewsMoveBreadCrumb();
        }
Пример #16
0
        protected void ibApproveContent_Command(object sender, CommandEventArgs e)
        {
            if (currentUser == null)
            {
                return;
            }

            News news = new News(siteSettings.SiteId, Convert.ToInt32(e.CommandArgument));

            if (news == null || news.NewsID == -1 || !news.StateId.HasValue)
            {
                return;
            }

            news.StateId          = WorkflowHelper.GetNextWorkflowStateId(workflowId, news.StateId.Value);
            news.ApprovedUserGuid = currentUser.UserGuid;
            news.ApprovedBy       = Context.User.Identity.Name.Trim();
            news.ApprovedUtc      = DateTime.UtcNow;
            news.RejectedNotes    = null;
            bool result = news.SaveState(lastWorkflowStateId);

            if (result)
            {
                if (!WebConfigSettings.DisableWorkflowNotification)
                {
                    NewsHelper.SendApprovalRequestNotification(
                        SiteUtils.GetSmtpSettings(),
                        siteSettings,
                        workflowId,
                        currentUser,
                        news);
                }

                message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");

                grid.Rebind();
            }
        }
Пример #17
0
        protected void ibApproveContent_Command(object sender, CommandEventArgs e)
        {
            if (currentUser == null || !isReviewRole)
            {
                return;
            }

            News news = new News(basePage.SiteId, Convert.ToInt32(e.CommandArgument));

            if (news == null || news.NewsID == -1 || !news.StateId.HasValue)
            {
                return;
            }

            news.StateId          = WorkflowHelper.GetNextWorkflowStateId(workflowId, news.StateId.Value);
            news.ApprovedUserGuid = currentUser.UserGuid;
            news.ApprovedBy       = Context.User.Identity.Name.Trim();
            news.ApprovedUtc      = DateTime.UtcNow;
            news.RejectedNotes    = null;
            bool result = news.SaveState(lastWorkflowStateId);

            if (result)
            {
                if (!WebConfigSettings.DisableWorkflowNotification)
                {
                    NewsHelper.SendApprovalRequestNotification(
                        SiteUtils.GetSmtpSettings(),
                        basePage.SiteInfo,
                        workflowId,
                        currentUser,
                        news);
                }

                WebUtils.SetupRedirect(this, Request.RawUrl);
            }
        }
Пример #18
0
        public void BuildNewsImagesXml(
            XmlDocument doc,
            XmlElement newsXml,
            News news,
            int languageId)
        {
            string imageFolderPath          = NewsHelper.MediaFolderPath(SiteId, news.NewsID);
            string thumbnailImageFolderPath = imageFolderPath + "thumbs/";

            List <ContentMedia> listMedia = ContentMedia.GetByContentDesc(news.NewsGuid);

            foreach (ContentMedia media in listMedia)
            {
                if (media.LanguageId == -1 || media.LanguageId == languageId)
                {
                    XmlElement element = doc.CreateElement("NewsImages");
                    newsXml.AppendChild(element);

                    XmlHelper.AddNode(doc, element, "Title", media.Title);
                    XmlHelper.AddNode(doc, element, "ImageUrl", Page.ResolveUrl(imageFolderPath + media.MediaFile));
                    XmlHelper.AddNode(doc, element, "ThumbnailUrl", Page.ResolveUrl(thumbnailImageFolderPath + media.ThumbnailFile));
                }
            }
        }
Пример #19
0
        protected void PopulateControls()
        {
            if (parametersAreInvalid)
            {
                pnlInnerWrap.Visible = false;
                return;
            }

            if (news.IsDeleted)
            {
                if (WebConfigSettings.Custom404Page.Length > 0)
                {
                    Server.Transfer(WebConfigSettings.Custom404Page);
                }
                else
                {
                    Server.Transfer("~/PageNotFound.aspx");
                }

                return;
            }

            if (news.IsPublished && news.EndDate < DateTime.UtcNow)
            {
                expired.Visible = true;
                //http://support.google.com/webmasters/bin/answer.py?hl=en&answer=40132
                // 410 means the resource is gone but once existed
                // google treats it as more permanent than a 404
                // and it should result in de-indexing the content
                Response.StatusCode        = 410;
                Response.StatusDescription = "Content Expired";
                if (
                    !NewsPermission.CanUpdate ||
                    !basePage.UserCanAuthorizeZone(news.ZoneID)
                    )
                {
                    pnlInnerWrap.Visible = false;
                    return;
                }
            }

            // if not published only the editor can see it
            if (!news.IsPublished)
            {
                bool stopRedirect = false;

                if (WebConfigSettings.EnableContentWorkflow && basePage.SiteInfo.EnableContentWorkflow)
                {
                    if (news.StateId.HasValue && WorkflowHelper.UserHasStatePermission(workflowId, news.StateId.Value))
                    {
                        stopRedirect = true;
                    }
                }
                else
                {
                    if (
                        (currentUser != null && currentUser.UserGuid == news.UserGuid) ||
                        (NewsPermission.CanUpdate && basePage.UserCanAuthorizeZone(news.ZoneID))
                        )
                    {
                        stopRedirect = true;
                    }
                }

                if (!stopRedirect)
                {
                    pnlInnerWrap.Visible = false;
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentZoneUrl());
                    return;
                }
            }

            SetupMetaTags();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<NewsDetail></NewsDetail>");
            XmlElement root = doc.DocumentElement;

            //XmlHelper.AddNode(doc, root, "ModuleTitle", module.ModuleTitle);
            XmlHelper.AddNode(doc, root, "ZoneTitle", basePage.CurrentZone.Name);
            XmlHelper.AddNode(doc, root, "ZoneDescription", basePage.CurrentZone.Description);
            XmlHelper.AddNode(doc, root, "ViewMore", NewsResources.NewsMoreLinkText);
            XmlHelper.AddNode(doc, root, "Title", news.Title);
            XmlHelper.AddNode(doc, root, "SubTitle", news.SubTitle);
            XmlHelper.AddNode(doc, root, "ZoneUrl", SiteUtils.GetCurrentZoneUrl());

            if (module.ResourceFileDef.Length > 0 && module.ResourceKeyDef.Length > 0)
            {
                List <string> lstResourceKeys = module.ResourceKeyDef.SplitOnCharAndTrim(';');

                foreach (string item in lstResourceKeys)
                {
                    XmlHelper.AddNode(doc, root, item, ResourceHelper.GetResourceString(module.ResourceFileDef, item));
                }
            }

            XmlHelper.AddNode(doc, root, "EditLink", NewsHelper.BuildEditLink(news, basePage, userCanUpdate, currentUser));

            //XmlHelper.AddNode(doc, root, "ViewCVLink", GetCVListLink(news.NewsID, news.CommentCount, NewsPermission.CanManageComment));
            XmlHelper.AddNode(doc, root, "ApplyText", NewsResources.JobApplyLable);
            XmlHelper.AddNode(doc, root, "ApplyUrl", this.siteRoot + "/News/JobApplyDialog.aspx?zoneid=" + zoneId.ToString() + "&NewsID=" + newsId.ToString());

            XmlHelper.AddNode(doc, root, "ShowOption", news.ShowOption.ToString());

            XmlHelper.AddNode(doc, root, "CreatedDate", FormatDate(news.StartDate, NewsResources.NewsDateFormat));
            XmlHelper.AddNode(doc, root, "CreatedTime", FormatDate(news.StartDate, NewsResources.NewsTimeFormat));
            XmlHelper.AddNode(doc, root, "CreatedDD", FormatDate(news.StartDate, "dd"));
            XmlHelper.AddNode(doc, root, "CreatedYY", FormatDate(news.StartDate, "yy"));
            XmlHelper.AddNode(doc, root, "CreatedYYYY", FormatDate(news.StartDate, "yyyy"));
            XmlHelper.AddNode(doc, root, "CreatedMM", FormatDate(news.StartDate, "MM"));
            if (WorkingCulture.DefaultName.ToLower() == "vi-vn")
            {
                string monthVI = "Tháng " + FormatDate(news.StartDate, "MM");
                XmlHelper.AddNode(doc, root, "CreatedMMM", monthVI);
                XmlHelper.AddNode(doc, root, "CreatedMMMM", monthVI);
            }
            else
            {
                XmlHelper.AddNode(doc, root, "CreatedMMM", FormatDate(news.StartDate, "MMM"));
                XmlHelper.AddNode(doc, root, "CreatedMMMM", FormatDate(news.StartDate, "MMMM"));
            }

            XmlHelper.AddNode(doc, root, "Code", news.Code);
            XmlHelper.AddNode(doc, root, "BriefContent", news.BriefContent);
            XmlHelper.AddNode(doc, root, "FullContent", news.FullContent);
            XmlHelper.AddNode(doc, root, "ViewCount", news.Viewed.ToString());
            XmlHelper.AddNode(doc, root, "FileUrl", news.FileAttachment);

            if (displaySettings.ShowNextPreviousLink)
            {
                BuildNextPreviousXml(doc, root);
            }

            XmlHelper.AddNode(doc, root, "FacebookLike", RenderFacebookLike());
            XmlHelper.AddNode(doc, root, "PlusOne", RenderPlusOne());
            XmlHelper.AddNode(doc, root, "TweetThis", RenderTweetThis());
            XmlHelper.AddNode(doc, root, "Print", RenderPrinter());
            XmlHelper.AddNode(doc, root, "Email", RenderEmailSubject());
            XmlHelper.AddNode(doc, root, "FullUrl", NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID));

            if (displaySettings.ShowAttribute)
            {
                BuildNewsAttributesXml(doc, root, languageId);
            }

            BuildNewsImagesXml(doc, root);

            #region Start news other

            BuildNewsOtherXml(doc, root, zoneId, pageNumber, config.RelatedItemsToShow, out totalPages);
            if (NewsHelper.IsAjaxRequest(Request) && WebUtils.ParseBoolFromQueryString("isajax", false))
            {
                Response.Write(XmlHelper.TransformXML(SiteUtils.GetXsltBasePath("news", config.XsltFileNameDetailPage), doc));
                Response.End();
                return;
            }

            string pageUrlLeaveOutPageNumber = NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID);

            if (config.HidePaginationOnDetailPage)
            {
                divPager.Visible = false;
            }
            else
            {
                string pageUrl = pageUrlLeaveOutPageNumber;
                if (WebUtils.ParseInt32FromQueryString("NewsId", -1) == -1 && config.LoadFirstItem)
                {
                    pageUrl = SiteUtils.GetCurrentZoneUrl();
                }

                if (pageUrl.Contains("?"))
                {
                    pageUrl += "&amp;pagenumber={0}";
                }
                else
                {
                    pageUrl += "?pagenumber={0}";
                }
                pgr.PageURLFormat = pageUrl;
                pgr.ShowFirstLast = true;
                pgr.PageSize      = config.PageSize;
                pgr.PageCount     = totalPages;
                pgr.CurrentIndex  = pageNumber;
                divPager.Visible  = (totalPages > 1);
            }

            if (WebUtils.ParseInt32FromQueryString("pagenumber", -1) == 1)
            {
                basePage.AdditionalMetaMarkup += "\n<link rel=\"canonical\" href=\"" + pageUrlLeaveOutPageNumber + "\" />";
            }

            #endregion

            XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("news", config.XsltFileNameDetailPage), doc);

            News.IncrementViewedCount(news.NewsID);
        }
Пример #20
0
        public static void SendApprovalRequestNotification(
            SmtpSettings smtpSettings,
            SiteSettings siteSettings,
            int workflowId,
            SiteUser submittingUser,
            News draftNews
            )
        {
            if (!draftNews.StateId.HasValue)
            {
                return;
            }

            WorkflowState workflowState = WorkflowHelper.GetWorkflowState(workflowId, draftNews.StateId.Value);

            if (workflowState == null || workflowState.StateId == -1)
            {
                return;
            }

            if (workflowState.ReviewRoles.Length == 0 ||
                workflowState.NotifyTemplate.Length == 0)                //"ApprovalRequestNotification"
            {
                return;
            }

            string approvalRoles = workflowState.ReviewRoles;

            gbSiteMapNode gbNode = SiteUtils.GetSiteMapNodeByZoneId(draftNews.ZoneID);

            if (gbNode != null)
            {
                List <string> authorizedRoles = gbNode.AuthorizedRoles.SplitOnCharAndTrim(';');
                List <string> reviewRoles     = workflowState.ReviewRoles.SplitOnCharAndTrim(';');

                if (authorizedRoles.Count > 0 && reviewRoles.Count > 0)
                {
                    approvalRoles = string.Empty;

                    foreach (string reviewRole in reviewRoles)
                    {
                        foreach (string role in authorizedRoles)
                        {
                            if (reviewRole.ToLower() == role.ToLower())
                            {
                                approvalRoles += reviewRole + ";";
                            }
                        }
                    }
                }
            }

            List <string> emailAddresses = SiteUser.GetEmailAddresses(siteSettings.SiteId, approvalRoles);

            int queuedMessageCount = 0;

            EmailTemplate template        = EmailTemplate.Get(siteSettings.SiteId, workflowState.NotifyTemplate);
            string        subject         = template.Subject.Replace("{SiteName}", siteSettings.SiteName);
            string        messageTemplate = template.HtmlBody;

            List <string> emailTo = (template.ToAddresses.Length > 0 ? ";" + template.ToAddresses : "").SplitOnCharAndTrim(';');

            string emailToAddress = string.Empty;

            foreach (string email in emailAddresses)
            {
                if (WebConfigSettings.EmailAddressesToExcludeFromAdminNotifications.IndexOf(email,
                                                                                            StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    continue;
                }
                if (!Email.IsValidEmailAddressSyntax(email))
                {
                    continue;
                }

                if (!emailToAddress.Contains(email + ";"))
                {
                    emailToAddress += email + ";";
                }
            }
            foreach (string email in emailTo)
            {
                if (WebConfigSettings.EmailAddressesToExcludeFromAdminNotifications.IndexOf(email,
                                                                                            StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    continue;
                }
                if (!Email.IsValidEmailAddressSyntax(email))
                {
                    continue;
                }

                if (!emailToAddress.Contains(email + ";"))
                {
                    emailToAddress += email + ";";
                }
            }

            string replyEmail = submittingUser.Email;

            if (template.ReplyToAddress.Length > 0)
            {
                replyEmail += ";" + template.ReplyToAddress;
            }

            string fromEmailAlias = (template.FromName.Length > 0 ? template.FromName : siteSettings.DefaultFromEmailAlias);

            StringBuilder message = new StringBuilder();

            message.Append(messageTemplate);
            message.Replace("{Title}", draftNews.Title);
            message.Replace("{SubmittedDate}", DateTimeHelper.GetLocalTimeString(draftNews.ApprovedUtc, SiteUtils.GetUserTimeZone(),
                                                                                 SiteUtils.GetUserTimeOffset()));
            message.Replace("{SubmittedBy}", submittingUser.Name);
            message.Replace("{ContentUrl}", NewsHelper.FormatNewsUrl(draftNews.Url, draftNews.NewsID, draftNews.ZoneID));

            EmailMessageTask messageTask = new EmailMessageTask(smtpSettings);

            messageTask.SiteGuid       = siteSettings.SiteGuid;
            messageTask.EmailFrom      = siteSettings.DefaultEmailFromAddress;
            messageTask.EmailFromAlias = fromEmailAlias;
            messageTask.EmailReplyTo   = replyEmail;
            messageTask.EmailTo        = emailToAddress;
            messageTask.EmailCc        = template.CcAddresses;
            messageTask.EmailBcc       = template.BccAddresses;
            messageTask.UseHtml        = true;
            messageTask.Subject        = subject;
            messageTask.HtmlBody       = message.ToString();
            messageTask.QueueTask();
            queuedMessageCount += 1;

            //Email.Send(
            //        smtpSettings,
            //        siteSettings.DefaultEmailFromAddress,
            //        siteSettings.DefaultFromEmailAlias,
            //        submittingUser.Email,
            //        email,
            //        string.Empty,
            //        string.Empty,
            //        messageSubject,
            //        message.ToString(),
            //        false,
            //        Email.PriorityNormal);

            WebTaskManager.StartOrResumeTasks();
        }
Пример #21
0
        public static XmlDocument BuildNewsDataXml(XmlDocument doc, XmlElement newsXml, News news, TimeZoneInfo timeZone,
                                                   double timeOffset, string editLink, int siteId = 1)
        {
            XmlHelper.AddNode(doc, newsXml, "Title", news.Title);
            XmlHelper.AddNode(doc, newsXml, "SubTitle", news.SubTitle);
            XmlHelper.AddNode(doc, newsXml, "Url", NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID));
            XmlHelper.AddNode(doc, newsXml, "Target", NewsHelper.GetNewsTarget(news.OpenInNewWindow));
            XmlHelper.AddNode(doc, newsXml, "ShowOption", news.ShowOption.ToString());
            XmlHelper.AddNode(doc, newsXml, "ZoneId", news.ZoneID.ToInvariantString());

            SiteMapDataSource siteMapDataSource = new SiteMapDataSource();

            siteMapDataSource.SiteMapProvider = "canhcamsite" + siteId.ToInvariantString();

            SiteMapNode rootNode     = siteMapDataSource.Provider.RootNode;
            SiteMapNode startingNode = null;

            if (rootNode == null)
            {
                return(null);
            }

            if (news.ZoneID > -1)
            {
                SiteMapNodeCollection allNodes = rootNode.GetAllNodes();
                foreach (SiteMapNode childNode in allNodes)
                {
                    gbSiteMapNode gbNode = childNode as gbSiteMapNode;
                    if (gbNode == null)
                    {
                        continue;
                    }

                    if (Convert.ToInt32(gbNode.Key) == news.ZoneID)
                    {
                        startingNode = gbNode;
                        XmlHelper.AddNode(doc, newsXml, "ZoneDescription", gbNode.Description);
                        XmlHelper.AddNode(doc, newsXml, "ZoneTitle", gbNode.Title);
                        break;
                    }
                }
            }

            string imageFolderPath          = NewsHelper.MediaFolderPath(news.SiteId, news.NewsID);
            string thumbnailImageFolderPath = imageFolderPath + "thumbs/";

            if (news.ImageFile.Length > 0)
            {
                XmlHelper.AddNode(doc, newsXml, "ImageUrl", VirtualPathUtility.ToAbsolute(imageFolderPath + news.ImageFile));
            }
            if (news.ThumbnailFile.Length > 0)
            {
                XmlHelper.AddNode(doc, newsXml, "ThumbnailUrl",
                                  VirtualPathUtility.ToAbsolute(thumbnailImageFolderPath + news.ThumbnailFile));
            }

            XmlHelper.AddNode(doc, newsXml, "EditLink", editLink);

            XmlHelper.AddNode(doc, newsXml, "BriefContent", news.BriefContent);
            XmlHelper.AddNode(doc, newsXml, "FullContent", news.FullContent);
            XmlHelper.AddNode(doc, newsXml, "ViewCount", news.Viewed.ToString());
            XmlHelper.AddNode(doc, newsXml, "CommentCount", news.CommentCount.ToString());
            XmlHelper.AddNode(doc, newsXml, "FileUrl", news.FileAttachment);

            object startDate = news.StartDate;

            XmlHelper.AddNode(doc, newsXml, "CreatedDate", FormatDate(startDate, timeZone, timeOffset,
                                                                      ResourceHelper.GetResourceString("NewsResources", "NewsDateFormat")));
            XmlHelper.AddNode(doc, newsXml, "CreatedTime", FormatDate(startDate, timeZone, timeOffset,
                                                                      ResourceHelper.GetResourceString("NewsResources", "NewsTimeFormat")));
            XmlHelper.AddNode(doc, newsXml, "CreatedDD", FormatDate(startDate, timeZone, timeOffset, "dd"));
            XmlHelper.AddNode(doc, newsXml, "CreatedYY", FormatDate(startDate, timeZone, timeOffset, "yy"));
            XmlHelper.AddNode(doc, newsXml, "CreatedYYYY", FormatDate(startDate, timeZone, timeOffset, "yyyy"));
            XmlHelper.AddNode(doc, newsXml, "CreatedMM", FormatDate(startDate, timeZone, timeOffset, "MM"));
            if (System.Globalization.CultureInfo.CurrentCulture.Name.ToLower() == "vi-vn")
            {
                string monthVI = "Tháng " + FormatDate(startDate, timeZone, timeOffset, "MM");
                XmlHelper.AddNode(doc, newsXml, "CreatedMMM", monthVI);
                XmlHelper.AddNode(doc, newsXml, "CreatedMMMM", monthVI);
            }
            else
            {
                XmlHelper.AddNode(doc, newsXml, "CreatedMMM", FormatDate(startDate, timeZone, timeOffset, "MMM"));
                XmlHelper.AddNode(doc, newsXml, "CreatedMMMM", FormatDate(startDate, timeZone, timeOffset, "MMMM"));
            }
            if (news.EndDate != null && news.EndDate != DateTime.MaxValue)
            {
                XmlHelper.AddNode(doc, newsXml, "EndDate", FormatDate(news.EndDate, timeZone, timeOffset,
                                                                      ResourceHelper.GetResourceString("NewsResources", "NewsDateFormat")));
            }

            return(doc);
        }
Пример #22
0
        public XmlDocument GetPageXml(int zoneId,
                                      int pageNumber,
                                      int pageSize,
                                      out int totalPages)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<NewsList></NewsList>");
            XmlElement root = doc.DocumentElement;

            XmlHelper.AddNode(doc, root, "ModuleTitle", this.moduleTitle);
            XmlHelper.AddNode(doc, root, "ZoneTitle", basePage.CurrentZone.Name);
            XmlHelper.AddNode(doc, root, "ZoneDescription", basePage.CurrentZone.Description);
            XmlHelper.AddNode(doc, root, "ViewMore", NewsResources.NewsMoreLinkText);
            XmlHelper.AddNode(doc, root, "SiteUrl", basePage.SiteRoot);        // add 2013-08-21 Hontam's project
            XmlHelper.AddNode(doc, root, "PageNumber", pageNumber.ToString()); // add 2014-10-25 RitaCorp's project
            if (module != null && module.ResourceFileDef.Length > 0 && module.ResourceKeyDef.Length > 0)
            {
                List <string> lstResourceKeys = module.ResourceKeyDef.SplitOnCharAndTrim(';');

                foreach (string item in lstResourceKeys)
                {
                    XmlHelper.AddNode(doc, root, item, ResourceHelper.GetResourceString(module.ResourceFileDef, item));
                }
            }

            int         languageId = WorkingCulture.LanguageId;
            List <News> lstNews    = new List <News>();

            if (basePage.ViewMode == PageViewMode.WorkInProgress &&
                WebConfigSettings.EnableContentWorkflow &&
                siteSettings.EnableContentWorkflow
                //&& userCanUpdate && basePage.UserCanAuthorizeZone(zoneId)
                )
            {
                Guid?userGuid = null;

                string stateIdList                     = string.Empty;
                int    workflowId                      = WorkflowHelper.GetWorkflowId(News.FeatureGuid);
                int    firstWorkflowStateId            = WorkflowHelper.GetFirstWorkflowStateId(workflowId);
                List <WorkflowState> lstWorkflowStates = WorkflowHelper.GetWorkflowStates(workflowId);
                foreach (WorkflowState wfState in lstWorkflowStates)
                {
                    if (WorkflowHelper.UserHasStatePermission(lstWorkflowStates, wfState.StateId))
                    {
                        if (wfState.StateId == firstWorkflowStateId)
                        {
                            userGuid = currentUser.UserGuid;
                        }
                        else
                        {
                            userGuid = null;
                        }

                        stateIdList += wfState.StateId + ";";
                    }
                }

                totalPages = 1;
                int totalRows = News.GetCountBySearch(siteSettings.SiteId, zoneId.ToString(), config.NewsType, -1, stateIdList, languageId, -1, -1, null, null, null, null, userGuid, string.Empty);

                if (pageSize > 0)
                {
                    totalPages = totalRows / pageSize;
                }

                if (totalRows <= pageSize)
                {
                    totalPages = 1;
                }
                else if (pageSize > 0)
                {
                    int remainder;
                    Math.DivRem(totalRows, pageSize, out remainder);
                    if (remainder > 0)
                    {
                        totalPages += 1;
                    }
                }

                lstNews = News.GetPageBySearch(siteSettings.SiteId, zoneId.ToString(), config.NewsType, -1, stateIdList, languageId, -1, -1, null, null, null, null, userGuid, string.Empty, pageNumber, pageSize);
            }
            else
            {
                if (config.ShowAllNews)
                {
                    string childZoneIds = NewsHelper.GetChildZoneIdToSemiColonSeparatedString(siteSettings.SiteId, zoneId);

                    totalPages = 1;
                    int totalRows = News.GetCountByListZone(siteSettings.SiteId, childZoneIds, config.NewsType, -1, languageId);

                    if (pageSize > 0)
                    {
                        totalPages = totalRows / pageSize;
                    }

                    if (totalRows <= pageSize)
                    {
                        totalPages = 1;
                    }
                    else if (pageSize > 0)
                    {
                        int remainder;
                        Math.DivRem(totalRows, pageSize, out remainder);
                        if (remainder > 0)
                        {
                            totalPages += 1;
                        }
                    }

                    lstNews = News.GetPageByListZone(siteSettings.SiteId, childZoneIds, config.NewsType, -1, languageId, pageNumber, pageSize);
                }
                else
                {
                    totalPages = 1;
                    int totalRows = News.GetCount(siteSettings.SiteId, zoneId, languageId, -1, -1);

                    if (pageSize > 0)
                    {
                        totalPages = totalRows / pageSize;
                    }

                    if (totalRows <= pageSize)
                    {
                        totalPages = 1;
                    }
                    else if (pageSize > 0)
                    {
                        int remainder;
                        Math.DivRem(totalRows, pageSize, out remainder);
                        if (remainder > 0)
                        {
                            totalPages += 1;
                        }
                    }

                    lstNews = News.GetPage(siteSettings.SiteId, zoneId, languageId, -1, -1, pageNumber, pageSize);
                }
            }

            int newsId = WebUtils.ParseInt32FromQueryString("NewsId", -1);

            foreach (News news in lstNews)
            {
                XmlElement newsXml = doc.CreateElement("News");
                root.AppendChild(newsXml);

                NewsHelper.BuildNewsDataXml(doc, newsXml, news, timeZone, timeOffset, NewsHelper.BuildEditLink(news, basePage, userCanUpdate, currentUser));

                XmlHelper.AddNode(doc, newsXml, "ApplyText", NewsResources.JobApplyLable);
                XmlHelper.AddNode(doc, newsXml, "ApplyUrl", this.SiteRoot + "/News/JobApplyDialog.aspx?zoneid=" + zoneId.ToString() + "&NewsID=" + news.NewsID.ToString());

                if (newsId > 0)
                {
                    if (news.NewsID == newsId)
                    {
                        XmlHelper.AddNode(doc, newsXml, "IsActive", "true");
                    }
                }

                if (config.ShowAllImagesInNewsList)
                {
                    BuildNewsImagesXml(doc, newsXml, news, languageId);
                }

                //2015-11-27
                if (config.ShowAttributesInNewsList)
                {
                    BuildNewsAttributesXml(doc, newsXml, news.NewsGuid, languageId);
                }
            }

            if (pageNumber < totalPages)
            {
                string pageUrl = SiteUtils.GetCurrentZoneUrl();

                if (pageUrl.Contains("?"))
                {
                    pageUrl += "&pagenumber=" + (pageNumber + 1).ToString();
                }
                else
                {
                    pageUrl += "?pagenumber=" + (pageNumber + 1).ToString();
                }

                XmlHelper.AddNode(doc, root, "NextPageUrl", pageUrl);
            }

            return(doc);
        }
Пример #23
0
        private void btnPostComment_Click(object sender, EventArgs e)
        {
            if (!ShouldAllowComments())
            {
                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }
            if (!IsValidComment())
            {
                //SetupInternalCommentSystem();
                PopulateControls();
                return;
            }
            if (news == null)
            {
                return;
            }

            if (news.AllowCommentsForDays < 0)
            {
                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }

            DateTime endDate = news.StartDate.AddDays((double)news.AllowCommentsForDays);

            if ((endDate < DateTime.UtcNow) && (news.AllowCommentsForDays > 0))
            {
                return;
            }

            if (this.chkRememberMe.Checked)
            {
                SetCookies();
            }

            News.AddNewsComment(
                news.NewsID,
                this.txtName.Text,
                this.txtCommentTitle.Text,
                this.txtURL.Text,
                edComment.Text,
                DateTime.UtcNow);

            if (config.NotifyOnComment)
            {
                //added this due to news coment spam and need to be able to ban the ip of the spammer
                StringBuilder message = new StringBuilder();
                message.Append(basePage.SiteRoot + news.Url.Replace("~", string.Empty));

                message.Append("\n\nHTTP_USER_AGENT: " + Page.Request.ServerVariables["HTTP_USER_AGENT"] + "\n");
                message.Append("HTTP_HOST: " + Page.Request.ServerVariables["HTTP_HOST"] + "\n");
                message.Append("REMOTE_HOST: " + Page.Request.ServerVariables["REMOTE_HOST"] + "\n");
                message.Append("REMOTE_ADDR: " + SiteUtils.GetIP4Address() + "\n");
                message.Append("LOCAL_ADDR: " + Page.Request.ServerVariables["LOCAL_ADDR"] + "\n");
                message.Append("HTTP_REFERER: " + Page.Request.ServerVariables["HTTP_REFERER"] + "\n");

                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

                if ((config.NotifyEmail.Length > 0) && (Email.IsValidEmailAddressSyntax(config.NotifyEmail)))
                {
                    EmailTemplate template = EmailTemplate.Get(siteSettings.SiteId, "NewsCommentNotification");

                    string fromAddress = siteSettings.DefaultEmailFromAddress;
                    string fromAlias   = template.FromName;
                    if (fromAlias.Length == 0)
                    {
                        fromAlias = siteSettings.DefaultFromEmailAlias;
                    }
                    string toEmail = config.NotifyEmail;
                    if (template.ToAddresses.Length > 0)
                    {
                        toEmail += ";" + template.ToAddresses;
                    }

                    NewsHelper.SendCommentNotification(
                        SiteUtils.GetSmtpSettings(),
                        siteSettings.SiteGuid,
                        fromAddress,
                        fromAlias,
                        toEmail,
                        template.ReplyToAddress,
                        template.CcAddresses,
                        template.BccAddresses,
                        template.Subject,
                        template.HtmlBody,
                        siteSettings.SiteName,
                        message.ToString());
                }

                if (config.NotifyEmail != news.UserEmail)
                {
                    EmailTemplate template = EmailTemplate.Get(siteSettings.SiteId, "NewsCommentNotification");

                    string fromAddress = siteSettings.DefaultEmailFromAddress;
                    string fromAlias   = template.FromName;
                    if (fromAlias.Length == 0)
                    {
                        fromAlias = siteSettings.DefaultFromEmailAlias;
                    }
                    string toEmail = news.UserEmail;
                    if (template.ToAddresses.Length > 0)
                    {
                        toEmail += ";" + template.ToAddresses;
                    }

                    NewsHelper.SendCommentNotification(
                        SiteUtils.GetSmtpSettings(),
                        siteSettings.SiteGuid,
                        fromAddress,
                        fromAlias,
                        toEmail,
                        template.ReplyToAddress,
                        template.CcAddresses,
                        template.BccAddresses,
                        template.Subject,
                        template.HtmlBody,
                        siteSettings.SiteName,
                        message.ToString());
                }
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Пример #24
0
        private void SetupMetaTags()
        {
            string title = news.Title;

            if (news.MetaTitle.Length > 0)
            {
                basePage.Title = news.MetaTitle;
                title          = news.MetaTitle;
            }
            else
            {
                basePage.Title = SiteUtils.FormatPageTitle(basePage.SiteInfo, news.Title);
            }

            if (news.MetaKeywords.Length > 0)
            {
                basePage.MetaKeywordCsv = news.MetaKeywords;
            }
            else if (basePage.SiteInfo.MetaKeyWords.Length > 0)
            {
                basePage.MetaKeywordCsv = basePage.SiteInfo.GetMetaKeyWords(WorkingCulture.LanguageId);
            }

            if (news.MetaDescription.Length > 0)
            {
                basePage.MetaDescription = news.MetaDescription;
            }
            else if (news.BriefContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(news.BriefContent, 156);
            }
            else if (news.FullContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(news.FullContent, 156);
            }

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:title\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:url\" content=\"" + NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID) + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:site_name\" content=\"" + basePage.SiteInfo.SiteName + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:type\" content=\"article\" />";

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"name\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            ZoneSettings currentZone = CacheHelper.GetCurrentZone();

            if (basePage.SiteInfo.MetaAdditional.Length > 0)
            {
                basePage.AdditionalMetaMarkup = basePage.SiteInfo.MetaAdditional;
            }
            if (currentZone.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += currentZone.AdditionalMetaTags;
            }
            if (news.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += news.AdditionalMetaTags;
            }
        }
Пример #25
0
        public void BuildNewsOtherXml(
            XmlDocument doc,
            XmlElement root,
            int zoneId,
            int pageNumber,
            int pageSize,
            out int totalPages)
        {
            XmlHelper.AddNode(doc, root, "NewsOtherText", NewsResources.OtherNewsLabel);
            XmlHelper.AddNode(doc, root, "ProductOtherText", NewsResources.OtherProductLabel);
            XmlHelper.AddNode(doc, root, "ProjectOtherText", NewsResources.OtherProjectLabel);

            List <News> lstNews = new List <News>();

            if (pageSize < 0)
            {
                pageSize   = -pageSize;
                totalPages = 1;
                int totalRows = News.GetCount(basePage.SiteId, zoneId, languageId, -1, -1);

                if (pageSize > 0)
                {
                    totalPages = totalRows / pageSize;
                }

                if (totalRows <= pageSize)
                {
                    totalPages = 1;
                }
                else if (pageSize > 0)
                {
                    int remainder;
                    Math.DivRem(totalRows, pageSize, out remainder);
                    if (remainder > 0)
                    {
                        totalPages += 1;
                    }
                }

                lstNews = News.GetPage(basePage.SiteId, zoneId, languageId, -1, -1, pageNumber, pageSize);
            }
            else
            {
                lstNews = News.GetPageNewsOther(zoneId, news.NewsID, languageId, config.NewsType, pageNumber, pageSize, out totalPages);
            }

            foreach (News news in lstNews)
            {
                XmlElement newsXml = doc.CreateElement("NewsOther");
                root.AppendChild(newsXml);

                NewsHelper.BuildNewsDataXml(doc, newsXml, news, timeZone, timeOffset, NewsHelper.BuildEditLink(news, basePage, userCanUpdate, currentUser));

                if (news.NewsID == newsId)
                {
                    XmlHelper.AddNode(doc, newsXml, "IsActive", "true");
                }
            }

            if (pageNumber < totalPages)
            {
                string pageUrl = NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID);

                int iNewsId = WebUtils.ParseInt32FromQueryString("NewsId", -1);
                if (iNewsId == -1 && config.LoadFirstItem)
                {
                    pageUrl = SiteUtils.GetCurrentZoneUrl();
                }

                if (pageUrl.Contains("?"))
                {
                    pageUrl += "&pagenumber=" + (pageNumber + 1).ToString();
                }
                else
                {
                    pageUrl += "?pagenumber=" + (pageNumber + 1).ToString();
                }

                XmlHelper.AddNode(doc, root, "NextPageUrl", pageUrl);
            }
        }
Пример #26
0
        private string RenderEmailSubject()
        {
            SetupEmailSubjectScript();

            return(string.Format("<a href='{0}' class='email-link' target='_blank' title='{1}' rel='nofollow'><span>{2}</span></a>",
                                 siteRoot + "/News/EmailSubjectDialog.aspx?u=" + Context.Server.HtmlEncode(NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID)),
                                 NewsResources.NewsEmailLink,
                                 NewsResources.NewsEmailLink));
        }
Пример #27
0
        private void DoSearch()
        {
            if (Page.IsPostBack)
            {
                return;
            }

            if (Request.QueryString.Get("q") == null)
            {
                return;
            }

            query = Request.QueryString.Get("q");

            if (this.query.Length == 0)
            {
                return;
            }

            //txtSearchInput.Text = Server.HtmlEncode(query).Replace("&quot;", "\"") ;
            txtSearchInput.Text = SecurityHelper.SanitizeHtml(query);
            if (WebConfigSettings.EscapingSpecialCharactersInKeyword)
            {
                query = query.Replace("-", "\\-");
            }

            queryErrorOccurred = false;

            CanhCam.SearchIndex.IndexItemCollection searchResults = CanhCam.SearchIndex.IndexHelper.Search(
                siteSettings.SiteId,
                isSiteEditor,
                GetUserRoles(),
                News.FeatureGuid,
                CultureInfo.CurrentUICulture.Name,
                DateTime.MinValue,
                DateTime.MaxValue,
                query,
                WebConfigSettings.EnableSearchResultsHighlighting,
                WebConfigSettings.SearchResultsFragmentSize,
                pageNumber,
                pageSize,
                WebConfigSettings.SearchMaxClauseCount,
                out totalHits,
                out queryErrorOccurred);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<NewsList></NewsList>");
            XmlElement root = doc.DocumentElement;

            XmlHelper.AddNode(doc, root, "SiteRoot", SiteRoot);
            XmlHelper.AddNode(doc, root, "TotalNews", totalHits.ToString());
            XmlHelper.AddNode(doc, root, "Keyword", Server.HtmlEncode(query));
            XmlHelper.AddNode(doc, root, "ProductText", ResourceHelper.GetResourceString("ProductResources", "ProductFeatureName"));
            XmlHelper.AddNode(doc, root, "NewsText", ResourceHelper.GetResourceString("NewsResources", "NewsFeatureName"));

            if (searchResults.Count == 0)
            {
                if (InitIndexIfNeeded())
                {
                    return;
                }

                if (txtSearchInput.Text.Length > 0)
                {
                    string noResults = Resources.NewsResources.SearchResultsNotFound;
                    if (queryErrorOccurred)
                    {
                        noResults = ResourceHelper.GetResourceString("Resource", "SearchQueryInvalid");
                    }

                    XmlHelper.AddNode(doc, root, "NoResults", noResults);
                }
            }
            else
            {
                float  duration     = searchResults.ExecutionTime * 0.0000001F;
                string searchSumary = string.Format(Resources.NewsResources.SearchResultsFormat, totalHits.ToString(CultureInfo.InvariantCulture), Server.HtmlEncode(query), duration.ToString());

                XmlHelper.AddNode(doc, root, "SearchSumary", searchSumary);
                XmlHelper.AddNode(doc, root, "Duration", duration.ToString());

                totalPages = 1;

                if (pageSize > 0)
                {
                    totalPages = totalHits / pageSize;
                }

                if (totalHits <= pageSize)
                {
                    totalPages = 1;
                }
                else
                {
                    int remainder;
                    Math.DivRem(totalHits, pageSize, out remainder);
                    if (remainder > 0)
                    {
                        totalPages += 1;
                    }
                }

                string searchUrl = SiteRoot
                                   + "/News/SearchResults.aspx?q=" + Server.UrlEncode(query)
                                   + "&amp;p={0}";

                pgrTop.PageURLFormat = searchUrl;
                pgrTop.ShowFirstLast = true;
                pgrTop.CurrentIndex  = pageNumber;
                pgrTop.PageSize      = pageSize;
                pgrTop.PageCount     = totalPages;
                pgrTop.Visible       = (totalPages > 1);

                pgrBottom.PageURLFormat = searchUrl;
                pgrBottom.ShowFirstLast = true;
                pgrBottom.CurrentIndex  = pageNumber;
                pgrBottom.PageSize      = pageSize;
                pgrBottom.PageCount     = totalPages;
                pgrBottom.Visible       = (totalPages > 1);

                string newsGuids = string.Empty;
                string sepa      = string.Empty;
                foreach (IndexItem item in searchResults)
                {
                    if (!newsGuids.ContainsCaseInsensitive(item.ItemGuid.ToString()))
                    {
                        newsGuids += sepa + item.ItemGuid.ToString();
                        sepa       = ";";
                    }
                }

                if (newsGuids.Length > 0)
                {
                    List <News> lstNews = News.GetByGuids(siteSettings.SiteId, newsGuids, 1, WorkingCulture.LanguageId);
                    foreach (News news in lstNews)
                    {
                        XmlElement newsXml = doc.CreateElement("News");
                        root.AppendChild(newsXml);

                        NewsHelper.BuildNewsDataXml(doc, newsXml, news, timeZone, timeOffset, string.Empty);

                        if (WebConfigSettings.EnableSearchResultsHighlighting)
                        {
                            foreach (IndexItem item in searchResults)
                            {
                                if (item.ItemGuid == news.NewsGuid)
                                {
                                    XmlHelper.AddNode(doc, newsXml, "HighlightContent", item.Intro);

                                    break;
                                }
                            }
                        }
                    }
                }
            }

            XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("news", "NewsSearchResults.xslt"), doc);
        }
Пример #28
0
        protected string GetAttachFile(int newsID, object attachFile1, object attachFile2)
        {
            string attachFile = string.Empty;

            if (attachFile1 != null && attachFile1.ToString().Length > 0)
            {
                attachFile += string.Format("<a class='cp-link' target='_blank' href='{0}'>{1}</a>", Page.ResolveUrl(NewsHelper.AttachmentsPath(siteSettings.SiteId, newsId)) + attachFile1, attachFile1);
            }
            if (attachFile2 != null && attachFile1.ToString().Length > 0)
            {
                if (!string.IsNullOrEmpty(attachFile))
                {
                    attachFile += "<br />";
                }
                attachFile += string.Format("<a class='cp-link' target='_blank' href='{0}'>{1}</a>", Page.ResolveUrl(NewsHelper.AttachmentsPath(siteSettings.SiteId, newsId)) + attachFile2, attachFile2);
            }

            return(attachFile);
        }
Пример #29
0
        private void PopulateControls()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<NewsList></NewsList>");
            XmlElement root = doc.DocumentElement;

            XmlHelper.AddNode(doc, root, "ModuleTitle", this.Title);
            XmlHelper.AddNode(doc, root, "ZoneTitle", CurrentZone.Name);
            XmlHelper.AddNode(doc, root, "ViewMore", NewsResources.NewsMoreLinkText);

            if (ModuleConfiguration.ResourceFileDef.Length > 0 && ModuleConfiguration.ResourceKeyDef.Length > 0)
            {
                List <string> lstResourceKeys = ModuleConfiguration.ResourceKeyDef.SplitOnCharAndTrim(';');

                foreach (string item in lstResourceKeys)
                {
                    XmlHelper.AddNode(doc, root, item, ResourceHelper.GetResourceString(ModuleConfiguration.ResourceFileDef, item));
                }
            }

            CmsBasePage basePage      = Page as CmsBasePage;
            bool        userCanUpdate = NewsPermission.CanUpdate;
            SiteUser    currentUser   = SiteUtils.GetCurrentSiteUser();

            List <News> lstNews    = new List <News>();
            int         languageId = WorkingCulture.LanguageId;

            if (config.ZoneId > -1 || config.ZoneIds.Length > 0 || config.SortBy > 0)
            {
                string zoneRangeIds = string.Empty;

                if (config.ZoneIds.Length > 0)
                {
                    zoneRangeIds = config.ZoneIds;
                }
                else
                {
                    int zoneId = config.ZoneId;
                    if (zoneId == 0)
                    {
                        zoneId = CurrentZone.ZoneId;
                    }

                    zoneRangeIds = NewsHelper.GetChildZoneIdToSemiColonSeparatedString(siteSettings.SiteId, zoneId);
                }

                lstNews = News.GetPageBySearch2(1, config.MaxItemsToGet, siteSettings.SiteId, zoneRangeIds, 1, languageId, config.NewsType, config.Position, -1, null, null, null, null, null, null, null, config.SortBy);
            }
            else
            {
                lstNews = News.GetPage(SiteId, -1, languageId, config.NewsType, config.Position, 1, config.MaxItemsToGet);
            }

            foreach (News news in lstNews)
            {
                XmlElement newsXml = doc.CreateElement("News");
                root.AppendChild(newsXml);

                NewsHelper.BuildNewsDataXml(doc, newsXml, news, timeZone, timeOffset, NewsHelper.BuildEditLink(news, basePage, userCanUpdate, currentUser));

                if (config.ShowAllImagesInNewsList)
                {
                    BuildNewsImagesXml(doc, newsXml, news, languageId);
                }
            }

            XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("news", ModuleConfiguration.XsltFileName), doc);
        }
Пример #30
0
        private void RenderNode(XmlDocument doc, XmlElement xmlElement, gbSiteMapNode gbNode)
        {
            if (!ShouldRender(gbNode))
            {
                return;
            }

            XmlElement item = doc.CreateElement("Zone");

            xmlElement.AppendChild(item);

            XmlHelper.AddNode(doc, item, "ZoneId", gbNode.ZoneId.ToInvariantString());
            XmlHelper.AddNode(doc, item, "Depth", gbNode.Depth.ToInvariantString());
            XmlHelper.AddNode(doc, item, "ChildCount", gbNode.ChildNodes.Count.ToInvariantString());
            XmlHelper.AddNode(doc, item, "IsClickable", gbNode.IsClickable.ToString().ToLower());
            XmlHelper.AddNode(doc, item, "Url", FormatUrl(gbNode));
            XmlHelper.AddNode(doc, item, "Target", (gbNode.OpenInNewWindow == true ? "_blank" : "_self"));
            XmlHelper.AddNode(doc, item, "Title", GetZoneTitle(gbNode));
            XmlHelper.AddNode(doc, item, "Description", GetDescription(gbNode));
            XmlHelper.AddNode(doc, item, "ImageUrl", gbNode.PrimaryImage);
            XmlHelper.AddNode(doc, item, "SecondImageUrl", gbNode.SecondImage);

            List <News> lstNews = new List <News>();

            if (config.ShowAllNews)
            {
                string zoneIds = NewsHelper.GetChildZoneIdToSemiColonSeparatedString(siteSettings.SiteId, gbNode.ZoneId);
                if (config.MaxItemsToGet == 0)
                {
                    int iCount = News.GetCountByListZone(siteSettings.SiteId, zoneIds, -1, config.NewsPosition, languageId);
                    XmlHelper.AddNode(doc, item, "NewsCount", iCount.ToString());
                }
                else if (config.MaxItemsToGet > 0)
                {
                    lstNews = News.GetPageByListZone(siteSettings.SiteId, zoneIds, -1, config.NewsPosition, languageId, 1, config.MaxItemsToGet);
                }
                else
                {
                    int iCount = News.GetCountByListZone(siteSettings.SiteId, zoneIds, -1, config.NewsPosition, languageId);
                    XmlHelper.AddNode(doc, item, "NewsCount", iCount.ToString());

                    lstNews = News.GetPageByListZone(siteSettings.SiteId, zoneIds, -1, config.NewsPosition, languageId, 1, Math.Abs(config.MaxItemsToGet));
                }
            }
            else
            {
                if (config.MaxItemsToGet == 0)
                {
                    int iCount = News.GetCount(siteSettings.SiteId, gbNode.ZoneId, -1, config.NewsPosition, languageId);
                    XmlHelper.AddNode(doc, item, "NewsCount", iCount.ToString());
                }
                else if (config.MaxItemsToGet > 0)
                {
                    lstNews = News.GetPage(siteSettings.SiteId, gbNode.ZoneId, languageId, -1, config.NewsPosition, 1, config.MaxItemsToGet);
                }
                else
                {
                    int iCount = News.GetCount(siteSettings.SiteId, gbNode.ZoneId, -1, config.NewsPosition, languageId);
                    XmlHelper.AddNode(doc, item, "NewsCount", iCount.ToString());

                    lstNews = News.GetPage(siteSettings.SiteId, gbNode.ZoneId, languageId, -1, config.NewsPosition, 1, Math.Abs(config.MaxItemsToGet));
                }
            }

            foreach (News news in lstNews)
            {
                XmlElement newsXml = doc.CreateElement("News");
                item.AppendChild(newsXml);

                NewsHelper.BuildNewsDataXml(doc, newsXml, news, timeZone, timeOffset, NewsHelper.BuildEditLink(news, basePage, userCanUpdate, currentUser));

                if (news.NewsID == newsId)
                {
                    XmlHelper.AddNode(doc, newsXml, "IsActive", "true");
                }

                if (config.ShowAllImagesInNewsList)
                {
                    BuildNewsImagesXml(doc, newsXml, news, languageId);
                }
            }

            if ((currentNode != null) &&
                (currentNode.ZoneGuid == gbNode.ZoneGuid)    // Selected
                )
            {
                XmlHelper.AddNode(doc, item, "IsActive", "true");
            }
            else
            {
                XmlHelper.AddNode(doc, item, "IsActive", "false");
            }

            if (gbNode.ChildNodes.Count > 0)
            {
                foreach (SiteMapNode childNode in gbNode.ChildNodes)
                {
                    gbSiteMapNode gbChildNode = childNode as gbSiteMapNode;
                    if (gbChildNode == null)
                    {
                        continue;
                    }

                    RenderNode(doc, item, gbChildNode);
                }
            }
        }