Select Git revision
class.PublicationB.php 4.73 KiB
<?php
#räksmörgås
class PublicationB {
public static $logRoot = '/home/WWW/documents_by_mail/logs/maillogs';
private static $elements =
array(
'artkey','arttype','abstract','address','booktitle','keywords',
'journal','title','volume','number','pages','note','html',
'month', 'year','published', 'publisher','LUPid','LUPdate', 'LUPkey');
private static $dbFields = array('artkey','arttype', 'authorsAreEditors',
'title', 'bibtexTitle', 'booktitle','year',
'month', 'shortMonth', 'number','series','school','institution',
'publisher','address','journal','volume','pages',
'project','note', 'keywords', 'abstract','html','fulltextURL',
'popsciLink','isrn', 'mailURL','published', 'advisor',
'examiner', 'LUPdate', 'LUPid');
private static $monthNames = array(
'jan'=>'January', 'feb'=>'February', 'mar'=>'March', 'apr'=>'April',
'may'=>'May', 'jun'=>'June', 'jul'=>'July', 'aug'=>'August',
'sep'=>'September', 'oct'=>'October', 'nov'=>'November', 'dec'=>'December'
);
public function __construct($module = null) {
foreach (self::$dbFields as $field) {
$this->$field = '';
}
$this->module = $module;
}
public $year = 0;
public $authorArray = array();
public $authorNames = array();
public $editorArray = array();
public $editorNames = array();
public $fullTexts = array();
public function putValue($name,$val) {
if (in_array($name,self::$dbFields) || $name == 'LUPkey'
|| $name == 'mailURL'
|| $name =='accessRestriction') {
$this->$name = $val;
return;
} else if ( $name =='fullText' ) {
$this->fullTexts[] = $val;
return;
}
die('Bad variable ' . $name . PHP_EOL);
}
public function putAuthorEditor($last, $first, $role) {
// $role must be 'author' or 'editor'.
switch ($role) {
case 'author': $this->authorNames[] = array($first,$last); break;
case 'editor': $this->editorNames[] = array($first,$last); break;
default: die('Error in putAuthorEditor.');
}
}
public function putJournal($name) {
$this->Journal = $name;
$this->JCB = $name;
}
public function putConference($name) {
$this->Conference = $name;
$this->JCB = $name;
}
public function putArttype() {
$module = $this->module;
if (array_key_exists($this->arttype,$module::$publicationTypeShort)) {
$this->arttypeShort = $module::$publicationTypeShort[$this->arttype];
} else $this->arttypeShort = 'Misc';
$pt = array_flip($module::$publicationTypes);
if (array_key_exists($this->arttype,$pt)) {
$this->arttypeLong = $pt[$this->arttype];
} else { $this->arttypeLong = $this->arttype; }
}
public function putAuthors() {
$auth = array(); $eds = array();
foreach ($this->authorNames as $au) $auth[] = join(' ',$au);
$this->authors = join(', ',$auth);
if (count($auth) > 2) $this->authorsShort = $auth[0] . ' et al';
else $this->authorsShort = $this->authors;
foreach ($this->editorNames as $au) $eds[] = join(' ',$au);
$this->editors = join(', ',$eds);
if (count($eds) > 2) $this->editorsShort = $eds[0] . ' et al';
else $this->editorsShort = $this->editors;
switch (count($this->editorNames)) {
case 0:
unset($this->editors);
break;
case 1:
$this->editors .= ' (Ed.)';
$this->editorsShort .= ' (Ed.)';
break;
default:
$this->editors .= ' (Eds.)';
$this->editorsShort .= ' (Eds.)';
}
if (count($this->authorNames) == 0) {
$this->authors = $this->editors;
$this->authorsShort = $this->editorsShort;
unset($this->editors);
}
}
function putMembers($link) {
foreach (self::$dbFields as $field) {
if ($this->$field == '') unset($this->$field);
}
if (isset($this->published)) {
if ($this->published == 'published') unset($this->published);
}
if (isset($this->isrn)) $this->isrn_bib =
str_replace('--','-{\hskip0.1em}-',$this->isrn);
if ($this->arttype == 'msc') {
$this->LUPlink = sprintf('<a href="https://lup.lub.lu.se/student-papers/search/publication/%s">Record in LUP</a>',$this->LUPid);
} else {
$this->LUPlink =
sprintf('<a href="http://lup.lub.lu.se/record/%s">Record in LUP</a>',
$this->LUPid);
}
$this->link = $link;
if (isset($this->month)) $this->shortMonth =
array_flip(self::$monthNames)[$this->month];
$this->putAuthors();
$this->putArttype();
}
function setEditLink($item,$id,$action) {
$params = array('LUPid' => $this->LUPid);
$title = $this->title;
$this->editLink = $item->CreateLink($id, $action, '', $title, $params);
}
}