File_MARC
[ class tree: File_MARC ] [ index: File_MARC ] [ all elements ]

Class: File_MARC_Record

Source Location: /File_MARC-1.4.1/File/MARC/Record.php

Class Overview


Represents a single MARC record


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 54]
Represents a single MARC record

A MARC record contains a leader and zero or more fields held within a linked list structure. Fields are represented by File_MARC_Data_Field objects.



[ Top ]


Class Variables

$fields =

[line 63]

Contains a linked list of File_MARC_Data_Field objects for

this record

  • Access: protected

Type:   File_MARC_List


[ Top ]

$leader =

[line 69]

Record leader
  • Access: protected

Type:   string


[ Top ]

$marc =

[line 90]

MARC instance for access to the XML header/footer methods We need this so that we can properly wrap a collection of MARC records.
  • Access: protected

Type:   File_MARC


[ Top ]

$marcxml =

[line 82]

XMLWriter for writing collections
  • Access: protected

Type:   XMLWriter


[ Top ]

$warnings =

[line 75]

Non-fatal warnings generated during parsing
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 104]

true __construct( [File_MARC $marc = null])

Start function

Set all variables to defaults to create new File_MARC_Record object


Parameters:

File_MARC   $marc   —  MARC record from File_MARC or File_MARCXML

[ Top ]

__destruct (Destructor)   [line 120]

void __destruct( )

Destroys the data field

[ Top ]

addWarning   [line 416]

true addWarning( string $warning)

Add a warning to the MARC record that something non-fatal occurred during parsing.
  • Access: public

Parameters:

string   $warning   —  warning message

[ Top ]

appendField   [line 171]

File_MARC_Field appendField( File_MARC_Field $new_field)

Appends field to MARC record

Adds a File_MARC_Control_Field or File_MARC_Data_Field object to the end of the existing list of fields.

  • Return: The field that was added

Parameters:

File_MARC_Field   $new_field   —  The field to add

[ Top ]

deleteFields   [line 390]

int deleteFields( string $tag, [bool $pcre = null])

Delete all occurrences of a field matching a tag name from the record.
  • Return: number of fields that were deleted

Parameters:

string   $tag   —  tag for the fields to be deleted
bool   $pcre   —  if true, then match as a regular expression

[ Top ]

getField   [line 334]

{@link getField( [string $spec = null], [bool $pcre = null])

Return the first File_MARC_Data_Field or File_MARC_Control_Field object that matches the specified tag name. Returns false if no match is found.

Parameters:

string   $spec   —  tag name
bool   $pcre   —  if true, then match as a regular expression

[ Top ]

getFields   [line 362]

File_MARC_List|array getFields( [string $spec = null], [bool $pcre = null])

Return an array or File_MARC_List containing all File_MARC_Data_Field or File_MARC_Control_Field objects that match the specified tag name. If the tag name is omitted all fields are returned.

Parameters:

string   $spec   —  tag name
bool   $pcre   —  if true, then match as a regular expression

[ Top ]

getLeader   [line 136]

string getLeader( )

Get MARC leader

Returns the leader for the MARC record. No validation on the specified leader is performed.

  • Return: returns the leader

[ Top ]

getWarnings   [line 428]

array getWarnings( )

Return the array of warnings from the MARC record.
  • Return: warning messages
  • Access: public

[ Top ]

insertField   [line 229]

File_MARC_Field insertField( File_MARC_Field $new_field, File_MARC_Field $existing_field, [bool $before = false])

Inserts a field in the MARC record relative to an existing field

Inserts a File_MARC_Control_Field or File_MARC_Data_Field object before or after a specified existing field.

  1.  // Example: Insert a new field before the first 650 field
  2.  
  3.  // Create the new field
  4.  $subfields[= new File_MARC_Subfield('a''Scott, Daniel.');
  5.  $new_field = new File_MARC_Data_Field('100'$subfields0null);
  6.  
  7.  // Retrieve the target field for our insertion point
  8.  $subject $record->getFields('650');
  9.  
  10.  // Insert the new field
  11.  if (is_array($subject)) {
  12.      $record->insertField($new_field$subject[0]true);
  13.  }
  14.  elseif ($subject{
  15.      $record->insertField($new_field$subjecttrue);
  16.  }

  • Return: The field that was added

Parameters:

File_MARC_Field   $new_field   —  The field to add
File_MARC_Field   $existing_field   —  The target field
bool   $before   —  Insert the new field before the existing field if true, after the existing field if false

[ Top ]

prependField   [line 190]

File_MARC_Field prependField( File_MARC_Field $new_field)

Prepends field to MARC record

Adds a File_MARC_Control_Field or File_MARC_Data_Field object to the start of to the existing list of fields.

  • Return: The field that was added

Parameters:

File_MARC_Field   $new_field   —  The field to add

[ Top ]

setLeader   [line 153]

string setLeader( string $leader)

Set MARC record leader

Sets the leader for the MARC record. No validation on the specified leader is performed.

  • Return: returns the leader

Parameters:

string   $leader   —  Leader

[ Top ]

setLeaderLengths   [line 299]

bool setLeaderLengths( int $record_length, int $base_address)

Set MARC record leader lengths

Set the Leader lengths of the record according to defaults specified in http://www.loc.gov/marc/bibliographic/ecbdldrd.html

  • Return: Success or failure

Parameters:

int   $record_length   —  Record length
int   $base_address   —  Base address of data

[ Top ]

toJSON   [line 508]

string toJSON( )

Return the MARC record in JSON format

This method produces a JSON representation of a MARC record. The input encoding must be UTF8, otherwise the returned values will be corrupted.

  • Return: representation of MARC record in JSON format
  • Todo: Fix encoding input / output issues (PHP 6.0 required?)

[ Top ]

toJSONHash   [line 559]

string toJSONHash( )

Return the MARC record in Bill Dueber's MARC-HASH JSON format

This method produces a JSON representation of a MARC record as defined at http://robotlibrarian.billdueber.com/new-interest-in-marc-hash-json/ The input * encoding must be UTF8, otherwise the returned values will be corrupted.

  • Return: representation of MARC record in JSON format
  • Todo: Fix encoding input / output issues (PHP 6.0 required?)

[ Top ]

toRaw   [line 460]

string toRaw( )

Return the record in raw MARC format.

If you have modified an existing MARC record or created a new MARC record, use this method to save the record for use in other programs that accept the MARC format -- for example, your integrated library system.

  1.  // Example: Modify a record and save the output to a file
  2.  $record->deleteFields('650');
  3.  
  4.  // Now that the record has no subject fields, save it to disk
  5.  fopen($file'/home/dan/no_subject.mrc''w');
  6.  fwrite($file$record->toRaw());
  7.  fclose($file);

  • Return: Raw MARC data

[ Top ]

toXML   [line 616]

string toXML( [string $encoding = "UTF-8"], [bool $indent = true], [bool $single = true])

Return the MARC record in MARCXML format

This method produces an XML representation of a MARC record that attempts to adhere to the MARCXML standard documented at http://www.loc.gov/standards/marcxml/

  • Return: representation of MARC record in MARCXML format
  • Todo: Fix encoding input / output issues (PHP 6.0 required?)

Parameters:

string   $encoding   —  output encoding for the MARCXML record
bool   $indent   —  pretty-print the MARCXML record
bool   $single   —  wrap the <record> element in a <collection> element

[ Top ]

__toString   [line 484]

string __toString( )

Return the MARC record in a pretty printed string

This method produces an easy-to-read textual display of a MARC record.

The structure is roughly: <tag> <ind1> <ind2> _

  • Return: Formatted representation of MARC record

[ Top ]


Documentation generated on Wed, 13 Nov 2019 12:37:08 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.