You are here

function Record::_build_dir in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 modules/marcParse/php-marc.php \Record::_build_dir()
  2. 7 modules/marcParse/php-marc.php \Record::_build_dir()
  3. 7.2 modules/marcParse/php-marc.php \Record::_build_dir()

* Build Record Directory * * Generate the directory of the Record according to existing data. *

Return value

array Array ( $fields, $directory, $total, $baseaddress )

1 call to Record::_build_dir()
Record::raw in marcParse/php-marc.php
* Return Raw * * Return the Record in raw MARC format. *

File

marcParse/php-marc.php, line 473

Class

Record
Record Class Create a MARC Record class

Code

function _build_dir() {

  // Vars
  $fields = array();
  $directory = array();
  $dataend = 0;
  foreach ($this->fields as $field_group) {
    foreach ($field_group as $field) {

      // Get data in raw format
      $str = $field
        ->raw();
      $fields[] = $str;

      // Create directory entry
      $len = strlen($str);
      $direntry = sprintf("%03s%04d%05d", $field
        ->tagno(), $len, $dataend);
      $directory[] = $direntry;
      $dataend += $len;
    }
  }

  /**
   * Rules from MARC::Record::USMARC
   */
  $baseaddress = LEADER_LEN + count($directory) * DIRECTORY_ENTRY_LEN + 1;

  // end-of-field marker
  $total = $baseaddress + $dataend + 1;

  // End-of-record marker
  return array(
    $fields,
    $directory,
    $total,
    $baseaddress,
  );
}