Wiki

Options

Case Status Kiln
Register Log In

Wiki

Options

 
FogBugz Plugin Interfaces (All…»Implementing IPluginWikiPageJo…
  • RSS Feed

Last modified on 12/15/2014 5:22 PM by User.

Tags:

Implementing IPluginWikiPageJoin, IPluginWikiPageCommit and IPluginWikiPageInfoDisplay

FogBugz Plugin Interfaces > Wikis and Wiki Pages > IPluginWikiPageJoin, IPluginWikiPageCommit and IPluginWikiPageInfoDisplay

Introduction

This article will demonstrate simple code for a FogBugz plugin that implements the IPluginWikiPageJoin, IPluginWikiPageCommit and IPluginWikiPageInfoDisplay interfaces contained in the FogCreek.FogBugz.Plugins.Interfaces class library.

Functionality

This plugin will add a table to the database, WikiPageStats which will be joined against WikiPage to provide a custom field, nCharacterCount which will be updated with the current number of characters in the raw html of the wiki page each time it is saved (commited).

IPluginWikiPageJoin

This plugins use the IPluginWikiPageJoin method to specify a table containing an integer "ixWikiPage" column, allowing FogBugz to automatically join the columns of that table to the "WikiPage" table. This allows the plugin developer to use CWikiPage.GetPluginField() and CWikiPage.GetPluginFieldOrig() to easily retrieve column values from the joined table,  and use CWikiPage.SetPluginField() to specify a value to be set upon commit.

IPluginWikiPageInfoDisplay and IPluginWikiPageCommit

In this example, IPluginWikiPageCommit is implemented to count and store the number of characters in the current wiki page whenever it is saved. That count is displayed in a CWikiPageInfoBlock object via IPluginWikiPageInfoDisplay. To demonstrate how wiki page rollback occurs, this plugin fails to commit when the character count is higher than a set constant (500). The rollback method of IPluginWikiPageCommit generates a UI notification (using CPluginApi.Notifications) indicating that it was called.

Editing a sample article:

This article has not beed saved since the plugin was installed, so it has not counted the length:

After editing and clicking save:

See the character count on the info page, saved in the WikiPageStats table:

A long edit:

After clicking save, since the character count is greater than 500, so WikiPageCommitBefore returns false, aborting the commit and causing WikiPageCommitRollback to be called, keeping the user in the editor:

Compile and Install It On Your Own

Download the source file:   IPluginWikiPageJoin_InfoDisplay_Commit_Example.cs

Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin