/// <summary> Saves the data entered by the user through one page of this template to the provided bibliographic object </summary> /// <param name="Bib"> Object into which to save the user-entered data </param> /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param> /// <param name="Page">Page number of the template to save</param> public void Save_To_Bib(SobekCM_Item Bib, User_Object Current_User, int Page) { // If this is not a valid page, just return if ((Page < 1) || (Page > templatePages.Count)) { return; } // Get the page Template_Page thisPage = templatePages[Page - 1]; // Go through each of the elements and prepare to save foreach (abstract_Element thisElement in thisPage.Panels.SelectMany(ThisPanel => ThisPanel.Elements)) { thisElement.Prepare_For_Save(Bib, Current_User); } // Now, step through and save the constants foreach (abstract_Element thisElement in constants) { thisElement.Save_Constant_To_Bib(Bib); } // Now, step through and save them all foreach (abstract_Element thisElement in thisPage.Panels.SelectMany(ThisPanel => ThisPanel.Elements)) { thisElement.Save_To_Bib(Bib); } }
/// <summary> Displays one page worth of elements from an item as HTML using this template </summary> /// <param name="Output">Text writer to write all of the HTML for this template</param> /// <param name="Bib">Bibliographic identifier for the item to display</param> /// <param name="Skin_Code">Current base skin code</param> /// <param name="isMozilla">Flag indicates if this is Mozilla</param> /// <param name="Current_User"> Current user, which can dictate how certain elements within this template render</param> /// <param name="CurrentLanguage"> Current language of the user interface </param> /// <param name="Translator"> Language support object is used to help translate common user interface terms into the current language</param> /// <param name="Base_URL"> Base URL for the current request</param> /// <param name="page">Page number to display from this template</param> /// <returns>HTML code for any pop-up forms, which must be placed in a different DIV on the web page</returns> public string Render_Template_HTML(TextWriter Output, SobekCM_Item Bib, string Skin_Code, bool isMozilla, User_Object Current_User, Web_Language_Enum CurrentLanguage, Language_Support_Info Translator, string Base_URL, int page) { // If this is not a valid page, just return if ((page < 1) || (page > templatePages.Count)) { return(String.Empty); } // Start to build the return value StringBuilder returnValue = new StringBuilder(); // Get the page Template_Page thisPage = templatePages[page - 1]; // Set the current base url on all the elements foreach (abstract_Element thisElement in templatePages.SelectMany(thisPage2 => thisPage2.Panels.SelectMany(thisPanel => thisPanel.Elements))) { thisElement.Set_Base_URL(Base_URL); } // Now, render these pages Output.WriteLine("<!-- Begin to render '" + Title + "' template -->"); Output.WriteLine("<table cellpadding=\"4px\" border=\"0px\" cellspacing=\"0px\" class=\"SobekEditItemSection\" >"); Output.WriteLine(); bool first_title = true; foreach (Template_Panel thisPanel in thisPage.Panels) { Output.WriteLine(" <!-- '" + thisPanel.Title + "' Panel -->"); Output.WriteLine(" <tr align=\"left\">"); if (first_title) { Output.WriteLine(" <td colspan=\"3\" class=\"SobekEditItemSectionTitle_first\"> " + thisPanel.Title + "</td>"); first_title = false; } else { Output.WriteLine(" <td colspan=\"3\" class=\"SobekEditItemSectionTitle\"> " + thisPanel.Title + "</td>"); } Output.WriteLine(" </tr>"); Output.WriteLine(); foreach (abstract_Element thisElement in thisPanel.Elements) { thisElement.Render_Template_HTML(Output, Bib, Skin_Code, isMozilla, returnValue, Current_User, CurrentLanguage, Translator, Base_URL); } } Output.WriteLine("</table>"); Output.WriteLine("<br />"); return(returnValue.ToString()); }
/// <summary> Adds a new template page to the collection of pages contained within this template </summary> /// <param name="newPage"> New template page to add </param> internal void Add_Page(Template_Page newPage) { templatePages.Add(newPage); }
/// <summary> Adds a new template page to the collection of pages contained within this template </summary> /// <param name="NewPage"> New template page to add </param> internal void Add_Page(Template_Page NewPage) { templatePages.Add(NewPage); }
private void process_inputs(XmlNodeReader nodeReader, Template thisTemplate, bool exclude_divisions) { // Keep track of the current pages and panels Template_Page currentPage = null; Template_Panel currentPanel = null; bool inPanel = false; // Read all the nodes while (nodeReader.Read()) { // Get the node name, trimmed and to upper string nodeName = nodeReader.Name.Trim().ToUpper(); // If this is the inputs or constant start tag, return if (((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeName == "INPUTS")) || ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name == "CONSTANTS"))) { return; } // If this is the beginning tag for an element, assign the next values accordingly if (nodeReader.NodeType == XmlNodeType.Element) { // Does this start a new page? if (nodeName == "PAGE") { // Set the inPanel flag to false inPanel = false; // Create the new page and add to this template currentPage = new Template_Page(); thisTemplate.Add_Page(currentPage); } // Does this start a new panel? if ((nodeName == "PANEL") && (currentPage != null)) { // Set the inPanel flag to true inPanel = true; // Create the new panel and add to the current page currentPanel = new Template_Panel(); currentPage.Add_Panel(currentPanel); } // Is this a name element? if ((nodeName == "NAME") && (currentPage != null)) { // Get the text string title = read_text_node(nodeReader); // Set the name for either the page or panel if (inPanel) { currentPanel.Title = title; } else { currentPage.Title = title; } } // Is this a name element? if ((nodeName == "INSTRUCTIONS") && (currentPage != null)) { // Get the text string instructions = read_text_node(nodeReader); // Set the name for either the page or panel if (!inPanel) { currentPage.Instructions = instructions; } } // Is this a new element? if ((nodeName == "ELEMENT") && (nodeReader.HasAttributes) && (currentPanel != null)) { abstract_Element currentElement = process_element(nodeReader, thisTemplate.InputPages.Count); if ((currentElement != null) && ((!exclude_divisions) || (currentElement.Type != Element_Type.Structure_Map))) { currentPanel.Add_Element(currentElement); } } } } }
private void process_inputs( XmlNodeReader nodeReader, CompleteTemplate ThisCompleteTemplate, bool exclude_divisions ) { // Keep track of the current pages and panels Template_Page currentPage = null; Template_Panel currentPanel = null; bool inPanel = false; // Read all the nodes while ( nodeReader.Read() ) { // Get the node name, trimmed and to upper string nodeName = nodeReader.Name.Trim().ToUpper(); // If this is the inputs or constant start tag, return if ((( nodeReader.NodeType == XmlNodeType.EndElement ) && ( nodeName == "INPUTS" )) || (( nodeReader.NodeType == XmlNodeType.Element ) && ( nodeReader.Name == "CONSTANTS"))) { return; } // If this is the beginning tag for an element, assign the next values accordingly if ( nodeReader.NodeType == XmlNodeType.Element ) { // Does this start a new page? if ( nodeName == "PAGE" ) { // Set the inPanel flag to false inPanel = false; // Create the new page and add to this CompleteTemplate currentPage = new Template_Page(); ThisCompleteTemplate.Add_Page( currentPage ); } // Does this start a new panel? if (( nodeName == "PANEL" ) && ( currentPage != null )) { // Set the inPanel flag to true inPanel = true; // Create the new panel and add to the current page currentPanel = new Template_Panel(); currentPage.Add_Panel( currentPanel ); } // Is this a name element? if ((nodeName == "NAME") && (currentPage != null)) { // Get the text string title = read_text_node( nodeReader ); // Set the name for either the page or panel if ( inPanel ) { currentPanel.Title = title; } else { currentPage.Title = title; } } // Is this a name element? if ((nodeName == "INSTRUCTIONS") && (currentPage != null)) { // Get the text string instructions = read_text_node(nodeReader); // Set the name for either the page or panel if (!inPanel) { currentPage.Instructions = instructions; } } // Is this a new element? if ((nodeName == "ELEMENT") && (nodeReader.HasAttributes) && (currentPanel != null)) { abstract_Element currentElement = process_element( nodeReader, ThisCompleteTemplate.InputPages.Count ); if (( currentElement != null ) && (( !exclude_divisions ) || ( currentElement.Type != Element_Type.Structure_Map ))) currentPanel.Add_Element( currentElement ); } } } }