|
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\CiteProc; |
|
13
|
|
|
use Seboettg\CiteProc\Data\DataList; |
|
14
|
|
|
use Seboettg\CiteProc\Style\Options\CitationOptions; |
|
15
|
|
|
use Seboettg\Collection\ArrayList; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class Citation |
|
20
|
|
|
* |
|
21
|
|
|
* The cs:citation element describes the formatting of citations, which consist of one or more references (“cites”) to |
|
22
|
|
|
* bibliographic sources. Citations appear in the form of either in-text citations (in the author (e.g. “[Doe]”), |
|
23
|
|
|
* author-date (“[Doe 1999]”), label (“[doe99]”) or number (“[1]”) format) or notes. The required cs:layout child |
|
24
|
|
|
* element describes what, and how, bibliographic data should be included in the citations (see Layout). |
|
25
|
|
|
* |
|
26
|
|
|
* @package Seboettg\CiteProc\Node\Style |
|
27
|
|
|
* |
|
28
|
|
|
* @author Sebastian Böttger <[email protected]> |
|
29
|
|
|
*/ |
|
|
|
|
|
|
30
|
|
|
class Citation extends StyleElement |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
private $node; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
|
|
|
|
|
36
|
|
|
* Citation constructor. |
|
37
|
|
|
* @param \SimpleXMLElement $node |
|
|
|
|
|
|
38
|
|
|
*/ |
|
39
|
130 |
|
public function __construct(\SimpleXMLElement $node, $parent) |
|
40
|
|
|
{ |
|
41
|
130 |
|
parent::__construct($node, $parent); |
|
42
|
130 |
|
$citationOptions = new CitationOptions($node); |
|
43
|
130 |
|
CiteProc::getContext()->setCitationSpecificOptions($citationOptions); |
|
44
|
130 |
|
$this->node = $node; |
|
45
|
130 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
|
|
|
|
|
48
|
|
|
* @param array|DataList $data |
|
|
|
|
|
|
49
|
|
|
* @param ArrayList $citationItems |
|
|
|
|
|
|
50
|
|
|
* @return string |
|
|
|
|
|
|
51
|
|
|
*/ |
|
52
|
91 |
|
public function render($data, $citationItems) |
|
53
|
|
|
{ |
|
54
|
91 |
|
if (!$this->attributesInitialized) { |
|
55
|
91 |
|
$this->initInheritableNameAttributes($this->node); |
|
56
|
|
|
} |
|
57
|
91 |
|
return $this->layout->render($data, $citationItems); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
} |