/// <summary> Perform all the work of adding to the response stream back to the web user </summary>
/// <param name="Navigation_Place_Holder"> Place holder is used to add more complex server-side objects during execution</param>
/// <param name="TOC_Place_Holder"> Place holder is used to add more complex server-side objects during execution</param>
/// <param name="Main_Place_Holder"> Place holder is used to add more complex server-side objects during execution</param>
/// <param name="myUfdcUploadPlaceHolder"> Place holder is used to add more complex server-side objects during execution </param>
/// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
/// <remarks> Since this class writes all the output directly to the response stream, this method simply returns, without doing anything</remarks>
public override void Add_Controls(PlaceHolder Navigation_Place_Holder,
PlaceHolder TOC_Place_Holder,
PlaceHolder Main_Place_Holder,
PlaceHolder myUfdcUploadPlaceHolder, Custom_Tracer Tracer)
{
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Rendering the requested data in html format");
// Render HTML and add controls depending on the current mode
switch (currentMode.Mode)
{
#region Start adding HTML and controls for SIMPLE WEB CONTENT TEXT mode
case Display_Mode_Enum.Simple_HTML_CMS:
subwriter = new Web_Content_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, htmlBasedContent, siteMap);
// Add any necessary controls
if (siteMap != null)
{
((Web_Content_HtmlSubwriter)subwriter).Add_Controls(Main_Place_Holder, Tracer);
}
break;
#endregion
#region Start adding HTML and controls for MY SOBEK mode
case Display_Mode_Enum.My_Sobek:
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building the my sobek HTML subwriter");
// Build the my sobek subwriter
mySobekWriter = new MySobek_HtmlSubwriter( results_statistics, paged_results, codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, currentItem, aggregationAliases, webSkins, currentUser, ipRestrictionInfo, iconList, urlPortals, statsDateRange, thematicHeadings, Tracer);
subwriter = mySobekWriter;
mySobekWriter.Hierarchy_Object = hierarchyObject;
mySobekWriter.Skin = htmlSkin;
mySobekWriter.Mode = currentMode;
// If the my sobek writer contains pop up forms, add the header here first
if ( mySobekWriter.Contains_Popup_Forms )
{
StringBuilder header_builder = new StringBuilder();
StringWriter header_writer = new StringWriter(header_builder);
Display_Header(header_writer, Tracer);
LiteralControl header_literal = new LiteralControl(header_builder.ToString());
Main_Place_Holder.Controls.Add(header_literal);
}
// Add any necessary controls
mySobekWriter.Add_Controls(Main_Place_Holder, myUfdcUploadPlaceHolder, Tracer);
// Finally, add the footer
if (mySobekWriter.Contains_Popup_Forms)
{
StringBuilder footer_builder = new StringBuilder();
StringWriter footer_writer = new StringWriter(footer_builder);
Display_Footer(footer_writer, Tracer);
LiteralControl footer_literal = new LiteralControl(footer_builder.ToString());
Main_Place_Holder.Controls.Add(footer_literal);
}
break;
#endregion
#region Start adding HTML and controls for ADMINISTRATIVE mode
case Display_Mode_Enum.Administrative:
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building the admin HTML subwriter");
// Build the my sobek subwriter
adminWriter = new Admin_HtmlSubwriter(results_statistics, paged_results, codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, currentItem, aggregationAliases, webSkins, currentUser, ipRestrictionInfo, iconList, urlPortals, statsDateRange, thematicHeadings, Tracer);
subwriter = adminWriter;
adminWriter.Hierarchy_Object = hierarchyObject;
adminWriter.Skin = htmlSkin;
adminWriter.Mode = currentMode;
// If the my sobek writer contains pop up forms, add the header here first
if (adminWriter.Contains_Popup_Forms)
{
StringBuilder header_builder = new StringBuilder();
StringWriter header_writer = new StringWriter(header_builder);
Display_Header(header_writer, Tracer);
LiteralControl header_literal = new LiteralControl(header_builder.ToString());
Main_Place_Holder.Controls.Add(header_literal);
}
// Add any necessary controls
adminWriter.Add_Controls(Main_Place_Holder, myUfdcUploadPlaceHolder, Tracer);
// Finally, add the footer
if (adminWriter.Contains_Popup_Forms)
{
StringBuilder footer_builder = new StringBuilder();
StringWriter footer_writer = new StringWriter(footer_builder);
Display_Footer(footer_writer, Tracer);
LiteralControl footer_literal = new LiteralControl(footer_builder.ToString());
Main_Place_Holder.Controls.Add(footer_literal);
}
break;
#endregion
#region Start adding HTML and add controls for RESULTS mode
case Display_Mode_Enum.Results:
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building the Search Results HTML Subwriter");
// Build the results subwriter
resultsWriter = new Search_Results_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser );
subwriter = resultsWriter;
resultsWriter.Hierarchy_Object = hierarchyObject;
resultsWriter.Skin = htmlSkin;
resultsWriter.Mode = currentMode;
// Make sure the corresponding 'search' is the latest
currentMode.Mode = Display_Mode_Enum.Search;
HttpContext.Current.Session["LastSearch"] = currentMode.Redirect_URL();
currentMode.Mode = Display_Mode_Enum.Results;
// Add the controls and save the tree info in the session state
//System.Web.HttpContext.Current.Session["tree_info"] = resultsWriter.Add_Controls(Main_Place_Holder, Tracer, null);
resultsWriter.Add_Controls(Main_Place_Holder, Tracer, null);
break;
#endregion
#region Add HTML and controls for PUBLIC FOLDER mode
case Display_Mode_Enum.Public_Folder:
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building the Public Folder HTML Subwriter");
// Build the subwriter for this case
subwriter = new Public_Folder_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser, publicFolder)
{Hierarchy_Object = hierarchyObject, Skin = htmlSkin, Mode = currentMode};
// Also try to add any controls
((Public_Folder_HtmlSubwriter)subwriter).Add_Controls(Main_Place_Holder, Tracer, null );
break;
#endregion
#region Add HTML and controls for COLLECTION VIEWS
case Display_Mode_Enum.Search:
case Display_Mode_Enum.Aggregation_Home:
case Display_Mode_Enum.Aggregation_Browse_Info:
case Display_Mode_Enum.Aggregation_Browse_By:
case Display_Mode_Enum.Aggregation_Browse_Map:
case Display_Mode_Enum.Aggregation_Private_Items:
case Display_Mode_Enum.Aggregation_Item_Count:
case Display_Mode_Enum.Aggregation_Usage_Statistics:
case Display_Mode_Enum.Aggregation_Admin_View:
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building the Collection HTML Subwriter");
// Build the subwriter for this case
subwriter = new Aggregation_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, translator, thisBrowseObject, results_statistics, paged_results, codeManager, itemList, thematicHeadings, currentUser, ipRestrictionInfo, htmlBasedContent, Tracer);
// Also try to add any controls
((Aggregation_HtmlSubwriter) subwriter).Add_Controls(Main_Place_Holder, Tracer);
break;
#endregion
#region Start adding HTML and add controls for ITEM DISPLAY mode
case Display_Mode_Enum.Item_Display:
if (!currentMode.Invalid_Item)
{
if (currentItem == null)
return;
//SobekCM.Library.ItemViewer.Viewers.abstractItemViewer page_viewer = null;
//// Set the code for bib level mets to show the volume list by dwe
//if ((currentItem.METS.RecordStatus == METS_Record_Status.BIB_LEVEL) && (currentMode.ViewerCode.Length == 0))
//{
// currentMode.ViewerCode = "BI1";
//}
//// Get the valid viewer code
//Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Getting the appropriate item viewer");
//if (currentMode.ViewerCode != "TS")
//{
// if ((currentMode.ViewerCode.Length == 0) && (currentMode.Coordinates.Length > 0))
// {
// currentMode.ViewerCode = "GM";
// }
// currentMode.ViewerCode = currentItem.Behaviors.Get_Valid_Viewer_Code(currentMode.ViewerCode, currentMode.Page);
// SobekCM.Resource_Object.Behaviors.View_Object viewObject = currentItem.Behaviors.Get_Viewer(currentMode.ViewerCode);
// page_viewer = SobekCM.Library.ItemViewer.Viewers.ItemViewer_Factory.Get_Viewer(viewObject, currentItem.Bib_Info.Type.Type.ToUpper());
// Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Created " + page_viewer.GetType().ToString().Replace("SobekCM.Library.ItemViewer.Viewers.", ""));
// // Assign the rest of the information, if a page viewer was created
// if (page_viewer != null)
// {
// page_viewer.CurrentItem = currentItem;
// page_viewer.CurrentMode = currentMode;
// page_viewer.Redirect += new SobekCM.Library.ItemViewer.Viewers.Redirect_Requested(itemWriter_Redirect);
// // If this was the citation viewer, pass in the translation object
// string type = page_viewer.GetType().ToString();
// if (page_viewer.GetType().ToString() == "SobekCM.Library.ItemViewer.Viewers.Citation_ItemViewer")
// {
// ((SobekCM.Library.ItemViewer.Viewers.Citation_ItemViewer)page_viewer).Translator = translator;
// if ( currentUser != null )
// {
// ((SobekCM.Library.ItemViewer.Viewers.Citation_ItemViewer)page_viewer).User_Can_Edit_Item = currentUser.Can_Edit_This_Item(currentItem);
// }
// }
// }
//}
// Determine the browser
bool ie = (currentMode.Browser_Type.IndexOf("IE") >= 0 );
bool show_toc = false;
if (HttpContext.Current.Session["Show TOC"] != null)
{
Boolean.TryParse(HttpContext.Current.Session["Show TOC"].ToString(), out show_toc);
}
// Check that this item is not checked out by another user
bool itemCheckedOutByOtherUser = false;
if (currentItem.Behaviors.CheckOut_Required)
{
if (!checkedItems.Check_Out(currentItem.Web.ItemID, HttpContext.Current.Request.UserHostAddress))
{
itemCheckedOutByOtherUser = true;
}
}
// Check to see if this is IP restricted
string restriction_message = String.Empty;
if (currentItem.Behaviors.IP_Restriction_Membership > 0)
{
if (HttpContext.Current != null)
{
int user_mask = (int)HttpContext.Current.Session["IP_Range_Membership"];
int comparison = currentItem.Behaviors.IP_Restriction_Membership & user_mask;
if (comparison == 0)
{
int restriction = currentItem.Behaviors.IP_Restriction_Membership;
int restriction_counter = 0;
while (restriction % 2 != 1)
{
restriction = restriction >> 1;
restriction_counter++;
}
restriction_message = ipRestrictionInfo[restriction_counter].Item_Restricted_Statement;
}
}
}
// Create the item viewer writer
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Building Item Writer");
itemWriter = new Item_HtmlSubwriter(currentItem, currentPage, currentUser,
codeManager, translator, show_toc, (SobekCM_Library_Settings.JP2_Server.Length > 0),
currentMode, hierarchyObject, restriction_message, itemsInTitle, Tracer);
subwriter = itemWriter;
itemWriter.Mode = currentMode;
itemWriter.Skin = htmlSkin;
itemWriter.Item_Checked_Out_By_Other_User = itemCheckedOutByOtherUser;
// Add the navigation part to this form
itemWriter.Add_Nav_Bar_Menu_Section(Navigation_Place_Holder, ie, Tracer);
//if (itemWriter.PageViewer != null)
//{
// Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Allowing page viewer to add left navigation bar section to <i>navigationPlaceHolder</i>");
// itemWriter.Nav_Bar_Menu_Section_Added = itemWriter.PageViewer.Add_Nav_Bar_Menu_Section(Navigation_Place_Holder, ie, Tracer);
//}
// Add the TOC section
Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Allowing item viewer to add table of contents to <i>tocPlaceHolder</i>");
itemWriter.Add_Standard_TOC(TOC_Place_Holder, Tracer);
// Add the main viewer section
itemWriter.Add_Main_Viewer_Section(Main_Place_Holder, Tracer);
}
break;
#endregion
default:
Tracer.Add_Trace("Html_MainWriter.Add_Html_And_Controls", "No controls or html added to page");
break;
}
}