예제 #1
0
 /**
  * @param \File_MARC_Data_Field $field
  *
  * @return DataField
  */
 private function convertDataField(\File_MARC_Data_Field $field)
 {
     $tag = $field->getTag();
     $ind1 = $field->getIndicator(1);
     $ind2 = $field->getIndicator(2);
     $dataField = new DataField($tag, [$ind1, $ind2]);
     foreach ($field->getSubfields() as $subField) {
         $dataField->addSubField($this->convertSubfield($subField));
     }
     return $dataField;
 }
예제 #2
0
 /**
  * Returns the array element for the 'getAllRecordLinks' method
  *
  * @param File_MARC_Data_Field $field Field to examine
  *
  * @return array|bool                 Array on success, boolean false if no
  * valid link could be found in the data.
  */
 protected function getFieldData($field)
 {
     // Make sure that there is a t field to be displayed:
     if ($title = $field->getSubfield('t')) {
         $title = $title->getData();
     } else {
         return false;
     }
     $linkTypeSetting = isset($this->mainConfig->Record->marc_links_link_types) ? $this->mainConfig->Record->marc_links_link_types : 'id,oclc,dlc,isbn,issn,title';
     $linkTypes = explode(',', $linkTypeSetting);
     $linkFields = $field->getSubfields('w');
     // Run through the link types specified in the config.
     // For each type, check field for reference
     // If reference found, exit loop and go straight to end
     // If no reference found, check the next link type instead
     foreach ($linkTypes as $linkType) {
         switch (trim($linkType)) {
             case 'oclc':
                 foreach ($linkFields as $current) {
                     if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) {
                         $link = ['type' => 'oclc', 'value' => $oclc];
                     }
                 }
                 break;
             case 'dlc':
                 foreach ($linkFields as $current) {
                     if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) {
                         $link = ['type' => 'dlc', 'value' => $dlc];
                     }
                 }
                 break;
             case 'id':
                 foreach ($linkFields as $current) {
                     if ($bibLink = $this->getIdFromLinkingField($current)) {
                         $link = ['type' => 'bib', 'value' => $bibLink];
                     }
                 }
                 break;
             case 'isbn':
                 if ($isbn = $field->getSubfield('z')) {
                     $link = ['type' => 'isn', 'value' => trim($isbn->getData()), 'exclude' => $this->getUniqueId()];
                 }
                 break;
             case 'issn':
                 if ($issn = $field->getSubfield('x')) {
                     $link = ['type' => 'isn', 'value' => trim($issn->getData()), 'exclude' => $this->getUniqueId()];
                 }
                 break;
             case 'title':
                 $link = ['type' => 'title', 'value' => $title];
                 break;
         }
         // Exit loop if we have a link
         if (isset($link)) {
             break;
         }
     }
     // Make sure we have something to display:
     return !isset($link) ? false : ['title' => $this->getRecordLinkNote($field), 'value' => $title, 'link' => $link];
 }
예제 #3
0
 /**
  * Get FieldData
  *
  * @param \File_MARC_Data_Field $field Field
  *
  * @return array|Boolean
  */
 protected function getFieldData($field)
 {
     // Make sure that there is a t field to be displayed:
     if ($title = $field->getSubfield('t')) {
         $title = $title->getData();
     } else {
         return false;
     }
     // If set, display relationship information in i subfield
     if ($relation = $field->getSubfield('i')) {
         $relation = $relation->getData();
     } else {
         $relation = $this->getRecordLinkNote($field);
     }
     $linkTypeSetting = isset($this->mainConfig->Record->marc_links_link_types) ? $this->mainConfig->Record->marc_links_link_types : 'id,oclc,dlc,isbn,issn,title';
     $linkTypes = explode(',', $linkTypeSetting);
     $link = false;
     if (in_array('id', $linkTypes)) {
         // Search ID in field 9
         $linkSubfield = $field->getSubfield('9');
         if ($linkSubfield && ($bibLink = $this->getIdFromLinkingField($linkSubfield))) {
             $link = ['type' => 'bib', 'value' => $bibLink];
         }
     } elseif (in_array('ctrlnum', $linkTypes)) {
         // Extract ctrlnum from field w, ignore the prefix
         $linkFields = $linkFields = $field->getSubfields('w');
         foreach ($linkFields as $current) {
             if (preg_match('/\\(([^)]+)\\)(.+)/', $current->getData(), $matches)) {
                 $link = ['type' => 'ctrlnum', 'value' => $matches[1] . $matches[2]];
             }
         }
     }
     // Found link based on special conditions, stop here
     if ($link) {
         return ['title' => $relation, 'value' => $title, 'link' => $link];
     }
     // Fallback to base method if no custom field found
     return parent::getFieldData($field);
 }
예제 #4
0
파일: Holdings.php 프로젝트: CUSAT/vufind
 /**
  * Extract field data
  *
  * @param    \File_MARC_Data_Field $field
  * @param    Array $fieldMapping Field code=>name mapping
  * @return    Array
  */
 protected function extractFieldData(\File_MARC_Data_Field $field, array $fieldMapping)
 {
     $subFields = $field->getSubfields();
     $rawData = array();
     $data = array();
     // Fetch data
     foreach ($subFields as $code => $subdata) {
         if ($this->useConcatenation($code, $rawData)) {
             $rawData[$code] .= $this->concatenationMapping[$code] . $subdata->getData();
         } else {
             $rawData[$code] = $subdata->getData();
         }
     }
     foreach ($fieldMapping as $code => $name) {
         $data[$name] = isset($rawData[$code]) ? $rawData[$code] : '';
     }
     return $data;
 }
예제 #5
0
<?php

require 'File/MARC.php';
// File_MARC offers the ability to add subfields at any point within
// an existing set of subfields
// First, create some subfields
$subfields[] = new File_MARC_Subfield('a', 'nothing');
$subfields[] = new File_MARC_Subfield('z', 'everything');
// Then, create a field including those subfields
$field = new File_MARC_Data_Field('100', $subfields, '0');
// Create some new subfields
$subfield1 = new File_MARC_Subfield('g', 'a little');
$subfield2 = new File_MARC_Subfield('k', 'a bit more');
$subfield3 = new File_MARC_Subfield('t', 'a lot');
// Append a new subfield to the existing set of subfields
// Expected order: a-z-g
$field->appendSubfield($subfield1);
// Insert a new subfield after the first subfield with code 'z'
// Expected order: a-z-k-g
$sf = $field->getSubfields('z');
// getSubfields() always returns an array; we just want the first subfield
if (count($sf) > 0) {
    $field->insertSubfield($subfield2, $sf[0]);
}
// Insert a new subfield prior to the first subfield with code 'z'
// Expected order: a-t-z-k-g
$sf = $field->getSubfield('z');
// getSubfield() simply returns the first matching subfield
if ($sf) {
    $field->insertSubfield($subfield3, $sf, true);
}
예제 #6
0
 /**
  * @param File_MARC_Data_Field $marcField
  * @param File_MARC_Subfield $subField
  * @return string
  */
 public function getSubfieldData($marcField, $subField)
 {
     if ($marcField) {
         return $marcField->getSubfield($subField) ? $marcField->getSubfield($subField)->getData() : '';
     } else {
         return '';
     }
 }
예제 #7
0
파일: models.php 프로젝트: rsinger/Jangle
 function buildMarc($bibData)
 {
     $mrc = new File_MARC_Record();
     $mrc->appendField(new File_MARC_Control_Field("001", $bibData["bibid"]));
     $ldr = '                       ';
     $ohOhEight = strftime("%Y%m%d", strtotime($bibData['create_dt'])) . '                           ';
     switch ($bibData["material_cd"]) {
         case 1:
             $ldr[6] = 'j';
             $ldr[7] = 'm';
             break;
         case 2:
             $ldr[6] = 'a';
             $ldr[7] = 'm';
             break;
         case 3:
             $ldr[6] = 'j';
             $ldr[7] = 'm';
             break;
         case 4:
             $ldr[6] = 'm';
             $ldr[7] = 'm';
             break;
         case 5:
             $ldr[6] = 'p';
             $ldr[7] = 'i';
             break;
         case 6:
             $ldr[6] = 'a';
             $ldr[7] = 's';
             break;
         case 7:
             $ldr[6] = 'e';
             $ldr[7] = 'm';
             break;
         case 8:
             $ldr[6] = 'g';
             $ldr[7] = 'm';
             break;
         default:
             $ldr[6] = 'a';
             $ldr[7] = 'm';
             break;
     }
     $subfields = array(new File_MARC_Subfield("a", $bibData["title"]));
     if ($bibData["title_remainder"]) {
         array_push($subfields, new File_MARC_Subfield("b", $bibData["title_remainder"]));
     }
     if ($bibData["responsibility_stmt"]) {
         array_push($subfields, new File_MARC_Subfield("c", $bibData["responsibility_stmt"]));
     }
     $title = new File_MARC_Data_Field("245", $subfields, "0", "0");
     $mrc->appendField($title);
     $author = new File_MARC_Data_Field("100", array(new File_MARC_Subfield("a", $bibData["author"])), "1", NULL);
     $mrc->appendField($author);
     $subjects = array($bibData["topic1"], $bibData["topic2"], $bibData["topic3"], $bibData["topic4"], $bibData["topic5"]);
     for ($i = 0; $i < count($subjects); $i++) {
         $sub = new File_MARC_Data_field("650", array(new File_MARC_Subfield("a", $subjects[$i])), NULL, "4");
         $mrc->appendField($sub);
     }
     $query = "SELECT * from biblio_field WHERE bibid = " . $bibData['bibid'] . " GROUP BY fieldid";
     $result = mysql_query($query);
     while ($row = mysql_fetch_assoc($result)) {
         if (!isset($fieldId)) {
             $fieldId = $row["fieldid"];
             if ($row["ind1_cd"] != "N") {
                 $ind1 = $row["ind1_cd"];
             } else {
                 $ind1 = NULL;
             }
             if ($row["ind2_cd"] != "N") {
                 $ind2 = $row["ind2_cd"];
             } else {
                 $ind2 = NULL;
             }
             $field = new File_MARC_Data_Field(str_pad($row["tag"], 3, "0", STR_PAD_LEFT), $ind1, $ind2);
         }
         if ($fieldId == $row["fieldid"]) {
             $field->appendSubfield(new File_MARC_Subfield($row["subfield_cd"], $row["field_data"]));
         } else {
             $mrc->appendField($field);
             $fieldId = $row["fieldid"];
             if ($row["ind1_cd"] != "N") {
                 $ind1 = $row["ind1_cd"];
             } else {
                 $ind1 = NULL;
             }
             if ($row["ind2_cd"] != "N") {
                 $ind2 = $row["ind2_cd"];
             } else {
                 $ind2 = NULL;
             }
             $field = new File_MARC_Data_Field(str_pad($row["tag"], 3, "0", STR_PAD_LEFT), $ind1, $ind2);
             $field->appendSubfield(new File_MARC_Subfield($row["subfield_cd"], $row["field_data"]));
         }
     }
     $mrc->setLeader($ldr);
     $mrc->appendField(new File_MARC_Control_Field("008", $ohOhEight));
     return $mrc;
 }
예제 #8
0
 /** Additional functions added by srickel1 to facitilate export of Authority records **/
 public function getAuthorityRecord($id)
 {
     // authority record query
     $sql = trim("\n\t\t\t\tSELECT\n\t\t\t\tauthority_view.id,\n\t\t\t\tauthority_view.record_creation_date_gmt,\n\t\t\t\tauthority_view.suppress_code,\n\t\t\t\tvarfield_view.marc_tag,\n\t\t\t\tvarfield_view.marc_ind1,\n\t\t\t\tvarfield_view.marc_ind2,\n\t\t\t\tTRIM(varfield_view.field_content),\n\t\t\t\tvarfield_view.varfield_type_code,\n\t\t\t\tcontrol_field.p40,\n\t\t\t\tcontrol_field.p41,\n\t\t\t\tcontrol_field.p42,\n\t\t\t\tleader_field.*\n\t\t\t\tFROM\n\t\t\t\tsierra_view.authority_view\n\t\t\t\tINNER JOIN\n\t\t\t\tsierra_view.varfield_view ON authority_view.id = varfield_view.record_id\n\t\t\t\tLEFT JOIN\n\t\t\t\tsierra_view.leader_field ON authority_view.id = leader_field.record_id\n\t\t\t\tLEFT JOIN\n\t\t\t\tsierra_view.control_field ON authority_view.id = control_field.record_id\n\t\t\t\tWHERE\n\t\t\t\tauthority_view.record_num = '{$id}' and control_field.control_num=8\n\t\t\t\tORDER BY\n\t\t\t\tmarc_tag\n\t\t\t\t");
     $results = $this->getResults($sql);
     if (count($results) == 0) {
         return null;
     }
     // let's parse a few things, shall we
     $result = $results[0];
     $internal_id = $result[0];
     // internal postgres id
     if ($result['suppress_code'] == 'n') {
         //suppressed item - let's delete it from the discovery tool data.
         $record = $this->createDeletedRecord($id);
         return $record;
     }
     //start the marc record
     $record = new File_MARC_Record();
     // leader
     // 0000's here get converted to correct lengths by File_MARC
     $leader = '00000';
     // 00-04 - Record length
     /* we have to determine what to do in the cases that we get no leader information back from the database */
     if ($this->getLeaderValue($result, 'record_status_code') == ' ') {
         $leader .= $this->getLeaderValue($result, 'p40');
     } else {
         $leader .= $this->getLeaderValue($result, 'record_status_code');
     }
     //we can get the following field from the bcode1 field
     if ($this->getLeaderValue($result, 'record_type_code') == ' ') {
         $leader .= $this->getLeaderValue($result, 'p41');
     } else {
         $leader .= $this->getLeaderValue($result, 'record_type_code');
     }
     // 06 - Type of record
     //we can get the following field from the ? field
     $leader .= $this->getLeaderValue($result, 'p42');
     $leader .= $this->getLeaderValue($result, 'control_type_code');
     // 08 - Type of control
     $leader .= $this->getLeaderValue($result, 'char_encoding_scheme_code');
     // 09 - Character coding scheme
     $leader .= '2';
     // 10 - Indicator count
     $leader .= '2';
     // 11 - Subfield code count
     $leader .= '00000';
     // 12-16 - Base address of data
     //found the next one in p43 of control_field
     $leader .= $this->getLeaderValue($result, 'encoding_level_code');
     // 17 - Encoding level
     $leader .= $this->getLeaderValue($result, 'descriptive_cat_form_code');
     // 18 - Descriptive cataloging form
     $leader .= $this->getLeaderValue($result, 'multipart_level_code');
     // 19 - Multipart resource record level
     $leader .= '4';
     // 20 - Length of the length-of-field portion
     $leader .= '5';
     // 21 - Length of the starting-character-position portion
     $leader .= '0';
     // 22 - Length of the implementation-defined portion
     $leader .= '0';
     // 23 - Undefined
     $record->setLeader($leader);
     // marc fields
     $record_id_field = new File_MARC_Data_Field('035');
     $record->appendField($record_id_field);
     $record_id_field->appendSubfield(new File_MARC_Subfield('a', $this->getFullRecordId($id, 'a')));
     foreach ($results as $result) {
         try {
             // skip missing tags and 'old' 9xx tags that mess with the above
             if ($result['marc_tag'] == null || $result['marc_tag'] == '907' || $result['marc_tag'] == '998') {
                 continue;
             }
             // control field
             if ((int) $result['marc_tag'] < 10) {
                 $control_field = new File_MARC_Control_Field($result['marc_tag'], $result['field_content']);
                 $record->appendField($control_field);
             } else {
                 $data_field = new File_MARC_Data_Field($result['marc_tag']);
                 $data_field->setIndicator(1, $result['marc_ind1']);
                 $data_field->setIndicator(2, $result['marc_ind2']);
                 $content = $result['field_content'];
                 $content_array = explode('|', $content);
                 foreach ($content_array as $subfield) {
                     $code = substr($subfield, 0, 1);
                     $data = substr($subfield, 1);
                     if ($code == '') {
                         continue;
                     }
                     $subfield = new File_MARC_Subfield($code, trim($data));
                     $data_field->appendSubfield($subfield);
                 }
                 $record->appendField($data_field);
             }
         } catch (File_MARC_Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
         }
     }
     return $record;
 }
예제 #9
0
 /**
  * Returns the array element for the 'getAllRecordLinks' method
  *
  * @param File_MARC_Data_Field $field Field to examine
  * @param string               $value Field name for use in label
  *
  * @access protected
  * @return array|bool                 Array on success, boolean false if no
  * valid link could be found in the data.
  */
 protected function getFieldData($field, $value)
 {
     global $configArray;
     $labelPrfx = 'note_';
     $baseURI = $configArray['Site']['url'];
     $relInfo = $field->getSubfield('i') ? $field->getSubfield('i')->getData() : '';
     $title = $field->getSubfield('t') ? $field->getSubfield('t')->getData() : '';
     $diff = $field->getSubfield('c') ? $field->getSubfield('c')->getData() : '';
     $issn = $field->getSubfield('x') ? $field->getSubfield('x')->getData() : '';
     $isbn = $field->getSubfield('z') ? $field->getSubfield('z')->getData() : '';
     if ($diff) {
         $title .= " {$diff}";
     }
     $fallbackTitle = '';
     if (empty($title)) {
         if (!empty($relInfo)) {
             $fallbackTitle = $relInfo . ' ';
         }
         if (!empty($issn)) {
             $fallbackTitle .= $issn;
         } else {
             $fallbackTitle .= $isbn;
         }
     }
     // There are two possible ways we may want to link to a record with subfield w
     // -- either we will have a raw bibliographic record in subfield w, or else we
     // will have an OCLC number prefixed by (OCoLC).  If we have both, we want to
     // favor the bib number over the OCLC number.  If we have an unrecognized
     // parenthetical prefix to the number, we should simply ignore it.
     $bib = $oclc = '';
     $linkFields = $field->getSubfields('w');
     foreach ($linkFields as $current) {
         $text = $current->getData();
         // Extract parenthetical prefixes:
         if (preg_match('/\\(([^)]+)\\)(.+)/', $text, $matches)) {
             // Is it an OCLC number?
             if ($matches[1] == 'OCoLC') {
                 $oclc = $baseURI . '/Search/Results?lookfor=' . urlencode($matches[2]) . '&type=oclc_num&jumpto=1';
             }
         } else {
             // No parenthetical prefix found -- assume raw bib number:
             $bib = $baseURI . '/Record/' . $text;
         }
     }
     // Check which link type we found in the code above... and use title search
     // if we found nothing!
     if (!empty($bib)) {
         $link = $bib;
     } else {
         if (!empty($oclc)) {
             $link = $oclc;
         } else {
             if (!empty($issn)) {
                 $link = $baseURI . '/Search/Results?lookfor=' . urlencode($issn) . '&type=ISN';
             } else {
                 if (!empty($isbn)) {
                     $link = $baseURI . '/Search/Results?lookfor=' . urlencode($isbn) . '&type=ISN';
                 } else {
                     $link = $baseURI . '/Search/Results?lookfor=' . urlencode('"' . $title . '"') . '&type=Title';
                 }
             }
         }
     }
     return array('title' => $labelPrfx . $value, 'value' => empty($title) ? $fallbackTitle : $title, 'issn' => $issn, 'link' => $link);
 }
예제 #10
0
파일: Record.php 프로젝트: guenterh/vufind
 /**
  * MatchesConditions
  *
  * @param array                 $conditions Conditions
  * @param \File_MARC_Data_Field $marcRecord MarcRecord
  *
  * @return bool
  */
 protected function matchesConditions(array $conditions, \File_MARC_Data_Field $marcRecord)
 {
     if (empty($conditions)) {
         return true;
     }
     $matchesOr = false;
     $orConditionsCount = count($conditions);
     $i = 0;
     while (!$matchesOr && $i < $orConditionsCount) {
         $j = 0;
         $matchesAnd = true;
         $andConditions = explode('&&', $conditions[$i]);
         $andConditionsCount = count($andConditions);
         while ($matchesAnd && $j < $andConditionsCount) {
             list($subfieldKey, $subfieldValue) = explode('|', $andConditions[$j]);
             $subfield = $marcRecord->getSubfield(trim($subfieldKey));
             $matchesAnd = $subfield && preg_match('/' . trim($subfieldValue) . '/', $subfield->getData());
             $j++;
         }
         $matchesOr = $matchesOr || $matchesAnd;
         $i++;
     }
     return $matchesOr;
 }
예제 #11
0
 /**
  * Returns the array element for the 'getAllRecordLinks' method
  *
  * @param File_MARC_Data_Field $field Field to examine
  * @param string               $value Field name for use in label
  *
  * @return array|bool                 Array on success, boolean false if no
  * valid link could be found in the data.
  */
 protected function getFieldData($field, $value)
 {
     $labelPrfx = 'note_';
     // There are two possible ways we may want to link to a record -- either
     // we will have a raw bibliographic record in subfield w, or else we will
     // have an OCLC number prefixed by (OCoLC).  If we have both, we want to
     // favor the bib number over the OCLC number.  If we have an unrecognized
     // parenthetical prefix to the number, we should simply ignore it.
     $bib = $oclc = '';
     $linkFields = $field->getSubfields('w');
     foreach ($linkFields as $current) {
         $text = $current->getData();
         // Extract parenthetical prefixes:
         if (preg_match('/\\(([^)]+)\\)(.+)/', $text, $matches)) {
             // Is it an OCLC number?
             if ($matches[1] == 'OCoLC') {
                 $oclc = $matches[2];
             }
         } else {
             // No parenthetical prefix found -- assume raw bib number:
             $bib = $text;
         }
     }
     // Check which link type we found in the code above... and fail if we
     // found nothing!
     if (!empty($bib)) {
         $link = array('type' => 'bib', 'value' => $bib);
     } else {
         if (!empty($oclc)) {
             $link = array('type' => 'oclc', 'value' => $oclc);
         } else {
             return false;
         }
     }
     return array('title' => $labelPrfx . $value, 'value' => $field->getSubfield('t')->getData(), 'link' => $link);
 }
예제 #12
0
파일: Sierra.php 프로젝트: ebscomazen/shrew
 /**
  * Fetch an individual record
  * 
  * @param string $id
  * @return File_MARC_Record|null
  */
 public function getBibRecord($id)
 {
     // bib record query
     $sql = trim("\r\n\t\t\tSELECT\r\n\t\t\t\tbib_view.id,\r\n\t\t\t\tbib_view.bcode1,\r\n\t\t\t\tbib_view.bcode2,\r\n\t\t\t\tbib_view.bcode3,\r\n\t\t\t\tbib_view.cataloging_date_gmt,\r\n\t\t\t\tvarfield_view.marc_tag,\r\n\t\t\t\tvarfield_view.marc_ind1,\r\n\t\t\t\tvarfield_view.marc_ind2,\r\n\t\t\t\tvarfield_view.field_content,\r\n\t\t\t\tvarfield_view.varfield_type_code,\r\n\t\t\t\tleader_field.*\r\n\t\t\tFROM\r\n\t\t\t\tsierra_view.bib_view\r\n\t\t\tINNER JOIN \r\n\t\t\t\tsierra_view.varfield_view ON bib_view.id = varfield_view.record_id\r\n\t\t\tLEFT JOIN\r\n\t\t\t\tsierra_view.leader_field ON bib_view.id = leader_field.record_id\r\n\t\t\tWHERE\r\n\t\t\t\tbib_view.record_num = '{$id}'\r\n\t\t\tORDER BY \r\n\t\t\t\tmarc_tag\r\n\t\t");
     $results = $this->getResults($sql);
     if (count($results) == 0) {
         return null;
     }
     $record = new File_MARC_Record();
     // let's parse a few things, shall we
     $result = $results[0];
     $internal_id = $result[0];
     // internal postgres id
     // leader
     // 0000's here get converted to correct lengths by File_MARC
     $leader = '00000';
     // 00-04 - Record length
     $leader .= $this->getLeaderValue($result, 'record_status_code');
     // 05 - Record status
     $leader .= $this->getLeaderValue($result, 'record_type_code');
     // 06 - Type of record
     $leader .= $this->getLeaderValue($result, 'bib_level_code');
     // 07 - Bibliographic level
     $leader .= $this->getLeaderValue($result, 'control_type_code');
     // 08 - Type of control
     $leader .= $this->getLeaderValue($result, 'char_encoding_scheme_code');
     // 09 - Character coding scheme
     $leader .= '2';
     // 10 - Indicator count
     $leader .= '2';
     // 11 - Subfield code count
     $leader .= '00000';
     // 12-16 - Base address of data
     $leader .= $this->getLeaderValue($result, 'encoding_level_code');
     // 17 - Encoding level
     $leader .= $this->getLeaderValue($result, 'descriptive_cat_form_code');
     // 18 - Descriptive cataloging form
     $leader .= $this->getLeaderValue($result, 'multipart_level_code');
     // 19 - Multipart resource record level
     $leader .= '4';
     // 20 - Length of the length-of-field portion
     $leader .= '5';
     // 21 - Length of the starting-character-position portion
     $leader .= '0';
     // 22 - Length of the implementation-defined portion
     $leader .= '0';
     // 23 - Undefined
     $record->setLeader($leader);
     // innovative bib record fields
     $bib_field = new File_MARC_Data_Field('907');
     $record->appendField($bib_field);
     $bib_field->appendSubfield(new File_MARC_Subfield('a', $this->getFullRecordId($id)));
     // cataloging info fields
     $bib_field = new File_MARC_Data_Field('998');
     $record->appendField($bib_field);
     $bib_field->appendSubfield(new File_MARC_Subfield('c', trim($result['cataloging_date_gmt'])));
     $bib_field->appendSubfield(new File_MARC_Subfield('d', trim($result['bcode1'])));
     $bib_field->appendSubfield(new File_MARC_Subfield('e', trim($result['bcode2'])));
     $bib_field->appendSubfield(new File_MARC_Subfield('f', trim($result['bcode3'])));
     // marc fields
     foreach ($results as $result) {
         try {
             // skip missing tags and 'old' 9xx tags that mess with the above
             if ($result['marc_tag'] == null || $result['marc_tag'] == '907' || $result['marc_tag'] == '998') {
                 continue;
             }
             // control field
             if ((int) $result['marc_tag'] < 10) {
                 $control_field = new File_MARC_Control_Field($result['marc_tag'], $result['field_content']);
                 $record->appendField($control_field);
             } else {
                 $data_field = new File_MARC_Data_Field($result['marc_tag']);
                 $data_field->setIndicator(1, $result['marc_ind1']);
                 $data_field->setIndicator(2, $result['marc_ind2']);
                 $content = $result['field_content'];
                 $content_array = explode('|', $content);
                 foreach ($content_array as $subfield) {
                     $code = substr($subfield, 0, 1);
                     $data = substr($subfield, 1);
                     if ($code == '') {
                         continue;
                     }
                     $subfield = new File_MARC_Subfield($code, trim($data));
                     $data_field->appendSubfield($subfield);
                 }
                 $record->appendField($data_field);
             }
         } catch (File_MARC_Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
         }
     }
     // location codes
     $sql = trim("\r\n\t\t\tSELECT location_code\r\n\t\t\tFROM\r\n\t\t\t\tsierra_view.bib_record_location\r\n\t\t\tWHERE\r\n\t\t\t\tbib_record_id = '{$internal_id}'\r\n\t\t");
     $results = $this->getResults($sql);
     if (count($results) > 0) {
         $location_record = new File_MARC_Data_Field('907');
         foreach ($results as $result) {
             $location_record->appendSubfield(new File_MARC_Subfield('b', trim((string) $result['location_code'])));
         }
         $record->appendField($location_record);
     }
     // item records
     $sql = trim("\r\n\t\t\tSELECT item_view.*\r\n\t\t\tFROM \r\n\t\t\t\tsierra_view.bib_view,\r\n\t\t\t\tsierra_view.item_view,\r\n\t\t\t\tsierra_view.bib_record_item_record_link\r\n\t\t\tWHERE \r\n\t\t\t\tbib_view.record_num = '{$id}' AND\r\n\t\t\t\tbib_view.id = bib_record_item_record_link.bib_record_id AND\r\n\t\t\t\titem_view.id = bib_record_item_record_link.item_record_id\t\t\t\t\r\n\t\t");
     $results = $this->getResults($sql);
     foreach ($results as $result) {
         $item_record = new File_MARC_Data_Field('945');
         $item_record->appendSubfield(new File_MARC_Subfield('l', trim($result['location_code'])));
         $record->appendField($item_record);
     }
     return $record;
 }