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) {
function uw_lib_refshelf_render_data() {
$content = "";
$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
if (array_key_exists("cat_id", $_GET) || array_key_exists("toc_id", $_GET)) {
if (isset($_GET['cat_id']) && !empty($_GET['cat_id'])) {
//Displaying Subcategories
$tit = html_entity_decode($_GET['title']);
$txt = "<h3>" . $tit . "</h3><br />";
$_SESSION['tit'] = $txt;
$qparam = $_GET['cat_id'];
$links = uw_lib_refshelf_get_links($qparam, "toc_id");
if (empty($links)) {
$txt = "<h3>Resources for " . $tit . "</h3><br />";
$links .= uw_lib_refshelf_get_links($qparam, "resources");
}
$_SESSION['toc_links'] = $links;
$content .= $main_category;
$content .= $txt;
$content .= $links;
}
elseif (isset($_GET['toc_id']) && !empty($_GET['toc_id'])) {
//Displaying resources for the subcategories
$content .= $main_category;
$content .= $_SESSION['tit'];
$content .= "<div>" . $_SESSION['toc_links'] . "</div><br />";
$tit = html_entity_decode($_GET['title']);
$txt = "<h3>" . $tit . "</h3><br />";
$qparam = $_GET['toc_id'];
$content .= $txt;
$qparam = $_GET['toc_id'];
$content .= uw_lib_refshelf_get_links($qparam, "resources");
}
}
else{
if (isset($_GET{'pagenum'})) {
//Pagination View
$search_res = "";
$rec_limit = 0;
$pagenum = $_GET{'pagenum'} + 1;
$offset = $rec_limit * $pagenum;
$offset = $rec_limit * $pagenum;
$stored_search_results = $_SESSION['search_results'];
$word = $_SESSION['search_word'];
$toc = $_SESSION['top_cat'];
......@@ -95,10 +94,10 @@ function uw_lib_refshelf_render_data() {
}
else {
//Displaying the top level links
$links = "";
$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;
$param = 0;
$content .= $txt;
......@@ -210,7 +209,6 @@ function uw_lib_refshelf_form_validate($form, &$form_state) {
*/
function uw_lib_refshelf_form_submit($form, &$form_state) {
$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['rebuild'] = TRUE;
}
......@@ -251,7 +249,6 @@ function uw_lib_refshelf_search($word) {
//Eliminate duplicates
$no_duplicates = array_unique($all);
//$no_duplicates = uw_lib_refshelf_highlight_words($word, $no_duplicates);
$records_cnt = count($no_duplicates);
$actual_records = $records_cnt -1 ;
if ($records_cnt < 25) {
......@@ -293,13 +290,10 @@ function uw_lib_refshelf_highlight_word($word, $str) {
*/
function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset) {
$page = "";
$results = "";
$te = "";
$records_cnt = count($no_duplicates);
$content = "";
$results = "";
$rec_count = count($no_duplicates);
$rec_limit = 25;
$rec_count = $records_cnt;
$left_rec = $rec_count - ($pagenum * $rec_limit) - 2 ;
$offset = $rec_limit * $pagenum ;
$limit = $rec_limit * $pagenum;
......@@ -319,7 +313,7 @@ function uw_lib_refshelf_view_results($no_duplicates, $word, $pagenum, $offset)
$cnt++;
}
if (!empty($page)) {
$results = $msg . $page;//."<br />".$pagination;
$results = $msg . $page;
}
else {
$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) {
if ( $left_rec < $rec_limit ) {
$last = $pagenum - 2;
$content = "<a href = \"?pagenum={$last}\">Previous</a>";
}
elseif ($pagenum == 0 ) {
$content = "<a href = \"?pagenum={$pagenum}\">Next</a>";
}
elseif ($pagenum > 0 ) {
$last = $pagenum - 2;
$content .= "<a href = \"?pagenum={$last}\">Previous</a> |";
$content .= "<a href = \"?pagenum={$pagenum}\">Next</a>";
}
elseif ($pagenum == 0 ) {
$content = "<a href = \"?pagenum={$pagenum}\">Next</a>";
}
elseif ($pagenum > 0 ) {
$last = $pagenum - 2;
$content .= "<a href = \"?pagenum={$last}\">Previous</a> |";
$content .= "<a href = \"?pagenum={$pagenum}\">Next</a>";
}
$content = "<table align='center'><tr><td align='center'>" . $content . "</td></tr></table>";
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