Open Journal Systems  3.3.0
Key.php
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 
11 
14 use SimpleXMLElement;
15 
30 class Key implements SortKey
31 {
36  private $variable;
37 
42  private $sort = "ascending";
43 
48  private $macro;
49 
54  private $rangePart = 1;
55 
68  public function __construct(SimpleXMLElement $node)
69  {
71  foreach ($node->attributes() as $attribute) {
72  $name = $attribute->getName();
73  if ($name === "variable") {
74  $this->variable = (string) $attribute;
75  }
76  if ($name === "sort") {
77  $this->sort = (string) $attribute;
78  }
79  if ($name === "macro") {
80  $this->variable = "macro";
81  $this->macro = (string) $attribute;
82  }
83  }
84  }
85 
89  public function getVariable()
90  {
91  return $this->variable;
92  }
93 
97  public function getSort()
98  {
99  return $this->sort;
100  }
101 
105  public function getMacro()
106  {
107  return $this->macro;
108  }
109 
113  public function isNameVariable()
114  {
115  return Variables::isNameVariable($this->variable);
116  }
117 
121  public function isNumberVariable()
122  {
123  return Variables::isNumberVariable($this->variable);
124  }
125 
129  public function isDateVariable()
130  {
131  return Variables::isDateVariable($this->variable);
132  }
133 
137  public function isMacro()
138  {
139  return $this->variable === "macro" && !empty(CiteProc::getContext()->getMacro($this->macro));
140  }
141 
145  public function setRangePart($rangePart)
146  {
147  $this->rangePart = $rangePart;
148  }
149 
153  public function getRangePart()
154  {
155  return $this->rangePart;
156  }
157 }
Seboettg\CiteProc\Style\Sort\Key\isDateVariable
isDateVariable()
Definition: Key.php:141
Seboettg\CiteProc\Style\Sort\Key\isNameVariable
isNameVariable()
Definition: Key.php:125
Seboettg\CiteProc\Style\Sort\Key\isNumberVariable
isNumberVariable()
Definition: Key.php:133
Seboettg\CiteProc\Util\Variables\isNumberVariable
static isNumberVariable($name)
Definition: Variables.php:143
Seboettg\CiteProc\Util\Variables\isNameVariable
static isNameVariable($name)
Definition: Variables.php:152
Seboettg\CiteProc\Style\Sort\Key\getMacro
getMacro()
Definition: Key.php:117
Seboettg\CiteProc\Style\Sort\Key\isMacro
isMacro()
Definition: Key.php:149
Seboettg\CiteProc\CiteProc
Definition: CiteProc.php:32
Seboettg\CiteProc\Util\Variables
Definition: Variables.php:25
Seboettg\CiteProc\Style\Sort\Key\__construct
__construct(SimpleXMLElement $node)
Definition: Key.php:80
Seboettg\CiteProc\Style\Sort\Key\setRangePart
setRangePart($rangePart)
Definition: Key.php:157
Seboettg\CiteProc\CiteProc\getContext
static getContext()
Definition: CiteProc.php:45
Seboettg\CiteProc\Style\Sort\Key\getRangePart
getRangePart()
Definition: Key.php:165
Seboettg\CiteProc\Style\Sort\Key
Definition: Key.php:30
Seboettg\CiteProc\Style\Sort\Key\getSort
getSort()
Definition: Key.php:109
Seboettg\CiteProc\Style\Sort\SortKey
Definition: SortKey.php:12
Seboettg\CiteProc\Style\Sort\Sort\sort
sort(&$data)
Definition: Sort.php:70
Seboettg\CiteProc\Style\Sort\Key\getVariable
getVariable()
Definition: Key.php:101
Seboettg\CiteProc\Util\Variables\isDateVariable
static isDateVariable($name)
Definition: Variables.php:134
Seboettg\CiteProc\Style\Sort
Definition: Key.php:10