Completed
Push — develop ( 046500...e6f6e1 )
by Greg
17:00 queued 04:46
created
app/Functions/FunctionsPrintLists.php 1 patch
Switch Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1687,37 +1687,37 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 		}
1689 1689
 		switch ($style) {
1690
-			case 1:
1691
-				return '<ul><li>' . implode('</li><li>', $html) . '</li></ul>';
1692
-			case 2:
1693
-				return implode(I18N::$list_separator, $html);
1694
-			case 3:
1695
-				$i     = 0;
1696
-				$count = count($html);
1697
-				if ($count > 36) {
1698
-					$col = 4;
1699
-				} elseif ($count > 18) {
1700
-					$col = 3;
1701
-				} elseif ($count > 6) {
1702
-					$col = 2;
1703
-				} else {
1704
-					$col = 1;
1705
-				}
1706
-				$newcol = ceil($count / $col);
1707
-				$html2  = '<table class="list_table"><tr>';
1708
-				$html2 .= '<td class="list_value" style="padding: 14px;">';
1709
-
1710
-				foreach ($html as $surns) {
1711
-					$html2 .= $surns . '<br>';
1712
-					$i++;
1713
-					if ($i == $newcol && $i < $count) {
1714
-						$html2 .= '</td><td class="list_value" style="padding: 14px;">';
1715
-						$newcol = $i + ceil($count / $col);
1716
-					}
1690
+		case 1:
1691
+			return '<ul><li>' . implode('</li><li>', $html) . '</li></ul>';
1692
+		case 2:
1693
+			return implode(I18N::$list_separator, $html);
1694
+		case 3:
1695
+			$i     = 0;
1696
+			$count = count($html);
1697
+			if ($count > 36) {
1698
+				$col = 4;
1699
+			} elseif ($count > 18) {
1700
+				$col = 3;
1701
+			} elseif ($count > 6) {
1702
+				$col = 2;
1703
+			} else {
1704
+				$col = 1;
1705
+			}
1706
+			$newcol = ceil($count / $col);
1707
+			$html2  = '<table class="list_table"><tr>';
1708
+			$html2 .= '<td class="list_value" style="padding: 14px;">';
1709
+
1710
+			foreach ($html as $surns) {
1711
+				$html2 .= $surns . '<br>';
1712
+				$i++;
1713
+				if ($i == $newcol && $i < $count) {
1714
+					$html2 .= '</td><td class="list_value" style="padding: 14px;">';
1715
+					$newcol = $i + ceil($count / $col);
1717 1716
 				}
1718
-				$html2 .= '</td></tr></table>';
1717
+			}
1718
+			$html2 .= '</td></tr></table>';
1719 1719
 
1720
-				return $html2;
1720
+			return $html2;
1721 1721
 		}
1722 1722
 	}
1723 1723
 
@@ -1747,15 +1747,15 @@  discard block
 block discarded – undo
1747 1747
 		}
1748 1748
 
1749 1749
 		switch ($sort) {
1750
-			case 'name':
1751
-				uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSortName');
1752
-				break;
1753
-			case 'date_asc':
1754
-				uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSort');
1755
-				$arr = array_reverse($arr);
1756
-				break;
1757
-			case 'date_desc':
1758
-				uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSort');
1750
+		case 'name':
1751
+			uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSortName');
1752
+			break;
1753
+		case 'date_asc':
1754
+			uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSort');
1755
+			$arr = array_reverse($arr);
1756
+			break;
1757
+		case 'date_desc':
1758
+			uasort($arr, '\Fisharebest\Webtrees\Functions\Functions::eventSort');
1759 1759
 		}
1760 1760
 		$html = '';
1761 1761
 		foreach ($arr as $value) {
@@ -1788,15 +1788,15 @@  discard block
 block discarded – undo
1788 1788
 		$n        = 0;
1789 1789
 		$table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
1790 1790
 		switch ($sort) {
1791
-			case 'name':        //name
1792
-				$aaSorting = "[5,'asc'], [4,'desc']";
1793
-				break;
1794
-			case 'date_asc':    //date ascending
1795
-				$aaSorting = "[4,'asc'], [5,'asc']";
1796
-				break;
1797
-			case 'date_desc':   //date descending
1798
-				$aaSorting = "[4,'desc'], [5,'asc']";
1799
-				break;
1791
+		case 'name':        //name
1792
+			$aaSorting = "[5,'asc'], [4,'desc']";
1793
+			break;
1794
+		case 'date_asc':    //date ascending
1795
+			$aaSorting = "[4,'asc'], [5,'asc']";
1796
+			break;
1797
+		case 'date_desc':   //date descending
1798
+			$aaSorting = "[4,'desc'], [5,'asc']";
1799
+			break;
1800 1800
 		}
1801 1801
 		$html = '';
1802 1802
 		$controller
@@ -1843,27 +1843,27 @@  discard block
 block discarded – undo
1843 1843
 			}
1844 1844
 			$html .= '<tr><td>';
1845 1845
 			switch ($record::RECORD_TYPE) {
1846
-				case 'INDI':
1847
-					$icon = $record->getSexImage('small');
1848
-					break;
1849
-				case 'FAM':
1850
-					$icon = '<i class="icon-button_family"></i>';
1851
-					break;
1852
-				case 'OBJE':
1853
-					$icon = '<i class="icon-button_media"></i>';
1854
-					break;
1855
-				case 'NOTE':
1856
-					$icon = '<i class="icon-button_note"></i>';
1857
-					break;
1858
-				case 'SOUR':
1859
-					$icon = '<i class="icon-button_source"></i>';
1860
-					break;
1861
-				case 'REPO':
1862
-					$icon = '<i class="icon-button_repository"></i>';
1863
-					break;
1864
-				default:
1865
-					$icon = '&nbsp;';
1866
-					break;
1846
+			case 'INDI':
1847
+				$icon = $record->getSexImage('small');
1848
+				break;
1849
+			case 'FAM':
1850
+				$icon = '<i class="icon-button_family"></i>';
1851
+				break;
1852
+			case 'OBJE':
1853
+				$icon = '<i class="icon-button_media"></i>';
1854
+				break;
1855
+			case 'NOTE':
1856
+				$icon = '<i class="icon-button_note"></i>';
1857
+				break;
1858
+			case 'SOUR':
1859
+				$icon = '<i class="icon-button_source"></i>';
1860
+				break;
1861
+			case 'REPO':
1862
+				$icon = '<i class="icon-button_repository"></i>';
1863
+				break;
1864
+			default:
1865
+				$icon = '&nbsp;';
1866
+				break;
1867 1867
 			}
1868 1868
 			$html .= '<a href="' . $record->getHtmlUrl() . '">' . $icon . '</a>';
1869 1869
 			$html .= '</td>';
@@ -2092,14 +2092,14 @@  discard block
 block discarded – undo
2092 2092
 
2093 2093
 		// Now we've filtered the list, we can sort by event, if required
2094 2094
 		switch ($sort_by) {
2095
-			case 'anniv':
2096
-				// Data is already sorted by anniversary date
2097
-				break;
2098
-			case 'alpha':
2099
-				uasort($filtered_events, function (Fact $x, Fact $y) {
2100
-					return GedcomRecord::compare($x->getParent(), $y->getParent());
2101
-				});
2102
-				break;
2095
+		case 'anniv':
2096
+			// Data is already sorted by anniversary date
2097
+			break;
2098
+		case 'alpha':
2099
+			uasort($filtered_events, function (Fact $x, Fact $y) {
2100
+				return GedcomRecord::compare($x->getParent(), $y->getParent());
2101
+			});
2102
+			break;
2103 2103
 		}
2104 2104
 
2105 2105
 		foreach ($filtered_events as $fact) {
Please login to merge, or discard this patch.
app/Functions/FunctionsRtl.php 1 patch
Switch Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -124,227 +124,227 @@  discard block
 block discarded – undo
124 124
 			$closeParIndex = strpos(self::CLOSE_PARENTHESES, $currentLetter); // Which closing parenthesis is this?
125 125
 
126 126
 			switch ($currentLetter) {
127
-				case '<':
128
-					// Assume this '<' starts an HTML element
129
-					$endPos = strpos($workingText, '>'); // look for the terminating '>'
130
-					if ($endPos === false) {
131
-						$endPos = 0;
132
-					}
133
-					$currentLen += $endPos;
134
-					$element = substr($workingText, 0, $currentLen);
135
-					$temp    = strtolower(substr($element, 0, 3));
136
-					if (strlen($element) < 7 && $temp == '<br') {
137
-						if ($numberState) {
138
-							$numberState = false;
139
-							if (self::$currentState == 'RTL') {
140
-								self::$waitingText .= WT_UTF8_PDF;
141
-							}
127
+			case '<':
128
+				// Assume this '<' starts an HTML element
129
+				$endPos = strpos($workingText, '>'); // look for the terminating '>'
130
+				if ($endPos === false) {
131
+					$endPos = 0;
132
+				}
133
+				$currentLen += $endPos;
134
+				$element = substr($workingText, 0, $currentLen);
135
+				$temp    = strtolower(substr($element, 0, 3));
136
+				if (strlen($element) < 7 && $temp == '<br') {
137
+					if ($numberState) {
138
+						$numberState = false;
139
+						if (self::$currentState == 'RTL') {
140
+							self::$waitingText .= WT_UTF8_PDF;
142 141
 						}
143
-						self::breakCurrentSpan($result);
144
-					} elseif (self::$waitingText == '') {
145
-						$result .= $element;
146
-					} else {
147
-						self::$waitingText .= $element;
148 142
 					}
149
-					$workingText = substr($workingText, $currentLen);
150
-					break;
151
-				case '&':
152
-					// Assume this '&' starts an HTML entity
153
-					$endPos = strpos($workingText, ';'); // look for the terminating ';'
143
+					self::breakCurrentSpan($result);
144
+				} elseif (self::$waitingText == '') {
145
+					$result .= $element;
146
+				} else {
147
+					self::$waitingText .= $element;
148
+				}
149
+				$workingText = substr($workingText, $currentLen);
150
+				break;
151
+			case '&':
152
+				// Assume this '&' starts an HTML entity
153
+				$endPos = strpos($workingText, ';'); // look for the terminating ';'
154
+				if ($endPos === false) {
155
+					$endPos = 0;
156
+				}
157
+				$currentLen += $endPos;
158
+				$entity = substr($workingText, 0, $currentLen);
159
+				if (strtolower($entity) == '&nbsp;') {
160
+					$entity .= '&nbsp;'; // Ensure consistent case for this entity
161
+				}
162
+				if (self::$waitingText == '') {
163
+					$result .= $entity;
164
+				} else {
165
+					self::$waitingText .= $entity;
166
+				}
167
+				$workingText = substr($workingText, $currentLen);
168
+				break;
169
+			case '{':
170
+				if (substr($workingText, 1, 1) == '{') {
171
+					// Assume this '{{' starts a TCPDF directive
172
+					$endPos = strpos($workingText, '}}'); // look for the terminating '}}'
154 173
 					if ($endPos === false) {
155 174
 						$endPos = 0;
156 175
 					}
157
-					$currentLen += $endPos;
158
-					$entity = substr($workingText, 0, $currentLen);
159
-					if (strtolower($entity) == '&nbsp;') {
160
-						$entity .= '&nbsp;'; // Ensure consistent case for this entity
161
-					}
162
-					if (self::$waitingText == '') {
163
-						$result .= $entity;
164
-					} else {
165
-						self::$waitingText .= $entity;
166
-					}
167
-					$workingText = substr($workingText, $currentLen);
176
+					$currentLen        = $endPos + 2;
177
+					$directive         = substr($workingText, 0, $currentLen);
178
+					$workingText       = substr($workingText, $currentLen);
179
+					$result            = $result . self::$waitingText . $directive;
180
+					self::$waitingText = '';
168 181
 					break;
169
-				case '{':
170
-					if (substr($workingText, 1, 1) == '{') {
171
-						// Assume this '{{' starts a TCPDF directive
172
-						$endPos = strpos($workingText, '}}'); // look for the terminating '}}'
173
-						if ($endPos === false) {
174
-							$endPos = 0;
182
+				}
183
+			default:
184
+				// Look for strings of numbers with optional leading or trailing + or -
185
+				// and with optional embedded numeric punctuation
186
+				if ($numberState) {
187
+					// If we're inside a numeric string, look for reasons to end it
188
+					$offset    = 0; // Be sure to look at the current character first
189
+					$charArray = self::getChar($workingText . "\n", $offset);
190
+					if (strpos(self::NUMBERS, $charArray['letter']) === false) {
191
+						// This is not a digit.  Is it numeric punctuation?
192
+						if (substr($workingText . "\n", $offset, 6) == '&nbsp;') {
193
+							$offset += 6; // This could be numeric punctuation
194
+						} elseif (strpos(self::NUMBER_PUNCTUATION, $charArray['letter']) !== false) {
195
+							$offset += $charArray['length']; // This could be numeric punctuation
175 196
 						}
176
-						$currentLen        = $endPos + 2;
177
-						$directive         = substr($workingText, 0, $currentLen);
178
-						$workingText       = substr($workingText, $currentLen);
179
-						$result            = $result . self::$waitingText . $directive;
180
-						self::$waitingText = '';
181
-						break;
182
-					}
183
-				default:
184
-					// Look for strings of numbers with optional leading or trailing + or -
185
-					// and with optional embedded numeric punctuation
186
-					if ($numberState) {
187
-						// If we're inside a numeric string, look for reasons to end it
188
-						$offset    = 0; // Be sure to look at the current character first
197
+						// If the next character is a digit, the current character is numeric punctuation
189 198
 						$charArray = self::getChar($workingText . "\n", $offset);
190 199
 						if (strpos(self::NUMBERS, $charArray['letter']) === false) {
191
-							// This is not a digit.  Is it numeric punctuation?
192
-							if (substr($workingText . "\n", $offset, 6) == '&nbsp;') {
193
-								$offset += 6; // This could be numeric punctuation
194
-							} elseif (strpos(self::NUMBER_PUNCTUATION, $charArray['letter']) !== false) {
195
-								$offset += $charArray['length']; // This could be numeric punctuation
196
-							}
197
-							// If the next character is a digit, the current character is numeric punctuation
198
-							$charArray = self::getChar($workingText . "\n", $offset);
199
-							if (strpos(self::NUMBERS, $charArray['letter']) === false) {
200
-								// This is not a digit.  End the run of digits and punctuation.
201
-								$numberState = false;
202
-								if (self::$currentState == 'RTL') {
203
-									if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
204
-										$currentLetter = WT_UTF8_PDF . $currentLetter;
205
-									} else {
206
-										$currentLetter = $currentLetter . WT_UTF8_PDF; // Include a trailing + or - in the run
207
-									}
200
+							// This is not a digit.  End the run of digits and punctuation.
201
+							$numberState = false;
202
+							if (self::$currentState == 'RTL') {
203
+								if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
204
+									$currentLetter = WT_UTF8_PDF . $currentLetter;
205
+								} else {
206
+									$currentLetter = $currentLetter . WT_UTF8_PDF; // Include a trailing + or - in the run
208 207
 								}
209 208
 							}
210 209
 						}
211
-					} else {
212
-						// If we're outside a numeric string, look for reasons to start it
213
-						if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
214
-							// This might be a number lead-in
215
-							$offset   = $currentLen;
216
-							$nextChar = substr($workingText . "\n", $offset, 1);
217
-							if (strpos(self::NUMBERS, $nextChar) !== false) {
218
-								$numberState = true; // We found a digit: the lead-in is therefore numeric
219
-								if (self::$currentState == 'RTL') {
220
-									$currentLetter = WT_UTF8_LRE . $currentLetter;
221
-								}
222
-							}
223
-						} elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
224
-							$numberState = true; // The current letter is a digit
210
+					}
211
+				} else {
212
+					// If we're outside a numeric string, look for reasons to start it
213
+					if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
214
+						// This might be a number lead-in
215
+						$offset   = $currentLen;
216
+						$nextChar = substr($workingText . "\n", $offset, 1);
217
+						if (strpos(self::NUMBERS, $nextChar) !== false) {
218
+							$numberState = true; // We found a digit: the lead-in is therefore numeric
225 219
 							if (self::$currentState == 'RTL') {
226 220
 								$currentLetter = WT_UTF8_LRE . $currentLetter;
227 221
 							}
228 222
 						}
223
+					} elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
224
+						$numberState = true; // The current letter is a digit
225
+						if (self::$currentState == 'RTL') {
226
+							$currentLetter = WT_UTF8_LRE . $currentLetter;
227
+						}
229 228
 					}
229
+				}
230
+
231
+				// Determine the directionality of the current UTF-8 character
232
+				$newState = self::$currentState;
233
+				while (true) {
234
+					if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
235
+						if (self::$currentState == '') {
236
+							$newState = 'RTL';
237
+							break;
238
+						}
230 239
 
231
-					// Determine the directionality of the current UTF-8 character
232
-					$newState = self::$currentState;
233
-					while (true) {
234
-						if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
235
-							if (self::$currentState == '') {
240
+						if (self::$currentState == 'RTL') {
241
+							break;
242
+						}
243
+						// Switch to RTL only if this isn't a solitary RTL letter
244
+						$tempText = substr($workingText, $currentLen);
245
+						while ($tempText != '') {
246
+							$nextCharArray = self::getChar($tempText, 0);
247
+							$nextLetter    = $nextCharArray['letter'];
248
+							$nextLen       = $nextCharArray['length'];
249
+							$tempText      = substr($tempText, $nextLen);
250
+
251
+							if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
236 252
 								$newState = 'RTL';
237
-								break;
253
+								break 2;
238 254
 							}
239 255
 
240
-							if (self::$currentState == 'RTL') {
241
-								break;
256
+							if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
257
+								$newState = 'RTL';
258
+								break 2;
242 259
 							}
243
-							// Switch to RTL only if this isn't a solitary RTL letter
244
-							$tempText = substr($workingText, $currentLen);
245
-							while ($tempText != '') {
246
-								$nextCharArray = self::getChar($tempText, 0);
247
-								$nextLetter    = $nextCharArray['letter'];
248
-								$nextLen       = $nextCharArray['length'];
249
-								$tempText      = substr($tempText, $nextLen);
250
-
251
-								if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
252
-									$newState = 'RTL';
253
-									break 2;
254
-								}
255
-
256
-								if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
257
-									$newState = 'RTL';
258
-									break 2;
259
-								}
260 260
 
261
-								if ($nextLetter === ' ') {
262
-									break;
263
-								}
264
-								$nextLetter .= substr($tempText . "\n", 0, 5);
265
-								if ($nextLetter === '&nbsp;') {
266
-									break;
267
-								}
268
-							}
269
-							// This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
270
-							$currentLetter = WT_UTF8_LRO . $currentLetter . WT_UTF8_PDF;
271
-							$newState      = 'LTR';
272
-							break;
273
-						}
274
-						if (($currentLen != 1) || ($currentLetter >= 'A' && $currentLetter <= 'Z') || ($currentLetter >= 'a' && $currentLetter <= 'z')) {
275
-							// Since it’s neither Hebrew nor Arabic, this UTF-8 character or ASCII letter must be LTR
276
-							$newState = 'LTR';
277
-							break;
278
-						}
279
-						if ($closeParIndex !== false) {
280
-							// This closing parenthesis has to inherit the matching opening parenthesis' directionality
281
-							if (!empty($openParDirection[$closeParIndex]) && $openParDirection[$closeParIndex] != '?') {
282
-								$newState = $openParDirection[$closeParIndex];
261
+							if ($nextLetter === ' ') {
262
+								break;
283 263
 							}
284
-							$openParDirection[$closeParIndex] = '';
285
-							break;
286
-						}
287
-						if ($openParIndex !== false) {
288
-							// Opening parentheses always inherit the following directionality
289
-							self::$waitingText .= $currentLetter;
290
-							$workingText = substr($workingText, $currentLen);
291
-							while (true) {
292
-								if ($workingText === '') {
293
-									break;
294
-								}
295
-								if (substr($workingText, 0, 1) === ' ') {
296
-									// Spaces following this left parenthesis inherit the following directionality too
297
-									self::$waitingText .= ' ';
298
-									$workingText = substr($workingText, 1);
299
-									continue;
300
-								}
301
-								if (substr($workingText, 0, 6) === '&nbsp;') {
302
-									// Spaces following this left parenthesis inherit the following directionality too
303
-									self::$waitingText .= '&nbsp;';
304
-									$workingText = substr($workingText, 6);
305
-									continue;
306
-								}
264
+							$nextLetter .= substr($tempText . "\n", 0, 5);
265
+							if ($nextLetter === '&nbsp;') {
307 266
 								break;
308 267
 							}
309
-							$openParDirection[$openParIndex] = '?';
310
-							break 2; // double break because we're waiting for more information
311 268
 						}
312
-
313
-						// We have a digit or a "normal" special character.
314
-						//
315
-						// When this character is not at the start of the input string, it inherits the preceding directionality;
316
-						// at the start of the input string, it assumes the following directionality.
317
-						//
318
-						// Exceptions to this rule will be handled later during final clean-up.
319
-						//
269
+						// This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
270
+						$currentLetter = WT_UTF8_LRO . $currentLetter . WT_UTF8_PDF;
271
+						$newState      = 'LTR';
272
+						break;
273
+					}
274
+					if (($currentLen != 1) || ($currentLetter >= 'A' && $currentLetter <= 'Z') || ($currentLetter >= 'a' && $currentLetter <= 'z')) {
275
+						// Since it’s neither Hebrew nor Arabic, this UTF-8 character or ASCII letter must be LTR
276
+						$newState = 'LTR';
277
+						break;
278
+					}
279
+					if ($closeParIndex !== false) {
280
+						// This closing parenthesis has to inherit the matching opening parenthesis' directionality
281
+						if (!empty($openParDirection[$closeParIndex]) && $openParDirection[$closeParIndex] != '?') {
282
+							$newState = $openParDirection[$closeParIndex];
283
+						}
284
+						$openParDirection[$closeParIndex] = '';
285
+						break;
286
+					}
287
+					if ($openParIndex !== false) {
288
+						// Opening parentheses always inherit the following directionality
320 289
 						self::$waitingText .= $currentLetter;
321 290
 						$workingText = substr($workingText, $currentLen);
322
-						if (self::$currentState != '') {
323
-							$result .= self::$waitingText;
324
-							self::$waitingText = '';
291
+						while (true) {
292
+							if ($workingText === '') {
293
+								break;
294
+							}
295
+							if (substr($workingText, 0, 1) === ' ') {
296
+								// Spaces following this left parenthesis inherit the following directionality too
297
+								self::$waitingText .= ' ';
298
+								$workingText = substr($workingText, 1);
299
+								continue;
300
+							}
301
+							if (substr($workingText, 0, 6) === '&nbsp;') {
302
+								// Spaces following this left parenthesis inherit the following directionality too
303
+								self::$waitingText .= '&nbsp;';
304
+								$workingText = substr($workingText, 6);
305
+								continue;
306
+							}
307
+							break;
325 308
 						}
309
+						$openParDirection[$openParIndex] = '?';
326 310
 						break 2; // double break because we're waiting for more information
327 311
 					}
328
-					if ($newState != self::$currentState) {
329
-						// A direction change has occurred
330
-						self::finishCurrentSpan($result, false);
331
-						self::$previousState = self::$currentState;
332
-						self::$currentState  = $newState;
333
-						self::beginCurrentSpan($result);
334
-					}
312
+
313
+					// We have a digit or a "normal" special character.
314
+					//
315
+					// When this character is not at the start of the input string, it inherits the preceding directionality;
316
+					// at the start of the input string, it assumes the following directionality.
317
+					//
318
+					// Exceptions to this rule will be handled later during final clean-up.
319
+					//
335 320
 					self::$waitingText .= $currentLetter;
336 321
 					$workingText = substr($workingText, $currentLen);
337
-					$result .= self::$waitingText;
338
-					self::$waitingText = '';
322
+					if (self::$currentState != '') {
323
+						$result .= self::$waitingText;
324
+						self::$waitingText = '';
325
+					}
326
+					break 2; // double break because we're waiting for more information
327
+				}
328
+				if ($newState != self::$currentState) {
329
+					// A direction change has occurred
330
+					self::finishCurrentSpan($result, false);
331
+					self::$previousState = self::$currentState;
332
+					self::$currentState  = $newState;
333
+					self::beginCurrentSpan($result);
334
+				}
335
+				self::$waitingText .= $currentLetter;
336
+				$workingText = substr($workingText, $currentLen);
337
+				$result .= self::$waitingText;
338
+				self::$waitingText = '';
339 339
 
340
-					foreach ($openParDirection as $index => $value) {
341
-						// Since we now know the proper direction, remember it for all waiting opening parentheses
342
-						if ($value === '?') {
343
-							$openParDirection[$index] = self::$currentState;
344
-						}
340
+				foreach ($openParDirection as $index => $value) {
341
+					// Since we now know the proper direction, remember it for all waiting opening parentheses
342
+					if ($value === '?') {
343
+						$openParDirection[$index] = self::$currentState;
345 344
 					}
345
+				}
346 346
 
347
-					break;
347
+				break;
348 348
 			}
349 349
 		}
350 350
 
@@ -461,34 +461,34 @@  discard block
 block discarded – undo
461 461
 
462 462
 		// Finally, correct '<LTR>', '</LTR>', '<RTL>', and '</RTL>'
463 463
 		switch ($direction) {
464
-			case 'BOTH':
465
-			case 'both':
466
-				// LTR text: <span dir="ltr"> text </span>
467
-				// RTL text: <span dir="rtl"> text </span>
468
-				$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
469
-				$eLTR = $nothing . '</span>';
470
-				$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
471
-				$eRTL = $nothing . '</span>';
472
-				break;
473
-			case 'LTR':
474
-			case 'ltr':
475
-				// LTR text: <span dir="ltr"> text </span>
476
-				// RTL text: text
477
-				$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
478
-				$eLTR = $nothing . '</span>';
479
-				$sRTL = '';
480
-				$eRTL = '';
481
-				break;
482
-			case 'RTL':
483
-			case 'rtl':
484
-			default:
485
-				// LTR text: text
486
-				// RTL text: <span dir="rtl"> text </span>
487
-				$sLTR = '';
488
-				$eLTR = '';
489
-				$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
490
-				$eRTL = $nothing . '</span>';
491
-				break;
464
+		case 'BOTH':
465
+		case 'both':
466
+			// LTR text: <span dir="ltr"> text </span>
467
+			// RTL text: <span dir="rtl"> text </span>
468
+			$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
469
+			$eLTR = $nothing . '</span>';
470
+			$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
471
+			$eRTL = $nothing . '</span>';
472
+			break;
473
+		case 'LTR':
474
+		case 'ltr':
475
+			// LTR text: <span dir="ltr"> text </span>
476
+			// RTL text: text
477
+			$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
478
+			$eLTR = $nothing . '</span>';
479
+			$sRTL = '';
480
+			$eRTL = '';
481
+			break;
482
+		case 'RTL':
483
+		case 'rtl':
484
+		default:
485
+			// LTR text: text
486
+			// RTL text: <span dir="rtl"> text </span>
487
+			$sLTR = '';
488
+			$eLTR = '';
489
+			$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
490
+			$eRTL = $nothing . '</span>';
491
+			break;
492 492
 		}
493 493
 		$result = str_replace(array(self::$startLTR, self::$endLTR, self::$startRTL, self::$endRTL), array($sLTR, $eLTR, $sRTL, $eRTL), $result);
494 494
 
Please login to merge, or discard this patch.
app/I18N.php 1 patch
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public static function gedcomAge($string) {
285 285
 		switch ($string) {
286
-			case 'STILLBORN':
287
-				// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (stillborn)
288
-				return self::translate('(stillborn)');
289
-			case 'INFANT':
290
-				// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (in infancy)
291
-				return self::translate('(in infancy)');
292
-			case 'CHILD':
293
-				// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (in childhood)
294
-				return self::translate('(in childhood)');
286
+		case 'STILLBORN':
287
+			// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (stillborn)
288
+			return self::translate('(stillborn)');
289
+		case 'INFANT':
290
+			// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (in infancy)
291
+			return self::translate('(in infancy)');
292
+		case 'CHILD':
293
+			// I18N: Description of an individual’s age at an event.  For example, Died 14 Jan 1900 (in childhood)
294
+			return self::translate('(in childhood)');
295 295
 		}
296 296
 		$age = array();
297 297
 		if (preg_match('/(\d+)y/', $string, $match)) {
@@ -871,15 +871,15 @@  discard block
 block discarded – undo
871 871
 	 */
872 872
 	public static function defaultCalendar() {
873 873
 		switch (self::$locale->languageTag()) {
874
-			case 'ar':
875
-				return new ArabicCalendar;
876
-			case 'fa':
877
-				return new PersianCalendar;
878
-			case 'he':
879
-			case 'yi':
880
-				return new JewishCalendar;
881
-			default:
882
-				return new GregorianCalendar;
874
+		case 'ar':
875
+			return new ArabicCalendar;
876
+		case 'fa':
877
+			return new PersianCalendar;
878
+		case 'he':
879
+		case 'yi':
880
+			return new JewishCalendar;
881
+		default:
882
+			return new GregorianCalendar;
883 883
 		}
884 884
 	}
885 885
 }
Please login to merge, or discard this patch.
app/Report/ReportBase.php 1 patch
Switch Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -139,258 +139,258 @@
 block discarded – undo
139 139
 			 */
140 140
 			switch ($this->pageFormat) {
141 141
 				// ISO A series
142
-				case '4A0': // ISO 216, 1682 mm x 2378 mm
143
-					$sizes = array(4767.86, 6740.79);
144
-					break;
145
-				case '2A0': // ISO 216, 1189 mm x 1682 mm
146
-					$sizes = array(3370.39, 4767.86);
147
-					break;
148
-				case 'A0': // ISO 216, 841 mm x 1189mm
149
-					$sizes = array(2383.94, 3370.39);
150
-					break;
151
-				case 'A1': // ISO 216, 594 mm x 841 mm
152
-					$sizes = array(1683.78, 2383.94);
153
-					break;
154
-				case 'A2': // ISO 216, 420 mm x 594 mm
155
-					$sizes = array(1190.55, 1683.78);
156
-					break;
157
-				case 'A3': // ISO 216, 297 mm x 420 mm
158
-					$sizes = array(841.89, 1190.55);
159
-					break;
160
-				case 'A4': // ISO 216, 210 mm 297 mm
161
-					$sizes = array(595.28, 841.89);
162
-					break;
163
-				case 'A5': // ISO 216, 148 mm x 210 mm
164
-					$sizes = array(419.53, 595.28);
165
-					break;
166
-				case 'A6': // ISO 216, 105 mm x 148 mm
167
-					$sizes = array(297.64, 419.53);
168
-					break;
169
-				case 'A7': // ISO 216, 74 mm x 105 mm
170
-					$sizes = array(209.76, 297.64);
171
-					break;
172
-				case 'A8': // ISO 216, 52 mm x 74 mm
173
-					$sizes = array(147.40, 209.76);
174
-					break;
175
-				case 'A9': // ISO 216, 37 mm x 52 mm
176
-					$sizes = array(104.88, 147.40);
177
-					break;
178
-				case 'A10': // ISO 216, 26 mm x 37 mm
179
-					$sizes = array(73.70, 104.88);
180
-					break;
181
-
182
-				// ISO B series
183
-				case 'B0': // ISO 216, 1000 mm x 1414 mm
184
-					$sizes = array(2834.65, 4008.19);
185
-					break;
186
-				case 'B1': // ISO 216, 707 mm x 1000 mm
187
-					$sizes = array(2004.09, 2834.65);
188
-					break;
189
-				case 'B2': // ISO 216, 500 mm x 707 mm
190
-					$sizes = array(1417.32, 2004.09);
191
-					break;
192
-				case 'B3': // ISO 216, 353 mm x 500 mm
193
-					$sizes = array(1000.63, 1417.32);
194
-					break;
195
-				case 'B4': // ISO 216, 250 mm x 353 mm
196
-					$sizes = array(708.66, 1000.63);
197
-					break;
198
-				case 'B5': // ISO 216, 176 mm x 250 mm
199
-					$sizes = array(498.90, 708.66);
200
-					break;
201
-				case 'B6': // ISO 216, 125 mm x 176 mm
202
-					$sizes = array(354.33, 498.90);
203
-					break;
204
-				case 'B7': // ISO 216, 88 mm x 125 mm
205
-					$sizes = array(249.45, 354.33);
206
-					break;
207
-				case 'B8': // ISO 216, 62 mm x 88 mm
208
-					$sizes = array(175.75, 249.45);
209
-					break;
210
-				case 'B9': // ISO 216, 44 mm x 62 mm
211
-					$sizes = array(124.72, 175.75);
212
-					break;
213
-				case 'B10': // ISO 216, 31 mm x 44 mm
214
-					$sizes = array(87.87, 124.72);
215
-					break;
216
-
217
-				// ISO C series, Envelope
218
-				case 'C0': // ISO 269, 917 mm x 1297 mm, For flat A0 sheet
219
-					$sizes = array(2599.37, 3676.54);
220
-					break;
221
-				case 'C1': // ISO 269, 648 mm x 917 mm, For flat A1 sheet
222
-					$sizes = array(1836.85, 2599.37);
223
-					break;
224
-				case 'C2': // ISO 269, 458 mm x 648 mm, For flat A2 sheet, A1 folded in half
225
-					$sizes = array(1298.27, 1836.85);
226
-					break;
227
-				case 'C3': // ISO 269, 324 mm x 458 mm, For flat A3 sheet, A2 folded in half
228
-					$sizes = array(918.43, 1298.27);
229
-					break;
230
-				case 'C4': // ISO 269, 229 mm x 324 mm, For flat A4 sheet, A3 folded in half
231
-					$sizes = array(649.13, 918.43);
232
-					break;
233
-				case 'C5': // ISO 269, 162 mm x 229 mm, For flat A5 sheet, A4 folded in half
234
-					$sizes = array(459.21, 649.13);
235
-					break;
236
-				case 'C6/5': // ISO 269, 114 mm x 229 mm. A5 folded twice = 1/3 A4. Alternative for the DL envelope
237
-					$sizes = array(323.15, 649.13);
238
-					break;
239
-				case 'C6': // ISO 269, 114 mm x 162 mm, For A5 folded in half
240
-					$sizes = array(323.15, 459.21);
241
-					break;
242
-				case 'C7/6': // ISO 269, 81 mm x 162 mm, For A5 sheet folded in thirds
243
-					$sizes = array(229.61, 459.21);
244
-					break;
245
-				case 'C7': // ISO 269, 81 mm x 114 mm, For A5 folded in quarters
246
-					$sizes = array(229.61, 323.15);
247
-					break;
248
-				case 'C8': // ISO 269, 57 mm x 81 mm
249
-					$sizes = array(161.57, 229.61);
250
-					break;
251
-				case 'C9': // ISO 269, 40 mm x 57 mm
252
-					$sizes = array(113.39, 161.57);
253
-					break;
254
-				case 'C10': // ISO 269, 28 mm x 40 mm
255
-					$sizes = array(79.37, 113.39);
256
-					break;
257
-				case 'DL': // Original DIN 678 but ISO 269 now has this C6/5 , 110 mm x 220 mm, For A4 sheet folded in thirds, A5 in half
258
-					$sizes = array(311.81, 623.62);
259
-					break;
260
-
261
-				// Untrimmed stock sizes for the ISO-A Series - ISO primary range
262
-				case 'RA0': // ISO 478, 860 mm x 1220 mm
263
-					$sizes = array(2437.80, 3458.27);
264
-					break;
265
-				case 'RA1': // ISO 478, 610 mm x 860 mm
266
-					$sizes = array(1729.13, 2437.80);
267
-					break;
268
-				case 'RA2': // ISO 478, 430 mm x 610 mm
269
-					$sizes = array(1218.90, 1729.13);
270
-					break;
271
-				case 'RA3': // ISO 478, 305 mm x 430 mm
272
-					$sizes = array(864.57, 1218.90);
273
-					break;
274
-				case 'RA4': // ISO 478, 215 mm x 305 mm
275
-					$sizes = array(609.45, 864.57);
276
-					break;
277
-
278
-				// Untrimmed stock sizes for the ISO-A Series - ISO supplementary range
279
-				case 'SRA0': // ISO 593, 900 mm x 1280 mm
280
-					$sizes = array(2551.18, 3628.35);
281
-					break;
282
-				case 'SRA1': // ISO 593, 640 mm x 900 mm
283
-					$sizes = array(1814.17, 2551.18);
284
-					break;
285
-				case 'SRA2': // ISO 593, 450 mm x 640 mm
286
-					$sizes = array(1275.59, 1814.17);
287
-					break;
288
-				case 'SRA3': // ISO 593, 320 mm x 450 mm
289
-					$sizes = array(907.09, 1275.59);
290
-					break;
291
-				case 'SRA4': // ISO 593, 225 mm x 320 mm
292
-					$sizes = array(637.80, 907.09);
293
-					break;
294
-
295
-				// ISO size variations
296
-				case 'A2EXTRA': // ISO 216, 445 mm x 619 mm
297
-					$sizes = array(1261.42, 1754.65);
298
-					break;
299
-				case 'A2SUPER': // ISO 216, 305 mm x 508 mm
300
-					$sizes = array(864.57, 1440.00);
301
-					break;
302
-				case 'A3EXTRA': // ISO 216, 322 mm x 445 mm
303
-					$sizes = array(912.76, 1261.42);
304
-					break;
305
-				case 'SUPERA3': // ISO 216, 305 mm x 487 mm
306
-					$sizes = array(864.57, 1380.47);
307
-					break;
308
-				case 'A4EXTRA': // ISO 216, 235 mm x 322 mm
309
-					$sizes = array(666.14, 912.76);
310
-					break;
311
-				case 'A4LONG': // ISO 216, 210 mm x 348 mm
312
-					$sizes = array(595.28, 986.46);
313
-					break;
314
-				case 'A4SUPER': // ISO 216, 229 mm x 322 mm
315
-					$sizes = array(649.13, 912.76);
316
-					break;
317
-				case 'SUPERA4': // ISO 216, 227 mm x 356 mm
318
-					$sizes = array(643.46, 1009.13);
319
-					break;
320
-				case 'A5EXTRA': // ISO 216, 173 mm x 235 mm
321
-					$sizes = array(490.39, 666.14);
322
-					break;
323
-				case 'SOB5EXTRA': // ISO 216, 202 mm x 276 mm
324
-					$sizes = array(572.60, 782.36);
325
-					break;
326
-
327
-				// Japanese version of the ISO 216 B series
328
-				case 'JB0': // JIS P 0138-61, 1030 mm x 1456 mm
329
-					$sizes = array(2919.69, 4127.24);
330
-					break;
331
-				case 'JB1': // JIS P 0138-61, 728 mm x 1030 mm
332
-					$sizes = array(2063.62, 2919.69);
333
-					break;
334
-				case 'JB2': // JIS P 0138-61, 515 mm x 728 mm
335
-					$sizes = array(1459.84, 2063.62);
336
-					break;
337
-				case 'JB3': // JIS P 0138-61, 364 mm x 515 mm
338
-					$sizes = array(1031.81, 1459.84);
339
-					break;
340
-				case 'JB4': // JIS P 0138-61, 257 mm x 364 mm
341
-					$sizes = array(728.50, 1031.81);
342
-					break;
343
-				case 'JB5': // JIS P 0138-61, 182 mm x 257 mm
344
-					$sizes = array(515.91, 728.50);
345
-					break;
346
-				case 'JB6': // JIS P 0138-61, 128 mm x 182 mm
347
-					$sizes = array(362.83, 515.91);
348
-					break;
349
-				case 'JB7': // JIS P 0138-61, 91 mm x 128 mm
350
-					$sizes = array(257.95, 362.83);
351
-					break;
352
-				case 'JB8': // JIS P 0138-61, 64 mm x 91 mm
353
-					$sizes = array(181.42, 257.95);
354
-					break;
355
-				case 'JB9': // JIS P 0138-61, 45 mm x 64 mm
356
-					$sizes = array(127.56, 181.42);
357
-					break;
358
-				case 'JB10': // JIS P 0138-61, 32 mm x 45 mm
359
-					$sizes = array(90.71, 127.56);
360
-					break;
361
-
362
-				// US pages
363
-				case 'EXECUTIVE': // 7.25 in x 10.5 in
364
-					$sizes = array(522.00, 756.00);
365
-					break;
366
-				case 'FOLIO': // 8.5 in x 13 in
367
-					$sizes = array(612.00, 936.00);
368
-					break;
369
-				case 'FOOLSCAP': // 13.5 in x 17 in
370
-					$sizes = array(972.00, 1224.00);
371
-					break;
372
-				case 'LEDGER': // 11 in x 17 in
373
-					$sizes = array(792.00, 1224.00);
374
-					break;
375
-				case 'LEGAL': // 8.5 in x 14 in
376
-					$sizes = array(612.00, 1008.00);
377
-					break;
378
-				case 'LETTER': // 8.5 in x 11 in
379
-					$sizes = array(612.00, 792.00);
380
-					break;
381
-				case 'QUARTO': // 8.46 in x 10.8 in
382
-					$sizes = array(609.12, 777.50);
383
-					break;
384
-				case 'STATEMENT': // 5.5 in x 8.5 in
385
-					$sizes = array(396.00, 612.00);
386
-					break;
387
-				case 'USGOVT': // 8 in x 11 in
388
-					$sizes = array(576.00, 792.00);
389
-					break;
390
-				default:
391
-					$this->pageFormat = 'A4';
392
-					$sizes            = array(595.28, 841.89);
393
-					break;
142
+			case '4A0': // ISO 216, 1682 mm x 2378 mm
143
+				$sizes = array(4767.86, 6740.79);
144
+				break;
145
+			case '2A0': // ISO 216, 1189 mm x 1682 mm
146
+				$sizes = array(3370.39, 4767.86);
147
+				break;
148
+			case 'A0': // ISO 216, 841 mm x 1189mm
149
+				$sizes = array(2383.94, 3370.39);
150
+				break;
151
+			case 'A1': // ISO 216, 594 mm x 841 mm
152
+				$sizes = array(1683.78, 2383.94);
153
+				break;
154
+			case 'A2': // ISO 216, 420 mm x 594 mm
155
+				$sizes = array(1190.55, 1683.78);
156
+				break;
157
+			case 'A3': // ISO 216, 297 mm x 420 mm
158
+				$sizes = array(841.89, 1190.55);
159
+				break;
160
+			case 'A4': // ISO 216, 210 mm 297 mm
161
+				$sizes = array(595.28, 841.89);
162
+				break;
163
+			case 'A5': // ISO 216, 148 mm x 210 mm
164
+				$sizes = array(419.53, 595.28);
165
+				break;
166
+			case 'A6': // ISO 216, 105 mm x 148 mm
167
+				$sizes = array(297.64, 419.53);
168
+				break;
169
+			case 'A7': // ISO 216, 74 mm x 105 mm
170
+				$sizes = array(209.76, 297.64);
171
+				break;
172
+			case 'A8': // ISO 216, 52 mm x 74 mm
173
+				$sizes = array(147.40, 209.76);
174
+				break;
175
+			case 'A9': // ISO 216, 37 mm x 52 mm
176
+				$sizes = array(104.88, 147.40);
177
+				break;
178
+			case 'A10': // ISO 216, 26 mm x 37 mm
179
+				$sizes = array(73.70, 104.88);
180
+				break;
181
+
182
+			// ISO B series
183
+			case 'B0': // ISO 216, 1000 mm x 1414 mm
184
+				$sizes = array(2834.65, 4008.19);
185
+				break;
186
+			case 'B1': // ISO 216, 707 mm x 1000 mm
187
+				$sizes = array(2004.09, 2834.65);
188
+				break;
189
+			case 'B2': // ISO 216, 500 mm x 707 mm
190
+				$sizes = array(1417.32, 2004.09);
191
+				break;
192
+			case 'B3': // ISO 216, 353 mm x 500 mm
193
+				$sizes = array(1000.63, 1417.32);
194
+				break;
195
+			case 'B4': // ISO 216, 250 mm x 353 mm
196
+				$sizes = array(708.66, 1000.63);
197
+				break;
198
+			case 'B5': // ISO 216, 176 mm x 250 mm
199
+				$sizes = array(498.90, 708.66);
200
+				break;
201
+			case 'B6': // ISO 216, 125 mm x 176 mm
202
+				$sizes = array(354.33, 498.90);
203
+				break;
204
+			case 'B7': // ISO 216, 88 mm x 125 mm
205
+				$sizes = array(249.45, 354.33);
206
+				break;
207
+			case 'B8': // ISO 216, 62 mm x 88 mm
208
+				$sizes = array(175.75, 249.45);
209
+				break;
210
+			case 'B9': // ISO 216, 44 mm x 62 mm
211
+				$sizes = array(124.72, 175.75);
212
+				break;
213
+			case 'B10': // ISO 216, 31 mm x 44 mm
214
+				$sizes = array(87.87, 124.72);
215
+				break;
216
+
217
+			// ISO C series, Envelope
218
+			case 'C0': // ISO 269, 917 mm x 1297 mm, For flat A0 sheet
219
+				$sizes = array(2599.37, 3676.54);
220
+				break;
221
+			case 'C1': // ISO 269, 648 mm x 917 mm, For flat A1 sheet
222
+				$sizes = array(1836.85, 2599.37);
223
+				break;
224
+			case 'C2': // ISO 269, 458 mm x 648 mm, For flat A2 sheet, A1 folded in half
225
+				$sizes = array(1298.27, 1836.85);
226
+				break;
227
+			case 'C3': // ISO 269, 324 mm x 458 mm, For flat A3 sheet, A2 folded in half
228
+				$sizes = array(918.43, 1298.27);
229
+				break;
230
+			case 'C4': // ISO 269, 229 mm x 324 mm, For flat A4 sheet, A3 folded in half
231
+				$sizes = array(649.13, 918.43);
232
+				break;
233
+			case 'C5': // ISO 269, 162 mm x 229 mm, For flat A5 sheet, A4 folded in half
234
+				$sizes = array(459.21, 649.13);
235
+				break;
236
+			case 'C6/5': // ISO 269, 114 mm x 229 mm. A5 folded twice = 1/3 A4. Alternative for the DL envelope
237
+				$sizes = array(323.15, 649.13);
238
+				break;
239
+			case 'C6': // ISO 269, 114 mm x 162 mm, For A5 folded in half
240
+				$sizes = array(323.15, 459.21);
241
+				break;
242
+			case 'C7/6': // ISO 269, 81 mm x 162 mm, For A5 sheet folded in thirds
243
+				$sizes = array(229.61, 459.21);
244
+				break;
245
+			case 'C7': // ISO 269, 81 mm x 114 mm, For A5 folded in quarters
246
+				$sizes = array(229.61, 323.15);
247
+				break;
248
+			case 'C8': // ISO 269, 57 mm x 81 mm
249
+				$sizes = array(161.57, 229.61);
250
+				break;
251
+			case 'C9': // ISO 269, 40 mm x 57 mm
252
+				$sizes = array(113.39, 161.57);
253
+				break;
254
+			case 'C10': // ISO 269, 28 mm x 40 mm
255
+				$sizes = array(79.37, 113.39);
256
+				break;
257
+			case 'DL': // Original DIN 678 but ISO 269 now has this C6/5 , 110 mm x 220 mm, For A4 sheet folded in thirds, A5 in half
258
+				$sizes = array(311.81, 623.62);
259
+				break;
260
+
261
+			// Untrimmed stock sizes for the ISO-A Series - ISO primary range
262
+			case 'RA0': // ISO 478, 860 mm x 1220 mm
263
+				$sizes = array(2437.80, 3458.27);
264
+				break;
265
+			case 'RA1': // ISO 478, 610 mm x 860 mm
266
+				$sizes = array(1729.13, 2437.80);
267
+				break;
268
+			case 'RA2': // ISO 478, 430 mm x 610 mm
269
+				$sizes = array(1218.90, 1729.13);
270
+				break;
271
+			case 'RA3': // ISO 478, 305 mm x 430 mm
272
+				$sizes = array(864.57, 1218.90);
273
+				break;
274
+			case 'RA4': // ISO 478, 215 mm x 305 mm
275
+				$sizes = array(609.45, 864.57);
276
+				break;
277
+
278
+			// Untrimmed stock sizes for the ISO-A Series - ISO supplementary range
279
+			case 'SRA0': // ISO 593, 900 mm x 1280 mm
280
+				$sizes = array(2551.18, 3628.35);
281
+				break;
282
+			case 'SRA1': // ISO 593, 640 mm x 900 mm
283
+				$sizes = array(1814.17, 2551.18);
284
+				break;
285
+			case 'SRA2': // ISO 593, 450 mm x 640 mm
286
+				$sizes = array(1275.59, 1814.17);
287
+				break;
288
+			case 'SRA3': // ISO 593, 320 mm x 450 mm
289
+				$sizes = array(907.09, 1275.59);
290
+				break;
291
+			case 'SRA4': // ISO 593, 225 mm x 320 mm
292
+				$sizes = array(637.80, 907.09);
293
+				break;
294
+
295
+			// ISO size variations
296
+			case 'A2EXTRA': // ISO 216, 445 mm x 619 mm
297
+				$sizes = array(1261.42, 1754.65);
298
+				break;
299
+			case 'A2SUPER': // ISO 216, 305 mm x 508 mm
300
+				$sizes = array(864.57, 1440.00);
301
+				break;
302
+			case 'A3EXTRA': // ISO 216, 322 mm x 445 mm
303
+				$sizes = array(912.76, 1261.42);
304
+				break;
305
+			case 'SUPERA3': // ISO 216, 305 mm x 487 mm
306
+				$sizes = array(864.57, 1380.47);
307
+				break;
308
+			case 'A4EXTRA': // ISO 216, 235 mm x 322 mm
309
+				$sizes = array(666.14, 912.76);
310
+				break;
311
+			case 'A4LONG': // ISO 216, 210 mm x 348 mm
312
+				$sizes = array(595.28, 986.46);
313
+				break;
314
+			case 'A4SUPER': // ISO 216, 229 mm x 322 mm
315
+				$sizes = array(649.13, 912.76);
316
+				break;
317
+			case 'SUPERA4': // ISO 216, 227 mm x 356 mm
318
+				$sizes = array(643.46, 1009.13);
319
+				break;
320
+			case 'A5EXTRA': // ISO 216, 173 mm x 235 mm
321
+				$sizes = array(490.39, 666.14);
322
+				break;
323
+			case 'SOB5EXTRA': // ISO 216, 202 mm x 276 mm
324
+				$sizes = array(572.60, 782.36);
325
+				break;
326
+
327
+			// Japanese version of the ISO 216 B series
328
+			case 'JB0': // JIS P 0138-61, 1030 mm x 1456 mm
329
+				$sizes = array(2919.69, 4127.24);
330
+				break;
331
+			case 'JB1': // JIS P 0138-61, 728 mm x 1030 mm
332
+				$sizes = array(2063.62, 2919.69);
333
+				break;
334
+			case 'JB2': // JIS P 0138-61, 515 mm x 728 mm
335
+				$sizes = array(1459.84, 2063.62);
336
+				break;
337
+			case 'JB3': // JIS P 0138-61, 364 mm x 515 mm
338
+				$sizes = array(1031.81, 1459.84);
339
+				break;
340
+			case 'JB4': // JIS P 0138-61, 257 mm x 364 mm
341
+				$sizes = array(728.50, 1031.81);
342
+				break;
343
+			case 'JB5': // JIS P 0138-61, 182 mm x 257 mm
344
+				$sizes = array(515.91, 728.50);
345
+				break;
346
+			case 'JB6': // JIS P 0138-61, 128 mm x 182 mm
347
+				$sizes = array(362.83, 515.91);
348
+				break;
349
+			case 'JB7': // JIS P 0138-61, 91 mm x 128 mm
350
+				$sizes = array(257.95, 362.83);
351
+				break;
352
+			case 'JB8': // JIS P 0138-61, 64 mm x 91 mm
353
+				$sizes = array(181.42, 257.95);
354
+				break;
355
+			case 'JB9': // JIS P 0138-61, 45 mm x 64 mm
356
+				$sizes = array(127.56, 181.42);
357
+				break;
358
+			case 'JB10': // JIS P 0138-61, 32 mm x 45 mm
359
+				$sizes = array(90.71, 127.56);
360
+				break;
361
+
362
+			// US pages
363
+			case 'EXECUTIVE': // 7.25 in x 10.5 in
364
+				$sizes = array(522.00, 756.00);
365
+				break;
366
+			case 'FOLIO': // 8.5 in x 13 in
367
+				$sizes = array(612.00, 936.00);
368
+				break;
369
+			case 'FOOLSCAP': // 13.5 in x 17 in
370
+				$sizes = array(972.00, 1224.00);
371
+				break;
372
+			case 'LEDGER': // 11 in x 17 in
373
+				$sizes = array(792.00, 1224.00);
374
+				break;
375
+			case 'LEGAL': // 8.5 in x 14 in
376
+				$sizes = array(612.00, 1008.00);
377
+				break;
378
+			case 'LETTER': // 8.5 in x 11 in
379
+				$sizes = array(612.00, 792.00);
380
+				break;
381
+			case 'QUARTO': // 8.46 in x 10.8 in
382
+				$sizes = array(609.12, 777.50);
383
+				break;
384
+			case 'STATEMENT': // 5.5 in x 8.5 in
385
+				$sizes = array(396.00, 612.00);
386
+				break;
387
+			case 'USGOVT': // 8 in x 11 in
388
+				$sizes = array(576.00, 792.00);
389
+				break;
390
+			default:
391
+				$this->pageFormat = 'A4';
392
+				$sizes            = array(595.28, 841.89);
393
+				break;
394 394
 			}
395 395
 			$this->pagew = $sizes[0];
396 396
 			$this->pageh = $sizes[1];
Please login to merge, or discard this patch.
app/Report/ReportParserGenerate.php 1 patch
Switch Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -934,14 +934,14 @@  discard block
 block discarded – undo
934 934
 				$tags  = preg_split('/[: ]/', $tag);
935 935
 				$value = $this->getGedcomValue($tag, $level, $this->gedrec);
936 936
 				switch (end($tags)) {
937
-					case 'DATE':
938
-						$tmp   = new Date($value);
939
-						$value = $tmp->display();
940
-						break;
941
-					case 'PLAC':
942
-						$tmp   = new Place($value, $WT_TREE);
943
-						$value = $tmp->getShortName();
944
-						break;
937
+				case 'DATE':
938
+					$tmp   = new Date($value);
939
+					$value = $tmp->display();
940
+					break;
941
+				case 'PLAC':
942
+					$tmp   = new Place($value, $WT_TREE);
943
+					$value = $tmp->getShortName();
944
+					break;
945 945
 				}
946 946
 				if ($useBreak == "1") {
947 947
 					// Insert <br> when multiple dates exist.
@@ -1325,22 +1325,22 @@  discard block
 block discarded – undo
1325 1325
 		// Arithmetic functions
1326 1326
 		if (preg_match("/(\d+)\s*([\-\+\*\/])\s*(\d+)/", $value, $match)) {
1327 1327
 			switch ($match[2]) {
1328
-				case "+":
1329
-					$t     = $match[1] + $match[3];
1330
-					$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1331
-					break;
1332
-				case "-":
1333
-					$t     = $match[1] - $match[3];
1334
-					$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1335
-					break;
1336
-				case "*":
1337
-					$t     = $match[1] * $match[3];
1338
-					$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1339
-					break;
1340
-				case "/":
1341
-					$t     = $match[1] / $match[3];
1342
-					$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1343
-					break;
1328
+			case "+":
1329
+				$t     = $match[1] + $match[3];
1330
+				$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1331
+				break;
1332
+			case "-":
1333
+				$t     = $match[1] - $match[3];
1334
+				$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1335
+				break;
1336
+			case "*":
1337
+				$t     = $match[1] * $match[3];
1338
+				$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1339
+				break;
1340
+			case "/":
1341
+				$t     = $match[1] / $match[3];
1342
+				$value = preg_replace("/" . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . "/", $t, $value);
1343
+				break;
1344 1344
 			}
1345 1345
 		}
1346 1346
 		if (strpos($value, "@") !== false) {
@@ -1850,180 +1850,180 @@  discard block
 block discarded – undo
1850 1850
 		}
1851 1851
 		// Some filters/sorts can be applied using SQL, while others require PHP
1852 1852
 		switch ($listname) {
1853
-			case "pending":
1854
-				$rows = Database::prepare(
1855
-					"SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" .
1856
-					" FROM `##change`" . " WHERE (xref, change_id) IN (" .
1857
-					"  SELECT xref, MAX(change_id)" .
1858
-					"  FROM `##change`" .
1859
-					"  WHERE status = 'pending' AND gedcom_id = :tree_id" .
1860
-					"  GROUP BY xref" .
1861
-					" )"
1862
-				)->execute(array(
1863
-					'tree_id' => $WT_TREE->getTreeId(),
1864
-				))->fetchAll();
1865
-				$this->list = array();
1866
-				foreach ($rows as $row) {
1867
-					$this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom);
1868
-				}
1869
-				break;
1870
-			case 'individual':
1871
-				$sql_select   = "SELECT DISTINCT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` ";
1872
-				$sql_join     = "";
1873
-				$sql_where    = " WHERE i_file = :tree_id";
1874
-				$sql_order_by = "";
1875
-				$sql_params   = array('tree_id' => $WT_TREE->getTreeId());
1876
-				foreach ($attrs as $attr => $value) {
1877
-					if (strpos($attr, 'filter') === 0 && $value) {
1878
-						$value = $this->substituteVars($value, false);
1879
-						// Convert the various filters into SQL
1880
-						if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
1881
-							$sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)";
1882
-							$sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
1883
-							$sql_params[$attr . 'fact'] = $match[1];
1884
-							$date                       = new Date($match[3]);
1885
-							if ($match[2] == "LTE") {
1886
-								$sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
1887
-								$sql_params[$attr . 'date'] = $date->maximumJulianDay();
1888
-							} else {
1889
-								$sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
1890
-								$sql_params[$attr . 'date'] = $date->minimumJulianDay();
1853
+		case "pending":
1854
+			$rows = Database::prepare(
1855
+				"SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" .
1856
+				" FROM `##change`" . " WHERE (xref, change_id) IN (" .
1857
+				"  SELECT xref, MAX(change_id)" .
1858
+				"  FROM `##change`" .
1859
+				"  WHERE status = 'pending' AND gedcom_id = :tree_id" .
1860
+				"  GROUP BY xref" .
1861
+				" )"
1862
+			)->execute(array(
1863
+				'tree_id' => $WT_TREE->getTreeId(),
1864
+			))->fetchAll();
1865
+			$this->list = array();
1866
+			foreach ($rows as $row) {
1867
+				$this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom);
1868
+			}
1869
+			break;
1870
+		case 'individual':
1871
+			$sql_select   = "SELECT DISTINCT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` ";
1872
+			$sql_join     = "";
1873
+			$sql_where    = " WHERE i_file = :tree_id";
1874
+			$sql_order_by = "";
1875
+			$sql_params   = array('tree_id' => $WT_TREE->getTreeId());
1876
+			foreach ($attrs as $attr => $value) {
1877
+				if (strpos($attr, 'filter') === 0 && $value) {
1878
+					$value = $this->substituteVars($value, false);
1879
+					// Convert the various filters into SQL
1880
+					if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
1881
+						$sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)";
1882
+						$sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
1883
+						$sql_params[$attr . 'fact'] = $match[1];
1884
+						$date                       = new Date($match[3]);
1885
+						if ($match[2] == "LTE") {
1886
+							$sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
1887
+							$sql_params[$attr . 'date'] = $date->maximumJulianDay();
1888
+						} else {
1889
+							$sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
1890
+							$sql_params[$attr . 'date'] = $date->minimumJulianDay();
1891
+						}
1892
+						if ($sortby == $match[1]) {
1893
+							$sortby = "";
1894
+							$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
1895
+						}
1896
+						unset($attrs[$attr]); // This filter has been fully processed
1897
+					} elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) {
1898
+						// Do nothing, unless you have to
1899
+						if ($match[1] != '' || $sortby == 'NAME') {
1900
+							$sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)";
1901
+							// Search the DB only if there is any name supplied
1902
+							if ($match[1] != "") {
1903
+								$names = explode(" ", $match[1]);
1904
+								foreach ($names as $n => $name) {
1905
+									$sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
1906
+									$sql_params[$attr . 'name' . $n] = $name;
1907
+								}
1891 1908
 							}
1892
-							if ($sortby == $match[1]) {
1909
+							// Let the DB do the name sorting even when no name was entered
1910
+							if ($sortby == "NAME") {
1893 1911
 								$sortby = "";
1894
-								$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
1912
+								$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
1895 1913
 							}
1896
-							unset($attrs[$attr]); // This filter has been fully processed
1897
-						} elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) {
1898
-							// Do nothing, unless you have to
1899
-							if ($match[1] != '' || $sortby == 'NAME') {
1900
-								$sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)";
1901
-								// Search the DB only if there is any name supplied
1902
-								if ($match[1] != "") {
1903
-									$names = explode(" ", $match[1]);
1904
-									foreach ($names as $n => $name) {
1905
-										$sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
1906
-										$sql_params[$attr . 'name' . $n] = $name;
1907
-									}
1908
-								}
1909
-								// Let the DB do the name sorting even when no name was entered
1910
-								if ($sortby == "NAME") {
1911
-									$sortby = "";
1912
-									$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
1913
-								}
1914
-							}
1915
-							unset($attrs[$attr]); // This filter has been fully processed
1916
-						} elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) {
1917
-							$sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom";
1918
-							// PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
1919
-							$sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]);
1920
-							unset($attrs[$attr]); // This filter has been fully processed
1921
-						} elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
1922
-							$sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)";
1923
-							$sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)";
1924
-							$sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
1925
-							$sql_params[$attr . 'place'] = $match[1];
1926
-							// Don't unset this filter. This is just initial filtering
1927
-						} elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) {
1928
-							$sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
1929
-							$sql_params[$attr . 'contains1'] = $match[1];
1930
-							$sql_params[$attr . 'contains2'] = $match[2];
1931
-							$sql_params[$attr . 'contains3'] = $match[3];
1932
-							// Don't unset this filter. This is just initial filtering
1933 1914
 						}
1915
+						unset($attrs[$attr]); // This filter has been fully processed
1916
+					} elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) {
1917
+						$sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom";
1918
+						// PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
1919
+						$sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]);
1920
+						unset($attrs[$attr]); // This filter has been fully processed
1921
+					} elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
1922
+						$sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)";
1923
+						$sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)";
1924
+						$sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
1925
+						$sql_params[$attr . 'place'] = $match[1];
1926
+						// Don't unset this filter. This is just initial filtering
1927
+					} elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) {
1928
+						$sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
1929
+						$sql_params[$attr . 'contains1'] = $match[1];
1930
+						$sql_params[$attr . 'contains2'] = $match[2];
1931
+						$sql_params[$attr . 'contains3'] = $match[3];
1932
+						// Don't unset this filter. This is just initial filtering
1934 1933
 					}
1935 1934
 				}
1935
+			}
1936 1936
 
1937
-				$this->list = array();
1938
-				$rows       = Database::prepare(
1939
-					$sql_select . $sql_join . $sql_where . $sql_order_by
1940
-				)->execute($sql_params)->fetchAll();
1941
-
1942
-				foreach ($rows as $row) {
1943
-					$this->list[] = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
1944
-				}
1945
-				break;
1946
-
1947
-			case 'family':
1948
-				$sql_select   = "SELECT DISTINCT f_id AS xref, f_gedcom AS gedcom FROM `##families`";
1949
-				$sql_join     = "";
1950
-				$sql_where    = " WHERE f_file = :tree_id";
1951
-				$sql_order_by = "";
1952
-				$sql_params   = array('tree_id' => $WT_TREE->getTreeId());
1953
-				foreach ($attrs as $attr => $value) {
1954
-					if (strpos($attr, 'filter') === 0 && $value) {
1955
-						$value = $this->substituteVars($value, false);
1956
-						// Convert the various filters into SQL
1957
-						if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
1958
-							$sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=f_file AND {$attr}.d_gid=f_id)";
1959
-							$sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
1960
-							$sql_params[$attr . 'fact'] = $match[1];
1961
-							$date                       = new Date($match[3]);
1962
-							if ($match[2] == "LTE") {
1963
-								$sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
1964
-								$sql_params[$attr . 'date'] = $date->maximumJulianDay();
1965
-							} else {
1966
-								$sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
1967
-								$sql_params[$attr . 'date'] = $date->minimumJulianDay();
1937
+			$this->list = array();
1938
+			$rows       = Database::prepare(
1939
+				$sql_select . $sql_join . $sql_where . $sql_order_by
1940
+			)->execute($sql_params)->fetchAll();
1941
+
1942
+			foreach ($rows as $row) {
1943
+				$this->list[] = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
1944
+			}
1945
+			break;
1946
+
1947
+		case 'family':
1948
+			$sql_select   = "SELECT DISTINCT f_id AS xref, f_gedcom AS gedcom FROM `##families`";
1949
+			$sql_join     = "";
1950
+			$sql_where    = " WHERE f_file = :tree_id";
1951
+			$sql_order_by = "";
1952
+			$sql_params   = array('tree_id' => $WT_TREE->getTreeId());
1953
+			foreach ($attrs as $attr => $value) {
1954
+				if (strpos($attr, 'filter') === 0 && $value) {
1955
+					$value = $this->substituteVars($value, false);
1956
+					// Convert the various filters into SQL
1957
+					if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
1958
+						$sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=f_file AND {$attr}.d_gid=f_id)";
1959
+						$sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
1960
+						$sql_params[$attr . 'fact'] = $match[1];
1961
+						$date                       = new Date($match[3]);
1962
+						if ($match[2] == "LTE") {
1963
+							$sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
1964
+							$sql_params[$attr . 'date'] = $date->maximumJulianDay();
1965
+						} else {
1966
+							$sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
1967
+							$sql_params[$attr . 'date'] = $date->minimumJulianDay();
1968
+						}
1969
+						if ($sortby == $match[1]) {
1970
+							$sortby = "";
1971
+							$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
1972
+						}
1973
+						unset($attrs[$attr]); // This filter has been fully processed
1974
+					} elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) {
1975
+						$sql_where .= " AND f_gedcom REGEXP :{$attr}gedcom";
1976
+						// PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
1977
+						$sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]);
1978
+						unset($attrs[$attr]); // This filter has been fully processed
1979
+					} elseif (preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) {
1980
+						// Do nothing, unless you have to
1981
+						if ($match[1] != '' || $sortby == 'NAME') {
1982
+							$sql_join .= " JOIN `##name` AS {$attr} ON n_file = f_file AND n_id IN (f_husb, f_wife)";
1983
+							// Search the DB only if there is any name supplied
1984
+							if ($match[1] != "") {
1985
+								$names = explode(" ", $match[1]);
1986
+								foreach ($names as $n => $name) {
1987
+									$sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
1988
+									$sql_params[$attr . 'name' . $n] = $name;
1989
+								}
1968 1990
 							}
1969
-							if ($sortby == $match[1]) {
1991
+							// Let the DB do the name sorting even when no name was entered
1992
+							if ($sortby == "NAME") {
1970 1993
 								$sortby = "";
1971
-								$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
1972
-							}
1973
-							unset($attrs[$attr]); // This filter has been fully processed
1974
-						} elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) {
1975
-							$sql_where .= " AND f_gedcom REGEXP :{$attr}gedcom";
1976
-							// PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
1977
-							$sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]);
1978
-							unset($attrs[$attr]); // This filter has been fully processed
1979
-						} elseif (preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) {
1980
-							// Do nothing, unless you have to
1981
-							if ($match[1] != '' || $sortby == 'NAME') {
1982
-								$sql_join .= " JOIN `##name` AS {$attr} ON n_file = f_file AND n_id IN (f_husb, f_wife)";
1983
-								// Search the DB only if there is any name supplied
1984
-								if ($match[1] != "") {
1985
-									$names = explode(" ", $match[1]);
1986
-									foreach ($names as $n => $name) {
1987
-										$sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
1988
-										$sql_params[$attr . 'name' . $n] = $name;
1989
-									}
1990
-								}
1991
-								// Let the DB do the name sorting even when no name was entered
1992
-								if ($sortby == "NAME") {
1993
-									$sortby = "";
1994
-									$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
1995
-								}
1994
+								$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
1996 1995
 							}
1997
-							unset($attrs[$attr]); // This filter has been fully processed
1998
-
1999
-						} elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
2000
-							$sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file=f_file)";
2001
-							$sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid=f_id)";
2002
-							$sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
2003
-							$sql_params[$attr . 'place'] = $match[1];
2004
-							// Don't unset this filter. This is just initial filtering
2005
-						} elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) {
2006
-							$sql_where .= " AND f_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
2007
-							$sql_params[$attr . 'contains1'] = $match[1];
2008
-							$sql_params[$attr . 'contains2'] = $match[2];
2009
-							$sql_params[$attr . 'contains3'] = $match[3];
2010
-							// Don't unset this filter. This is just initial filtering
2011 1996
 						}
1997
+						unset($attrs[$attr]); // This filter has been fully processed
1998
+
1999
+					} elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
2000
+						$sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file=f_file)";
2001
+						$sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid=f_id)";
2002
+						$sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
2003
+						$sql_params[$attr . 'place'] = $match[1];
2004
+						// Don't unset this filter. This is just initial filtering
2005
+					} elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) {
2006
+						$sql_where .= " AND f_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
2007
+						$sql_params[$attr . 'contains1'] = $match[1];
2008
+						$sql_params[$attr . 'contains2'] = $match[2];
2009
+						$sql_params[$attr . 'contains3'] = $match[3];
2010
+						// Don't unset this filter. This is just initial filtering
2012 2011
 					}
2013 2012
 				}
2013
+			}
2014 2014
 
2015
-				$this->list = array();
2016
-				$rows       = Database::prepare(
2017
-					$sql_select . $sql_join . $sql_where . $sql_order_by
2018
-				)->execute($sql_params)->fetchAll();
2015
+			$this->list = array();
2016
+			$rows       = Database::prepare(
2017
+				$sql_select . $sql_join . $sql_where . $sql_order_by
2018
+			)->execute($sql_params)->fetchAll();
2019 2019
 
2020
-				foreach ($rows as $row) {
2021
-					$this->list[] = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
2022
-				}
2023
-				break;
2020
+			foreach ($rows as $row) {
2021
+				$this->list[] = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
2022
+			}
2023
+			break;
2024 2024
 
2025
-			default:
2026
-				throw new \DomainException('Invalid list name: ' . $listname);
2025
+		default:
2026
+			throw new \DomainException('Invalid list name: ' . $listname);
2027 2027
 		}
2028 2028
 
2029 2029
 		$filters  = array();
@@ -2084,17 +2084,17 @@  discard block
 block discarded – undo
2084 2084
 								$searchstr = "1 " . $tag;
2085 2085
 							}
2086 2086
 							switch ($expr) {
2087
-								case "CONTAINS":
2088
-									if ($t == "PLAC") {
2089
-										$searchstr .= "[^\n]*[, ]*" . $val;
2090
-									} else {
2091
-										$searchstr .= "[^\n]*" . $val;
2092
-									}
2093
-									$filters[] = $searchstr;
2094
-									break;
2095
-								default:
2096
-									$filters2[] = array("tag" => $tag, "expr" => $expr, "val" => $val);
2097
-									break;
2087
+							case "CONTAINS":
2088
+								if ($t == "PLAC") {
2089
+									$searchstr .= "[^\n]*[, ]*" . $val;
2090
+								} else {
2091
+									$searchstr .= "[^\n]*" . $val;
2092
+								}
2093
+								$filters[] = $searchstr;
2094
+								break;
2095
+							default:
2096
+								$filters2[] = array("tag" => $tag, "expr" => $expr, "val" => $val);
2097
+								break;
2098 2098
 							}
2099 2099
 						}
2100 2100
 					}
@@ -2138,31 +2138,31 @@  discard block
 block discarded – undo
2138 2138
 						}
2139 2139
 
2140 2140
 						switch ($expr) {
2141
-							case "GTE":
2142
-								if ($t == "DATE") {
2143
-									$date1 = new Date($v);
2144
-									$date2 = new Date($val);
2145
-									$keep  = (Date::compare($date1, $date2) >= 0);
2146
-								} elseif ($val >= $v) {
2147
-									$keep = true;
2148
-								}
2149
-								break;
2150
-							case "LTE":
2151
-								if ($t == "DATE") {
2152
-									$date1 = new Date($v);
2153
-									$date2 = new Date($val);
2154
-									$keep  = (Date::compare($date1, $date2) <= 0);
2155
-								} elseif ($val >= $v) {
2156
-									$keep = true;
2157
-								}
2158
-								break;
2159
-							default:
2160
-								if ($v == $val) {
2161
-									$keep = true;
2162
-								} else {
2163
-									$keep = false;
2164
-								}
2165
-								break;
2141
+						case "GTE":
2142
+							if ($t == "DATE") {
2143
+								$date1 = new Date($v);
2144
+								$date2 = new Date($val);
2145
+								$keep  = (Date::compare($date1, $date2) >= 0);
2146
+							} elseif ($val >= $v) {
2147
+								$keep = true;
2148
+							}
2149
+							break;
2150
+						case "LTE":
2151
+							if ($t == "DATE") {
2152
+								$date1 = new Date($v);
2153
+								$date2 = new Date($val);
2154
+								$keep  = (Date::compare($date1, $date2) <= 0);
2155
+							} elseif ($val >= $v) {
2156
+								$keep = true;
2157
+							}
2158
+							break;
2159
+						default:
2160
+							if ($v == $val) {
2161
+								$keep = true;
2162
+							} else {
2163
+								$keep = false;
2164
+							}
2165
+							break;
2166 2166
 						}
2167 2167
 					}
2168 2168
 				}
@@ -2174,26 +2174,26 @@  discard block
 block discarded – undo
2174 2174
 		}
2175 2175
 
2176 2176
 		switch ($sortby) {
2177
-			case 'NAME':
2178
-				uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare');
2179
-				break;
2180
-			case 'CHAN':
2181
-				uasort($this->list, function (GedcomRecord $x, GedcomRecord $y) {
2182
-					return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true);
2183
-				});
2184
-				break;
2185
-			case 'BIRT:DATE':
2186
-				uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate');
2187
-				break;
2188
-			case 'DEAT:DATE':
2189
-				uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate');
2190
-				break;
2191
-			case 'MARR:DATE':
2192
-				uasort($this->list, '\Fisharebest\Webtrees\Family::compareMarrDate');
2193
-				break;
2194
-			default:
2195
-				// unsorted or already sorted by SQL
2196
-				break;
2177
+		case 'NAME':
2178
+			uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare');
2179
+			break;
2180
+		case 'CHAN':
2181
+			uasort($this->list, function (GedcomRecord $x, GedcomRecord $y) {
2182
+				return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true);
2183
+			});
2184
+			break;
2185
+		case 'BIRT:DATE':
2186
+			uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate');
2187
+			break;
2188
+		case 'DEAT:DATE':
2189
+			uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate');
2190
+			break;
2191
+		case 'MARR:DATE':
2192
+			uasort($this->list, '\Fisharebest\Webtrees\Family::compareMarrDate');
2193
+			break;
2194
+		default:
2195
+			// unsorted or already sorted by SQL
2196
+			break;
2197 2197
 		}
2198 2198
 
2199 2199
 		array_push($this->repeats_stack, array($this->repeats, $this->repeat_bytes));
@@ -2344,88 +2344,88 @@  discard block
 block discarded – undo
2344 2344
 		if (!empty($person)) {
2345 2345
 			$this->list[$id] = $person;
2346 2346
 			switch ($group) {
2347
-				case "child-family":
2348
-					foreach ($person->getChildFamilies() as $family) {
2349
-						$husband = $family->getHusband();
2350
-						$wife    = $family->getWife();
2351
-						if (!empty($husband)) {
2352
-							$this->list[$husband->getXref()] = $husband;
2353
-						}
2354
-						if (!empty($wife)) {
2355
-							$this->list[$wife->getXref()] = $wife;
2356
-						}
2357
-						$children = $family->getChildren();
2358
-						foreach ($children as $child) {
2359
-							if (!empty($child)) {
2360
-								$this->list[$child->getXref()] = $child;
2361
-							}
2362
-						}
2347
+			case "child-family":
2348
+				foreach ($person->getChildFamilies() as $family) {
2349
+					$husband = $family->getHusband();
2350
+					$wife    = $family->getWife();
2351
+					if (!empty($husband)) {
2352
+						$this->list[$husband->getXref()] = $husband;
2363 2353
 					}
2364
-					break;
2365
-				case "spouse-family":
2366
-					foreach ($person->getSpouseFamilies() as $family) {
2367
-						$husband = $family->getHusband();
2368
-						$wife    = $family->getWife();
2369
-						if (!empty($husband)) {
2370
-							$this->list[$husband->getXref()] = $husband;
2371
-						}
2372
-						if (!empty($wife)) {
2373
-							$this->list[$wife->getXref()] = $wife;
2354
+					if (!empty($wife)) {
2355
+						$this->list[$wife->getXref()] = $wife;
2356
+					}
2357
+					$children = $family->getChildren();
2358
+					foreach ($children as $child) {
2359
+						if (!empty($child)) {
2360
+							$this->list[$child->getXref()] = $child;
2374 2361
 						}
2375
-						$children = $family->getChildren();
2376
-						foreach ($children as $child) {
2377
-							if (!empty($child)) {
2378
-								$this->list[$child->getXref()] = $child;
2379
-							}
2362
+					}
2363
+				}
2364
+				break;
2365
+			case "spouse-family":
2366
+				foreach ($person->getSpouseFamilies() as $family) {
2367
+					$husband = $family->getHusband();
2368
+					$wife    = $family->getWife();
2369
+					if (!empty($husband)) {
2370
+						$this->list[$husband->getXref()] = $husband;
2371
+					}
2372
+					if (!empty($wife)) {
2373
+						$this->list[$wife->getXref()] = $wife;
2374
+					}
2375
+					$children = $family->getChildren();
2376
+					foreach ($children as $child) {
2377
+						if (!empty($child)) {
2378
+							$this->list[$child->getXref()] = $child;
2380 2379
 						}
2381 2380
 					}
2382
-					break;
2383
-				case "direct-ancestors":
2384
-					$this->addAncestors($this->list, $id, false, $maxgen);
2385
-					break;
2386
-				case "ancestors":
2387
-					$this->addAncestors($this->list, $id, true, $maxgen);
2388
-					break;
2389
-				case "descendants":
2390
-					$this->list[$id]->generation = 1;
2391
-					$this->addDescendancy($this->list, $id, false, $maxgen);
2392
-					break;
2393
-				case "all":
2394
-					$this->addAncestors($this->list, $id, true, $maxgen);
2395
-					$this->addDescendancy($this->list, $id, true, $maxgen);
2396
-					break;
2381
+				}
2382
+				break;
2383
+			case "direct-ancestors":
2384
+				$this->addAncestors($this->list, $id, false, $maxgen);
2385
+				break;
2386
+			case "ancestors":
2387
+				$this->addAncestors($this->list, $id, true, $maxgen);
2388
+				break;
2389
+			case "descendants":
2390
+				$this->list[$id]->generation = 1;
2391
+				$this->addDescendancy($this->list, $id, false, $maxgen);
2392
+				break;
2393
+			case "all":
2394
+				$this->addAncestors($this->list, $id, true, $maxgen);
2395
+				$this->addDescendancy($this->list, $id, true, $maxgen);
2396
+				break;
2397 2397
 			}
2398 2398
 		}
2399 2399
 
2400 2400
 		switch ($sortby) {
2401
-			case 'NAME':
2402
-				uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare');
2403
-				break;
2404
-			case 'BIRT:DATE':
2405
-				uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate');
2406
-				break;
2407
-			case 'DEAT:DATE':
2408
-				uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate');
2409
-				break;
2410
-			case 'generation':
2411
-				$newarray = array();
2412
-				reset($this->list);
2413
-				$genCounter = 1;
2414
-				while (count($newarray) < count($this->list)) {
2415
-					foreach ($this->list as $key => $value) {
2416
-						$this->generation = $value->generation;
2417
-						if ($this->generation == $genCounter) {
2418
-							$newarray[$key]             = new \stdClass;
2419
-							$newarray[$key]->generation = $this->generation;
2420
-						}
2401
+		case 'NAME':
2402
+			uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare');
2403
+			break;
2404
+		case 'BIRT:DATE':
2405
+			uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate');
2406
+			break;
2407
+		case 'DEAT:DATE':
2408
+			uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate');
2409
+			break;
2410
+		case 'generation':
2411
+			$newarray = array();
2412
+			reset($this->list);
2413
+			$genCounter = 1;
2414
+			while (count($newarray) < count($this->list)) {
2415
+				foreach ($this->list as $key => $value) {
2416
+					$this->generation = $value->generation;
2417
+					if ($this->generation == $genCounter) {
2418
+						$newarray[$key]             = new \stdClass;
2419
+						$newarray[$key]->generation = $this->generation;
2421 2420
 					}
2422
-					$genCounter++;
2423 2421
 				}
2424
-				$this->list = $newarray;
2425
-				break;
2426
-			default:
2427
-				// unsorted
2428
-				break;
2422
+				$genCounter++;
2423
+			}
2424
+			$this->list = $newarray;
2425
+			break;
2426
+		default:
2427
+			// unsorted
2428
+			break;
2429 2429
 		}
2430 2430
 		array_push($this->repeats_stack, array($this->repeats, $this->repeat_bytes));
2431 2431
 		$this->repeat_bytes = xml_get_current_line_number($this->parser) + 1;
Please login to merge, or discard this patch.
admin_site_change.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -207,14 +207,14 @@
 block discarded – undo
207 207
 
208 208
 		foreach ($differences as $difference) {
209 209
 			switch ($difference[1]) {
210
-				case MyersDiff::DELETE:
211
-					$diff_lines[] = '<del>' . $difference[0] . '</del>';
212
-					break;
213
-				case MyersDiff::INSERT:
214
-					$diff_lines[] = '<ins>' . $difference[0] . '</ins>';
215
-					break;
216
-				default:
217
-					$diff_lines[] = $difference[0];
210
+			case MyersDiff::DELETE:
211
+				$diff_lines[] = '<del>' . $difference[0] . '</del>';
212
+				break;
213
+			case MyersDiff::INSERT:
214
+				$diff_lines[] = '<ins>' . $difference[0] . '</ins>';
215
+				break;
216
+			default:
217
+				$diff_lines[] = $difference[0];
218 218
 			}
219 219
 		}
220 220
 
Please login to merge, or discard this patch.