|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* citeproc-php |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://github.com/seboettg/citeproc-php for the source repository |
|
6
|
|
|
* @copyright Copyright (c) 2016 Sebastian Böttger. |
|
7
|
|
|
* @license https://opensource.org/licenses/MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Seboettg\CiteProc\Style; |
|
11
|
|
|
|
|
12
|
|
|
use Seboettg\CiteProc\Data\DataList; |
|
13
|
|
|
use Seboettg\CiteProc\Style\Options\BibliographyOptions; |
|
14
|
|
|
use Seboettg\CiteProc\CiteProc; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Bibliography |
|
18
|
|
|
* |
|
19
|
|
|
* The cs:bibliography element describes the formatting of bibliographies, which list one or more bibliographic sources. |
|
20
|
|
|
* The required cs:layout child element describes how each bibliographic entry should be formatted. cs:layout may be |
|
21
|
|
|
* preceded by a cs:sort element, which can be used to specify how references within the bibliography should be sorted |
|
22
|
|
|
* (see Sorting). |
|
23
|
|
|
* |
|
24
|
|
|
* @package Seboettg\CiteProc |
|
25
|
|
|
* |
|
26
|
|
|
* @author Sebastian Böttger <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
class Bibliography extends StyleElement |
|
29
|
|
|
{ |
|
30
|
|
|
private $node; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Bibliography constructor. |
|
34
|
|
|
* @param \SimpleXMLElement $node |
|
35
|
|
|
* @param Root $parent |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct(\SimpleXMLElement $node, $parent) |
|
38
|
|
|
{ |
|
39
|
|
|
parent::__construct($node, $parent); |
|
40
|
|
|
$this->node = $node; |
|
41
|
|
|
$bibliographyOptions = new BibliographyOptions($node); |
|
42
|
|
|
CiteProc::getContext()->setBibliographySpecificOptions($bibliographyOptions); |
|
43
|
|
|
$this->initInheritableNameAttributes($node); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param array|DataList $data |
|
48
|
|
|
* @param int|null $citationNumber |
|
49
|
|
|
* @return string |
|
50
|
|
|
*/ |
|
51
|
|
|
public function render($data, $citationNumber = null) |
|
52
|
|
|
{ |
|
53
|
|
|
if (!$this->attributesInitialized) { |
|
54
|
|
|
$this->initInheritableNameAttributes($this->node); |
|
55
|
|
|
} |
|
56
|
|
|
$subsequentAuthorSubstitute = CiteProc::getContext() |
|
57
|
|
|
->getBibliographySpecificOptions() |
|
58
|
|
|
->getSubsequentAuthorSubstitute(); |
|
59
|
|
|
|
|
60
|
|
|
$subsequentAuthorSubstituteRule = CiteProc::getContext() |
|
61
|
|
|
->getBibliographySpecificOptions() |
|
62
|
|
|
->getSubsequentAuthorSubstituteRule(); |
|
63
|
|
|
|
|
64
|
|
|
if ($subsequentAuthorSubstitute !== null && !empty($subsequentAuthorSubstituteRule)) { |
|
65
|
|
|
CiteProc::getContext()->getCitationItems()->setSubsequentAuthorSubstitute($subsequentAuthorSubstitute); |
|
66
|
|
|
CiteProc::getContext()->getCitationItems()->setSubsequentAuthorSubstituteRule($subsequentAuthorSubstituteRule); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $this->layout->render($data, $citationNumber); |
|
70
|
|
|
} |
|
71
|
|
|
} |