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 brief info from Alma More...
 
  getPortfolios ()
  get full portfolios for the bib More...
 
  getItems ()
  populate items property with Items objects ## XXX TEST More...
 
  getItemList ()
  populates itemList property 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
  useNormac ()
 
  addControlField ($tag, $data)
  add a data field to the MARC record using Normac More...
 
  addDataField ($tag, $indicators, $subfields)
  add a data field to the MARC record using Normac More...
 
  normacToXML ()
  convert normac fields back to XML More...
 
  appendField ($tag, $ind1, $ind2, $subfields)
  add a field to the MARC record More...
 
  getFields ($tag)
  get fields for the given MARC tag More...
 
  getMarcFields ($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()
 
  $itemList
 
  $items = array()
 
  $portfolioList = array()
 
- Public Attributes inherited from AlmaObjectWithMARC
  $marc
 
- Public Attributes inherited from AlmaObject
  $el_access = array()
 
  $xml
 
  $templateDir = __DIR__ . "/templates"
 

Protected Attributes

  $el_address
 

Detailed Description

Definition at line 2159 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 2236 of file grima-lib.php.

References $grima.

2236  {
2237  global $grima;
2238  $this->xml = $grima->postBib($this->xml);
2239  }
$grima
Definition: grima-lib.php:4293

◆ deleteAllPortfolios()

Bib::deleteAllPortfolios ( )

delete all portfolios from the bib

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

References $grima.

2344  {
2345  global $grima;
2346  while ($this->getPortfolioList()) {
2347  foreach($this->portfolioList as $portfolio) {
2348  error_log("deleting " . $portfolio['pid'] . "\n");
2349  $portfolio->deleteFromAlma();
2350  }
2351  $this->portfolioList = array();
2352  sleep(3);
2353  }
2354  }
$grima
Definition: grima-lib.php:4293
getPortfolioList()
populate portfolioList property with brief info from Alma
Definition: grima-lib.php:2370

◆ deleteFromAlma()

Bib::deleteFromAlma ( )

deletes the Bib from Alma

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

References $grima.

2258  {
2259  global $grima;
2260  $grima->deleteBib($this['mms_id']);
2261  }
$grima
Definition: grima-lib.php:4293

◆ deleteTreeFromAlma()

Bib::deleteTreeFromAlma ( )

deletes the Bib and its inventory #XXX

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

References $grima.

2268  {
2269  global $grima;
2270  $this->getHoldings();
2271  foreach ($this->holdings as $holding) {
2272  $holding->deleteTreeFromAlma(); #XXX
2273  }
2274  $this->deleteAllPortfolios($this['mms_id']); #XXX
2275  $grima->deleteBib($this['mms_id']);
2276  }
deleteAllPortfolios()
delete all portfolios from the bib
Definition: grima-lib.php:2344
getHoldings()
populate holdings property with Holdings items
Definition: grima-lib.php:2328
$grima
Definition: grima-lib.php:4293

◆ get_title_proper()

Bib::get_title_proper ( )

a tidy title proper

Returns
string 245$a with ISBD punctuation removed

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

2423  {
2424  $xpath = new DomXpath($this->xml);
2425  $title = $xpath->query("//record/datafield[@tag='245']/subfield[@code='a']");
2426  return preg_replace("/[ \/=:,;\.]*$/","",$title[0]->nodeValue);
2427  }

◆ getHoldings()

Bib::getHoldings ( )

populate holdings property with Holdings items

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

References Grima\getHoldingsList().

2328  {
2329  $this->getHoldingsList();
2330  foreach ($this->holdingsList->entries as $entry) {
2331  $holding = new Holding();
2332  $holding->loadFromAlma($this['mms_id'],$entry['holding_id']);
2333  $holding['mms_id'] = $this['mms_id'];
2334  $this->holdings[] = $holding;
2335  }
2336  return $this->holdings;
2337  }
$holdings
Definition: grima-lib.php:2161
class Holding
Definition: grima-lib.php:2579
getHoldingsList()
populate holdingsList property with info from Alma
Definition: grima-lib.php:2361

◆ getHoldingsList()

Bib::getHoldingsList ( )

populate holdingsList property with info from Alma

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

2361  {
2362  $this->holdingsList = new HoldingsList($this['mms_id']);
2363  }
class HoldingsList
Definition: grima-lib.php:2475

◆ getItemList()

Bib::getItemList ( )

populates itemList property from Alma

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

References $grima.

2413  { # XXX
2414  global $grima;
2415  $this->itemList = new ItemList($this['mms_id'],'ALL');
2416  }
$grima
Definition: grima-lib.php:4293
class ItemList
Definition: grima-lib.php:2537

◆ getItems()

Bib::getItems ( )

populate items property with Items objects ## XXX TEST

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

References Grima\getItemList().

2402  {
2403  $this->getItemList();
2404  $this->items =& $this->itemList->items;
2405  return $this->items;
2406  }
$items
Definition: grima-lib.php:2164
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:2413

◆ 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 2448 of file grima-lib.php.

2448  {
2449  $xpath = new DomXPath($this->xml);
2450  $calls = array();
2451  foreach (array('050','090') as $tag) {
2452  foreach ($xpath->query("//datafield[@tag='$tag']") as $call) {
2453  $calls[] = $call;
2454  }
2455  }
2456  $ret = array();
2457 
2458  foreach ($calls as $node) {
2459  $classs = $xpath->query("subfield[@code='a']",$node);
2460  $items = $xpath->query("subfield[@code='b']",$node);
2461  if ((count($classs) > 0) and (count($items) > 0)) {
2462  $ret = array($classs[0]->nodeValue,$items[0]->nodeValue);
2463  }
2464  }
2465  return $ret;
2466  }
$items
Definition: grima-lib.php:2164

◆ getPortfolioList()

Bib::getPortfolioList ( )

populate portfolioList property with brief info from Alma

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

References $grima.

2370  { # maybe rename
2371  global $grima;
2372  $limit = 10; $offset = 0; # where to allow passing
2373  $ret = $grima->getElectronicPortfoliosForBib($this['mms_id'],$limit,$offset);
2374  $xpath = new DOMXpath($ret);
2375  $ports = $xpath->query('//portfolio');
2376  foreach ($ports as $portnode) {
2377  $newport = new ElectronicPortfolio();
2378  $newport->loadFromPortfolioListNode($portnode);
2379  $this->portfolioList[] = $newport;
2380  }
2381  return count($ports); # XXX is this the right thing to return?
2382  }
class ElectronicPortfolio
Definition: grima-lib.php:3248
$grima
Definition: grima-lib.php:4293

◆ getPortfolios()

Bib::getPortfolios ( )

get full portfolios for the bib

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

2389  {
2390  $this->getPortfolioList();
2391  foreach($this->portfolioList as $port) {
2392  $port->loadFromAlma($port['portfolio_id']);
2393  }
2394  return $this->portfolioList;
2395  }
getPortfolioList()
populate portfolioList property with brief info from Alma
Definition: grima-lib.php:2370
$portfolioList
Definition: grima-lib.php:2166

◆ hasInventory()

Bib::hasInventory ( )

populate holdings property with Holdings items

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

References Grima\getHoldingsList().

2283  {
2284  $this->getHoldingsList();
2285  if (count($this->holdingsList->entries) > 0) {
2286  return true;
2287  }
2288  $this->getPortfolioList();
2289  if (count($this->portfolioList) > 0) {
2290  print_r($this->portfolioList);
2291  return true;
2292  } else {
2293  return false;
2294  }
2295  }
getHoldingsList()
populate holdingsList property with info from Alma
Definition: grima-lib.php:2361
getPortfolioList()
populate portfolioList property with brief info from Alma
Definition: grima-lib.php:2370

◆ linkedToCZ()

Bib::linkedToCZ ( )

is the bib linked to the community zone?

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

2302  {
2303  $xpath = new DomXPath($this->xml);
2304  $nodes = $xpath->query("//linked_record_id[@type='CZ']");
2305  return (count($nodes) > 0);
2306  }

◆ loadFromAlma()

Bib::loadFromAlma (   $mms_id )

populates the bib with a record from Alma

Parameters
string $mms_id MMS ID of record to load from Alma

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

References $grima.

2225  {
2226  global $grima;
2227  $this->xml = $grima->getBib($mms_id);
2228  }
$grima
Definition: grima-lib.php:4293

◆ offsetGet()

Bib::offsetGet (   $offset )

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

2182  {
2183  if ($offset == 'Type') {
2184  $leader = $this['leader'];
2185  return $leader[6];
2186  }
2187  if ($offset == 'BLvl') {
2188  $leader = $this['leader'];
2189  return $leader[7];
2190  }
2191  if ($offset == 'ELvl') {
2192  $leader = $this['leader'];
2193  return $leader[17];
2194  }
2195  if ($offset == 'Desc') {
2196  $leader = $this['leader'];
2197  return $leader[18];
2198  }
2199  return parent::offsetGet($offset);
2200  }

◆ offsetSet()

Bib::offsetSet (   $offset,
  $value 
)

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

2203  {
2204  parent::offsetSet($offset,$value);
2205  if ($offset == 'author') {
2206  $this->replaceOrAddSubfield('100','a',$value);
2207  }
2208  if ($offset == 'title') {
2209  $this->replaceOrAddSubfield('245','a',$value);
2210  }
2211  if (($offset == 'publisher_const') or ($offset == 'publisher')) {
2212  $this->replaceOrAddSubfield('264','b',$value);
2213  }
2214  if ($offset == 'place_of_publication') {
2215  $this->replaceOrAddSubfield('264','a',$value);
2216  }
2217  }
replaceOrAddSubfield($tag, $code, $value)
replace or add subfield value in marc
Definition: grima-lib.php:2124

◆ unlinkFromCZ()

Bib::unlinkFromCZ ( )

does this work : Not supported for CZ

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

2314  {
2315  $xpath = new DomXPath($this->xml);
2316  $nodes = $xpath->query("//linked_record_id[@type='CZ']");
2317  foreach ($nodes as $node) {
2318  $node->parentNode->removeChild($node);
2319  }
2320  $this->updateAlma();
2321  }
updateAlma()
replaces the Bib in Alma
Definition: grima-lib.php:2246

◆ updateAlma()

Bib::updateAlma ( )

replaces the Bib in Alma

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

References $grima.

2246  {
2247  global $grima;
2248  # XXX parent here?
2249  $this->normacToXML();
2250  $this->xml = $grima->putBib($this['mms_id'],$this->xml);
2251  }
$grima
Definition: grima-lib.php:4293
normacToXML()
convert normac fields back to XML
Definition: grima-lib.php:1985

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',
'suppress_from_publishing' => '//suppress_from_publishing',
)

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

◆ $holdings

Bib::$holdings = array()

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

◆ $holdingsList

Bib::$holdingsList

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

◆ $itemList

Bib::$itemList

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

◆ $items

Bib::$items = array()

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

◆ $portfolioList

Bib::$portfolioList = array()

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


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