Welcome
Monday, May 15, 2006
+Hiding the !new Icon for WSS Lists
Here's a way to do it per list, if you don't want a
global change to the lists...
You can stick this function in the ows.js, directly on
the allitems.aspx page or wherever else you may find
appropriate and attach it to the Body onload. ( i.e. BODY
onload=“javascript:HideNewIcons();“ )
I just find it more convenient to modify a particular
list template where users may not want that silly icon...
OK, so it adds a fraction of a second to the page
load, but shouldn't be that bad...
function HideNewIcons()
{
var fields,i;
fields = document.getElementsByTagName('IMG');
for( i = 0; i < fields.length; i ++ )
{
var imgsrc = fields[i].getAttribute('SRC');
if(imgsrc.indexOf("new.gif") != -1)
{
fields[i].style.visibility = "hidden";
}
}
}
It's always fun to “cheat” things to work... :)
Monday, January 16, 2006
+Treeview Source
It is a REAL PAIN to post code to this site...
+Add Folder-Level Context Menu Items
Here’s how to do it: -Some of you may ask “Why the heck?”… Well, I just come up with the solutions, not the problemsJ
Naturally, there may be several folders with like names in a library. This is intended to be used for standard folders. For example, for time sheets kept as per standard in a folder named “TimeReports”.
The script below can be replaced and tailored to meet the requirements. Ideally you will have a custom js file, custom doclib definitions and have defined one or more custom AddDoclibMenuItems functions also. For this test, we’ll use the default AddDoclibMenuItems function
Make sure you create a backup of the ows.js if you are modifying this file directly and not using a custom.js file.
1. We need a little script to return the file’s immediate parent folder name.
This goes anywhere in your script file.
function GetFolderName()
{
var fileName = GetFileName(currentItemFileUrl);
var folderName = currentItemFileUrl;
// remove /filename.ext from path
folderName = folderName.replace('/' + fileName,'')
// get folder name
return folderName.substring(folderName.lastIndexOf('/')+1);
}
function GetFileName(inPathFile)
{
return inPathFile.substring(inPathFile.lastIndexOf('/')+1);
}
2. Insert the function to add a custom menu items
function AddCustomFolderMenu()
{
var retval = false; // if no custom menu is added, default return value
var fName = GetFolderName();
switch (fName)
{
// here is where you can get creative and do our own logic. Get data from an xml file etc…
case "NewFolder":
// add only the ‘Edit’ and checkin/out menu items to any folder named “New Folder”
setDocType();
strDisplayText = StBuildParam(L_EditIn_Text, currentItemAppName);
strAction = "EditInOffice2000('" + currentItemFileUrl + "', '" + currentItemAppName + "', '" + ctx.HttpRoot + "')";
strImagePath = ctx.imagesPath + currentItemIcon;
CAMOpt(m, strDisplayText + " 2000", strAction, strImagePath);
AddCheckinCheckoutMenuItem(m, ctx, currentItemEscapedFileUrl);
retval = true; // No more menu items to be added.
break;
case "test":
// for this example, we will add an item in addition to the default menu items
strDisplayText = "Generate PDF Document";
strAction = "STSNavigate('" + ctx.HttpRoot + "/_layouts/makepdf/makepdfversion.aspx?DocumentName=" + GetFileName(currentItemFileUrl) + "&SourceFolder=" + GetFileName(currentItemEscapedFileUrl) + "&DocumentType=" + docExt + "&RootFolder=" + GetSource() +"')";
strImagePath = ctx.imagesPath + "pdf.gif";
CAMOpt(m, strDisplayText, strAction, strImagePath);
retval = false; // on return, it will continue to add the default items.
break;
case "so on and so on…":
}
return retval;
}
3. Locate the function below:
We need to place the test in an appropriate location within the script, for example
function AddDocLibMenuItems(m, ctx)
{
…
4. Find the statement:
if (currentItemFSObjType != 1)
{
…
(I guess we can have custom menu items for folders, but we mostly want to act on items inside folders…)
5. Insert this code (immediately after if statement above)
Here is where we will call our switch/case to determine whether a custom menu is required. If the menu was added, we will break out and render our custom menu items only.
var retval = AddCustomFolderMenu(currentItemEscapedFileUrl);
if (retval == true)
{
window.onfocus = RefreshOnNextFocus;
return;
// if menu was added, we render and quit.
}
6. Done
Nothing further required… Except for a few folders with the names you have selected. Maybe a browser refresh ;)
Wednesday, August 03, 2005
+Updated TreeView Navigation
Friday, June 10, 2005
+BreadCrumb Links for SPS Areas
Regardless, I haven’t found a similar posting, so here goes
We all know that there is a breadcrumb navigation for the left nav in SPS. Some would like to have it on the top of the page, and this needs to be a custom modification, so here is how to do it:
For this example, I will be replacing the Page Title with the breadcrumb link.
- Open any of the default.aspx pages for an area template in your favourite editor. For example, the SPSTOPIC\default.aspx page.
- Locate the following code that renders the page title:
<tr> <td ID="onetidPageTitle" class="ms-pagetitle">
<SPSWC:CategoryProperty runat="server" Property="Name" /> </td> </tr> - Comment this entry
- Replace the code with the following:
<tr><td><spswc:breadcrumbtrail id="BreadCrumbTrail2"
runat="server" titlelocid="MultiPage_BreadcrumbWebPartTitle"
verticalmode="false" frametype="None"></td></tr>
Note that you will need to give the control a unique ID ("BreadCrumbTrail2") ast here is another control already on the page. - Save the Page and take a look… You should see something like this in place of the Page Title.
- Finally, if you would like to edit the appearance, the classes to modify this are:
.bc-cell
.bc-htable
.bc-trail
.bc-leadin
.ms-vb bc-cell
Back to: Home > Topics > Applications
Wednesday, June 08, 2005
+Force Document Check-out
The issue: Two or more users opening a document for editing simultaneously. This can happen quite easily if users do not follow procedure and is likely to cause some headaches in large environments.
The solution: Easy… Build the procedure into the function so your users don’t have the option to ‘skip’ it.
We need to do two things, both in the ows.js – or customows.js if you have one - Always back-up before editing!
First, we must edit the original call to the editor (Office 2003 application).
Find the AddDoclibMenuItems function as shown below. We need to pass an extra argument, ctx.HttpRoot, to establish the origin when we make the call to editDocumentWithProgID2 function. This is necessary to perform the Check-out. Locate the line and edit as shown below.
function AddDocLibMenuItems(m, ctx)
{
...
strAction = "editDocumentWithProgID2('" + currentItemFileUrl + "', '" + currentItemProgId + "', '" + currentItemOpenControl + "', '" + ctx.HttpRoot + "')";
...
}
Next we analyse the Check-In and Check-Out function to determine how to implement it:
The call to Check-Out an item is like so:
NavigateToCheckinAspx('" + ctx.HttpRoot + "', 'FileName=" + url + "&Checkout=true')";
And the NavigateToCheckinAspx is like so:
function NavigateToCheckinAspx(strHttpRoot, strArgs)
{
SubmitFormPost(strHttpRoot + "/_layouts/" + L_Language_Text + "/Checkin.aspx?" + strArgs + "&Source=" + GetSource());
}
Thus, we can modify the editDocumentWithProgID2 function to perform the checkout before the item is opened. To do this, add the new argument we are passing to the function (strHttpRoot) and add the if statements below to the beginning of the editDocumentWithProgID2 function as shown:
function editDocumentWithProgID2(strDocument, varProgID, varEditor, strHttpRoot)
{
if (currentItemCheckedOutUserId == null)
currentItemCheckedOutUserId = itemTable.COUId;
if (currentItemCheckedOutUserId == "")
{
SubmitFormPost(strHttpRoot + "/_layouts/" + L_Language_Text + "/Checkin.aspx?FileName=" + strDocument + "&Checkout=true&Source=" + GetSource());
}
...
}
The Result: If the document is not checked out, it will automatically be checked out when the user elects to edit the item.
+Document Workspace: Multiple Documents
The problem:
So you have a project that needs to update/modyfy multiple documents. On top of that, they are in various libraries. Do you really want to create a workspace for each one? Definitely not. Need to configure security, possibly event handlers fot the libraries, etc. Unless you have an application to automate this, it's a pain. regardless, it's a pain cause you need multiple workspaces.
Here's a trick: (Note, this is just the idea. I will leave the details of coding to you...)
You need to create a small application - maybe a webpart) to build a list of available files in a given site.
a) The app should be called from the target library. For example, using a new button in the library toolbar that can pass the target url to the application.
b) The App should allow selection from multiple libraries and be able to navigate subfolders to allow the user access to all the files in the current site.
c) for each selected file, you will need to store the full url.
d) Once all files are selected and the user clicks 'ok', the files are copied to the desired Workspace library. At the time of copying the files, you must set the _SourceUrl field to match the origin url. like so:
item.Item("Source Url") = "http://server/sites/site/library/folder/filename.ext"
where item is an SPListItem object, meaning a file in a document library in this case.
if you use an SPFile object, just substitute
file.Item.Item("Source Url") = "http://server/sites/site/library/folder/filename.ext"
So now you have a bunch of files from different sources in one central workspace for editing, and they are all connected to their respective parent objects.
NB: don't forget to check-out the source files when you do this...
Thursday, February 17, 2005
+Display User Site Roles
<html>
<%@ Page language="VB"%>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<HEAD>
<Link REL="stylesheet" Type="text/css" HREF="/_layouts/<%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%>/styles/ows.css">
<script language="vb" runat="server">
Sub Page_Load(obj as object, e as eventargs)
Dim mySite As SPSite = SPControl.GetContextSite(Context)
Dim myWeb As SPWeb = SPControl.GetContextWeb(Context)
Response.Write("<table border=1 class=ms-hovercellactive><tr><td>Site</td><td>User</td><td>Roles</td></tr>")
For Each subSite as SPWeb In mySite.AllWebs
Response.Write("<tr><td>" + subSite.ServerRelativeUrl.ToString + "</td>")
For Each user As SPUser In subSite.Users
Response.Write("<td>" + user.Name + "</td><td>")
For Each role as SPRole In user.Roles
Response.Write( role.Name.ToString + " ")
Next role
Response.Write("</td></tr><td></td>")
Next user
Response.Write("</tr>")
Next subSite
Response.Write("</table>")
End Sub
</script></head><body></body></HTML>
+Display Properties for List (Doclib) Items in Site
<html>
<%@ Page language="VB"%> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<!-- by Manuel Montes -- pastel_de_limon@hotmail.com -->
<HEAD>
<script language="vb" runat="server">
Public outputstring as string
Sub Page_Load(obj as object, e as eventargs)
Dim ThisWeb As SPWeb = SPControl.GetContextWeb(Context)
'ThisWeb.AllowUnsafeUpdates = True
Dim hash As System.Collections.Hashtable
Dim keys As System.Collections.ICollection
Response.Write(ThisWeb.url + "<BR>")
Dim lists as SPListCollection = ThisWeb.GetListsOfType(SPBaseType.DocumentLibrary)
For Each list as SPList In lists
Dim docLibrary As SPDocumentLibrary = CType(list, SPDocumentLibrary)
if not docLibrary.IsCatalog
Response.Write(docLibrary.Title + "<BR>")
For Each item as SPListItem in docLibrary.Items
hash = item.File.Properties
keys = hash.Keys
For Each key As Object In keys
Response.Write(SPEncode.HtmlEncode(key.ToString()) & " : " & SPEncode.HtmlEncode(hash(key.ToString()).ToString()) & ";")
Response.write("<BR>")
Next key
Response.Write("Next Item: <BR>")
Next item
End if
Next list
End Sub
</script></head><body></body></HTML>
Monday, January 31, 2005
+Simple User Welcome for SPS/WSS
Save this page in the layouts/1033 folder and and reference it in a page viewer webpart...
<html> <%@ Page language="C#"%> <%@ Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@
Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint"
%> <%@ Register Tagprefix="WebPartPages"
Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <% SPSite
spServer = SPControl.GetContextSite(System.Web.HttpContext.Current); SPWeb spWeb
= SPControl.GetContextWeb(System.Web.HttpContext.Current); %> <%
string welcome = "Welcome to the " + spWeb.Title + " site. "; string welcome2
= "You are logged on as: " + spWeb.CurrentUser.Name ;
%> <BODY height=40px scroll="no"> <TABLE ><TR><td style="font-family:Arial;
font-size:10pt; font-weight:bold; color:#af0b1c"><%=welcome%> </td></TR> <TR><td
style="font-family:Arial; font-size:10pt; font-weight:bold;
color:#000000"><%=welcome2%> </td></TR></TABLE> </BODY> </HTML>
+Recycle Bin for SPS and WSS Libraries
My first challenge was realising that it's impossible to use an event handler to catch an splistiem on the delete event. Of course... it's quite impossible to act on a deleted item. So this implied a different approach, which was just recently published by Maxim Karpov in the february edition of MSDN Magazine. This solution is great, if you are to use event handlers.
I opted for a different approach. Rather than using event handlers, I built an application that is called via the context menu. The goal here is to replace the Delete command with a call to move the file to a designated "Recycle Bin" library.
I have a demo video, about 1.5MB which shows how this application works. If anyone likes I can email it. I will gladly share this.
One challenge I have found is in retaining the document metadata, such as the last edited time, or modified time. Also, for deleted folders, I have not been able to access these properties. Nonetheless, this is far better than an item-level restore from SQL!!!
The main advantage of this solution over the event-driven solution is that only ONE recycle bin pre site is required, and you do not need to keep a mirror of each library.
The main advantage of the event-driven solution is that it catched delete events in explorer view also, whereas this solution does not.
There are several security checks performed by the application to verify delete/restore permissions, and this will also display user friendly messages for checked-out items etc. while the standard WSS redirect to an error page is rather abrupt and rude.
Looking to finish up some minor glitches in the next weeks.
Thursday, January 27, 2005
+Library TreeView Navigation Control for SPS and WSS
Document Library Tree View navigation Control
This control is a explorer tree-type navigator that you can stick inyour sharepoint left navbar.To implement this solution, follow these steps:
- Create a new Web Control Libray project in vb.net
- Paste the source code below - also available here.
- Generate a key file (sn -k {path}\treenav.snk) and reference it in the assemblyinfo.vb as shown here:
<Assembly: AssemblyKeyFile("c:\keys\libtreenav.snk")>
- Edit the version number for the assembly ex:
<Assembly: AssemblyVersion("1.1.1.0")>
- Recompile the code
- To trust the assembly, add it to the GAC OR copy it to the bin folder and add a safecontrol entry in the web.config like this:
<SafeControl Assembly="LibraryTreeView, Version=1.1.1.0, Culture=neutral, PublicKeyToken=db9e239c2db54b1b" Namespace="LibraryTreeView" TypeName="*" Safe="True" />
- Restart iis.
Note: You can determine the assembly's PKT by viewing the item properties from the GAC (C:\windows\assembly folder)To render the control:
Next, edit the pages
- In your default.aspx and in the allitems.aspx of the doclib list template, insert this directive:
%@ Register Tagprefix="LTV" Namespace="LibraryTreeView" Assembly="LibraryTreeView, Version=,Culture=neutral, PublicKeyToken= yourassemlblypkt" %>
- The control uses Geir Landro's dtree javascript ( www.destroydrop.com/tree ) so you need to download this, I place the dtree.js in layouts\1033 and used layouts\1033\images\img to store the dtree images for this.(you can put them wherever you want)
- Reference the script and the css file in your default.aspx and allitems.aspx
<link rel="StyleSheet" href="/_layouts/1033/styles/dtree.css" type="text/css" />
<script type="text/javascript" src="/_layouts/1033/dtree.js"></script>
- Place the control into the navigation Table, best right at the top, before the Documents navbar item.
<LTV:TreeViewNav id="LTVNav1" runat="server" />
- You will also need to customize the dtree.css file to control the boundaries of the navigator. If you do not set boundaries on the control, as you expand the tree, your navigation column will also expand and the web part page will shrink.
You can do it like this, for example. You can read about controlling scrollbars to learn how to customise this to your liking.
in the dtree.css file, edit this class:
.dtree {
font-family: Arial;
font-size: 8pt;
color: #000000;
white-space: nowrap;
overflow-x: scroll;
overflow-y: hidden;
height: auto;
width: 120px;
SCROLLBAR-FACE-COLOR: #ffffff;
SCROLLBAR-ARROW-COLOR: #AF0B1C;
SCROLLBAR-TRACK-COLOR: #ffffff;
SCROLLBAR-BASE-COLOR: #ffffff;
scrollbar-shadow-color: #ffffff;
scrollbar-darkshadow-color: #ffffff;
scrollbar-highlight-color: none;
scrollbar-3dlight-color:#ffffff;
}
To open the linked documents in a new window, change (add) the following italicised code in the dtree.js
if ((node.icon == this.icon.folder) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
}else{
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" target="new" href="' + node.url + '"';}
© 2004 Manuel Montes
+TreeView Control source code
'This control was written by Manuel Montes. manuel.montes@cibc.com
'The dTree javascript referenced in this control is written by Geir Landro
#End Region
Imports System.ComponentModel
Imports System.Web.UI
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}:TreeViewNav runat=server></{0}:TreeViewNav>")> Public Class TreeViewNav
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Public htmlstring As String = "" 'used to build the javascript
Public Index As Integer 'unique identifier for each node
Public TempIndex As Integer 'holds current node ID
Public SiteName As String
Public CurrentLib As SPDocumentLibrary
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter
Dim CurrentWeb As SPWeb = SPControl.GetContextWeb(Context)
Dim ParentSite As SPSite = CurrentWeb.Site ' need site to work with lists and to set the following property
ParentSite.CatchAccessDeniedException = False 'do not prompt for authentication if no access
SiteName = "LibTree" & CurrentWeb.CurrentUser.ID.ToString
Dim Libraries As SPListCollection = CurrentWeb.GetListsOfType(SPBaseType.DocumentLibrary)
Libraries.ListsForCurrentUser = True
Dim Library As SPDocumentLibrary
Dim SubIndex As Integer = 0 ' Holds the level of subs
Try
Index = 0
htmlstring = "<div class=""dtree""><p><a href=""javascript: " & SiteName &amp; ".openAll();"">Open All</a> <a href=""javascript: " & SiteName &amp; ".closeAll();"">Close All</a></p>"
htmlstring += "<script type=""text/javascript"">"
htmlstring += SiteName + " = new dTree('" + SiteName + "');"
htmlstring += SiteName + ".add(0,-1,'Site Libraries');"
'users in Readers group do not have browse directory perm used in web.subfolders cast so implemented lists instead.
For Each Library In Libraries 'iterate all the site document libraries
'If Library.Permissions.DoesUserHavePermissions(SPRights.ViewPages) And Library.Permissions.DoesUserHavePermissions(SPRights.ViewListItems) Then
If Not Library.Title = "Recycled" And Not Library.IsCatalog And Not Library.BaseTemplate = SPListTemplateType.PictureLibrary Then
CurrentLib = Library
Dim NewUrl As String() = Library.DefaultViewUrl.Split("/")
Dim CurrentFolder As SPFolder = CurrentWeb.GetFolder(NewUrl.GetValue(NewUrl.Length - 3))
Index = Index + 1
htmlstring += SiteName & ".add(" & Index & ",0,'" & CurrentFolder.Name & "','" & CurrentFolder.ServerRelativeUrl &amp; "','','','_layouts/1033/images/img/folder.gif');"
SubIndex = Index
If CurrentFolder.SubFolders.Count > 0 Then
ListSubFolders(CurrentFolder, SubIndex)
End If
If CurrentFolder.Files.Count > 0 Then
ListFiles(CurrentFolder, SubIndex)
End If
End If
'End If
'SubIndex = 0
Next
'htmlstring += "LibTree.config.folderlinks = ""False"";"
htmlstring += "document.write(" & SiteName &amp; ");"
htmlstring += "<"
htmlstring += "/script"
htmlstring += "></div>"
output.Write(htmlstring)
Libraries = Nothing
Library = Nothing
'CurrentWeb.Close()
Catch UnauthorizedAccessException As Exception
output.Write(UnauthorizedAccessException.Message.ToString)
End Try
End Sub
Sub ListSubFolders(ByVal ThisFolder As SPFolder, ByVal ParentIndex As Integer)
Dim Subfolder As SPFolder
'if there are subfolders, we iterate these, else we write the current folder to the tree and exit the sub
If ThisFolder.SubFolders.Count > 0 Then
For Each Subfolder In ThisFolder.SubFolders 'iterate current folder subfolders
If Subfolder.Name <> "Forms" And Subfolder.Name.Chars(0) <> "_" Then
Index = Index + 1
htmlstring += SiteName & ".add(" & Index & "," & ParentIndex & ",'" & Subfolder.Name &amp; "','" & Subfolder.ServerRelativeUrl &amp; "','','','_layouts/1033/images/img/folder.gif');"
'if this folder has subs we must enter the sub again and start again
If Subfolder.SubFolders.Count > 0 Then
TempIndex = Index
ListSubFolders(Subfolder, Index)
If Subfolder.Files.Count > 0 Then
ListFiles(Subfolder, TempIndex)
End If
Else
'Add the current Folder's files to the tree.
If Subfolder.Files.Count > 0 Then
ListFiles(Subfolder, Index)
End If
End If
End If
Next
Else
' last subfolder in current branch; add current folder and its files to the tree and exit the sub
Index = Index + 1
htmlstring += SiteName & ".add(" & Index & "," & TempIndex & ",'" & ThisFolder.Name &amp; "','" & ThisFolder.ServerRelativeUrl &amp; "','','','_layouts/1033/images/img/folder.gif');"
If ThisFolder.Files.Count > 0 Then
ListFiles(ThisFolder, Index)
End If
End If
End Sub
Sub ListFiles(ByVal Folder As SPFolder, ByVal SubInd As Integer)
Try
If CurrentLib.EnableModeration = True Then
For Each objFile As SPFile In Folder.Files 'iterate files in current folder
If objFile.Item.ModerationInformation.Status = SPModerationStatusType.Approved Then
Index = Index + 1
htmlstring += SiteName & ".add(" & Index & "," & SubInd &amp; ",'" & objFile.Name & "','" & objFile.ServerRelativeUrl &amp; "','" & objFile.Name.ToString &amp; "','','_layouts/1033/images/img/" & GetFileImage(objFile.Name) & "');"
End If
Next
Else
For Each objFile As SPFile In Folder.Files 'iterate files in current folder
Index = Index + 1
htmlstring += SiteName & ".add(" & Index & "," & SubInd &amp; ",'" & objFile.Name & "','" & objFile.ServerRelativeUrl &amp; "','" & objFile.Name.ToString &amp; "','','_layouts/1033/images/img/" & GetFileImage(objFile.Name) & "');"
Next
End If
Catch FileList As Exception
End Try
End Sub
Function GetFileImage(ByVal FileName)
' extract file extension from filename
Dim FileExt As String = FileName.Substring(FileName.Length - 3, 3)
Dim ImageFile As String
Select Case FileExt
'files are in the images\img folder. add new for new file types as needed.
Case "doc"
ImageFile = "doc16.gif"
Case "xls"
ImageFile = "xls16.gif"
Case "ppt"
ImageFile = "ppt16.gif"
Case "vsd"
ImageFile = "vsd16.gif"
Case "mpp"
ImageFile = "mpp16.gif"
Case "pdf"
ImageFile = "pdf.gif"
Case "txt"
ImageFile = "txt16.gif"
Case "xml"
ImageFile = "xml16.gif"
Case "htm"
ImageFile = "htm16.gif"
Case Else
ImageFile = "page.gif"
End Select
Return ImageFile
End Function
End Class
