XML_Parser_Simple(); } /** * handle the element * * The element will be handled, once it's closed * * @access private * @param string name of the element * @param array attributes of the element * @param string character data of the element */ function handleElement($name, $attribs, $data) { /* printf('handling %s in tag depth %d
', $name, $this->getCurrentDepth()); printf('character data: %s
', $data ); print 'Attributes:
'; print '
';
        print_r( $attribs );
        print '
'; print '
'; */ if ($name == "LINK") { $this->link_data = $data; } if ($name == "TITLE") { $this->title = $data; } } } ////////////////////////////////////////////////////// // Detritus from the Hello, Dolly wordpress plugin, may be useful one day again: // We need some CSS to position the paragraph function connoshow_css() { echo " "; } function id2html($id) { $data_url = "http://www.connotea.org/data/uri/".$id; $human_url = "http://www.connotea.org/uri/".$id; $req =& new HTTP_Request($data_url); $req->setBasicAuth(YOURUSERNAME, YOURPASSWORD); $response = $req->sendRequest(); if (PEAR::isError($response)) { // FIXME: error handling? return "failed getting URL:".$response->getMessage(); } // create temporary file $fname = "/tmp/connoshow-dl.xml"; $fp = fopen($fname,"wb"); fputs($fp,$req->getResponseBody()); fclose($fp); $p = &new myParser(); $result = $p->setInputFile($fname); $result = $p->parse(); if ($p->link_data == False) { return "bad Connotea link"; } return "\"". $p->title ."\"[Connotea|link]"; } function addconno($text) { preg_match_all("#\[conno\](.*?)\[/conno\]#si",$text,$conno_matches); for ($i=0; $i < count($conno_matches[0]); $i++) { $pos = strpos($text, $conno_matches[0][$i]); $conno_id = $conno_matches[1][$i]; $newtext = id2html($conno_id); $text = substr_replace($text, $newtext, $pos, strlen($conno_matches[0][$i])); } return $text; } //add_filter('the_title', 'addconno'); add_filter('the_content', 'addconno'); //add_filter('the_excpert', 'addconno'); ?>