Tuesday, June 9, 2009

Customizing the Page Editing Toolbar to include Content Validation for the Web Content Scenario in Microsoft Office SharePoint Server (MOSS)

In recent weeks several people have asked me how they can implement content validation in Microsoft SharePoint as a new menu item for users in such a way to allow not only for validation but also to include guidance and educational value. An additional request has been the ability to test for Accessibility in languages beyond English; specifically: Spanish, Italian, and French. This solution will cover these concerns. This Post covers content validation for:


  • Accessibility
  • Link Checking
  • (X)HTML Markup Validity

To follow along you simply need SharePoint installed or you can simply download the Microsoft Office SharePoint Server 2007 VHD that will contain all the software needed for you to follow along. Download Link (http://www.microsoft.com/downloads/details.aspx?FamilyID=67f93dcb-ada8-4db5-a47b-df17e14b2c74&DisplayLang=en). For the testing engines the following sites will be referenced:






For the purpose of this test and code this post will reference these external sites and the validation will run externally. However, in some cases this will not be possible and you may therefore want to download these validation servers to your local servers so as not to worry about hostname routing over the internet. This example will be complete and it will require no outside references. If you find something is missing please notify the author: Robert B. Yonaitis @ ryonaitis@gmail.com.


Figure 1 - MOSS interface displaying our final product which is integrated content validation


Note the menu item Validation contains three new tests: Validate Accessibility with Hera, Validate Links with the W3C Link Checker, and Validate Markup with the W3C Validator. To create this menu option we need to complete a few simple steps:




  1. Edit the CustomEditingMenu.XML File with SharePoint Designer
  2. Perform an IIS Reset on the Litwaredemo machine
  3. Test our pages

In this method there will be no source code to write or compile. So let us begin!

Editing the CustomEditingMenu.XML File
To properly ADD items to the Edit Menu capabilities you will need to modify or add a CustomEditingMenu.XML file. By default the litwaredemo image has a Blank CustomEditingMenu.XML file. This is what we will edit to provide content validation.
1. Start the WIN03_MOSS.VHD
2. Open SharePoint Designer from the LITWAREDEMO VHD to the MOSS Site
a. Select Start
b. Select All Programs
c. Select Microsoft Office
d. Select Microsoft Office SharePoint Designer
e. Select File from The SharePoint Designer Menu
f. Select Open Site from The SharePoint Designer Menu
g. TYPEIN http://localhost/ into the Site Name Input Box
h. Select Open
i. Login if Required: Default User/ Password pair is: Administrator / pass@word1
3. Navigate the folder list to _catalogs / masterpage / Editing Menu
4. Open the CustomEditingMenu.XML file in the SharePoint Designer
5. Replace the content with the following content (NOTE: THIS ASSUMES THIS FILE HAS NOT BEEN MODIFIED BEFORE AND YOU ARE WORKING WITH A FRESH IMAGE) or download the xml file

6. Select File Save from the SharePoint Designer Menu
7. CHECK the file in if required
8. Publish a Major Version
9. Close SharePoint Designer
10. From the Start Menu Select Start Run
11. Enter IISRESET in the OPEN: Text Input
12. Select OK
13. When the IISRESET is complete Launch your site http://litwaredemo/pages/default.aspx
You will note you now have the three menu items under the new validation menu item

Some Explanations of the nodes
This post covered a large amount of ground and now it is time to step back for a moment and to explain the validation a bit and for this we will use the Hera Accessibility Validation node.

In the Console node we will set the values required to implement Accessibility Validation. Most of the items are self explanatory but the following is an Explanation:

  • DisplayText – The DisplayText attribute is used to name the menu item text that the user will see as in Figure 1 of this post and is configurable by the person setting up the site
  • UseResourceFile – By default this is set to false for all of the validations
  • ImageURL – This assigns the menu item image to be the actionssettings.gif file and is configurable by the person setting up the site
  • UserRights – The UserRights attribute describes the rights necessary to see the node that is being described. A complete list of available values can be found on the following MSDN Page and is customizable by the person configuring the menu: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx
  • RequiredRightsMode – The RequiredRightsMode attribute is set to any by default
  • PermissionContext – The PermissionContext attribute is set to the CurrentSite. A complete list of available values can be found on the following MSDN Page and is customizable by the person configuring the menu: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.permissioncontext.aspx
  • IsSiteRelative – The IsSiteRelative attribute is set to false. This is very important. It tells the system that the NavigateURL link is not relative to the MOSS site you are on so it does not attend the page being called to the current site. // If this was not set to false you would end up with a link to something like this: http://litwaredemo/Pages/javascript:window.open();"
  • NavigateURL – The NavigateURL attribute is where we define what page to test and what site we will be testing the site on and in this example it is Hera. Please note Hera will be able to detect your browser language and bring up the page in the correct language.



Figure 2 - Hera Report

Closing
The post you just read is designed to work on sites available on the internet. If you will be using this on an intranet you will need to download and install the testing engines onto your own server. All of the validation engines selected for this example can be downloaded. Please note the NavigateURL will have to change if you change validation server locations from the ones that are used for the example.

Upcoming Posts


  • How to deploy this solution over a farm as a feature
  • How to create a simple workflow that takes advantage of these items
  • How to create moss publishing sites that produce valid xhtml

About the Author
Robert B. Yonaitis is the Founder of HiSoftware Inc, (Hiawatha Island Software Company). Robert has also authored multiple titles focused on Content Publishing and Content Management: The Elements of WebSite Promotion , Understanding Internet Traffic, Understanding Accessibility. Yonaitis' leadership brought HiSoftware technologies recognition for the positive impact that they have had for everyone who uses information and applications on the Internet regardless of physical or technical ability. Yonaitis’ technology and software innovations have received numerous accolades and awards, including the 2002 Da Vinci award for Electronics and IT Innovations that have most improved the lives of People with Disabilities. His design of the testing portal, cynthiasays.com, was endorsed by the ACB for its impact and educational importance in the area of Web Accessibility. Yonaitis holds a private pilot license. He received a BS, majoring in Computer Science, from Franklin Pierce in NH and a MAS from Embry-Riddle specializing in Aeronautics and Space Studies.



You can download this post as a PDF

0 comments: