Isis_Rec Class Reference
List of all members.
Public Member Functions |
| fmt ($val, $fmt=ISIS_REC_MHL) |
| Isis_Rec () |
| len () |
| fdt (&$tag) |
| res () |
| get ($tag) |
| v ($tag=null, $fmt=null) |
| recs ($db=null) |
| h ($tag=null, $fmt= '') |
| mhl ($tag=null) |
| append ($tag, $val) |
| add ($argv) |
| addglobals () |
| pack () |
| rm ($pos, $pack=FALSE) |
| del ($tag=null, $pack=FALSE) |
| set ($tag) |
| embed ($that) |
| toString ($mode=ISIS_REC_TEXT) |
| parse ($text, $repl=null) |
| map ($func=null) |
| fmt ($val, $fmt=ISIS_REC_MHL) |
| Isis_Rec () |
| len () |
| fdt (&$tag) |
| res () |
| get ($tag) |
| v ($tag=null, $fmt=null) |
| h ($tag=null, $fmt= '') |
| mhl ($tag=null) |
| append ($tag, $val) |
| add ($argv) |
| addglobals () |
| pack () |
| rm ($pos, $pack=FALSE) |
| del ($tag=null, $pack=FALSE) |
| set ($tag) |
| embed ($tag, $that) |
| toString ($mode=ISIS_REC_BIN) |
| parse ($text, $repl=null) |
| map ($func=null) |
Public Attributes |
| $db = 0 |
| $mfn = 0 |
| $head = '' |
| $tag |
| $val |
| $v = null |
| $holy = 0 |
Member Function Documentation
add an array to the record.
- Parameters:
-
| mixed | $argv an array either as a single parameter or as a variable number of arguments. The array is processed as follows:
- if an item is an int, it is appended, with the following item as value.
- if an item is an array, add is called recursively on this array
- if an item is '-db' or '-mfn', the corresponding properties are set
- if we have an fdt which maps the item to an int, the following item as value is added with the tag given by the fdt.
- if an item is ISIS_REC_TEXT, the following item is parsed in text mode.
- else the item is parsed in standard mode.
|
add an array to the record.
- Parameters:
-
| mixed | $argv an array either as a single parameter or as a variable number of arguments. The array is processed as follows:
- if an item is an int, it is appended, with the following item as value.
- if an item is an array, add is called recursively on this array
- if an item is '-db' or '-mfn', the corresponding properties are set
- if we have an fdt which maps the item to an int, the following item as value is added with the tag given by the fdt.
- if an item is ISIS_REC_TEXT, the following item is parsed in text mode.
- else the item is parsed in standard mode.
|
Isis_Rec::append |
( |
$ |
tag, |
|
|
$ |
val | |
|
) |
| | |
append a new field (tag-value-pair) to the end of the record.
- Parameters:
-
| int | $tag tag to use in the field. It is not enforced that tag is an integer. |
| string | $val the new fields value. The string type is not enforced here. |
- Returns:
- the new value
Isis_Rec::append |
( |
$ |
tag, |
|
|
$ |
val | |
|
) |
| | |
append a new field (tag-value-pair) to the end of the record.
- Parameters:
-
| int | $tag tag to use in the field. fdt is applied |
| string | $val the new fields value. The string type is not enforced here. |
- Returns:
- the new value
Isis_Rec::del |
( |
$ |
tag = null , |
|
|
$ |
pack = FALSE | |
|
) |
| | |
remove all fields or all with a given tag.
Isis_Rec::del |
( |
$ |
tag = null , |
|
|
$ |
pack = FALSE | |
|
) |
| | |
remove all fields or all with a given tag.
try to look up non-numeric tags in the fdt
try to look up non-numeric tags in the fdt
Isis_Rec::fmt |
( |
$ |
val, |
|
|
$ |
fmt = ISIS_REC_MHL | |
|
) |
| | |
static function to format a value. maybe used as Isis_Rec::fmt.
- Parameters:
-
| string | $val a value to be formatted |
| string | $fmt a format specification, defaults to 'MHL'
- if $fmt is null, the value is returned unchanged
- if $fmt starts with '&' or '', that character is stripped and htmlspecialchars or urlencode, resp., is applied to the (each) value as last step
- if $fmt starts with 'MHL' (the constant ISIS_REC_MHL), that is stripped and the classical MHL ISIS formatting applied to values (before & or % mangling, rarely needed with subfields)
- if $fmt is (now) empty, the complete value is used
- else we're going for subfields:
- if $fmt starts with a hat, the hat is stripped an used as subfield delimiter (TAB otherwise)
- if $fmt matches /^([^(]*)\((*)(\.\.(*))?/, the part from the first '(' on is stripped as occurence selector (note that an optional closing ')' and additional chars are ignored)
- the (remaining) characters in $fmt are subfield names, '*' selects any subfield (including the initial unnamed, even if it's empty !), '' any without stripping subfield names
- if there is a occurence or range selected, for every character in the $fmt the specified occurences are used (counted from 0). If either bound is empty, 0 is used. If a range is specified (.. given), an upper bound of 0 means up to end. By default, only the first occurence (0) is used.
|
- Returns:
- if there is only a single character (remaining) in $fmt, and only a single occurence selectedi (no ..), a string is returned. Else you've been asking for an array, and so an array is returned even if it contains only a single value. If more than one subfield name was specified or the '*', the names are used ('' for the initial). If a range is selected, the index is used (in addition). Fields are added by first looping over subfield names, then occurences. PHP may or may not loop the array in that order. Example: '^ab' gives keys 'a' and 'b', 'b(1..' gives keys '1','2'...m '^cab(..', gives 'c0', 'c1', ... 'a0', ...
Isis_Rec::fmt |
( |
$ |
val, |
|
|
$ |
fmt = ISIS_REC_MHL | |
|
) |
| | |
static function to format a value. maybe used as Isis_Rec::fmt.
- Parameters:
-
| string | $val a value to be formatted |
| string | $fmt a format specification, defaults to 'MHL'
- if $fmt is null, the value is returned unchanged
- if $fmt starts with '&' or '', that character is stripped and htmlspecialchars or urlencode, resp., is applied to the (each) value as last step
- if $fmt starts with 'MHL' (the constant ISIS_REC_MHL), that is stripped and the classical MHL ISIS formatting applied to values (before & or % mangling, rarely needed with subfields)
- if $fmt is (now) empty, the complete value is used
- else we're going for subfields:
- if $fmt starts with a hat, the hat is stripped an used as subfield delimiter (TAB otherwise)
- if $fmt matches /^([^(]*)\((*)(\.\.(*))?/, the part from the first '(' on is stripped as occurence selector (note that an optional closing ')' and additional chars are ignored)
- the (remaining) characters in $fmt are subfield names, '*' selects any subfield (including the initial unnamed, even if it's empty !), '' any without stripping subfield names
- if there is a occurence or range selected, for every character in the $fmt the specified occurences are used (counted from 0). If either bound is empty, 0 is used. If a range is specified (.. given), an upper bound of 0 means up to end. By default, only the first occurence (0) is used.
|
- Returns:
- if there is only a single character (remaining) in $fmt, and only a single occurence selectedi (no ..), a string is returned. Else you've been asking for an array, and so an array is returned even if it contains only a single value. If more than one subfield name was specified or the '*', the names are used ('' for the initial). If a range is selected, the index is used (in addition). Fields are added by first looping over subfield names, then occurences. PHP may or may not loop the array in that order. Example: '^ab' gives keys 'a' and 'b', 'b(1..' gives keys '1','2'...m '^cab(..', gives 'c0', 'c1', ... 'a0', ...
get all values for tag as array
get all values for tag as array
Isis_Rec::h |
( |
$ |
tag = null , |
|
|
$ |
fmt = '' | |
|
) |
| | |
Isis_Rec::h |
( |
$ |
tag = null , |
|
|
$ |
fmt = '' | |
|
) |
| | |
create an ISIS record.
- Returns:
- object Isis_Rec a new ISIS record
create an ISIS record.
- Returns:
- object Isis_Rec a new ISIS record
- Returns:
- the number of fields
- Returns:
- the number of fields
Isis_Rec::map |
( |
$ |
func = null |
) |
|
return the "data fork" of this record by mapping a function to tags and values in parallel.
- Parameters:
-
| function | $func defaults to null, resulting in an array of fields, each an array [0] => $tag, [1] => $val. |
- Returns:
- a new array as of array_map
Isis_Rec::map |
( |
$ |
func = null |
) |
|
return the "data fork" of this record by mapping a function to tags and values in parallel.
- Parameters:
-
| function | $func defaults to null, resulting in an array of fields, each an array [0] => $tag, [1] => $val. |
- Returns:
- a new array as of array_map
Isis_Rec::mhl |
( |
$ |
tag = null |
) |
|
Isis_Rec::mhl |
( |
$ |
tag = null |
) |
|
recompact after unsetting
recompact after unsetting
Isis_Rec::parse |
( |
$ |
text, |
|
|
$ |
repl = null | |
|
) |
| | |
parse text as record fields to add. For each non-empty line, initial digits are used as tag (empty == 0), an optional following tab is skipped, and the rest used as value, after replacing $repl, if given, with newlines. If the line starts with a tab and the record is not empty, a newline and the value are appended to the last field, else a new field is appended to the record.
- Parameters:
-
| string | $repl string to be converted back to newlines. use ISIS_REC_TEXT, if you know text is from toString(ISIS_REC_TEXT) |
- Returns:
- number of fields added
Isis_Rec::parse |
( |
$ |
text, |
|
|
$ |
repl = null | |
|
) |
| | |
parse text as record fields to add. For each non-empty line, initial digits are used as tag (empty == 0), an optional following tab is skipped, and the rest used as value, after replacing $repl, if given, with newlines. If the line starts with a tab and the record is not empty, a newline and the value are appended to the last field, else a new field is appended to the record.
- Parameters:
-
| string | $repl string to be converted back to newlines. use ISIS_REC_TEXT, if you know text is from toString(ISIS_REC_TEXT) |
- Returns:
- number of fields added
Isis_Rec::recs |
( |
$ |
db = null |
) |
|
return an array of subrecords
reset tag and val array pointers
reset tag and val array pointers
Isis_Rec::rm |
( |
$ |
pos, |
|
|
$ |
pack = FALSE | |
|
) |
| | |
remove a field at given pos, poking a hole in the field list.
Isis_Rec::rm |
( |
$ |
pos, |
|
|
$ |
pack = FALSE | |
|
) |
| | |
remove a field at given pos, poking a hole in the field list.
set fields with tag to values. set( 42, 'foo', 'bar', 'baz' ) will change the first three occurences of 42 to 'foo', 'bar' and 'baz', resp.
- if there are less than three occurences, the remaining values are appended
- if there are more than three occurences, the remaining occurences are deleted
- if a value is the integer 0, processing stops (i.e. remaining occurences are left unchanged)
- if a value is a positive integer n, processing skips n occurences (letting them unchanged)
- if a value is an array, it's elements are used (it is flattened out non-recursively)
- Parameters:
-
| mixed | $tag tag by int or name |
| mixed | values... variable number of values |
set fields with tag to values. set( 42, 'foo', 'bar', 'baz' ) will change the first three occurences of 42 to 'foo', 'bar' and 'baz', resp.
- if there are less than three occurences, the remaining values are appended
- if there are more than three occurences, the remaining occurences are deleted
- if a value is the integer 0, processing stops (i.e. remaining occurences are left unchanged)
- if a value is a positive integer n, processing skips n occurences (letting them unchanged)
- if a value is an array, it's elements are used (it is flattened out non-recursively)
- Parameters:
-
| mixed | $tag tag by int or name |
| mixed | values... variable number of values |
Isis_Rec::toString |
( |
$ |
mode = ISIS_REC_BIN |
) |
|
serialize record to a string. After each field, including the last one, a newline is added.
- Parameters:
-
| string | $mode replacement value for newlines. suggested is one of the predefined constants. defaults to ISIS_REC_BIN. |
- Returns:
- the string representation of the record
Isis_Rec::toString |
( |
$ |
mode = ISIS_REC_TEXT |
) |
|
serialize record to a string. After each field, including the last one, a newline is added.
- Parameters:
-
| string | $mode replacement value for newlines. suggested is one of the predefined constants. defaults to ISIS_REC_TEXT. |
- Returns:
- the string representation of the record
Isis_Rec::v |
( |
$ |
tag = null , |
|
|
$ |
fmt = null | |
|
) |
| | |
v is for value -- get the value of the next occurence of tag in the record. The position is reset by res or when using v with a different tag.
- Parameters:
-
| mixed | $fmt format to apply
- if $fmt is null (or the value is null), the value is returned unmodified
- if $fmt is a string, the value is formatted by Isis_Rec::fmt (returns string or array).
- if $fmt is 0, a new Isis_Rec is used as $fmt
- if $fmt is an object, it is assumed to be a record, into which a subrecord (as of embed) is to be extracted. This also advances the loop position to after the child fields. The record is returned.
- other values of $fmt are reserved for future extensions and currently return null.
|
Isis_Rec::v |
( |
$ |
tag = null , |
|
|
$ |
fmt = null | |
|
) |
| | |
v is for value -- get the value of the next occurence of tag in the record. The position is reset by res or when using v with a different tag.
- Parameters:
-
| mixed | $fmt format to apply
- if $fmt is null (or the value is null), the value is returned unmodified
- if $fmt is a string, the value is formatted by Isis_Rec::fmt (returns string or array).
- other values of $fmt are reserved for future extensions and currently return null.
|
Member Data Documentation
The associated database, if any. Better be an Isis_Db.
The record's header. For data records, this is mfn[][], where leader can any be any MARC leader data.
number of holes in record
The record's MFN ("master file number", a.k.a. rowid). A value of 0 means the record did not yet have a number in it's db, a write will be handled as insert.
The records MFN ("master file number", a.k.a. rowid). A value of 0 means the record did not yet have a number in it's db, a write will be handled as insert.
Array of tags for the record. Keys and values better be integers (others might be ignored or yield unexpected results in some contexts). The count of the tag array is taken as length of the record. The tag array may have holes (unassigned ints) if unset is used.
Array of values for the record. Values better be strings (i.e. will be forced to strings by some operations).
last tag accessed using function v
The documentation for this class was generated from the following files:
- contrib/malete/php/Isis/Rec.php
- contrib/openisis/php/Isis/Rec.php