示例#1
0
 /**
  * Delete a subfield from the field.
  *
  * @param File_MARC_Subfield $subfield The subfield to delete
  *
  * @return bool                         Success or failure
  */
 function deleteSubfield(File_MARC_Subfield $subfield)
 {
     if ($this->subfields->deleteNode($subfield)) {
         return true;
     }
     return false;
 }
示例#2
0
 /**
  * Inserts a field in the MARC record relative to an existing field
  *
  * Inserts a {@link File_MARC_Control_Field} or {@link File_MARC_Data_Field}
  * object before or after a specified existing field.
  *
  * <code>
  * // Example: Insert a new field before the first 650 field
  *
  * // Create the new field
  * $subfields[] = new File_MARC_Subfield('a', 'Scott, Daniel.');
  * $new_field = new File_MARC_Data_Field('100', $subfields, 0, null);
  *
  * // Retrieve the target field for our insertion point
  * $subject = $record->getFields('650');
  *
  * // Insert the new field
  * if (is_array($subject)) {
  *     $record->insertField($new_field, $subject[0], true);
  * }
  * elseif ($subject) {
  *     $record->insertField($new_field, $subject, true);
  * }
  * </code>
  *
  * @param File_MARC_Field $new_field      The field to add
  * @param File_MARC_Field $existing_field The target field
  * @param bool            $before         Insert the new field before the existing field if true, after the existing field if false
  *
  * @return File_MARC_Field                The field that was added
  */
 function insertField(File_MARC_Field $new_field, File_MARC_Field $existing_field, $before = false)
 {
     switch ($before) {
         /* Insert before the specified field in the record */
         case true:
             $this->fields->insertNode($new_field, $existing_field, true);
             break;
             /* Insert after the specified field in the record */
         /* Insert after the specified field in the record */
         case false:
             $this->fields->insertNode($new_field, $existing_field);
             break;
         default:
             $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INSERTFIELD_MODE], array("mode" => $before));
             throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INSERTFIELD_MODE);
     }
     return $new_field;
 }
示例#3
0
 /**
  * Delete a subfield from the field.
  *
  * @param File_MARC_Subfield $subfield The subfield to delete
  *
  * @return void
  */
 function deleteSubfield(File_MARC_Subfield $subfield)
 {
     $this->subfields->deleteNode($subfield);
 }