In-line File Uploader Update
Two nights ago I posted about my In-line File Uploader addition for Community Server 2.0. Over the weekend I had less time that I thought I would to keep working on it, but I did fix one fairly important problem.
The way I had it written the extra tab that appeared when writing a new post was second - and this caused other tabs to appear incorrectly. A bit of digging around showed me it was because the code-behind for that page had some hard coded tab indexes (tsk tsk, for shame).
So I've updated CreateEditBlogPost.ascx.cs with a fix so that it's not as hard coded anymore. That is, it's not hard coded to a set of integer array indexes, it's now depending on control id's, which is at least better :)
Here's a quick rundown on the code that I changed. Before, we had code like this:
const int attachTabIndex = 1;
const int inkTabIndex = 2;
const int videoTabIndex = 3;
void Bind()
{
EditorTabs.Tabs[attachTabIndex].Visible = this.EnableAttachments;
if(this.EnableInkSupport)
{
inkWeb.Enabled = true;
inkWeb.RegisterLinkButton(this.PostButton);
}
else
{
inkWeb.Enabled = false;
}
EditorTabs.Tabs[inkTabIndex].Visible = inkWeb.Enabled;
//etc etc - a whole heap more code here
}
And I changed it to this:
protected CA.PageView PostAttachmentsPage;
protected CA.PageView WhiteBoardPage;
protected CA.PageView VideoPage;
void Bind()
{
CA.TabStripTab attachmentsTab = EditorTabs.FindItemById(PostAttachmentsPage.ID);
CA.TabStripTab inkTab = EditorTabs.FindItemById(WhiteBoardPage.ID);
CA.TabStripTab videoTab = EditorTabs.FindItemById(VideoPage.ID);
attachmentsTab.Visible = this.EnableAttachments;
if(this.EnableInkSupport)
{
inkWeb.Enabled = true;
inkWeb.RegisterLinkButton(this.PostButton);
}
else
{
inkWeb.Enabled = false;
}
inkTab.Visible = inkWeb.Enabled;
//etc etc - a whole heap more code here
}
Basically, the content of each tab is held in a </componentart:pageview> which has a specific ID. These can be used to look up a specific tab in the tabStrip's tabs collection.
But to make this work, the tabs themselves need a specific ID too - and currently as the default code stands, each tab has ID of String.Empty - whoops :)
So a quick change to tabData.xml (the file which defines the tabs that will appear) to define the IDs, and we're done:
<SiteMap>
<item Text="Post" KeyboardShortcut = "Alt+C" PageViewId = "ContentPage" id="ContentPage" />
<item Text="File Uploads" KeyboardShortcut = "Alt+U" PageViewID = "FileUploadPage" id="FileUploadPage" />
<item Text="Post Attachments" KeyboardShortcut = "Alt+A" PageViewId = "PostAttachmentsPage" id="PostAttachmentsPage" />
<item Text="WhiteBoard" KeyboardShortcut = "Alt+W" PageViewId = "WhiteBoardPage" id="WhiteBoardPage" />
<item Text="Video" KeyboardShortcut = "Alt+V" PageViewId = "VideoPage" id="VideoPage" />
<item Text="Options" KeyboardShortcut = "Alt+M" PageViewId = "PostOptionsPage" id="PostOptionsPage" />
<item Text="Advanced Options" KeyboardShortcut = "Alt+S" PageViewId = "PostAdvancedOptionsPage" id="PostAdvancedOptionsPage" />
<item Text = "Preview" ClientSideCommand="SelectPreview()" PageViewId = "PreViewPage" id="PreViewPage" />
</SiteMap>
The download for the mod has now been updated to include this code fix.