Lang.TypeTitleAuthorTopic Rating
(1 to 5 - best)CommentAcquired"; $defaultSort=array(0=>7,0,1,4,5,3,2,6); //default sort order $hideAdmin=true; //if false, button is placed to the right of the "Apply" button - visible to everybody //if true, it is placed below, so at least not visible at once $showEE=false; //if true and in the bibtex entry an electronic edition link is found ("EE=link" or "url=link") this link is shown (title gets a href) //NB: url and ee can both be present, where the first one should be used to link to a webpage with further information while // ee should directly link to the corresponding pdf $createJumpMarks=true;// VERY IMPORTANT TO SET THIS TO TRUE IF YOU WANT NAME TAGS TO CREATED FOR // REFERRING TO YOUR PAPERS FROM OTHER PAGES! for example: // http://panmental.de/papers/publications.php?table|short#KKLSsvmSpamFilter $addBreaksBeforeLinks=true; //end define personalization variables here of define before in an include script $QUERY_STRING=$_SERVER['QUERY_STRING']; if(isset($_POST["verb"])){ $QUERY_STRING="verb=".$_POST["verb"]; } if(isset($_POST["identifier"])){ $QUERY_STRING=$QUERY_STRING."&identifier=".$_POST["identifier"]; } if(isset($_POST["metadataPrefix"])){ $QUERY_STRING=$QUERY_STRING."&metadataPrefix=".$_POST["metadataPrefix"]; } if(isset($_POST["from"])){ $QUERY_STRING=$QUERY_STRING."&from=".$_POST["from"]; } if(isset($_POST["until"])){ $QUERY_STRING=$QUERY_STRING."&until=".$_POST["until"]; } if(isset($_POST["from"])){ $QUERY_STRING=$QUERY_STRING."&from=".$_POST["from"]; } $shortStyle="div.shortEntry {margin-left:0.5em; text-indent:-0.2em; }"; //text-align:justify; $boxedStyle="div.boxedData {overflow:auto; border:1px solid #aaa; margin:0.3em; padding:0.5em; }"; $scriptInfo="This page is auto-generated from an xml database, get the script!"; $textsArray=array(); //all fields which are currently used: $languageData=""; $typeData=""; $titleData=""; $authorData=""; $acquiredData=""; $ratingData=""; $topicData=""; $commentData=""; $bibtextData=""; $current=""; //for variable variables if($title!="") $pagetitle=$title; else $pagetitle="List of Texts"; // if(strpos($QUERY_STRING,"detailed")) $shortVersion=0; else $shortVersion=1; if($shortVersion==1) $defaultSort=array(0=>7,3,2,0,1,4,5,6); //default sort order (short display mode) else $defaultSort=array(0=>7,0,1,4,5,3,2,6); //default sort order $SCRNAME=$SCRIPT_NAME; //for calling ourselves lateron $sep="|"; //seperating string for the options in QUERY_STRING $name=array(); $name[0] = "Language"; $name[1] = "Type"; $name[2] = "Title"; $name[3] = "Author"; $name[4] = "Topic"; $name[5] = "Rating"; $name[6] = "Comment"; $name[7] = "Acquired"; $name[8] = "BibTex"; if(!isset($searchiframes)){ if(strpos(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),"gb")===false) //.com and .de $searchiframes=" "; else //co.uk and .de $searchiframes=" "; } $bibTexCnt=0; //this preamble is needed for every library file $libStart=" ]> If you can read this either your viewer is not able to display styles for xml files or the stylesheet is missing.
In the latter case download http://".$SERVER_NAME.$PHP_SELF."?stylesheet.xsl and save it in the same place as the xml data file.
"; $message=""; //for messages to the admin, i.e. "data has been saved" $args=explode($sep,$QUERY_STRING); //session_start(); //session information is not used currently //our purpose is only to return the raw .xml data file if($args[0]=="downloadData"){ header("Content-type: text/xml"); header("Content-Disposition: attachment; filename=\"".$downloadFilename."\""); readfile($filename); die(); } //our purpose is only to return the stylesheet for formatting xml if($args[0]=="stylesheet.xsl"){ header("Content-type: text/xml"); header("Content-Disposition: attachment; filename=\"stylesheet.xsl\""); echo " $pagetitle $stylesheet ".$headline."
"; die(); } if(($args[0]!="downloadBib")&&(stristr($QUERY_STRING,"verb")==false)&&($QUERY_STRING!="sitemap.xml")){ //only bibtex, OAI and sitemap mode follows beloa all other special modes are above this line echo " \r\n\r\n"; if($args[0]=="bibtex") echo "\r\n"; else echo "\r\n"; echo "\r\n"; echo "\r\n"; echo "\r\n"; if($args[0]!="bibtex"){ echo "\r\n"; echo "\r\n"; } echo "\r\n"; echo $stylesheet."\r\n"; echo "\r\n"; if(($args[0]!="edit")&&($args[0]!="add")) echo "";} //first call - define frame if((sizeof($args)==1)&&(($args[0]=="")||(($args[0]=="short")||($args[0]=="detailed")))){ echo"$pagetitle\r\n \r\n "; echo $content; echo "<br/><a href=\"$SCRNAME?table|short\">see short version</a>"; echo "<br/><a href=\"$SCRNAME?table|detailed\">see detailed version</a>"; echo "<br/><a href=\"$SCRNAME?downloadBib\">download bibfile</a>"; echo "<br/><a href=\"$SCRNAME?downloadData\">download xml datafile</a>"; echo " and the corresponding <a href=\"$SCRNAME?stylesheet.xsl\">stylesheet</a>"; echo ""; die(); } function extractBib($what,$haystack){ $delim1="{";$delim2="}"; if(substr_count($haystack,$delim1)<3){ $delim1="\"";$delim2="\""; } $ret=""; while(($ret=="")&&($test=stristr($haystack,$what))){ $haystack=trim(substr($haystack,strpos(strtoupper($haystack),strtoupper($what))-1)); if($haystack!=$test){ //character before $what must be white-space $haystack=substr($test,strlen($what)); continue; } $haystack=trim(substr($test,strlen($what))); if(strpos($haystack,"=")==0){ //first non-white-space character must be = $cnt=0; $startpos=strpos($haystack,$delim1); if(strpos($haystack,",")<$startpos){ $ret=substr($haystack,1,strpos($haystack,",")-1); return trim(str_replace("\\","",str_replace($delim2,"",str_replace($delim1,"",$ret)))); } $endpos=$startpos; while($cnt$i)){ $authArr[$i]=trim($authArr[$i]); // if(!strpos($authArr[$i],",")){ //begin abbreviate fornames $aa=explode(" ",$authArr[$i]); if(!strpos($authArr[$i],",")){ for($j=0;$j2)&&(!strpos($aa[$j],"."))) $aa[$j]=substr($aa[$j],0,1)."."; } else{ for($j=1;$j2)&&(!strpos($aa[$j],"."))) $aa[$j]=substr($aa[$j],0,1)."."; } $authArr[$i]=implode(" ",$aa); //end abbreviate fornames if((!strpos($authArr[$i],","))&&(strpos($authArr[$i]," "))) $authArr[$i]=strrchr($authArr[$i]," ")."$sepName ".substr($authArr[$i],0,strrpos($authArr[$i]," ")); $i++; // }else $i=9999; } $tempdat=implode(" and ",$authArr); //end this is the surname / given name exchange $temppos=0; $lastpos=$temppos; while($lastpos=strpos($tempdat," and ",$temppos)){ $temppos=$lastpos+1; } if($temppos>0) $tempdat[$temppos]="#"; $tempdat=str_replace(" and ",", ",$tempdat); $tempdat=str_replace(" #nd "," and ",$tempdat); return $tempdat.$suffix; } function searchIt($keywordphrase){ return " (amazon: .co.uk\"\" .com\"\" .de\"\")"; } //this will take bibtex data (one entry a time) and return a fairly standard citation representation in html function bibtex2html($texEntry,$internalNumber,$addlinks=true){ $ret=extractBib("text",$texEntry); if(trim($ret)==""){ //begin there is no predefined text to show, we create some $author=extractBib("author",$texEntry); if($author==""){ $author=extractBib("editor",$texEntry); $author=$author.", ed."; } $shortAuth=shortenAuthors($author); $ret=$ret.$shortAuth; $year=extractBib("year",$texEntry); if($ret[strlen($ret)-1]!=".") $ret=$ret."."; $ret=$ret." "; $title=extractBib("title",$texEntry); if((trim($author)=="")||(trim($title)=="")) return ""; $texType=strtolower(extractBibType($texEntry)); if(($texType!="article")&&($texType!="inproceedings")) $ret=$ret."$title"; else $ret=$ret.$title; if($title[strlen($title)-1]!=".") $ret=$ret."."; if($texType=="phdthesis"){ $ret=$ret." Ph.D. Thesis"; $school=extractBib("school",$texEntry); if(trim($school)!="") $ret=$ret.", ".$school; $addrs=extractBib("address",$texEntry); if(trim($addrs)!="") $ret=$ret.", ".$addrs; if(trim(strtolower($year))!="") $ret=$ret.", ".$year; $ret=$ret."."; } if($texType=="article"){ $journ=extractBib("journal",$texEntry); if($journ=="") //might be a book chapter... $journ=extractBib("book",$texEntry); if(trim(strtolower($journ))!=""){ $ret=$ret." In ".$journ.""; $vol=extractBib("volume",$texEntry); if(trim(strtolower($vol))!="") $ret=$ret.", ".$vol; $numb=extractBib("number",$texEntry); if(trim(strtolower($numb))!="") $ret=$ret." (".str_replace("--","-",$numb).")"; $pages=extractBib("pages",$texEntry); if(trim(strtolower($pages))!="") $ret=$ret.": ".str_replace("--","-",$pages); if(trim(strtolower($year))!="") $ret=$ret.", ".$year; $ret=$ret."."; } } if($texType=="inproceedings"){ $booktitle=extractBib("booktitle",$texEntry); if(trim(strtolower($booktitle))!=""){ $ret=$ret." In ".$booktitle.""; $pages=extractBib("pages",$texEntry); if(trim(strtolower($pages))!="") $ret=$ret.", pages ".str_replace("--","-",$pages); $publisher=extractBib("publisher",$texEntry); if(trim(strtolower($publisher))!="") $ret=$ret.", ".$publisher; if(trim(strtolower($year))!="") $ret=$ret.", ".$year; $ret=$ret."."; } } if($texType=="book"){ $publisher=extractBib("publisher",$texEntry); if(trim(strtolower($publisher))!="") $ret=$ret." ".$publisher; $pubaddress=extractBib("address",$texEntry); if(trim(strtolower($pubaddress))!="") $ret=$ret.", ".$pubaddress; if(trim(strtolower($year))!="") $ret=$ret.", ".$year; $ret=$ret."."; } }//end there is no predefined text to show, we create some if($addlinks){ global $createJumpMarks; global $addBreaksBeforeLinks; if($createJumpMarks){//KNSQbioClockGRNs $bibName=extractBibName($texEntry); $ret="".$ret; } $tempdat=extractBib("url",$texEntry); if($addBreaksBeforeLinks) $ret=$ret."
"; if($tempdat!="") $ret=$ret." (link) "; $tempdat=extractBib("EE",$texEntry); if($tempdat!="") $ret=$ret." (file) "; //link to show complete bibtex entry - specific to this script global $SCRNAME; global $sep; global $args; $ret=$ret." (bibtex)"; if($texType=="book"){ $authSplit=split(",",$shortAuth); $authorOne=trim($authSplit[0]); $keywordphrase=str_replace(" ","%20",$title)."%20$authorOne"; $ret=$ret.searchIt($keywordphrase); } } return "
".$ret."
"; } function sel($i,$j){ if($i==$j) return "selected"; return ""; } //we are the upper part of frame if($args[0]=="head"){ echo ""; echo "\r\n"; echo "\r\n"; echo "
\r\n"; echo "
Sort entries ordered by (the further right the less important): $scriptInfo
"; if($shortVersion==1) for($i=0;$i<4;$i++){ echo ""; } else for($i=0;$i<8;$i++){ echo ""; } echo "\r\n"; echo "
\r\n"; echo "
\r\n"; if($shortVersion==1) echo "\r\n"; else echo "\r\n"; echo "\r\n"; echo "\r\n"; echo " This is a OAI / Dublin Core repository, sitemap available
"; if(is_writable($filename)){ if($hideAdmin){ echo "
\r\n"; echo "



"; } echo "\r\n"; } echo "
\r\n"; echo "
\r\n"; echo "\r\n"; die; } //begin read xml data file function trustedFile($file) { // only trust local files owned by ourselves if (!eregi("^([a-z]+)://", $file) && fileowner($file) == getmyuid()) { return true; } return false; } function startElement($parser, $name, $attribs) //opening, i.e. { global $titleData; global $authorData; global $acquiredData; global $ratingData; global $commentData; global $topicData; global $languageData; global $typeData; global $bibtexData; if($name=="TEXT"){ $topicData=""; $titleData=""; $authorData=""; $acquiredData=""; $ratingData=""; $commentData=""; $languageData=""; $typeData=""; $bibtexData=""; } else{ global $current; $$current=trim($$current); $current=strtolower($name)."Data"; } //no attributes used, ignore $attribs... } function endElement($parser, $name) //closing, i.e. { if($name=="TEXT"){ global $titleData; global $authorData; global $acquiredData; $acquiredData=trim($acquiredData); global $ratingData; global $commentData; global $bibtexData; $bibtexData=trim($bibtexData); global $textsArray; global $topicData; global $languageData; global $typeData; global $args; global $bibTexCnt; if(($args[0]=="edit")&&($args[2]=="d")&&(intval($args[1])==sizeof($textsArray))){ //delete entry by ignoring it, but only one entry! $args[1]="-1"; } else{ if($bibtexData!="") $bibTexCnt++; $textsArray[]=array( //create text entry in our array 'Language' => $languageData, 'Type' => $typeData, 'Title' => $titleData, 'Author' => $authorData, 'Acquired' => $acquiredData, 'Topic' => $topicData, 'Rating' => $ratingData, 'Comment' => $commentData, 'BibTex' => $bibtexData); } } } function characterData($parser, $data) //plain text like this { global $current; global $titleData; global $authorData; global $acquiredData; global $ratingData; global $commentData; global $bibtexData; global $topicData; global $languageData; global $typeData; $$current=$$current.$data; } function PIHandler($parser, $target, $data) { switch (strtolower($target)) { case "php": global $parser_file; // If the parsed document is "trusted", we say it is safe // to execute PHP code inside it. If not, display the code // instead. if (trustedFile($parser_file[$parser])) { eval($data); } else { printf("Untrusted PHP code: %s", htmlspecialchars($data)); } break; } } function defaultHandler($parser, $data) { return; } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { if ($systemId) { if (!list($parser, $fp) = new_xml_parser($systemId)) { printf("Could not open entity %s at %s\r\n", $openEntityNames, $systemId); return false; } while ($data = fread($fp, 4096)) { if (!xml_parse($parser, $data, feof($fp))) { printf("XML error: %s at line %d while parsing entity %s\r\n", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), $openEntityNames); xml_parser_free($parser); return false; } } xml_parser_free($parser); return true; } return false; } function new_xml_parser($file) { global $parser_file; $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_set_processing_instruction_handler($xml_parser, "PIHandler"); xml_set_default_handler($xml_parser, "defaultHandler"); xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler"); if (!($fp = @fopen($file, "r"))) { return false; } if (!is_array($parser_file)) { settype($parser_file, "array"); } $parser_file[$xml_parser] = $file; return array($xml_parser, $fp); } if (!(list($xml_parser, $fp) = new_xml_parser($filename))) { echo ""; echo "Could not open XML input.
Maybe the database file ".$filename." is missing?
It should be placed in the same directory as the script and contain at least:
".str_replace(">",">",str_replace("<","<",$libStart.""));
    echo "
"; die(""); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d\r\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); // Obtain a list of columns $col=array(array(),array(),array(),array(),array(),array(),array(),array(),array()); foreach ($textsArray as $key => $row) { $col[0][$key] = $row['Language']; $col[1][$key] = $row['Type']; $col[2][$key] = $row['Title']; $col[3][$key] = $row['Author']; $col[4][$key] = $row['Topic']; $col[5][$key] = $row['Rating']; $col[6][$key] = $row['Comment']; $col[7][$key] = $row['Acquired']; $col[8][$key] = $row['BibTex']; $col[9][$key] = $key; } //end read xml data file //we are lower part of the frame //print_r($textsArray); //replace old file completly function writeLibrary(){ global $filename; global $col; global $name; global $libStart; ignore_user_abort(); if (!($f=fopen($filename,"a+"))) { return false; } ftruncate($f,0); fputs($f,$libStart); for($n=0;$n\r\n"); for($i=0;$i<9;$i++){ fputs($f," <".$name[$i].">".htmlspecialchars($col[$i][$n], ENT_QUOTES)."\r\n"); } fputs($f," \r\n"); } fputs($f,"
"); fclose($f); } //check over entered strings and return corrected version - currently only for changing special chars in German function correct ( $string ) { $fixed = htmlspecialchars( $string, ENT_QUOTES ); $trans_array = array(); for ($i=127; $i<255; $i++) { $trans_array[chr($i)] = "&#" . $i . ";"; } $really_fixed = strtr($fixed, $trans_array); return str_replace("\\","",trim($really_fixed)); } $admin=false; if((sizeof($args)>2)&&(($args[2]=="admin")||($args[3]=="admin")||($args[4]=="admin")||($args[5]=="admin")||($args[6]=="admin")||($args[7]=="admin"))&&(is_writable($filename))){ $admin=true; } function printDC($key,$val,$format){ if($format) echo "$val\r\n"; else echo "\r\n"; } //$i is the number of the entry and $format is true for OAI and false for HTML header data //N.B.: A bibtex is expected otherwise the data is really poor!!! function getDCdata($i,$format){ global $sep; global $col; $texEntry=$col[8][$i]; if($format) echo ""; printDC("title",$col[2][$i],$format); $author=extractBib("author",$texEntry); if($author!=""){ $ttt=explode(" and ",$author); for($j=0;$j"; } //determines whether the date ds is in the from-until range (both from and until might be empty) function isInRange($dd,$from,$until){ $ddstamp=strtotime($dd,0); if((!$ddstamp)||($ddstamp<0)) return true; if(($ddstamp>=$from)&&($ddstamp<=$until)) return true; else return false; } if($QUERY_STRING=="sitemap.xml"){ echo " \r\n"; for($i=0;$i http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]."?bibtex$sep".$i." ".$col[7][$i]." monthly "; } echo "\r\n"; die(); } //BEGIN OAI INTERFACE PART if((stristr($QUERY_STRING,"verb")!=false)||(stristr($QUERY_STRING,"junk")!=false)){ $QUERY_STRING=urldecode($QUERY_STRING); $args=explode("&",$QUERY_STRING); echo " ".date("Y-m-d")."T".date("H:i:s")."Z http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"].""; if($QUERY_STRING=="junk") { echo "At least verb required!"; echo "\r\n"; die(); } if(isset($arg["resumptionToken"])) { echo "Resumption token not supported."; echo "Resumption token not supported."; echo "\r\n"; die(); } if((strlen($arg["from"])>0)&&(strlen($arg["until"])>0)&&(strlen($arg["from"])!=strlen($arg["until"]))) { echo "Different granularities for the from and until parameters."; echo "\r\n"; die(); } if($arg["until"]=="1969-01-01") { echo "Stupid date/time!"; echo "\r\n"; die(); } $fromstamp=strtotime($arg["from"],0); if((!$fromstamp)||($fromstamp<0)) $fromstamp=-1; $untilstamp=strtotime($arg["until"],0); if((!$untilstamp)||($untilstamp<0)) $untilstamp=intval('999999999999999999999999999999'); if(((strlen($arg["from"])>0)&&($fromstamp<0))||((strlen($arg["until"])>0)&&($untilstamp>intval('999999999999999999999999999999')-1))) { echo "Invalid date/time format!"; echo "\r\n"; die(); } if(stristr($arg["verb"],"Identify")!=false) echo " ".$title." http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]." 2.0 ".$contact." 1970-01-01 no YYYY-MM-DD oai ".$identifier." : oai:$identifier:6 "; else if(stristr($arg["verb"],"ListMetadataFormats")!=false) echo " oai_dc http://www.openarchives.org/OAI/2.0/oai_dc.xsd http://www.openarchives.org/OAI/2.0/oai_dc/ "; else if(stristr($arg["verb"],"ListSets")!=false) echo " $identifier $title "; else if(stristr($arg["verb"],"ListIdentifiers")!=false){ echo ""; for($i=0;$i oai:$identifier:$i ".$col[7][$i]." $identifier "; echo ""; } else if(stristr($arg["verb"],"ListRecords")!=false){ if((!isset($arg["metadataPrefix"]))||(strlen($arg["metadataPrefix"])==0)){ echo "Valid metadataPrefix required!"; echo "\r\n"; die(); } $oneMatched=false; for($i=0;$i"; } echo "
oai:$identifier:$i ".$col[7][$i]." $identifier
\r\n"; getDCdata($i,true); echo "
"; } if(!$oneMatched){ echo "Not a single record matched!"; echo "\r\n"; die(); } else echo ""; } else if(stristr($arg["verb"],"GetRecord")!=false){ $ttt=explode(":",$arg["identifier"]); if((!isset($arg["identifier"]))||(strlen($arg["identifier"])==0)||(!isset($arg["metadataPrefix"]))||(strlen($arg["metadataPrefix"])==0)||(!isset($ttt[2]))||(strlen($ttt[2])==0)){ echo "Valid identifier and metadataPrefix required!"; echo "\r\n"; die(); } $i=intval($ttt[2]); echo "
oai:$identifier:$i ".$col[7][$i]." $identifier
\r\n"; getDCdata($i,true); echo "
"; } else{ echo "Unnkown verb argument!"; echo "Check syntax!"; echo "Check syntax!"; } echo "\r\n"; die(); } //END OAI INTERFACE PART if($args[0]=="downloadBib"){ if($bibTexCnt>0){ header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=\"".str_replace(".xml",".bib",$downloadFilename)."\""); for($n=0;$n \r\n"; getDCdata($dataPos,false); if(($dataPos<0)||($dataPos>=sizeof($col[9]))) $dataPos=-1; //protect array error if($dataPos==-1) echo "BibTex entry not found!"; else{ $titleString="Reference and Bibtex for ".$col[2][$dataPos]." by ".$col[3][$dataPos]; echo "\r\n"; echo "\r\n"; echo "\r\n"; echo "\r\n"; echo ""; echo "\r\n$titleString\r\n
Show full list$scriptInfo
"; echo "

Reference:

\r\n
".bibtex2html($col[8][$dataPos],$col[9][$dataPos],false)."
\r\n"; echo "

Bibtex:

\r\n
".$col[8][$dataPos]."
\r\n"; echo "

Other information:

\r\n
"; $tempdat=extractBib("url",$col[8][$dataPos]); if($tempdat!=""){ echo "Associated URL:
  $tempdat\r\n
"; } $tempdat=extractBib("EE",$col[8][$dataPos]); if($tempdat!=""){ echo "Electronic Edition:
  $tempdat\r\n
"; } for($i=0;$i<8;$i++){ echo "".$name[$i].":
  "; if(($i==6)&&(trim($col[$i][$dataPos])!="")) echo ""; else echo $col[$i][$dataPos]; echo "\r\n
"; } echo "\r\n
"; } echo "\r\n$searchiframes"; die(); } if(($admin)&&($args[0]=="edit")&&($args[2]=="d")){ //delete entry writeLibrary(); //write it $message=$message." Entry has been erased."; array_shift($args);//restore old parameter settings array_shift($args); array_shift($args); } if(($admin)&&(($args[0]=="edit")||($args[0]=="add"))){ if($args[2]=="y"){ //save changes if((isset($_POST["lang"]))&&($_POST["lang"]!="")){ if((isset($_POST["bibtex"]))&&($_POST["bibtex"]!="")){ //extract data from bibtex if(!((isset($_POST["author"]))&&($_POST["author"]!=""))){ $tempdat=extractBib("author",$_POST["bibtex"]); if($tempdat==""){ $tempdat=extractBib("editor",$_POST["bibtex"]); //surname first, better for sorting $attach=", ed."; } else $attach=""; $rest=""; if(($tempval=strpos($tempdat," and "))||($tempval=strpos($tempdat," and\r\n"))||($tempval=strpos($tempdat,"\r\nand "))){ //damn, several authors $tempdat=substr($tempdat,0,$tempval); $rest=" et. al."; } $_POST["author"]=strrchr($tempdat," ").", ".substr($tempdat,0,strrpos($tempdat," ")).$rest.$attach; } if(!((isset($_POST["title"]))&&($_POST["title"]!=""))) $_POST["title"]=extractBib("title",$_POST["bibtex"]); if(!((isset($_POST["type"]))&&($_POST["type"]!=""))){ $_POST["type"]=extractBibType($_POST["bibtex"]); } } $dataPos=intval($args[1]); if(($dataPos<0)||($dataPos>=sizeof($col[9]))) $dataPos=-1; //protect array error if($dataPos==-1){ //new entry array_push($col[0],correct($_POST["lang"])); array_push($col[1],correct($_POST["type"])); array_push($col[2],correct($_POST["title"])); array_push($col[3],correct($_POST["author"])); array_push($col[4],correct($_POST["topic"])); array_push($col[5],correct($_POST["rating"])); array_push($col[6],correct($_POST["comment"])); array_push($col[7],correct($_POST["acquired"])); array_push($col[8],correct($_POST["bibtex"])); array_push($col[9],sizeof($col[9])); } else{ $col[0][$dataPos]=correct($_POST["lang"]); $col[1][$dataPos]=correct($_POST["type"]); $col[2][$dataPos]=correct($_POST["title"]); $col[3][$dataPos]=correct($_POST["author"]); $col[4][$dataPos]=correct($_POST["topic"]); $col[5][$dataPos]=correct($_POST["rating"]); $col[6][$dataPos]=correct($_POST["comment"]); $col[7][$dataPos]=correct($_POST["acquired"]); $col[8][$dataPos]=correct($_POST["bibtex"]); } writeLibrary(); //write it $message=$message." Data has been saved."; } else $message=$message." Incomplete Data, not saved!"; array_shift($args);//restore old parameter settings array_shift($args); array_shift($args); } else{ //show form to allow user to make changes if($args[0]=="edit"){ $langVal=$col[0][intval($args[1])]; $typeVal=$col[1][intval($args[1])]; $titleVal=$col[2][intval($args[1])]; $authorVal=$col[3][intval($args[1])]; $topicVal=$col[4][intval($args[1])]; $ratingVal=$col[5][intval($args[1])]; $commentVal=$col[6][intval($args[1])]; $acquiredVal=$col[7][intval($args[1])]; $bibtexVal=$col[8][intval($args[1])]; }else{ $langVal="en"; $typeVal=""; $titleVal=""; $authorVal=""; $topicVal=""; $ratingVal=""; $commentVal=""; $acquiredVal=date("Y-m-d"); $bibtexVal=""; } echo ""; echo "\r\n"; echo "\r\n"; echo "
\r\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
language: comment:
type:
title:
author:
topic:
rating (1-5):
acquired:
\r\n"; echo "\r\n"; if($args[0]=="edit") echo "\r\n"; echo "   You can also paste a Bibtex entry below; type, author and title will be extracted from it.
"; echo "Bibtex entry here if available:
"; echo "
"; echo "\r\n"; echo "\r\n"; die(); } } if((sizeof($args)>1)&&($args[1]!="")&&($args[1]!="short")&&($args[1]!="detailed")){ $order=explode(",",$args[1]); } else $order=$defaultSort; //print_r($col); @array_multisort($col[$order[0]],SORT_DESC, $col[$order[1]],SORT_DESC, $col[$order[2]],SORT_DESC, $col[$order[3]],SORT_DESC, $col[$order[4]],SORT_DESC, $col[$order[5]],SORT_DESC, $col[$order[6]],SORT_DESC, $col[$order[7]],SORT_DESC, $col[8],SORT_DESC, $col[9],SORT_DESC); $atypecounts=array_count_values(array_map("strtolower",$col[1])); arsort($atypecounts); $atypes=array_keys($atypecounts); $atypesflip=array_flip($atypes); $atopiccounts=array_count_values(array_map("strtolower",$col[4])); arsort($atopiccounts); $atopics=array_keys($atopiccounts); $atopicsflip=array_flip($atopics); echo ""; if($admin){ echo ""; } echo " \r\n"; if($checkLoad!=-1) echo "\r\n"; else echo "\r\n"; if($admin){ echo "\r\n"; echo $message."
"; } //begin filter form echo "
Show: "; echo " AND "; echo ""; echo "
"; //end filter form if(($shortVersion==1)&&(!$admin)){ echo ""; for($n=0;$n"; echo ""; } echo "
"; if(trim($col[8][$n])!="") echo bibtex2html($col[8][$n],$col[9][$n]); else{ $au=shortenAuthors($col[3][$n]); echo "
".$au; if($au[strlen($au)-1]!="."){ echo ".";} echo " ".$col[2][$n].""; if($col[2][$n][strlen(trim($col[2][$n]))-1]!="."){ echo ".";} $authSplit=split(",",$au); $authorOne=trim($authSplit[0]); $keywordphrase=str_replace(" ","%20",$col[2][$n])."%20$authorOne"; echo " (no bibtex) ".searchIt($keywordphrase)."
"; } echo "
"; } else { //begin print table echo ""; if($admin) echo ""; if($bibTexCnt>0) echo ""; echo $headline."\r\n"; for($n=0;$n"; if($admin) echo ""; if($bibTexCnt>0){ if($col[8][$n]!="") echo ""; else echo ""; } for($i=0;$i<8;$i++){ if(($i==2)&&($showEE)){//special for making the title a link to the electronic edition ("EE" or "url") $tempdat=extractBib("url",$col[8][$n]); if($tempdat=="") $tempdat=extractBib("EE",$col[8][$n]); if($tempdat!="") echo ""; else echo ""; } else if(($i==6)&&(trim($col[$i][$n])!=""))//special for multiline textarea //Alternative: but is not searchable... echo ""; else echo ""; } echo "\r\n"; } echo "
EditBibTex
editbibtex".$col[$i][$n]."".$col[$i][$n]."".$col[$i][$n]."
\r\n"; //end print table } echo "\r\n$searchiframes"; echo "\r\n"; ?>