function writeTable($qualifier, $subject_id = '', $description_search = 0) { global $IconPath; global $proxyURL; $db = new Querier(); // sanitize submission $subject_id = scrubData($subject_id); // Prepare conditions $condition1 = ""; $condition2 = ""; $condition3 = ""; switch ($qualifier) { case "Num": $condition1 = "WHERE left(title, 1) REGEXP '[[:digit:]]+'"; $condition2 = "WHERE left(alternate_title, 1) REGEXP '[[:digit:]]+'"; break; case "All": $condition1 = "WHERE title != ''"; $condition2 = "WHERE alternate_title != ''"; break; case "bysub": if (isset($subject_id)) { //get title ids in pluslets' resource token connected to subject $lobjGuide = new Guide($subject_id); $lobjTitleIds = $lobjGuide->getRelatedTitles(); $condition1 = "WHERE (subject_id = {$subject_id}"; $condition1 .= count($lobjTitleIds) > 0 ? "\nOR t.title_id IN (" . implode(',', $lobjTitleIds) . ")" : ""; $condition1 .= ")"; $condition2 = "WHERE subject_id = {$subject_id}"; } else { $condition1 = "WHERE title LIKE " . $db->quote("%" . $qualifier . "%"); $condition2 = "WHERE alternate_title LIKE " . $db->quote("%" . $qualifier . "%"); } break; case "bytype": if (isset($_GET["type"])) { $condition1 = "WHERE ctags LIKE " . $db->quote(scrubData($_GET["type"])); $condition2 = "WHERE ctags LIKE " . $db->quote(scrubData($_GET["type"])); $condition3 = "and alternate_title NOT NULL"; } break; case "search": $condition1 = "WHERE title LIKE " . $db->quote("%" . $qualifier . "%"); // If you uncomment the next line, it will search description field $condition1 = "WHERE (title LIKE " . $db->quote("%" . $qualifier . "%") . " OR description LIKE " . $db->quote("%" . $qualifier . "%"); $condition2 = "WHERE alternate_title LIKE " . $db->quote("%" + $qualifier + "%"); break; default: // This is the simple output by letter and also the search if (strlen($qualifier) == 1) { // Is like the first letter $condition1 = "WHERE title LIKE " . $db->quote($qualifier . "%"); } else { $condition1 = "WHERE title LIKE " . $db->quote("%" . $qualifier . "%"); } if ($description_search == 1) { // If you uncomment the next line, it will search description field $condition1 = "WHERE (title LIKE " . $db->quote("%" . $qualifier . "%") . " OR description LIKE " . $db->quote("%" . $qualifier . "%") . ")"; } $condition2 = "WHERE alternate_title LIKE " . $db->quote("%" + $qualifier + "%"); } $q1 = "SELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n FROM title as t\n INNER JOIN location_title as lt\n ON t.title_id = lt.title_id\n INNER JOIN location as l\n ON lt.location_id = l.location_id\n INNER JOIN restrictions as r\n ON l.access_restrictions = r.restrictions_id\n INNER JOIN rank as rk\n ON rk.title_id = t.title_id\n INNER JOIN source as s\n ON rk.source_id = s.source_id\n {$condition1}\n AND eres_display = 'Y'\n ORDER BY newtitle"; $q2 = "SELECT distinct left(t.alternate_title,1) as initial, t.alternate_title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n FROM title as t\n INNER JOIN location_title as lt\n ON t.title_id = lt.title_id\n INNER JOIN location as l\n ON lt.location_id = l.location_id\n INNER JOIN restrictions as r\n ON l.access_restrictions = r.restrictions_id\n INNER JOIN rank as rk\n ON rk.title_id = t.title_id\n INNER JOIN source as s\n ON rk.source_id = s.source_id\n {$condition2}\n\t\t AND eres_display = 'Y'\n {$condition3}\n\n\t\t ORDER BY newtitle"; $r = $db->query($q1); $num_rows = count($r); if ($num_rows == 0) { return "<div class=\"no_results\">" . _("Sorry, there are no results at this time.") . "</div>"; } // prepare header $items = "<table width=\"98%\" class=\"item_listing\">"; $row_count = 0; $colour1 = "oddrow"; $colour2 = "evenrow"; foreach ($r as $myrow) { $row_colour = $row_count % 2 ? $colour1 : $colour2; $patterns = "/'|\"/"; $replacements = ""; $item_title = $myrow[1]; if ($myrow["pre"] != "") { $item_title = $myrow["pre"] . " " . $item_title; } $safe_title = trim(preg_replace($patterns, $replacements, $item_title)); $blurb = $myrow["description"]; $bib_id = $myrow[5]; /// CHECK RESTRICTIONS /// if ($myrow['4'] == 2 or $myrow['4'] == 3) { $url = $proxyURL . $myrow[3]; $rest_icons = "restricted"; } elseif ($myrow['4'] == 4) { $url = $myrow[3]; $rest_icons = "restricted"; } else { $url = $myrow[3]; $rest_icons = ""; // if you want the unlocked icon to show, enter "unrestricted" here } $current_ctags = explode("|", $myrow["ctags"]); // add our $rest_icons info to this array at the beginning array_unshift($current_ctags, $rest_icons); $icons = showIcons($current_ctags); /// Check for Help Guide /// if ($myrow["helpguide"] != "") { $helpguide = " <a href=\"" . $myrow["helpguide"] . "\"><img src=\"{$IconPath}/help.gif\" border=\"0\" alt=\"" . _("Help Guide") . "\" title=\"" . _("Help Guide") . "\" /></a>"; } else { $helpguide = ""; } //Check if there is a display note if ($myrow["display_note"] == NULL) { $display_note_text = ""; } else { $display_note_text = "<br /><strong>" . _("Note:") . " </strong>" . $myrow['display_note']; } $bonus = "{$blurb}<br />"; if ($blurb != "") { $information1 = "<span id=\"bib-{$bib_id}\" class=\"toggleLink curse_me\"><img src=\"{$IconPath}/information.png\" border=\"0\" alt=\"" . _("more information") . "\" title=\"" . _("more information") . "\" /></span>"; // This is new details link; you can use the one above if you prefer $information = "<span id=\"bib-{$bib_id}\" class=\"toggleLink curse_me\">" . _("about") . "</span>"; } else { $information = ""; } $target = targetBlanker(); $items .= self::generateLayout($row_colour, $url, $target, $item_title, $information, $information1, $icons, $helpguide, $display_note_text, $bonus); $row_count++; } $items .= "</table>"; return $items; }
public function output($action = "", $view = "public") { // public vs. admin parent::establishView($view); global $proxyURL; global $check_this; global $IconPath; global $all_ctags; $last_source_id = ""; ///////////////////////// // Create TOC ///////////////////////// $TOC = self::createTOC(); $this->_body = $TOC; $db = new Querier(); // Display all items for a subject, as tagged in Records tab $q = "select title, description, location, source, source.source_id, restrictions, location.format,\n\t\trestrictions_id, title.title_id, location.access_restrictions, rank.subject_id,\n\t\trank.title_id, location.helpguide, display_note, ctags, description_override, call_number\n\t\tFROM title, restrictions, location, location_title, source, rank\n\t\tWHERE title.title_id = location_title.title_id and location.location_id = location_title.location_id\n\t\tAND restrictions_id = access_restrictions and rank.subject_id = '{$this->_subject_id}' and rank.title_id = title.title_id\n\t\tAND source.source_id = rank.source_id\n ORDER BY source.rs asc, source.source, rank.rank asc, title.title, format"; //print $q; $r = $db->query($q); // set up some row colours $row_count = 0; $colour1 = "oddrow"; $colour2 = "evenrow"; $results = ""; // init foreach ($r as $myrow) { $label = $myrow["title"]; $url = $myrow["location"]; $restrictions = $myrow["restrictions_id"]; $display_note = $myrow["display_note"]; // Use description override if it exists if ($myrow["description_override"] != "") { $blurb = $myrow["description_override"]; } else { $blurb = $myrow["description"]; } if ($restrictions == 2 or $restrictions == 3) { // Check if it is restricted to local students $rest_icons = "restricted"; $final_url = $proxyURL . $myrow[2]; //$rest_icons = "<img src=\"$IconPath/lock.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Available to Students, Faculty and Staff\" title=\"Available to Students, Faculty and Staff\" /> "; } else { $rest_icons = ""; $final_url = $myrow[2]; //$rest_icons = "<img src=\"$IconPath/lock_unlock.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Unrestricted Resource\" title=\"Unrestricted Resource\" /> "; } // Generate our icons, comparing current ctags to the master list (in config.php) $pub_icons = ""; $current_ctags = explode("|", $myrow["ctags"]); // add our $rest_icons info to this array at the beginning array_unshift($current_ctags, $rest_icons); $pub_icons = showIcons($current_ctags); //Check if there is a display note if ($display_note == NULL) { $display_note_text = ""; } else { $display_note_text = "<strong>note: </strong>{$display_note}"; } $row_colour = $row_count % 2 ? $colour1 : $colour2; // Do we need a subdivision header? $this_source_id = $myrow[4]; if ($this_source_id != $last_source_id) { $results .= "<p class=\"leftcolheader\"><a name=\"{$myrow['4']}\"></a>{$myrow['3']}</p>\n\n"; $last_source_id = $this_source_id; $res_class = "dbresults no-border"; } else { $res_class = "dbresults"; } // clean up blurb $blurb = stripslashes($blurb) . "<br />"; // let's set our targets $target = targetBlanker(); // Display results switch ($myrow["format"]) { case "1": // web $first_line = "<a style=\"text-decoration: underline\" href=\"{$final_url}\" {$target}>{$label}</a> {$pub_icons}<br />"; break; case "2": // print $first_line = "<em>{$label}</em><br /><strong>" . _("Print Location:") . "</strong> {$final_url} {$pub_icons}<br />"; if ($myrow["8"] == $last_title_id) { $blurb = ""; $res_class = "dbresults-inset"; } break; case "3": // print with url $first_line = "<em>{$label}</em><br /><strong>" . _("Print Location:") . "</strong>\n <a style=\"text-decoration: underline\" href=\"{$final_url}\" {$target}>" . $myrow["call_number"] . "</a> {$pub_icons}<br />"; if ($myrow["8"] == $last_title_id) { $blurb = ""; $res_class = "dbresults-inset"; } break; } $results .= "<div class=\"{$res_class}\">\n {$first_line}\n {$blurb}\n {$display_note_text}\n </div>"; $last_title_id = $myrow["8"]; $row_count++; // Add 1 to the row count, for the "even/odd" row striping } $this->_body .= $results; parent::assemblePluslet(); return $this->_pluslet; }
protected function tokenizeText() { global $proxyURL; global $PublicPath; global $FAQPath; global $UserPath; global $IconPath; global $open_string; global $close_string; global $open_string_kw; global $close_string_kw; global $open_string_cn; global $close_string_cn; global $open_string_bib; $db = new Querier(); $icons = ""; //$target = "target=\"_" . $target . "\""; $target = ""; $target = targetBlanker(); $tokenized = ""; $parts = preg_split('/<span[^>]*>{{|}}<\\/span>/', $this->_body); if (count($parts) == 1) { $parts = preg_split('/{{|}}/', $this->_body); } if (count($parts) > 1) { // there are tokens in $body foreach ($parts as $part) { if (preg_match('/^dab},\\s?{\\d+},\\s?{.+},\\s?{[01]{3}$/', $part) || preg_match('/^dab},\\s?{\\d+},\\s?{.+},\\s?{[01]{2}$/', $part) || preg_match('/^faq},\\s?{(\\d+,)*\\d+$/', $part) || preg_match('/^cat},\\s?{.+},\\s?{.*},\\s?{\\w+$/', $part) || preg_match('/^fil},\\s?{.+},\\s?{.+$/', $part) || preg_match('/^sss},\\s?{[^}]*/', $part) || preg_match('/^toc},\\s?{[^}]*/', $part)) { // $part is a properly formed token $fields = preg_split('/},\\s?{/', $part); $prefix = substr($part, 0, 3); //print_r($fields); switch ($prefix) { case "faq": $query = "SELECT faq_id, question FROM `faq` WHERE faq_id IN(" . $fields[1] . ") ORDER BY question"; $result = $db->query($query); $tokenized .= "<ul>"; foreach ($result as $myrow) { $tokenized .= "<li><a href=\"{$FAQPath}" . "?faq_id={$myrow['0']}\" {$target}>" . stripslashes(htmlspecialchars_decode($myrow[1])) . "</a></li>"; } $tokenized .= "</ul>"; break; case "fil": $ext = explode(".", $fields[1]); $i = count($ext) - 1; $our_icon = showDocIcon($ext[$i]); $file = "{$UserPath}/{$fields['1']}"; $tokenized .= "<a href=\"{$file}\" {$target}>{$fields['2']}</a> <img style=\"position:relative; top:.3em;\" src=\"{$IconPath}/{$our_icon}\" alt=\"{$ext[$i]}\" />"; break; case "cat": $pretext = ""; switch ($fields[3]) { case "subject": $cat_url = $open_string . $fields[1] . $close_string; $pretext = $fields[2] . " "; $linktext = $fields[1]; break; case "keywords": $cat_url = $open_string_kw . $fields[1] . $close_string_kw; $linktext = $fields[2]; break; case "call_num": $cat_url = $open_string_cn . $fields[1] . $close_string_cn; $linktext = $fields[2]; break; case "bib": $cat_url = $open_string_bib . $fields[1]; $linktext = $fields[2]; break; } $tokenized .= "{$pretext}<a href=\"{$cat_url}\" {$target}>{$linktext}</a>"; break; case "dab": $description = ""; /////////////////// // Check for icons or descriptions in fields[3] // 00 = neither; 10 = icons no desc; 01 = desc no icons; 11 = both /////////////////// if (isset($fields["3"])) { // Transform the number into an array of values $options = str_split($fields["3"]); $show_icon_option = $options[0]; $show_desc_option = $options[1]; if ($show_icon_option == 1) { $show_icons = "yes"; $show_rank = 0; } else { $show_icons = ""; } if ($show_desc_option == 1) { $show_desc = 1; $show_rank = 0; } else { $show_desc = ""; } // This option was not in previous version so it needs to be checked if (isset($options[2])) { $show_note_option = $options[2]; if ($show_note_option == 1) { $show_note = 1; } else { $show_note = ""; } } } $query = "SELECT location, access_restrictions, format, ctags, helpguide, citation_guide, description, call_number, t.title, display_note\n FROM location l, location_title lt, title t\n WHERE l.location_id = lt.location_id\n AND lt.title_id = t.title_id\n AND t.title_id = {$fields['1']}"; $result = $db->query($query); foreach ($result as $myrow) { // eliminate final line breaks -- offset fixed 11/15/2011 agd $myrow[6] = preg_replace('/(<br \\/>)+/', '', $myrow[6]); // See if it's a web format if ($myrow[2] == 1) { if ($myrow[1] == 1) { $url = $myrow[0]; $rest_icons = "unrestricted"; } else { $url = $proxyURL . $myrow[0]; $rest_icons = "restricted"; } $current_ctags = explode("|", $myrow[3]); // add our $rest_icons info to this array at the beginning array_unshift($current_ctags, $rest_icons); if ($show_icons == "yes") { $icons = showIcons($current_ctags); } else { $icons = ""; } if ($show_desc == 1) { // if we know the subject_id, good; for public, must look up $subject_id = ''; if (isset($_GET["subject_id"])) { $subject_id = $_GET["subject_id"]; } elseif (isset($_GET["subject"])) { $q1 = "SELECT subject_id FROM subject WHERE shortform = '" . $_GET["subject"] . "'"; $r1 = $db->query($q1); //$subject_id = $db->last_id($r1); //$subject_id = $subject_id[0]; $subject_id = $r1[0]["subject_id"]; } $override = findDescOverride($subject_id, $fields[1]); // if they do want to display the description: if ($override != "") { // show the subject-specific "description_override" if it exists $description = "<br />" . scrubData($override); } else { $description = "<br />" . scrubData($myrow[6]); } //$description = "<br />$myrow[9]"; } if (isset($show_note) && $show_note == 1) { if ($myrow[9] != "") { $note = "<br />" . _("Note: ") . $myrow[9]; } } else { $note = ""; } if (!isset($note)) { $note = ""; } $tokenized .= "<a href=\"{$url}\" {$target}>{$myrow['8']}</a> {$icons} {$description} {$note}"; } else { // It's print $format = "other"; $current_ctags = explode("|", $myrow[3]); if ($show_icons == "yes") { $icons = showIcons($current_ctags); } else { $icons = ""; } // added Diane Z fall 2014 if ($show_desc == 1) { // if we know the subject_id, good; for public, must look up $subject_id = ''; if (isset($_GET["subject_id"])) { $subject_id = $_GET["subject_id"]; } elseif (isset($_GET["subject"])) { $q1 = "SELECT subject_id FROM subject WHERE shortform = '" . $_GET["subject"] . "'"; $r1 = $db->query($q1); $subject_id = $r1[0]["subject_id"]; } $override = findDescOverride($subject_id, $fields[1]); // if they do want to display the description: if ($override != "") { // show the subject-specific "description_override" if it exists $description = "<br />" . $override; } else { $description = "<br />" . $myrow[6]; } //$description = "<br />$myrow[9]"; } // end diane fall 2014 if (isset($show_note) && $show_note == 1) { if ($myrow[9] != "") { $note = "<br />" . _("Note: ") . $myrow[9]; } } else { $note = ""; } // Simple Print (2), or Print with URL (3) if ($myrow[2] == 3) { $tokenized .= "<em>{$myrow['8']}</em><br />" . _("") . "\n <a href=\"{$myrow['0']}\" {$target}>{$myrow['7']}</a>\n {$icons} {$description}"; } else { // check if it's a url if (preg_match('/^(https?|www)/', $myrow[0])) { $tokenized .= "<a href=\"{$myrow['0']}\" {$target}>{$myrow['8']}</a> {$icons} {$description} {$note}"; } else { $tokenized .= "{$myrow['8']} <em>{$myrow['0']}</em> {$icons} {$description} {$note}"; } } } } break; case 'sss': global $tel_prefix; $querier = new Querier(); $qs = "SELECT lname, fname, email, tel, title from staff WHERE email IN ('" . str_replace(',', "','", $fields[1]) . "') ORDER BY lname, fname"; //print $qs; $staffArray = $querier->query($qs); foreach ($staffArray as $value) { // get username from email $truncated_email = explode("@", $value[2]); $staff_picture = $this->_relative_asset_path . "users/_" . $truncated_email[0] . "/headshot.jpg"; // Output Picture and Contact Info $tokenized .= "\n \t\t\t<div class=\"clearboth\"><img src=\"{$staff_picture}\" alt=\"Picture: {$value['1']} {$value['0']}\" class=\"staff_photo2\" align=\"left\" style=\"margin-bottom: 5px;\" />\n \t\t\t<p><a href=\"mailto:{$value['2']}\">{$value['1']} {$value['0']}</a><br />{$value['4']}<br />\n \t\t\tTel: {$tel_prefix} {$value['3']}</p>\n</div>\n"; } break; case 'toc': $lobjTocPluslet = new Pluslet_TOC('', '', $this->_subject_id); $lobjTocPluslet->setTickedItems(explode(',', $fields[1])); $lobjTocPluslet->setHideTitleBar(1); $tokenized .= $lobjTocPluslet->output(); break; } } else { $tokenized .= $part; } } // end foreach } else { $this->_body = $this->_body; return; } $this->_body = $tokenized; }