2017 © Pedro Peláez
 

library file_marc_reference

MARCspec adapter for File_MARC

image

ck/file_marc_reference

MARCspec adapter for File_MARC

  • Friday, December 1, 2017
  • by collidoscope
  • Repository
  • 2 Watchers
  • 7 Stars
  • 2,189 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 24 % Grown

The README.md

File_MARC_Reference

Build Status Coverage Status, (*1)

File_MARC_Reference is an extension to the famous MARC parser for PHP File_MARC. With File_MARC_Reference you can use MARCspec as an unified way to access MARC data. Besides it simplifies File_MARC a lot., (*2)

Installation

Installation can be done by using Composer. Just run, (*3)

composer require ck/file_marc_reference

Usage

First require autoload.php, (*4)

<?php
require("vendor/autoload.php");

Reading MARC 21 data from a file or string stays the same (see File_MARC - Reading MARC data):, (*5)

// Retrieve a set of MARC records from a file
$records = new File_MARC('data.mrc');

// Iterate through the retrieved records
while ($record = $records->next())
{
 //...
}

Now if you want to reference data using a MARCspec you have to initialize a new File_MARC_Reference:, (*6)

// Retrieve a set of MARC records from a file
$records = new File_MARC('data.mrc');

// Iterate through the retrieved records
while ($record = $records->next())
{
    $reference = new File_MARC_Reference('245$a',$record);
}

After you referenced the data three public attributes are available:, (*7)

$reference = new File_MARC_Reference('245$a',$record);

// attribute data
$subfield = $reference->data[0];
print get_class($subfield);               // File_MARC_Subfield
print $subfield->getCode();               // a

// attribute content
print $reference->content[0];             // prints content of subfield a of field 245

// attribute cache
$field = $reference->cache['245'][0];
print get_class($field);                  // File_MARC_Data_Field
$subfield = $reference->cache['245$a'];
print get_class($subfield);               // File_MARC_Subfield

Let's see how we check dependencies with File_MARC if you have a task like: Reference to content of subfield "a" of field 306 if character with index position "0" of field 007 is either "m", "s" or "v"., (*8)

Instead of writing ..., (*9)

$fields_007 = $record->getFields('007');

$field_306 = $record->getField('306');

$subfields_a = false;

foreach($fields_007 as $field_007)
{
    $firstChar = substr($field_007->getData(),0,1);

    if(strpbrk($firstChar,"msv"))
    {
        $subfields_a = $field_306->getSubfields('a');
        break;
    }
}

if($subfields_a)
{
    foreach($subfields_a as $subfield_a)
    {
        echo $subfield_a->getData()."\n";
    }
}

... the same task with File_MARC_Reference:, (*10)


$reference = new File_MARC_Reference('306$a{007/0=\m|007/0=\s|007/0=\v}',$record); foreach($reference->content as $subfield_a) { echo $subfield_a."\n"; } // interested in field 007? No problem! print get_class($reference->cache['007'][0]); // File_MARC_Control_Field print $reference->cache['007/0'][0]; // prints the first char of first 007 field print $reference->cache['007/0'][1]; // prints the first char of second 007 field

The Versions

01/12 2017

dev-master

9999999-dev

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

01/12 2017

dev-dev

dev-dev

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

01/12 2017

v1.2.0

1.2.0.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

01/12 2017

dev-analysis-zEQjWD

dev-analysis-zEQjWD

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

27/09 2017

v1.1.4

1.1.4.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

06/09 2016

dev-analysis-zOL6W0

dev-analysis-zOL6W0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

05/09 2016

v1.1.1

1.1.1.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

05/09 2016

v1.1.0

1.1.0.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21 file_marc

07/06 2016

dev-analysis-ze04la

dev-analysis-ze04la

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21

06/06 2016

v1.0.4

1.0.4.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21

02/06 2016

v1.0.3

1.0.3.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21

10/02 2016

v1.0.2

1.0.2.0

MARCspec adapter for File_MARC

  Sources   Download

MIT

The Requires

 

The Development Requires

marcspec marc 21

28/01 2016

v1.0.1

1.0.1.0

MARCspec adapter for File_MARC

  Sources   Download

The Requires

 

The Development Requires

marcspec marc 21

04/12 2015

v1.0.0

1.0.0.0

MARCspec adapter for File_MARC

  Sources   Download

The Requires

 

The Development Requires

marcspec marc 21