Grima  2018-08
Whispering into Alma's ear
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Bib Class Reference
Inheritance diagram for Bib:
AlmaObjectWithMARC AlmaObject

Public Member Functions

 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 loadFromAlma ($mms_id)
 populates the bib with a record from Alma More...
 
 addToAlma ()
 adds record as a new record to Alma, updates Bib with current Alma version More...
 
 updateAlma ()
 replaces the Bib in Alma More...
 
 deleteFromAlma ()
 deletes the Bib from Alma More...
 
 deleteTreeFromAlma ()
 deletes the Bib and its inventory #XXX More...
 
 hasInventory ()
 populate holdings property with Holdings items More...
 
 linkedToCZ ()
 is the bib linked to the community zone? More...
 
 unlinkFromCZ ()
 does this work : Not supported for CZ More...
 
 getHoldings ()
 populate holdings property with Holdings items More...
 
 deleteAllPortfolios ()
 delete all portfolios from the bib More...
 
 getHoldingsList ()
 populate holdingsList property with info from Alma More...
 
 getPortfolioList ()
 populate portfolioList property with info from Alma More...
 
 get_title_proper ()
 a tidy title proper More...
 
 getLCCallNumber ()
 get LC call number, giving pref to 090 and later fields More...
 
- Public Member Functions inherited from AlmaObjectWithMARC
 appendField ($tag, $ind1, $ind2, $subfields)
 add a field to the MARC record More...
 
 getFields ($tag)
 get fields for the given MARC tag More...
 
 getSubfieldValues ($tag, $code)
 get subfield value More...
 
 deleteField ($tag)
 delete all $tag fields from the MARC record More...
 
 deleteSubfieldMatching ($tag, $code, $regex)
 delete subfields matching a regex More...
 
 replaceOrAddSubfield ($tag, $code, $value)
 replace or add subfield value in marc More...
 
- Public Member Functions inherited from AlmaObject
 __construct ()
 create new blank Alma Object More...
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 

Public Attributes

 $holdingsList
 
 $holdings = array()
 
 $portfolioList = array()
 
- Public Attributes inherited from AlmaObject
 $el_access = array()
 
 $xml
 
 $templateDir = __DIR__ . "/templates"
 

Protected Attributes

 $el_address
 

Detailed Description

Definition at line 1788 of file grima-lib.php.

Member Function Documentation

◆ addToAlma()

Bib::addToAlma ( )

adds record as a new record to Alma, updates Bib with current Alma version

Definition at line 1861 of file grima-lib.php.

References $grima.

1861  {
1862  global $grima;
1863  $this->xml = $grima->postBib($this->xml);
1864  }
$grima
Definition: grima-lib.php:1166

◆ deleteAllPortfolios()

Bib::deleteAllPortfolios ( )

delete all portfolios from the bib

Definition at line 1966 of file grima-lib.php.

References $grima, and getPortfolioList().

Referenced by deleteTreeFromAlma().

1966  {
1967  global $grima;
1968  while ($this->getPortfolioList()) {
1969  foreach($this->portfolioList as $portfolio) {
1970  $portfolio->deleteFromAlma();
1971  }
1972  $this->portfolioList = array();
1973  sleep(2);
1974  }
1975  }
$grima
Definition: grima-lib.php:1166
getPortfolioList()
populate portfolioList property with info from Alma
Definition: grima-lib.php:1991

◆ deleteFromAlma()

Bib::deleteFromAlma ( )

deletes the Bib from Alma

Definition at line 1881 of file grima-lib.php.

References $grima.

1881  {
1882  global $grima;
1883  $grima->deleteBib($this['mms_id']);
1884  }
$grima
Definition: grima-lib.php:1166

◆ deleteTreeFromAlma()

Bib::deleteTreeFromAlma ( )

deletes the Bib and its inventory #XXX

Definition at line 1891 of file grima-lib.php.

References $grima, deleteAllPortfolios(), and getHoldings().

1891  {
1892  global $grima;
1893  $this->getHoldings();
1894  foreach ($this->holdings as $holding) {
1895  $holding->deleteTreeFromAlma(); #XXX
1896  }
1897  $this->deleteAllPortfolios($this['mms_id']); #XXX
1898  $grima->deleteBib($this['mms_id']);
1899  }
deleteAllPortfolios()
delete all portfolios from the bib
Definition: grima-lib.php:1966
getHoldings()
populate holdings property with Holdings items
Definition: grima-lib.php:1951
$grima
Definition: grima-lib.php:1166

◆ get_title_proper()

Bib::get_title_proper ( )

a tidy title proper

Returns
string 245$a with ISBD punctuation removed

Definition at line 2020 of file grima-lib.php.

2020  {
2021  $xpath = new DomXpath($this->xml);
2022  $title = $xpath->query("//record/datafield[@tag='245']/subfield[@code='a']");
2023  return preg_replace("/[ \/=:,;\.]*$/","",$title[0]->nodeValue);
2024  }

◆ getHoldings()

Bib::getHoldings ( )

populate holdings property with Holdings items

Definition at line 1951 of file grima-lib.php.

References getHoldingsList().

Referenced by deleteTreeFromAlma().

1951  {
1952  $this->getHoldingsList();
1953  foreach ($this->holdingsList->entries as $entry) {
1954  $holding = new Holding();
1955  $holding->loadFromAlma($this['mms_id'],$entry['holding_id']);
1956  $holding['mms_id'] = $this['mms_id'];
1957  $this->holdings[] = $holding;
1958  }
1959  }
class Holding
Definition: grima-lib.php:2176
getHoldingsList()
populate holdingsList property with info from Alma
Definition: grima-lib.php:1982

◆ getHoldingsList()

Bib::getHoldingsList ( )

populate holdingsList property with info from Alma

Definition at line 1982 of file grima-lib.php.

Referenced by getHoldings(), and hasInventory().

1982  {
1983  $this->holdingsList = new HoldingsList($this['mms_id']);
1984  }
class HoldingsList
Definition: grima-lib.php:2072

◆ getLCCallNumber()

Bib::getLCCallNumber ( )

get LC call number, giving pref to 090 and later fields

Returns
Array(class,item) for two parts of call number

Definition at line 2045 of file grima-lib.php.

2045  {
2046  $xpath = new DomXPath($this->xml);
2047  $calls = array();
2048  foreach (array('050','090') as $tag) {
2049  foreach ($xpath->query("//datafield[@tag='$tag']") as $call) {
2050  $calls[] = $call;
2051  }
2052  }
2053  $ret = array();
2054 
2055  foreach ($calls as $node) {
2056  $classs = $xpath->query("subfield[@code='a']",$node);
2057  $items = $xpath->query("subfield[@code='b']",$node);
2058  if ((count($classs) > 0) and (count($items) > 0)) {
2059  $ret = array($classs[0]->nodeValue,$items[0]->nodeValue);
2060  }
2061  }
2062  return $ret;
2063  }

◆ getPortfolioList()

Bib::getPortfolioList ( )

populate portfolioList property with info from Alma

Definition at line 1991 of file grima-lib.php.

References $grima.

Referenced by deleteAllPortfolios(), and hasInventory().

1991  { # maybe rename
1992  global $grima;
1993  $limit = 10; $offset = 0; # where to allow passing
1994  $ret = $grima->getElectronicPortfoliosForBib($this['mms_id'],$limit,$offset);
1995  $xpath = new DOMXpath($ret);
1996  $ports = $xpath->query('//portfolio');
1997  foreach ($ports as $portnode) {
1998  $newport = new ElectronicPortfolio();
1999  $newport->loadFromPortfolioListNode($portnode);
2000  $this->portfolioList[] = $newport;
2001  }
2002  return count($ports);
2003  }
class ElectronicPortfolio
Definition: grima-lib.php:2788
$grima
Definition: grima-lib.php:1166

◆ hasInventory()

Bib::hasInventory ( )

populate holdings property with Holdings items

Definition at line 1906 of file grima-lib.php.

References getHoldingsList(), and getPortfolioList().

1906  {
1907  $this->getHoldingsList();
1908  if (count($this->holdingsList->entries) > 0) {
1909  return true;
1910  }
1911  $this->getPortfolioList();
1912  if (count($this->portfolioList) > 0) {
1913  print_r($this->portfolioList);
1914  return true;
1915  } else {
1916  return false;
1917  }
1918  }
getHoldingsList()
populate holdingsList property with info from Alma
Definition: grima-lib.php:1982
getPortfolioList()
populate portfolioList property with info from Alma
Definition: grima-lib.php:1991

◆ linkedToCZ()

Bib::linkedToCZ ( )

is the bib linked to the community zone?

Definition at line 1925 of file grima-lib.php.

1925  {
1926  $xpath = new DomXPath($this->xml);
1927  $nodes = $xpath->query("//linked_record_id[@type='CZ']");
1928  return (count($nodes) > 0);
1929  }

◆ loadFromAlma()

Bib::loadFromAlma (   $mms_id)

populates the bib with a record from Alma

Parameters
string$mms_idMMS ID of record to load from Alma

Definition at line 1850 of file grima-lib.php.

References $grima.

1850  {
1851  global $grima;
1852  $this->xml = $grima->getBib($mms_id);
1853  }
$grima
Definition: grima-lib.php:1166

◆ offsetGet()

Bib::offsetGet (   $offset)

Definition at line 1807 of file grima-lib.php.

1807  {
1808  if ($offset == 'Type') {
1809  $leader = $this['leader'];
1810  return $leader[6];
1811  }
1812  if ($offset == 'BLvl') {
1813  $leader = $this['leader'];
1814  return $leader[7];
1815  }
1816  if ($offset == 'ELvl') {
1817  $leader = $this['leader'];
1818  return $leader[17];
1819  }
1820  if ($offset == 'Desc') {
1821  $leader = $this['leader'];
1822  return $leader[18];
1823  }
1824  return parent::offsetGet($offset);
1825  }

◆ offsetSet()

Bib::offsetSet (   $offset,
  $value 
)

Definition at line 1828 of file grima-lib.php.

References AlmaObjectWithMARC\replaceOrAddSubfield().

1828  {
1829  parent::offsetSet($offset,$value);
1830  if ($offset == 'author') {
1831  $this->replaceOrAddSubfield('100','a',$value);
1832  }
1833  if ($offset == 'title') {
1834  $this->replaceOrAddSubfield('245','a',$value);
1835  }
1836  if (($offset == 'publisher_const') or ($offset == 'publisher')) {
1837  $this->replaceOrAddSubfield('264','b',$value);
1838  }
1839  if ($offset == 'place_of_publication') {
1840  $this->replaceOrAddSubfield('264','a',$value);
1841  }
1842  }
replaceOrAddSubfield($tag, $code, $value)
replace or add subfield value in marc
Definition: grima-lib.php:1736

◆ unlinkFromCZ()

Bib::unlinkFromCZ ( )

does this work : Not supported for CZ

Definition at line 1937 of file grima-lib.php.

References updateAlma().

1937  {
1938  $xpath = new DomXPath($this->xml);
1939  $nodes = $xpath->query("//linked_record_id[@type='CZ']");
1940  foreach ($nodes as $node) {
1941  $node->parentNode->removeChild($node);
1942  }
1943  $this->updateAlma();
1944  }
updateAlma()
replaces the Bib in Alma
Definition: grima-lib.php:1871

◆ updateAlma()

Bib::updateAlma ( )

replaces the Bib in Alma

Definition at line 1871 of file grima-lib.php.

References $grima.

Referenced by unlinkFromCZ().

1871  {
1872  global $grima;
1873  $this->xml = $grima->putBib($this['mms_id'],$this->xml);
1874  }
$grima
Definition: grima-lib.php:1166

Member Data Documentation

◆ $el_address

Bib::$el_address
protected
Initial value:
= array(
'mms_id' => '//mms_id',
'leader' => '//leader',
'record_format' => '//record_format',
'title' => '//title',
'author' => '//author',
'place_of_publication' => '//place_of_publication',
'publisher_const' => '//publisher_const',
'publisher' => '//publisher_const'
)

Definition at line 1796 of file grima-lib.php.

◆ $holdings

Bib::$holdings = array()

Definition at line 1790 of file grima-lib.php.

◆ $holdingsList

Bib::$holdingsList

Definition at line 1789 of file grima-lib.php.

◆ $portfolioList

Bib::$portfolioList = array()

Definition at line 1792 of file grima-lib.php.


The documentation for this class was generated from the following file: