/// <summary> /// 更新主题浏览量 /// </summary> /// <param name="tid">主题id</param> /// <param name="viewcount">浏览量</param> /// <returns>成功返回1,否则返回0</returns> public static int UpdateTopicViewCount(int tid, int viewcount) { if (Topics.appDBCache && Topics.ITopicService != null) { Discuz.Entity.TopicInfo topicInfo = Topics.ITopicService.GetTopicInfo(tid, 0, 0); if (topicInfo != null) { topicInfo.Views = topicInfo.Views + viewcount; Topics.ITopicService.UpdateTopic(topicInfo); } } return(DatabaseProvider.GetInstance().UpdateTopicViewCount(tid, viewcount)); }
/// <summary> /// 根据参数信息选择相应的模板 /// </summary> /// <param name="strTemplateid">默认的模板ID</param> /// <param name="pagename">请求的页面名称</param> /// <param name="newUrl">请求参数</param> /// <returns>返回相应的模板ID</returns> public string SelectTemplate(string strTemplateid, string pagename, string newUrl) { string pagenamelist = "showforum,showtopic,showdebate,showbonus,posttopic,postreply,showtree,editpost,delpost,topicadmin"; int forumid = 0; //要截取的字段串的开始位置 int startindex = pagename.LastIndexOf("/") + 1; //如果是指定的页面则进行模板查询 int length = pagename.LastIndexOf(".") - startindex; if (length > 0 && Utils.InArray(pagename.Substring(startindex, length), pagenamelist)) { foreach (string urlvalue in newUrl.Split('&')) { if ((urlvalue.IndexOf("forumid=") >= 0) && (urlvalue.Split('=')[1] != "")) { forumid = Utils.StrToInt(urlvalue.Split('=')[1], 0); } else { if ((urlvalue.IndexOf("topicid=") >= 0) && (urlvalue.Split('=')[1] != "")) { Discuz.Entity.TopicInfo topicinfo = Topics.GetTopicInfo(Utils.StrToInt(urlvalue.Split('=')[1], 0)); //主题存在时 if (topicinfo != null) { forumid = topicinfo.Fid; } } else { forumid = DNTRequest.GetInt("forumid", 0); } } if (forumid > 0) { Entity.ForumInfo forumInfo = Forums.GetForumInfo(forumid); int templateid = forumInfo == null ? 0 : forumInfo.Templateid; //当前版块未指定模板时(使用用户选择的模版或系统默认模板) if (templateid <= 0) { //从cookie中获取用户选择的模板 if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList())) { templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), GeneralConfigs.GetConfig().Templateid); } //使用系统默认模板 if (templateid == 0) { templateid = GeneralConfigs.GetConfig().Templateid; } } strTemplateid = templateid.ToString(); break; } } } return(strTemplateid); }