@@ -94,9 +94,10 @@ |
||
94 | 94 | } |
95 | 95 | // now re-order the elements |
96 | 96 | foreach ($parts as $part) { |
97 | - foreach ($locale_elements as $key => $element) |
|
98 | - if ($element->name == $part) { |
|
97 | + foreach ($locale_elements as $key => $element) { |
|
98 | + if ($element->name == $part) { |
|
99 | 99 | $this->elements[] = $element; |
100 | + } |
|
100 | 101 | unset($locale_elements[$key]); |
101 | 102 | } |
102 | 103 | } |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | foreach ($domNode->childNodes as $node) { |
56 | 56 | if ($node->nodeType == 1) { |
57 | 57 | $element = Factory::create($node, $citeProc); |
58 | - if (($element instanceof Label)) |
|
59 | - $element->variable = $var; |
|
58 | + if (($element instanceof Label)) { |
|
59 | + $element->variable = $var; |
|
60 | + } |
|
60 | 61 | if (($element instanceof Name) && $etal) { |
61 | 62 | $element->etal = $etal; |
62 | 63 | } |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | $variables = explode(' ', $this->variable); |
80 | 81 | |
81 | 82 | foreach ($variables as $var) { |
82 | - if (in_array($var, $this->citeProc->quash)) |
|
83 | - continue; |
|
83 | + if (in_array($var, $this->citeProc->quash)) { |
|
84 | + continue; |
|
85 | + } |
|
84 | 86 | if (isset($data->{$var}) && (!empty($data->{$var}))) { |
85 | 87 | $matches[] = $var; |
86 | 88 | } |
@@ -100,18 +102,21 @@ discard block |
||
100 | 102 | } else { // if it's not a "names" element, just render it |
101 | 103 | $text = $element->render($data, $mode); |
102 | 104 | $this->citeProc->quash[] = isset($element->variable) ? $element->variable : $element->var; |
103 | - if (!empty($text)) |
|
104 | - $variable_parts[] = $text; |
|
105 | + if (!empty($text)) { |
|
106 | + $variable_parts[] = $text; |
|
107 | + } |
|
108 | + } |
|
109 | + if (!empty($matches)) { |
|
110 | + break; |
|
105 | 111 | } |
106 | - if (!empty($matches)) |
|
107 | - break; |
|
108 | 112 | } |
109 | 113 | } |
110 | 114 | } |
111 | 115 | |
112 | 116 | foreach ($matches as $var) { |
113 | - if (in_array($var, $this->citeProc->quash) && in_array($var, $variables)) |
|
114 | - continue; |
|
117 | + if (in_array($var, $this->citeProc->quash) && in_array($var, $variables)) { |
|
118 | + continue; |
|
119 | + } |
|
115 | 120 | $text = ''; |
116 | 121 | if (!empty($data->{$var})) { |
117 | 122 | foreach ($this->elements as $element) { |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | } |
124 | 129 | } |
125 | 130 | } |
126 | - if (!empty($text)) |
|
127 | - $variable_parts[] = $text; |
|
131 | + if (!empty($text)) { |
|
132 | + $variable_parts[] = $text; |
|
133 | + } |
|
128 | 134 | } |
129 | 135 | |
130 | 136 | if (!empty($variable_parts)) { |
@@ -78,12 +78,17 @@ |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
81 | - if (empty($text_parts)) |
|
82 | - return; |
|
83 | - if ($variables && !$have_variables) |
|
84 | - return; // there has to be at least one other none empty value before the term is output |
|
85 | - if (count($text_parts) == $terms) |
|
86 | - return; // there has to be at least one other none empty value before the term is output |
|
81 | + if (empty($text_parts)) { |
|
82 | + return; |
|
83 | + } |
|
84 | + if ($variables && !$have_variables) { |
|
85 | + return; |
|
86 | + } |
|
87 | + // there has to be at least one other none empty value before the term is output |
|
88 | + if (count($text_parts) == $terms) { |
|
89 | + return; |
|
90 | + } |
|
91 | + // there has to be at least one other none empty value before the term is output |
|
87 | 92 | $delimiter = $this->delimiter; |
88 | 93 | //$text = implode($delimiter, $text_parts); // insert the delimiter if supplied. |
89 | 94 | $text = $this->implodeGroup($delimiter, $text_parts); |
@@ -218,8 +218,9 @@ |
||
218 | 218 | $option = $this->locale->xpath("//cs:style-options[@$arg1]"); |
219 | 219 | } |
220 | 220 | foreach ($option[0]->attributes() as $name => $value) { |
221 | - if ($name == $arg1) |
|
222 | - return (string) $value; |
|
221 | + if ($name == $arg1) { |
|
222 | + return (string) $value; |
|
223 | + } |
|
223 | 224 | } |
224 | 225 | break; |
225 | 226 | } |
@@ -36,35 +36,45 @@ discard block |
||
36 | 36 | $matches = 0; |
37 | 37 | foreach ($types as $type) { |
38 | 38 | if (isset($data->type)) { |
39 | - if ($data->type == $type && $match == 'any') |
|
40 | - return true; |
|
41 | - if ($data->type != $type && $match == 'all') |
|
42 | - return false; |
|
43 | - if ($data->type == $type) |
|
44 | - $matches++; |
|
39 | + if ($data->type == $type && $match == 'any') { |
|
40 | + return true; |
|
41 | + } |
|
42 | + if ($data->type != $type && $match == 'all') { |
|
43 | + return false; |
|
44 | + } |
|
45 | + if ($data->type == $type) { |
|
46 | + $matches++; |
|
47 | + } |
|
45 | 48 | } |
46 | 49 | } |
47 | - if ($match == 'all' && $matches == count($types)) |
|
48 | - return true; |
|
49 | - if ($match == 'none' && $matches == 0) |
|
50 | - return true; |
|
50 | + if ($match == 'all' && $matches == count($types)) { |
|
51 | + return true; |
|
52 | + } |
|
53 | + if ($match == 'none' && $matches == 0) { |
|
54 | + return true; |
|
55 | + } |
|
51 | 56 | return false; |
52 | 57 | } |
53 | 58 | if (($variables = $this->variable)) { |
54 | 59 | $variables = explode(' ', $variables); |
55 | 60 | $matches = 0; |
56 | 61 | foreach ($variables as $var) { |
57 | - if (isset($data->$var) && !empty($data->$var) && $match == 'any') |
|
58 | - return true; |
|
59 | - if ((!isset($data->$var) || empty($data->$var)) && $match == 'all') |
|
60 | - return false; |
|
61 | - if (isset($data->$var) && !empty($data->$var)) |
|
62 | - $matches++; |
|
62 | + if (isset($data->$var) && !empty($data->$var) && $match == 'any') { |
|
63 | + return true; |
|
64 | + } |
|
65 | + if ((!isset($data->$var) || empty($data->$var)) && $match == 'all') { |
|
66 | + return false; |
|
67 | + } |
|
68 | + if (isset($data->$var) && !empty($data->$var)) { |
|
69 | + $matches++; |
|
70 | + } |
|
71 | + } |
|
72 | + if ($match == 'all' && $matches == count($variables)) { |
|
73 | + return true; |
|
74 | + } |
|
75 | + if ($match == 'none' && $matches == 0) { |
|
76 | + return true; |
|
63 | 77 | } |
64 | - if ($match == 'all' && $matches == count($variables)) |
|
65 | - return true; |
|
66 | - if ($match == 'none' && $matches == 0) |
|
67 | - return true; |
|
68 | 78 | return false; |
69 | 79 | } |
70 | 80 | if (($is_numeric = $this->{'is-numeric'})) { |
@@ -72,8 +82,9 @@ discard block |
||
72 | 82 | $matches = 0; |
73 | 83 | foreach ($variables as $var) { |
74 | 84 | if (isset($data->$var)) { |
75 | - if (is_numeric($data->$var) && $match == 'any') |
|
76 | - return true; |
|
85 | + if (is_numeric($data->$var) && $match == 'any') { |
|
86 | + return true; |
|
87 | + } |
|
77 | 88 | if (!is_numeric($data->$var)) { |
78 | 89 | if (preg_match('/(?:^\d+|\d+$)/', $data->$var)) { |
79 | 90 | $matches++; |
@@ -81,18 +92,22 @@ discard block |
||
81 | 92 | return false; |
82 | 93 | } |
83 | 94 | } |
84 | - if (is_numeric($data->$var)) |
|
85 | - $matches++; |
|
95 | + if (is_numeric($data->$var)) { |
|
96 | + $matches++; |
|
97 | + } |
|
86 | 98 | } |
87 | 99 | } |
88 | - if ($match == 'all' && $matches == count($variables)) |
|
89 | - return true; |
|
90 | - if ($match == 'none' && $matches == 0) |
|
91 | - return true; |
|
100 | + if ($match == 'all' && $matches == count($variables)) { |
|
101 | + return true; |
|
102 | + } |
|
103 | + if ($match == 'none' && $matches == 0) { |
|
104 | + return true; |
|
105 | + } |
|
92 | 106 | return false; |
93 | 107 | } |
94 | - if (isset($this->locator)) |
|
95 | - $test = explode(' ', $this->type); |
|
108 | + if (isset($this->locator)) { |
|
109 | + $test = explode(' ', $this->type); |
|
110 | + } |
|
96 | 111 | |
97 | 112 | return false; |
98 | 113 | } |
@@ -46,8 +46,9 @@ |
||
46 | 46 | break; |
47 | 47 | case 'month': |
48 | 48 | $text = (isset($date[1])) ? $date[1] : ''; |
49 | - if (empty($text) || $text < 1 || $text > 12) |
|
50 | - return; |
|
49 | + if (empty($text) || $text < 1 || $text > 12) { |
|
50 | + return; |
|
51 | + } |
|
51 | 52 | // $form = $this->form; |
52 | 53 | switch ($this->form) { |
53 | 54 | case 'numeric': break; |
@@ -30,8 +30,9 @@ |
||
30 | 30 | public function render($data, $mode = NULL) { |
31 | 31 | $var = $this->variable; |
32 | 32 | |
33 | - if (!$var || empty($data->$var)) |
|
34 | - return; |
|
33 | + if (!$var || empty($data->$var)) { |
|
34 | + return; |
|
35 | + } |
|
35 | 36 | |
36 | 37 | // $form = $this->form; |
37 | 38 |
@@ -64,10 +64,12 @@ |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - if (empty($text)) |
|
68 | - return; |
|
69 | - if ($this->{'strip-periods'}) |
|
70 | - $text = str_replace('.', '', $text); |
|
67 | + if (empty($text)) { |
|
68 | + return; |
|
69 | + } |
|
70 | + if ($this->{'strip-periods'}) { |
|
71 | + $text = str_replace('.', '', $text); |
|
72 | + } |
|
71 | 73 | return $this->format($text); |
72 | 74 | } |
73 | 75 |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | $auth_count = 0; |
59 | 59 | $et_al_triggered = false; |
60 | 60 | |
61 | - if (!$this->attr_init || $this->attr_init != $mode) |
|
62 | - $this->initAttributes($mode); |
|
61 | + if (!$this->attr_init || $this->attr_init != $mode) { |
|
62 | + $this->initAttributes($mode); |
|
63 | + } |
|
63 | 64 | |
64 | 65 | $initialize_with = $this->{'initialize-with'}; |
65 | 66 | |
@@ -123,8 +124,9 @@ discard block |
||
123 | 124 | } |
124 | 125 | $authors[] = trim($this->format($text)); |
125 | 126 | } |
126 | - if (isset($this->{'et-al-min'}) && $count >= $this->{'et-al-min'}) |
|
127 | - break; |
|
127 | + if (isset($this->{'et-al-min'}) && $count >= $this->{'et-al-min'}) { |
|
128 | + break; |
|
129 | + } |
|
128 | 130 | } |
129 | 131 | if (isset($this->{'et-al-min'}) && |
130 | 132 | $count >= $this->{'et-al-min'} && |
@@ -309,8 +311,9 @@ discard block |
||
309 | 311 | protected function format($text, $part = 'base') |
310 | 312 | { |
311 | 313 | |
312 | - if (empty($text) || $this->noOp[$part]) |
|
313 | - return $text; |
|
314 | + if (empty($text) || $this->noOp[$part]) { |
|
315 | + return $text; |
|
316 | + } |
|
314 | 317 | if (isset($this->{$part}['text-case'])) { |
315 | 318 | switch ($this->{$part}['text-case']) { |
316 | 319 | case 'uppercase': |
@@ -332,8 +335,9 @@ discard block |
||
332 | 335 | $close_quote = isset($this->{$part}['close-quote']) ? $this->{$part}['close-quote'] : ''; |
333 | 336 | $prefix = isset($this->{$part}['prefix']) ? $this->{$part}['prefix'] : ''; |
334 | 337 | $suffix = isset($this->{$part}['suffix']) ? $this->{$part}['suffix'] : ''; |
335 | - if ($text[(strlen($text) - 1)] == $suffix) |
|
336 | - unset($suffix); |
|
338 | + if ($text[(strlen($text) - 1)] == $suffix) { |
|
339 | + unset($suffix); |
|
340 | + } |
|
337 | 341 | if (!empty($this->format[$part])) { |
338 | 342 | $text = '<span style="' . $this->format[$part] . '">' . $text . '</span>'; |
339 | 343 | } |
@@ -381,10 +385,12 @@ discard block |
||
381 | 385 | $this->noOp[$part] = false; |
382 | 386 | } |
383 | 387 | |
384 | - if (isset($attribs['prefix'])) |
|
385 | - $this->{$part}['prefix'] = $attribs['prefix']; |
|
386 | - if (isset($attribs['suffix'])) |
|
387 | - $this->{$part}['suffix'] = $attribs['suffix']; |
|
388 | + if (isset($attribs['prefix'])) { |
|
389 | + $this->{$part}['prefix'] = $attribs['prefix']; |
|
390 | + } |
|
391 | + if (isset($attribs['suffix'])) { |
|
392 | + $this->{$part}['suffix'] = $attribs['suffix']; |
|
393 | + } |
|
388 | 394 | |
389 | 395 | $this->format[$part] .= (isset($attribs['font-style'])) ? 'font-style: ' . $attribs['font-style'] . ';' : ''; |
390 | 396 | $this->format[$part] .= (isset($attribs['font-family'])) ? 'font-family: ' . $attribs['font-family'] . ';' : ''; |
@@ -397,8 +403,9 @@ discard block |
||
397 | 403 | $this->noOp[$part] = false; |
398 | 404 | $this->{$part}['text-case'] = $attribs['text-case']; |
399 | 405 | } |
400 | - if (!empty($this->format[$part])) |
|
401 | - $this->noOp[$part] = false; |
|
406 | + if (!empty($this->format[$part])) { |
|
407 | + $this->noOp[$part] = false; |
|
408 | + } |
|
402 | 409 | } |
403 | 410 | |
404 | 411 | } |
405 | 412 | \ No newline at end of file |