示例#1
0
		private void LoadWikiPage(WikiPage wikiPage) {
			try {
				webBrowserWiki.DocumentText=WikiPages.TranslateToXhtml(wikiPage.PageContent,false);
			}
			catch(Exception ex) {
				webBrowserWiki.DocumentText="";
				MessageBox.Show(this,Lan.g(this,"This page is broken and cannot be viewed.  Error message:")+" "+ex.Message);
			}
		}
示例#2
0
文件: FormWikiEdit.cs 项目: mnisl/OD
		/// <summary>Because FormWikiAllPages is no longer modal, this is necessary to be able to tell FormWikiEdit to refresh with inserted data.</summary>
		public void RefreshPage(WikiPage selectedWikiPage) {
			int tempStart=textContent.SelectionStart;
			if(selectedWikiPage==null) {
				textContent.Paste("[[]]");
				textContent.SelectionStart=tempStart+2;
			}
			else {
				textContent.Paste(("[["+selectedWikiPage.PageTitle+"]]"));
				textContent.SelectionStart=tempStart+selectedWikiPage.PageTitle.Length+4;
			}
			textContent.Focus();
			textContent.SelectionLength=0;
		}
示例#3
0
文件: WikiPages.cs 项目: mnisl/OD
		///<summary>Archives first by moving to WikiPageHist if it already exists.  Then, in either case, it inserts the new page.</summary>
		public static long InsertAndArchive(WikiPage wikiPage) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				wikiPage.WikiPageNum=Meth.GetLong(MethodBase.GetCurrentMethod(),wikiPage);
				return wikiPage.WikiPageNum;
			}
			WikiPage wpExisting=GetByTitle(wikiPage.PageTitle);
			if(wpExisting!=null) {
				WikiPageHist wpHist=PageToHist(wpExisting);
				WikiPageHists.Insert(wpHist);
				string command= "DELETE FROM wikipage WHERE PageTitle = '"+POut.String(wikiPage.PageTitle)+"'";
				Db.NonQ(command);
			}
			return Crud.WikiPageCrud.Insert(wikiPage);
		}
示例#4
0
		///<summary>Before calling this, make sure to increment/decrement the historyNavBack index to keep track of the position in history.  If loading a new page, decrement historyNavBack before calling this function.  </summary>
		private void LoadWikiPage(string pageTitle) {
			//This is called from 11 different places, any time the program needs to refresh a page from the db.
			//It's also called from the browser_Navigating event when a "wiki:" link is clicked.
			WikiPage wpage=WikiPages.GetByTitle(pageTitle);
			if(wpage==null) {
				if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"That page does not exist. Would you like to create it?")) {
					return;
				}
				FormWikiEdit FormWE=new FormWikiEdit();
				FormWE.WikiPageCur=new WikiPage();
				FormWE.WikiPageCur.IsNew=true;
				FormWE.WikiPageCur.PageTitle=pageTitle;
				FormWE.WikiPageCur.PageContent="[["+WikiPageCur.PageTitle+"]]\r\n"//link back
					+"<h1>"+pageTitle+"</h1>\r\n";//page title
				FormWE.OwnerForm=this;
				FormWE.Show();
				return;
			}
			WikiPageCur=wpage;
			webBrowserWiki.DocumentText=WikiPages.TranslateToXhtml(WikiPageCur.PageContent,false);
			Text="Wiki - "+WikiPageCur.PageTitle;
			#region historyMaint
			//This region is duplicated in webBrowserWiki_Navigating() for external links.  Modifications here will need to be reflected there.
			int indexInHistory=historyNav.Count-(1+historyNavBack);//historyNavBack number of pages before the last page in history.  This is the index of the page we are loading.
			if(historyNav.Count==0) {//empty history
				historyNavBack=0;
				historyNav.Add("wiki:"+pageTitle);
			}
			else if(historyNavBack<0) {//historyNavBack could be negative here.  This means before the action that caused this load, we were not navigating through history, simply set back to 0 and add to historyNav[] if necessary.
				historyNavBack=0;
				if(historyNav[historyNav.Count-1]!="wiki:"+pageTitle) {
					historyNav.Add("wiki:"+pageTitle);
				}
			}
			else if(historyNavBack>=0 && historyNav[indexInHistory]!="wiki:"+pageTitle) {//branching from page in history
				historyNav.RemoveRange(indexInHistory,historyNavBack+1);//remove "forward" history. branching off in a new direction
				historyNavBack=0;
				historyNav.Add("wiki:"+pageTitle);
			}
			#endregion
		}
示例#5
0
文件: WikiPageHists.cs 项目: mnisl/OD
		public static WikiPage RevertFrom(WikiPageHist wikiPageHist) {
			WikiPage retVal=new WikiPage();
			//retVal.WikiPageNum
			//retVal.UserNum
			retVal.PageTitle=wikiPageHist.PageTitle;
			retVal.PageContent=wikiPageHist.PageContent;
			retVal.KeyWords="";
			Match m=Regex.Match(wikiPageHist.PageContent,@"\[\[(keywords:).*?\]\]");
			if(m.Length>0) {
				retVal.KeyWords=m.Value.Substring(11).TrimEnd(']');
			}
			//retVal.DateTimeSaved=DateTime.Now;//gets set when inserted.
			return retVal;
		}
示例#6
0
文件: WikiPages.cs 项目: mnisl/OD
		public static WikiPageHist PageToHist(WikiPage wikiPage) {
			//No need to check RemotingRole; no call to db.
			WikiPageHist wikiPageHist=new WikiPageHist();
			wikiPageHist.WikiPageNum=-1;//todo:handle this -1, shouldn't be a problem since we always get pages by Title.
			wikiPageHist.UserNum=wikiPage.UserNum;
			wikiPageHist.PageTitle=wikiPage.PageTitle;
			wikiPageHist.PageContent=wikiPage.PageContent;
			wikiPageHist.DateTimeSaved=wikiPage.DateTimeSaved;//This gets set to NOW if this page is then inserted
			wikiPageHist.IsDeleted=false;
			return wikiPageHist;
		}
示例#7
0
文件: WikiPages.cs 项目: mnisl/OD
		///<summary></summary>
		public static void FillCache(DataTable table) {
			//No need to check RemotingRole; no call to db.
			masterPage=Crud.WikiPageCrud.TableToList(table)[0];
		}
示例#8
0
文件: WikiPages.cs 项目: mnisl/OD
		///<summary>Validation was already done in FormWikiRename to make sure that the page does not already exist in WikiPage table.  But what if the page already exists in WikiPageHistory?  In that case, previous history for the other page would start showing as history for the newly renamed page, which is fine.</summary>
		public static void Rename(WikiPage wikiPage, string newPageTitle) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),wikiPage,newPageTitle);
				return;
			}
			//a later improvement would be to validate again here in the business layer.
			wikiPage.UserNum=Security.CurUser.UserNum;
			InsertAndArchive(wikiPage);
			//Rename all pages in both tables: wikiPage and wikiPageHist.
			string command="UPDATE wikipage SET PageTitle='"+POut.String(newPageTitle)+"'WHERE PageTitle='"+POut.String(wikiPage.PageTitle)+"'";
			Db.NonQ(command);
			command="UPDATE wikipagehist SET PageTitle='"+POut.String(newPageTitle)+"'WHERE PageTitle='"+POut.String(wikiPage.PageTitle)+"'";
			Db.NonQ(command);
			//For now, we will simply fix existing links in history.
			//The way this is written currently is case sensitive.  That's fine, but it means that all existing links must be perfect, including case, or they will not get updated.
			//To enforce proper case, we fix it when saving each page in the WikiEdit window.
			command="UPDATE wikipage SET PageContent=REPLACE(PageContent,'[["+POut.String(wikiPage.PageTitle)+"]]', '[["+POut.String(newPageTitle)+"]]')";
			Db.NonQ(command);
			command="UPDATE wikipagehist SET PageContent=REPLACE(PageContent,'[["+POut.String(wikiPage.PageTitle)+"]]', '[["+POut.String(newPageTitle)+"]]')";
			Db.NonQ(command);
			return;
		}
		private void gridMain_CellDoubleClick(object sender,UI.ODGridClickEventArgs e) {
			JumpToPage=ListWikiPages[e.Row];
			DialogResult=DialogResult.OK;
		}
		private void LoadWikiPage(WikiPage wikiPage) {
			webBrowserWiki.DocumentText=WikiPages.TranslateToXhtml(wikiPage.PageContent,false);
		}
示例#11
0
 ///<summary></summary>
 public static void FillCache(DataTable table)
 {
     //No need to check RemotingRole; no call to db.
     masterPage = Crud.WikiPageCrud.TableToList(table)[0];
 }