예제 #1
0
 public JournalItemTokenReplace(JournalItem journalItem, JournalControl journalControl)
 {
     PropertySource["journalitem"]    = journalItem;
     PropertySource["journalcontrol"] = journalControl;
     if (journalItem.ItemData != null)
     {
         PropertySource["journaldata"] = journalItem.ItemData;
     }
     if (journalItem.JournalAuthor != null)
     {
         PropertySource["journalauthor"] = journalItem.JournalAuthor;
     }
 }
예제 #2
0
 public JournalItemTokenReplace(JournalItem journalItem, JournalControl journalControl)
 {
     PropertySource["journalitem"]    = journalItem;
     PropertySource["journalcontrol"] = journalControl;
     if (journalItem.ItemData != null)
     {
         PropertySource["journaldata"] = journalItem.ItemData;
     }
     if (journalItem.JournalAuthor != null)
     {
         PropertySource["journalauthor"]  = journalItem.JournalAuthor;
         PropertySource["journalprofile"] = new ProfilePicPropertyAccess(journalItem.JournalAuthor.Id);
     }
 }
        public JournalItemTokenReplace(JournalItem journalItem, JournalControl journalControl) {
            PropertySource["journalitem"] = journalItem;
            PropertySource["journalcontrol"] = journalControl;
            if (journalItem.ItemData != null) {
                PropertySource["journaldata"] = journalItem.ItemData;
            }
            if (journalItem.JournalAuthor != null) {
                PropertySource["journalauthor"] = journalItem.JournalAuthor;
            }
           
            
            

        }
예제 #4
0
		public string GetList(int currentIndex, int rows) 
        {
            if (CurrentUser.UserID > 0) {
                isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName);
            }
		    isUnverifiedUser = !CurrentUser.IsSuperUser && CurrentUser.IsInRole("Unverified Users");

			var journalControllerInternal = InternalJournalController.Instance;
			var sb = new StringBuilder();		

            string statusTemplate = Localization.GetString("journal_status", ResxPath);
            string linkTemplate = Localization.GetString("journal_link", ResxPath);
            string photoTemplate = Localization.GetString("journal_photo", ResxPath);
            string fileTemplate = Localization.GetString("journal_file", ResxPath);

		    statusTemplate = Regex.Replace(statusTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            linkTemplate = Regex.Replace(linkTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            photoTemplate = Regex.Replace(photoTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            fileTemplate = Regex.Replace(fileTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);

            string comment = Localization.GetString("comment", ResxPath);
            
            IList<JournalItem> journalList;
            if (ProfileId > 0) {
                journalList = journalControllerInternal.GetJournalItemsByProfile(OwnerPortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows);
            } else if (SocialGroupId > 0) {
                journalList = journalControllerInternal.GetJournalItemsByGroup(OwnerPortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows);
            } else {
                journalList = journalControllerInternal.GetJournalItems(OwnerPortalId, ModuleId, CurrentUser.UserID, currentIndex, rows);
            }

            var journalIds = journalList.Select(ji => ji.JournalId).ToList();
            IList<CommentInfo> comments = JournalController.Instance.GetCommentsByJournalIds(journalIds);

			foreach (JournalItem ji in journalList) {
                const string pattern = "{CanComment}(.*?){/CanComment}";
			    string replacement = GetStringReplacement(ji);

			    string rowTemplate;
			    if (ji.JournalType == "status") {
                    rowTemplate = statusTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                } else if (ji.JournalType == "link") {
                    rowTemplate = linkTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                } else if (ji.JournalType == "photo") {
                    rowTemplate = photoTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                } else if (ji.JournalType == "file") {
                    rowTemplate = fileTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                } else {
                    rowTemplate = GetJournalTemplate(ji.JournalType, ji);
                }
                
				var ctl = new JournalControl();
				
                bool isLiked = false;
                ctl.LikeList = GetLikeListHTML(ji, ref isLiked);
                ctl.LikeLink = String.Empty;
                ctl.CommentLink = String.Empty;
                
                ctl.AuthorNameLink = "<a href=\"" + Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] {"userId=" + ji.JournalAuthor.Id}) + "\">" + ji.JournalAuthor.Name + "</a>";
                if (CurrentUser.UserID > 0 &&  !isUnverifiedUser) 
                {
                    if (!ji.CommentsDisabled)
                    {
                        ctl.CommentLink = "<a href=\"#\" id=\"cmtbtn-" + ji.JournalId + "\">" + comment + "</a>";
                    }

                    if (isLiked) 
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:unlike}</a>";
                    } 
                    else 
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:like}</a>";
                    }
                }
                
                ctl.CommentArea = GetCommentAreaHTML(ji.JournalId, comments, ji.CommentsHidden, ji.CommentsDisabled);
				ji.TimeFrame = DateUtils.CalculateDateForDisplay(ji.DateCreated);
                ji.DateCreated = CurrentUser.LocalTime(ji.DateCreated);
 
                if (ji.Summary != null)
                {
                    ji.Summary = ji.Summary.Replace("\n", "<br />");
                }
                
                if (ji.Body != null)
                {
                    ji.Body = ji.Body.Replace(Environment.NewLine, "<br />");
                }

				var tokenReplace = new JournalItemTokenReplace(ji, ctl);
				string tmp = tokenReplace.ReplaceJournalItemTokens(rowTemplate);
                tmp = tmp.Replace("<br>", "<br />");
                sb.Append("<div class=\"journalrow\" id=\"jid-" + ji.JournalId + "\">");
                if (isAdmin || CurrentUser.UserID == ji.UserId) {
                    sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>");
                }
				sb.Append(tmp);
				sb.Append("</div>");
			}
          
			return Utilities.LocalizeControl(sb.ToString());
		}
예제 #5
0
        public string GetList(int currentIndex, int rows)
        {
            if (CurrentUser.UserID > 0)
            {
                isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName);
            }
            isUnverifiedUser = !CurrentUser.IsSuperUser && CurrentUser.IsInRole("Unverified Users");

            var journalControllerInternal = InternalJournalController.Instance;
            var sb = new StringBuilder();

            string statusTemplate = Localization.GetString("journal_status", ResxPath);
            string linkTemplate   = Localization.GetString("journal_link", ResxPath);
            string photoTemplate  = Localization.GetString("journal_photo", ResxPath);
            string fileTemplate   = Localization.GetString("journal_file", ResxPath);

            statusTemplate = Regex.Replace(statusTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            linkTemplate   = Regex.Replace(linkTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            photoTemplate  = Regex.Replace(photoTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);
            fileTemplate   = Regex.Replace(fileTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase);

            string comment = Localization.GetString("comment", ResxPath);

            IList <JournalItem> journalList;

            if (ProfileId > 0)
            {
                journalList = journalControllerInternal.GetJournalItemsByProfile(OwnerPortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows);
            }
            else if (SocialGroupId > 0)
            {
                journalList = journalControllerInternal.GetJournalItemsByGroup(OwnerPortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows);
            }
            else
            {
                journalList = journalControllerInternal.GetJournalItems(OwnerPortalId, ModuleId, CurrentUser.UserID, currentIndex, rows);
            }

            var journalIds = journalList.Select(ji => ji.JournalId).ToList();
            IList <CommentInfo> comments = JournalController.Instance.GetCommentsByJournalIds(journalIds);

            foreach (JournalItem ji in journalList)
            {
                const string pattern     = "{CanComment}(.*?){/CanComment}";
                string       replacement = GetStringReplacement(ji);

                string rowTemplate;
                if (ji.JournalType == "status")
                {
                    rowTemplate = statusTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                }
                else if (ji.JournalType == "link")
                {
                    rowTemplate = linkTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                }
                else if (ji.JournalType == "photo")
                {
                    rowTemplate = photoTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                }
                else if (ji.JournalType == "file")
                {
                    rowTemplate = fileTemplate;
                    rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase);
                }
                else
                {
                    rowTemplate = GetJournalTemplate(ji.JournalType, ji);
                }

                var ctl = new JournalControl();

                bool isLiked = false;
                ctl.LikeList    = GetLikeListHTML(ji, ref isLiked);
                ctl.LikeLink    = String.Empty;
                ctl.CommentLink = String.Empty;

                ctl.AuthorNameLink = "<a href=\"" + Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + ji.JournalAuthor.Id }) + "\">" + ji.JournalAuthor.Name + "</a>";
                if (CurrentUser.UserID > 0 && !isUnverifiedUser)
                {
                    if (!ji.CommentsDisabled)
                    {
                        ctl.CommentLink = "<a href=\"#\" id=\"cmtbtn-" + ji.JournalId + "\">" + comment + "</a>";
                    }

                    if (isLiked)
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:unlike}</a>";
                    }
                    else
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:like}</a>";
                    }
                }

                ctl.CommentArea = GetCommentAreaHTML(ji, comments);
                ji.TimeFrame    = DateUtils.CalculateDateForDisplay(ji.DateCreated);
                ji.DateCreated  = CurrentUser.LocalTime(ji.DateCreated);

                if (ji.Summary != null)
                {
                    ji.Summary = ji.Summary.Replace("\n", "<br />");
                }

                if (ji.Body != null)
                {
                    ji.Body = ji.Body.Replace(Environment.NewLine, "<br />");
                }

                var    tokenReplace = new JournalItemTokenReplace(ji, ctl);
                string tmp          = tokenReplace.ReplaceJournalItemTokens(rowTemplate);
                tmp = tmp.Replace("<br>", "<br />");
                sb.Append("<div class=\"journalrow\" id=\"jid-" + ji.JournalId + "\">");
                if (isAdmin || CurrentUser.UserID == ji.UserId || (ProfileId > Null.NullInteger && CurrentUser.UserID == ProfileId))
                {
                    sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>");
                }
                sb.Append(tmp);
                sb.Append("</div>");
            }

            return(Utilities.LocalizeControl(sb.ToString()));
        }