Ejemplo n.º 1
0
		public override string OnMouduleLoad(string content)
		{
			UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
			int topiccount = Utils.StrToInt(userprefs.GetValueByName("topiccount"), 10);
			bool iselite = Utils.StrToInt(userprefs.GetValueByName("iselite"), 0) > 0;

			DataTable topics = Focuses.GetTopicList(topiccount, 0, 0, TopicTimeType.All, TopicOrderType.ID, iselite, 30, false);
			StringBuilder sb = new StringBuilder(StaticFileProvider.GetContent(jsFile).Replace("${forumpath}", BaseConfigs.GetForumPath).Replace("${themepath}", this.SpaceConfig.ThemePath));
            GeneralConfigInfo config = GeneralConfigs.GetConfig();
            sb.Append("\r\n<div class='dnt-theme'><ul>\r\n");
			foreach (DataRow r in topics.Rows)
			{
                string img = string.Format("<img onerror='this.src=\"{0}space/modules/builtin/forum/images/item_extend.gif\";' src='{0}space/skins/themes/{1}/images/item_extend.gif' id='imgButton_{2}' onclick='showtree({2},10);' title='展开' alt='展开' style='cursor:pointer;'/>", BaseConfigs.GetForumPath, this.SpaceConfig.ThemePath, r["tid"]);
				if (Utils.StrToInt(r["replies"], 0) < 1)
                    img = string.Format("<img onerror='this.src=\"{0}space/modules/builtin/forum/images/item_collapsed.gif\";' src='{0}space/skins/themes/{1}/images/item_collapsed.gif' />", BaseConfigs.GetForumPath, this.SpaceConfig.ThemePath);

                if (config.Aspxrewrite == 1)
                    sb.AppendFormat("<li>{0}<a href='" + BaseConfigs.GetForumPath + "showtopic-{1}.aspx' title='{2}' target='_blank'>{2}</a></li>", img, r["tid"], r["title"]);
                else
                    sb.AppendFormat("<li>{0}<a href='" + BaseConfigs.GetForumPath + "showtopic.aspx?topicid={1}' title='{2}' target='_blank'>{2}</a></li>", img, r["tid"], r["title"]);

                sb.AppendFormat("<div id='divTopic{0}'></div>", r["tid"]);
			}
            sb.Append("\r\n</ul></div>\r\n");
			content = sb.ToString();
			return base.OnMouduleLoad (content);
		}
Ejemplo n.º 2
0
        /// <summary>
        /// 自定义编辑设置框内容
        /// </summary>
        /// <param name="editbox">编辑框原内容</param>
        /// <returns></returns>
        public override string OnEditBoxLoad(string editbox)
        {
            if (GeneralConfigs.GetConfig().Enablealbum != 1)
            {
                this.Editable = false;
                return "";
            }
            this.Editable = true;
            UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
            editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";

            //显示的相册Id,0为全部相册
            string value = userprefs.GetValueByName("albumid");
            value = value == string.Empty ? "0" : value;
            int albumid = Utils.StrToInt(value, 0);
            List<AlbumInfo> albumlist = DTOProvider.GetSpaceAlbumList(this.Module.Uid, 0, Utils.StrToInt(AlbumConfigs.GetConfig().MaxAlbumCount, 0), 1);
            string options = string.Empty;

            if (albumid == 0)
                options += "<option value=\"0\" selected>全部" + GeneralConfigs.GetConfig().Albumname + "</option>";
            else
                options += "<option value=\"0\">全部" + GeneralConfigs.GetConfig().Albumname + "</option>";                

            foreach (AlbumInfo album in albumlist)
            {
                if (album.Albumid == albumid)
                {
                    options += string.Format("<option value=\"{0}\" selected>{1}</option>", album.Albumid, album.Title);
                    this.ModulePref.Title = album.Title;
                }
                else
                {
                    options += string.Format("<option value=\"{0}\">{1}</option>", album.Albumid, album.Title);
                }
            }
            
            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<select id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "选择" + GeneralConfigs.GetConfig().Albumname + ": ", "albumid", options, "");

            //显示图片数
            value = userprefs.GetValueByName("photocount");
            value = value == "" ? "10" : value;
            int photocount = Utils.StrToInt(value, 10);

            if (photocount > 10 || photocount < 3)
                photocount = 10;

            options = string.Empty;
            for (int i = 3; i <= 10; i++)
            {
                if (photocount == i)
                    options += string.Format("<option value=\"{0}\" selected>{0} 张</option>", i);
                else
                    options += string.Format("<option value=\"{0}\">{0} 张</option>", i);
            }

            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<select id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "展示图片数量: ", "photocount", options, "");
            editbox += "</table>";
            return base.OnEditBoxLoad(editbox);
        }
Ejemplo n.º 3
0
		public ifr()
		{
			HttpContext.Current.Response.ContentType = "text/html";
//			if (ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost()))
//				return;

//			if (userid < 1)
//				return;
			string url = DNTRequest.GetQueryString("url");
			int mid = DNTRequest.GetQueryInt("mid", 0);
            int uid = DNTRequest.GetQueryInt("uid", 0);
			ModuleInfo moduleinfo = Spaces.GetModuleById(mid, uid);
			if (moduleinfo == null)
			{
				return;
			}
			if (url != moduleinfo.ModuleUrl)
			{
				return;
			}
			UserPrefsSaved ups = new UserPrefsSaved(moduleinfo.UserPref);

			string path = BaseConfigs.GetForumPath + "space/modules/" + url;
			string modulefilepath = Utils.GetMapPath(path);
			ModulePref mp = ModuleXmlHelper.LoadModulePref(modulefilepath);
			ModuleContent mc = ModuleXmlHelper.LoadContent(modulefilepath);

#if NET1			
            UserPrefCollection upc = ModuleXmlHelper.LoadUserPrefs(modulefilepath);
#else
            UserPrefCollection<UserPref> upc = ModuleXmlHelper.LoadUserPrefs(modulefilepath);
#endif
			
            StringBuilder registScript = new StringBuilder("<script type=\"text/javascript\">");
			foreach (UserPref up in upc)
			{
				string userprefvalue = ups.GetValueByName(up.Name);
				userprefvalue = userprefvalue == string.Empty ? up.DefaultValue : userprefvalue;
				registScript.AppendFormat(PREF_SCRIPT_FORMAT, mid, up.Name, userprefvalue);
			}
			registScript.Append(ModuleXmlHelper.GetModuleRequireScript(mp, mc.Type == ModuleContentType.HtmlInline));
			registScript.Append("</script>");
			string html = string.Format(IFRAME_HTML, registScript.ToString(), mc.ContentHtml, BaseConfigs.GetForumPath);
			html = html.Replace("__MODULE_ID__", mid.ToString()).Replace("_IG_", "_DS_");


			HttpContext.Current.Response.Write(html);
			HttpContext.Current.Response.End();




		}
Ejemplo n.º 4
0
        /// <summary>
        /// 自定义模块加载时的行为
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public override string OnMouduleLoad(string content)
        {
            content = StaticFileProvider.GetContent(filename);

            string showborder = "0";
            if (UserID == this.Module.Uid)
            {
                showborder = "1";
            }
            else
            {
                UserPrefsSaved ups = new UserPrefsSaved(this.Module.UserPref);
                showborder = ups.GetValueByName("showborder");
            }
            content = content.Replace("{showborder}", showborder == string.Empty ? "1" : showborder);
            
            content = content.Replace("{customizepanelcontent}", Spaces.GetCustomizePanelContent(this.ModuleID, this.Module.Uid));
            content = content.Replace("{themepath}", this.SpaceConfig.ThemePath);
            content = content.Replace("{forumpath}", BaseConfigs.GetForumPath);
            return base.OnMouduleLoad(content);
        }
Ejemplo n.º 5
0
		public override string OnEditBoxLoad(string editbox)
		{
			this.Editable = true;
			UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
			string value = userprefs.GetValueByName("showaddons");
			value = value == "" ? "0" : value;
			string checkedvalue = "";
			if (value == "1")
				checkedvalue = "checked";
			editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";
			editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{4}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{3}\" value=\"{1}\" type=\"hidden\" /><input type=\"checkbox\" {2} onclick=\"_gel('m___MODULE_ID___0').value = this.checked ? '1' : '0';\" /></td></tr>", "显示附加信息", value, checkedvalue, "showaddons", "");
            value = userprefs.GetValueByName("isvertical");
            value = value == "" ? "0" : value;
            if (value == "1")
                checkedvalue = "checked";
            else
                checkedvalue = "";

            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{4}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input id=\"m___MODULE_ID___1\" name=\"m___MODULE_ID___up_{3}\" value=\"{1}\" type=\"hidden\" /><input type=\"checkbox\" {2} onclick=\"_gel('m___MODULE_ID___1').value = this.checked ? '1' : '0';\" /></td></tr>", "竖排显示", value, checkedvalue, "isvertical", "");
			editbox += "</table>";
			return base.OnEditBoxLoad (editbox);
		}
Ejemplo n.º 6
0
		public override string OnEditBoxLoad(string editbox)
		{
			this.Editable = true;
			UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
			editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";
			
			//显示主题条数
			string value = userprefs.GetValueByName("topiccount");
			value = value == "" ? "10" : value;
			string options = string.Empty;
			for (int i = 10; i <= 50; i += 10)
			{
				if (value == i.ToString())
					options += string.Format("<option value=\"{0}\" selected>{0} 条 </option>", i);
				else
					options += string.Format("<option value=\"{0}\">{0} 条 </option>", i);
			}
			editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<select id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "显示主题数: ", "topiccount",options ,"");

			//是否是精华
			value = userprefs.GetValueByName("iselite");
			value = value == "" ? "0" : value;
			string checkedvalue = "";
			if (value == "1")
					checkedvalue = "checked";
			editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{4}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input id=\"m___MODULE_ID___1\" name=\"m___MODULE_ID___up_{3}\" value=\"{1}\" type=\"hidden\" /><input type=\"checkbox\" {2} onclick=\"_gel('m___MODULE_ID___1').value = this.checked ? '1' : '0';\" /></td></tr>", "仅显示精华帖: ", value, checkedvalue, "iselite", "");
			
//			//是否仅显示自己的
//			value = userprefs.GetValueByName("ismine");
//			value = value == "" ? "0" : value;
//			checkedvalue = "";
//			if (value == "1")
//				checkedvalue = "checked";
//			editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{4}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input id=\"m___MODULE_ID___2\" name=\"m___MODULE_ID___up_{3}\" value=\"{1}\" type=\"hidden\" /><input type=\"checkbox\" {2} onclick=\"_gel('m___MODULE_ID___2').value = this.checked ? '1' : '0';\" /></td></tr>", "仅显示我的主题: ", value, checkedvalue, "ismine", "");
			
			editbox += "</table>";
			return base.OnEditBoxLoad (editbox);
		}
Ejemplo n.º 7
0
        /// <summary>
        /// 自定义编辑框行为
        /// </summary>
        /// <param name="editbox"></param>
        /// <returns></returns>
        public override string OnEditBoxLoad(string editbox)
        {
            this.Editable = true;

            UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
            string value = userprefs.GetValueByName("showborder");
            value = value == string.Empty ? "0" : value;
            string checkvalue = string.Empty;
            if (value == "1")
                checkvalue = "checked";
            editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";
            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{4}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{3}\" value=\"{1}\" type=\"hidden\" /><input type=\"checkbox\" {2} onclick=\"_gel('m___MODULE_ID___0').value = this.checked ? '1' : '0';\" /></td></tr>", "显示边框: ", value, checkvalue, "showborder", "");
            value = userprefs.GetValueByName("moduletitle");

            if (value != string.Empty)
            {
                this.ModulePref.Title = value;
            }

            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input type=\"text\" size=\"20\" maxlen=\"200\" id=\"m___MODULE_ID___1\" name=\"m___MODULE_ID___up_{2}\" value=\"{1}\" /></td></tr>", "设置标题: ", value, "moduletitle", "");
            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\">&nbsp;</td><td colspan=\"1\" align=\"right\" width=\"65%\"><nobr><a id=\"DD_tg___cp___MODULE_ID__\" href=\"###\" onclick=\"_DS_popup(event,'__cp___MODULE_ID__');editpanel___MODULE_ID__();_gel('DD___cp___MODULE_ID__').style.zIndex = 2;\">点此编辑面板内容</a></nobr></td></tr>");
            editbox += "</table>";
            return base.OnEditBoxLoad(editbox);
        }
Ejemplo n.º 8
0
		public override string OnMouduleLoad(string content)
		{
			UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
			string value = userprefs.GetValueByName("showaddons");
            string vertical = userprefs.GetValueByName("isvertical");
			string[] score = Scoresets.GetValidScoreName();
			UserInfo ui = Users.GetUserInfo(this.Module.Uid);
			UserGroupInfo group = UserGroups.GetUserGroupInfo(ui.Groupid);
			content = StaticFileProvider.GetContent(contentTemplate);

            if (vertical == "1")
            {
                content = Regex.Replace(content, @"<div id=""UserInfo""([\s\S]+?)</div>\r\n</div>", "");
            }
            else
            {
                content = Regex.Replace(content, @"<div id=""UserInfo2""([\s\S]+?)</div>\r\n</div>", "");
            }

			content = content.Replace("${username}", ui.Username);
			string avatar = string.Empty;
            //if (ui.Avatar != string.Empty)
            //{
            //    if (Regex.IsMatch(ui.Avatar, @"^(http://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"))
            //        avatar = string.Format("<img src='{0}'", ui.Avatar);
            //    else if (ui.Avatar.StartsWith("avatars"))                
            //        avatar = string.Format("<img src='{0}'", BaseConfigs.GetForumPath + ui.Avatar.Replace('\\','/'));
            //    else
            //        avatar = string.Format("<img src='{0}'", ui.Avatar.Replace('\\', '/'));
            //    if (ui.Avatarwidth > 0)
            //        avatar += string.Format(" width='{0}' height='{1}' ", ui.Avatarwidth, ui.Avatarheight);
            //    avatar += "/>";
            //}
			content = content.Replace("${useravatar}", avatar);
			content = content.Replace("${userid}", ui.Uid.ToString());
			content = content.Replace("${nickname}", ui.Nickname);
			content = content.Replace("${usergroup}", group.Grouptitle);
			content = content.Replace("${usercredits}", ui.Credits.ToString());
            content = content.Replace("${forumpath}", BaseConfigs.GetForumPath);

			string addoninfo = string.Empty;
			if (value == "1")
			{
				if (score[1] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[1], ui.Extcredits1);
				if (score[2] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[2], ui.Extcredits2);
				if (score[3] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[3], ui.Extcredits3);
				if (score[4] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[4], ui.Extcredits4);
				if (score[5] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[5], ui.Extcredits5);
				if (score[6] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[6], ui.Extcredits6);
				if (score[7] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[7], ui.Extcredits7);
				if (score[8] != "")
					addoninfo += string.Format("<li><span>{0}: </span>{1}</li>", score[8], ui.Extcredits8);
			}
			content = content.Replace("${addoninfo}", addoninfo);

			return base.OnMouduleLoad (content);
		}
Ejemplo n.º 9
0
        /// <summary>
        /// 自定义模块加载时的行为
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public override string OnMouduleLoad(string content)
        {
            if (AlbumPluginProvider.GetInstance() == null || GeneralConfigs.GetConfig().Enablealbum != 1)
                return "相册插件未安装,模块暂不可用";

            UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
            int photocount = Utils.StrToInt(userprefs.GetValueByName("photocount"), 10);
            int albumid = Utils.StrToInt(userprefs.GetValueByName("albumid"), 0);
            List<PhotoInfo> photolist = DTOProvider.GetPhotoListByUserId(this.Module.Uid, albumid, photocount);
            StringBuilder sb = new StringBuilder(StaticFileProvider.GetContent(jsFile));
            StringBuilder sbImgList = new StringBuilder();
            for (int i = 0; i < photolist.Count; i++)
            {
                sbImgList.AppendFormat("data[\"-1_{0}\"] = \"img: {1}; url: {2}; target: _blank; \"\r\n", i+1, BaseConfigs.GetForumPath + Discuz.Album.Globals.GetSquareImage(photolist[i].Filename), BaseConfigs.GetForumPath + "showalbumlist.aspx?uid=" + this.Module.Uid);
            }
            sb.Replace("{$templatepath}", BaseConfigs.GetForumPath + "templates/" + Templates.GetTemplateItem(GeneralConfigs.GetConfig().Templateid).Directory);
            sb.Replace("{$photolist}", sbImgList.ToString());
            content = sb.ToString();
            return base.OnMouduleLoad(content);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取模块内容区html,不包括内置模块
        /// </summary>
        /// <returns>内容区html</returns>
		private string GetModuleBoxin()
		{
			switch(_module.ModuleType)
			{
				case ModuleType.Remote :
					return "此类模块暂不支持";
				case ModuleType.Rss :
					return GetRssBoxin();
				case ModuleType.Error :
					return "此类模块暂不支持";
			}

			//如果是内建类型则进行其他处理
			UserPrefsSaved ups = new UserPrefsSaved(_module.UserPref);
			string parms = "", returnStr = "";
			
			switch (_moduleContent.Type)
			{
				case ModuleContentType.Html :
					foreach (UserPref up in _userPrefCollection)
					{
						string userprefvalue = ups.GetValueByName(up.Name);
						userprefvalue = userprefvalue == string.Empty ? up.DefaultValue : userprefvalue;
						parms += string.Format("&up_{0}={1}", up.Name, Utils.UrlEncode(userprefvalue));
					}
					//{0}代表模块url,{1}代表render_inline,{2}代表当前站点路径
					returnStr = "<script><!--\r\nremote_modules.push(new RemoteModule(\"{0}\",\"__MODULE_ID__\",\"{1}\",\"{4}space/ifr.aspx?url={0}&nocache=1&uid={2}&mid=__MODULE_ID__&parent={3}\",false));// -->\r\n</script><div id=remote___MODULE_ID__ style=\"border:0px;padding:0px;margin:0px;width:100%\"><iframe id=remote_iframe___MODULE_ID__ style=\"border:0px;padding:0px;margin:0px;width:100%;height:200px;overflow:hidden;background:transparent;\" allowtransparency=\"yes\" frameborder=0 scrolling=no></iframe></div>";
					returnStr = string.Format(returnStr, _module.ModuleUrl, _modulePref.RenderInline, _module.Uid, GeneralConfigs.GetConfig().Forumurl + parms, BaseConfigs.GetForumPath);
					break;
				case ModuleContentType.HtmlInline :
					returnStr = _moduleContent.ContentHtml;
					break;
				case ModuleContentType.Url :
					//这里要对ContentHtml(这里一开始它的值与Href相同)进行进一步的处理,因为需要传递参数,参数是UserPref
					foreach (UserPref up in _userPrefCollection)
					{
						string userprefvalue = ups.GetValueByName(up.Name);
						userprefvalue = userprefvalue == string.Empty ? up.DefaultValue : userprefvalue;
						parms += string.Format("&up_{0}={1}", up.Name, Utils.UrlEncode(userprefvalue));
					}					
					if (parms.StartsWith("&"))
						parms = parms.TrimStart('&');

					returnStr = string.Format(_moduleContent.ContentHtml, parms);
					break;
			}
			return returnStr;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Get the content area's html 内建模块专有功能
		/// </summary>
		/// <returns>模块内容区的html</returns>
		public string GetModuleHtml()
		{
			string prefScriptFormat = "_DS_Prefs._add(\"{0}\",\"up_{1}\",\"{2}\");";
			UserPrefsSaved ups = new UserPrefsSaved(_module.UserPref);
			StringBuilder registScript = new StringBuilder("<script type=\"text/javascript\">");
			string root = BaseConfigs.GetForumPath;
			Hashtable ht = new Hashtable();

			if (_module.ModuleDefID == 0)
				_editable = _userPrefCollection == null ? false : _userPrefCollection.VisibleItemCount > 0;
			if (_module.ModuleType == ModuleType.Rss)
				_editable = true;

			string boxin = OnMouduleLoad(GetModuleBoxin());
			string editbox = OnEditBoxLoad(GetModuleEditBox());
			string moduleTitle = "<span id=\"m___MODULE_ID___title\" class=\"modtitle_text\"></span>";
			if (_module.ModuleType == ModuleType.Local)
				moduleTitle = _modulePref.TitleUrl == string.Empty ? "<span id=\"m___MODULE_ID___title\" class=\"modtitle_text\">" + _modulePref.Title + "</span>" : "<a class=\"mtlink\" id=\"m___MODULE_ID___url\" href=\"" + _modulePref.TitleUrl + "\" target=\"_blank\"><span id=\"m___MODULE_ID___title\" class=\"modtitle_text\">" + _modulePref.Title + "</span></a>";

			if (_moduleContent != null && _moduleContent.Type != ModuleContentType.Url)
			{
				//在内容区用js加载UserPref设置,并且将UserPref值加载到TemplateEngine的需要替换的集合里
				foreach (UserPref up in _userPrefCollection)
				{
					string userprefvalue = ups.GetValueByName(up.Name);
					userprefvalue = userprefvalue == string.Empty ? up.DefaultValue : userprefvalue;
					registScript.AppendFormat(prefScriptFormat, Module.ModuleID, up.Name, userprefvalue);

					string upName = "__UP_" + up.Name + "__";
					boxin = boxin.Replace(upName, userprefvalue);
					editbox = editbox.Replace(upName, userprefvalue);
					moduleTitle = moduleTitle.Replace(upName, userprefvalue);
				}
			}
			ht.Add("modboxin", registScript.Append("</script>").Append(boxin).ToString());
			ht.Add("meditbox", editbox);
			ht.Add("title", moduleTitle);
			ht.Add("editable", _editable ? _module.Uid == _userid : false);//还需要加权限判断
			ht.Add("scalable", _scalable);
			ht.Add("deletable", _module.Uid == _userid && _userid > 0);
			
			string html = ModuleTemplate.Instance.GetHtml(ht);//te.MergeTemplate();
			html = html.Replace("__MODULE_ID__", _moduleID.ToString());
			html = html.Replace("__TAB_ID__", _module.TabID.ToString());
			if (_userPrefCollection != null)
			{
				html = html.Replace("__USERPREF_COUNT__", _userPrefCollection.Count.ToString());
			}
            return html;
		}
Ejemplo n.º 12
0
		public override string OnEditBoxLoad(string editbox)
		{
			this.Editable = true;

            UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
            string value = userprefs.GetValueByName("moduletitle");
            //标题
            if (value != string.Empty)
                this.ModulePref.Title = value;

            editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";
            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input type=\"text\" size=\"20\" maxlen=\"200\" id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{2}\" value=\"{1}\" /></td></tr>", "设置标题: ", value, "moduletitle", "");
            
            //底色
            value = userprefs.GetValueByName("bgcolor");
            value = value == string.Empty ? "#ffffcc" : value;

            string options = string.Empty;
            #region 颜色选项
            if (value == "#ffffcc")
                options += "<option value='#ffffcc' selected>Yellow</option>";
            else
                options += "<option value='#ffffcc'>Yellow</option>";

            if (value == "#e5ecf9")
                options += "<option value='#e5ecf9' selected>Blue</option>";
            else
                options += "<option value='#e5ecf9'>Blue</option>";

            if (value == "white")
                options += "<option value='white' selected>White</option>";
            else
                options += "<option value='white'>White</option>";

            if (value == "#e0eee0")
                options += "<option value='#e0eee0' selected>Green</option>";
            else
                options += "<option value='#e0eee0'>Green</option>";

            if (value == "#fff0f5")
                options += "<option value='#fff0f5' selected>Pink</option>";
            else
                options += "<option value='#fff0f5'>Pink</option>";

            if (value == "#fff5ee")
                options += "<option value='#fff5ee' selected>Orange</option>";
            else
                options += "<option value='#fff5ee'>Orange</option>";

            #endregion


            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<select id=\"m___MODULE_ID___1\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "背景颜色:  ", "bgcolor", options, "");
             
            //文字颜色
            value = userprefs.GetValueByName("txtcolor");
            value = value == string.Empty ? "Black" : value;
            #region 颜色选项
            if (value == "Black")
                options = "<option value='Black' selected>Black</option>";
            else
                options = "<option value='Black'>Black</option>";

            if (value == "blue")
                options += "<option value='blue' selected>Blue</option>";
            else
                options += "<option value='blue'>Blue</option>";

            if (value == "green")
                options += "<option value='green' selected>Green</option>";
            else
                options += "<option value='green'>Green</option>";

            if (value == "red")
                options += "<option value='red' selected>Red</option>";
            else
                options += "<option value='red'>Red</option>";

            if (value == "#ff007f")
                options += "<option value='#ff007f' selected>Pink</option>";
            else
                options += "<option value='#ff007f'>Pink</option>";

            if (value == "#ff3300")
                options += "<option value='#ff3300' selected>Orange</option>";
            else
                options += "<option value='#ff3300'>Orange</option>";
            #endregion
            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<select id=\"m___MODULE_ID___2\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "文字颜色:  ", "txtcolor", options, "");
            editbox += "</table>";

			return base.OnEditBoxLoad(editbox) ;
		}
Ejemplo n.º 13
0
		public override string OnMouduleLoad(string content)
		{
			UserPrefsSaved ups = new UserPrefsSaved(this.Module.UserPref);
			string savedContent = ups.GetValueByName("content");
			savedContent = Utils.HtmlEncode(ForumUtils.BanWordFilter(savedContent));
			content = StaticFileProvider.GetContent(filename);
			if (this.UserID == this.Module.Uid)
			{
                content = content.Replace("${ContentArea}", string.Format("<textarea class=\"notepadcontent\" style=\"background-color: {1}; color: {2};\" id=\"content__MODULE_ID__\" onkeyup=\"setRows__MODULE_ID__();\" onblur=\"saveResult__MODULE_ID__();\">{0}</textarea>", savedContent, ups.GetValueByName("bgcolor") == string.Empty ? "#ffffcc" : ups.GetValueByName("bgcolor"), ups.GetValueByName("txtcolor")));
			}
			else
			{
				savedContent = savedContent.Replace("\n","<br />");
                content = content.Replace("${ContentArea}", string.Format("<div class=\"notepadcontent\" style=\"background-color: {1}; color: {2};padding: 8px;\">{0}</div>", savedContent, ups.GetValueByName("bgcolor") == string.Empty ? "#ffffcc" : ups.GetValueByName("bgcolor"), ups.GetValueByName("txtcolor")));
			}
			return base.OnMouduleLoad (content);
		}
Ejemplo n.º 14
0
		/// <summary>
		/// 将UserPrefs组织成Table表现形式
		/// </summary>
		/// <param name="defaultUserPrefs">默认设置</param>
		/// <param name="personalUserPrefs">用户的个性化设置</param>
		/// <returns></returns>
        public static string GetUserPrefsTable(UserPrefCollection<UserPref> defaultUserPrefs, UserPrefsSaved personalUserPrefs)
		{
			StringBuilder sb = new StringBuilder("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">");
			
			bool scriptAdded = false;

			for (int i = 0; i < defaultUserPrefs.Count; i++)
			{
				string value = personalUserPrefs.GetValueByName(defaultUserPrefs[i].Name);

				//此处不需要进行判断value的差异是因为当value为string.empty时ToHtml方法会自动按默认值输出
				sb.Append(defaultUserPrefs[i].ToHtml(value).Replace("__ITEM_INDEX__", i.ToString()));

				if (!scriptAdded && defaultUserPrefs[i].DataType == UserPrefDataType.ListType)
				{
					scriptAdded = true;
					sb.Insert(0,"<script>var listcontrol___MODULE_ID__ = new Array();function checklist___MODULE_ID__() {for (var i = 0; i < listcontrol___MODULE_ID__.length; i ++) {var inputFld = listcontrol___MODULE_ID__[i][0];var checkFunc = listcontrol___MODULE_ID__[i][1];if (inputFld.value &&inputFld.value.length > 0) {if(!checkFunc || checkFunc()) {inputFld.listApp.add();} else {inputFld.focus();inputFld.select();return false;}}}return true;};var checklist_submit___MODULE_ID__ = function(event) {if (!checklist___MODULE_ID__()) {return false;}return this.prev_submit(event);};var reset_list___MODULE_ID__ = function() {this.prev_reset();for (var i = 0; i < this.elements.length; i ++) {if (this.elements[i].listApp) {this.elements[i].listApp.reset();}}};_gel(\"m___MODULE_ID___form\").prev_reset = _gel(\"m___MODULE_ID___form\").reset;_gel(\"m___MODULE_ID___form\").reset = reset_list___MODULE_ID__;if (!_gel(\"m___MODULE_ID___form\").prev_submit) {_gel(\"m___MODULE_ID___form\").prev_submit = _gel(\"m___MODULE_ID___form\").onsubmit;_gel(\"m___MODULE_ID___form\").onsubmit = checklist_submit___MODULE_ID__;}</script>");
				}

			}
			if (defaultUserPrefs.ShowRequired)
				sb.Append("<tr><td colspan=\"3\" align=\"left\"><font color=\"red\">* 为必填项</font></td></tr>");
			sb.Append("</table>");
			return sb.ToString();
		}
Ejemplo n.º 15
0
        /// <summary>
        /// 自定义模块加载时的行为
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public override string OnMouduleLoad(string content)
        {
            UserPrefsSaved ups = new UserPrefsSaved(this.Module.UserPref);
            int charcount = Utils.StrToInt(ups.GetValueByName("charcount"), 500);
            //去掉http地址中的文件名称
            if (forumurl.ToLower().IndexOf("http://") == 0)
                forumurlnopage = forumurl.Substring(0, forumurl.LastIndexOf('/')) + "/";
            else
                forumurl = "../" + forumurl;

            if (configspaceurlnopage.ToLower().IndexOf("http://") < 0)
                configspaceurlnopage = forumurlnopage;
            else
                configspaceurlnopage = configspaceurlnopage.ToLower().Substring(0, configspaceurlnopage.LastIndexOf('/')) + "/";

            string templateContent = Utilities.Globals.GetFileContent(templateFile);//StaticFileProvider.GetContent(templateFile);
            StringBuilder sbMainTemplate = new StringBuilder();
            StringBuilder sbItemTemplate = new StringBuilder();
            StringBuilder sbTimeTemplate = new StringBuilder();
            StringBuilder sbLinkTemplate = new StringBuilder();
            StringBuilder sbTagTemplate = new StringBuilder();
            StringBuilder sbTagItem = new StringBuilder();
            StringBuilder sbContentTemplate = new StringBuilder();
            StringBuilder sbMoreContentTemplate = new StringBuilder();
            string[] templates = Utils.SplitString(templateContent, "/*Discuz Separator*/");

            if (templates.Length < 8)
                content = "模板文件加载出错, 请检查";
            else
            {
                sbMainTemplate.Append(templates[0]);
                sbItemTemplate.Append(templates[1]);
                sbTimeTemplate.Append(templates[2]);
                sbLinkTemplate.Append(templates[3]);
                sbTagTemplate.Append(templates[4]);
                sbTagItem.Append(templates[5]);
                sbContentTemplate.Append(templates[6]);
                sbMoreContentTemplate.Append(templates[7]);

                SpacePostInfo[] spaceposts = GetSpacePosts();
                string[] postids = new string[spaceposts.Length];
                for (int i = 0; i < spaceposts.Length; i++)
                {
                    postids[i] = spaceposts[i].Postid.ToString();
                }
                Dictionary<string, Dictionary<string, string>> categorys = null;
                if (postids.Length > 0)
                {
                    categorys = Spaces.GetSpacePostCategorys(string.Join(",", postids));
                    //获取分类
                }

                StringBuilder sbItemList = new StringBuilder();
                #region 循环遍历
                foreach (SpacePostInfo post in spaceposts)
                {
                    StringBuilder sbTemp = new StringBuilder(sbItemTemplate.ToString());
                    sbTemp.Replace("{$TimeTemplate}", ParseTimeTemplate(sbTimeTemplate.ToString(), post));
                    sbTemp.Replace("{$LinkTemplate}", ParseLinkTemplate(sbLinkTemplate, post, categorys));
                    StringBuilder sbTempTag = new StringBuilder(sbTagTemplate.ToString());
                    string tagItem = ParseTagItem(sbTagItem, post);
                    if (tagItem != string.Empty)
                        sbTemp.Replace("{$TagTemplate}", sbTempTag.Replace("{$TagItem}", tagItem).ToString());
                    else
                        sbTemp.Replace("{$TagTemplate}", string.Empty);

                    string postcontent = post.Content;

                    if (charcount == 0)//不显示正文
                        postcontent = string.Empty;
                    else if (charcount > 0)//截断
                    {
                        postcontent = Utils.GetTextFromHTML(Utils.HtmlDecode(postcontent));
                        if (postcontent.Length > charcount)
                        {
                            StringBuilder sbTempMoreContentTemplate = new StringBuilder(sbMoreContentTemplate.ToString());
                            sbTempMoreContentTemplate.Replace("{$Root}", configspaceurlnopage);
                            sbTempMoreContentTemplate.Replace("{$PostId}", post.Postid.ToString());
                            sbTempMoreContentTemplate.Replace("{$SpaceId}", SpaceConfig.SpaceID.ToString());
                            postcontent = postcontent.Substring(0, charcount) + "..." + sbTempMoreContentTemplate.ToString();
                        }
                    }

                    StringBuilder sbTempContent = new StringBuilder(sbContentTemplate.ToString());

                    sbTemp.Replace("{$ContentTemplate}", sbTempContent.Replace("{$Content}", postcontent).ToString());
                    sbItemList.Append(sbTemp);
                }
                #endregion

                sbMainTemplate.Replace("{$ItemTemplate}", sbItemList.ToString());
                sbMainTemplate.Replace("{$ForumPath}", forumurlnopage);
                sbMainTemplate.Replace("{$Skin}", base.SpaceConfig.ThemePath);
                content = sbMainTemplate.ToString() + "<div style='border-top:1px dashed #ccc; padding:10px 0; padding-left:10px;font-weight:bold;'><a href=\"viewspacepostlist.aspx?spaceid=" + base.SpaceConfig.SpaceID + "\">查看更多</a></div>";
            }
            return base.OnMouduleLoad(content);
        }
Ejemplo n.º 16
0
        public override string OnEditBoxLoad(string editbox)
        {
            this.Editable = true;
            UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref);
            editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">";
            string value = userprefs.GetValueByName("charcount");

            int charcount = Utils.StrToInt(value, 500);

            editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\">&nbsp;<input type=\"text\" size=\"20\" maxlen=\"200\" id=\"m___MODULE_ID___1\" name=\"m___MODULE_ID___up_{2}\" value=\"{1}\" /></td></tr>", "显示正文字数: ", charcount, "charcount", "");
            editbox += "</table>";

            return base.OnEditBoxLoad(editbox);
        }