@@ -31,451 +31,451 @@ |
||
31 | 31 | * The clippings cart. |
32 | 32 | */ |
33 | 33 | class ClippingsCartController { |
34 | - /** @var string Data to be downloaded. */ |
|
35 | - private $download_data; |
|
36 | - |
|
37 | - /** @var string[] List of files to include */ |
|
38 | - private $media_list; |
|
39 | - |
|
40 | - /** @var string The type of the record being added */ |
|
41 | - public $type; |
|
42 | - |
|
43 | - /** @var string The XREF of the record being added */ |
|
44 | - public $id; |
|
45 | - |
|
46 | - /** @var string Whether to include media files for media objects */ |
|
47 | - private $IncludeMedia; |
|
48 | - |
|
49 | - /** @var string The media path (if any) to prefix to the filenames */ |
|
50 | - public $conv_path; |
|
51 | - |
|
52 | - /** @var string The privacy level to apply to the download */ |
|
53 | - private $privatize_export; |
|
54 | - |
|
55 | - /** @var string Whether to download as ZIP file */ |
|
56 | - private $Zip; |
|
57 | - |
|
58 | - /** @var int The number of ancestor generations (individuals) to add */ |
|
59 | - public $level1; |
|
60 | - |
|
61 | - /** @var int The number of ancestor generations (families) to add */ |
|
62 | - public $level2; |
|
63 | - |
|
64 | - /** @var int The number of descendent generations to add */ |
|
65 | - public $level3; |
|
66 | - |
|
67 | - /** @var string[][] The contents of the cart */ |
|
68 | - private $cart; |
|
69 | - |
|
70 | - /** |
|
71 | - * Create the clippings controller |
|
72 | - */ |
|
73 | - public function __construct() { |
|
74 | - global $WT_TREE; |
|
75 | - |
|
76 | - // Our cart is an array of items in the session |
|
77 | - $this->cart = Session::get('cart', array()); |
|
78 | - |
|
79 | - if (!array_key_exists($WT_TREE->getTreeId(), $this->cart)) { |
|
80 | - $this->cart[$WT_TREE->getTreeId()] = array(); |
|
81 | - } |
|
82 | - |
|
83 | - $this->action = Filter::get('action'); |
|
84 | - $this->id = Filter::get('id'); |
|
85 | - $convert = Filter::get('convert', 'yes|no', 'no'); |
|
86 | - $this->Zip = Filter::get('Zip'); |
|
87 | - $this->IncludeMedia = Filter::get('IncludeMedia'); |
|
88 | - $this->conv_path = Filter::get('conv_path'); |
|
89 | - $this->privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor'); |
|
90 | - $this->level1 = Filter::getInteger('level1'); |
|
91 | - $this->level2 = Filter::getInteger('level2'); |
|
92 | - $this->level3 = Filter::getInteger('level3'); |
|
93 | - $others = Filter::get('others'); |
|
94 | - $this->type = Filter::get('type'); |
|
95 | - |
|
96 | - if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) { |
|
97 | - $this->privatize_export = 'visitor'; |
|
98 | - } |
|
99 | - if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) { |
|
100 | - $this->privatize_export = 'visitor'; |
|
101 | - } |
|
102 | - |
|
103 | - if ($this->action === 'add') { |
|
104 | - if (empty($this->type) && !empty($this->id)) { |
|
105 | - $obj = GedcomRecord::getInstance($this->id, $WT_TREE); |
|
106 | - if ($obj) { |
|
107 | - $this->type = $obj::RECORD_TYPE; |
|
108 | - } else { |
|
109 | - $this->type = ''; |
|
110 | - $this->id = ''; |
|
111 | - $this->action = ''; |
|
112 | - } |
|
113 | - } elseif (empty($this->id)) { |
|
114 | - $this->action = ''; |
|
115 | - } |
|
116 | - if (!empty($this->id) && $this->type !== 'FAM' && $this->type !== 'INDI' && $this->type !== 'SOUR') { |
|
117 | - $this->action = 'add1'; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - if ($this->action === 'add1') { |
|
122 | - $obj = GedcomRecord::getInstance($this->id, $WT_TREE); |
|
123 | - $this->addClipping($obj); |
|
124 | - if ($this->type === 'SOUR') { |
|
125 | - if ($others === 'linked') { |
|
126 | - foreach ($obj->linkedIndividuals('SOUR') as $indi) { |
|
127 | - $this->addClipping($indi); |
|
128 | - } |
|
129 | - foreach ($obj->linkedFamilies('SOUR') as $fam) { |
|
130 | - $this->addClipping($fam); |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
134 | - if ($this->type === 'FAM') { |
|
135 | - if ($others === 'parents') { |
|
136 | - $this->addClipping($obj->getHusband()); |
|
137 | - $this->addClipping($obj->getWife()); |
|
138 | - } elseif ($others === "members") { |
|
139 | - $this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE)); |
|
140 | - } elseif ($others === "descendants") { |
|
141 | - $this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE)); |
|
142 | - } |
|
143 | - } elseif ($this->type === 'INDI') { |
|
144 | - if ($others === 'parents') { |
|
145 | - foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) { |
|
146 | - $this->addFamilyMembers($family); |
|
147 | - } |
|
148 | - } elseif ($others === 'ancestors') { |
|
149 | - $this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1); |
|
150 | - } elseif ($others === 'ancestorsfamilies') { |
|
151 | - $this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2); |
|
152 | - } elseif ($others === 'members') { |
|
153 | - foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { |
|
154 | - $this->addFamilyMembers($family); |
|
155 | - } |
|
156 | - } elseif ($others === 'descendants') { |
|
157 | - foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { |
|
158 | - $this->addClipping($family); |
|
159 | - $this->addFamilyDescendancy($family, $this->level3); |
|
160 | - } |
|
161 | - } |
|
162 | - uksort($this->cart[$WT_TREE->getTreeId()], array($this, 'compareClippings')); |
|
163 | - } |
|
164 | - } elseif ($this->action === 'remove') { |
|
165 | - unset($this->cart[$WT_TREE->getTreeId()][$this->id]); |
|
166 | - } elseif ($this->action === 'empty') { |
|
167 | - $this->cart[$WT_TREE->getTreeId()] = array(); |
|
168 | - } elseif ($this->action === 'download') { |
|
169 | - $media = array(); |
|
170 | - $mediacount = 0; |
|
171 | - $filetext = FunctionsExport::gedcomHeader($WT_TREE); |
|
172 | - // Include SUBM/SUBN records, if they exist |
|
173 | - $subn = |
|
174 | - Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") |
|
175 | - ->execute(array('SUBN', $WT_TREE->getTreeId())) |
|
176 | - ->fetchOne(); |
|
177 | - if ($subn) { |
|
178 | - $filetext .= $subn . "\n"; |
|
179 | - } |
|
180 | - $subm = |
|
181 | - Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") |
|
182 | - ->execute(array('SUBM', $WT_TREE->getTreeId())) |
|
183 | - ->fetchOne(); |
|
184 | - if ($subm) { |
|
185 | - $filetext .= $subm . "\n"; |
|
186 | - } |
|
187 | - if ($convert === "yes") { |
|
188 | - $filetext = str_replace("UTF-8", "ANSI", $filetext); |
|
189 | - $filetext = utf8_decode($filetext); |
|
190 | - } |
|
191 | - |
|
192 | - switch ($this->privatize_export) { |
|
193 | - case 'gedadmin': |
|
194 | - $access_level = Auth::PRIV_NONE; |
|
195 | - break; |
|
196 | - case 'user': |
|
197 | - $access_level = Auth::PRIV_USER; |
|
198 | - break; |
|
199 | - case 'visitor': |
|
200 | - $access_level = Auth::PRIV_PRIVATE; |
|
201 | - break; |
|
202 | - case 'none': |
|
203 | - $access_level = Auth::PRIV_HIDE; |
|
204 | - break; |
|
205 | - } |
|
206 | - |
|
207 | - foreach (array_keys($this->cart[$WT_TREE->getTreeId()]) as $xref) { |
|
208 | - $object = GedcomRecord::getInstance($xref, $WT_TREE); |
|
209 | - // The object may have been deleted since we added it to the cart.... |
|
210 | - if ($object) { |
|
211 | - $record = $object->privatizeGedcom($access_level); |
|
212 | - // Remove links to objects that aren't in the cart |
|
213 | - preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
214 | - foreach ($matches as $match) { |
|
215 | - if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
216 | - $record = str_replace($match[0], '', $record); |
|
217 | - } |
|
218 | - } |
|
219 | - preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
220 | - foreach ($matches as $match) { |
|
221 | - if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
222 | - $record = str_replace($match[0], '', $record); |
|
223 | - } |
|
224 | - } |
|
225 | - preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
226 | - foreach ($matches as $match) { |
|
227 | - if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
228 | - $record = str_replace($match[0], '', $record); |
|
229 | - } |
|
230 | - } |
|
231 | - $record = FunctionsExport::convertMediaPath($record, $this->conv_path); |
|
232 | - $savedRecord = $record; // Save this for the "does this file exist" check |
|
233 | - if ($convert === 'yes') { |
|
234 | - $record = utf8_decode($record); |
|
235 | - } |
|
236 | - switch ($object::RECORD_TYPE) { |
|
237 | - case 'INDI': |
|
238 | - $filetext .= $record . "\n"; |
|
239 | - $filetext .= "1 SOUR @WEBTREES@\n"; |
|
240 | - $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
241 | - break; |
|
242 | - case 'FAM': |
|
243 | - $filetext .= $record . "\n"; |
|
244 | - $filetext .= "1 SOUR @WEBTREES@\n"; |
|
245 | - $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
246 | - break; |
|
247 | - case 'SOUR': |
|
248 | - $filetext .= $record . "\n"; |
|
249 | - $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
250 | - break; |
|
251 | - default: |
|
252 | - // This autoloads the PclZip library, so we can use its constants. |
|
253 | - new PclZip(''); |
|
254 | - |
|
255 | - $ft = preg_match_all("/\n\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); |
|
256 | - $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); |
|
257 | - for ($k = 0; $k < $ft; $k++) { |
|
258 | - // Skip external files and non-existant files |
|
259 | - if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { |
|
260 | - $media[$mediacount] = array( |
|
261 | - \PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], |
|
262 | - \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1], |
|
263 | - ); |
|
264 | - $mediacount++; |
|
265 | - } |
|
266 | - } |
|
267 | - $filetext .= trim($record) . "\n"; |
|
268 | - break; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - if ($this->IncludeMedia === "yes") { |
|
274 | - $this->media_list = $media; |
|
275 | - } else { |
|
276 | - $this->media_list = array(); |
|
277 | - } |
|
278 | - $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_BASE_URL . "\n"; |
|
279 | - if ($user_id = $WT_TREE->getPreference('CONTACT_EMAIL')) { |
|
280 | - $user = User::find($user_id); |
|
281 | - $filetext .= "1 AUTH " . $user->getRealName() . "\n"; |
|
282 | - } |
|
283 | - $filetext .= "0 TRLR\n"; |
|
284 | - //-- make sure the preferred line endings are used |
|
285 | - $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext); |
|
286 | - $this->download_data = $filetext; |
|
287 | - $this->downloadClipping(); |
|
288 | - } |
|
289 | - Session::put('cart', $this->cart); |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Loads everything in the clippings cart into a zip file. |
|
294 | - */ |
|
295 | - private function zipCart() { |
|
296 | - $tempFileName = 'clipping' . rand() . '.ged'; |
|
297 | - $fp = fopen(WT_DATA_DIR . $tempFileName, "wb"); |
|
298 | - if ($fp) { |
|
299 | - flock($fp, LOCK_EX); |
|
300 | - fwrite($fp, $this->download_data); |
|
301 | - flock($fp, LOCK_UN); |
|
302 | - fclose($fp); |
|
303 | - $zipName = "clippings" . rand(0, 1500) . ".zip"; |
|
304 | - $fname = WT_DATA_DIR . $zipName; |
|
305 | - $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("d M Y") . "."; |
|
306 | - $archive = new PclZip($fname); |
|
307 | - // add the ged file to the root of the zip file (strip off the data folder) |
|
308 | - $this->media_list[] = array(\PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $tempFileName, \PCLZIP_ATT_FILE_NEW_FULL_NAME => $tempFileName); |
|
309 | - $v_list = $archive->create($this->media_list, \PCLZIP_OPT_COMMENT, $comment); |
|
310 | - if ($v_list == 0) { |
|
311 | - echo "Error : " . $archive->errorInfo(true) . "</td></tr>"; |
|
312 | - } else { |
|
313 | - $openedFile = fopen($fname, "rb"); |
|
314 | - $this->download_data = fread($openedFile, filesize($fname)); |
|
315 | - fclose($openedFile); |
|
316 | - unlink($fname); |
|
317 | - } |
|
318 | - unlink(WT_DATA_DIR . $tempFileName); |
|
319 | - } else { |
|
320 | - echo I18N::translate('The file %s could not be created.', WT_DATA_DIR . $tempFileName) . " " . I18N::translate('Check the access rights on this folder.') . "<br><br>"; |
|
321 | - } |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Brings up the download dialog box and allows the user to download the file |
|
326 | - * based on the options he or she selected. |
|
327 | - */ |
|
328 | - public function downloadClipping() { |
|
329 | - if ($this->IncludeMedia === 'yes' || $this->Zip === 'yes') { |
|
330 | - header('Content-Type: application/zip'); |
|
331 | - header('Content-Disposition: attachment; filename="clipping.zip"'); |
|
332 | - $this->zipCart(); |
|
333 | - } else { |
|
334 | - header('Content-Type: text/plain'); |
|
335 | - header('Content-Disposition: attachment; filename="clipping.ged"'); |
|
336 | - } |
|
337 | - |
|
338 | - header('Content-length: ' . strlen($this->download_data)); |
|
339 | - echo $this->download_data; |
|
340 | - exit; |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Inserts a clipping into the clipping cart |
|
345 | - * |
|
346 | - * @param GedcomRecord $record |
|
347 | - */ |
|
348 | - public function addClipping(GedcomRecord $record) { |
|
349 | - if ($record->canShowName()) { |
|
350 | - $this->cart[$record->getTree()->getTreeId()][$record->getXref()] = true; |
|
351 | - // Add directly linked records |
|
352 | - preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches); |
|
353 | - foreach ($matches[1] as $match) { |
|
354 | - $this->cart[$record->getTree()->getTreeId()][$match] = true; |
|
355 | - } |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Recursive function to traverse the tree |
|
361 | - * |
|
362 | - * @param Family|null $family |
|
363 | - * @param int $level |
|
364 | - */ |
|
365 | - public function addFamilyDescendancy(Family $family = null, $level = PHP_INT_MAX) { |
|
366 | - if (!$family) { |
|
367 | - return; |
|
368 | - } |
|
369 | - foreach ($family->getSpouses() as $spouse) { |
|
370 | - $this->addClipping($spouse); |
|
371 | - } |
|
372 | - foreach ($family->getChildren() as $child) { |
|
373 | - $this->addClipping($child); |
|
374 | - foreach ($child->getSpouseFamilies() as $child_family) { |
|
375 | - $this->addClipping($child_family); |
|
376 | - if ($level > 0) { |
|
377 | - $this->addFamilyDescendancy($child_family, $level - 1); // recurse on the childs family |
|
378 | - } |
|
379 | - } |
|
380 | - } |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Add a family, and all its members |
|
385 | - * |
|
386 | - * @param Family|null $family |
|
387 | - */ |
|
388 | - public function addFamilyMembers(Family $family = null) { |
|
389 | - if (!$family) { |
|
390 | - return; |
|
391 | - } |
|
392 | - $this->addClipping($family); |
|
393 | - foreach ($family->getSpouses() as $spouse) { |
|
394 | - $this->addClipping($spouse); |
|
395 | - } |
|
396 | - foreach ($family->getChildren() as $child) { |
|
397 | - $this->addClipping($child); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * Recursively add direct-line ancestors to cart |
|
403 | - * |
|
404 | - * @param Individual|null $person |
|
405 | - * @param int $level |
|
406 | - */ |
|
407 | - public function addAncestorsToCart(Individual $person = null, $level = 0) { |
|
408 | - if (!$person) { |
|
409 | - return; |
|
410 | - } |
|
411 | - $this->addClipping($person); |
|
412 | - if ($level > 0) { |
|
413 | - foreach ($person->getChildFamilies() as $family) { |
|
414 | - $this->addClipping($family); |
|
415 | - $this->addAncestorsToCart($family->getHusband(), $level - 1); |
|
416 | - $this->addAncestorsToCart($family->getWife(), $level - 1); |
|
417 | - } |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * Recursively adds direct-line ancestors and their families to the cart |
|
423 | - * |
|
424 | - * @param Individual|null $person |
|
425 | - * @param int $level |
|
426 | - */ |
|
427 | - public function addAncestorsToCartFamilies(Individual $person = null, $level = 0) { |
|
428 | - if (!$person) { |
|
429 | - return; |
|
430 | - } |
|
431 | - if ($level > 0) { |
|
432 | - foreach ($person->getChildFamilies() as $family) { |
|
433 | - $this->addFamilyMembers($family); |
|
434 | - $this->addAncestorsToCartFamilies($family->getHusband(), $level - 1); |
|
435 | - $this->addAncestorsToCartFamilies($family->getWife(), $level - 1); |
|
436 | - } |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - /** |
|
441 | - * Helper function to sort records by type/name |
|
442 | - * |
|
443 | - * @param string $a |
|
444 | - * @param string $b |
|
445 | - * |
|
446 | - * @return int |
|
447 | - */ |
|
448 | - private static function compareClippings($a, $b) { |
|
449 | - global $WT_TREE; |
|
450 | - |
|
451 | - $a = GedcomRecord::getInstance($a, $WT_TREE); |
|
452 | - $b = GedcomRecord::getInstance($b, $WT_TREE); |
|
453 | - if ($a && $b) { |
|
454 | - switch ($a::RECORD_TYPE) { |
|
455 | - case 'INDI': $t1 = 1; break; |
|
456 | - case 'FAM': $t1 = 2; break; |
|
457 | - case 'SOUR': $t1 = 3; break; |
|
458 | - case 'REPO': $t1 = 4; break; |
|
459 | - case 'OBJE': $t1 = 5; break; |
|
460 | - case 'NOTE': $t1 = 6; break; |
|
461 | - default: $t1 = 7; break; |
|
462 | - } |
|
463 | - switch ($b::RECORD_TYPE) { |
|
464 | - case 'INDI': $t2 = 1; break; |
|
465 | - case 'FAM': $t2 = 2; break; |
|
466 | - case 'SOUR': $t2 = 3; break; |
|
467 | - case 'REPO': $t2 = 4; break; |
|
468 | - case 'OBJE': $t2 = 5; break; |
|
469 | - case 'NOTE': $t2 = 6; break; |
|
470 | - default: $t2 = 7; break; |
|
471 | - } |
|
472 | - if ($t1 != $t2) { |
|
473 | - return $t1 - $t2; |
|
474 | - } else { |
|
475 | - return GedcomRecord::compare($a, $b); |
|
476 | - } |
|
477 | - } else { |
|
478 | - return 0; |
|
479 | - } |
|
480 | - } |
|
34 | + /** @var string Data to be downloaded. */ |
|
35 | + private $download_data; |
|
36 | + |
|
37 | + /** @var string[] List of files to include */ |
|
38 | + private $media_list; |
|
39 | + |
|
40 | + /** @var string The type of the record being added */ |
|
41 | + public $type; |
|
42 | + |
|
43 | + /** @var string The XREF of the record being added */ |
|
44 | + public $id; |
|
45 | + |
|
46 | + /** @var string Whether to include media files for media objects */ |
|
47 | + private $IncludeMedia; |
|
48 | + |
|
49 | + /** @var string The media path (if any) to prefix to the filenames */ |
|
50 | + public $conv_path; |
|
51 | + |
|
52 | + /** @var string The privacy level to apply to the download */ |
|
53 | + private $privatize_export; |
|
54 | + |
|
55 | + /** @var string Whether to download as ZIP file */ |
|
56 | + private $Zip; |
|
57 | + |
|
58 | + /** @var int The number of ancestor generations (individuals) to add */ |
|
59 | + public $level1; |
|
60 | + |
|
61 | + /** @var int The number of ancestor generations (families) to add */ |
|
62 | + public $level2; |
|
63 | + |
|
64 | + /** @var int The number of descendent generations to add */ |
|
65 | + public $level3; |
|
66 | + |
|
67 | + /** @var string[][] The contents of the cart */ |
|
68 | + private $cart; |
|
69 | + |
|
70 | + /** |
|
71 | + * Create the clippings controller |
|
72 | + */ |
|
73 | + public function __construct() { |
|
74 | + global $WT_TREE; |
|
75 | + |
|
76 | + // Our cart is an array of items in the session |
|
77 | + $this->cart = Session::get('cart', array()); |
|
78 | + |
|
79 | + if (!array_key_exists($WT_TREE->getTreeId(), $this->cart)) { |
|
80 | + $this->cart[$WT_TREE->getTreeId()] = array(); |
|
81 | + } |
|
82 | + |
|
83 | + $this->action = Filter::get('action'); |
|
84 | + $this->id = Filter::get('id'); |
|
85 | + $convert = Filter::get('convert', 'yes|no', 'no'); |
|
86 | + $this->Zip = Filter::get('Zip'); |
|
87 | + $this->IncludeMedia = Filter::get('IncludeMedia'); |
|
88 | + $this->conv_path = Filter::get('conv_path'); |
|
89 | + $this->privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor'); |
|
90 | + $this->level1 = Filter::getInteger('level1'); |
|
91 | + $this->level2 = Filter::getInteger('level2'); |
|
92 | + $this->level3 = Filter::getInteger('level3'); |
|
93 | + $others = Filter::get('others'); |
|
94 | + $this->type = Filter::get('type'); |
|
95 | + |
|
96 | + if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) { |
|
97 | + $this->privatize_export = 'visitor'; |
|
98 | + } |
|
99 | + if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) { |
|
100 | + $this->privatize_export = 'visitor'; |
|
101 | + } |
|
102 | + |
|
103 | + if ($this->action === 'add') { |
|
104 | + if (empty($this->type) && !empty($this->id)) { |
|
105 | + $obj = GedcomRecord::getInstance($this->id, $WT_TREE); |
|
106 | + if ($obj) { |
|
107 | + $this->type = $obj::RECORD_TYPE; |
|
108 | + } else { |
|
109 | + $this->type = ''; |
|
110 | + $this->id = ''; |
|
111 | + $this->action = ''; |
|
112 | + } |
|
113 | + } elseif (empty($this->id)) { |
|
114 | + $this->action = ''; |
|
115 | + } |
|
116 | + if (!empty($this->id) && $this->type !== 'FAM' && $this->type !== 'INDI' && $this->type !== 'SOUR') { |
|
117 | + $this->action = 'add1'; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + if ($this->action === 'add1') { |
|
122 | + $obj = GedcomRecord::getInstance($this->id, $WT_TREE); |
|
123 | + $this->addClipping($obj); |
|
124 | + if ($this->type === 'SOUR') { |
|
125 | + if ($others === 'linked') { |
|
126 | + foreach ($obj->linkedIndividuals('SOUR') as $indi) { |
|
127 | + $this->addClipping($indi); |
|
128 | + } |
|
129 | + foreach ($obj->linkedFamilies('SOUR') as $fam) { |
|
130 | + $this->addClipping($fam); |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | + if ($this->type === 'FAM') { |
|
135 | + if ($others === 'parents') { |
|
136 | + $this->addClipping($obj->getHusband()); |
|
137 | + $this->addClipping($obj->getWife()); |
|
138 | + } elseif ($others === "members") { |
|
139 | + $this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE)); |
|
140 | + } elseif ($others === "descendants") { |
|
141 | + $this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE)); |
|
142 | + } |
|
143 | + } elseif ($this->type === 'INDI') { |
|
144 | + if ($others === 'parents') { |
|
145 | + foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) { |
|
146 | + $this->addFamilyMembers($family); |
|
147 | + } |
|
148 | + } elseif ($others === 'ancestors') { |
|
149 | + $this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1); |
|
150 | + } elseif ($others === 'ancestorsfamilies') { |
|
151 | + $this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2); |
|
152 | + } elseif ($others === 'members') { |
|
153 | + foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { |
|
154 | + $this->addFamilyMembers($family); |
|
155 | + } |
|
156 | + } elseif ($others === 'descendants') { |
|
157 | + foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { |
|
158 | + $this->addClipping($family); |
|
159 | + $this->addFamilyDescendancy($family, $this->level3); |
|
160 | + } |
|
161 | + } |
|
162 | + uksort($this->cart[$WT_TREE->getTreeId()], array($this, 'compareClippings')); |
|
163 | + } |
|
164 | + } elseif ($this->action === 'remove') { |
|
165 | + unset($this->cart[$WT_TREE->getTreeId()][$this->id]); |
|
166 | + } elseif ($this->action === 'empty') { |
|
167 | + $this->cart[$WT_TREE->getTreeId()] = array(); |
|
168 | + } elseif ($this->action === 'download') { |
|
169 | + $media = array(); |
|
170 | + $mediacount = 0; |
|
171 | + $filetext = FunctionsExport::gedcomHeader($WT_TREE); |
|
172 | + // Include SUBM/SUBN records, if they exist |
|
173 | + $subn = |
|
174 | + Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") |
|
175 | + ->execute(array('SUBN', $WT_TREE->getTreeId())) |
|
176 | + ->fetchOne(); |
|
177 | + if ($subn) { |
|
178 | + $filetext .= $subn . "\n"; |
|
179 | + } |
|
180 | + $subm = |
|
181 | + Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") |
|
182 | + ->execute(array('SUBM', $WT_TREE->getTreeId())) |
|
183 | + ->fetchOne(); |
|
184 | + if ($subm) { |
|
185 | + $filetext .= $subm . "\n"; |
|
186 | + } |
|
187 | + if ($convert === "yes") { |
|
188 | + $filetext = str_replace("UTF-8", "ANSI", $filetext); |
|
189 | + $filetext = utf8_decode($filetext); |
|
190 | + } |
|
191 | + |
|
192 | + switch ($this->privatize_export) { |
|
193 | + case 'gedadmin': |
|
194 | + $access_level = Auth::PRIV_NONE; |
|
195 | + break; |
|
196 | + case 'user': |
|
197 | + $access_level = Auth::PRIV_USER; |
|
198 | + break; |
|
199 | + case 'visitor': |
|
200 | + $access_level = Auth::PRIV_PRIVATE; |
|
201 | + break; |
|
202 | + case 'none': |
|
203 | + $access_level = Auth::PRIV_HIDE; |
|
204 | + break; |
|
205 | + } |
|
206 | + |
|
207 | + foreach (array_keys($this->cart[$WT_TREE->getTreeId()]) as $xref) { |
|
208 | + $object = GedcomRecord::getInstance($xref, $WT_TREE); |
|
209 | + // The object may have been deleted since we added it to the cart.... |
|
210 | + if ($object) { |
|
211 | + $record = $object->privatizeGedcom($access_level); |
|
212 | + // Remove links to objects that aren't in the cart |
|
213 | + preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
214 | + foreach ($matches as $match) { |
|
215 | + if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
216 | + $record = str_replace($match[0], '', $record); |
|
217 | + } |
|
218 | + } |
|
219 | + preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
220 | + foreach ($matches as $match) { |
|
221 | + if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
222 | + $record = str_replace($match[0], '', $record); |
|
223 | + } |
|
224 | + } |
|
225 | + preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER); |
|
226 | + foreach ($matches as $match) { |
|
227 | + if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { |
|
228 | + $record = str_replace($match[0], '', $record); |
|
229 | + } |
|
230 | + } |
|
231 | + $record = FunctionsExport::convertMediaPath($record, $this->conv_path); |
|
232 | + $savedRecord = $record; // Save this for the "does this file exist" check |
|
233 | + if ($convert === 'yes') { |
|
234 | + $record = utf8_decode($record); |
|
235 | + } |
|
236 | + switch ($object::RECORD_TYPE) { |
|
237 | + case 'INDI': |
|
238 | + $filetext .= $record . "\n"; |
|
239 | + $filetext .= "1 SOUR @WEBTREES@\n"; |
|
240 | + $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
241 | + break; |
|
242 | + case 'FAM': |
|
243 | + $filetext .= $record . "\n"; |
|
244 | + $filetext .= "1 SOUR @WEBTREES@\n"; |
|
245 | + $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
246 | + break; |
|
247 | + case 'SOUR': |
|
248 | + $filetext .= $record . "\n"; |
|
249 | + $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
250 | + break; |
|
251 | + default: |
|
252 | + // This autoloads the PclZip library, so we can use its constants. |
|
253 | + new PclZip(''); |
|
254 | + |
|
255 | + $ft = preg_match_all("/\n\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); |
|
256 | + $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); |
|
257 | + for ($k = 0; $k < $ft; $k++) { |
|
258 | + // Skip external files and non-existant files |
|
259 | + if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { |
|
260 | + $media[$mediacount] = array( |
|
261 | + \PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], |
|
262 | + \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1], |
|
263 | + ); |
|
264 | + $mediacount++; |
|
265 | + } |
|
266 | + } |
|
267 | + $filetext .= trim($record) . "\n"; |
|
268 | + break; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + if ($this->IncludeMedia === "yes") { |
|
274 | + $this->media_list = $media; |
|
275 | + } else { |
|
276 | + $this->media_list = array(); |
|
277 | + } |
|
278 | + $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_BASE_URL . "\n"; |
|
279 | + if ($user_id = $WT_TREE->getPreference('CONTACT_EMAIL')) { |
|
280 | + $user = User::find($user_id); |
|
281 | + $filetext .= "1 AUTH " . $user->getRealName() . "\n"; |
|
282 | + } |
|
283 | + $filetext .= "0 TRLR\n"; |
|
284 | + //-- make sure the preferred line endings are used |
|
285 | + $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext); |
|
286 | + $this->download_data = $filetext; |
|
287 | + $this->downloadClipping(); |
|
288 | + } |
|
289 | + Session::put('cart', $this->cart); |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Loads everything in the clippings cart into a zip file. |
|
294 | + */ |
|
295 | + private function zipCart() { |
|
296 | + $tempFileName = 'clipping' . rand() . '.ged'; |
|
297 | + $fp = fopen(WT_DATA_DIR . $tempFileName, "wb"); |
|
298 | + if ($fp) { |
|
299 | + flock($fp, LOCK_EX); |
|
300 | + fwrite($fp, $this->download_data); |
|
301 | + flock($fp, LOCK_UN); |
|
302 | + fclose($fp); |
|
303 | + $zipName = "clippings" . rand(0, 1500) . ".zip"; |
|
304 | + $fname = WT_DATA_DIR . $zipName; |
|
305 | + $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("d M Y") . "."; |
|
306 | + $archive = new PclZip($fname); |
|
307 | + // add the ged file to the root of the zip file (strip off the data folder) |
|
308 | + $this->media_list[] = array(\PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $tempFileName, \PCLZIP_ATT_FILE_NEW_FULL_NAME => $tempFileName); |
|
309 | + $v_list = $archive->create($this->media_list, \PCLZIP_OPT_COMMENT, $comment); |
|
310 | + if ($v_list == 0) { |
|
311 | + echo "Error : " . $archive->errorInfo(true) . "</td></tr>"; |
|
312 | + } else { |
|
313 | + $openedFile = fopen($fname, "rb"); |
|
314 | + $this->download_data = fread($openedFile, filesize($fname)); |
|
315 | + fclose($openedFile); |
|
316 | + unlink($fname); |
|
317 | + } |
|
318 | + unlink(WT_DATA_DIR . $tempFileName); |
|
319 | + } else { |
|
320 | + echo I18N::translate('The file %s could not be created.', WT_DATA_DIR . $tempFileName) . " " . I18N::translate('Check the access rights on this folder.') . "<br><br>"; |
|
321 | + } |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Brings up the download dialog box and allows the user to download the file |
|
326 | + * based on the options he or she selected. |
|
327 | + */ |
|
328 | + public function downloadClipping() { |
|
329 | + if ($this->IncludeMedia === 'yes' || $this->Zip === 'yes') { |
|
330 | + header('Content-Type: application/zip'); |
|
331 | + header('Content-Disposition: attachment; filename="clipping.zip"'); |
|
332 | + $this->zipCart(); |
|
333 | + } else { |
|
334 | + header('Content-Type: text/plain'); |
|
335 | + header('Content-Disposition: attachment; filename="clipping.ged"'); |
|
336 | + } |
|
337 | + |
|
338 | + header('Content-length: ' . strlen($this->download_data)); |
|
339 | + echo $this->download_data; |
|
340 | + exit; |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Inserts a clipping into the clipping cart |
|
345 | + * |
|
346 | + * @param GedcomRecord $record |
|
347 | + */ |
|
348 | + public function addClipping(GedcomRecord $record) { |
|
349 | + if ($record->canShowName()) { |
|
350 | + $this->cart[$record->getTree()->getTreeId()][$record->getXref()] = true; |
|
351 | + // Add directly linked records |
|
352 | + preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches); |
|
353 | + foreach ($matches[1] as $match) { |
|
354 | + $this->cart[$record->getTree()->getTreeId()][$match] = true; |
|
355 | + } |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Recursive function to traverse the tree |
|
361 | + * |
|
362 | + * @param Family|null $family |
|
363 | + * @param int $level |
|
364 | + */ |
|
365 | + public function addFamilyDescendancy(Family $family = null, $level = PHP_INT_MAX) { |
|
366 | + if (!$family) { |
|
367 | + return; |
|
368 | + } |
|
369 | + foreach ($family->getSpouses() as $spouse) { |
|
370 | + $this->addClipping($spouse); |
|
371 | + } |
|
372 | + foreach ($family->getChildren() as $child) { |
|
373 | + $this->addClipping($child); |
|
374 | + foreach ($child->getSpouseFamilies() as $child_family) { |
|
375 | + $this->addClipping($child_family); |
|
376 | + if ($level > 0) { |
|
377 | + $this->addFamilyDescendancy($child_family, $level - 1); // recurse on the childs family |
|
378 | + } |
|
379 | + } |
|
380 | + } |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Add a family, and all its members |
|
385 | + * |
|
386 | + * @param Family|null $family |
|
387 | + */ |
|
388 | + public function addFamilyMembers(Family $family = null) { |
|
389 | + if (!$family) { |
|
390 | + return; |
|
391 | + } |
|
392 | + $this->addClipping($family); |
|
393 | + foreach ($family->getSpouses() as $spouse) { |
|
394 | + $this->addClipping($spouse); |
|
395 | + } |
|
396 | + foreach ($family->getChildren() as $child) { |
|
397 | + $this->addClipping($child); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * Recursively add direct-line ancestors to cart |
|
403 | + * |
|
404 | + * @param Individual|null $person |
|
405 | + * @param int $level |
|
406 | + */ |
|
407 | + public function addAncestorsToCart(Individual $person = null, $level = 0) { |
|
408 | + if (!$person) { |
|
409 | + return; |
|
410 | + } |
|
411 | + $this->addClipping($person); |
|
412 | + if ($level > 0) { |
|
413 | + foreach ($person->getChildFamilies() as $family) { |
|
414 | + $this->addClipping($family); |
|
415 | + $this->addAncestorsToCart($family->getHusband(), $level - 1); |
|
416 | + $this->addAncestorsToCart($family->getWife(), $level - 1); |
|
417 | + } |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * Recursively adds direct-line ancestors and their families to the cart |
|
423 | + * |
|
424 | + * @param Individual|null $person |
|
425 | + * @param int $level |
|
426 | + */ |
|
427 | + public function addAncestorsToCartFamilies(Individual $person = null, $level = 0) { |
|
428 | + if (!$person) { |
|
429 | + return; |
|
430 | + } |
|
431 | + if ($level > 0) { |
|
432 | + foreach ($person->getChildFamilies() as $family) { |
|
433 | + $this->addFamilyMembers($family); |
|
434 | + $this->addAncestorsToCartFamilies($family->getHusband(), $level - 1); |
|
435 | + $this->addAncestorsToCartFamilies($family->getWife(), $level - 1); |
|
436 | + } |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + /** |
|
441 | + * Helper function to sort records by type/name |
|
442 | + * |
|
443 | + * @param string $a |
|
444 | + * @param string $b |
|
445 | + * |
|
446 | + * @return int |
|
447 | + */ |
|
448 | + private static function compareClippings($a, $b) { |
|
449 | + global $WT_TREE; |
|
450 | + |
|
451 | + $a = GedcomRecord::getInstance($a, $WT_TREE); |
|
452 | + $b = GedcomRecord::getInstance($b, $WT_TREE); |
|
453 | + if ($a && $b) { |
|
454 | + switch ($a::RECORD_TYPE) { |
|
455 | + case 'INDI': $t1 = 1; break; |
|
456 | + case 'FAM': $t1 = 2; break; |
|
457 | + case 'SOUR': $t1 = 3; break; |
|
458 | + case 'REPO': $t1 = 4; break; |
|
459 | + case 'OBJE': $t1 = 5; break; |
|
460 | + case 'NOTE': $t1 = 6; break; |
|
461 | + default: $t1 = 7; break; |
|
462 | + } |
|
463 | + switch ($b::RECORD_TYPE) { |
|
464 | + case 'INDI': $t2 = 1; break; |
|
465 | + case 'FAM': $t2 = 2; break; |
|
466 | + case 'SOUR': $t2 = 3; break; |
|
467 | + case 'REPO': $t2 = 4; break; |
|
468 | + case 'OBJE': $t2 = 5; break; |
|
469 | + case 'NOTE': $t2 = 6; break; |
|
470 | + default: $t2 = 7; break; |
|
471 | + } |
|
472 | + if ($t1 != $t2) { |
|
473 | + return $t1 - $t2; |
|
474 | + } else { |
|
475 | + return GedcomRecord::compare($a, $b); |
|
476 | + } |
|
477 | + } else { |
|
478 | + return 0; |
|
479 | + } |
|
480 | + } |
|
481 | 481 | } |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | switch ($this->privatize_export) { |
193 | - case 'gedadmin': |
|
194 | - $access_level = Auth::PRIV_NONE; |
|
195 | - break; |
|
196 | - case 'user': |
|
197 | - $access_level = Auth::PRIV_USER; |
|
198 | - break; |
|
199 | - case 'visitor': |
|
200 | - $access_level = Auth::PRIV_PRIVATE; |
|
201 | - break; |
|
202 | - case 'none': |
|
203 | - $access_level = Auth::PRIV_HIDE; |
|
204 | - break; |
|
193 | + case 'gedadmin': |
|
194 | + $access_level = Auth::PRIV_NONE; |
|
195 | + break; |
|
196 | + case 'user': |
|
197 | + $access_level = Auth::PRIV_USER; |
|
198 | + break; |
|
199 | + case 'visitor': |
|
200 | + $access_level = Auth::PRIV_PRIVATE; |
|
201 | + break; |
|
202 | + case 'none': |
|
203 | + $access_level = Auth::PRIV_HIDE; |
|
204 | + break; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | foreach (array_keys($this->cart[$WT_TREE->getTreeId()]) as $xref) { |
@@ -234,38 +234,38 @@ discard block |
||
234 | 234 | $record = utf8_decode($record); |
235 | 235 | } |
236 | 236 | switch ($object::RECORD_TYPE) { |
237 | - case 'INDI': |
|
238 | - $filetext .= $record . "\n"; |
|
239 | - $filetext .= "1 SOUR @WEBTREES@\n"; |
|
240 | - $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
241 | - break; |
|
242 | - case 'FAM': |
|
243 | - $filetext .= $record . "\n"; |
|
244 | - $filetext .= "1 SOUR @WEBTREES@\n"; |
|
245 | - $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
246 | - break; |
|
247 | - case 'SOUR': |
|
248 | - $filetext .= $record . "\n"; |
|
249 | - $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
250 | - break; |
|
251 | - default: |
|
252 | - // This autoloads the PclZip library, so we can use its constants. |
|
253 | - new PclZip(''); |
|
254 | - |
|
255 | - $ft = preg_match_all("/\n\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); |
|
256 | - $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); |
|
257 | - for ($k = 0; $k < $ft; $k++) { |
|
258 | - // Skip external files and non-existant files |
|
259 | - if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { |
|
260 | - $media[$mediacount] = array( |
|
261 | - \PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], |
|
262 | - \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1], |
|
263 | - ); |
|
264 | - $mediacount++; |
|
265 | - } |
|
266 | - } |
|
267 | - $filetext .= trim($record) . "\n"; |
|
268 | - break; |
|
237 | + case 'INDI': |
|
238 | + $filetext .= $record . "\n"; |
|
239 | + $filetext .= "1 SOUR @WEBTREES@\n"; |
|
240 | + $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
241 | + break; |
|
242 | + case 'FAM': |
|
243 | + $filetext .= $record . "\n"; |
|
244 | + $filetext .= "1 SOUR @WEBTREES@\n"; |
|
245 | + $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
246 | + break; |
|
247 | + case 'SOUR': |
|
248 | + $filetext .= $record . "\n"; |
|
249 | + $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n"; |
|
250 | + break; |
|
251 | + default: |
|
252 | + // This autoloads the PclZip library, so we can use its constants. |
|
253 | + new PclZip(''); |
|
254 | + |
|
255 | + $ft = preg_match_all("/\n\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); |
|
256 | + $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); |
|
257 | + for ($k = 0; $k < $ft; $k++) { |
|
258 | + // Skip external files and non-existant files |
|
259 | + if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { |
|
260 | + $media[$mediacount] = array( |
|
261 | + \PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], |
|
262 | + \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1], |
|
263 | + ); |
|
264 | + $mediacount++; |
|
265 | + } |
|
266 | + } |
|
267 | + $filetext .= trim($record) . "\n"; |
|
268 | + break; |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | } |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | $b = GedcomRecord::getInstance($b, $WT_TREE); |
453 | 453 | if ($a && $b) { |
454 | 454 | switch ($a::RECORD_TYPE) { |
455 | - case 'INDI': $t1 = 1; break; |
|
456 | - case 'FAM': $t1 = 2; break; |
|
457 | - case 'SOUR': $t1 = 3; break; |
|
458 | - case 'REPO': $t1 = 4; break; |
|
459 | - case 'OBJE': $t1 = 5; break; |
|
460 | - case 'NOTE': $t1 = 6; break; |
|
461 | - default: $t1 = 7; break; |
|
455 | + case 'INDI': $t1 = 1; break; |
|
456 | + case 'FAM': $t1 = 2; break; |
|
457 | + case 'SOUR': $t1 = 3; break; |
|
458 | + case 'REPO': $t1 = 4; break; |
|
459 | + case 'OBJE': $t1 = 5; break; |
|
460 | + case 'NOTE': $t1 = 6; break; |
|
461 | + default: $t1 = 7; break; |
|
462 | 462 | } |
463 | 463 | switch ($b::RECORD_TYPE) { |
464 | - case 'INDI': $t2 = 1; break; |
|
465 | - case 'FAM': $t2 = 2; break; |
|
466 | - case 'SOUR': $t2 = 3; break; |
|
467 | - case 'REPO': $t2 = 4; break; |
|
468 | - case 'OBJE': $t2 = 5; break; |
|
469 | - case 'NOTE': $t2 = 6; break; |
|
470 | - default: $t2 = 7; break; |
|
464 | + case 'INDI': $t2 = 1; break; |
|
465 | + case 'FAM': $t2 = 2; break; |
|
466 | + case 'SOUR': $t2 = 3; break; |
|
467 | + case 'REPO': $t2 = 4; break; |
|
468 | + case 'OBJE': $t2 = 5; break; |
|
469 | + case 'NOTE': $t2 = 6; break; |
|
470 | + default: $t2 = 7; break; |
|
471 | 471 | } |
472 | 472 | if ($t1 != $t2) { |
473 | 473 | return $t1 - $t2; |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * The clippings cart. |
32 | 32 | */ |
33 | -class ClippingsCartController { |
|
33 | +class ClippingsCartController |
|
34 | +{ |
|
34 | 35 | /** @var string Data to be downloaded. */ |
35 | 36 | private $download_data; |
36 | 37 | |
@@ -70,7 +71,8 @@ discard block |
||
70 | 71 | /** |
71 | 72 | * Create the clippings controller |
72 | 73 | */ |
73 | - public function __construct() { |
|
74 | + public function __construct() |
|
75 | + { |
|
74 | 76 | global $WT_TREE; |
75 | 77 | |
76 | 78 | // Our cart is an array of items in the session |
@@ -292,7 +294,8 @@ discard block |
||
292 | 294 | /** |
293 | 295 | * Loads everything in the clippings cart into a zip file. |
294 | 296 | */ |
295 | - private function zipCart() { |
|
297 | + private function zipCart() |
|
298 | + { |
|
296 | 299 | $tempFileName = 'clipping' . rand() . '.ged'; |
297 | 300 | $fp = fopen(WT_DATA_DIR . $tempFileName, "wb"); |
298 | 301 | if ($fp) { |
@@ -325,7 +328,8 @@ discard block |
||
325 | 328 | * Brings up the download dialog box and allows the user to download the file |
326 | 329 | * based on the options he or she selected. |
327 | 330 | */ |
328 | - public function downloadClipping() { |
|
331 | + public function downloadClipping() |
|
332 | + { |
|
329 | 333 | if ($this->IncludeMedia === 'yes' || $this->Zip === 'yes') { |
330 | 334 | header('Content-Type: application/zip'); |
331 | 335 | header('Content-Disposition: attachment; filename="clipping.zip"'); |
@@ -345,7 +349,8 @@ discard block |
||
345 | 349 | * |
346 | 350 | * @param GedcomRecord $record |
347 | 351 | */ |
348 | - public function addClipping(GedcomRecord $record) { |
|
352 | + public function addClipping(GedcomRecord $record) |
|
353 | + { |
|
349 | 354 | if ($record->canShowName()) { |
350 | 355 | $this->cart[$record->getTree()->getTreeId()][$record->getXref()] = true; |
351 | 356 | // Add directly linked records |
@@ -362,7 +367,8 @@ discard block |
||
362 | 367 | * @param Family|null $family |
363 | 368 | * @param int $level |
364 | 369 | */ |
365 | - public function addFamilyDescendancy(Family $family = null, $level = PHP_INT_MAX) { |
|
370 | + public function addFamilyDescendancy(Family $family = null, $level = PHP_INT_MAX) |
|
371 | + { |
|
366 | 372 | if (!$family) { |
367 | 373 | return; |
368 | 374 | } |
@@ -385,7 +391,8 @@ discard block |
||
385 | 391 | * |
386 | 392 | * @param Family|null $family |
387 | 393 | */ |
388 | - public function addFamilyMembers(Family $family = null) { |
|
394 | + public function addFamilyMembers(Family $family = null) |
|
395 | + { |
|
389 | 396 | if (!$family) { |
390 | 397 | return; |
391 | 398 | } |
@@ -404,7 +411,8 @@ discard block |
||
404 | 411 | * @param Individual|null $person |
405 | 412 | * @param int $level |
406 | 413 | */ |
407 | - public function addAncestorsToCart(Individual $person = null, $level = 0) { |
|
414 | + public function addAncestorsToCart(Individual $person = null, $level = 0) |
|
415 | + { |
|
408 | 416 | if (!$person) { |
409 | 417 | return; |
410 | 418 | } |
@@ -424,7 +432,8 @@ discard block |
||
424 | 432 | * @param Individual|null $person |
425 | 433 | * @param int $level |
426 | 434 | */ |
427 | - public function addAncestorsToCartFamilies(Individual $person = null, $level = 0) { |
|
435 | + public function addAncestorsToCartFamilies(Individual $person = null, $level = 0) |
|
436 | + { |
|
428 | 437 | if (!$person) { |
429 | 438 | return; |
430 | 439 | } |
@@ -445,7 +454,8 @@ discard block |
||
445 | 454 | * |
446 | 455 | * @return int |
447 | 456 | */ |
448 | - private static function compareClippings($a, $b) { |
|
457 | + private static function compareClippings($a, $b) |
|
458 | + { |
|
449 | 459 | global $WT_TREE; |
450 | 460 | |
451 | 461 | $a = GedcomRecord::getInstance($a, $WT_TREE); |
@@ -27,104 +27,104 @@ |
||
27 | 27 | * Class LoggedInUsersModule |
28 | 28 | */ |
29 | 29 | class LoggedInUsersModule extends AbstractModule implements ModuleBlockInterface { |
30 | - /** {@inheritdoc} */ |
|
31 | - public function getTitle() { |
|
32 | - return /* I18N: Name of a module. (A list of users who are online now) */ I18N::translate('Who is online'); |
|
33 | - } |
|
30 | + /** {@inheritdoc} */ |
|
31 | + public function getTitle() { |
|
32 | + return /* I18N: Name of a module. (A list of users who are online now) */ I18N::translate('Who is online'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** {@inheritdoc} */ |
|
36 | - public function getDescription() { |
|
37 | - return /* I18N: Description of the “Who is online” module */ I18N::translate('A list of users and visitors who are currently online.'); |
|
38 | - } |
|
35 | + /** {@inheritdoc} */ |
|
36 | + public function getDescription() { |
|
37 | + return /* I18N: Description of the “Who is online” module */ I18N::translate('A list of users and visitors who are currently online.'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Generate the HTML content of this block. |
|
42 | - * |
|
43 | - * @param int $block_id |
|
44 | - * @param bool $template |
|
45 | - * @param string[] $cfg |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
50 | - global $WT_TREE; |
|
40 | + /** |
|
41 | + * Generate the HTML content of this block. |
|
42 | + * |
|
43 | + * @param int $block_id |
|
44 | + * @param bool $template |
|
45 | + * @param string[] $cfg |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
50 | + global $WT_TREE; |
|
51 | 51 | |
52 | - $id = $this->getName() . $block_id; |
|
53 | - $class = $this->getName() . '_block'; |
|
54 | - $title = $this->getTitle(); |
|
55 | - $anonymous = 0; |
|
56 | - $logged_in = array(); |
|
57 | - $content = ''; |
|
58 | - foreach (User::allLoggedIn() as $user) { |
|
59 | - if (Auth::isAdmin() || $user->getPreference('visibleonline')) { |
|
60 | - $logged_in[] = $user; |
|
61 | - } else { |
|
62 | - $anonymous++; |
|
63 | - } |
|
64 | - } |
|
65 | - $count_logged_in = count($logged_in); |
|
66 | - $content .= '<div class="logged_in_count">'; |
|
67 | - if ($anonymous) { |
|
68 | - $content .= I18N::plural('%s anonymous signed-in user', '%s anonymous signed-in users', $anonymous, I18N::number($anonymous)); |
|
69 | - if ($count_logged_in) { |
|
70 | - $content .= ' | '; |
|
71 | - } |
|
72 | - } |
|
73 | - if ($count_logged_in) { |
|
74 | - $content .= I18N::plural('%s signed-in user', '%s signed-in users', $count_logged_in, I18N::number($count_logged_in)); |
|
75 | - } |
|
76 | - $content .= '</div>'; |
|
77 | - $content .= '<div class="logged_in_list">'; |
|
78 | - if (Auth::check()) { |
|
79 | - foreach ($logged_in as $user) { |
|
80 | - $individual = Individual::getInstance($WT_TREE->getUserPreference($user, 'gedcomid'), $WT_TREE); |
|
52 | + $id = $this->getName() . $block_id; |
|
53 | + $class = $this->getName() . '_block'; |
|
54 | + $title = $this->getTitle(); |
|
55 | + $anonymous = 0; |
|
56 | + $logged_in = array(); |
|
57 | + $content = ''; |
|
58 | + foreach (User::allLoggedIn() as $user) { |
|
59 | + if (Auth::isAdmin() || $user->getPreference('visibleonline')) { |
|
60 | + $logged_in[] = $user; |
|
61 | + } else { |
|
62 | + $anonymous++; |
|
63 | + } |
|
64 | + } |
|
65 | + $count_logged_in = count($logged_in); |
|
66 | + $content .= '<div class="logged_in_count">'; |
|
67 | + if ($anonymous) { |
|
68 | + $content .= I18N::plural('%s anonymous signed-in user', '%s anonymous signed-in users', $anonymous, I18N::number($anonymous)); |
|
69 | + if ($count_logged_in) { |
|
70 | + $content .= ' | '; |
|
71 | + } |
|
72 | + } |
|
73 | + if ($count_logged_in) { |
|
74 | + $content .= I18N::plural('%s signed-in user', '%s signed-in users', $count_logged_in, I18N::number($count_logged_in)); |
|
75 | + } |
|
76 | + $content .= '</div>'; |
|
77 | + $content .= '<div class="logged_in_list">'; |
|
78 | + if (Auth::check()) { |
|
79 | + foreach ($logged_in as $user) { |
|
80 | + $individual = Individual::getInstance($WT_TREE->getUserPreference($user, 'gedcomid'), $WT_TREE); |
|
81 | 81 | |
82 | - $content .= '<div class="logged_in_name">'; |
|
83 | - if ($individual) { |
|
84 | - $content .= '<a href="' . $individual->getHtmlUrl() . '">' . $user->getRealNameHtml() . '</a>'; |
|
85 | - } else { |
|
86 | - $content .= $user->getRealNameHtml(); |
|
87 | - } |
|
88 | - $content .= ' - ' . Filter::escapeHtml($user->getUserName()); |
|
89 | - if (Auth::id() != $user->getUserId() && $user->getPreference('contactmethod') != 'none') { |
|
90 | - $content .= ' <a class="icon-email" href="#" onclick="return message(\'' . Filter::escapeHtml($user->getUserName()) . '\', \'\', \'' . Filter::escapeHtml(Functions::getQueryUrl()) . '\');" title="' . I18N::translate('Send a message') . '"></a>'; |
|
91 | - } |
|
92 | - $content .= '</div>'; |
|
93 | - } |
|
94 | - } |
|
95 | - $content .= '</div>'; |
|
82 | + $content .= '<div class="logged_in_name">'; |
|
83 | + if ($individual) { |
|
84 | + $content .= '<a href="' . $individual->getHtmlUrl() . '">' . $user->getRealNameHtml() . '</a>'; |
|
85 | + } else { |
|
86 | + $content .= $user->getRealNameHtml(); |
|
87 | + } |
|
88 | + $content .= ' - ' . Filter::escapeHtml($user->getUserName()); |
|
89 | + if (Auth::id() != $user->getUserId() && $user->getPreference('contactmethod') != 'none') { |
|
90 | + $content .= ' <a class="icon-email" href="#" onclick="return message(\'' . Filter::escapeHtml($user->getUserName()) . '\', \'\', \'' . Filter::escapeHtml(Functions::getQueryUrl()) . '\');" title="' . I18N::translate('Send a message') . '"></a>'; |
|
91 | + } |
|
92 | + $content .= '</div>'; |
|
93 | + } |
|
94 | + } |
|
95 | + $content .= '</div>'; |
|
96 | 96 | |
97 | - if ($anonymous === 0 && $count_logged_in === 0) { |
|
98 | - return ''; |
|
99 | - } |
|
97 | + if ($anonymous === 0 && $count_logged_in === 0) { |
|
98 | + return ''; |
|
99 | + } |
|
100 | 100 | |
101 | - if ($template) { |
|
102 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
103 | - } else { |
|
104 | - return $content; |
|
105 | - } |
|
106 | - } |
|
101 | + if ($template) { |
|
102 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
103 | + } else { |
|
104 | + return $content; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - /** {@inheritdoc} */ |
|
109 | - public function loadAjax() { |
|
110 | - return false; |
|
111 | - } |
|
108 | + /** {@inheritdoc} */ |
|
109 | + public function loadAjax() { |
|
110 | + return false; |
|
111 | + } |
|
112 | 112 | |
113 | - /** {@inheritdoc} */ |
|
114 | - public function isUserBlock() { |
|
115 | - return true; |
|
116 | - } |
|
113 | + /** {@inheritdoc} */ |
|
114 | + public function isUserBlock() { |
|
115 | + return true; |
|
116 | + } |
|
117 | 117 | |
118 | - /** {@inheritdoc} */ |
|
119 | - public function isGedcomBlock() { |
|
120 | - return true; |
|
121 | - } |
|
118 | + /** {@inheritdoc} */ |
|
119 | + public function isGedcomBlock() { |
|
120 | + return true; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * An HTML form to edit block settings |
|
125 | - * |
|
126 | - * @param int $block_id |
|
127 | - */ |
|
128 | - public function configureBlock($block_id) { |
|
129 | - } |
|
123 | + /** |
|
124 | + * An HTML form to edit block settings |
|
125 | + * |
|
126 | + * @param int $block_id |
|
127 | + */ |
|
128 | + public function configureBlock($block_id) { |
|
129 | + } |
|
130 | 130 | } |
@@ -26,14 +26,17 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Class LoggedInUsersModule |
28 | 28 | */ |
29 | -class LoggedInUsersModule extends AbstractModule implements ModuleBlockInterface { |
|
29 | +class LoggedInUsersModule extends AbstractModule implements ModuleBlockInterface |
|
30 | +{ |
|
30 | 31 | /** {@inheritdoc} */ |
31 | - public function getTitle() { |
|
32 | + public function getTitle() |
|
33 | + { |
|
32 | 34 | return /* I18N: Name of a module. (A list of users who are online now) */ I18N::translate('Who is online'); |
33 | 35 | } |
34 | 36 | |
35 | 37 | /** {@inheritdoc} */ |
36 | - public function getDescription() { |
|
38 | + public function getDescription() |
|
39 | + { |
|
37 | 40 | return /* I18N: Description of the “Who is online” module */ I18N::translate('A list of users and visitors who are currently online.'); |
38 | 41 | } |
39 | 42 | |
@@ -46,7 +49,8 @@ discard block |
||
46 | 49 | * |
47 | 50 | * @return string |
48 | 51 | */ |
49 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
52 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
53 | + { |
|
50 | 54 | global $WT_TREE; |
51 | 55 | |
52 | 56 | $id = $this->getName() . $block_id; |
@@ -106,17 +110,20 @@ discard block |
||
106 | 110 | } |
107 | 111 | |
108 | 112 | /** {@inheritdoc} */ |
109 | - public function loadAjax() { |
|
113 | + public function loadAjax() |
|
114 | + { |
|
110 | 115 | return false; |
111 | 116 | } |
112 | 117 | |
113 | 118 | /** {@inheritdoc} */ |
114 | - public function isUserBlock() { |
|
119 | + public function isUserBlock() |
|
120 | + { |
|
115 | 121 | return true; |
116 | 122 | } |
117 | 123 | |
118 | 124 | /** {@inheritdoc} */ |
119 | - public function isGedcomBlock() { |
|
125 | + public function isGedcomBlock() |
|
126 | + { |
|
120 | 127 | return true; |
121 | 128 | } |
122 | 129 | |
@@ -125,6 +132,7 @@ discard block |
||
125 | 132 | * |
126 | 133 | * @param int $block_id |
127 | 134 | */ |
128 | - public function configureBlock($block_id) { |
|
135 | + public function configureBlock($block_id) |
|
136 | + { |
|
129 | 137 | } |
130 | 138 | } |
@@ -21,10 +21,10 @@ |
||
21 | 21 | * Interface ModuleReportInterface - Classes and libraries for module system |
22 | 22 | */ |
23 | 23 | interface ModuleReportInterface { |
24 | - /** |
|
25 | - * Return a menu item for this report. |
|
26 | - * |
|
27 | - * @return Menu |
|
28 | - */ |
|
29 | - public function getReportMenu(); |
|
24 | + /** |
|
25 | + * Return a menu item for this report. |
|
26 | + * |
|
27 | + * @return Menu |
|
28 | + */ |
|
29 | + public function getReportMenu(); |
|
30 | 30 | } |
@@ -20,7 +20,8 @@ |
||
20 | 20 | /** |
21 | 21 | * Interface ModuleReportInterface - Classes and libraries for module system |
22 | 22 | */ |
23 | -interface ModuleReportInterface { |
|
23 | +interface ModuleReportInterface |
|
24 | +{ |
|
24 | 25 | /** |
25 | 26 | * Return a menu item for this report. |
26 | 27 | * |
@@ -23,42 +23,42 @@ |
||
23 | 23 | * Class CemeteryReportModule |
24 | 24 | */ |
25 | 25 | class CemeteryReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** {@inheritdoc} */ |
|
27 | - public function getTitle() { |
|
28 | - // This text also appears in the .XML file - update both together |
|
29 | - return /* I18N: Name of a module/report */ I18N::translate('Cemeteries'); |
|
30 | - } |
|
26 | + /** {@inheritdoc} */ |
|
27 | + public function getTitle() { |
|
28 | + // This text also appears in the .XML file - update both together |
|
29 | + return /* I18N: Name of a module/report */ I18N::translate('Cemeteries'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** {@inheritdoc} */ |
|
33 | - public function getDescription() { |
|
34 | - // This text also appears in the .XML file - update both together |
|
35 | - return /* I18N: Description of the “Cemeteries” module */ I18N::translate('A report of individuals who were buried in a given place.'); |
|
36 | - } |
|
32 | + /** {@inheritdoc} */ |
|
33 | + public function getDescription() { |
|
34 | + // This text also appears in the .XML file - update both together |
|
35 | + return /* I18N: Description of the “Cemeteries” module */ I18N::translate('A report of individuals who were buried in a given place.'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * What is the default access level for this module? |
|
40 | - * |
|
41 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function defaultAccessLevel() { |
|
46 | - return Auth::PRIV_PRIVATE; |
|
47 | - } |
|
38 | + /** |
|
39 | + * What is the default access level for this module? |
|
40 | + * |
|
41 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function defaultAccessLevel() { |
|
46 | + return Auth::PRIV_PRIVATE; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Return a menu item for this report. |
|
51 | - * |
|
52 | - * @return Menu |
|
53 | - */ |
|
54 | - public function getReportMenu() { |
|
55 | - global $WT_TREE; |
|
49 | + /** |
|
50 | + * Return a menu item for this report. |
|
51 | + * |
|
52 | + * @return Menu |
|
53 | + */ |
|
54 | + public function getReportMenu() { |
|
55 | + global $WT_TREE; |
|
56 | 56 | |
57 | - return new Menu( |
|
58 | - $this->getTitle(), |
|
59 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
60 | - 'menu-report-' . $this->getName(), |
|
61 | - array('rel' => 'nofollow') |
|
62 | - ); |
|
63 | - } |
|
57 | + return new Menu( |
|
58 | + $this->getTitle(), |
|
59 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
60 | + 'menu-report-' . $this->getName(), |
|
61 | + array('rel' => 'nofollow') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | } |
@@ -22,15 +22,18 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class CemeteryReportModule |
24 | 24 | */ |
25 | -class CemeteryReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class CemeteryReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritdoc} */ |
27 | - public function getTitle() { |
|
28 | + public function getTitle() |
|
29 | + { |
|
28 | 30 | // This text also appears in the .XML file - update both together |
29 | 31 | return /* I18N: Name of a module/report */ I18N::translate('Cemeteries'); |
30 | 32 | } |
31 | 33 | |
32 | 34 | /** {@inheritdoc} */ |
33 | - public function getDescription() { |
|
35 | + public function getDescription() |
|
36 | + { |
|
34 | 37 | // This text also appears in the .XML file - update both together |
35 | 38 | return /* I18N: Description of the “Cemeteries” module */ I18N::translate('A report of individuals who were buried in a given place.'); |
36 | 39 | } |
@@ -42,7 +45,8 @@ discard block |
||
42 | 45 | * |
43 | 46 | * @return int |
44 | 47 | */ |
45 | - public function defaultAccessLevel() { |
|
48 | + public function defaultAccessLevel() |
|
49 | + { |
|
46 | 50 | return Auth::PRIV_PRIVATE; |
47 | 51 | } |
48 | 52 | |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | * |
52 | 56 | * @return Menu |
53 | 57 | */ |
54 | - public function getReportMenu() { |
|
58 | + public function getReportMenu() |
|
59 | + { |
|
55 | 60 | global $WT_TREE; |
56 | 61 | |
57 | 62 | return new Menu( |
@@ -29,267 +29,267 @@ discard block |
||
29 | 29 | * Class FamilyTreeStatisticsModule |
30 | 30 | */ |
31 | 31 | class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockInterface { |
32 | - /** Show this number of surnames by default */ |
|
33 | - const DEFAULT_NUMBER_OF_SURNAMES = 10; |
|
32 | + /** Show this number of surnames by default */ |
|
33 | + const DEFAULT_NUMBER_OF_SURNAMES = 10; |
|
34 | 34 | |
35 | - /** {@inheritdoc} */ |
|
36 | - public function getTitle() { |
|
37 | - return /* I18N: Name of a module */ I18N::translate('Statistics'); |
|
38 | - } |
|
35 | + /** {@inheritdoc} */ |
|
36 | + public function getTitle() { |
|
37 | + return /* I18N: Name of a module */ I18N::translate('Statistics'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** {@inheritdoc} */ |
|
41 | - public function getDescription() { |
|
42 | - return /* I18N: Description of “Statistics” module */ I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); |
|
43 | - } |
|
40 | + /** {@inheritdoc} */ |
|
41 | + public function getDescription() { |
|
42 | + return /* I18N: Description of “Statistics” module */ I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Generate the HTML content of this block. |
|
47 | - * |
|
48 | - * @param int $block_id |
|
49 | - * @param bool $template |
|
50 | - * @param string[] $cfg |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
55 | - global $WT_TREE, $ctype; |
|
45 | + /** |
|
46 | + * Generate the HTML content of this block. |
|
47 | + * |
|
48 | + * @param int $block_id |
|
49 | + * @param bool $template |
|
50 | + * @param string[] $cfg |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
55 | + global $WT_TREE, $ctype; |
|
56 | 56 | |
57 | - $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); |
|
58 | - $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); |
|
59 | - $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); |
|
60 | - $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); |
|
61 | - $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); |
|
62 | - $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); |
|
63 | - $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); |
|
64 | - $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); |
|
65 | - $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); |
|
66 | - $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); |
|
67 | - $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); |
|
68 | - $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); |
|
69 | - $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); |
|
70 | - $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); |
|
71 | - $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); |
|
72 | - $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); |
|
73 | - $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); |
|
74 | - $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); |
|
75 | - $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); |
|
57 | + $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); |
|
58 | + $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); |
|
59 | + $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); |
|
60 | + $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); |
|
61 | + $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); |
|
62 | + $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); |
|
63 | + $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); |
|
64 | + $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); |
|
65 | + $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); |
|
66 | + $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); |
|
67 | + $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); |
|
68 | + $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); |
|
69 | + $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); |
|
70 | + $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); |
|
71 | + $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); |
|
72 | + $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); |
|
73 | + $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); |
|
74 | + $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); |
|
75 | + $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); |
|
76 | 76 | |
77 | - // This can be overriden when embedding in an HTML block |
|
78 | - $block = '0'; |
|
77 | + // This can be overriden when embedding in an HTML block |
|
78 | + $block = '0'; |
|
79 | 79 | |
80 | - foreach (array('show_common_surnames', 'number_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', 'block') as $name) { |
|
81 | - if (array_key_exists($name, $cfg)) { |
|
82 | - $$name = $cfg[$name]; |
|
83 | - } |
|
84 | - } |
|
80 | + foreach (array('show_common_surnames', 'number_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', 'block') as $name) { |
|
81 | + if (array_key_exists($name, $cfg)) { |
|
82 | + $$name = $cfg[$name]; |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - $id = $this->getName() . $block_id; |
|
87 | - $class = $this->getName() . '_block'; |
|
88 | - if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
89 | - $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
90 | - } else { |
|
91 | - $title = ''; |
|
92 | - } |
|
93 | - $title .= $this->getTitle() . ' — ' . $WT_TREE->getTitleHtml(); |
|
86 | + $id = $this->getName() . $block_id; |
|
87 | + $class = $this->getName() . '_block'; |
|
88 | + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
89 | + $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
90 | + } else { |
|
91 | + $title = ''; |
|
92 | + } |
|
93 | + $title .= $this->getTitle() . ' — ' . $WT_TREE->getTitleHtml(); |
|
94 | 94 | |
95 | - $stats = new Stats($WT_TREE); |
|
95 | + $stats = new Stats($WT_TREE); |
|
96 | 96 | |
97 | - $content = ''; |
|
97 | + $content = ''; |
|
98 | 98 | |
99 | - if ($show_last_update) { |
|
100 | - $content .= '<p>' . /* I18N: %s is a date */ |
|
101 | - I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</p>'; |
|
102 | - } |
|
99 | + if ($show_last_update) { |
|
100 | + $content .= '<p>' . /* I18N: %s is a date */ |
|
101 | + I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</p>'; |
|
102 | + } |
|
103 | 103 | |
104 | - /** Responsive Design */ |
|
105 | - $content .= '<div class="stat-table1">'; |
|
106 | - if ($stat_indi) { |
|
107 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; |
|
108 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</div></div>'; |
|
109 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</div></div>'; |
|
110 | - } |
|
111 | - if ($stat_surname) { |
|
112 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; |
|
113 | - } |
|
114 | - if ($stat_fam) { |
|
115 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>'; |
|
116 | - } |
|
117 | - if ($stat_sour) { |
|
118 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>'; |
|
119 | - } |
|
120 | - if ($stat_media) { |
|
121 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>'; |
|
122 | - } |
|
123 | - if ($stat_repo) { |
|
124 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>'; |
|
125 | - } |
|
126 | - if ($stat_events) { |
|
127 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>'; |
|
128 | - } |
|
129 | - if ($stat_users) { |
|
130 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; |
|
131 | - if (Auth::isManager($WT_TREE)) { |
|
132 | - $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; |
|
133 | - } else { |
|
134 | - $content .= $stats->totalUsers(); |
|
135 | - } |
|
136 | - $content .= '</div></div>'; |
|
137 | - } |
|
138 | - if (!$block) { |
|
139 | - $content .= '</div><div class="facts_table stat-table2">'; |
|
140 | - } |
|
141 | - if ($stat_first_birth) { |
|
142 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstBirthYear() . '</div>'; |
|
143 | - if (!$block) { |
|
144 | - $content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>'; |
|
145 | - } |
|
146 | - $content .= '</div>'; |
|
147 | - } |
|
148 | - if ($stat_last_birth) { |
|
149 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastBirthYear() . '</div>'; |
|
150 | - if (!$block) { |
|
151 | - $content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>'; |
|
152 | - } |
|
153 | - $content .= '</div>'; |
|
154 | - } |
|
155 | - if ($stat_first_death) { |
|
156 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstDeathYear() . '</div>'; |
|
157 | - if (!$block) { |
|
158 | - $content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>'; |
|
159 | - } |
|
160 | - $content .= '</div>'; |
|
161 | - } |
|
162 | - if ($stat_last_death) { |
|
163 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastDeathYear() . '</div>'; |
|
164 | - if (!$block) { |
|
165 | - $content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>'; |
|
166 | - } |
|
167 | - $content .= '</div>'; |
|
168 | - } |
|
169 | - if ($stat_long_life) { |
|
170 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individual who lived the longest') . '</div><div class="facts_value stats_value stat-cell">' . $stats->longestLifeAge() . '</div>'; |
|
171 | - if (!$block) { |
|
172 | - $content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>'; |
|
173 | - } |
|
174 | - $content .= '</div>'; |
|
175 | - } |
|
176 | - if ($stat_avg_life) { |
|
177 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average age at death') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageLifespan() . '</div>'; |
|
178 | - if (!$block) { |
|
179 | - $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); |
|
180 | - $content .= ' ' . I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</div>'; |
|
181 | - } |
|
182 | - $content .= '</div>'; |
|
183 | - } |
|
104 | + /** Responsive Design */ |
|
105 | + $content .= '<div class="stat-table1">'; |
|
106 | + if ($stat_indi) { |
|
107 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; |
|
108 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</div></div>'; |
|
109 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</div></div>'; |
|
110 | + } |
|
111 | + if ($stat_surname) { |
|
112 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; |
|
113 | + } |
|
114 | + if ($stat_fam) { |
|
115 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>'; |
|
116 | + } |
|
117 | + if ($stat_sour) { |
|
118 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>'; |
|
119 | + } |
|
120 | + if ($stat_media) { |
|
121 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>'; |
|
122 | + } |
|
123 | + if ($stat_repo) { |
|
124 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>'; |
|
125 | + } |
|
126 | + if ($stat_events) { |
|
127 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>'; |
|
128 | + } |
|
129 | + if ($stat_users) { |
|
130 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; |
|
131 | + if (Auth::isManager($WT_TREE)) { |
|
132 | + $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; |
|
133 | + } else { |
|
134 | + $content .= $stats->totalUsers(); |
|
135 | + } |
|
136 | + $content .= '</div></div>'; |
|
137 | + } |
|
138 | + if (!$block) { |
|
139 | + $content .= '</div><div class="facts_table stat-table2">'; |
|
140 | + } |
|
141 | + if ($stat_first_birth) { |
|
142 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstBirthYear() . '</div>'; |
|
143 | + if (!$block) { |
|
144 | + $content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>'; |
|
145 | + } |
|
146 | + $content .= '</div>'; |
|
147 | + } |
|
148 | + if ($stat_last_birth) { |
|
149 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastBirthYear() . '</div>'; |
|
150 | + if (!$block) { |
|
151 | + $content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>'; |
|
152 | + } |
|
153 | + $content .= '</div>'; |
|
154 | + } |
|
155 | + if ($stat_first_death) { |
|
156 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstDeathYear() . '</div>'; |
|
157 | + if (!$block) { |
|
158 | + $content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>'; |
|
159 | + } |
|
160 | + $content .= '</div>'; |
|
161 | + } |
|
162 | + if ($stat_last_death) { |
|
163 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastDeathYear() . '</div>'; |
|
164 | + if (!$block) { |
|
165 | + $content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>'; |
|
166 | + } |
|
167 | + $content .= '</div>'; |
|
168 | + } |
|
169 | + if ($stat_long_life) { |
|
170 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individual who lived the longest') . '</div><div class="facts_value stats_value stat-cell">' . $stats->longestLifeAge() . '</div>'; |
|
171 | + if (!$block) { |
|
172 | + $content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>'; |
|
173 | + } |
|
174 | + $content .= '</div>'; |
|
175 | + } |
|
176 | + if ($stat_avg_life) { |
|
177 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average age at death') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageLifespan() . '</div>'; |
|
178 | + if (!$block) { |
|
179 | + $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); |
|
180 | + $content .= ' ' . I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</div>'; |
|
181 | + } |
|
182 | + $content .= '</div>'; |
|
183 | + } |
|
184 | 184 | |
185 | - if ($stat_most_chil && !$block) { |
|
186 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Family with the most children') . '</div><div class="facts_value stats_value stat-cell">' . $stats->largestFamilySize() . '</div>'; |
|
187 | - if (!$block) { |
|
188 | - $content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>'; |
|
189 | - } |
|
190 | - $content .= '</div>'; |
|
191 | - } |
|
192 | - if ($stat_avg_chil) { |
|
193 | - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average number of children per family') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageChildren() . '</div>'; |
|
194 | - if (!$block) { |
|
195 | - $content .= '<div class="facts_value stat-cell left"></div>'; |
|
196 | - } |
|
197 | - $content .= '</div>'; |
|
198 | - } |
|
199 | - $content .= '</div>'; |
|
185 | + if ($stat_most_chil && !$block) { |
|
186 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Family with the most children') . '</div><div class="facts_value stats_value stat-cell">' . $stats->largestFamilySize() . '</div>'; |
|
187 | + if (!$block) { |
|
188 | + $content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>'; |
|
189 | + } |
|
190 | + $content .= '</div>'; |
|
191 | + } |
|
192 | + if ($stat_avg_chil) { |
|
193 | + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average number of children per family') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageChildren() . '</div>'; |
|
194 | + if (!$block) { |
|
195 | + $content .= '<div class="facts_value stat-cell left"></div>'; |
|
196 | + } |
|
197 | + $content .= '</div>'; |
|
198 | + } |
|
199 | + $content .= '</div>'; |
|
200 | 200 | |
201 | - if ($show_common_surnames) { |
|
202 | - $surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), 0, (int) $number_of_surnames); |
|
201 | + if ($show_common_surnames) { |
|
202 | + $surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), 0, (int) $number_of_surnames); |
|
203 | 203 | |
204 | - $all_surnames = array(); |
|
205 | - foreach (array_keys($surnames) as $surname) { |
|
206 | - $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false)); |
|
207 | - } |
|
204 | + $all_surnames = array(); |
|
205 | + foreach (array_keys($surnames) as $surname) { |
|
206 | + $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false)); |
|
207 | + } |
|
208 | 208 | |
209 | - if (!empty($surnames)) { |
|
210 | - ksort($all_surnames); |
|
211 | - $content .= '<div class="clearfloat">'; |
|
212 | - $content .= '<p>'; |
|
213 | - $content .= '<strong>' . I18N::translate('Most common surnames') . '</strong>'; |
|
214 | - $content .= '<br>'; |
|
215 | - $content .= '<span class="common_surnames">' . FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE) . '</span>'; |
|
216 | - $content .= '</p>'; |
|
217 | - $content .= '</div>'; |
|
218 | - } |
|
219 | - } |
|
209 | + if (!empty($surnames)) { |
|
210 | + ksort($all_surnames); |
|
211 | + $content .= '<div class="clearfloat">'; |
|
212 | + $content .= '<p>'; |
|
213 | + $content .= '<strong>' . I18N::translate('Most common surnames') . '</strong>'; |
|
214 | + $content .= '<br>'; |
|
215 | + $content .= '<span class="common_surnames">' . FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE) . '</span>'; |
|
216 | + $content .= '</p>'; |
|
217 | + $content .= '</div>'; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ($template) { |
|
222 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
223 | - } else { |
|
224 | - return $content; |
|
225 | - } |
|
226 | - } |
|
221 | + if ($template) { |
|
222 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
223 | + } else { |
|
224 | + return $content; |
|
225 | + } |
|
226 | + } |
|
227 | 227 | |
228 | - /** {@inheritdoc} */ |
|
229 | - public function loadAjax() { |
|
230 | - return true; |
|
231 | - } |
|
228 | + /** {@inheritdoc} */ |
|
229 | + public function loadAjax() { |
|
230 | + return true; |
|
231 | + } |
|
232 | 232 | |
233 | - /** {@inheritdoc} */ |
|
234 | - public function isUserBlock() { |
|
235 | - return true; |
|
236 | - } |
|
233 | + /** {@inheritdoc} */ |
|
234 | + public function isUserBlock() { |
|
235 | + return true; |
|
236 | + } |
|
237 | 237 | |
238 | - /** {@inheritdoc} */ |
|
239 | - public function isGedcomBlock() { |
|
240 | - return true; |
|
241 | - } |
|
238 | + /** {@inheritdoc} */ |
|
239 | + public function isGedcomBlock() { |
|
240 | + return true; |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * An HTML form to edit block settings |
|
245 | - * |
|
246 | - * @param int $block_id |
|
247 | - */ |
|
248 | - public function configureBlock($block_id) { |
|
249 | - if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
250 | - $this->setBlockSetting($block_id, 'show_last_update', Filter::postBool('show_last_update')); |
|
251 | - $this->setBlockSetting($block_id, 'show_common_surnames', Filter::postBool('show_common_surnames')); |
|
252 | - $this->setBlockSetting($block_id, 'number_of_surnames', Filter::postInteger('number_of_surnames')); |
|
253 | - $this->setBlockSetting($block_id, 'stat_indi', Filter::postBool('stat_indi')); |
|
254 | - $this->setBlockSetting($block_id, 'stat_fam', Filter::postBool('stat_fam')); |
|
255 | - $this->setBlockSetting($block_id, 'stat_sour', Filter::postBool('stat_sour')); |
|
256 | - $this->setBlockSetting($block_id, 'stat_other', Filter::postBool('stat_other')); |
|
257 | - $this->setBlockSetting($block_id, 'stat_media', Filter::postBool('stat_media')); |
|
258 | - $this->setBlockSetting($block_id, 'stat_repo', Filter::postBool('stat_repo')); |
|
259 | - $this->setBlockSetting($block_id, 'stat_surname', Filter::postBool('stat_surname')); |
|
260 | - $this->setBlockSetting($block_id, 'stat_events', Filter::postBool('stat_events')); |
|
261 | - $this->setBlockSetting($block_id, 'stat_users', Filter::postBool('stat_users')); |
|
262 | - $this->setBlockSetting($block_id, 'stat_first_birth', Filter::postBool('stat_first_birth')); |
|
263 | - $this->setBlockSetting($block_id, 'stat_last_birth', Filter::postBool('stat_last_birth')); |
|
264 | - $this->setBlockSetting($block_id, 'stat_first_death', Filter::postBool('stat_first_death')); |
|
265 | - $this->setBlockSetting($block_id, 'stat_last_death', Filter::postBool('stat_last_death')); |
|
266 | - $this->setBlockSetting($block_id, 'stat_long_life', Filter::postBool('stat_long_life')); |
|
267 | - $this->setBlockSetting($block_id, 'stat_avg_life', Filter::postBool('stat_avg_life')); |
|
268 | - $this->setBlockSetting($block_id, 'stat_most_chil', Filter::postBool('stat_most_chil')); |
|
269 | - $this->setBlockSetting($block_id, 'stat_avg_chil', Filter::postBool('stat_avg_chil')); |
|
270 | - } |
|
243 | + /** |
|
244 | + * An HTML form to edit block settings |
|
245 | + * |
|
246 | + * @param int $block_id |
|
247 | + */ |
|
248 | + public function configureBlock($block_id) { |
|
249 | + if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
250 | + $this->setBlockSetting($block_id, 'show_last_update', Filter::postBool('show_last_update')); |
|
251 | + $this->setBlockSetting($block_id, 'show_common_surnames', Filter::postBool('show_common_surnames')); |
|
252 | + $this->setBlockSetting($block_id, 'number_of_surnames', Filter::postInteger('number_of_surnames')); |
|
253 | + $this->setBlockSetting($block_id, 'stat_indi', Filter::postBool('stat_indi')); |
|
254 | + $this->setBlockSetting($block_id, 'stat_fam', Filter::postBool('stat_fam')); |
|
255 | + $this->setBlockSetting($block_id, 'stat_sour', Filter::postBool('stat_sour')); |
|
256 | + $this->setBlockSetting($block_id, 'stat_other', Filter::postBool('stat_other')); |
|
257 | + $this->setBlockSetting($block_id, 'stat_media', Filter::postBool('stat_media')); |
|
258 | + $this->setBlockSetting($block_id, 'stat_repo', Filter::postBool('stat_repo')); |
|
259 | + $this->setBlockSetting($block_id, 'stat_surname', Filter::postBool('stat_surname')); |
|
260 | + $this->setBlockSetting($block_id, 'stat_events', Filter::postBool('stat_events')); |
|
261 | + $this->setBlockSetting($block_id, 'stat_users', Filter::postBool('stat_users')); |
|
262 | + $this->setBlockSetting($block_id, 'stat_first_birth', Filter::postBool('stat_first_birth')); |
|
263 | + $this->setBlockSetting($block_id, 'stat_last_birth', Filter::postBool('stat_last_birth')); |
|
264 | + $this->setBlockSetting($block_id, 'stat_first_death', Filter::postBool('stat_first_death')); |
|
265 | + $this->setBlockSetting($block_id, 'stat_last_death', Filter::postBool('stat_last_death')); |
|
266 | + $this->setBlockSetting($block_id, 'stat_long_life', Filter::postBool('stat_long_life')); |
|
267 | + $this->setBlockSetting($block_id, 'stat_avg_life', Filter::postBool('stat_avg_life')); |
|
268 | + $this->setBlockSetting($block_id, 'stat_most_chil', Filter::postBool('stat_most_chil')); |
|
269 | + $this->setBlockSetting($block_id, 'stat_avg_chil', Filter::postBool('stat_avg_chil')); |
|
270 | + } |
|
271 | 271 | |
272 | - $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); |
|
273 | - $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); |
|
274 | - $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); |
|
275 | - $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); |
|
276 | - $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); |
|
277 | - $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); |
|
278 | - $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); |
|
279 | - $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); |
|
280 | - $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); |
|
281 | - $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); |
|
282 | - $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); |
|
283 | - $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); |
|
284 | - $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); |
|
285 | - $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); |
|
286 | - $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); |
|
287 | - $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); |
|
288 | - $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); |
|
289 | - $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); |
|
290 | - $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); |
|
272 | + $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); |
|
273 | + $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); |
|
274 | + $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); |
|
275 | + $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); |
|
276 | + $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); |
|
277 | + $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); |
|
278 | + $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); |
|
279 | + $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); |
|
280 | + $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); |
|
281 | + $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); |
|
282 | + $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); |
|
283 | + $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); |
|
284 | + $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); |
|
285 | + $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); |
|
286 | + $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); |
|
287 | + $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); |
|
288 | + $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); |
|
289 | + $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); |
|
290 | + $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); |
|
291 | 291 | |
292 | - ?> |
|
292 | + ?> |
|
293 | 293 | <tr> |
294 | 294 | <td class="descriptionbox wrap width33"> |
295 | 295 | <label for="show-last-update"> |
@@ -452,5 +452,5 @@ discard block |
||
452 | 452 | </td> |
453 | 453 | </tr> |
454 | 454 | <?php |
455 | - } |
|
455 | + } |
|
456 | 456 | } |
@@ -28,17 +28,20 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * Class FamilyTreeStatisticsModule |
30 | 30 | */ |
31 | -class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockInterface { |
|
31 | +class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockInterface |
|
32 | +{ |
|
32 | 33 | /** Show this number of surnames by default */ |
33 | 34 | const DEFAULT_NUMBER_OF_SURNAMES = 10; |
34 | 35 | |
35 | 36 | /** {@inheritdoc} */ |
36 | - public function getTitle() { |
|
37 | + public function getTitle() |
|
38 | + { |
|
37 | 39 | return /* I18N: Name of a module */ I18N::translate('Statistics'); |
38 | 40 | } |
39 | 41 | |
40 | 42 | /** {@inheritdoc} */ |
41 | - public function getDescription() { |
|
43 | + public function getDescription() |
|
44 | + { |
|
42 | 45 | return /* I18N: Description of “Statistics” module */ I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); |
43 | 46 | } |
44 | 47 | |
@@ -51,7 +54,8 @@ discard block |
||
51 | 54 | * |
52 | 55 | * @return string |
53 | 56 | */ |
54 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
57 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
58 | + { |
|
55 | 59 | global $WT_TREE, $ctype; |
56 | 60 | |
57 | 61 | $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); |
@@ -226,17 +230,20 @@ discard block |
||
226 | 230 | } |
227 | 231 | |
228 | 232 | /** {@inheritdoc} */ |
229 | - public function loadAjax() { |
|
233 | + public function loadAjax() |
|
234 | + { |
|
230 | 235 | return true; |
231 | 236 | } |
232 | 237 | |
233 | 238 | /** {@inheritdoc} */ |
234 | - public function isUserBlock() { |
|
239 | + public function isUserBlock() |
|
240 | + { |
|
235 | 241 | return true; |
236 | 242 | } |
237 | 243 | |
238 | 244 | /** {@inheritdoc} */ |
239 | - public function isGedcomBlock() { |
|
245 | + public function isGedcomBlock() |
|
246 | + { |
|
240 | 247 | return true; |
241 | 248 | } |
242 | 249 | |
@@ -245,7 +252,8 @@ discard block |
||
245 | 252 | * |
246 | 253 | * @param int $block_id |
247 | 254 | */ |
248 | - public function configureBlock($block_id) { |
|
255 | + public function configureBlock($block_id) |
|
256 | + { |
|
249 | 257 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
250 | 258 | $this->setBlockSetting($block_id, 'show_last_update', Filter::postBool('show_last_update')); |
251 | 259 | $this->setBlockSetting($block_id, 'show_common_surnames', Filter::postBool('show_common_surnames')); |
@@ -27,57 +27,57 @@ discard block |
||
27 | 27 | * Class MediaTabModule |
28 | 28 | */ |
29 | 29 | class MediaTabModule extends AbstractModule implements ModuleTabInterface { |
30 | - /** @var Fact[] A list of facts with media objects. */ |
|
31 | - private $facts; |
|
30 | + /** @var Fact[] A list of facts with media objects. */ |
|
31 | + private $facts; |
|
32 | 32 | |
33 | - /** {@inheritdoc} */ |
|
34 | - public function getTitle() { |
|
35 | - return /* I18N: Name of a module */ I18N::translate('Media'); |
|
36 | - } |
|
33 | + /** {@inheritdoc} */ |
|
34 | + public function getTitle() { |
|
35 | + return /* I18N: Name of a module */ I18N::translate('Media'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** {@inheritdoc} */ |
|
39 | - public function getDescription() { |
|
40 | - return /* I18N: Description of the “Media” module */ I18N::translate('A tab showing the media objects linked to an individual.'); |
|
41 | - } |
|
38 | + /** {@inheritdoc} */ |
|
39 | + public function getDescription() { |
|
40 | + return /* I18N: Description of the “Media” module */ I18N::translate('A tab showing the media objects linked to an individual.'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** {@inheritdoc} */ |
|
44 | - public function defaultTabOrder() { |
|
45 | - return 50; |
|
46 | - } |
|
43 | + /** {@inheritdoc} */ |
|
44 | + public function defaultTabOrder() { |
|
45 | + return 50; |
|
46 | + } |
|
47 | 47 | |
48 | - /** {@inheritdoc} */ |
|
49 | - public function hasTabContent() { |
|
50 | - global $WT_TREE; |
|
48 | + /** {@inheritdoc} */ |
|
49 | + public function hasTabContent() { |
|
50 | + global $WT_TREE; |
|
51 | 51 | |
52 | - return Auth::isEditor($WT_TREE) || $this->getFactsWithMedia(); |
|
53 | - } |
|
52 | + return Auth::isEditor($WT_TREE) || $this->getFactsWithMedia(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** {@inheritdoc} */ |
|
56 | - public function isGrayedOut() { |
|
57 | - return !$this->getFactsWithMedia(); |
|
58 | - } |
|
55 | + /** {@inheritdoc} */ |
|
56 | + public function isGrayedOut() { |
|
57 | + return !$this->getFactsWithMedia(); |
|
58 | + } |
|
59 | 59 | |
60 | - /** {@inheritdoc} */ |
|
61 | - public function getTabContent() { |
|
62 | - global $WT_TREE, $controller; |
|
60 | + /** {@inheritdoc} */ |
|
61 | + public function getTabContent() { |
|
62 | + global $WT_TREE, $controller; |
|
63 | 63 | |
64 | - ob_start(); |
|
65 | - echo '<table class="facts_table">'; |
|
66 | - foreach ($this->getFactsWithMedia() as $fact) { |
|
67 | - if ($fact->getTag() == 'OBJE') { |
|
68 | - FunctionsPrintFacts::printMainMedia($fact, 1); |
|
69 | - } else { |
|
70 | - for ($i = 2; $i < 4; ++$i) { |
|
71 | - FunctionsPrintFacts::printMainMedia($fact, $i); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
75 | - if (!$this->getFactsWithMedia()) { |
|
76 | - echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', I18N::translate('There are no media objects for this individual.'), '</td></tr>'; |
|
77 | - } |
|
78 | - // New media link |
|
79 | - if ($controller->record->canEdit() && $WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->record->getTree())) { |
|
80 | - ?> |
|
64 | + ob_start(); |
|
65 | + echo '<table class="facts_table">'; |
|
66 | + foreach ($this->getFactsWithMedia() as $fact) { |
|
67 | + if ($fact->getTag() == 'OBJE') { |
|
68 | + FunctionsPrintFacts::printMainMedia($fact, 1); |
|
69 | + } else { |
|
70 | + for ($i = 2; $i < 4; ++$i) { |
|
71 | + FunctionsPrintFacts::printMainMedia($fact, $i); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | + if (!$this->getFactsWithMedia()) { |
|
76 | + echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', I18N::translate('There are no media objects for this individual.'), '</td></tr>'; |
|
77 | + } |
|
78 | + // New media link |
|
79 | + if ($controller->record->canEdit() && $WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->record->getTree())) { |
|
80 | + ?> |
|
81 | 81 | <tr> |
82 | 82 | <td class="facts_label"> |
83 | 83 | <?php echo GedcomTag::getLabel('OBJE'); ?> |
@@ -94,49 +94,49 @@ discard block |
||
94 | 94 | </td> |
95 | 95 | </tr> |
96 | 96 | <?php |
97 | - } |
|
98 | - ?> |
|
97 | + } |
|
98 | + ?> |
|
99 | 99 | </table> |
100 | 100 | <?php |
101 | - return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>'; |
|
102 | - } |
|
101 | + return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>'; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get all the facts for an individual which contain media objects. |
|
106 | - * |
|
107 | - * @return Fact[] |
|
108 | - */ |
|
109 | - private function getFactsWithMedia() { |
|
110 | - global $controller; |
|
104 | + /** |
|
105 | + * Get all the facts for an individual which contain media objects. |
|
106 | + * |
|
107 | + * @return Fact[] |
|
108 | + */ |
|
109 | + private function getFactsWithMedia() { |
|
110 | + global $controller; |
|
111 | 111 | |
112 | - if ($this->facts === null) { |
|
113 | - $facts = $controller->record->getFacts(); |
|
114 | - foreach ($controller->record->getSpouseFamilies() as $family) { |
|
115 | - if ($family->canShow()) { |
|
116 | - foreach ($family->getFacts() as $fact) { |
|
117 | - $facts[] = $fact; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
121 | - $this->facts = array(); |
|
122 | - foreach ($facts as $fact) { |
|
123 | - if (preg_match('/(?:^1|\n\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->getGedcom())) { |
|
124 | - $this->facts[] = $fact; |
|
125 | - } |
|
126 | - } |
|
127 | - Functions::sortFacts($this->facts); |
|
128 | - } |
|
112 | + if ($this->facts === null) { |
|
113 | + $facts = $controller->record->getFacts(); |
|
114 | + foreach ($controller->record->getSpouseFamilies() as $family) { |
|
115 | + if ($family->canShow()) { |
|
116 | + foreach ($family->getFacts() as $fact) { |
|
117 | + $facts[] = $fact; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | + $this->facts = array(); |
|
122 | + foreach ($facts as $fact) { |
|
123 | + if (preg_match('/(?:^1|\n\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->getGedcom())) { |
|
124 | + $this->facts[] = $fact; |
|
125 | + } |
|
126 | + } |
|
127 | + Functions::sortFacts($this->facts); |
|
128 | + } |
|
129 | 129 | |
130 | - return $this->facts; |
|
131 | - } |
|
130 | + return $this->facts; |
|
131 | + } |
|
132 | 132 | |
133 | - /** {@inheritdoc} */ |
|
134 | - public function canLoadAjax() { |
|
135 | - return !Auth::isSearchEngine(); // Search engines cannot use AJAX |
|
136 | - } |
|
133 | + /** {@inheritdoc} */ |
|
134 | + public function canLoadAjax() { |
|
135 | + return !Auth::isSearchEngine(); // Search engines cannot use AJAX |
|
136 | + } |
|
137 | 137 | |
138 | - /** {@inheritdoc} */ |
|
139 | - public function getPreLoadContent() { |
|
140 | - return ''; |
|
141 | - } |
|
138 | + /** {@inheritdoc} */ |
|
139 | + public function getPreLoadContent() { |
|
140 | + return ''; |
|
141 | + } |
|
142 | 142 | } |
@@ -26,39 +26,46 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Class MediaTabModule |
28 | 28 | */ |
29 | -class MediaTabModule extends AbstractModule implements ModuleTabInterface { |
|
29 | +class MediaTabModule extends AbstractModule implements ModuleTabInterface |
|
30 | +{ |
|
30 | 31 | /** @var Fact[] A list of facts with media objects. */ |
31 | 32 | private $facts; |
32 | 33 | |
33 | 34 | /** {@inheritdoc} */ |
34 | - public function getTitle() { |
|
35 | + public function getTitle() |
|
36 | + { |
|
35 | 37 | return /* I18N: Name of a module */ I18N::translate('Media'); |
36 | 38 | } |
37 | 39 | |
38 | 40 | /** {@inheritdoc} */ |
39 | - public function getDescription() { |
|
41 | + public function getDescription() |
|
42 | + { |
|
40 | 43 | return /* I18N: Description of the “Media” module */ I18N::translate('A tab showing the media objects linked to an individual.'); |
41 | 44 | } |
42 | 45 | |
43 | 46 | /** {@inheritdoc} */ |
44 | - public function defaultTabOrder() { |
|
47 | + public function defaultTabOrder() |
|
48 | + { |
|
45 | 49 | return 50; |
46 | 50 | } |
47 | 51 | |
48 | 52 | /** {@inheritdoc} */ |
49 | - public function hasTabContent() { |
|
53 | + public function hasTabContent() |
|
54 | + { |
|
50 | 55 | global $WT_TREE; |
51 | 56 | |
52 | 57 | return Auth::isEditor($WT_TREE) || $this->getFactsWithMedia(); |
53 | 58 | } |
54 | 59 | |
55 | 60 | /** {@inheritdoc} */ |
56 | - public function isGrayedOut() { |
|
61 | + public function isGrayedOut() |
|
62 | + { |
|
57 | 63 | return !$this->getFactsWithMedia(); |
58 | 64 | } |
59 | 65 | |
60 | 66 | /** {@inheritdoc} */ |
61 | - public function getTabContent() { |
|
67 | + public function getTabContent() |
|
68 | + { |
|
62 | 69 | global $WT_TREE, $controller; |
63 | 70 | |
64 | 71 | ob_start(); |
@@ -106,7 +113,8 @@ discard block |
||
106 | 113 | * |
107 | 114 | * @return Fact[] |
108 | 115 | */ |
109 | - private function getFactsWithMedia() { |
|
116 | + private function getFactsWithMedia() |
|
117 | + { |
|
110 | 118 | global $controller; |
111 | 119 | |
112 | 120 | if ($this->facts === null) { |
@@ -131,12 +139,14 @@ discard block |
||
131 | 139 | } |
132 | 140 | |
133 | 141 | /** {@inheritdoc} */ |
134 | - public function canLoadAjax() { |
|
142 | + public function canLoadAjax() |
|
143 | + { |
|
135 | 144 | return !Auth::isSearchEngine(); // Search engines cannot use AJAX |
136 | 145 | } |
137 | 146 | |
138 | 147 | /** {@inheritdoc} */ |
139 | - public function getPreLoadContent() { |
|
148 | + public function getPreLoadContent() |
|
149 | + { |
|
140 | 150 | return ''; |
141 | 151 | } |
142 | 152 | } |
@@ -22,64 +22,64 @@ |
||
22 | 22 | * Class ThemeSelectModule |
23 | 23 | */ |
24 | 24 | class ThemeSelectModule extends AbstractModule implements ModuleBlockInterface { |
25 | - /** {@inheritdoc} */ |
|
26 | - public function getTitle() { |
|
27 | - return /* I18N: Name of a module */ I18N::translate('Theme change'); |
|
28 | - } |
|
25 | + /** {@inheritdoc} */ |
|
26 | + public function getTitle() { |
|
27 | + return /* I18N: Name of a module */ I18N::translate('Theme change'); |
|
28 | + } |
|
29 | 29 | |
30 | - /** {@inheritdoc} */ |
|
31 | - public function getDescription() { |
|
32 | - return /* I18N: Description of the “Theme change” module */ I18N::translate('An alternative way to select a new theme.'); |
|
33 | - } |
|
30 | + /** {@inheritdoc} */ |
|
31 | + public function getDescription() { |
|
32 | + return /* I18N: Description of the “Theme change” module */ I18N::translate('An alternative way to select a new theme.'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Generate the HTML content of this block. |
|
37 | - * |
|
38 | - * @param int $block_id |
|
39 | - * @param bool $template |
|
40 | - * @param string[] $cfg |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
45 | - $id = $this->getName() . $block_id; |
|
46 | - $class = $this->getName() . '_block'; |
|
47 | - $title = $this->getTitle(); |
|
48 | - $menu = Theme::theme()->menuThemes(); |
|
35 | + /** |
|
36 | + * Generate the HTML content of this block. |
|
37 | + * |
|
38 | + * @param int $block_id |
|
39 | + * @param bool $template |
|
40 | + * @param string[] $cfg |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
45 | + $id = $this->getName() . $block_id; |
|
46 | + $class = $this->getName() . '_block'; |
|
47 | + $title = $this->getTitle(); |
|
48 | + $menu = Theme::theme()->menuThemes(); |
|
49 | 49 | |
50 | - if ($menu) { |
|
51 | - $content = '<div class="center theme_form">' . $menu . '</div><br>'; |
|
50 | + if ($menu) { |
|
51 | + $content = '<div class="center theme_form">' . $menu . '</div><br>'; |
|
52 | 52 | |
53 | - if ($template) { |
|
54 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
55 | - } else { |
|
56 | - return $content; |
|
57 | - } |
|
58 | - } else { |
|
59 | - return ''; |
|
60 | - } |
|
61 | - } |
|
53 | + if ($template) { |
|
54 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
55 | + } else { |
|
56 | + return $content; |
|
57 | + } |
|
58 | + } else { |
|
59 | + return ''; |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - /** {@inheritdoc} */ |
|
64 | - public function loadAjax() { |
|
65 | - return false; |
|
66 | - } |
|
63 | + /** {@inheritdoc} */ |
|
64 | + public function loadAjax() { |
|
65 | + return false; |
|
66 | + } |
|
67 | 67 | |
68 | - /** {@inheritdoc} */ |
|
69 | - public function isUserBlock() { |
|
70 | - return true; |
|
71 | - } |
|
68 | + /** {@inheritdoc} */ |
|
69 | + public function isUserBlock() { |
|
70 | + return true; |
|
71 | + } |
|
72 | 72 | |
73 | - /** {@inheritdoc} */ |
|
74 | - public function isGedcomBlock() { |
|
75 | - return true; |
|
76 | - } |
|
73 | + /** {@inheritdoc} */ |
|
74 | + public function isGedcomBlock() { |
|
75 | + return true; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * An HTML form to edit block settings |
|
80 | - * |
|
81 | - * @param int $block_id |
|
82 | - */ |
|
83 | - public function configureBlock($block_id) { |
|
84 | - } |
|
78 | + /** |
|
79 | + * An HTML form to edit block settings |
|
80 | + * |
|
81 | + * @param int $block_id |
|
82 | + */ |
|
83 | + public function configureBlock($block_id) { |
|
84 | + } |
|
85 | 85 | } |
@@ -21,14 +21,17 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Class ThemeSelectModule |
23 | 23 | */ |
24 | -class ThemeSelectModule extends AbstractModule implements ModuleBlockInterface { |
|
24 | +class ThemeSelectModule extends AbstractModule implements ModuleBlockInterface |
|
25 | +{ |
|
25 | 26 | /** {@inheritdoc} */ |
26 | - public function getTitle() { |
|
27 | + public function getTitle() |
|
28 | + { |
|
27 | 29 | return /* I18N: Name of a module */ I18N::translate('Theme change'); |
28 | 30 | } |
29 | 31 | |
30 | 32 | /** {@inheritdoc} */ |
31 | - public function getDescription() { |
|
33 | + public function getDescription() |
|
34 | + { |
|
32 | 35 | return /* I18N: Description of the “Theme change” module */ I18N::translate('An alternative way to select a new theme.'); |
33 | 36 | } |
34 | 37 | |
@@ -41,7 +44,8 @@ discard block |
||
41 | 44 | * |
42 | 45 | * @return string |
43 | 46 | */ |
44 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
47 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
48 | + { |
|
45 | 49 | $id = $this->getName() . $block_id; |
46 | 50 | $class = $this->getName() . '_block'; |
47 | 51 | $title = $this->getTitle(); |
@@ -61,17 +65,20 @@ discard block |
||
61 | 65 | } |
62 | 66 | |
63 | 67 | /** {@inheritdoc} */ |
64 | - public function loadAjax() { |
|
68 | + public function loadAjax() |
|
69 | + { |
|
65 | 70 | return false; |
66 | 71 | } |
67 | 72 | |
68 | 73 | /** {@inheritdoc} */ |
69 | - public function isUserBlock() { |
|
74 | + public function isUserBlock() |
|
75 | + { |
|
70 | 76 | return true; |
71 | 77 | } |
72 | 78 | |
73 | 79 | /** {@inheritdoc} */ |
74 | - public function isGedcomBlock() { |
|
80 | + public function isGedcomBlock() |
|
81 | + { |
|
75 | 82 | return true; |
76 | 83 | } |
77 | 84 | |
@@ -80,6 +87,7 @@ discard block |
||
80 | 87 | * |
81 | 88 | * @param int $block_id |
82 | 89 | */ |
83 | - public function configureBlock($block_id) { |
|
90 | + public function configureBlock($block_id) |
|
91 | + { |
|
84 | 92 | } |
85 | 93 | } |
@@ -19,45 +19,45 @@ |
||
19 | 19 | * Interface ModuleBlockInterface - Classes and libraries for module system |
20 | 20 | */ |
21 | 21 | interface ModuleBlockInterface { |
22 | - /** |
|
23 | - * Generate the HTML content of this block. |
|
24 | - * |
|
25 | - * @param int $block_id |
|
26 | - * @param bool $template |
|
27 | - * @param string[] $cfg |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function getBlock($block_id, $template = true, $cfg = array()); |
|
22 | + /** |
|
23 | + * Generate the HTML content of this block. |
|
24 | + * |
|
25 | + * @param int $block_id |
|
26 | + * @param bool $template |
|
27 | + * @param string[] $cfg |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function getBlock($block_id, $template = true, $cfg = array()); |
|
32 | 32 | |
33 | - /** |
|
34 | - * Should this block load asynchronously using AJAX? |
|
35 | - * |
|
36 | - * Simple blocks are faster in-line, more comples ones |
|
37 | - * can be loaded later. |
|
38 | - * |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - public function loadAjax(); |
|
33 | + /** |
|
34 | + * Should this block load asynchronously using AJAX? |
|
35 | + * |
|
36 | + * Simple blocks are faster in-line, more comples ones |
|
37 | + * can be loaded later. |
|
38 | + * |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + public function loadAjax(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Can this block be shown on the user’s home page? |
|
45 | - * |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function isUserBlock(); |
|
43 | + /** |
|
44 | + * Can this block be shown on the user’s home page? |
|
45 | + * |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function isUserBlock(); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Can this block be shown on the tree’s home page? |
|
52 | - * |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function isGedcomBlock(); |
|
50 | + /** |
|
51 | + * Can this block be shown on the tree’s home page? |
|
52 | + * |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function isGedcomBlock(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * An HTML form to edit block settings |
|
59 | - * |
|
60 | - * @param int $block_id |
|
61 | - */ |
|
62 | - public function configureBlock($block_id); |
|
57 | + /** |
|
58 | + * An HTML form to edit block settings |
|
59 | + * |
|
60 | + * @param int $block_id |
|
61 | + */ |
|
62 | + public function configureBlock($block_id); |
|
63 | 63 | } |
@@ -18,7 +18,8 @@ |
||
18 | 18 | /** |
19 | 19 | * Interface ModuleBlockInterface - Classes and libraries for module system |
20 | 20 | */ |
21 | -interface ModuleBlockInterface { |
|
21 | +interface ModuleBlockInterface |
|
22 | +{ |
|
22 | 23 | /** |
23 | 24 | * Generate the HTML content of this block. |
24 | 25 | * |
@@ -23,50 +23,50 @@ |
||
23 | 23 | * Class BirthDeathMarriageReportModule |
24 | 24 | */ |
25 | 25 | class BirthDeathMarriageReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** |
|
27 | - * How should this module be labelled on tabs, menus, etc.? |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function getTitle() { |
|
32 | - // This text also appears in the .XML file - update both together |
|
33 | - return /* I18N: Name of a module/report. “Vital records” are life events - birth/marriage/death */ I18N::translate('Vital records'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * How should this module be labelled on tabs, menus, etc.? |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function getTitle() { |
|
32 | + // This text also appears in the .XML file - update both together |
|
33 | + return /* I18N: Name of a module/report. “Vital records” are life events - birth/marriage/death */ I18N::translate('Vital records'); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * A sentence describing what this module does. |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getDescription() { |
|
42 | - // This text also appears in the .XML file - update both together |
|
43 | - return /* I18N: Description of the “Vital records” module. “Vital records” are life events - birth/marriage/death */ I18N::translate('A report of vital records for a given date or place.'); |
|
44 | - } |
|
36 | + /** |
|
37 | + * A sentence describing what this module does. |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getDescription() { |
|
42 | + // This text also appears in the .XML file - update both together |
|
43 | + return /* I18N: Description of the “Vital records” module. “Vital records” are life events - birth/marriage/death */ I18N::translate('A report of vital records for a given date or place.'); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * What is the default access level for this module? |
|
48 | - * |
|
49 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
50 | - * |
|
51 | - * @return int |
|
52 | - */ |
|
53 | - public function defaultAccessLevel() { |
|
54 | - return Auth::PRIV_PRIVATE; |
|
55 | - } |
|
46 | + /** |
|
47 | + * What is the default access level for this module? |
|
48 | + * |
|
49 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
50 | + * |
|
51 | + * @return int |
|
52 | + */ |
|
53 | + public function defaultAccessLevel() { |
|
54 | + return Auth::PRIV_PRIVATE; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Return a menu item for this report. |
|
59 | - * |
|
60 | - * @return Menu |
|
61 | - */ |
|
62 | - public function getReportMenu() { |
|
63 | - global $WT_TREE; |
|
57 | + /** |
|
58 | + * Return a menu item for this report. |
|
59 | + * |
|
60 | + * @return Menu |
|
61 | + */ |
|
62 | + public function getReportMenu() { |
|
63 | + global $WT_TREE; |
|
64 | 64 | |
65 | - return new Menu( |
|
66 | - $this->getTitle(), |
|
67 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
68 | - 'menu-report-' . $this->getName(), |
|
69 | - array('rel' => 'nofollow') |
|
70 | - ); |
|
71 | - } |
|
65 | + return new Menu( |
|
66 | + $this->getTitle(), |
|
67 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
68 | + 'menu-report-' . $this->getName(), |
|
69 | + array('rel' => 'nofollow') |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | } |
@@ -22,13 +22,15 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class BirthDeathMarriageReportModule |
24 | 24 | */ |
25 | -class BirthDeathMarriageReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class BirthDeathMarriageReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** |
27 | 28 | * How should this module be labelled on tabs, menus, etc.? |
28 | 29 | * |
29 | 30 | * @return string |
30 | 31 | */ |
31 | - public function getTitle() { |
|
32 | + public function getTitle() |
|
33 | + { |
|
32 | 34 | // This text also appears in the .XML file - update both together |
33 | 35 | return /* I18N: Name of a module/report. “Vital records” are life events - birth/marriage/death */ I18N::translate('Vital records'); |
34 | 36 | } |
@@ -38,7 +40,8 @@ discard block |
||
38 | 40 | * |
39 | 41 | * @return string |
40 | 42 | */ |
41 | - public function getDescription() { |
|
43 | + public function getDescription() |
|
44 | + { |
|
42 | 45 | // This text also appears in the .XML file - update both together |
43 | 46 | return /* I18N: Description of the “Vital records” module. “Vital records” are life events - birth/marriage/death */ I18N::translate('A report of vital records for a given date or place.'); |
44 | 47 | } |
@@ -50,7 +53,8 @@ discard block |
||
50 | 53 | * |
51 | 54 | * @return int |
52 | 55 | */ |
53 | - public function defaultAccessLevel() { |
|
56 | + public function defaultAccessLevel() |
|
57 | + { |
|
54 | 58 | return Auth::PRIV_PRIVATE; |
55 | 59 | } |
56 | 60 | |
@@ -59,7 +63,8 @@ discard block |
||
59 | 63 | * |
60 | 64 | * @return Menu |
61 | 65 | */ |
62 | - public function getReportMenu() { |
|
66 | + public function getReportMenu() |
|
67 | + { |
|
63 | 68 | global $WT_TREE; |
64 | 69 | |
65 | 70 | return new Menu( |