Commit 1ad35457 authored by Ganesharatnam's avatar Ganesharatnam
Browse files

Clean up file

parent a6ffdaec
...@@ -46,46 +46,45 @@ function uw_lib_refshelf_data($param, $url) { ...@@ -46,46 +46,45 @@ function uw_lib_refshelf_data($param, $url) {
function uw_lib_refshelf_render_data() { function uw_lib_refshelf_render_data() {
$content = ""; $content = "";
$links = ""; $links = "";
$main_category = '<a href="online-reference-shelf" style="float:right;">Go back to main category</a>';
//Check for cat_id and toc_id in GET //Check for cat_id and toc_id in GET
if (array_key_exists("cat_id", $_GET) || array_key_exists("toc_id", $_GET)) { if (array_key_exists("cat_id", $_GET) || array_key_exists("toc_id", $_GET)) {
if (isset($_GET['cat_id']) && !empty($_GET['cat_id'])) { if (isset($_GET['cat_id']) && !empty($_GET['cat_id'])) {
//Displaying Subcategories //Displaying Subcategories
$tit = html_entity_decode($_GET['title']); $tit = html_entity_decode($_GET['title']);
$txt = "<h3>" . $tit . "</h3><br />"; $txt = "<h3>" . $tit . "</h3><br />";
$_SESSION['tit'] = $txt; $_SESSION['tit'] = $txt;
$qparam = $_GET['cat_id']; $qparam = $_GET['cat_id'];
$links = uw_lib_refshelf_get_links($qparam, "toc_id"); $links = uw_lib_refshelf_get_links($qparam, "toc_id");
if (empty($links)) { if (empty($links)) {
$txt = "<h3>Resources for " . $tit . "</h3><br />"; $txt = "<h3>Resources for " . $tit . "</h3><br />";
$links .= uw_lib_refshelf_get_links($qparam, "resources"); $links .= uw_lib_refshelf_get_links($qparam, "resources");
} }
$_SESSION['toc_links'] = $links; $_SESSION['toc_links'] = $links;
$content .= $main_category;
$content .= $txt; $content .= $txt;
$content .= $links; $content .= $links;
} }
elseif (isset($_GET['toc_id']) && !empty($_GET['toc_id'])) { elseif (isset($_GET['toc_id']) && !empty($_GET['toc_id'])) {
//Displaying resources for the subcategories //Displaying resources for the subcategories
$content .= $main_category;
$content .= $_SESSION['tit']; $content .= $_SESSION['tit'];
$content .= "<div>" . $_SESSION['toc_links'] . "</div><br />"; $content .= "<div>" . $_SESSION['toc_links'] . "</div><br />";
$tit = html_entity_decode($_GET['title']); $tit = html_entity_decode($_GET['title']);
$txt = "<h3>" . $tit . "</h3><br />"; $txt = "<h3>" . $tit . "</h3><br />";
$qparam = $_GET['toc_id'];
$content .= $txt; $content .= $txt;
$qparam = $_GET['toc_id'];
$content .= uw_lib_refshelf_get_links($qparam, "resources"); $content .= uw_lib_refshelf_get_links($qparam, "resources");
} }
} }
else{ else{
if (isset($_GET{'pagenum'})) { if (isset($_GET{'pagenum'})) {
//Pagination View //Pagination View
$search_res = ""; $search_res = "";
$rec_limit = 0; $rec_limit = 0;
$pagenum = $_GET{'pagenum'} + 1; $pagenum = $_GET{'pagenum'} + 1;
$offset = $rec_limit * $pagenum; $offset = $rec_limit * $pagenum;
$stored_search_results = $_SESSION['search_results']; $stored_search_results = $_SESSION['search_results'];
$word = $_SESSION['search_word']; $word = $_SESSION['search_word'];
$toc = $_SESSION['top_cat']; $toc = $_SESSION['top_cat'];
...@@ -95,10 +94,10 @@ function uw_lib_refshelf_render_data() { ...@@ -95,10 +94,10 @@ function uw_lib_refshelf_render_data() {
} }
else { else {
//Displaying the top level links //Displaying the top level links
$links = ""; $links = "";
$txt = '<div><p>Find answers to quick factual questions in the online resources below.</p></div>'; $txt = '<div><p>Find answers to quick factual questions in the online resources below.</p></div>';
$txt .= '<div><h3><a href="online-reference-shelf">Browse by category</a></h3><br /></div>'; //$txt .= '<div><h3><a href="online-reference-shelf">Browse by category</a></h3><br /></div>';
$txt .= '<div><h3>Browse by category</h3><br /></div>';
$_SESSION['txt'] = $txt; $_SESSION['txt'] = $txt;
$param = 0; $param = 0;
$content .= $txt; $content .= $txt;
...@@ -210,7 +209,6 @@ function uw_lib_refshelf_form_validate($form, &$form_state) { ...@@ -210,7 +209,6 @@ function uw_lib_refshelf_form_validate($form, &$form_state) {
*/ */
function uw_lib_refshelf_form_submit($form, &$form_state) { function uw_lib_refshelf_form_submit($form, &$form_state) {
$word = $form_state['values']['name']; $word = $form_state['values']['name'];
//drupal_set_message(t('Yay, your word is fine!'.$word));
$form_state['results_table'] = uw_lib_refshelf_search($word); $form_state['results_table'] = uw_lib_refshelf_search($word);
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
} }
...@@ -251,7 +249,6 @@ function uw_lib_refshelf_search($word) { ...@@ -251,7 +249,6 @@ function uw_lib_refshelf_search($word) {
//Eliminate duplicates //Eliminate duplicates
$no_duplicates = array_unique($all); $no_duplicates = array_unique($all);
//$no_duplicates = uw_lib_refshelf_highlight_words($word, $no_duplicates);
$records_cnt = count($no_duplicates); $records_cnt = count($no_duplicates);
$actual_records = $records_cnt -1 ; $actual_records = $records_cnt -1 ;
if ($records_cnt < 25) { if ($records_cnt < 25) {
...@@ -293,13 +290,10 @@ function uw_lib_refshelf_highlight_word($word, $str) { ...@@ -293,13 +290,10 @@ function uw_lib_refshelf_highlight_word($word, $str) {
*/ */
function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset) { function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset) {
$page = ""; $page = "";
$results = "";
$te = "";
$records_cnt = count($no_duplicates);
$content = ""; $content = "";
$results = "";
$rec_count = count($no_duplicates);
$rec_limit = 25; $rec_limit = 25;
$rec_count = $records_cnt;
$left_rec = $rec_count - ($pagenum * $rec_limit) - 2 ; $left_rec = $rec_count - ($pagenum * $rec_limit) - 2 ;
$offset = $rec_limit * $pagenum ; $offset = $rec_limit * $pagenum ;
$limit = $rec_limit * $pagenum; $limit = $rec_limit * $pagenum;
...@@ -319,7 +313,7 @@ function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset) ...@@ -319,7 +313,7 @@ function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset)
$cnt++; $cnt++;
} }
if (!empty($page)) { if (!empty($page)) {
$results = $msg . $page;//."<br />".$pagination; $results = $msg . $page;
} }
else { else {
$results = "<br /><br /><p>No results found for the keyword <b>" . $word . "</b></p>"; $results = "<br /><br /><p>No results found for the keyword <b>" . $word . "</b></p>";
...@@ -392,18 +386,15 @@ function uw_lib_refshelf_pagination($pagenum, $left_rec, $rec_limit) { ...@@ -392,18 +386,15 @@ function uw_lib_refshelf_pagination($pagenum, $left_rec, $rec_limit) {
if ( $left_rec < $rec_limit ) { if ( $left_rec < $rec_limit ) {
$last = $pagenum - 2; $last = $pagenum - 2;
$content = "<a href = \"?pagenum={$last}\">Previous</a>"; $content = "<a href = \"?pagenum={$last}\">Previous</a>";
} }
elseif ($pagenum == 0 ) { elseif ($pagenum == 0 ) {
$content = "<a href = \"?pagenum={$pagenum}\">Next</a>"; $content = "<a href = \"?pagenum={$pagenum}\">Next</a>";
} }
elseif ($pagenum > 0 ) { elseif ($pagenum > 0 ) {
$last = $pagenum - 2; $last = $pagenum - 2;
$content .= "<a href = \"?pagenum={$last}\">Previous</a> |"; $content .= "<a href = \"?pagenum={$last}\">Previous</a> |";
$content .= "<a href = \"?pagenum={$pagenum}\">Next</a>"; $content .= "<a href = \"?pagenum={$pagenum}\">Next</a>";
} }
$content = "<table align='center'><tr><td align='center'>" . $content . "</td></tr></table>"; $content = "<table align='center'><tr><td align='center'>" . $content . "</td></tr></table>";
return $content; return $content;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment