cvs: pear /File_MARC CHANGELOG LICENSE MARC.php index.html package.xml publish_web.php /File_MARC/MARC Control_Field.php Data_Field.php Exception.php
Field.php List.php Record.php Subfield.php /File_MARC/examples example.mrc marc_yaz.php read.php subfields.php /File_MARC/tests example.mrc
marc_001.phpt marc_002.phpt marc_003.phpt marc_004.phpt marc_005.phpt marc_006.phpt marc_007.phpt marc_field_001.phpt marc_field_002.phpt
marc_field_003.phpt marc_field_004.phpt marc_subfield_001.phpt marc_subfield_002.phpt music.mrc

From: Date: Tue, 14 Nov 2006 18:12:58 +0000
Subject: cvs: pear /File_MARC CHANGELOG LICENSE MARC.php index.html package.xml publish_web.php /File_MARC/MARC Control_Field.php Data_Field.php Exception.php
Field.php List.php Record.php Subfield.php /File_MARC/examples example.mrc marc_yaz.php read.php subfields.php /File_MARC/tests example.mrc
marc_001.phpt marc_002.phpt marc_003.phpt marc_004.phpt marc_005.phpt marc_006.phpt marc_007.phpt marc_field_001.phpt marc_field_002.phpt
marc_field_003.phpt marc_field_004.phpt marc_subfield_001.phpt marc_subfield_002.phpt music.mrc
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-43073@lists.php.net to get a copy of this message
dbs Tue Nov 14 18:12:58 2006 UTC Added files: /pear/File_MARC CHANGELOG LICENSE MARC.php index.html package.xml publish_web.php /pear/File_MARC/MARC Control_Field.php Data_Field.php Exception.php Field.php List.php Record.php Subfield.php /pear/File_MARC/examples example.mrc marc_yaz.php read.php subfields.php /pear/File_MARC/tests example.mrc marc_001.phpt marc_002.phpt marc_003.phpt marc_004.phpt marc_005.phpt marc_006.phpt marc_007.phpt marc_field_001.phpt marc_field_002.phpt marc_field_003.phpt marc_field_004.phpt marc_subfield_001.phpt marc_subfield_002.phpt music.mrc Log: Commit 0.1.0 alpha release

http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC.php +++ pear/File_MARC/MARC.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: MARC.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ * @link http://pear.php.net/package/File_MARC * @example read.php Retrieve specific fields and subfields from a record * @example subfields.php Create new subfields and add them in specific order * @example marc_yaz.php Pretty print a MARC record retrieved through the PECL yaz extension */ require_once 'PEAR/Exception.php'; require_once 'Structures/LinkedList/Double.php'; require_once 'File/MARC/Record.php'; require_once 'File/MARC/Field.php'; require_once 'File/MARC/Control_Field.php'; require_once 'File/MARC/Data_Field.php'; require_once 'File/MARC/Subfield.php'; require_once 'File/MARC/Exception.php'; require_once 'File/MARC/List.php'; // {{{ class File_MARC /** * The main File_MARC class enables you to return File_MARC_Record * objects from a stream or string. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC { // {{{ constants /** * MARC records retrieved from a file */ const SOURCE_FILE = 1; /** * MARC records retrieved from a binary string */ const SOURCE_STRING = 2; /** * Hexadecimal value for Subfield indicator */ const SUBFIELD_INDICATOR = "\x1F"; /** * Hexadecimal value for End of Field */ const END_OF_FIELD = "\x1E"; /** * Hexadecimal value for End of Record */ const END_OF_RECORD = "\x1D"; /** * Length of the Directory */ const DIRECTORY_ENTRY_LEN = 12; /** * Length of the Leader */ const LEADER_LEN = 24; /** * Maximum record length */ const MAX_RECORD_LENGTH = 99999; // }}} // {{{ properties /** * Source containing raw records * * @var resource */ protected $source; /** * Source type (SOURCE_FILE or SOURCE_STRING) * * @var int */ protected $type; // }}} // {{{ Constructor: function __construct() /** * Read in MARC records * * This function reads in MARC record files or strings that * contain one or more MARC records. * * <code> * <?php * // Retrieve MARC records from a file * $journals = new File_MARC('journals.mrc', SOURCE_FILE); * * // Retrieve MARC records from a string (e.g. Z39 query results) * $monographs = new File_MARC($raw_marc, SOURCE_STRING); * ?> * </code> * * @param string $in Name of the file, or a raw MARC string * @param int $source Source of the input, either SOURCE_FILE * or SOURCE_STRING */ function __construct($source, $type = self::SOURCE_FILE) { switch ($type) { case self::SOURCE_FILE: if (!file_exists($source)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_FILE], array('filename' => $source)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_FILE); } $this->type = self::SOURCE_FILE; $this->source = fopen($source, 'rb'); break; case self::SOURCE_STRING: $this->type = self::SOURCE_STRING; $this->source = explode(File_MARC::END_OF_RECORD, $source); break; default: throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_SOURCE], File_MARC_Exception::ERROR_INVALID_SOURCE); } } // }}} // {{{ nextRaw() /** * Return the next raw MARC record * * Returns the next raw MARC record, unless all records already have * been read. * * @return string Either a raw record or false */ function nextRaw() { if ($this->type == self::SOURCE_FILE) { $record = stream_get_line($this->source, File_MARC::MAX_RECORD_LENGTH, File_MARC::END_OF_RECORD); // Remove illegal stuff that sometimes occurs between records $record = preg_replace('/^[\\x0a\\x0d\\x00]+/', "", $record); } elseif ($this->type == self::SOURCE_STRING) { $record = array_shift($this->source); } // Exit if we are at the end of the file if (!$record) { return false; } // Append the end of record we lost during stream_get_line() or explode() $record .= File_MARC::END_OF_RECORD; // Validate record structure if (strlen($record) < 5) { throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_MISSING_LENGTH], File_MARC_Exception::ERROR_MISSING_LENGTH); } $record_length = substr($record, 0, 5); if (!preg_match("/^\d{5}$/", $record_length)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_NONNUMERIC_LENGTH], array("record_length" => $record_length)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_NONNUMERIC_LENGTH); } if ($record_length != strlen($record)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INCORRECT_LENGTH], array("record_length" => $record_length, "actual" => strlen($record))); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INCORRECT_LENGTH); } return $record; } // }}} // {{{ next() /** * Return next {@link File_MARC_Record} object * * Decodes the next raw MARC record and returns the {@link File_MARC_Record} * object. * <code> * <?php * // Retrieve a set of MARC records from a file * $journals = new File_MARC('journals.mrc', SOURCE_FILE); * * // Iterate through the retrieved records * while ($record = $journals->next()) { * print $record; * print "\n"; * } * * ?> * </code> * * @return File_MARC_Record next record, or false if there are * no more records */ function next() { if ($raw = $this->nextRaw()) { return $this->_decode($raw); } else { return false; } } // }}} // {{{ _decode() /** * Decode a given raw MARC record * * Port of Andy Lesters MARC::File::USMARC->decode() Perl function into PHP. * * @param string $text Raw MARC record * @return File_MARC_Record Decoded File_MARC_Record object */ private function _decode($text) { if (!preg_match("/^(\d{5})/", $text, $matches)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_NONNUMERIC_LENGTH], array("record_length" => substr($text, 0, 5))); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_NONNUMERIC_LENGTH); } $marc = new File_MARC_Record(); // Store record length $record_length = $matches[1]; if ($record_length != strlen($text)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INCORRECT_LENGTH], array("record_length" => substr($record_length), "actual" => strlen($text))); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INCORRECT_LENGTH); } if (substr($text, -1, 1) != File_MARC::END_OF_RECORD) throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_TERMINATOR], File_MARC_Exception::ERROR_INVALID_TERMINATOR); // Store leader $marc->setLeader(substr($text, 0, File_MARC::LEADER_LEN)); // bytes 12 - 16 of leader give offset to the body of the record $data_start = 0 + substr($text, 12, 5); // immediately after the leader comes the directory (no separator) $dir = substr($text, File_MARC::LEADER_LEN, $data_start - File_MARC::LEADER_LEN - 1); // -1 to allow for \x1e at end of directory // character after the directory must be \x1e if (substr($text, $data_start-1, 1) != File_MARC::END_OF_FIELD) { throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_NO_DIRECTORY], File_MARC_Exception::ERROR_NO_DIRECTORY); } // All directory entries 12 bytes long, so length % 12 must be 0 if (strlen($dir) % File_MARC::DIRECTORY_ENTRY_LEN != 0) { throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_LENGTH], File_MARC_Exception::ERROR_INVALID_DIRECTORY_LENGTH); } // go through all the fields $nfields = strlen($dir) / File_MARC::DIRECTORY_ENTRY_LEN; for ($n=0; $n<$nfields; $n++) { // As pack returns to key 1, leave place 0 in list empty list(, $tag) = unpack("A3", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN)); list(, $len) = unpack("A3/A4", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN)); list(, $offset) = unpack("A3/A4/A5", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN)); // Check directory validity if (!preg_match("/^[0-9A-Za-z]{3}$/", $tag)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG); } if (!preg_match("/^\d{4}$/", $len)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG_LENGTH], array("tag" => $tag, "len" => $len)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG_LENGTH); } if (!preg_match("/^\d{5}$/", $offset)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_OFFSET], array("tag" => $tag, "offset" => $offset)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_DIRECTORY_OFFSET); } if ($offset + $len > $record_length) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_DIRECTORY); } $tag_data = substr($text, $data_start + $offset, $len); if (substr($tag_data, -1, 1) == File_MARC::END_OF_FIELD) { /* get rid of the end-of-tag character */ $tag_data = substr($tag_data, 0, -1); $len--; } else { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_FIELD_EOF], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_FIELD_EOF); } if (preg_match("/^\d+$/", $tag) and ($tag < 10)) { $marc->appendField(new File_MARC_Control_Field($tag, $tag_data)); } else { $subfields = split(File_MARC::SUBFIELD_INDICATOR, $tag_data); $indicators = array_shift($subfields); if (strlen($indicators) > 2 || strlen($indicators) == 0) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATORS], array("tag" => $tag, "indicators" => $indicators)); $marc->addWarning($errorMessage); list($ind1,$ind2) = array(" ", " "); } else { $ind1 = substr($indicators, 0, 1); $ind2 = substr($indicators, 1, 1); } // Split the subfield data into subfield name and data pairs $subfield_data = array(); foreach ($subfields as $subfield) { if (strlen($subfield) > 0) { $subfield_data[] = new File_MARC_Subfield(substr($subfield, 0, 1), substr($subfield, 1)); } else { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_EMPTY_SUBFIELD], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_EMPTY_SUBFIELD); } } if (!isset($subfield_data)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_EMPTY_SUBFIELD], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_EMPTY_SUBFIELD); } $marc->appendField(new File_MARC_Data_Field($tag, $subfield_data, $ind1, $ind2)); } } return $marc; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/index.html?view=markup&rev=1.1 Index: pear/File_MARC/index.html +++ pear/File_MARC/index.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>File_MARC package for PHP</title> </head> <body> <h1>File_MARC package for PHP</h1> <p>Hey, welcome to the File_MARC package for PHP. If you don't know what MARC is, then you probably don't need this package -- but you can find out more about MARC at <a href= "http://loc.gov/marc/">Library of Congress: MARC standards</a>.</p> <h2>Requirements</h2> <ul> <li>PHP 5: this package was primarily developed with PHP 5.1.4. I have successfully tested 5.2.0RC1 through RC4.</li> <li><a href="/link/">Structures_LinkedList</a> package, also under development</li> </ul> <h2><a name="download">Download</a></h2> <p>Current release: <a href="current.tgz">current.tgz</a>.</p> <p>See <a href="#previous">Previous releases</a> for older versions of this code.</p> <h2>Documentation</h2> <p>Read the <a href="docs/">File_MARC API documentation</a>.</p> <h3>Highlighted source files</h3> <ul> <li><a href="highlight_MARC.php">MARC.php (package source)</a></li> <li><a href="highlight_read.php">read.php (example)</a></li> <li><a href="highlight_subfields.php">subfields.php (example)</a></li> <li><a href="highlight_marc_yaz.php">marc_yaz.php (example)</a></li> </ul> <h2>Installation</h2> <ol> <li>Download the <a href= "#download">File_MARC</a> package.</li> <li>Install the Structures_LinkedList prerequisite package (currently in alpha) with the PEAR installer: <pre> # pear install Structures_LinkedList-alpha </pre> </li> <li>Forcefully install the File_MARC package with the PEAR installer: <pre> # pear install --force File_MARC-0.0.#.tgz </pre></li> </ol> <h2>Comments</h2> <p>Comments are welcome by email at <a href= "mailto:dan@coffeecode.net">dan@coffeecode.net</a>.</p> <h2>Future</h2> <p>More documentation, more MARC-oriented functionality. I plan to make MARC_Record-&gt;appendField() append the field to the end of the corresponding [0-9]xx range to keep records conformant with LOC guidelines. There's no way of sorting the MARC fields... that probably needs to happen. If I'm really aggressive, I might try adding levels of MARC standards compliance for error modes (e.g. only one 1XX field per bibliographic record). Or adding semantic shortcuts for a given record based on the fixed fields values (e.g. $record-&gt;getLanguage() or the like).</p> <h2><a name="previous">Previous releases</a></h2> <ul> <li><a href= "File_MARC-0.0.8.tar.gz">File_MARC-0.0.8.tar.gz</a></li> <li><a href= "File_MARC-0.0.7.tar.gz">File_MARC-0.0.7.tar.gz</a></li> <li><a href= "File_MARC-0.0.6.tar.gz">File_MARC-0.0.6.tar.gz</a></li> <li><a href= "File_MARC-0.0.5.tar.gz">File_MARC-0.0.5.tar.gz</a></li> <li><a href= "File_MARC-0.0.4.tar.gz">File_MARC-0.0.4.tar.gz</a></li> <li><a href= "File_MARC-0.0.3a.tar.gz">File_MARC-0.0.3a.tar.gz</a></li> <li><a href= "MARC-0.0.2-alpha.tar.gz">MARC-0.0.2-alpha.tar.gz</a></li> <li><a href= "MARC-0.0.1-alpha.tar.gz">MARC-0.0.1-alpha.tar.gz</a></li> </ul> </body> </html> http://cvs.php.net/viewvc.cgi/pear/File_MARC/package.xml?view=markup&rev=1.1 Index: pear/File_MARC/package.xml +++ pear/File_MARC/package.xml <?xml version="1.0" encoding="utf-8"?> <package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>File_MARC</name> <channel>pear.php.net</channel> <summary>Parse, modify, and create MARC records</summary> <description>The standard for machine-readable cataloging (MARC) records is documented at http://loc.gov/marc/. This package enables you to read existing MARC records from a file, string, or (using the YAZ extension), from a Z39.50 source. You can also use this package to create new MARC records. This package is based on the PHP MARC package, originally called "php-marc", that is part of the Emilda Project (http://www.emilda.org). Christoffer Landtman generously agreed to make the "php-marc" code available under the GNU LGPL so it could be used as the basis of this PEAR package. </description> <lead> <name>Dan Scott</name> <user>dbs</user> <email>dbs@php.net</email> <active>yes</active> </lead> <date>2006-11-03</date> <version> <release>0.1.0</release> <api>0.1.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <license uri="http://www.gnu.org/copyleft/lesser.html">GNU Lesser General Public License</license> <notes> 0.1.0-alpha * Split each class out into its own file * Do not return anything from constructors </notes> <contents> <dir name="/" baseinstalldir="File"> <file name="CHANGELOG" role="doc" /> <file name="MARC.php" role="php" /> <file name="LICENSE" role="doc" /> <dir name="MARC"> <file name="Control_Field.php" role="php" /> <file name="Data_Field.php" role="php" /> <file name="Exception.php" role="php" /> <file name="Field.php" role="php" /> <file name="List.php" role="php" /> <file name="Record.php" role="php" /> <file name="Subfield.php" role="php" /> </dir> <dir name="examples"> <file name="example.mrc" role="doc" /> <file name="marc_yaz.php" role="doc" /> <file name="read.php" role="doc" /> <file name="subfields.php" role="doc" /> </dir> <dir name="tests"> <file name="example.mrc" role="test" /> <file name="marc_001.phpt" role="test" /> <file name="marc_002.phpt" role="test" /> <file name="marc_003.phpt" role="test" /> <file name="marc_004.phpt" role="test" /> <file name="marc_005.phpt" role="test" /> <file name="marc_006.phpt" role="test" /> <file name="marc_007.phpt" role="test" /> <file name="marc_field_001.phpt" role="test" /> <file name="marc_field_002.phpt" role="test" /> <file name="marc_field_003.phpt" role="test" /> <file name="marc_field_004.phpt" role="test" /> <file name="marc_subfield_001.phpt" role="test" /> <file name="marc_subfield_002.phpt" role="test" /> <file name="music.mrc" role="test" /> </dir> </dir> </contents> <dependencies> <required> <php> <min>5.1</min> </php> <pearinstaller> <min>1.4.0</min> </pearinstaller> <package> <name>Structures_LinkedList</name> <channel>pear.php.net</channel> </package> </required> </dependencies> <phprelease> </phprelease> </package> http://cvs.php.net/viewvc.cgi/pear/File_MARC/publish_web.php?view=markup&rev=1.1 Index: pear/File_MARC/publish_web.php +++ pear/File_MARC/publish_web.php <?php $package = 'File_MARC';// What is our package name? $package_file = 'MARC.php'; // What is our primary package? $publish_dir = "/home/dan/tmp/marcweb/"; // Publish directory // What's the name of our HTML file? $html_file = 'index.html'; // Clean out the directory exec("rm -fr $publish_dir"); // Export the SVN repository exec("svn export . $publish_dir"); // Rest of our work will be done within the publish directory chdir($publish_dir); // Define the set of files to highlight: package + examples // Need to split this array into package file vs. example files somehow $files_to_highlight = array($package_file => $package_file); $examples = scandir('examples'); foreach ($examples as $example_file) { if ($example_file == '.' or $example_file == '..') { continue; } $files_to_highlight[$example_file] = "examples/$example_file"; } // Create the package exec('pear package'); // Create file highlighter php pages for package foreach ($files_to_highlight as $highlighter => $path) { $fh = fopen("highlight_$highlighter", "w"); fwrite($fh, "<?php highlight_file('$path'); ?>"); fclose($fh); } // Create the online API documentation exec("phpdoc -t docs -f $package_file"); // create php.ini files with short_open_tag = off in each doc subdirectory // this is only required because ICDSoft turns on short_tags globally // and phpDocumentor creates XHTML files with .php.html extensions $doc_dir = scandir("docs/"); foreach ($doc_dir as $directory) { if (!is_dir("docs/$directory")) { continue; } if ($directory == '.' or $directory == '..') { continue; } $fh = fopen("docs/$directory/php.ini", "w"); fwrite($fh, "short_open_tag = Off"); fclose($fh); } // get new package name $new_package = ''; $contents = scandir('.'); foreach ($contents as $file) { if (preg_match("/$package-[\d\.]+.tgz/", $file)) { $new_package = $file; } } // update HTML file with links to new package version $html = file_get_contents($html_file); $new_html = preg_replace("/current.tgz/", $new_package, $html); $fh = fopen($html_file, 'w'); fwrite($fh, $new_html); fclose($fh); unlink('publish_web.php'); ?> http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Control_Field.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Control_Field.php +++ pear/File_MARC/MARC/Control_Field.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Control_Field.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Control_Field extends File_MARC_Field /** * The File_MARC_Control_Field class represents a single control field * in a MARC record. * * A MARC control field consists of a tag name and control data. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Control_Field extends File_MARC_Field { // {{{ Properties /** * Value of field, if field is a Control field * @var string */ protected $data; // }}} // {{{ Constructor: function __construct() /** * Field init function * * Create a new {@link File_MARC_Control_Field} object from passed arguments * * @param string $tag tag * @param string $data control field data * @param string $ind1 placeholder for class strictness * @param string $ind2 placeholder for class strictness */ function __construct($tag, $data, $ind1 = null, $ind2 = null) { $this->data = $data; parent::__construct($tag); } // }}} // {{{ Destructor: function __destruct() /** * Destroys the control field */ function __destruct() { $this->data = null; parent::__destruct(); } // }}} // {{{ Explicit destructor: function delete() /** * Destroys the control field */ function delete() { $this->__destruct(); } // }}} // {{{ getData() /** * Get control field data * * @return string returns data in control field */ function getData() { return $this->data; } // }}} // {{{ isEmpty() /** * Is empty * * Checks if the field contains data * @return bool Returns true if the field is empty, otherwise false */ function isEmpty() { return ($this->data) ? false : true; } // }}} // {{{ setData() /** * Set control field data * * @param string $data data for the control field * @return bool returns the new data in the control field */ function setData($data) { $this->data = $data; return $this->getData(); } // }}} // {{{ __toString() /** * Return as a formatted string * * Return the control field as a formatted string for pretty printing * * @return string Formatted output of control Field */ function __toString() { return sprintf("%3s %s", $this->tag, $this->data); } // }}} // {{{ toRaw() /** * Return as raw MARC * * Return the control field formatted in Raw MARC for saving into MARC files * * @return string Raw MARC */ function toRaw() { return $this->data.File_MARC::END_OF_FIELD; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Data_Field.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Data_Field.php +++ pear/File_MARC/MARC/Data_Field.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Data_Field.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Data_Field extends File_MARC_Field /** * The File_MARC_Data_Field class represents a single field in a MARC record. * * A MARC data field consists of a tag name, two indicators which may be null, * and zero or more subfields represented by {@link File_MARC_Subfield} objects. * Subfields are held within a linked list structure. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Data_Field extends File_MARC_Field { // {{{ properties /** * Value of the first indicator * @var string */ protected $ind1; /** * Value of the second indicator * @var string */ protected $ind2; /** * Linked list of subfields * @var File_MARC_List */ protected $subfields; // }}} // {{{ Constructor: function __construct() /** * {@link File_MARC_Data_Field} constructor * * Create a new {@link File_MARC_Data_Field} object. The only required * parameter is a tag. This enables programs to build up new fields * programmatically. * * <code> * // Example: Create a new data field * * // We can optionally create an array of subfields first * $subfields[] = new File_MARC_Data_Subfield('a', 'Scott, Daniel.'); * * // Create the new 100 field complete with a _a subfield and an indicator * $new_field = new File_MARC_Data_Field('100', $subfields, 0, null); * </code> * @param string $tag tag * @param array $subfields array of {@link File_MARC_Subfield} objects * @param string $ind1 first indicator * @param string $ind2 second indicator */ function __construct($tag, array $subfields = null, $ind1 = null, $ind2 = null) { $this->subfields = new File_MARC_List(); parent::__construct($tag); $this->ind1 = $this->_validateIndicator($ind1); $this->ind2 = $this->_validateIndicator($ind2); // we'll let users add subfields after if they so desire if ($subfields) { $this->addSubfields($subfields); } } // }}} // {{{ Destructor: function __destruct() /** * Destroys the data field */ function __destruct() { $this->subfields = null; $this->ind1 = null; $this->ind2 = null; parent::__destruct(); } // }}} // {{{ Explicit destructor: function delete() /** * Destroys the data field */ function delete() { $this->__destruct(); } // }}} // {{{ protected function _validateIndicator() /** * Validates an indicator field * * Validates the value passed in for an indicator. This routine ensures * that an indicator is a single character. If the indicator value is null, * then this method returns a single character. * * If the indicator value contains more than a single character, this * throws an exception. * * @param string $indicator Value of the indicator to be validated * @return string Returns the indicator, or space if the indicator was null */ private function _validateIndicator($indicator) { if ($indicator == null) { $indicator = ' '; } elseif (strlen($indicator) > 1) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATOR], array("tag" => $this->getTag(), "indicator" => $indicator)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_INDICATOR); } return $indicator; } // }}} // {{{ appendSubfield() /** * Appends subfield to subfield list * * Adds a File_MARC_Subfield object to the end of the existing list * of subfields. * * @param File_MARC_Subfield $new_subfield The subfield to add * @return File_MARC_Subfield the new File_MARC_Subfield object */ function appendSubfield(File_MARC_Subfield $new_subfield) { /* Append as the last field in the record */ $this->subfields->appendNode($new_subfield); return $new_subfield; } // }}} // {{{ prependSubfield() /** * Prepends subfield to subfield liss * * Adds a File_MARC_Subfield object to the start of the existing list * of subfields. * * @param File_MARC_Subfield $new_subfield The subfield to add * @return File_MARC_Subfield the new File_MARC_Subfield object */ function prependSubfield(File_MARC_Subfield $new_subfield) { $this->subfields->prependNode($new_subfield); return $new_subfield; } // }}} // {{{ insertSubfield() /** * Inserts a field in the MARC record relative to an existing field * * Inserts a {@link File_MARC_Subfield} object before or after an existing * subfield. * * @param File_MARC_Subfield $new_field The subfield to add * @param File_MARC_Subfield $existing_field The target subfield * @param bool $before Insert the subfield before the existing subfield * if true, after the existing subfield if false * @return File_MARC_Subfield The new subfield */ function insertSubfield(File_MARC_Subfield $new_field, File_MARC_Subfield $existing_field, $before = false) { switch ($before) { /* Insert before the specified subfield in the record */ case true: $this->subfields->insertNode($new_field, $existing_field, true); break; /* Insert after the specified subfield in the record */ case false: $this->subfields->insertNode($new_field, $existing_field); break; default: $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INSERTSUBFIELD_MODE], array("mode" => $mode)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INSERTSUBFIELD_MODE); return false; } return $new_field; } // }}} // {{{ addSubfields() /** * Adds an array of subfields to a {@link File_MARC_Data_Field} object * * Appends subfields to existing subfields in the order in which * they appear in the array. For finer grained control of the subfield * order, use {@link appendSubfield()}, {@link prependSubfield()}, * or {@link insertSubfield()} to add each subfield individually. * * @param array $subfields array of {@link File_MARC_Subfield} objects * @return int returns the number of subfields that were added */ function addSubfields(array $subfields) { /* * Just in case someone passes in a single File_MARC_Subfield * instead of an array */ if ($subfields instanceof File_MARC_Subfield) { $this->appendSubfield($subfields); return 1; } // Add subfields $cnt = 0; foreach ($subfields as $subfield) { $this->appendSubfield($subfield); $cnt++; } return $cnt; } // }}} // {{{ deleteSubfield() /** * Delete a subfield from the field. * * @return bool Success or failure */ function deleteSubfield(File_MARC_Subfield $subfield) { if ($this->subfields->deleteNode($subfield)) { return true; } return false; } // }}} // {{{ getIndicator() /** * Get the value of an indicator * * @param int $ind number of the indicator (1 or 2) * @return string returns indicator value if it exists, otherwise false */ function getIndicator($ind) { if ($ind == 1) { return $this->ind1; } elseif ($ind == 2) { return $this->ind2; } else { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST], array("indicator" => $indicator)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST); } return false; } // }}} // {{{ setIndicator() /** * Set the value of an indicator * * @param int $ind number of the indicator (1 or 2) * @param string $value value of the indicator * @return string returns indicator value if it exists, otherwise false */ function setIndicator($ind, $value) { switch ($ind) { case 1: $this->ind1 = $this->_validateIndicator($value); break; case 2: $this->ind2 = $this->_validateIndicator($value); break; default: $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST], array("indicator" => $ind)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST); return false; } return getIndicator($ind); } // }}} // {{{ getSubfield() /** * Returns the first subfield that matches a requested code. * * @param string $code subfield code for which the * {@link File_MARC_Subfield} is retrieved * @return File_MARC_Subfield returns the first subfield that matches * $code, or false if no codes match $code */ function getSubfield($code = null) { // iterate merrily through the subfields looking for the requested code foreach ($this->subfields as $sf) { if ($sf->getCode() == $code) { return $sf; } } // No matches were found return false; } // }}} // {{{ getSubfields() /** * Returns an array of subfields that match a requested code, * or a {@link File_MARC_List} that contains all of the subfields * if the requested code is null. * * @param string $code subfield code for which the * {@link File_MARC_Subfield} is retrieved * @return File_MARC_List|array returns a linked list of all subfields * if $code is null, an array of {@link File_MARC_Subfield} objects if * one or more subfields match, or false if no codes match $code */ function getSubfields($code = null) { $results = array(); // return all subfields if no specific subfields were requested if ($code === null) { $results = $this->subfields; return $results; } // iterate merrily through the subfields looking for the requested code foreach ($this->subfields as $sf) { if ($sf->getCode() == $code) { $results[] = $sf; } } return $results; } // }}} // {{{ isEmpty() /** * Checks if the field is empty. * * Checks if the field is empty. If the field has at least one subfield * with data, it is not empty. * * @return bool Returns true if the field is empty, otherwise false */ function isEmpty() { // If $this->subfields is null, we must have deleted it if (!$this->subfields) { return true; } // Iterate through the subfields looking for some data foreach ($this->subfields as $subfield) { // Check if subfield has data if (!$subfield->isEmpty()) { return false; } } // It is empty return true; } // }}} /** * ========== OUTPUT METHODS ========== */ // {{{ __toString() /** * Return Field formatted * * Return Field as a formatted string. * * @return string Formatted output of Field */ function __toString() { // Variables $lines = array(); // Process tag and indicators $pre = sprintf("%3s %1s%1s", $this->tag, $this->ind1, $this->ind2); // Process subfields foreach ($this->subfields as $subfield) { $lines[] = sprintf("%6s _%1s%s", $pre, $subfield->getCode(), $subfield->getData()); $pre = ""; } return join("\n", $lines); } // }}} // {{{ toRaw() /** * Return Field in Raw MARC * * Return the Field formatted in Raw MARC for saving into MARC files * * @return string Raw MARC */ function toRaw() { $subfields = array(); foreach ($this->subfields as $subfield) { if (!$subfield->isEmpty()) { $subfields[] = $subfield->toRaw(); } } return $this->ind1.$this->ind2.implode("", $subfields).File_MARC::END_OF_FIELD; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Exception.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Exception.php +++ pear/File_MARC/MARC/Exception.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Exception.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Exception extends PEAR_Exception /** * The File_MARC_Exception class enables error-handling * for the File_MARC package. * * @category File Formats * @package File_MARC * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Exception extends PEAR_Exception { // {{{ Error codes /** * File could not be opened */ const ERROR_INVALID_FILE = -1; /** * User passed an unknown SOURCE_ constant */ const ERROR_INVALID_SOURCE = -2; /** * MARC record ended with an invalid terminator */ const ERROR_INVALID_TERMINATOR = -3; /** * No directory was found for the MARC record */ const ERROR_NO_DIRECTORY = -4; /** * An entry in the MARC directory was not 12 bytes */ const ERROR_INVALID_DIRECTORY_LENGTH = -5; /** * An entry in the MARC directory specified an invalid tag */ const ERROR_INVALID_DIRECTORY_TAG = -6; /** * An entry in the MARC directory specified an invalid tag length */ const ERROR_INVALID_DIRECTORY_TAG_LENGTH = -7; /** * An entry in the MARC directory specified an invalid field offset */ const ERROR_INVALID_DIRECTORY_OFFSET = -8; /** * An entry in the MARC directory runs past the end of the record */ const ERROR_INVALID_DIRECTORY = -9; /** * A field does not end with the expected end-of-field character */ const ERROR_FIELD_EOF = -10; /** * A field has invalid indicators */ const ERROR_INVALID_INDICATORS = -11; /** * A subfield is defined, but has no data */ const ERROR_EMPTY_SUBFIELD = -12; /** * An indicator other than 1 or 2 was requested */ const ERROR_INVALID_INDICATOR_REQUEST = -13; /** * An invalid mode for adding a field was specified */ const ERROR_INSERTFIELD_MODE = -14; /** * An invalid object was passed instead of a File_MARC_Field object */ const ERROR_INVALID_FIELD = -15; /** * An invalid object was passed instead of a File_MARC_Subfield object */ const ERROR_INVALID_SUBFIELD = -16; /** * An invalid mode for adding a subfield was specified */ const ERROR_INSERTSUBFIELD_MODE = -17; /** * The length in the MARC leader does not match the actual record length */ const ERROR_INCORRECT_LENGTH = -18; /** * The length field in the leader was less than five characters long */ const ERROR_MISSING_LENGTH = -19; /** * A five-digit length could not be found in the MARC leader */ const ERROR_NONNUMERIC_LENGTH = -20; /** * Tag does not adhere to MARC standards */ const ERROR_INVALID_TAG = -21; /** * A field has invalid indicators */ const ERROR_INVALID_INDICATOR = -22; // }}} // {{{ error messages public static $messages = array( self::ERROR_EMPTY_SUBFIELD => 'No subfield data found in tag "%tag%"', self::ERROR_FIELD_EOF => 'Field for tag "%tag%" does not end with an end of field character', self::ERROR_INCORRECT_LENGTH => 'Invalid record length: Leader says "%record_length%" bytes; actual record length is "%actual%"', self::ERROR_INSERTFIELD_MODE => 'insertField() mode "%mode%" was not recognized', self::ERROR_INSERTSUBFIELD_MODE => 'insertSubfield() mode "%mode%" was not recognized', self::ERROR_INVALID_DIRECTORY => 'Directory entry for tag "%tag%" runs past the end of the record', self::ERROR_INVALID_DIRECTORY_LENGTH => 'Invalid directory length', self::ERROR_INVALID_DIRECTORY_OFFSET => 'Invalid offset "%offset%" for tag "%tag%" in directory', self::ERROR_INVALID_DIRECTORY_TAG => 'Invalid tag "%tag%" in directory', self::ERROR_INVALID_DIRECTORY_TAG_LENGTH => 'Invalid length "%len%" in directory for tag "%tag%"', self::ERROR_INVALID_FIELD => 'Specified field must be a File_MARC_Data_Field or File_MARC_Control_Field object, but was "%field%"', self::ERROR_INVALID_FILE => 'Invalid input file "%filename%"', self::ERROR_INVALID_INDICATOR_REQUEST => 'Attempt to access indicator "%indicator%" failed; 1 and 2 are the only valid indicators', self::ERROR_INVALID_INDICATORS => 'Invalid indicators "%indicators%" forced to blanks for tag "%tag%"', self::ERROR_INVALID_SOURCE => "Invalid source for MARC records", self::ERROR_INVALID_SUBFIELD => 'Specified field must be a File_MARC_Subfield object, but was "%class%"', self::ERROR_INVALID_TAG => 'Tag "%tag%" is not a valid tag.', self::ERROR_INVALID_TERMINATOR => 'Invalid record terminator', self::ERROR_MISSING_LENGTH => "Couldn't find record length", self::ERROR_NO_DIRECTORY => 'No directory found', self::ERROR_NONNUMERIC_LENGTH => 'Record length "%record_length%" is not numeric', self::ERROR_INVALID_INDICATOR => 'Illegal indicator "%indicator%" in field "%tag%" forced to blank', ); // }}} // {{{ formatError() /** * Replaces placeholder tokens in an error message with actual values. * * This method enables you to internationalize the messages for the * File_MARC class by simply replacing the File_MARC_Exception::$messages * array with translated values for the messages. * * @param string $message Error message containing placeholders * @param array $errorValues Actual values to substitute for placeholders * @return string Formatted message */ public static function formatError($message, $errorValues) { foreach ($errorValues as $token => $value) { $message = preg_replace("/\%$token\%/", $value, $message); } return $message; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Field.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Field.php +++ pear/File_MARC/MARC/Field.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Field.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Field extends Structures_LinkedList_DoubleNode /** * The File_MARC_Field class is expected to be extended to reflect the * requirements of control and data fields. * * Every MARC field contains a tag name. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Field extends Structures_LinkedList_DoubleNode { // {{{ properties /** * The tag name of the Field * @var string */ protected $tag; // }}} // {{{ Constructor: function __construct() /** * File_MARC_Field constructor * * Create a new {@link File_MARC_Field} object from passed arguments. We * define placeholders for the arguments required by child classes. * * @param string $tag tag * @param string $subfields placeholder for subfields or control data * @param string $ind1 placeholder for first indicator * @param string $ind2 placeholder for second indicator */ function __construct($tag, $subfields = null, $ind1 = null, $ind2 = null) { $this->tag = $tag; // Check if valid tag if (!preg_match("/^[0-9A-Za-z]{3}$/", $tag)) { $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_TAG], array("tag" => $tag)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_TAG); } } // }}} // {{{ Destructor: function __destruct() /** * Destroys the data field */ function __destruct() { $this->tag = null; parent::__destruct(); } // }}} // {{{ getTag() /** * Returns the tag for this {@link File_MARC_Field} object * * @return string returns the tag number of the field */ function getTag() { return $this->tag; } // }}} // {{{ setTag() /** * Sets the tag for this {@link File_MARC_Field} object * * @param string $tag new value for the tag * @return string returns the tag number of the field */ function setTag($tag) { $this->tag = $tag; return $this->getTag(); } // }}} // {{{ isEmpty() /** * Is empty * * Checks if the field is empty. * * @return bool Returns true if the field is empty, otherwise false */ function isEmpty() { if ($this->getTag()) { return false; } // It is empty return true; } // }}} /** * ========== OUTPUT METHODS ========== */ // {{{ __toString() /** * Return Field formatted * * Return Field as a formatted string. * * @return string Formatted output of Field */ function __toString() { return $this->getTag(); } // }}} // {{{ toRaw() /** * Return field in raw MARC format (stub) * * Return the field formatted in raw MARC for saving into MARC files. This * stub method is extended by the child classes. * * @return bool Raw MARC */ function toRaw() { return false; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/List.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/List.php +++ pear/File_MARC/MARC/List.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: List.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_List extends Structures_LinkedList_Double /** * The File_MARC_List class extends the Structures_LinkedList_Double class * to override the key() method in a meaningful way for foreach() iterators. * * For the list of {@link File_MARC_Field} objects in a {@link File_MARC_Record} * object, the key() method returns the tag name of the field. * * For the list of {@link File_MARC_Subfield} objects in a {@link * File_MARC_Data_Field} object, the key() method returns the code of * the subfield. * * <code> * // Iterate through the fields in a record with key=>value iteration * foreach ($record->getFields() as $tag=>$value) { * print "$tag: "; * if ($value instanceof File_MARC_Control_Field) { * print $value->getData(); * } * else { * // Iterate through the subfields in this data field * foreach ($value->getSubfields() as $code=>$subdata) { * print "_$code"; * } * } * print "\n"; * } * </code> * * @category File Formats * @package File_MARC * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_List extends Structures_LinkedList_Double { // {{{ key() /** * Returns the tag for a {@link File_MARC_Field} object, or the code * for a {@link File_MARC_Subfield} object. * * This method enables you to use a foreach iterator to retrieve * the tag or code as the key for the iterator. * * @return string returns the tag or code */ function key() { if ($this->current() instanceof File_MARC_Field) { return $this->current()->getTag(); } elseif ($this->current() instanceof File_MARC_Subfield) { return $this->current()->getCode(); } return false; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Record.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Record.php +++ pear/File_MARC/MARC/Record.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Record.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Record /** * 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 {@link File_MARC_Data_Field} * objects. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Record { // {{{ properties /** * Contains a linked list of {@link File_MARC_Data_Field} objects for * this record * @var File_MARC_List */ protected $fields; /** * Record leader * @var string */ protected $leader; /** * Non-fatal warnings generated during parsing * @var array */ protected $warnings; // }}} // {{{ Constructor: function __construct() /** * Start function * * Set all variables to defaults to create new File_MARC_Record object * @return true */ function __construct() { $this->fields = new File_MARC_List(); $this->leader = str_repeat(' ', 24); } // }}} // {{{ Destructor: function __destruct() /** * Destroys the data field */ function __destruct() { $this->fields = null; $this->warnings = null; } // }}} // {{{ getLeader() /** * Get MARC leader * * Returns the leader for the MARC record. No validation * on the specified leader is performed. * * @return string returns the leader */ function getLeader() { return $this->leader; } // }}} // {{{ setLeader() /** * Set MARC record leader * * Sets the leader for the MARC record. No validation * on the specified leader is performed. * * @param string $leader Leader * @return string returns the leader */ function setLeader($leader) { $this->leader = $leader; return $this->leader; } // }}} // {{{ appendField() /** * Appends field to MARC record * * Adds a {@link File_MARC_Control_Field} or {@link File_MARC_Data_Field} * object to the end of the existing list of fields. * * @param File_MARC_Field $new_field The field to add * @return File_MARC_Field The field that was added */ function appendField(File_MARC_Field $new_field) { /* Append as the last field in the record */ $this->fields->appendNode($new_field); return $new_field; } // }}} // {{{ prependField() /** * Prepends field to MARC record * * Adds a {@link File_MARC_Control_Field} or {@link File_MARC_Data_Field} * object to the start of to the existing list of fields. * * @param File_MARC_Field $new_field The field to add * @return File_MARC_Field The field that was added */ function prependField(File_MARC_Field $new_field) { $this->fields->prependNode($new_field); return $new_field; } // }}} // {{{ insertField() /** * 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_Data_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 */ 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" => $mode)); throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INSERTFIELD_MODE); return false; } return $new_field; } // }}} // {{{ _buildDirectory() /** * Build record directory * * Generate the directory of the record according to the current contents * of the record. * * @return array Array ($fields, $directory, $total, $base_address) */ private function _buildDirectory() { // Vars $fields = array(); $directory = array(); $data_end = 0; foreach ($this->fields as $field) { // No empty fields allowed if (!$field->isEmpty()) { // Get data in raw format $str = $field->toRaw(); $fields[] = $str; // Create directory entry $len = strlen($str); $direntry = sprintf("%03s%04d%05d", $field->getTag(), $len, $data_end); $directory[] = $direntry; $data_end += $len; } } /** * Rules from MARC::Record::USMARC */ $base_address = File_MARC::LEADER_LEN + // better be 24 (count($directory) * File_MARC::DIRECTORY_ENTRY_LEN) + // all the directory entries 1; // end-of-field marker $total = $base_address + // stuff before first field $data_end + // Length of the fields 1; // End-of-record marker return array($fields, $directory, $total, $base_address); } // }}} // {{{ setLeaderLengths() /** * Set MARC record leader lengths * * Set the Leader lengths of the record according to defaults specified in * {@link http://www.loc.gov/marc/bibliographic/ecbdldrd.html} * * @param int $record_length Record length * @param int $base_address Base address of data * @return bool Success or failure */ function setLeaderLengths($record_length, $base_address) { if (!is_int($record_length)) { return false; } if (!is_int($base_address)) { return false; } // Set record length $this->leader = substr_replace($this->leader, sprintf("%05d", $record_length), 0, 5); $this->leader = substr_replace($this->leader, sprintf("%05d", $base_address), 12, 5); $this->leader = substr_replace($this->leader, '22', 10, 2); $this->leader = substr_replace($this->leader, '4500', 20, 4); return true; } // }}} // {{{ getField() /** * Return the first {@link File_MARC_Data_Field} or * {@link File_MARC_Control_Field} object that matches the specified tag * name. Returns false if no match is found. * * @param string $spec tag name * @param bool $pcre if true, then match as a regular expression * @return {@link File_MARC_Data_Field}|{@link File_MARC_Control_Field} first field that matches the requested tag name */ function getField($spec = null, $pcre = null) { foreach ($this->fields as $field) { if (($pcre && preg_match("/$spec/", $field->getTag())) || (!$pcre && $spec == $field->getTag()) ) { return $field; } } return false; } // }}} // {{{ getFields() /** * Return an array or {@link File_MARC_List} containing all * {@link File_MARC_Data_Field} or {@link File_MARC_Control_Field} objects * that match the specified tag name. If the tag name is omitted all * fields are returned. * * @param string $spec tag name * @param bool $pcre if true, then match as a regular expression * @return File_MARC_List|array {@link File_MARC_Data_Field} or * {@link File_MARC_Control_Field} objects that match the requested tag name */ function getFields($spec = null, $pcre = null) { if (!$spec) { return $this->fields; } // Okay, we're actually looking for something specific $matches = array(); foreach ($this->fields as $field) { if (($pcre && preg_match("/$spec/", $field->getTag())) || (!$pcre && $spec == $field->getTag()) ) { $matches[] = $field; } } return $matches; } // }}} // {{{ deleteFields() /** * Delete all occurrences of a field matching a tag name from the record. * * @param string $tag tag for the fields to be deleted * @param bool $pcre if true, then match as a regular expression * @return int number of fields that were deleted */ function deleteFields($tag, $pcre = null) { $cnt = 0; foreach ($this->getFields() as $field) { if (($pcre && preg_match("/$tag/", $field->getTag())) || (!$pcre && $tag == $field->getTag()) ) { $field->delete(); $cnt++; } } return $cnt; } // }}} // {{{ addWarnings() /** * Add a warning to the MARC record that something non-fatal occurred during * parsing. * * @param string $warning warning message */ public function addWarnings($warning) { $this->warnings[] = $warning; } // }}} // {{{ getWarnings() /** * Return the array of warnings from the MARC record. * * @return array warning messages */ public function getWarnings($warning) { return $this->warnings; } // }}} // {{{ output methods /** * ========== OUTPUT METHODS ========== */ // {{{ 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. * * <code> * // Example: Modify a record and save the output to a file * $record->deleteFields('650'); * * // Now that the record has no subject fields, save it to disk * fopen($file, '/home/dan/no_subject.mrc', 'w'); * fwrite($file, $record->toRaw()); * fclose($file); * </code> * * @return string Raw MARC data */ function toRaw() { list($fields, $directory, $record_length, $base_address) = $this->_buildDirectory(); $this->setLeaderLengths($record_length, $base_address); /** * Glue together all parts */ return $this->leader.implode("", $directory).File_MARC::END_OF_FIELD.implode("", $fields).File_MARC::END_OF_RECORD; } // }}} // {{{ __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> _<code><data> * _<code><data> * * @return string Formatted representation of MARC record */ function __toString() { // Begin output $formatted = "LDR " . $this->leader . "\n"; foreach ($this->fields as $field) { if (!$field->isEmpty()) { $formatted .= $field->__toString() . "\n"; } } return $formatted; } // }}} // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/MARC/Subfield.php?view=markup&rev=1.1 Index: pear/File_MARC/MARC/Subfield.php +++ pear/File_MARC/MARC/Subfield.php <?php /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */ /** * Parser for MARC records * * This package is based on the PHP MARC package, originally called "php-marc", * that is part of the Emilda Project (http://www.emilda.org). Christoffer * Landtman generously agreed to make the "php-marc" code available under the * GNU LGPL so it could be used as the basis of this PEAR package. * * PHP version 5 * * LICENSE: This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @copyright 2003-2006 Oy Realnode Ab, Dan Scott * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: Subfield.php,v 1.1 2006/11/14 18:12:57 dbs Exp $ */ // {{{ class File_MARC_Subfield extends Structures_LinkedList_DoubleNode /** * The File_MARC_Subfield class represents a single subfield in a MARC * record field. * * Represents a subfield within a MARC field and implements all management * functions related to a single subfield. This class also implements * the possibility of duplicate subfields within a single field, for example * 650 _z Test1 _z Test2. * * @category File Formats * @package File_MARC * @author Christoffer Landtman <landtman@realnode.com> * @author Dan Scott <dscott@laurentian.ca> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @link http://pear.php.net/package/File_MARC */ class File_MARC_Subfield extends Structures_LinkedList_DoubleNode { // {{{ properties /** * Subfield code, e.g. _a, _b * @var string */ protected $code; /** * Data contained by the subfield * @var string */ protected $data; // }}} // {{{ Constructor: function __construct() /** * File_MARC_Subfield constructor * * Create a new subfield to represent the code and data * * @param string $code Subfield code * @param string $data Subfield data */ function __construct($code, $data) { $this->code = $code; $this->data = $data; } // }}} // {{{ Destructor: function __destruct() /** * Destroys the subfield */ function __destruct() { $this->code = null; $this->data = null; parent::__destruct(); } // }}} // {{{ Explicit destructor: function delete() /** * Destroys the subfield */ function delete() { $this->__destruct(); } // }}} // {{{ getCode() /** * Return code of the subfield * * @return string Tag name */ function getCode() { return $this->code; } // }}} // {{{ getData() /** * Return data of the subfield * * @return string data */ function getData() { return $this->data; } // }}} // {{{ __toString() /** * Return string representation of subfield * * @return string String representation */ public function __toString() { $pretty = '[' . $this->getCode() . ']: ' . $this->getData(); return $pretty; } // }}} // {{{ toRaw() /** * Return the USMARC representation of the subfield * * @return string USMARC representation */ function toRaw() { $result = File_MARC::SUBFIELD_INDICATOR.$this->code.$this->data; return $result; } // }}} // {{{ setCode() /** * Sets code of the subfield * * @param string $code new code for the subfield * @return string code */ function setCode($code) { if ($code) { // could check more stringently; m/[a-Z]/ or the likes $this->code = $code; } else { // code must be _something_; raise error return false; } return true; } // }}} // {{{ setData() /** * Sets data of the subfield * * @param string $data new data for the subfield * @return string data */ function setData($data) { $this->data = $data; return true; } // }}} // {{{ isEmpty() /** * Checks whether the subfield is empty or not * * @return bool True or false */ function isEmpty() { // There is data if ($this->data) { return false; } // There is no data return true; } // }}} } // }}} http://cvs.php.net/viewvc.cgi/pear/File_MARC/examples/example.mrc?view=markup&rev=1.1 Index: pear/File_MARC/examples/example.mrc +++ pear/File_MARC/examples/example.mrc 01850 2200517 45000010011000000030007000110080039000180200026000570350015000830400007000980420012001050840018001170840018001350840021001530840022001741000030001962450062002262500013002882600058003013000033003594400037003925000023004295990010004527400024004627750034004868410048005208410049005688410047006178410048006648410047007128410047007598520038008068520021008448520013008658520016008788520028008948520021009229000056009439000060009999000057010599000056011169000057011729000060012299760026012890050017013150000000044EMILDA980120s1998 fi j 000 0 swe a9515008808cFIM 72:00 99515008808 aNB 9NB9SEE aHcd,u2kssb/6 5NBauHc2kssb 5SEEaHcf2kssb/6 5QaHcd,uf2kssb/61 aJansson, Tove,d1914-200104aDet osynliga barnet och andra berättelser /cTove Jansson a7. uppl. aHelsingfors :bSchildt,c1998 ;e(Falun :fScandbook) a166, [4] s. :bill. ;c21 cm 0aMumin-biblioteket,x99-0698931-9 aOriginaluppl. 1962 aLi: S4 aDet os! ynliga barnet1 z951-50-0385-7w9515003857907 5Liaxab0201080u 0 4000uu |000000e1 5SEEaxab0201080u 0 4000uu |000000e1 5Laxab0201080u 0 4000uu |000000e1 5NBaxab0201080u 0 4000uu |000000e1 5Qaxab0201080u 0 4000uu |000000e1 5Saxab0201080u 0 4000uu |000000e1 5NBbNBcNB98:12hpliktjR, 980520 5LibLicCNBhh,u 5SEEbSEE 5QbQj98947 5LbLc0100h98/j3043 H 5SbShSv97j72351saYanson, Tobe,d1914-2001uJansson, Tove,d1914-20011saJanssonová, Tove,d1914-2001uJansson, Tove,d1914-20011saJansone, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJansson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanssonova, Tove,d1914-2001uJansson, Tove,d1914-2001 2aHcd,ubSkönlitteratur20050204111518.0 http://cvs.php.net/viewvc.cgi/pear/File_MARC/examples/marc_yaz.php?view=markup&rev=1.1 Index: pear/File_MARC/examples/marc_yaz.php +++ pear/File_MARC/examples/marc_yaz.php <?php $dir = dirname(__FILE__); require 'File/MARC.php'; // Define the usable fields for our CCL query $ccl_fields = array( "ti" => "1=4", "au" => "1=1", "isbn" => "1=7" ); // Declare the array that will hold the parsed results $ccl_results = array(); // Connect to the laurentian.ca Z39.50 server $conn = yaz_connect('142.51.8.7:2200/UNICORN'); yaz_ccl_conf($conn, $ccl_fields); // Define our query for a most excellent text $ccl_query = "ti='derby' and au='scott'"; // Parse the CCL query into yaz's native format $result = yaz_ccl_parse($conn, $ccl_query, $ccl_results); if (!$result) { echo "Error: " . $ccl_results['errorstring']; exit(); } // Submit the query $rpn = $ccl_results['rpn']; yaz_search($conn, 'rpn', $rpn); yaz_wait(); // Any errors trying to retrieve this record? $error = yaz_error($conn); if ($error) { print "Error: $error\n"; exit(); } // Retrieve the first MARC record as raw MARC $rec = yaz_record($conn, 1, "raw"); if (!$rec) { print "Error: Retrieved no results.\n"; exit(); } // Parse the retrieved MARC record $marc_file = new File_MARC($rec, File_MARC::SOURCE_STRING); while ($marc_record = $marc_file->next()) { print $marc_record; print "\n"; } ?> http://cvs.php.net/viewvc.cgi/pear/File_MARC/examples/read.php?view=markup&rev=1.1 Index: pear/File_MARC/examples/read.php +++ pear/File_MARC/examples/read.php <?php require 'File/MARC.php'; // Read MARC records from a stream (a file, in this case) $marc_source = new File_MARC('example.mrc'); // Retrieve the first MARC record from the source $marc_record = $marc_source->next(); // Retrieve a personal name field from the record $names = $marc_record->getFields('100'); foreach ($names as $name_field) { // Now print the $a subfield switch ($name_field->getIndicator(1)) { case 0: print "Forename: "; break; case 1: print "Surname: "; break; case 2: print "Family name: "; break; } $name = $name_field->getSubfields('a'); if (count($name) == 1) { print $name[0]->getData() . "\n"; } else { print "Error -- \$a subfield appears more than once in this field!"; } } print "\nPrint all series statement fields (4xx):\n"; // Retrieve all series statement fields // Series statement fields start with a 4 (PCRE) $subjects = $marc_record->getFields('^4', true); // Iterate through all of the returned series statement fields foreach ($subjects as $field) { // print with File_MARC_Field_Data's magic __toString() method print $field; } print "\n"; ?> http://cvs.php.net/viewvc.cgi/pear/File_MARC/examples/subfields.php?view=markup&rev=1.1 Index: pear/File_MARC/examples/subfields.php +++ pear/File_MARC/examples/subfields.php <?php require 'File/MARC.php'; // File_MARC offers the ability to add subfields at any point within // an existing set of subfields // First, create some subfields $subfields[] = new File_MARC_Subfield('a', 'nothing'); $subfields[] = new File_MARC_Subfield('z', 'everything'); // Then, create a field including those subfields $field = new File_MARC_Data_Field('100', $subfields, '0'); // Create some new subfields $subfield1 = new File_MARC_Subfield('g', 'a little'); $subfield2 = new File_MARC_Subfield('k', 'a bit more'); $subfield3 = new File_MARC_Subfield('t', 'a lot'); // Append a new subfield to the existing set of subfields // Expected order: a-z-g $field->appendSubfield($subfield1); // Insert a new subfield after the first subfield with code 'z' // Expected order: a-z-k-g $sf = $field->getSubfields('z'); // getSubfields() always returns an array; we just want the first subfield if (count($sf) > 0) { $field->insertSubfield($subfield2, $sf[0]); } // Insert a new subfield prior to the first subfield with code 'z' // Expected order: a-t-z-k-g $sf = $field->getSubfield('z'); // getSubfield() simply returns the first matching subfield if ($sf) { $field->insertSubfield($subfield3, $sf, true); } // let's see the results print $field; print "\n"; ?> http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/example.mrc?view=markup&rev=1.1 Index: pear/File_MARC/tests/example.mrc +++ pear/File_MARC/tests/example.mrc 01850 2200517 45000010011000000030007000110080039000180200026000570350015000830400007000980420012001050840018001170840018001350840021001530840022001741000030001962450062002262500013002882600058003013000033003594400037003925000023004295990010004527400024004627750034004868410048005208410049005688410047006178410048006648410047007128410047007598520038008068520021008448520013008658520016008788520028008948520021009229000056009439000060009999000057010599000056011169000057011729000060012299760026012890050017013150000000044EMILDA980120s1998 fi j 000 0 swe a9515008808cFIM 72:00 99515008808 aNB 9NB9SEE aHcd,u2kssb/6 5NBauHc2kssb 5SEEaHcf2kssb/6 5QaHcd,uf2kssb/61 aJansson, Tove,d1914-200104aDet osynliga barnet och andra berättelser /cTove Jansson a7. uppl. aHelsingfors :bSchildt,c1998 ;e(Falun :fScandbook) a166, [4] s. :bill. ;c21 cm 0aMumin-biblioteket,x99-0698931-9 aOriginaluppl. 1962 aLi: S4 aDet os! ynliga barnet1 z951-50-0385-7w9515003857907 5Liaxab0201080u 0 4000uu |000000e1 5SEEaxab0201080u 0 4000uu |000000e1 5Laxab0201080u 0 4000uu |000000e1 5NBaxab0201080u 0 4000uu |000000e1 5Qaxab0201080u 0 4000uu |000000e1 5Saxab0201080u 0 4000uu |000000e1 5NBbNBcNB98:12hpliktjR, 980520 5LibLicCNBhh,u 5SEEbSEE 5QbQj98947 5LbLc0100h98/j3043 H 5SbShSv97j72351saYanson, Tobe,d1914-2001uJansson, Tove,d1914-20011saJanssonová, Tove,d1914-2001uJansson, Tove,d1914-20011saJansone, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJansson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanssonova, Tove,d1914-2001uJansson, Tove,d1914-2001 2aHcd,ubSkönlitteratur20050204111518.0 http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_001.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_001.phpt +++ pear/File_MARC/tests/marc_001.phpt --TEST-- marc_001: iterate and pretty print a MARC record --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'example.mrc'); while ($marc_record = $marc_file->next()) { print $marc_record; print "\n"; } ?> --EXPECT-- LDR 01850 2200517 4500 001 0000000044 003 EMILDA 008 980120s1998 fi j 000 0 swe 020 _a9515008808 _cFIM 72:00 035 _99515008808 040 _aNB 042 _9NB _9SEE 084 _aHcd,u _2kssb/6 084 _5NB _auHc _2kssb 084 _5SEE _aHcf _2kssb/6 084 _5Q _aHcd,uf _2kssb/6 100 1 _aJansson, Tove, _d1914-2001 245 04 _aDet osynliga barnet och andra berättelser / _cTove Jansson 250 _a7. uppl. 260 _aHelsingfors : _bSchildt, _c1998 ; _e(Falun : _fScandbook) 300 _a166, [4] s. : _bill. ; _c21 cm 440 0 _aMumin-biblioteket, _x99-0698931-9 500 _aOriginaluppl. 1962 599 _aLi: S 740 4 _aDet osynliga barnet 775 1 _z951-50-0385-7 _w9515003857 _907 841 _5Li _axa _b0201080u 0 4000uu |000000 _e1 841 _5SEE _axa _b0201080u 0 4000uu |000000 _e1 841 _5L _axa _b0201080u 0 4000uu |000000 _e1 841 _5NB _axa _b0201080u 0 4000uu |000000 _e1 841 _5Q _axa _b0201080u 0 4000uu |000000 _e1 841 _5S _axa _b0201080u 0 4000uu |000000 _e1 852 _5NB _bNB _cNB98:12 _hplikt _jR, 980520 852 _5Li _bLi _cCNB _hh,u 852 _5SEE _bSEE 852 _5Q _bQ _j98947 852 _5L _bL _c0100 _h98/ _j3043 H 852 _5S _bS _hSv97 _j7235 900 1s _aYanson, Tobe, _d1914-2001 _uJansson, Tove, _d1914-2001 900 1s _aJanssonová, Tove, _d1914-2001 _uJansson, Tove, _d1914-2001 900 1s _aJansone, Tuve, _d1914-2001 _uJansson, Tove, _d1914-2001 900 1s _aJanson, Tuve, _d1914-2001 _uJansson, Tove, _d1914-2001 900 1s _aJansson, Tuve, _d1914-2001 _uJansson, Tove, _d1914-2001 900 1s _aJanssonova, Tove, _d1914-2001 _uJansson, Tove, _d1914-2001 976 2 _aHcd,u _bSkönlitteratur 005 20050204111518.0 http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_002.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_002.phpt +++ pear/File_MARC/tests/marc_002.phpt --TEST-- marc_002: iterate and pretty print MARC records from a file with multiple records --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'music.mrc'); while ($marc_record = $marc_file->next()) { print $marc_record; print "\n"; } ?> --EXPECT-- LDR 01145ncm 2200277 i 4500 001 000073594 004 AAJ5802 005 20030415102100.0 008 801107s1977 nyujza 010 _a 77771106 035 _a(CaOTUIC)15460184 035 9 _aAAJ5802 040 _aLC 050 00 _aM1366 _b.M62 _dM1527.2 245 04 _aThe Modern Jazz Quartet : _bThe legendary profile. -- 260 _aNew York : _bM.J.Q. Music, _cc1977. 300 _ascore (72 p.) ; _c31 cm. 500 _aFor piano, vibraphone, drums, and double bass. 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 650 0 _aJazz. 650 0 _aMotion picture music _vExcerpts _vScores. 700 12 _aLewis, John, _d1920- _tSelections. _f1977. 700 12 _aJackson, Milt. _tMartyrs. _f1977. 700 12 _aJackson, Milt. _tLegendary profile. _f1977. 740 4 _aThe legendary profile. 852 00 _bMUSIC _cMAIN _kfolio _hM1366 _iM62 _91 _4Marvin Duchow Music _5 LDR 01293cjm 2200289 a 4500 001 001878039 005 20050110174900.0 007 sd fungnn|||e| 008 940202r19931981nyujzn i d 024 1 _a7464573372 028 02 _aJK 57337 _bRed Baron 035 _a(OCoLC)29737267 040 _aSVP _cSVP _dLGG 100 1 _aDesmond, Paul, _d1924- 245 10 _aPaul Desmond & the Modern Jazz Quartet _h[sound recording] 260 _aNew York, N.Y. : _bRed Baron : _bManufactured by Sony Music Entertainment, _cp1993. 300 _a1 sound disc (39 min.) : _bdigital ; _c4 3/4 in. 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 500 _aAll arrangements by John Lewis. 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 650 0 _aJazz _y1971-1980. 700 1 _aLewis, John, _d1920- 710 2 _aModern Jazz Quartet. 740 0 _aPaul Desmond and the Modern Jazz Quartet. LDR 01829cjm 2200385 a 4500 001 001964482 005 20060626132700.0 007 sd fzngnn|m|e| 008 871211p19871957nyujzn d 024 1 _a4228332902 028 01 _a833 290-2 _bVerve 033 0 _a19571027 _b6299 _cD56 033 0 _a196112-- _b3804 _cN4 033 0 _a19571019 _b4104 _cC6 033 0 _a197107-- _b6299 _cV7 035 _a(OCoLC)17222092 040 _aCPL _cCPL _dOCL _dLGG 048 _apz01 _aka01 _asd01 _apd01 110 2 _aModern Jazz Quartet. _4prf 245 14 _aThe Modern Jazz Quartet plus _h[sound recording]. 260 _a[New York] : _bVerve, _cp1987. 300 _a1 sound disc : _bdigital ; _c4 3/4 in. 440 0 _aCompact jazz 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 500 _aCompact disc. 500 _aAnalog recording. 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 650 0 _aJazz. 700 1 _aJackson, Milt. _4prf 700 1 _aPeterson, Oscar, _d1925- _4prf 700 1 _aBrown, Ray, _d1926-2002. _4prf 700 1 _aThigpen, Ed. _4prf 700 1 _aHayes, Louis, _d1937- _4prf 852 80 _bMUSIC _cAV _hCD 1131 _4Marvin Duchow Music _5Audio-Visual http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_003.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_003.phpt +++ pear/File_MARC/tests/marc_003.phpt --TEST-- marc_003: getFields() with various regular expressions --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'music.mrc'); print "Test with a simple string\n"; while ($marc_record = $marc_file->next()) { print "\nNext record:\n"; $fields = $marc_record->getFields('650'); foreach ($fields as $field) { print $field; print "\n"; } } print "\nTest with regular expression\n"; $marc_file = new File_MARC($dir . '/' . 'music.mrc'); while ($marc_record = $marc_file->next()) { print "\nNext record:\n"; $fields = $marc_record->getFields('00\d', true); foreach ($fields as $field) { print $field; print "\n"; } } ?> --EXPECT-- Test with a simple string Next record: 650 0 _aJazz. 650 0 _aMotion picture music _vExcerpts _vScores. Next record: 650 0 _aJazz _y1971-1980. Next record: 650 0 _aJazz. Test with regular expression Next record: 001 000073594 004 AAJ5802 005 20030415102100.0 008 801107s1977 nyujza Next record: 001 001878039 005 20050110174900.0 007 sd fungnn|||e| 008 940202r19931981nyujzn i d Next record: 001 001964482 005 20060626132700.0 007 sd fzngnn|m|e| 008 871211p19871957nyujzn d http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_004.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_004.phpt +++ pear/File_MARC/tests/marc_004.phpt --TEST-- marc_004: Delete fields and subfields --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'music.mrc'); print "\nDelete all fields with tag 650\n"; while ($marc_record = $marc_file->next()) { print "\nNext record:\n"; $fields = $marc_record->getFields('650'); foreach ($fields as $field) { $field->delete(); } print $marc_record; } $marc_file = null; $marc_file = new File_MARC($dir . '/' . 'music.mrc'); print "\nDelete all subfields with code 'a' from fields with tag 650\n"; while ($marc_record = $marc_file->next()) { print "\nNext record:\n"; $fields = $marc_record->getFields('650'); foreach ($fields as $field) { $sf = $field->getSubfields('a'); foreach ($sf as $subfield) { $field->deleteSubfield($subfield); } } print $marc_record; } ?> --EXPECT-- Delete all fields with tag 650 Next record: LDR 01145ncm 2200277 i 4500 001 000073594 004 AAJ5802 005 20030415102100.0 008 801107s1977 nyujza 010 _a 77771106 035 _a(CaOTUIC)15460184 035 9 _aAAJ5802 040 _aLC 050 00 _aM1366 _b.M62 _dM1527.2 245 04 _aThe Modern Jazz Quartet : _bThe legendary profile. -- 260 _aNew York : _bM.J.Q. Music, _cc1977. 300 _ascore (72 p.) ; _c31 cm. 500 _aFor piano, vibraphone, drums, and double bass. 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 700 12 _aLewis, John, _d1920- _tSelections. _f1977. 700 12 _aJackson, Milt. _tMartyrs. _f1977. 700 12 _aJackson, Milt. _tLegendary profile. _f1977. 740 4 _aThe legendary profile. 852 00 _bMUSIC _cMAIN _kfolio _hM1366 _iM62 _91 _4Marvin Duchow Music _5 Next record: LDR 01293cjm 2200289 a 4500 001 001878039 005 20050110174900.0 007 sd fungnn|||e| 008 940202r19931981nyujzn i d 024 1 _a7464573372 028 02 _aJK 57337 _bRed Baron 035 _a(OCoLC)29737267 040 _aSVP _cSVP _dLGG 100 1 _aDesmond, Paul, _d1924- 245 10 _aPaul Desmond & the Modern Jazz Quartet _h[sound recording] 260 _aNew York, N.Y. : _bRed Baron : _bManufactured by Sony Music Entertainment, _cp1993. 300 _a1 sound disc (39 min.) : _bdigital ; _c4 3/4 in. 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 500 _aAll arrangements by John Lewis. 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 700 1 _aLewis, John, _d1920- 710 2 _aModern Jazz Quartet. 740 0 _aPaul Desmond and the Modern Jazz Quartet. Next record: LDR 01829cjm 2200385 a 4500 001 001964482 005 20060626132700.0 007 sd fzngnn|m|e| 008 871211p19871957nyujzn d 024 1 _a4228332902 028 01 _a833 290-2 _bVerve 033 0 _a19571027 _b6299 _cD56 033 0 _a196112-- _b3804 _cN4 033 0 _a19571019 _b4104 _cC6 033 0 _a197107-- _b6299 _cV7 035 _a(OCoLC)17222092 040 _aCPL _cCPL _dOCL _dLGG 048 _apz01 _aka01 _asd01 _apd01 110 2 _aModern Jazz Quartet. _4prf 245 14 _aThe Modern Jazz Quartet plus _h[sound recording]. 260 _a[New York] : _bVerve, _cp1987. 300 _a1 sound disc : _bdigital ; _c4 3/4 in. 440 0 _aCompact jazz 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 500 _aCompact disc. 500 _aAnalog recording. 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 700 1 _aJackson, Milt. _4prf 700 1 _aPeterson, Oscar, _d1925- _4prf 700 1 _aBrown, Ray, _d1926-2002. _4prf 700 1 _aThigpen, Ed. _4prf 700 1 _aHayes, Louis, _d1937- _4prf 852 80 _bMUSIC _cAV _hCD 1131 _4Marvin Duchow Music _5Audio-Visual Delete all subfields with code 'a' from fields with tag 650 Next record: LDR 01145ncm 2200277 i 4500 001 000073594 004 AAJ5802 005 20030415102100.0 008 801107s1977 nyujza 010 _a 77771106 035 _a(CaOTUIC)15460184 035 9 _aAAJ5802 040 _aLC 050 00 _aM1366 _b.M62 _dM1527.2 245 04 _aThe Modern Jazz Quartet : _bThe legendary profile. -- 260 _aNew York : _bM.J.Q. Music, _cc1977. 300 _ascore (72 p.) ; _c31 cm. 500 _aFor piano, vibraphone, drums, and double bass. 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 650 0 _vExcerpts _vScores. 700 12 _aLewis, John, _d1920- _tSelections. _f1977. 700 12 _aJackson, Milt. _tMartyrs. _f1977. 700 12 _aJackson, Milt. _tLegendary profile. _f1977. 740 4 _aThe legendary profile. 852 00 _bMUSIC _cMAIN _kfolio _hM1366 _iM62 _91 _4Marvin Duchow Music _5 Next record: LDR 01293cjm 2200289 a 4500 001 001878039 005 20050110174900.0 007 sd fungnn|||e| 008 940202r19931981nyujzn i d 024 1 _a7464573372 028 02 _aJK 57337 _bRed Baron 035 _a(OCoLC)29737267 040 _aSVP _cSVP _dLGG 100 1 _aDesmond, Paul, _d1924- 245 10 _aPaul Desmond & the Modern Jazz Quartet _h[sound recording] 260 _aNew York, N.Y. : _bRed Baron : _bManufactured by Sony Music Entertainment, _cp1993. 300 _a1 sound disc (39 min.) : _bdigital ; _c4 3/4 in. 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 500 _aAll arrangements by John Lewis. 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 650 0 _y1971-1980. 700 1 _aLewis, John, _d1920- 710 2 _aModern Jazz Quartet. 740 0 _aPaul Desmond and the Modern Jazz Quartet. Next record: LDR 01829cjm 2200385 a 4500 001 001964482 005 20060626132700.0 007 sd fzngnn|m|e| 008 871211p19871957nyujzn d 024 1 _a4228332902 028 01 _a833 290-2 _bVerve 033 0 _a19571027 _b6299 _cD56 033 0 _a196112-- _b3804 _cN4 033 0 _a19571019 _b4104 _cC6 033 0 _a197107-- _b6299 _cV7 035 _a(OCoLC)17222092 040 _aCPL _cCPL _dOCL _dLGG 048 _apz01 _aka01 _asd01 _apd01 110 2 _aModern Jazz Quartet. _4prf 245 14 _aThe Modern Jazz Quartet plus _h[sound recording]. 260 _a[New York] : _bVerve, _cp1987. 300 _a1 sound disc : _bdigital ; _c4 3/4 in. 440 0 _aCompact jazz 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 500 _aCompact disc. 500 _aAnalog recording. 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 700 1 _aJackson, Milt. _4prf 700 1 _aPeterson, Oscar, _d1925- _4prf 700 1 _aBrown, Ray, _d1926-2002. _4prf 700 1 _aThigpen, Ed. _4prf 700 1 _aHayes, Louis, _d1937- _4prf 852 80 _bMUSIC _cAV _hCD 1131 _4Marvin Duchow Music _5Audio-Visual http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_005.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_005.phpt +++ pear/File_MARC/tests/marc_005.phpt --TEST-- marc_005: Ensure a duplicated record is a deep copy; test deleteFields() --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'example.mrc'); $marc_record = $marc_file->next(); $copy_record = $marc_record; $duplicate_record = clone $marc_record; $num_deleted1 = $marc_record->deleteFields('020'); print "Deleted $num_deleted1 fields from the original record.\n"; $num_deleted2 = $copy_record->deleteFields('8\\d\\d', true); print "Deleted $num_deleted2 fields from the shallow copy record.\n"; $num_deleted3 = $duplicate_record->deleteFields('9\\d\\d', true); print "Deleted $num_deleted3 fields from the duplicate record.\n"; print "Original:\n"; print $marc_record; print "\nCopy:\n"; print $copy_record; print "\nDuplicate:\n"; print $duplicate_record; print "\n"; ?> --EXPECT-- Deleted 1 fields from the original record. Deleted 12 fields from the shallow copy record. Deleted 7 fields from the duplicate record. Original: LDR 01850 2200517 4500 001 0000000044 003 EMILDA 008 980120s1998 fi j 000 0 swe 035 _99515008808 040 _aNB 042 _9NB _9SEE 084 _aHcd,u _2kssb/6 084 _5NB _auHc _2kssb 084 _5SEE _aHcf _2kssb/6 084 _5Q _aHcd,uf _2kssb/6 100 1 _aJansson, Tove, _d1914-2001 245 04 _aDet osynliga barnet och andra berättelser / _cTove Jansson 250 _a7. uppl. 260 _aHelsingfors : _bSchildt, _c1998 ; _e(Falun : _fScandbook) 300 _a166, [4] s. : _bill. ; _c21 cm 440 0 _aMumin-biblioteket, _x99-0698931-9 500 _aOriginaluppl. 1962 599 _aLi: S 740 4 _aDet osynliga barnet 775 1 _z951-50-0385-7 _w9515003857 _907 005 20050204111518.0 Copy: LDR 01850 2200517 4500 001 0000000044 003 EMILDA 008 980120s1998 fi j 000 0 swe 035 _99515008808 040 _aNB 042 _9NB _9SEE 084 _aHcd,u _2kssb/6 084 _5NB _auHc _2kssb 084 _5SEE _aHcf _2kssb/6 084 _5Q _aHcd,uf _2kssb/6 100 1 _aJansson, Tove, _d1914-2001 245 04 _aDet osynliga barnet och andra berättelser / _cTove Jansson 250 _a7. uppl. 260 _aHelsingfors : _bSchildt, _c1998 ; _e(Falun : _fScandbook) 300 _a166, [4] s. : _bill. ; _c21 cm 440 0 _aMumin-biblioteket, _x99-0698931-9 500 _aOriginaluppl. 1962 599 _aLi: S 740 4 _aDet osynliga barnet 775 1 _z951-50-0385-7 _w9515003857 _907 005 20050204111518.0 Duplicate: LDR 01850 2200517 4500 001 0000000044 003 EMILDA 008 980120s1998 fi j 000 0 swe 035 _99515008808 040 _aNB 042 _9NB _9SEE 084 _aHcd,u _2kssb/6 084 _5NB _auHc _2kssb 084 _5SEE _aHcf _2kssb/6 084 _5Q _aHcd,uf _2kssb/6 100 1 _aJansson, Tove, _d1914-2001 245 04 _aDet osynliga barnet och andra berättelser / _cTove Jansson 250 _a7. uppl. 260 _aHelsingfors : _bSchildt, _c1998 ; _e(Falun : _fScandbook) 300 _a166, [4] s. : _bill. ; _c21 cm 440 0 _aMumin-biblioteket, _x99-0698931-9 500 _aOriginaluppl. 1962 599 _aLi: S 740 4 _aDet osynliga barnet 775 1 _z951-50-0385-7 _w9515003857 _907 005 20050204111518.0 http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_006.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_006.phpt +++ pear/File_MARC/tests/marc_006.phpt --TEST-- marc_006: test read.php --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // Read MARC records from a stream (a file, in this case) $marc_source = new File_MARC($dir . '/' . 'example.mrc'); // Retrieve the first MARC record from the source $marc_record = $marc_source->next(); // Retrieve a personal name field from the record $names = $marc_record->getFields('100'); foreach ($names as $name_field) { // Now print the $a subfield switch ($name_field->getIndicator(1)) { case 0: print "Forename: "; break; case 1: print "Surname: "; break; case 2: print "Family name: "; break; } $name = $name_field->getSubfields('a'); if (count($name) == 1) { print $name[0]->getData() . "\n"; } else { print "Error -- \$a subfield appears more than once in this field!"; } } // Retrieve all series statement fields // Series statement fields start with a 4 (PCRE) $subjects = $marc_record->getFields('^4', true); // Iterate through all of the returned series statement fields foreach ($subjects as $field) { // print with File_MARC_Field_Data's magic __toString() method print $field; } ?> --EXPECT-- Surname: Jansson, Tove, 440 0 _aMumin-biblioteket, _x99-0698931-9 http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_007.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_007.phpt +++ pear/File_MARC/tests/marc_007.phpt --TEST-- marc_007: Use key=>value iteration for tags and codes --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; $marc_file = new File_MARC($dir . '/' . 'example.mrc'); if ($marc_record = $marc_file->next()) { foreach ($marc_record->getFields() as $tag=>$value) { print "$tag: "; if ($value instanceof File_MARC_Control_Field) { print $value->getData(); } else { foreach ($value->getSubfields() as $code=>$subdata) { print "_$code"; } } print "\n"; } } ?> --EXPECT-- 001: 0000000044 003: EMILDA 008: 980120s1998 fi j 000 0 swe 020: _a_c 035: _9 040: _a 042: _9_9 084: _a_2 084: _5_a_2 084: _5_a_2 084: _5_a_2 100: _a_d 245: _a_c 250: _a 260: _a_b_c_e_f 300: _a_b_c 440: _a_x 500: _a 599: _a 740: _a 775: _z_w_9 841: _5_a_b_e 841: _5_a_b_e 841: _5_a_b_e 841: _5_a_b_e 841: _5_a_b_e 841: _5_a_b_e 852: _5_b_c_h_j 852: _5_b_c_h 852: _5_b 852: _5_b_j 852: _5_b_c_h_j 852: _5_b_h_j 900: _a_d_u_d 900: _a_d_u_d 900: _a_d_u_d 900: _a_d_u_d 900: _a_d_u_d 900: _a_d_u_d 976: _a_b 005: 20050204111518.0 http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_field_001.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_field_001.phpt +++ pear/File_MARC/tests/marc_field_001.phpt --TEST-- marc_field_001: Exercise basic methods for File_MARC_Field class --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // create some subfields $subfields[] = new File_MARC_Subfield('a', 'nothing'); $subfields[] = new File_MARC_Subfield('z', 'everything'); // test constructor $field = new File_MARC_Data_Field('100', $subfields, '0'); // test basic getter methods print "Tag: " . $field->getTag() . "\n"; print "Ind1: " . $field->getIndicator(1) . "\n"; print "Ind2: " . $field->getIndicator(2) . "\n"; // test pretty print print $field; print "\n"; // test raw print print $field->toRaw(); ?> --EXPECT-- Tag: 100 Ind1: 0 Ind2: 100 0 _anothing _zeverything 0 anothingzeverything http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_field_002.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_field_002.phpt +++ pear/File_MARC/tests/marc_field_002.phpt --TEST-- marc_field_002: Create fields with invalid indicators --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // create some subfields $subfields[] = new File_MARC_Subfield('a', 'nothing'); $subfields[] = new File_MARC_Subfield('z', 'everything'); // test constructor try { $field = new File_MARC_Data_Field('100', $subfields, '$@'); } catch (Exception $e) { print "Error: {$e->getMessage()}\n"; } --EXPECT-- Error: Illegal indicator "$@" in field "100" forced to blank http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_field_003.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_field_003.phpt +++ pear/File_MARC/tests/marc_field_003.phpt --TEST-- marc_field_003: Add subfields to an existing field --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // create some subfields $subfields[] = new File_MARC_Subfield('a', 'nothing'); $subfields[] = new File_MARC_Subfield('z', 'everything'); // create a field $field = new File_MARC_Data_Field('100', $subfields, '0'); // create some new subfields $subfield1 = new File_MARC_Subfield('g', 'a little'); $subfield2 = new File_MARC_Subfield('k', 'a bit more'); $subfield3 = new File_MARC_Subfield('t', 'a lot'); // append a new subfield to the existing set of subfields // expected order: a-z-g $field->appendSubfield($subfield1); // insert a new subfield after the first subfield with code 'z' // expected order: a-z-k-g $sf = $field->getSubfields('z'); // we might get an array back; in this case, we want the first subfield if (is_array($sf)) { $field->insertSubfield($subfield2, $sf[0]); } else { $field->insertSubfield($subfield2, $sf); } // insert a new subfield prior to the first subfield with code 'z' // expected order: a-t-z-k-g $sf = $field->getSubfields('z'); // we might get an array back; in this case, we want the first subfield if (is_array($sf)) { $field->insertSubfield($subfield3, $sf[0], true); } else { $field->insertSubfield($subfield3, $sf, true); } // let's see the results print $field; print "\n"; ?> --EXPECT-- 100 0 _anothing _ta lot _zeverything _ka bit more _ga little http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_field_004.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_field_004.phpt +++ pear/File_MARC/tests/marc_field_004.phpt --TEST-- marc_field_004: Add subfields to an existing field (corner case) --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // create some subfields $subfields[] = new File_MARC_Subfield('a', 'nothing'); $subfields[] = new File_MARC_Subfield('z', 'everything'); // create a field $field = new File_MARC_Data_Field('100', $subfields, '0'); // create some new subfields $subfield1 = new File_MARC_Subfield('g', 'a little'); // test the fieldpost corner case by inserting prior to the first subfield $sf = $field->getSubfields('a'); // we might get an array back; in this case, we want the first subfield if (is_array($sf)) { $field->insertSubfield($subfield1, $sf[0], true); } else { $field->insertSubfield($subfield1, $sf, true); } // let's see the results print $field; print "\n"; ?> --EXPECT-- 100 0 _ga little _anothing _zeverything http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_subfield_001.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_subfield_001.phpt +++ pear/File_MARC/tests/marc_subfield_001.phpt --TEST-- marc_subfield_001: Exercise basic methods for File_MARC_Subfield class --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; // test constructor $subfield = new File_MARC_Subfield('a', 'wasssup'); // test get methods print "Code: " . $subfield->getCode() . "\n"; print "Data: " . $subfield->getData() . "\n"; // test __toString implementation print $subfield; print "\n"; // test raw output implementation print $subfield->toRaw() . "\n"; // test isEmpty() if ($subfield->isEmpty()) { print "Subfield is empty\n"; } else { print "Subfield is not empty\n"; } ?> --EXPECT-- Code: a Data: wasssup [a]: wasssup awasssup Subfield is not empty http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/marc_subfield_002.phpt?view=markup&rev=1.1 Index: pear/File_MARC/tests/marc_subfield_002.phpt +++ pear/File_MARC/tests/marc_subfield_002.phpt --TEST-- marc_subfield_002: Exercise setter and isEmpty() methods for File_MARC_Subfield class --FILE-- <?php $dir = dirname(__FILE__); require $dir . '/../' . 'MARC.php'; function testEmpty($testSubfield) { print "Subfield is "; if ($testSubfield->isEmpty()) { print "empty.\n"; } else { print "not empty.\n"; } } $subfield = new File_MARC_Subfield('a', 'wasssup'); // test isEmpty() scenarios testEmpty($subfield); $subfield->setData(null); testEmpty($subfield); $subfield->setData('just hangin'); testEmpty($subfield); // test setCode() scenarios print "\nSet code to 'z'..."; if ($subfield->setCode('z')) { print "\n"; print $subfield; } print "\nSet code to ''..."; if ($subfield->setCode('')) { print "\n"; print $subfield; } print "\nSet code to null..."; if ($subfield->setCode(null)) { print "\n"; print $subfield; } ?> --EXPECT-- Subfield is not empty. Subfield is empty. Subfield is not empty. Set code to 'z'... [z]: just hangin Set code to ''... Set code to null... http://cvs.php.net/viewvc.cgi/pear/File_MARC/tests/music.mrc?view=markup&rev=1.1 Index: pear/File_MARC/tests/music.mrc +++ pear/File_MARC/tests/music.mrc 01145ncm 2200277 i 4500001001000000004000800010005001700018008004100035010001700076035002200093035001200115040000700127050002500134245005700159260003800216300002800254500005100282505026600333650001000599650004400609700004400653700003600697700004600733740002700779852006100806000073594AAJ580220030415102100.0801107s1977 nyujza  a 77771106  a(CaOTUIC)154601849 aAAJ5802 aLC00aM1366b.M62dM1527.204aThe Modern Jazz Quartet :bThe legendary profile. -- aNew York :bM.J.Q. Music,cc1977. ascore (72 p.) ;c31 cm. aFor piano, vibraphone, drums, and double bass.0 aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 0aJazz. 0aMotion picture musicvExcerptsvScores.12aLewis, John,d1920-tSelections.f1977.12aJackson, Mi! lt.tMartyrs.f1977.12aJackson, Milt.tLegendary profile.f1977.4 aThe legendary profile.00bMUSICcMAINkfoliohM1366iM62914Marvin Duchow Music5 01293cjm 2200289 a 450000100100000000500170001000700150002700800410004202400150008302800240009803500200012204000180014210000260016024500620018626000850024830000510033351101380038450000360052251800580055850000590061650000700067550501420074565000210088770000240090871000250093274000460095700187803920050110174900.0sd fungnn|||e|940202r19931981nyujzn i d1 a746457337202aJK 57337bRed Baron a(OCoLC)29737267 aSVPcSVPdLGG1 aDesmond, Paul,d1924-10aPaul Desmond & the Modern Jazz Quarteth[sound recording] aNew York, N.Y. :bRed Baron :bManufactured by Sony Music Entertainment,cp1993. a1 sound disc (39 min.) :bdigital ;c4 3/4 in.0 aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. aAll arrangements by John Lewis. aRecorded live on December 25, 1971 at Town Hall, NYC. aOriginally released in 1981 by Finesse as LP FW 27487. aProgram notes by Irvi! ng Townsend, June 1981, on container insert.0 aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 0aJazzy1971-1980.1 aLewis, John,d1920-2 aModern Jazz Quartet.0 aPaul Desmond and the Modern Jazz Quartet. 01829cjm 2200385 a 450000100100000000500170001000700150002700800410004202400150008302800210009803300240011903300230014303300230016603300230018903500200021204000230023204800270025511000300028224500530031226000330036530000410039844000170043951102230045651802640067950000180094350000220096150502500098365000100123370000240124370000330126770000330130070000220133370000300135585200580138500196448220060626132700.0sd fzngnn|m|e|871211p19871957nyujzn d1 a422833290201a833 290-2bVerve0 a19571027b6299cD560 a196112--b3804cN40 a19571019b4104cC60 a197107--b6299cV7 a(OCoLC)17222092 aCPLcCPLdOCLdLGG apz01aka01asd01apd012 aModern Jazz Quartet.4prf14aThe Modern Jazz Quartet plush[sound recording]. a[New York] :bVerve,cp1987. a1 sound disc :bdigital ;c4 3/4 in. 0aCompact jazz0 aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (! 2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). aCompact disc. aAnalog recording.0 aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 0aJazz.1 aJackson, Milt.4prf1 aPeterson, Oscar,d1925-4prf1 aBrown, Ray,d1926-2002.4prf1 aThigpen, Ed.4prf1 aHayes, Louis,d1937-4prf80bMUSICcAVhCD 11314Marvin Duchow Music5Audio-Visual
« previous php.pear.cvs (#43073) next »