public static function getInstance($db) { if (self::$instance === null) { self::$instance = new self($db); } return self::$instance; }
/** * writeFedora - */ function writeFedora($nodeId, $node) { $flag = false; $namespace = $this->namespace; $nextPid = $nodeId; $pidName = $namespace; $pidNum = $nextPid; $ext = 'pdf'; $authors = array(); $contributorsList = $this->makeAuthorsArray($nodeId); // list out authors if (count($contributorsList)) { foreach ($contributorsList as $contributor) { $authors[] = $this->xmlifyDataFilter($contributor); } } else { $authors = null; } // build list of keywords for subject $keywordsList = $this->getKeywordsList($nodeId); $publishers[] = $node['biblio_publisher']; $publishers[] = $node['biblio_remote_db_provider']; $type = $this->getPublicationType($node['biblio_type']); // translate number into human word $host = $_SERVER['SERVER_NAME']; // if year is 9999 make it blank, we don't want to store the biblio centric "no year" marker $year = $node['biblio_year'] == 9999 ? '' : $node['biblio_year']; $this->fedoraFoxXml->clearData(); $this->fedoraFoxXml->subjectName = $pidName; $this->fedoraFoxXml->state = 'A'; // active $this->fedoraFoxXml->controlGrp = 'X'; // xml $this->fedoraFoxXml->baseUrl = htmlentities($node['biblio_url'], ENT_QUOTES, 'UTF-8'); // make friendly to the xml parser in Fedora // package up the data $this->fedoraFoxXml->title = $this->xmlifyDataFilter($node['title']); $this->fedoraFoxXml->creator = $authors; $this->fedoraFoxXml->subject = $keywordsList; // grab any keywords and put in the subject field $this->fedoraFoxXml->description = $this->xmlifyDataFilter($node['biblio_abst_e']); $this->fedoraFoxXml->publisher = $publishers; $this->fedoraFoxXml->identifier = 'http://' . $host . '/node/' . $nodeId; $this->fedoraFoxXml->contributor = ''; // empty $this->fedoraFoxXml->date = $year; $this->fedoraFoxXml->type = $type; // translated to words from code number $this->fedoraFoxXml->format = ''; $this->fedoraFoxXml->source = htmlentities($node['biblio_url'], ENT_QUOTES, 'UTF-8'); $this->fedoraFoxXml->language = $node['biblio_lang']; $this->fedoraFoxXml->relation = ''; $this->fedoraFoxXml->coverage = ''; $rights = new RightsModel(); $rights->setFromNode($node); $this->fedoraFoxXml->rights = '' . $rights; // sets the rights, listed pipe delimited values, for: status, statement, license name, license url $this->fedoraFoxXml->pidName = $pidName; $this->fedoraFoxXml->pid = $pidNum; $xml = $this->fedoraFoxXml->buildFoxXml($ext); $this->fedoraClient->pid = $pidName . ':' . $pidNum; $this->fedoraClient->pidName = $pidName; $this->fedoraClient->pidNum = $pidNum; if ($this->loggingFlag) { fedora_watchmen('fox xml author name ' . $this->fedoraFoxXml->contributor); } // create the fox xml file $this->fedoraClient->saveFoxFiles($xml); // feed fedora the data $this->fedoraClient->httpcode = 200; // clear it to good so we don't have confusion with setting elsewhere in isExists. $resp = $this->fedoraClient->sendData($xml, $pidName, $pidNum); // an error has something like "Fedora: 401" // success has basically like "citebank:12345" if ($this->loggingFlag) { if ($this->fedoraClient->httpcode != 200) { fedora_watchmen('sendData resp ' . $this->fedoraClient->httpcode); } } if (strstr($resp, $pidName . ':' . $pidNum)) { $flag = true; } // done return $flag; }
/** * makeIARecordMetaData - create the meta data for the nid item to use for an Internet Archive entry */ function makeIARecordMetaData($nid) { $metaData = array(); // given nid, get the biblio data, title $node = $this->getBiblioData($nid); // fill in metadata // send back the array /* title year publisher biblio data? */ $biblio_abst_e = isset($node['biblio_abst_e']) ? $node['biblio_abst_e'] : ''; $biblio_abst_f = isset($node['biblio_abst_f']) ? $node['biblio_abst_f'] : ''; $biblio_access_date = isset($node['biblio_access_date']) ? $node['biblio_access_date'] : ''; $biblio_accession_number = isset($node['biblio_accession_number']) ? $node['biblio_accession_number'] : ''; $biblio_alternate_title = isset($node['biblio_alternate_title']) ? $node['biblio_alternate_title'] : ''; $biblio_auth_address = isset($node['biblio_auth_address']) ? $node['biblio_auth_address'] : ''; $biblio_call_number = isset($node['biblio_call_number']) ? $node['biblio_call_number'] : ''; $biblio_citekey = isset($node['biblio_citekey']) ? $node['biblio_citekey'] : ''; $biblio_coins = isset($node['biblio_coins']) ? $node['biblio_coins'] : ''; $biblio_contributors = isset($node['biblio_contributors']) ? $node['biblio_contributors'] : array(); $biblio_custom1 = isset($node['biblio_custom1']) ? $node['biblio_custom1'] : ''; $biblio_custom2 = isset($node['biblio_custom2']) ? $node['biblio_custom2'] : ''; $biblio_custom3 = isset($node['biblio_custom3']) ? $node['biblio_custom3'] : ''; $biblio_custom4 = isset($node['biblio_custom4']) ? $node['biblio_custom4'] : ''; $biblio_custom5 = isset($node['biblio_custom5']) ? $node['biblio_custom5'] : ''; $biblio_custom6 = isset($node['biblio_custom6']) ? $node['biblio_custom6'] : ''; $biblio_custom7 = isset($node['biblio_custom7']) ? $node['biblio_custom7'] : ''; $biblio_date = isset($node['biblio_date']) ? $node['biblio_date'] : ''; $biblio_doi = isset($node['biblio_doi']) ? $node['biblio_doi'] : ''; $biblio_edition = isset($node['biblio_edition']) ? $node['biblio_edition'] : ''; $biblio_full_text = isset($node['biblio_full_text']) ? $node['biblio_full_text'] : ''; $biblio_isbn = isset($node['biblio_isbn']) ? $node['biblio_isbn'] : ''; $biblio_issn = isset($node['biblio_issn']) ? $node['biblio_issn'] : ''; $biblio_issue = isset($node['biblio_issue']) ? $node['biblio_issue'] : ''; $biblio_keywords = isset($node['biblio_keywords']) ? $node['biblio_keywords'] : array(); $biblio_label = isset($node['biblio_label']) ? $node['biblio_label'] : ''; // sourcePrj; $biblio_lang = isset($node['biblio_lang']) ? $node['biblio_lang'] : ''; $biblio_notes = isset($node['biblio_notes']) ? $node['biblio_notes'] : ''; $biblio_number = isset($node['biblio_number']) ? $node['biblio_number'] : ''; $biblio_number_of_volumes = isset($node['biblio_number_of_volumes']) ? $node['biblio_number_of_volumes'] : ''; $biblio_original_publication = isset($node['biblio_original_publication']) ? $node['biblio_original_publication'] : ''; $biblio_other_number = isset($node['biblio_other_number']) ? $node['biblio_other_number'] : ''; $biblio_pages = isset($node['biblio_pages']) ? $node['biblio_pages'] : ''; $biblio_place_published = isset($node['biblio_place_published']) ? $node['biblio_place_published'] : ''; $biblio_publisher = isset($node['biblio_publisher']) ? $node['biblio_publisher'] : ''; $biblio_refereed = isset($node['biblio_refereed']) ? $node['biblio_refereed'] : ''; $biblio_remote_db_name = isset($node['biblio_remote_db_name']) ? $node['biblio_remote_db_name'] : ''; // sourceUrl; $biblio_remote_db_provider = isset($node['biblio_remote_db_provider']) ? $node['biblio_remote_db_provider'] : ''; // sourceOrg; $biblio_reprint_edition = isset($node['biblio_reprint_edition']) ? $node['biblio_reprint_edition'] : ''; $biblio_research_notes = isset($node['biblio_research_notes']) ? $node['biblio_research_notes'] : ''; $biblio_secondary_title = isset($node['biblio_secondary_title']) ? $node['biblio_secondary_title'] : ''; $biblio_section = isset($node['biblio_section']) ? $node['biblio_section'] : ''; $biblio_short_title = isset($node['biblio_short_title']) ? $node['biblio_short_title'] : ''; $biblio_tertiary_title = isset($node['biblio_tertiary_title']) ? $node['biblio_tertiary_title'] : ''; //$biblio_title = (isset($node['biblio_title']) ? $node['biblio_title'] : ''); $biblio_title = isset($node['title']) ? $node['title'] : ''; $biblio_translated_title = isset($node['biblio_translated_title']) ? $node['biblio_translated_title'] : ''; $biblio_type = isset($node['biblio_type']) ? $node['biblio_type'] : ''; $biblio_type_of_work = isset($node['biblio_type_of_work']) ? $node['biblio_type_of_work'] : ''; $biblio_url = isset($node['biblio_url']) ? $node['biblio_url'] : ''; $biblio_volume = isset($node['biblio_volume']) ? $node['biblio_volume'] : ''; $biblio_year = isset($node['biblio_year']) ? $node['biblio_year'] : ''; // ****************************** // set the meta data // //$metaData['type'] = $biblio_type; //$metaData['number'] = $biblio_number; //$metaData['other_number'] = $biblio_other_number; if ($biblio_secondary_title) { $metaData['secondary_title'] = $biblio_secondary_title; } if ($biblio_tertiary_title) { $metaData['tertiary_title'] = $biblio_tertiary_title; } if ($biblio_edition) { $metaData['edition'] = $biblio_edition; } if ($biblio_publisher) { $metaData['publisher'] = $biblio_publisher; } if ($biblio_place_published) { $metaData['place_published'] = $biblio_place_published; } $biblio_year = $this->filterOddChars($biblio_year); // no neg years please if ($biblio_year != 9999) { $metaData['year'] = $biblio_year; } if ($biblio_volume) { $metaData['volume'] = $biblio_volume; } if ($biblio_pages) { $metaData['pages'] = $biblio_pages; } if ($biblio_date) { $metaData['date'] = $biblio_date; } //$metaData['isbn'] = $biblio_isbn; if ($biblio_lang) { $metaData['language'] = $biblio_lang; } if ($biblio_abst_e) { $metaData['abstract'] = $biblio_abst_e; } if ($biblio_abst_f) { $metaData['abstract_f'] = $biblio_abst_f; } if ($biblio_full_text) { $metaData['full_text'] = $biblio_full_text; } // if ($biblio_url) { // $metaData['url'] = $biblio_url; // } // use the citebank url to the item $host = $this->host; $metaData['url'] = 'http://' . $host . '/node/' . $nid; if ($biblio_issue) { $metaData['issue'] = $biblio_issue; } // add in publication type text, as in: Journal Article if ($biblio_type) { $metaData['publication_type'] = $this->getPublicationType($biblio_type); // translate number into human word } if ($biblio_type_of_work) { $metaData['type_of_work'] = $biblio_type_of_work; } if ($biblio_accession_number) { $metaData['accession_number'] = $biblio_accession_number; } if ($biblio_call_number) { $metaData['call_number'] = $biblio_call_number; } if ($biblio_notes) { $metaData['notes'] = $biblio_notes; } // Rights $rights = new RightsModel(); $metaData = $rights->setIAMetaData($metaData, $biblio_year, $biblio_custom1, $biblio_custom2, $biblio_custom3, $biblio_custom4); // if ($biblio_custom1) { // $metaData['rights'] = $biblio_custom1; // } //$metaData['custom1'] = $biblio_custom1; //$metaData['custom2'] = $biblio_custom2; //$metaData['custom3'] = $biblio_custom3; //$metaData['custom4'] = $biblio_custom4; //$metaData['custom5'] = $biblio_custom5; //$metaData['custom6'] = $biblio_custom6; //$metaData['custom7'] = $biblio_custom7; if ($biblio_research_notes) { $metaData['research_notes'] = $biblio_research_notes; } if ($biblio_number_of_volumes) { $metaData['number_of_volumes'] = $biblio_number_of_volumes; } if ($biblio_short_title) { $metaData['short_title'] = $biblio_short_title; } if ($biblio_alternate_title) { $metaData['alternate_title'] = $biblio_alternate_title; } if ($biblio_original_publication) { $metaData['original_publication'] = $biblio_original_publication; } if ($biblio_reprint_edition) { $metaData['reprint_edition'] = $biblio_reprint_edition; } if ($biblio_translated_title) { $metaData['translated_title'] = $biblio_translated_title; } if ($biblio_section) { $metaData['section'] = $biblio_section; } //$metaData['citekey'] = $biblio_citekey; //$metaData['coins'] = $biblio_coins; if ($biblio_doi) { $metaData['doi'] = $biblio_doi; } //$metaData['issn'] = $biblio_issn; if ($biblio_auth_address) { $metaData['auth_address'] = $biblio_auth_address; } //$metaData['remote_db_name'] = $biblio_remote_db_name; //$metaData['remote_db_provider'] = $biblio_remote_db_provider; //$metaData['label'] = $biblio_label; if ($biblio_remote_db_provider) { $metaData['source_organization'] = $biblio_remote_db_provider; } if ($biblio_remote_db_name) { $metaData['source_url'] = $biblio_remote_db_name; } if ($biblio_label) { $metaData['source_project'] = $biblio_label; } if ($biblio_access_date) { $metaData['access_date'] = $biblio_access_date; } if ($biblio_refereed) { $metaData['refereed'] = $biblio_refereed; } if ($biblio_title) { $metaData['title'] = $biblio_title; } // xml clean for accents and such all the meta data foreach ($metaData as $key => $val) { //$metaData[$key] = $this->cleanTitle($val); //$metaData[$key] = htmlentities(utf8_encode($val), ENT_QUOTES, 'UTF-8'); $metaData[$key] = $this->xmlUtf8Clean($val); } // handle authors, "creator"s in IA terms if ($biblio_contributors) { $authors = ''; foreach ($biblio_contributors as $biblio_contributorskeys => $author) { //$authorName = htmlentities(utf8_encode($this->filterIASymbols($author['name'])), ENT_QUOTES, 'UTF-8'); $authorName = $this->xmlUtf8ScrubClean($author['name']); $authors .= $authorName; $authors .= '|'; } $authors = rtrim($authors, '|'); // in the S3 model, the xml tags are created for each piped item $metaData['creator'] = $authors; $msg = 'metadata: authors(' . print_r($metaData['creator'], 1) . ')'; $this->watchdog($msg); } // handle keywords, "subject"s in IA terms if ($biblio_keywords) { $keywords = ''; foreach ($biblio_keywords as $keywordkeys => $keyword) { //$keywordItem = htmlentities(utf8_encode($this->filterIASymbols($keyword['word'])), ENT_QUOTES, 'UTF-8'); $keywordItem = $this->xmlUtf8ScrubClean($keyword['word']); $keywords .= $keywordItem; $keywords .= '|'; } $keywords = rtrim($keywords, '|'); $metaData['subject'] = $keywords; $msg = 'metadata: subjects(' . print_r($metaData['subject'], 1) . ')'; $this->watchdog($msg); } //$metaData['description'] = ''; //$metaData['sponsor'] = 'Missiouri Botanical Garden'; /* <identifier>threenewlizardso00brow</identifier> <description>Beviora, no.464-487 (1981-1986), pp.1-12</description> <language>eng</language> <mediatype>texts</mediatype> <subject>Reptiles</subject> <title>Three new lizards of the genus Emoia (Scincidae) from southern New Guinea.</title> <collection>opensource</collection> <creator>W. C. Brown</creator> <creator>F. Parker</creator> <uploader>mike.lichtenberg@mobot.org</uploader> <identifier-access>http://www.archive.org/details/threenewlizardso00brow</identifier-access> <identifier-ark>ark:/13960/t3320fq6x</identifier-ark> <ppi>300</ppi> <ocr>ABBYY FineReader 8.0</ocr> <publicdate>2009-09-16 18:50:44</publicdate> */ // ****************************** return $metaData; }