citation = trim($citation); $this->journal = trim($journal); $this->authors = trim($authors); $this->pdf = trim($pdf); $this->year = trim( $year); $this->num = trim( $num); $this->title = trim( $title); $this->type = trim( $type); } // init function scatter( &$citation, &$journal, &$authors, &$pdf, &$year, &$num, &$title, &$type) { $citation = $this->citation; $journal = $this->journal; $authors = $this->authors; $pdf = $this->pdf; $year = $this->year; $num = $this->num; $title = $this->title; $type = $this->type; } } // class person function readDatabase($filename, $demo_mode) { // ************************************* // *** read the xml database // ************************************* $data = implode("",file($filename)); $parser = xml_parser_create(); xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); $num_rows = xml_parse_into_struct($parser,$data,$values,$tags); xml_parser_free($parser); // ************************************* // *** end of xml code // ************************************* // ************************************* // demo what the xml array looks like // ************************************* if ($demo_mode == 11220) { echo "
";
   print_r( $values);
   echo "
"; } // ************************************* // loop through the structures // ************************************* $i = 0; do { if( $values[$i]['level'] == 3) { $fred = $values[$i]['tag']; $$fred = $values[$i]['value']; // ssecho "$fred = $$fred \n"; } $i++; $typexml = $values[$i]['type']; $level = $values[$i]['level']; if( $typexml == "close" && $level == 2) { $pp[] = new article($cit,$jnl,$auth,$pdf,$year,$num,$title,$type); $cit = $jnl = $auth = $pdf = $year = $num = $title = ""; // echo "$fn $email $off $phn \n"; } } while (! ($typexml == "close" && $level == 1)); return $pp; } // function readDatabase // ****************************************************** // ************** custom sort function ****************** // ****************************************************** function alphasort($a, $b) { if( $a->type == "patent") { $aaaprefix = "bb" . $a->num; } else if ($a->type == "book") { $aaaprefix = "aa" ; } else { $aaaprefix = ""; } if( $b->type == "patent") { $bbbprefix = "bb" . $b->num; } else if ($b->type == "book") { $bbbprefix = "aa"; } else { $bbbprefix = ""; } if ( $aaaprefix . $a->year . $a->num == $bbbprefix . $b->year . $b->num ) return 0; return ( $aaaprefix . $a->year . $a->num < $bbbprefix . $b->year . $b->num ? 1 : -1); } // alphasort // ********************************************* // *** main program // ********************************************* while (list ($header, $value) = each ($HTTP_POST_VARS)) { $$header = $value; } $testing = 1; $demo_mode=1; $articles = readDatabase( "hnw.xmldata.txt", $demo_mode); $cnti = sizeof( $articles); usort( $articles, "alphasort"); if ($demo_mode == 1) { // *********************************************************** // ********** automatically create links to years ************ // *********************************************************** echo "Haydn Wadley Publications" . "\n" . '' . '' . '' . "\n
\n\n"; include "header.php"; echo "\n

Haydn Wadley Publications

\n" . '

' . "\n\n"; // ********************************************************* // ****************** list links to years ****************** // ********************************************************* $oldstate = "ssss"; for( $i = 0; $i < $cnti; $i++) { $articles[$i]->scatter( $citation, $journal, $authors, $pdf, $year, $num, $title, $type); if( $type == "patent" and $oldstate != $type) { $oldstate = $type; echo "\nPatents \n"; } if( $type == "book" and $oldstate != $type) { $oldstate = $type; echo "\nBooks \n"; echo "
Papers from "; } if( $type == "paper" and $oldstate != $year) { $oldstate = $year; echo "\n$year \n"; } } // create links in page echo "\n
" . "Many reprints are now available electronically.

"; // *********************************************************** // ********** create article citations *********************** // *********************************************************** echo "


\n"; $oldstate = "startstate"; echo ""; for( $i = 0; $i < $cnti; $i++) { $articles[$i]->scatter( $citation, $journal, $authors, $pdf, $year, $num, $title, $type); if( $type == "patent" and $oldstate == "startstate") { $oldstate = $type; echo "\n\n"; } if( $type == "book" and $oldstate == "patent") { $oldstate = $type; echo "\n\n"; } if( $oldstate == "book" and $type == "paper") { $oldstate = $year; echo "\n\n"; echo "\n\n"; } if( $type == "paper" and $oldstate != $year) { $oldstate = $year; echo "\n\n"; } $tmpstr = "PDF/" . $pdf; if (file_exists ( $tmpstr) && strlen( $tmpstr) > 4) { $ref1 = ""; $ref2 = ""; } else { $ref1 = $ref2 = ""; } if(strlen(trim($authors))<1) {$auth_separator = " ";} else {$auth_separator = ", ";} if( strlen( trim( $journal))< 2) { $journal_separator = " "; } else { $journal_separator = ", "; } // echo "debug ===$authors===

"; echo "\n\n" . "

"; echo "\n"; } // print all citations echo "

" . " Patents

" . " Books

Journal Articles

" . " $year

" . " $year
$num.$authors" . $auth_separator . ""$ref1$title$ref2", " . " $journal" . $journal_separator . $citation . "

"; include "ipm.footer.php"; } // demo only ?>