ck/file_marc_reference 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ck/file_marc_reference

最新稳定版本:v1.2.0

Composer 安装命令:

composer require ck/file_marc_reference

包简介

MARCspec adapter for File_MARC

README 文档

README

Build Status Coverage Status

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.

Installation

Installation can be done by using Composer. Just run

composer require ck/file_marc_reference 

Usage

First require autoload.php

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

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

// 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:

// 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:

$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".

Instead of writing ...

$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:

 $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

统计信息

  • 总下载量: 66.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固