Search Bibliography";
/* construct the template filename */
$qry="select substr(templates,5) as templ_file from x_search where substr(templates,1,3)='BS:'";
db_vars($con,$qry);
$templ_file.="-search.tmpl";
/* import the citation formating code based on
* the citestyle field in the HTML table
*/
$citestyle=strtolower($citestyle);
require("bib-style-".$citestyle.".php3");
/* Clean the incoming published resource id */
if(strlen($pubid)<1){
$pubid="MISSING RESOURCE IDENTIFIER";
}
else{
$pubid=strtoupper($pubid);
}
$pid="UNKNOWN";
/* retrieve the published resource row */
$qry="select pubid, online, type, author, x_year, title, ";
$qry.="secondaryauthor, secondarytitle, placepublished, publisher, ";
$qry.="volume, numberofvolumes, number, pagenos, edition, x_date, ";
$qry.="url, urltype, urldate, typeofwork, isbn_issn, ";
$qry.="source, abstract, notes, ";
$qry.="classification, format, x_language, contains, descriptionofwork ";
$qry.="from pubresource where UPPER(pubid)='$pubid' limit 1 offset 0";
/* Run full target query */
$res=pg_exec($con,$qry);
$numrows = pg_numrows($res);
/* check for an unknown resource */
if($numrows == 0){
$result="Unknown resource id: $pubid";
}
else{
/* get resource row */
$pub_row=pg_fetch_array($res,0);
$doRelated=false;
if(pg_numrows($res)>0)$doRelated=true;
if($doRelated){
/* check for existence of entity-pubresource intersecting table */
$qry="select tablename from pg_tables where tablename='eprrship'";
$res=pg_exec($con,$qry);
/* get related entities for this resource */
$related="";
$qry="select distinct e.eid, e.ename, e.esubname, e.estart, e.esdatemod, ";
$qry.="e.eend, e.eedatemod, toe.gentype from eprrship as re, entity as e, typeofentity as toe ";
$qry.="where (re.relationship='Primary' or re.relationship='Primary Creator') and re.eid=e.eid and UPPER(e.etype)=UPPER(toe.types) and UPPER(re.pubid)='$pubid' ";
$qry.="order by e.ename, e.esubname ";
$numrows=0;
$res=pg_exec($con,$qry);
$numrows=pg_numrows($res);
for($i=0;$i<$numrows;$i++){
$row=pg_fetch_array($res,$i);
/* init locals */
$name=""; $subname=""; $start=""; $end="";
$startmod=""; $endmod=""; $has_date=false;
/* name */
$name=$row["ename"];
$subname=$row["esubname"];
if(strcmp(strtoupper($row["gentype"]),"PERSON")){
if (strlen($subname)>0 && strlen($name)>0 )$name.=", ";
$name=$name.$subname;
}
/* eid */
$eid=strtoupper($row['eid']);
/* start date - just the year */
$start = substr($row['estart'],0,4);
/* start date modifier */
$startmod = $row['esdatemod'];
if(!strcmp($startmod,"c")){
$start = $startmod+$start;
}
else{
$start = $start.$startmod;
}
/* end date - just the year */
$end = substr($row['eend'],0,4);
/* start date modifier */
$endmod = $row['eedatemod'];
if(!strcmp($endmod,"c")){
$end = $endmod+$end;
}
else{
$end = $end.$endmod;
}
$start=trim($start);
$end=trim($end);
$name=trim($name);
if(strlen(trim($start.$end)) > 0)$has_date=true;
$tmp_e="";
/* build entity name as link */
$tmp_e.="";
/* entity name of the form NAME, SUBNAME (DATE_RANGE) */
$tmp_e.=$name;
if($has_date)$tmp_e.=" ($start - $end)";
$tmp_e.="
";
$related.=$tmp_e;
}
} /* end of building related links */
$pub_row = clean_pubresource_row($pub_row);
$pub_type = strtolower($pub_row['type']);
if (strcmp($row['online'],'t') == 0){
$pub_type = "online ".$pub_type;
}
/* Set up labels */
/* defaults */
$author_label = "Author";
$title_label = "Title";
$sectitle_label = "In";
$secauthor_label = "Editor";
$url_label = "URL";
$pub_label = "Imprint";
$year_label = "Year";
/* vary default labels for different resource types */
switch(strtolower($pub_type)){
case "online resource section":
case "resource section":{
$secauthor_label = "Resource Creator";
break;
}
case "online resource":
case "resource" : {
$author_label = "Creator";
$secauthor_label = "Contributor";
break;
}
case "journal article":
case "article":{
$sectitle_label = "Journal";
$pub_label = "Issue";
break;
}
case "online article":{
$sectitle_label = "In";
$pub_label = "Issue";
break;
}
case "newspaper article":{
$sectitle_label = "Newspaper";
$pub_label = "Issue";
break;
}
case "online journal":
case "journal":{
$author_label = "Editor";
$sectitle_label = "Journal";
$pub_label = "Issue";
break;
}
case "edited book":{
$author_label = "Editor";
break;
}
case "conference proceedings":
case "online conference proceedings": {
$author_label = "Editor";
break;
}
}
/* author */
$pub_author = $pub_row['author'];
/* title */
$pub_title = $pub_row['title'];
/* secondary title, edn, vol */
$pub_sectitle = $pub_row['secondarytitle'];
/* secondary author */
$pub_secauthor = $pub_row['secondaryauthor'];
/* publication (for articles)
* imprint (for others)
*/
// set default to
// publisher, place of publication
$tmp="";
$split = array();
$pub_pub="";
list($pub_pub, $tmp) = cit_def_publisher($pub_row, $pub_pub, $tmp);
list($pub_pub, $tmp) = cit_def_pubplace($pub_row,$pub_pub, $tmp);
list($pub_pub, $tmp) = cit_def_date_year($pub_row,$pub_pub, $tmp);
// set default resource type to book
$res_type="Book";
$tmp="";
/* year - default empty, use imprint */
$pub_year="";
/* variations on publication and secondary title */
switch(strtolower($pub_type)){
case "journal article":
case "newspaper article":
case "online article":
case "article":{
// Volume, Issue, Publisher, Pub Place
list($pub_pub, $tmp) = cit_def_volume($pub_row);
list($pub_pub, $tmp) = cit_def_issue($pub_row,$pub_pub,$tmp);
list($pub_pub, $tmp) = cit_def_publisher($pub_row, $pub_pub, $tmp);
list($pub_pub, $tmp) = cit_def_pubplace($pub_row,$pub_pub, $tmp);
list($pub_year,$tmp) = cit_def_date_year($pub_row);
if(strlen($pub_sectitle)>0)$pub_sectitle="".$pub_sectitle."";
break;
}
// book
case "book":
case "cdrom":
case "report":
case "online report":
case "edited book":
case "online conference proceedings":
case "conference proceedings": {
// publisher, place , year is default
if(strlen($pub_title)>0)$pub_title="".$pub_title."";
// title + edition + volume
$tmp = ", ";
list($pub_title,$tmp)=cit_def_edition($pub_row,$pub_title,$tmp);
list($pub_title,$tmp)=cit_def_volume($pub_row,$pub_title,$tmp);
break;
}
// book section
case "book section":
case "online conference paper":
case "conference paper":{
// publisher, place , year is default
if(strlen($pub_sectitle)>0)$pub_sectitle="".$pub_sectitle."";
// secondary title + edition + volume
$tmp = ", ";
list($pub_sectitle,$tmp)=cit_def_edition($pub_row,$pub_sectitle,$tmp);
list($pub_sectitle,$tmp)=cit_def_volume($pub_row,$pub_sectitle,$tmp);
break;
}
case "online journal":
case "journal":{
list($pub_pub, $tmp) = cit_def_volume($pub_row);
list($pub_pub, $tmp) = cit_def_issue($pub_row,$pub_pub,$tmp);
list($pub_pub, $tmp) = cit_def_publisher($pub_row,$pub_pub,$tmp);
list($pub_year, $tmp) = cit_def_date_year($pub_row);
if(strlen($pub_sectitle)>0){
$pub_sectitle="".$pub_sectitle."";
}
else{
$pub_title="".$pub_title."";
}
break;
}
// resource section
case "online resource section":
case "resource section" :{
// publisher
list($pub_pub, $tmp) = cit_def_publisher($pub_row);
list($pub_pub, $tmp) = cit_def_date_year($pub_row,$pub_pub,$tmp);
if(strlen($pub_sectitle)>0)$pub_sectitle="".$pub_sectitle."";
break;
}
// resource
case "online resource":
case "resource" :
case "pamphlet" :
case "online pamphlet" :{
// publisher
list($pub_pub, $tmp) = cit_def_publisher($pub_row);
list($pub_pub, $tmp) = cit_def_date_year($pub_row,$pub_pub,$tmp);
if(strlen($pub_title)>0)$pub_title="".$pub_title."";
break;
}
case "review" :{
// volume, issue, year
list($pub_pub, $tmp)=cit_def_volume($pub_row);
list($pub_pub, $tmp)=cit_def_issue($pub_row,$pub_pub,$tmp);
list($pub_year,$tmp) = cit_def_year($pub_row,$pub_pub,"");
if(strlen($pub_sectitle)>0)$pub_sectitle="".$pub_sectitle."";
break;
}
case "thesis" :{
// instistution
list($pub_pub, $tmp) = cit_def_institution($pub_row,"","");
list($pub_pub, $tmp) = cit_def_date_year($pub_row,$pub_pub,$tmp);
break;
}
}
/* Type of resource text for heading */
$res_head="";
if(strlen($pub_row['type'])>0){
if(strcmp($pub_row['online'],"f"))$res_head.="Online ";
$res_head.=$pub_row['type'];
$res_head = ucwords($res_head);
}
// set default resource type to book
// $res_text="Book";
// if(strcmp($pub_row['online'],"f"))$res_text="Online Resource";
// if(strpos(" ".tolower($pub_row['type'],"article") > 0){
// $res_text="Article";
// }
$res_text=$res_head;
/* description of work */
$tmp = ", ";
if (strlen($pub_sectitle)>0){
list($pub_sectitle,$tmp)=cit_def_desc_of_work($pub_row,$pub_sectitle,$tmp);
}
else{
list($pub_title,$tmp)=cit_def_desc_of_work($pub_row,$pub_title,$tmp);
}
/* pages */
$pub_pages = $pub_row['pagenos'];
$fo = "";
$fc = "";
/* detail block */
$result.="
".$fo.$author_label.":".$fc." | "; $result.=""; $result.=" | $pub_author | "; $result.="
".$fo.$title_label.":".$fc." | "; $result.=""; $result.=" | $pub_title | "; $result.="
".$fo.$sectitle_label.":".$fc." | "; $result.=""; $result.=" | $pub_sectitle | "; $result.="
".$fo.$secauthor_label.":".$fc." | "; $result.=""; $result.=" | $pub_secauthor | "; $result.="
".$fo.$pub_label.$fc." | "; $result.=""; $result.=" | $pub_pub | "; $result.="
".$fo.$year_label.$fc." | "; $result.=""; $result.=" | $pub_year | "; $result.="
".$fo.$url_label.$fc." | "; $result.=""; $result.=" | "; $result.="".$pub_row['url']." | "; $result.="
".$fo."Pages:".$fc." | "; $result.=""; $result.=" | $pub_pages | "; $result.="
".$fo."Resource Type:".$fc." | "; $result.=""; $result.=" | $res_text | "; $result.="
".$fo."Type of Work:".$fc." | "; $result.=""; $result.=" | "; $result.=$pub_row['typeofwork']; $result.=" |
".$fo.$label.$fc." | "; $result.=""; $result.=" | $field | "; $result.="
".$fo."See:".$fc." | "; $result.=""; $result.=" | $related | "; } $result.="