1<?php 2namespace Fisharebest\Webtrees; 3 4/** 5 * webtrees: online genealogy 6 * Copyright (C) 2015 webtrees development team 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19/** 20 * Class ClippingsCartModule 21 */ 22class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, ModuleSidebarInterface { 23 /** {@inheritdoc} */ 24 public function getTitle() { 25 return /* I18N: Name of a module */ I18N::translate('Clippings cart'); 26 } 27 28 /** {@inheritdoc} */ 29 public function getDescription() { 30 return /* I18N: Description of the “Clippings cart” module */ I18N::translate('Select records from your family tree and save them as a GEDCOM file.'); 31 } 32 33 /** {@inheritdoc} */ 34 public function defaultAccessLevel() { 35 return Auth::PRIV_USER; 36 } 37 38 /** {@inheritdoc} */ 39 public function modAction($mod_action) { 40 switch ($mod_action) { 41 case 'ajax': 42 $html = $this->getSidebarAjaxContent(); 43 header('Content-Type: text/html; charset=UTF-8'); 44 echo $html; 45 break; 46 case 'index': 47 global $controller, $WT_TREE; 48 49 $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'); 50 51 $cart = Session::get('cart'); 52 $clip_ctrl = new ClippingsCart; 53 54 $controller = new PageController; 55 $controller 56 ->setPageTitle($this->getTitle()) 57 ->PageHeader() 58 ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) 59 ->addInlineJavascript('autocomplete();'); 60 61 echo '<script>'; 62 echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; 63 echo '</script>'; 64 65 if (!$cart[$WT_TREE->getTreeId()]) { 66 echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; 67 } 68 69 if ($clip_ctrl->action == 'add') { 70 $record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE); 71 if ($clip_ctrl->type === 'FAM') { ?> 72 <form action="module.php" method="get"> 73 <input type="hidden" name="mod" value="clippings"> 74 <input type="hidden" name="mod_action" value="index"> 75 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 76 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 77 <input type="hidden" name="action" value="add1"> 78 <table> 79 <thead> 80 <tr> 81 <td class="topbottombar"> 82 <?php echo I18N::translate('Add to the clippings cart'); ?> 83 </td> 84 </tr> 85 </thead> 86 <tbody> 87 <tr> 88 <td class="optionbox"> 89 <input type="radio" name="others" value="parents"> 90 <?php echo $record->getFullName(); ?> 91 </td> 92 </tr> 93 <tr> 94 <td class="optionbox"> 95 <input type="radio" name="others" value="members" checked> 96 <?php echo /* I18N: %s is a family (husband + wife) */ I18N::translate('%s and their children', $record->getFullName()); ?> 97 </td> 98 </tr> 99 <tr> 100 <td class="optionbox"> 101 <input type="radio" name="others" value="descendants"> 102 <?php echo /* I18N: %s is a family (husband + wife) */ I18N::translate('%s and their descendants', $record->getFullName()); ?> 103 </td> 104 </tr> 105 </tbody> 106 <tfoot> 107 <tr> 108 <td class="topbottombar"><input type="submit" value="<?php echo I18N::translate('continue'); ?>"> 109 </td> 110 </tr> 111 </tfoot> 112 </table> 113 </form> 114 <?php } elseif ($clip_ctrl->type === 'INDI') { ?> 115 <form action="module.php" method="get"> 116 <input type="hidden" name="mod" value="clippings"> 117 <input type="hidden" name="mod_action" value="index"> 118 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 119 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 120 <input type="hidden" name="action" value="add1"></td></tr> 121 <table> 122 <thead> 123 <tr> 124 <td class="topbottombar"> 125 <?php echo I18N::translate('Add to the clippings cart'); ?> 126 </td> 127 </tr> 128 </thead> 129 <tbody> 130 <tr> 131 <td class="optionbox"> 132 <label> 133 <input type="radio" name="others" checked value="none"> 134 <?php echo $record->getFullName(); ?> 135 </label> 136 </td> 137 </tr> 138 <tr> 139 <td class="optionbox"> 140 <label> 141 <input type="radio" name="others" value="parents"> 142 <?php 143 if ($record->getSex() === 'F') { 144 echo /* I18N: %s is a woman's name */ I18N::translate('%s, her parents and siblings', $record->getFullName()); 145 } else { 146 echo /* I18N: %s is a man's name */ I18N::translate('%s, his parents and siblings', $record->getFullName()); 147 } 148 ?> 149 </label> 150 </td> 151 </tr> 152 <tr> 153 <td class="optionbox"> 154 <label> 155 <input type="radio" name="others" value="members"> 156 <?php 157 if ($record->getSex() === 'F') { 158 echo /* I18N: %s is a woman's name */ I18N::translate('%s, her spouses and children', $record->getFullName()); 159 } else { 160 echo /* I18N: %s is a man's name */ I18N::translate('%s, his spouses and children', $record->getFullName()); 161 } 162 ?> 163 </label> 164 </td> 165 </tr> 166 <tr> 167 <td class="optionbox"> 168 <label> 169 <input type="radio" name="others" value="ancestors" id="ancestors"> 170 <?php 171 if ($record->getSex() === 'F') { 172 echo /* I18N: %s is a woman's name */ I18N::translate('%s and her ancestors', $record->getFullName()); 173 } else { 174 echo /* I18N: %s is a man's name */ I18N::translate('%s and his ancestors', $record->getFullName()); 175 } 176 ?> 177 </label> 178 <br> 179 180 <?php echo I18N::translate('Number of generations'); ?> 181 <input type="text" size="5" name="level1" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestors');"> 182 </td> 183 </tr> 184 <tr> 185 <td class="optionbox"> 186 <label> 187 <input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies"> 188 <?php 189 if ($record->getSex() === 'F') { 190 echo /* I18N: %s is a woman's name */ I18N::translate('%s, her ancestors and their families', $record->getFullName()); 191 } else { 192 echo /* I18N: %s is a man's name */ I18N::translate('%s, his ancestors and their families', $record->getFullName()); 193 } 194 ?> 195 </label> 196 <br > 197 198 <?php echo I18N::translate('Number of generations'); ?> 199 <input type="text" size="5" name="level2" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestorsfamilies');"> 200 </td> 201 </tr> 202 <tr> 203 <td class="optionbox"> 204 <label> 205 <input type="radio" name="others" value="descendants" id="descendants"> 206 <?php 207 if ($record->getSex() === 'F') { 208 echo /* I18N: %s is a woman's name */ I18N::translate('%s, her spouses and descendants', $record->getFullName()); 209 } else { 210 echo /* I18N: %s is a man's name */ I18N::translate('%s, his spouses and descendants', $record->getFullName()); 211 } 212 ?> 213 </label> 214 <br > 215 216 <?php echo I18N::translate('Number of generations'); ?> 217 <input type="text" size="5" name="level3" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('descendants');"> 218 </td> 219 </tr> 220 </tbody> 221 <tfoot> 222 <tr> 223 <td class="topbottombar"> 224 <input type="submit" value="<?php echo I18N::translate('continue'); ?>"> 225 </td> 226 </tr> 227 </tfoot> 228 </table> 229 </form> 230 <?php } elseif ($clip_ctrl->type === 'SOUR') { ?> 231 <form action="module.php" method="get"> 232 <input type="hidden" name="mod" value="clippings"> 233 <input type="hidden" name="mod_action" value="index"> 234 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 235 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 236 <input type="hidden" name="action" value="add1"></td></tr> 237 <table> 238 <thead> 239 <tr> 240 <td class="topbottombar"> 241 <?php echo I18N::translate('Add to the clippings cart'); ?> 242 </td> 243 </tr> 244 </thead> 245 <tbody> 246 <tr> 247 <td class="optionbox"> 248 <label> 249 <input type="radio" name="others" checked value="none"> 250 <?php echo $record->getFullName(); ?> 251 </label> 252 </td> 253 </tr> 254 <tr> 255 <td class="optionbox"> 256 <label> 257 <input type="radio" name="others" value="linked"> 258 <?php echo /* I18N: %s is the name of a source */ I18N::translate('%s and the individuals that reference it.', $record->getFullName()); ?> 259 </label> 260 </td> 261 </tr> 262 </tbody> 263 <tfoot> 264 <tr> 265 <td class="topbottombar"> 266 <input type="submit" value="<?php echo I18N::translate('continue'); ?>"> 267 </td> 268 </tr> 269 </tfoot> 270 </table> 271 </form> 272 <?php } 273 } 274 275 if (!$cart[$WT_TREE->getTreeId()]) { 276 if ($clip_ctrl->action != 'add') { 277 echo I18N::translate('The clippings cart allows you to take extracts (“clippings”) from this family tree and bundle them up into a single file for downloading and subsequent importing into your own genealogy program. The downloadable file is recorded in GEDCOM format.<br><ul><li>How to take clippings?<br>This is really simple. Whenever you see a clickable name (individual, family, or source) you can go to the Details page of that name. There you will see the <b>Add to clippings cart</b> option. When you click that link you will be offered several options to download.</li><li>How to download?<br>Once you have items in your cart, you can download them just by clicking the “Download” link. Follow the instructions and links.</li></ul>'); 278 ?> 279 <form method="get" name="addin" action="module.php"> 280 <input type="hidden" name="mod" value="clippings"> 281 <input type="hidden" name="mod_action" value="index"> 282 <table> 283 <thead> 284 <tr> 285 <td colspan="2" class="topbottombar"> 286 <?php echo I18N::translate('Add to the clippings cart'); ?> 287 </td> 288 </tr> 289 </thead> 290 <tbody> 291 <tr> 292 <td class="optionbox"> 293 <input type="hidden" name="action" value="add"> 294 <input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="5"> 295 </td> 296 <td class="optionbox"> 297 <?php echo print_findindi_link('cart_item_id'); ?> 298 <?php echo print_findfamily_link('cart_item_id'); ?> 299 <?php echo print_findsource_link('cart_item_id', ''); ?> 300 <input type="submit" value="<?php echo I18N::translate('Add'); ?>"> 301 </td> 302 </tr> 303 </tbody> 304 </table> 305 </form> 306 <?php 307 } 308 309 // -- end new lines 310 echo I18N::translate('Your clippings cart is empty.'); 311 } else { 312 // Keep track of the INDI from the parent page, otherwise it will 313 // get lost after ajax updates 314 $pid = Filter::get('pid', WT_REGEX_XREF); 315 316 if ($clip_ctrl->action != 'download' && $clip_ctrl->action != 'add') { ?> 317 <table><tr><td class="width33" valign="top" rowspan="3"> 318 <form method="get" action="module.php"> 319 <input type="hidden" name="mod" value="clippings"> 320 <input type="hidden" name="mod_action" value="index"> 321 <input type="hidden" name="action" value="download"> 322 <input type="hidden" name="pid" value="<?php echo $pid; ?>"> 323 <table> 324 <tr><td colspan="2" class="topbottombar"><h2><?php echo I18N::translate('Download'); ?></h2></td></tr> 325 <tr> 326 <td class="descriptionbox width50 wrap"> 327 <?php echo I18N::translate('To reduce the size of the download, you can compress the data into a .ZIP file. You will need to uncompress the .ZIP file before you can use it.'); ?> 328 </td> 329 <td class="optionbox wrap"> 330 <input type="checkbox" name="Zip" value="yes"> 331 <?php echo I18N::translate('Zip file(s)'); ?> 332 </td> 333 </tr> 334 <tr> 335 <td class="descriptionbox width50 wrap"> 336 <?php echo I18N::translate('Include media (automatically zips files)'); ?> 337 </td> 338 <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes"></td></tr> 339 340 <?php if (Auth::isManager($WT_TREE)) { ?> 341 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'); ?></td> 342 <td class="optionbox"> 343 <input type="radio" name="privatize_export" value="none" checked> <?php echo I18N::translate('None'); ?><br> 344 <input type="radio" name="privatize_export" value="gedadmin"> <?php echo I18N::translate('Manager'); ?><br> 345 <input type="radio" name="privatize_export" value="user"> <?php echo I18N::translate('Member'); ?><br> 346 <input type="radio" name="privatize_export" value="visitor"> <?php echo I18N::translate('Visitor'); ?> 347 </td></tr> 348 <?php } elseif (Auth::isMember($WT_TREE)) { ?> 349 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'); ?></td> 350 <td class="optionbox"> 351 <input type="radio" name="privatize_export" value="user" checked> <?php echo I18N::translate('Member'); ?><br> 352 <input type="radio" name="privatize_export" value="visitor"> <?php echo I18N::translate('Visitor'); ?> 353 </td></tr> 354 <?php } ?> 355 356 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Convert from UTF-8 to ISO-8859-1'); ?></td> 357 <td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr> 358 359 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Add the GEDCOM media path to filenames'); ?></td> 360 <td class="optionbox"> 361 <input type="checkbox" name="conv_path" value="<?php echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')); ?>"> 362 <span dir="auto"><?php echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')); ?></span> 363 </td></tr> 364 365 <tr><td class="topbottombar" colspan="2"> 366 <input type="submit" value="<?php echo I18N::translate('Download'); ?>"> 367 </form> 368 </td></tr> 369 </table> 370 </td></tr> 371 </table> 372 <br> 373 374 <form method="get" name="addin" action="module.php"> 375 <input type="hidden" name="mod" value="clippings"> 376 <input type="hidden" name="mod_action" value="index"> 377 <table> 378 <thead> 379 <tr> 380 <td colspan="2" class="topbottombar" style="text-align:center; "> 381 <?php echo I18N::translate('Add to the clippings cart'); ?> 382 </td> 383 </tr> 384 </thead> 385 <tbody> 386 <tr> 387 <td class="optionbox"> 388 <input type="hidden" name="action" value="add"> 389 <input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="8"> 390 </td> 391 <td class="optionbox"> 392 <?php echo print_findindi_link('cart_item_id'); ?> 393 <?php echo print_findfamily_link('cart_item_id'); ?> 394 <?php echo print_findsource_link('cart_item_id'); ?> 395 <input type="submit" value="<?php echo I18N::translate('Add'); ?>"> 396 </td> 397 </tr> 398 </tbody> 399 </table> 400 </form> 401 402 403 <?php } ?> 404 <br><a href="module.php?mod=clippings&mod_action=index&action=empty"><?php echo I18N::translate('Empty the clippings cart'); ?></a> 405 </td></tr> 406 407 <tr><td class="topbottombar"><h2><?php echo I18N::translate('Family tree clippings cart'); ?></h2></td></tr> 408 409 <tr><td valign="top"> 410 <table id="mycart" class="sortable list_table width100"> 411 <tr> 412 <th class="list_label"><?php echo I18N::translate('Record'); ?></th> 413 <th class="list_label"><?php echo I18N::translate('Remove'); ?></th> 414 </tr> 415 <?php 416 foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { 417 $record = GedcomRecord::getInstance($xref, $WT_TREE); 418 if ($record) { 419 switch ($record::RECORD_TYPE) { 420 case 'INDI': $icon = 'icon-indis'; break; 421 case 'FAM': $icon = 'icon-sfamily'; break; 422 case 'SOUR': $icon = 'icon-source'; break; 423 case 'REPO': $icon = 'icon-repository'; break; 424 case 'NOTE': $icon = 'icon-note'; break; 425 case 'OBJE': $icon = 'icon-media'; break; 426 default: $icon = 'icon-clippings'; break; 427 } 428 ?> 429 <tr><td class="list_value"> 430 <i class="<?php echo $icon; ?>"></i> 431 <?php 432 echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>'; 433 ?> 434 </td> 435 <td class="list_value center vmiddle"><a href="module.php?mod=clippings&mod_action=index&action=remove&id=<?php echo $xref; ?>" class="icon-remove" title="<?php echo I18N::translate('Remove'); ?>"></a></td> 436 </tr> 437 <?php 438 } 439 } 440 ?> 441 </table> 442 </td></tr></table> 443 <?php 444 } 445 break; 446 default: 447 http_response_code(404); 448 break; 449 } 450 } 451 452 /** {@inheritdoc} */ 453 public function defaultMenuOrder() { 454 return 20; 455 } 456 457 /** {@inheritdoc} */ 458 public function getMenu() { 459 global $controller, $WT_TREE; 460 461 if (Auth::isSearchEngine()) { 462 return null; 463 } 464 //-- main clippings menu item 465 $menu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . $WT_TREE->getNameUrl(), 'menu-clippings'); 466 if (isset($controller->record)) { 467 $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . $WT_TREE->getNameUrl(), 'menu-clippingscart'); 468 $menu->addSubmenu($submenu); 469 } 470 if (!empty($controller->record) && $controller->record->canShow()) { 471 $submenu = new Menu(I18N::translate('Add to the clippings cart'), 'module.php?mod=clippings&mod_action=index&action=add&id=' . $controller->record->getXref(), 'menu-clippingsadd'); 472 $menu->addSubmenu($submenu); 473 } 474 475 return $menu; 476 } 477 478 /** {@inheritdoc} */ 479 public function defaultSidebarOrder() { 480 return 60; 481 } 482 483 /** {@inheritdoc} */ 484 public function hasSidebarContent() { 485 if (Auth::isSearchEngine()) { 486 return false; 487 } else { 488 // Creating a controller has the side effect of initialising the cart 489 new ClippingsCart; 490 491 return true; 492 } 493 } 494 495 /** {@inheritdoc} */ 496 public function getSidebarContent() { 497 global $controller; 498 499 $controller->addInlineJavascript(' 500 jQuery("#sb_clippings_content").on("click", ".add_cart, .remove_cart", function() { 501 jQuery("#sb_clippings_content").load(this.href); 502 return false; 503 }); 504 '); 505 506 return '<div id="sb_clippings_content">' . $this->getCartList() . '</div>'; 507 } 508 509 /** {@inheritdoc} */ 510 public function getSidebarAjaxContent() { 511 global $WT_TREE; 512 513 $cart = Session::get('cart'); 514 515 $clip_ctrl = new ClippingsCart; 516 $add = Filter::get('add', WT_REGEX_XREF); 517 $add1 = Filter::get('add1', WT_REGEX_XREF); 518 $remove = Filter::get('remove', WT_REGEX_XREF); 519 $others = Filter::get('others'); 520 $clip_ctrl->level1 = Filter::getInteger('level1'); 521 $clip_ctrl->level2 = Filter::getInteger('level2'); 522 $clip_ctrl->level3 = Filter::getInteger('level3'); 523 if ($add) { 524 $record = GedcomRecord::getInstance($add, $WT_TREE); 525 if ($record) { 526 $clip_ctrl->id = $record->getXref(); 527 $clip_ctrl->type = $record::RECORD_TYPE; 528 $clip_ctrl->addClipping($record); 529 } 530 } elseif ($add1) { 531 $record = Individual::getInstance($add1, $WT_TREE); 532 if ($record) { 533 $clip_ctrl->id = $record->getXref(); 534 $clip_ctrl->type = $record::RECORD_TYPE; 535 if ($others == 'parents') { 536 foreach ($record->getChildFamilies() as $family) { 537 $clip_ctrl->addClipping($family); 538 $clip_ctrl->addFamilyMembers($family); 539 } 540 } elseif ($others == 'ancestors') { 541 $clip_ctrl->addAncestorsToCart($record, $clip_ctrl->level1); 542 } elseif ($others == 'ancestorsfamilies') { 543 $clip_ctrl->addAncestorsToCartFamilies($record, $clip_ctrl->level2); 544 } elseif ($others == 'members') { 545 foreach ($record->getSpouseFamilies() as $family) { 546 $clip_ctrl->addClipping($family); 547 $clip_ctrl->addFamilyMembers($family); 548 } 549 } elseif ($others == 'descendants') { 550 foreach ($record->getSpouseFamilies() as $family) { 551 $clip_ctrl->addClipping($family); 552 $clip_ctrl->addFamilyDescendancy($family, $clip_ctrl->level3); 553 } 554 } 555 } 556 } elseif ($remove) { 557 unset($cart[$WT_TREE->getTreeId()][$remove]); 558 Session::put('cart', $cart); 559 } elseif (isset($_REQUEST['empty'])) { 560 $cart[$WT_TREE->getTreeId()] = array(); 561 Session::put('cart', $cart); 562 } elseif (isset($_REQUEST['download'])) { 563 return $this->downloadForm($clip_ctrl); 564 } 565 566 return $this->getCartList(); 567 } 568 569 /** 570 * A list for the side bar. 571 * 572 * @return string 573 */ 574 public function getCartList() { 575 global $WT_TREE; 576 577 $cart = Session::get('cart', array()); 578 if (!array_key_exists($WT_TREE->getTreeId(), $cart)) { 579 $cart[$WT_TREE->getTreeId()] = array(); 580 } 581 $pid = Filter::get('pid', WT_REGEX_XREF); 582 583 if (!$cart[$WT_TREE->getTreeId()]) { 584 $out = I18N::translate('Your clippings cart is empty.'); 585 } else { 586 $out = '<ul>'; 587 foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { 588 $record = GedcomRecord::getInstance($xref, $WT_TREE); 589 if ($record instanceof Individual || $record instanceof Family) { 590 switch ($record::RECORD_TYPE) { 591 case 'INDI': 592 $icon = 'icon-indis'; 593 break; 594 case 'FAM': 595 $icon = 'icon-sfamily'; 596 break; 597 } 598 $out .= '<li>'; 599 if (!empty($icon)) { 600 $out .= '<i class="' . $icon . '"></i>'; 601 } 602 $out .= '<a href="' . $record->getHtmlUrl() . '">'; 603 if ($record instanceof Individual) { 604 $out .= $record->getSexImage(); 605 } 606 $out .= ' ' . $record->getFullName() . ' '; 607 if ($record instanceof Individual && $record->canShow()) { 608 $out .= ' (' . $record->getLifeSpan() . ')'; 609 } 610 $out .= '</a>'; 611 $out .= '<a class="icon-remove remove_cart" href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&remove=' . $xref . '&pid=' . $pid . '" title="' . I18N::translate('Remove') . '"></a>'; 612 $out .= '</li>'; 613 } 614 } 615 $out .= '</ul>'; 616 } 617 618 if ($cart[$WT_TREE->getTreeId()]) { 619 $out .= 620 '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&empty=true&pid=' . $pid . '" class="remove_cart">' . 621 I18N::translate('Empty the clippings cart') . 622 '</a>' . 623 '<br>' . 624 '<a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&download=true&pid=' . $pid . '" class="add_cart">' . 625 I18N::translate('Download') . 626 '</a>'; 627 } 628 $record = Individual::getInstance($pid, $WT_TREE); 629 if ($record && !array_key_exists($record->getXref(), $cart[$WT_TREE->getTreeId()])) { 630 $out .= '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&add=' . $pid . '&pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>'; 631 } 632 633 return $out; 634 } 635 636 /** 637 * @param ClippingsCart $clip_ctrl 638 * 639 * @return string 640 */ 641 public function downloadForm(ClippingsCart $clip_ctrl) { 642 global $WT_TREE; 643 644 $pid = Filter::get('pid', WT_REGEX_XREF); 645 646 $out = '<script>'; 647 $out .= 'function cancelDownload() { 648 var link = "module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&pid=' . $pid . '"; 649 jQuery("#sb_clippings_content").load(link); 650 }'; 651 $out .= '</script>'; 652 $out .= '<form method="get" action="module.php"> 653 <input type="hidden" name="mod" value="clippings"> 654 <input type="hidden" name="mod_action" value="index"> 655 <input type="hidden" name="pid" value="' . $pid . '"> 656 <input type="hidden" name="action" value="download"> 657 <table> 658 <tr><td colspan="2" class="topbottombar"><h2>' . I18N::translate('Download') . '</h2></td></tr> 659 <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Zip file(s)') . '</td> 660 <td class="optionbox"><input type="checkbox" name="Zip" value="yes" checked></td></tr> 661 662 <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Include media (automatically zips files)') . '</td> 663 <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes" checked></td></tr> 664 '; 665 666 if (Auth::isManager($WT_TREE)) { 667 $out .= 668 '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' . 669 '<td class="optionbox">' . 670 ' <input type="radio" name="privatize_export" value="none" checked> ' . I18N::translate('None') . '<br>' . 671 ' <input type="radio" name="privatize_export" value="gedadmin"> ' . I18N::translate('Manager') . '<br>' . 672 ' <input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' . 673 ' <input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . 674 '</td></tr>'; 675 } elseif (Auth::isMember($WT_TREE)) { 676 $out .= 677 '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' . 678 '<td class="list_value">' . 679 ' <input type="radio" name="privatize_export" value="user" checked> ' . I18N::translate('Member') . '<br>' . 680 ' <input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . 681 '</td></tr>'; 682 } 683 684 $out .= ' 685 <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Convert from UTF-8 to ISO-8859-1') . '</td> 686 <td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr> 687 688 <tr> 689 <td class="descriptionbox width50 wrap">' . I18N::translate('Add the GEDCOM media path to filenames') . '</td> 690 <td class="optionbox"> 691 <input type="checkbox" name="conv_path" value="' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '"> 692 <span dir="auto">' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '</span></td> 693 </tr> 694 695 <input type="hidden" name="conv_path" value="' . $clip_ctrl->conv_path . '"> 696 697 </td></tr> 698 699 <tr><td class="topbottombar" colspan="2"> 700 <input type="button" value="' . I18N::translate('Cancel') . '" onclick="cancelDownload();"> 701 <input type="submit" value="' . I18N::translate('Download') . '"> 702 </form>'; 703 704 return $out; 705 } 706 707} 708