/// <summary> Constructor for a new instance of the Metadata_Browse_AggregationViewer class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Aggregation"> Current item aggregation object to display </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Metadata_Browse_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode) { string defaultBrowseBy = Current_Aggregation.Default_BrowseBy; // If there is not info browse mode listed, use the default if (Current_Mode.Info_Browse_Mode.Length == 0) { Current_Mode.Info_Browse_Mode = defaultBrowseBy; } if ((Current_Mode.Info_Browse_Mode.Length == 0) && (Current_Aggregation.Has_Browse_By_Pages)) { Current_Mode.Info_Browse_Mode = Current_Aggregation.Browse_By_Pages(Current_Mode.Language)[0].Code; } // Get this browse browseObject = Current_Aggregation.Get_Browse_Info_Object(Current_Mode.Info_Browse_Mode); // Was this a metadata browseby, or just a static html? if ((browseObject == null) || (browseObject.Source != Item_Aggregation_Child_Page.Source_Type.Static_HTML)) { // Determine the correct metadata code string metadata_code = Current_Mode.Info_Browse_Mode.Trim().Replace("_", " "); Current_Mode.Info_Browse_Mode = metadata_code; // Only get values if there was a metadata code if (metadata_code.Length > 0) { // Check the cache for this value List <string> cacheInstance = Cached_Data_Manager.Retrieve_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer); if (cacheInstance != null) { results = cacheInstance; } else { results = SobekCM_Database.Get_Item_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer); Cached_Data_Manager.Store_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, results, Tracer); } } } }
/// <summary> Add the HTML to be displayed in the search box </summary> /// <param name="Output"> Textwriter to write the HTML for this viewer</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public override void Add_Search_Box_HTML(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Advanced_Search_AggregationViewer.Add_Search_Box_HTML", "Adding html for search box"); } // Get the list of years for this aggregation string aggrCode = currentCollection.Code.ToLower(); string key = aggrCode + "_YearRanges"; List <int> yearRange = HttpContext.Current.Cache[key] as List <int>; if (yearRange == null) { yearRange = new List <int>(); List <string> yearRangeString = SobekCM_Database.Get_Item_Aggregation_Metadata_Browse(aggrCode, "Temporal Year", Tracer); foreach (string thisYear in yearRangeString) { int result; if (Int32.TryParse(thisYear, out result)) { yearRange.Add(result); } } HttpContext.Current.Cache.Insert(key, yearRange, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); } string searchLanguage = "Search for:"; string inLanguage = "in"; string searchButtonText = "Search"; string searchOptions = "Search Options"; string precision = "Precision"; string contains_exactly = "Contains exactly the search terms"; string contains_any_form = "Contains any form of the search terms"; const string CONTAINS_MEANING = "Contains the search term or terms of similar meaning"; //string select_collect_groups = "Select collection groups to include in search:"; //string select_collect = "Select collections to include in search:"; //string select_subcollect = "Select subcollections to include in search:"; if (currentMode.Language == Web_Language_Enum.Spanish) { searchLanguage = "Búsqueda de la:"; inLanguage = "en"; searchButtonText = "Buscar"; searchOptions = "Opciones de Búsqueda"; precision = "Precisión"; contains_exactly = "Contiene exactamente los términos de búsqueda"; contains_any_form = "Contiene todas las formas de los términos de búsqueda"; } if (currentMode.Language == Web_Language_Enum.French) { searchLanguage = "Recherche de:"; inLanguage = "en"; //select_collect_groups = "Choisir les group de collection pour inclure dans votre recherche:"; //select_collect = "Choisir les collections pour inclure dans votre recherche:"; //select_subcollect = "Choisir les souscollections pour inclure dans votre recherche:"; searchButtonText = "Search"; } // Now, populate the search terms, if there was one or some string text1 = String.Empty; string text2 = String.Empty; string text3 = String.Empty; string text4 = String.Empty; if (currentMode.Search_String.Length > 0) { string[] splitter = currentMode.Search_String.Split(",".ToCharArray()); text1 = splitter[0].Replace(" =", " or "); if (splitter.Length > 1) { text2 = splitter[1].Replace(" =", " or "); } if (splitter.Length > 2) { text3 = splitter[2].Replace(" =", " or "); } if (splitter.Length > 3) { text4 = splitter[3].Replace(" =", " or "); } } // Were the search fields specified? string andOrValue1 = "+"; string andOrValue2 = "+"; string andOrValue3 = "+"; string dropDownValue1 = "ZZ"; string dropDownValue2 = "TI"; string dropDownValue3 = "AU"; string dropDownValue4 = "TO"; if (currentMode.Search_Fields.Length > 0) { // Parse by commas string[] fieldSplitter = currentMode.Search_Fields.Replace(" ", "+").Split(",".ToCharArray()); dropDownValue1 = fieldSplitter[0]; if ((fieldSplitter.Length > 1) && (fieldSplitter[1].Length > 1)) { andOrValue1 = fieldSplitter[1][0].ToString(); dropDownValue2 = fieldSplitter[1].Substring(1); } if ((fieldSplitter.Length > 2) && (fieldSplitter[2].Length > 1)) { andOrValue2 = fieldSplitter[2][0].ToString(); dropDownValue3 = fieldSplitter[2].Substring(1); } if ((fieldSplitter.Length > 3) && (fieldSplitter[3].Length > 1)) { andOrValue3 = fieldSplitter[3][0].ToString(); dropDownValue4 = fieldSplitter[3].Substring(1); } } Output.WriteLine(" <table id=\"sbkAsav_SearchPanel\" >"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td style=\"width:28%;text-align:right;\"><label for=\"Textbox1\">" + searchLanguage + "</label></td>"); Output.WriteLine(" <td style=\"width:3%;\"> </td>"); Output.WriteLine(" <td style=\"width:58%;\">"); Output.WriteLine(" <input name=\"Textbox1\" type=\"text\" id=\"Textbox1\" class=\"sbkAsav_SearchBox sbk_Focusable\" value=\"" + text1 + "\" />"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style\"width:3%;text-align:center;\">" + inLanguage + "</td>"); Output.WriteLine(" <td style=\"width:8%;\">"); Output.WriteLine(" <select name=\"Dropdownlist1\" id=\"Dropdownlist1\" class=\"sbkAsav_DropDownList\" style=\"width:128px;\" >"); add_drop_down_options(Output, dropDownValue1); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"2\" style=\"text-align:right;\">"); Output.WriteLine(" <select name=\"andOrNotBox1\" id=\"andOrNotBox1\" class=\"sbkAsav_AndOrNotBox\">"); add_and_or_not_options(Output, andOrValue1); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style=\"width:58%;\">"); Output.WriteLine(" <input name=\"Textbox2\" type=\"text\" id=\"Textbox2\" class=\"sbkAsav_SearchBox sbk_Focusable\" value=\"" + text2 + "\" />"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style\"width:3%;text-align:center;\">" + inLanguage + "</td>"); Output.WriteLine(" <td style=\"width:8%;\">"); Output.WriteLine(" <select name=\"Dropdownlist2\" id=\"Dropdownlist2\" class=\"sbkAsav_DropDownList\" style=\"width:128px;\" >"); add_drop_down_options(Output, dropDownValue2); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"2\" style=\"text-align:right;\">"); Output.WriteLine(" <select name=\"andOrNotBox2\" id=\"andOrNotBox2\" class=\"sbkAsav_AndOrNotBox\">"); add_and_or_not_options(Output, andOrValue2); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style=\"width:58%;\">"); Output.WriteLine(" <input name=\"Textbox3\" type=\"text\" id=\"Textbox3\" class=\"sbkAsav_SearchBox sbk_Focusable\" value=\"" + text3 + "\" />"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style\"width:3%;text-align:center;\">" + inLanguage + "</td>"); Output.WriteLine(" <td style=\"width:8%;\">"); Output.WriteLine(" <select name=\"Dropdownlist3\" id=\"Dropdownlist3\" class=\"sbkAsav_DropDownList\" style=\"width:128px;\">"); add_drop_down_options(Output, dropDownValue3); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"2\" style=\"text-align:right;\">"); Output.WriteLine(" <select name=\"andOrNotBox3\" id=\"andOrNotBox3\" class=\"sbkAsav_AndOrNotBox\">"); add_and_or_not_options(Output, andOrValue3); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style=\"width:58%;\">"); Output.WriteLine(" <input name=\"Textbox4\" type=\"text\" id=\"Textbox4\" class=\"sbkAsav_SearchBox sbk_Focusable\" value=\"" + text4 + "\" />"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style\"width:3%;text-align:center;\">" + inLanguage + "</td>"); Output.WriteLine(" <td style=\"width:8%;\">"); Output.WriteLine(" <select name=\"Dropdownlist4\" id=\"Dropdownlist4\" class=\"sbkAsav_DropDownList\" style=\"width:128px;\">"); add_drop_down_options(Output, dropDownValue4); Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); // Show the year range data, if there are any years in this const string YEAR_RANGE = "Limit by Year"; if (yearRange.Count > 0) { Output.WriteLine(" <tr style=\"height:50px;\">"); Output.WriteLine(" <td style=\"text-align:right;\">" + YEAR_RANGE + ":</td>"); Output.WriteLine(" <td> </td>"); Output.WriteLine(" <td colspan=\"2\" style=\"text-align:left\">"); Output.WriteLine(" <select name=\"YearDropDown1\" id=\"YearDropDown1\" class=\"sbkAsav_YearDropDown\">"); // Output.WriteLine(" <option value=\"ZZ\"> </option>"); int currYear1 = currentMode.DateRange_Year1; if ((currYear1 != -1) && (!yearRange.Contains(currYear1))) { Output.WriteLine(" <option selected=\"selected\" value=\"" + currYear1 + "\">" + currYear1 + "</option>"); } if (currYear1 == -1) { currYear1 = yearRange[0]; } foreach (int thisYear in yearRange) { if (thisYear == currYear1) { Output.WriteLine(" <option selected=\"selected\" value=\"" + thisYear + "\">" + thisYear + "</option>"); } else { Output.WriteLine(" <option value=\"" + thisYear + "\">" + thisYear + "</option>"); } } Output.WriteLine(" </select>"); Output.WriteLine(" through "); Output.WriteLine(" <select name=\"YearDropDown2\" id=\"YearDropDown2\" class=\"sbkAsav_YearDropDown\">"); // Output.WriteLine(" <option value=\"ZZ\"> </option>"); int currYear2 = currentMode.DateRange_Year1; if ((currYear2 != -1) && (!yearRange.Contains(currYear2))) { Output.WriteLine(" <option selected=\"selected\" value=\"" + currYear2 + "\">" + currYear2 + "</option>"); } if (currYear2 == -1) { currYear2 = yearRange[yearRange.Count - 1]; } foreach (int thisYear in yearRange) { if (thisYear == currYear2) { Output.WriteLine(" <option selected=\"selected\" value=\"" + thisYear + "\">" + thisYear + "</option>"); } else { Output.WriteLine(" <option value=\"" + thisYear + "\">" + thisYear + "</option>"); } } Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" <td style=\"text-align:right;\">"); Output.WriteLine(" <span id=\"circular_progress\" class=\"hidden_progress\"> </span> "); if (currentCollection.Children_Count > 0) { Output.WriteLine(" <button name=\"searchButton\" id=\"searchButton\" class=\"sbk_SearchButton\" onclick=\"" + scriptActionName + ";return false;\">" + searchButtonText + "<img id=\"sbkAsav_ButtonArrow\" src=\"" + currentMode.Base_URL + "default/images/button_next_arrow2.png\" alt=\"\" /></button>"); } else { Output.WriteLine(" <button name=\"searchButton\" id=\"searchButton\" class=\"sbk_SearchButton\" onclick=\"" + scriptActionName + ";return false;\">" + searchButtonText + "<img id=\"sbkAsav_ButtonArrow\" src=\"" + currentMode.Base_URL + "default/images/button_next_arrow2.png\" alt=\"\" /></button>"); } Output.WriteLine(" </td>"); } else { Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"5\" style=\"text-align:right;\">"); Output.WriteLine(" <span id=\"circular_progress\" class=\"hidden_progress\"> </span> "); if (currentCollection.Children_Count > 0) { Output.WriteLine(" <button name=\"searchButton\" id=\"searchButton\" class=\"sbk_SearchButton\" onclick=\"" + scriptActionName + ";return false;\">" + searchButtonText + "<img id=\"sbkAsav_ButtonArrow\" src=\"" + currentMode.Base_URL + "default/images/button_next_arrow2.png\" alt=\"\" /></button>"); } else { Output.WriteLine(" <button name=\"searchButton\" id=\"searchButton\" class=\"sbk_SearchButton\" onclick=\"" + scriptActionName + ";return false;\">" + searchButtonText + "<img id=\"sbkAsav_ButtonArrow\" src=\"" + currentMode.Base_URL + "default/images/button_next_arrow2.png\" alt=\"\" /></button>"); } Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); } Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"2\" class=\"sbkAsav_SearchOptions\">" + searchOptions + "</span></td>"); Output.WriteLine(" <td style=\"vertical-align:middle;text-align:left;\"> <a href=\"" + currentMode.Base_URL + "help\" target=\"SEARCHHELP\" ><img src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/help_button.jpg\" alt=\"HELP\" /></a></td>"); Output.WriteLine(" <td colspan=\"2\"> </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td colspan=\"5\">"); Output.WriteLine(" <table>"); Output.WriteLine(" <tr style=\"text-align:left;vertical-align:top;\">"); Output.WriteLine(" <td style=\"width:120px;\"> </td>"); Output.WriteLine(" <td>" + precision + ": </td>"); Output.WriteLine(" <td>"); Output.WriteLine(" <input type=\"radio\" name=\"precision\" id=\"precisionContains\" value=\"contains\" /> <label for=\"precisionContains\">" + contains_exactly + "</label> <br />"); Output.WriteLine(" <input type=\"radio\" name=\"precision\" id=\"precisionResults\" value=\"results\" checked=\"checked\" /> <label for=\"precisionResults\">" + contains_any_form + "</label> <br />"); if (currentMode.Language == Web_Language_Enum.English) { Output.WriteLine(" <input type=\"radio\" name=\"precision\" id=\"precisionLike\" value=\"resultslike\" /> <label for=\"precisionLike\">" + CONTAINS_MEANING + "</label> "); } Output.WriteLine(" </td>"); Output.WriteLine(" </tr> "); Output.WriteLine(" </table>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" </table>"); Output.WriteLine(); Output.WriteLine("<!-- Focus on first search box -->"); Output.WriteLine("<script type=\"text/javascript\">focus_element('Textbox1');</script>"); Output.WriteLine(); }
/// <summary> Add the HTML to be displayed in the search box </summary> /// <param name="Output"> Textwriter to write the HTML for this viewer</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public override void Add_Search_Box_HTML(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Basic_Search_AggregationViewer.Add_Search_Box_HTML", "Adding html for search box"); } // Get the list of years for this aggregation string aggrCode = currentCollection.Code.ToLower(); string key = aggrCode + "_YearRanges"; List <int> yearRange = HttpContext.Current.Cache[key] as List <int>; if (yearRange == null) { yearRange = new List <int>(); List <string> yearRangeString = SobekCM_Database.Get_Item_Aggregation_Metadata_Browse(aggrCode, "Temporal Year", Tracer); foreach (string thisYear in yearRangeString) { int result; if (Int32.TryParse(thisYear, out result)) { yearRange.Add(result); } } HttpContext.Current.Cache.Insert(key, yearRange, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); } string search_collection = "Search Collection"; const string YEAR_RANGE = "Limit by Year"; if (currentMode.Language == Web_Language_Enum.Spanish) { search_collection = "Buscar en la colección"; } if (currentMode.Language == Web_Language_Enum.French) { search_collection = "Recherche dans la collection"; } Output.WriteLine(" <table id=\"sbkBsav_SearchPanel_Years\" >"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td style=\"text-align:right;width:27%;\" id=\"sbkBsav_SearchPrompt\"><label for=\"SobekHomeSearchBox\">" + search_collection + ":</label></td>"); Output.WriteLine(" <td style=\"width:3%;\"> </td>"); Output.WriteLine(" <td style=\"width:60%;\"><input name=\"u_search\" type=\"text\" class=\"sbkBsav_SearchBox sbk_Focusable\" id=\"SobekHomeSearchBox\" value=\"" + textBoxValue + "\" onkeydown=\"return fnTrapKD(event, 'basicyears', '" + arg1 + "', '" + arg2 + "','" + browse_url + "');\" /></td>"); Output.WriteLine(" <td style=\"width:10%;\"><button class=\"sbk_GoButton\" title=\"" + search_collection + "\" onclick=\"" + scriptActionName + ";return false;\">Go</button></td>"); Output.WriteLine(" <td><div id=\"circular_progress\" name=\"circular_progress\" class=\"hidden_progress\"> </div></td>"); Output.WriteLine(" </tr>"); // Show the year range data, if there are any years in this if (yearRange.Count > 0) { Output.WriteLine(" <tr style=\"align:right; height:45px;\">"); Output.WriteLine(" <td align=\"right\" id=\"sbkBsav_SearchYearPrompt\">" + YEAR_RANGE + ":</td>"); Output.WriteLine(" <td> </td>"); Output.WriteLine(" <td style=\"text-align:left;\" colspan=\"3\">"); Output.WriteLine(" <select name=\"YearDropDown1\" id=\"YearDropDown1\" class=\"sbkBsav_YearDropDown\">"); // Output.WriteLine(" <option value=\"ZZ\"> </option>"); int currYear1 = currentMode.DateRange_Year1; if ((currYear1 != -1) && (!yearRange.Contains(currYear1))) { Output.WriteLine(" <option selected=\"selected\" value=\"" + currYear1 + "\">" + currYear1 + "</option>"); } if (currYear1 == -1) { currYear1 = yearRange[0]; } foreach (int thisYear in yearRange) { if (thisYear == currYear1) { Output.WriteLine(" <option selected=\"selected\" value=\"" + thisYear + "\">" + thisYear + "</option>"); } else { Output.WriteLine(" <option value=\"" + thisYear + "\">" + thisYear + "</option>"); } } Output.WriteLine(" </select>"); Output.WriteLine(" through "); Output.WriteLine(" <select name=\"YearDropDown2\" id=\"YearDropDown2\" class=\"sbkBsav_YearDropDown\">"); // Output.WriteLine(" <option value=\"ZZ\"> </option>"); int currYear2 = currentMode.DateRange_Year1; if ((currYear2 != -1) && (!yearRange.Contains(currYear2))) { Output.WriteLine(" <option selected=\"selected\" value=\"" + currYear2 + "\">" + currYear2 + "</option>"); } if (currYear2 == -1) { currYear2 = yearRange[yearRange.Count - 1]; } foreach (int thisYear in yearRange) { if (thisYear == currYear2) { Output.WriteLine(" <option selected=\"selected\" value=\"" + thisYear + "\">" + thisYear + "</option>"); } else { Output.WriteLine(" <option value=\"" + thisYear + "\">" + thisYear + "</option>"); } } Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); } //if (( currentUser != null ) && (currentUser.Is_System_Admin)) //{ // Output.WriteLine(" <tr align=\"right\">"); // Output.WriteLine(" <td> </td>"); // Output.WriteLine(" <td align=\"left\" colspan=\"4\">"); // Output.WriteLine(" <input type=\"checkbox\" value=\"PRIVATE_ITEMS\" name=\"privatecheck\" id=\"privatecheck\" unchecked onclick=\"focus_element( 'SobekHomeSearchBox');\" /><label for=\"privatecheck\">" + INCLUDE_PRIVATES + "</label>"); // Output.WriteLine(" </td>"); // Output.WriteLine(" </tr>"); //} Output.WriteLine(" </table>"); Output.WriteLine("<br />"); Output.WriteLine(); Output.WriteLine("<!-- Focus on search box -->"); Output.WriteLine("<script type=\"text/javascript\">focus_element('SobekHomeSearchBox');</script>"); Output.WriteLine(); }