function Record::_build_dir in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 modules/marcParse/php-marc.php \Record::_build_dir()
- 6 marcParse/php-marc.php \Record::_build_dir()
- 7 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 modules/
marcParse/ php-marc.php - Return Raw
File
- modules/
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,
);
}