Exemple #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;
 }
Exemple #2
0
 /**
  * Support method for getFieldData() -- factor the relationship indicator
  * into the field number where relevant to generate a note to associate
  * with a record link.
  *
  * @param File_MARC_Data_Field $field Field to examine
  *
  * @return string
  */
 protected function getRecordLinkNote($field)
 {
     // If set, use relationship information from subfield i
     if ($subfieldI = $field->getSubfield('i')) {
         $data = trim($subfieldI->getData());
         if (!empty($data)) {
             return $data;
         }
     }
     // Normalize blank relationship indicator to 0:
     $relationshipIndicator = $field->getIndicator('2');
     if ($relationshipIndicator == ' ') {
         $relationshipIndicator = '0';
     }
     // Assign notes based on the relationship type
     $value = $field->getTag();
     switch ($value) {
         case '780':
             if (in_array($relationshipIndicator, range('0', '7'))) {
                 $value .= '_' . $relationshipIndicator;
             }
             break;
         case '785':
             if (in_array($relationshipIndicator, range('0', '8'))) {
                 $value .= '_' . $relationshipIndicator;
             }
             break;
     }
     return 'note_' . $value;
 }
Exemple #3
0
 /**
  * Convert sub fields to array map
  *
  * @param \File_MARC_Data_Field $field             Field
  * @param Array                 $fieldMap          FieldMap
  * @param Boolean               $includeIndicators Add the two indicators to the
  *                                                 field list
  *
  * @return Array
  */
 protected function getMappedFieldData($field, array $fieldMap, $includeIndicators = true)
 {
     $subFieldValues = [];
     if ($includeIndicators) {
         $subFieldValues['@ind1'] = $field->getIndicator(1);
         $subFieldValues['@ind2'] = $field->getIndicator(2);
     }
     foreach ($fieldMap as $code => $name) {
         if (substr($code, 0, 1) === '_') {
             // Underscore means repeatable
             $code = substr($code, 1);
             // Remove underscore
             /**
              * Subfields
              *
              * @var \File_MARC_Subfield[] $subFields
              */
             $subFields = $field->getSubfields((string) $code);
             if (sizeof($subFields)) {
                 //$subFieldValues[$name] = array();
                 $i = 1;
                 foreach ($subFields as $subField) {
                     $subFieldValues[$i . $name] = $subField->getData();
                     $i++;
                 }
             }
         } else {
             // Normal single field
             $subField = $field->getSubfield((string) $code);
             if ($subField) {
                 $subFieldValues[$name] = $subField->getData();
             }
         }
     }
     return $subFieldValues;
 }
Exemple #4
0
 /**
  * Support method for getFieldData() -- factor the relationship indicator
  * into the field number where relevant to generate a note to associate
  * with a record link.
  *
  * @param File_MARC_Data_Field $field Field to examine
  *
  * @return string
  */
 protected function getRecordLinkNote($field)
 {
     // Normalize blank relationship indicator to 0:
     $relationshipIndicator = $field->getIndicator('2');
     if ($relationshipIndicator == ' ') {
         $relationshipIndicator = '0';
     }
     // Assign notes based on the relationship type
     $value = $field->getTag();
     switch ($value) {
         case '780':
             if (in_array($relationshipIndicator, range('0', '7'))) {
                 $value .= '_' . $relationshipIndicator;
             }
             break;
         case '785':
             if (in_array($relationshipIndicator, range('0', '8'))) {
                 $value .= '_' . $relationshipIndicator;
             }
             break;
     }
     return 'note_' . $value;
 }