function sort_browser() { global $pdo; ?> <script type="text/javascript"> var category_option = ''; var category_item_option = ''; function loadItem(select_box) { options_array = document.forms['browser_sort'].elements['category_item'].options; // Clear the list for (i = 0; i < options_array.length; i++) { options_array[i] = null; } options_array.length = 0; switch (select_box.options[select_box.selectedIndex].value) { case 'author': info_Array = author_array; break; case 'department': info_Array = department_array; break; case 'category': info_Array = category_array; break; <?php udf_functions_java_menu(); ?> default : order_array = document.forms['browser_sort'].elements['category_item_order'].options; info_Array = new Array(); info_Array[0] = new Array('Empty', 0); break; } category_option = select_box.options[select_box.selectedIndex].value; switch (category_option) { case 'author': <?php echo "\tcategory_option_msg = '" . msg('category_option_author') . "';" . PHP_EOL; ?> break; case 'department': <?php echo "\tcategory_option_msg = '" . msg('category_option_department') . "';" . PHP_EOL; ?> break; case 'category': <?php echo "\tcategory_option_msg = '" . msg('category_option_category') . "';" . PHP_EOL; ?> break; default : <?php echo "\tcategory_option_msg = '" . msg('label_empty') . "';" . PHP_EOL; ?> break; } <?php echo "\toptions_array[0] = new Option('" . msg('outpage_choose') . " ' + category_option_msg);" . PHP_EOL; ?> options_array[0].id = 0; options_array[0].value = 'choose_an_author'; for (i = 0; i < info_Array.length; i++) { options_array[i + 1] = new Option(info_Array[i][0]); options_array[i + 1].id = i + 1; options_array[i + 1].value = info_Array[i][0]; } category_option = select_box.options[select_box.selectedIndex].value; } function loadOrder(select_box) { category_item_option = select_box.options[select_box.selectedIndex].value; if (category_item_option == 'choose_an_author') exit(); order_array = new Array(); <?php echo "\torder_array[0] = new Array(\"" . msg('outpage_ascending') . "\", 0, \"asc\");" . PHP_EOL; echo "\torder_array[1] = new Array(\"" . msg('outpage_descending') . "\", 0, \"desc\");" . PHP_EOL; echo "\toptions_array = document.forms['browser_sort'].elements['category_item_order'].options;" . PHP_EOL; echo "\toptions_array[0] = new Option('" . msg('outpage_choose_an_order') . "');" . PHP_EOL; ?> options_array[0].id = 0; options_array[0].value = 'choose_an_order'; for (i = 0; i < order_array.length; i++) { options_array[i + 1] = new Option(order_array[i][0]); options_array[i + 1].id = i + 1; options_array[i + 1].value = order_array[i][2]; } } function load(select_box) { window.location = "search.php?submit=submit&sort_by=id&where=" + category_option + "&sort_order=" + select_box.options[select_box.selectedIndex].value + "&keyword=" + escape(category_item_option) + "&exact_phrase=on"; } <?php ///////////////////////////////FOR AUTHOR/////////////////////////////////////////// $query = "\n SELECT\n last_name,\n first_name,\n id\n FROM\n {$GLOBALS['CONFIG']['db_prefix']}user\n ORDER BY\n last_name ASC\n "; $stmt = $pdo->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(); $index = 0; echo "author_array = new Array();" . PHP_EOL; foreach ($result as $row) { $last_name = e::h($row['last_name']); $first_name = e::h($row['first_name']); $id = e::h($row['id']); echo "\tauthor_array[{$index}] = new Array(\"{$last_name} {$first_name}\", {$id});" . PHP_EOL; $index++; } ///////////////////////////////FOR DEPARTMENT////////////////////////// $query = "\n SELECT\n name,\n id\n FROM\n {$GLOBALS['CONFIG']['db_prefix']}department\n ORDER BY\n name ASC\n "; $stmt = $pdo->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(); $index = 0; echo "department_array = new Array();" . PHP_EOL; foreach ($result as $row) { $dept = e::h($row['name']); $id = e::h($row['id']); echo "\tdepartment_array[{$index}] = new Array(\"{$dept}\", {$id});" . PHP_EOL; $index++; } ///////////////////////////////FOR FILE CATEGORY//////////////////////////////////////// $query = "\n SELECT\n name,\n id\n FROM\n {$GLOBALS['CONFIG']['db_prefix']}category\n ORDER BY\n name ASC\n "; $stmt = $pdo->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(); $index = 0; echo "category_array = new Array();" . PHP_EOL; foreach ($result as $row) { $category = e::h($row['name']); $id = e::h($row['id']); echo "\tcategory_array[{$index}] = new Array(\"{$category}\", {$id});" . PHP_EOL; $index++; } udf_functions_java_array(); /////////////////////////////////////////////////////////////////////// echo '</script>' . PHP_EOL; ?> <form name = "browser_sort"> <table name = "browser" border = "0" cellspacing = "1"> <tr> <td><?php echo msg('label_browse_by'); ?> </td> <td nowrap rowspan="0"> <select name="category" onChange="loadItem(this)" width="0" size="1"> <option id="0" selected ><?php echo msg('label_select_one'); ?> </option> <option id="1" value="author"><?php echo msg('author'); ?> </option> <option id="2" value="department"><?php echo msg('label_department'); ?> </option> <option id="3" value="category"><?php echo msg('label_file_category'); ?> </option> <?php udf_functions_java_options(4); ?> </select> </td> <td> <select name="category_item" onChange="loadOrder(this)"> <option id="0" selected ><?php echo msg('label_empty'); ?> </option> </select> </td> <td> <select name="category_item_order" onChange="load(this)"> <option id="0" selected ><?php echo msg('label_empty'); ?> </option> </select> </td> </tr> </table> </form > <?php }
function sort_browser() { ?> <script type="text/javascript"> var category_option = ''; var category_item_option = ''; function loadItem(select_box) { options_array = document.forms['browser_sort'].elements['category_item'].options; // Clear the list for(i=0; i< options_array.length; i++) { options_array[i]=null; } options_array.length = 0; switch(select_box.options[select_box.selectedIndex].value) { case 'author': info_Array = author_array; break; case 'department': info_Array = department_array; break; case 'category': info_Array = category_array; break; <?php udf_functions_java_menu(); ?> default : order_array = document.forms['browser_sort'].elements['category_item_order'].options; info_Array = new Array(); info_Array[0] = new Array('Empty', 0); break; } category_option = select_box.options[select_box.selectedIndex].value; switch(category_option) { case 'author': <?php echo "\tcategory_option_msg = '" . msg('category_option_author') . "';\n"; ?> break; case 'department': <?php echo "\tcategory_option_msg = '" . msg('category_option_department') . "';\n"; ?> break; case 'category': <?php echo "\tcategory_option_msg = '" . msg('category_option_category') . "';\n"; ?> break; default : <?php echo "\tcategory_option_msg = '" . msg('label_empty') . "';\n"; ?> break; } <?php echo "\toptions_array[0] = new Option('" . msg('outpage_choose') . "' + category_option_msg);\n"; ?> options_array[0].id= 0; options_array[0].value = 'choose_an_author'; for(i=0; i< info_Array.length; i++) { options_array[ i + 1 ]= new Option(info_Array[i][0]); options_array[ i + 1 ].id= i + 1; options_array[ i + 1 ].value = info_Array[i][0]; } category_option = select_box.options[select_box.selectedIndex].value; } function loadOrder(select_box) { category_item_option = select_box.options[select_box.selectedIndex].value; if(category_item_option == 'choose_an_author') exit(); order_array = new Array(); <?php echo "\torder_array[0] = new Array(\"" . msg('outpage_ascending') . "\", 0, \"asc\");\n"; echo "\torder_array[1] = new Array(\"" . msg('outpage_descending') . "\", 0, \"desc\");\n"; echo "\toptions_array = document.forms['browser_sort'].elements['category_item_order'].options;\n"; echo "\toptions_array[0] = new Option('" . msg('outpage_choose_an_order') . "');\n"; ?> options_array[0].id= 0; options_array[0].value = 'choose_an_order'; for(i=0; i< order_array.length; i++) { options_array[i+1]= new Option(order_array[i][0]); options_array[i+1].id= i + 1; options_array[i+1].value = order_array[i][2]; } } function load(select_box) { window.location = "search.php?submit=submit&sort_by=id&where=" + category_option + "&sort_order=" + select_box.options[select_box.selectedIndex].value + "&keyword=" + escape(category_item_option) + "&exact_phrase=on"; } <?php ///////////////////////////////FOR AUTHOR/////////////////////////////////////////// $query = "SELECT last_name, first_name, id FROM {$GLOBALS['CONFIG']['db_prefix']}user ORDER BY last_name ASC"; $result = mysql_query($query, $GLOBALS['connection']) or die('Error in query' . mysql_error()); $count = mysql_num_rows($result); $index = 0; echo "author_array = new Array();\n"; while ($index < $count) { list($last_name, $first_name, $id) = mysql_fetch_row($result); echo "\tauthor_array[{$index}] = new Array(\"{$last_name} {$first_name}\", {$id});\n"; $index++; } ///////////////////////////////FOR DEPARTMENT////////////////////////// $query = "SELECT name, id FROM {$GLOBALS['CONFIG']['db_prefix']}department ORDER BY name ASC"; $result = mysql_query($query, $GLOBALS['connection']) or die('Error in query' . mysql_error()); $count = mysql_num_rows($result); $index = 0; echo "department_array = new Array();\n"; while ($index < $count) { list($dept, $id) = mysql_fetch_row($result); echo "\tdepartment_array[{$index}] = new Array(\"{$dept}\", {$id});\n"; $index++; } ///////////////////////////////FOR FILE CATEGORY//////////////////////////////////////// $query = "SELECT name, id FROM {$GLOBALS['CONFIG']['db_prefix']}category ORDER BY name ASC"; $result = mysql_query($query, $GLOBALS['connection']) or die('Error in query' . mysql_error()); $count = mysql_num_rows($result); $index = 0; echo "category_array = new Array();\n"; while ($index < $count) { list($category, $id) = mysql_fetch_row($result); echo "\tcategory_array[{$index}] = new Array(\"{$category}\", {$id});\n"; $index++; } udf_functions_java_array(); /////////////////////////////////////////////////////////////////////// echo '</script>' . "\n"; ?> <form name="browser_sort"> <table name="browser" border="0" cellspacing="1"> <tr><td><?php echo msg('label_browse_by'); ?> </td> <td NOWRAP ROWSPAN="0"> <select name='category' onChange='loadItem(this)' width='0' size='1'> <option id='0' selected><?php echo msg('label_select_one'); ?> </option> <option id='1' value='author'><?php echo msg('author'); ?> </option> <option id='2' value='department'><?php echo msg('label_department'); ?> </option> <option id='3' value='category'><?php echo msg('label_file_category'); ?> </option> <?php udf_functions_java_options(4); ?> </select> </td> <td> <select name='category_item' onChange='loadOrder(this)'> <option id='0' selected><?php echo msg('label_empty'); ?> </option> </select> </td> <td> <select name='category_item_order' onChange='load(this)'> <option id='0' selected><?php echo msg('label_empty'); ?> </option> </select> </td> </tr> </table> </form> <?php }