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 19use Zend_Session; 20 21/** 22 * Class ClippingsCartModule 23 */ 24class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleSidebarInterface { 25 26 /** {@inheritdoc} */ 27 public function getTitle() { 28 return /* I18N: Name of a module */ I18N::translate('Clippings cart'); 29 } 30 31 /** {@inheritdoc} */ 32 public function getDescription() { 33 return /* I18N: Description of the “Clippings cart” module */ I18N::translate('Select records from your family tree and save them as a GEDCOM file.'); 34 } 35 36 /** {@inheritdoc} */ 37 public function defaultAccessLevel() { 38 return WT_PRIV_USER; 39 } 40 41 /** {@inheritdoc} */ 42 public function modAction($mod_action) { 43 switch ($mod_action) { 44 case 'ajax': 45 $html = $this->getSidebarAjaxContent(); 46 Zend_Session::writeClose(); 47 header('Content-Type: text/html; charset=UTF-8'); 48 echo $html; 49 break; 50 case 'index': 51 global $controller, $WT_SESSION, $WT_TREE; 52 53 $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'); 54 55 $clip_ctrl = new ClippingsCart; 56 57 $controller = new PageController; 58 $controller 59 ->setPageTitle($this->getTitle()) 60 ->PageHeader() 61 ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) 62 ->addInlineJavascript('autocomplete();'); 63 64 echo '<script>'; 65 echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; 66 echo '</script>'; 67 68 if (!$WT_SESSION->cart[WT_GED_ID]) { 69 echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; 70 } 71 72 if ($clip_ctrl->action == 'add') { 73 $person = GedcomRecord::getInstance($clip_ctrl->id); 74 echo '<h3><a href="', $person->getHtmlUrl(), '">' . $person->getFullName(), '</a></h3>'; 75 if ($clip_ctrl->type === 'FAM') { ?> 76 <form action="module.php" method="get"> 77 <input type="hidden" name="mod" value="clippings"> 78 <input type="hidden" name="mod_action" value="index"> 79 <table> 80 <tr><td class="topbottombar"><?php echo I18N::translate('Which other links from this family would you like to add?'); ?> 81 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 82 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 83 <input type="hidden" name="action" value="add1"></td></tr> 84 <tr><td class="optionbox"><input type="radio" name="others" checked value="none"><?php echo I18N::translate('Add just this family record.'); ?></td></tr> 85 <tr><td class="optionbox"><input type="radio" name="others" value="parents"><?php echo I18N::translate('Add parents’ records together with this family record.'); ?></td></tr> 86 <tr><td class="optionbox"><input type="radio" name="others" value="members"><?php echo I18N::translate('Add parents’ and children’s records together with this family record.'); ?></td></tr> 87 <tr><td class="optionbox"><input type="radio" name="others" value="descendants"><?php echo I18N::translate('Add parents’ and all descendants’ records together with this family record.'); ?></td></tr> 88 <tr><td class="topbottombar"><input type="submit" value="<?php echo I18N::translate('Continue adding'); ?>"></td></tr> 89 90 </table> 91 </form> 92 <?php } elseif ($clip_ctrl->type === 'INDI') { ?> 93 <form action="module.php" method="get"> 94 <input type="hidden" name="mod" value="clippings"> 95 <input type="hidden" name="mod_action" value="index"> 96 <table> 97 <tr><td class="topbottombar"><?php echo I18N::translate('Which links from this individual would you also like to add?'); ?> 98 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 99 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 100 <input type="hidden" name="action" value="add1"></td></tr> 101 <tr><td class="optionbox"><input type="radio" name="others" checked value="none"><?php echo I18N::translate('Add just this individual.'); ?></td></tr> 102 <tr><td class="optionbox"><input type="radio" name="others" value="parents"><?php echo I18N::translate('Add this individual, his parents, and siblings.'); ?></td></tr> 103 <tr><td class="optionbox"><input type="radio" name="others" value="ancestors" id="ancestors"><?php echo I18N::translate('Add this individual and his direct line ancestors.'); ?><br> 104 <?php echo I18N::translate('Number of generations:'); ?> <input type="text" size="5" name="level1" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestors');"></td></tr> 105 <tr><td class="optionbox"><input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies"><?php echo I18N::translate('Add this individual, his direct line ancestors, and their families.'); ?><br > 106 <?php echo I18N::translate('Number of generations:'); ?> <input type="text" size="5" name="level2" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestorsfamilies');"></td></tr> 107 <tr><td class="optionbox"><input type="radio" name="others" value="members"><?php echo I18N::translate('Add this individual, his spouse, and children.'); ?></td></tr> 108 <tr><td class="optionbox"><input type="radio" name="others" value="descendants" id="descendants"><?php echo I18N::translate('Add this individual, his spouse, and all descendants.'); ?><br > 109 <?php echo I18N::translate('Number of generations:'); ?> <input type="text" size="5" name="level3" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('descendants');"></td></tr> 110 <tr><td class="topbottombar"><input type="submit" value="<?php echo I18N::translate('Continue adding'); ?>"> 111 </table> 112 </form> 113 <?php } elseif ($clip_ctrl->type === 'SOUR') { ?> 114 <form action="module.php" method="get"> 115 <input type="hidden" name="mod" value="clippings"> 116 <input type="hidden" name="mod_action" value="index"> 117 <table> 118 <tr><td class="topbottombar"><?php echo I18N::translate('Which records linked to this source should be added?'); ?> 119 <input type="hidden" name="id" value="<?php echo $clip_ctrl->id; ?>"> 120 <input type="hidden" name="type" value="<?php echo $clip_ctrl->type; ?>"> 121 <input type="hidden" name="action" value="add1"></td></tr> 122 <tr><td class="optionbox"><input type="radio" name="others" checked value="none"><?php echo I18N::translate('Add just this source.'); ?></td></tr> 123 <tr><td class="optionbox"><input type="radio" name="others" value="linked"><?php echo I18N::translate('Add this source and families/individuals linked to it.'); ?></td></tr> 124 <tr><td class="topbottombar"><input type="submit" value="<?php echo I18N::translate('Continue adding'); ?>"> 125 </table> 126 </form> 127 <?php } 128 } 129 130 if (!$WT_SESSION->cart[WT_GED_ID]) { 131 if ($clip_ctrl->action != 'add') { 132 133 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>'); 134 ?> 135 <form method="get" name="addin" action="module.php"> 136 <input type="hidden" name="mod" value="clippings"> 137 <input type="hidden" name="mod_action" value="index"> 138 <table> 139 <tr> 140 <td colspan="2" class="topbottombar" style="text-align:center; "> 141 <?php echo I18N::translate('Enter an individual, family, or source ID'); ?> 142 </td> 143 </tr> 144 <tr> 145 <td class="optionbox"> 146 <input type="hidden" name="action" value="add"> 147 <input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="5"> 148 </td> 149 <td class="optionbox"> 150 <?php echo print_findindi_link('cart_item_id'); ?> 151 <?php echo print_findfamily_link('cart_item_id'); ?> 152 <?php echo print_findsource_link('cart_item_id', ''); ?> 153 <input type="submit" value="<?php echo I18N::translate('Add'); ?>"> 154 155 </td> 156 </tr> 157 </table> 158 </form> 159 <?php 160 } 161 162 // -- end new lines 163 echo I18N::translate('Your clippings cart is empty.'); 164 } else { 165 // Keep track of the INDI from the parent page, otherwise it will 166 // get lost after ajax updates 167 $pid = Filter::get('pid', WT_REGEX_XREF); 168 169 if ($clip_ctrl->action != 'download' && $clip_ctrl->action != 'add') { ?> 170 <table><tr><td class="width33" valign="top" rowspan="3"> 171 <form method="get" action="module.php"> 172 <input type="hidden" name="mod" value="clippings"> 173 <input type="hidden" name="mod_action" value="index"> 174 <input type="hidden" name="action" value="download"> 175 <input type="hidden" name="pid" value="<?php echo $pid; ?>"> 176 <table> 177 <tr><td colspan="2" class="topbottombar"><h2><?php echo I18N::translate('Download'); ?></h2></td></tr> 178 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Zip file(s)'), help_link('zip'); ?></td> 179 <td class="optionbox"><input type="checkbox" name="Zip" value="yes"></td></tr> 180 181 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Include media (automatically zips files)'), help_link('include_media'); ?></td> 182 <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes"></td></tr> 183 184 <?php if (WT_USER_GEDCOM_ADMIN) { ?> 185 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'), help_link('apply_privacy'); ?></td> 186 <td class="optionbox"> 187 <input type="radio" name="privatize_export" value="none" checked> <?php echo I18N::translate('None'); ?><br> 188 <input type="radio" name="privatize_export" value="gedadmin"> <?php echo I18N::translate('Manager'); ?><br> 189 <input type="radio" name="privatize_export" value="user"> <?php echo I18N::translate('Member'); ?><br> 190 <input type="radio" name="privatize_export" value="visitor"> <?php echo I18N::translate('Visitor'); ?> 191 </td></tr> 192 <?php } elseif (WT_USER_CAN_ACCESS) { ?> 193 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'), help_link('apply_privacy'); ?></td> 194 <td class="optionbox"> 195 <input type="radio" name="privatize_export" value="user" checked> <?php echo I18N::translate('Member'); ?><br> 196 <input type="radio" name="privatize_export" value="visitor"> <?php echo I18N::translate('Visitor'); ?> 197 </td></tr> 198 <?php } ?> 199 200 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Convert from UTF-8 to ISO-8859-1'), help_link('utf8_ansi'); ?></td> 201 <td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr> 202 203 <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Add the GEDCOM media path to filenames'), help_link('GEDCOM_MEDIA_PATH'); ?></td> 204 <td class="optionbox"> 205 <input type="checkbox" name="conv_path" value="<?php echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')); ?>"> 206 <span dir="auto"><?php echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')); ?></span> 207 </td></tr> 208 209 <tr><td class="topbottombar" colspan="2"> 210 <input type="submit" value="<?php echo I18N::translate('Download'); ?>"> 211 </form> 212 </td></tr> 213 </table> 214 </td></tr> 215 </table> 216 <br> 217 218 <form method="get" name="addin" action="module.php"> 219 <input type="hidden" name="mod" value="clippings"> 220 <input type="hidden" name="mod_action" value="index"> 221 <table> 222 <tr> 223 <td colspan="2" class="topbottombar" style="text-align:center; "> 224 <?php echo I18N::translate('Enter an individual, family, or source ID'); ?> 225 </td> 226 </tr> 227 <tr> 228 <td class="optionbox"> 229 <input type="hidden" name="action" value="add"> 230 <input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="8"> 231 </td> 232 <td class="optionbox"> 233 <?php echo print_findindi_link('cart_item_id'); ?> 234 <?php echo print_findfamily_link('cart_item_id'); ?> 235 <?php echo print_findsource_link('cart_item_id'); ?> 236 <input type="submit" value="<?php echo I18N::translate('Add'); ?>"> 237 238 </td> 239 </tr> 240 </table> 241 </form> 242 243 244 <?php } ?> 245 <br><a href="module.php?mod=clippings&mod_action=index&action=empty"><?php echo I18N::translate('Empty the clippings cart'); ?></a> 246 </td></tr> 247 248 <tr><td class="topbottombar"><h2><?php echo I18N::translate('Family tree clippings cart'); ?></h2></td></tr> 249 250 <tr><td valign="top"> 251 <table id="mycart" class="sortable list_table width100"> 252 <tr> 253 <th class="list_label"><?php echo I18N::translate('Record'); ?></th> 254 <th class="list_label"><?php echo I18N::translate('Remove'); ?></th> 255 </tr> 256 <?php 257 foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { 258 $record = GedcomRecord::getInstance($xref); 259 if ($record) { 260 switch ($record::RECORD_TYPE) { 261 case 'INDI': $icon = 'icon-indis'; break; 262 case 'FAM': $icon = 'icon-sfamily'; break; 263 case 'SOUR': $icon = 'icon-source'; break; 264 case 'REPO': $icon = 'icon-repository'; break; 265 case 'NOTE': $icon = 'icon-note'; break; 266 case 'OBJE': $icon = 'icon-media'; break; 267 default: $icon = 'icon-clippings'; break; 268 } 269 ?> 270 <tr><td class="list_value"> 271 <i class="<?php echo $icon; ?>"></i> 272 <?php 273 echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>'; 274 ?> 275 </td> 276 <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> 277 </tr> 278 <?php 279 } 280 } 281 ?> 282 </table> 283 </td></tr></table> 284 <?php 285 } 286 break; 287 default: 288 http_response_code(404); 289 break; 290 } 291 } 292 293 /** {@inheritdoc} */ 294 public function defaultMenuOrder() { 295 return 20; 296 } 297 298 /** {@inheritdoc} */ 299 public function getMenu() { 300 global $controller; 301 302 if (Auth::isSearchEngine()) { 303 return null; 304 } 305 //-- main clippings menu item 306 $menu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . WT_GEDURL, 'menu-clippings'); 307 if (isset($controller->record)) { 308 $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . WT_GEDURL, 'menu-clippingscart'); 309 $menu->addSubmenu($submenu); 310 } 311 if (!empty($controller->record) && $controller->record->canShow()) { 312 $submenu = new Menu(I18N::translate('Add to clippings cart'), 'module.php?mod=clippings&mod_action=index&action=add&id=' . $controller->record->getXref(), 'menu-clippingsadd'); 313 $menu->addSubmenu($submenu); 314 } 315 return $menu; 316 } 317 318 /** {@inheritdoc} */ 319 public function defaultSidebarOrder() { 320 return 60; 321 } 322 323 /** {@inheritdoc} */ 324 public function hasSidebarContent() { 325 if (Auth::isSearchEngine()) { 326 return false; 327 } else { 328 // Creating a controller has the side effect of initialising the cart 329 new ClippingsCart; 330 331 return true; 332 } 333 } 334 335 /** {@inheritdoc} */ 336 public function getSidebarContent() { 337 global $controller; 338 339 $controller->addInlineJavascript(' 340 jQuery("#sb_clippings_content").on("click", ".add_cart, .remove_cart", function() { 341 jQuery("#sb_clippings_content").load(this.href); 342 return false; 343 }); 344 '); 345 346 return '<div id="sb_clippings_content">' . $this->getCartList() . '</div>'; 347 } 348 349 /** {@inheritdoc} */ 350 public function getSidebarAjaxContent() { 351 global $WT_SESSION; 352 353 $clip_ctrl = new ClippingsCart; 354 $add = Filter::get('add', WT_REGEX_XREF); 355 $add1 = Filter::get('add1', WT_REGEX_XREF); 356 $remove = Filter::get('remove', WT_REGEX_XREF); 357 $others = Filter::get('others'); 358 $clip_ctrl->level1 = Filter::getInteger('level1'); 359 $clip_ctrl->level2 = Filter::getInteger('level2'); 360 $clip_ctrl->level3 = Filter::getInteger('level3'); 361 if ($add) { 362 $record = GedcomRecord::getInstance($add); 363 if ($record) { 364 $clip_ctrl->id = $record->getXref(); 365 $clip_ctrl->type = $record::RECORD_TYPE; 366 $clip_ctrl->addClipping($record); 367 } 368 } elseif ($add1) { 369 $record = Individual::getInstance($add1); 370 if ($record) { 371 $clip_ctrl->id = $record->getXref(); 372 $clip_ctrl->type = $record::RECORD_TYPE; 373 if ($others == 'parents') { 374 foreach ($record->getChildFamilies() as $family) { 375 $clip_ctrl->addClipping($family); 376 $clip_ctrl->addFamilyMembers($family); 377 } 378 } elseif ($others == 'ancestors') { 379 $clip_ctrl->addAncestorsToCart($record, $clip_ctrl->level1); 380 } elseif ($others == 'ancestorsfamilies') { 381 $clip_ctrl->addAncestorsToCartFamilies($record, $clip_ctrl->level2); 382 } elseif ($others == 'members') { 383 foreach ($record->getSpouseFamilies() as $family) { 384 $clip_ctrl->addClipping($family); 385 $clip_ctrl->addFamilyMembers($family); 386 } 387 } elseif ($others == 'descendants') { 388 foreach ($record->getSpouseFamilies() as $family) { 389 $clip_ctrl->addClipping($family); 390 $clip_ctrl->addFamilyDescendancy($family, $clip_ctrl->level3); 391 } 392 } 393 } 394 } elseif ($remove) { 395 unset ($WT_SESSION->cart[WT_GED_ID][$remove]); 396 } elseif (isset($_REQUEST['empty'])) { 397 $WT_SESSION->cart[WT_GED_ID] = array(); 398 } elseif (isset($_REQUEST['download'])) { 399 return $this->downloadForm($clip_ctrl); 400 } 401 return $this->getCartList(); 402 } 403 404 /** 405 * A list for the side bar. 406 * 407 * @return string 408 */ 409 public function getCartList() { 410 global $WT_SESSION; 411 412 // Keep track of the INDI from the parent page, otherwise it will 413 // get lost after ajax updates 414 $pid = Filter::get('pid', WT_REGEX_XREF); 415 416 if (!$WT_SESSION->cart[WT_GED_ID]) { 417 $out = I18N::translate('Your clippings cart is empty.'); 418 } else { 419 $out = '<ul>'; 420 foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { 421 $record = GedcomRecord::getInstance($xref); 422 if ($record instanceof Individual || $record instanceof Family) { 423 switch ($record::RECORD_TYPE) { 424 case 'INDI': 425 $icon = 'icon-indis'; 426 break; 427 case 'FAM': 428 $icon = 'icon-sfamily'; 429 break; 430 } 431 $out .= '<li>'; 432 if (!empty($icon)) { 433 $out .= '<i class="' . $icon . '"></i>'; 434 } 435 $out .= '<a href="' . $record->getHtmlUrl() . '">'; 436 if ($record instanceof Individual) { 437 $out .= $record->getSexImage(); 438 } 439 $out .= ' ' . $record->getFullName() . ' '; 440 if ($record instanceof Individual && $record->canShow()) { 441 $out .= ' (' . $record->getLifeSpan() . ')'; 442 } 443 $out .= '</a>'; 444 $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>'; 445 $out .= '</li>'; 446 } 447 } 448 $out .= '</ul>'; 449 } 450 451 if ($WT_SESSION->cart[WT_GED_ID]) { 452 $out .= 453 '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&empty=true&pid=' . $pid . '" class="remove_cart">' . 454 I18N::translate('Empty the clippings cart') . 455 '</a>' . 456 '<br>' . 457 '<a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&download=true&pid=' . $pid . '" class="add_cart">' . 458 I18N::translate('Download') . 459 '</a>'; 460 } 461 $record = Individual::getInstance($pid); 462 if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) { 463 $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>'; 464 } 465 return $out; 466 } 467 468 /** 469 * @param Individual $person 470 * 471 * @return string 472 */ 473 public function askAddOptions(Individual $person) { 474 $MAX_PEDIGREE_GENERATIONS = $person->getTree()->getPreference('MAX_PEDIGREE_GENERATIONS'); 475 476 $out = '<h3><a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a></h3>'; 477 $out .= '<script>'; 478 $out .= 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;} 479 function continueAjax(frm) { 480 var others = jQuery("input[name=\'others\']:checked").val(); 481 var link = "module.php?mod='.$this->getName() . '&mod_action=ajax&sb_action=clippings&add1="+frm.pid.value+"&others="+others+"&level1="+frm.level1.value+"&level2="+frm.level2.value+"&level3="+frm.level3.value; 482 jQuery("#sb_clippings_content").load(link); 483 }'; 484 $out .= '</script>'; 485 if ($person instanceof Family) { 486 $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> 487 <input type="hidden" name="mod" value="clippings"> 488 <input type="hidden" name="mod_action" value="index"> 489 <table> 490 <tr><td class="topbottombar">' . I18N::translate('Which other links from this family would you like to add?') . ' 491 <input type="hidden" name="pid" value="'.$person->getXref() . '"> 492 <input type="hidden" name="type" value="'.$person::RECORD_TYPE . '"> 493 <input type="hidden" name="action" value="add1"></td></tr> 494 <tr><td class="optionbox"><input type="radio" name="others" checked value="none">'. I18N::translate('Add just this family record.') . '</td></tr> 495 <tr><td class="optionbox"><input type="radio" name="others" value="parents">'. I18N::translate('Add parents’ records together with this family record.') . '</td></tr> 496 <tr><td class="optionbox"><input type="radio" name="others" value="members">'. I18N::translate('Add parents’ and children’s records together with this family record.') . '</td></tr> 497 <tr><td class="optionbox"><input type="radio" name="others" value="descendants">'. I18N::translate('Add parents’ and all descendants’ records together with this family record.') . '</td></tr> 498 <tr><td class="topbottombar"><input type="submit" value="'. I18N::translate('Continue adding') . '"></td></tr> 499 </table> 500 </form>'; 501 } elseif ($person instanceof Individual) { 502 $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> 503 <input type="hidden" name="mod" value="clippings"> 504 <input type="hidden" name="mod_action" value="index"> 505 ' . I18N::translate('Which links from this individual would you also like to add?') . ' 506 <input type="hidden" name="pid" value="'.$person->getXref() . '"> 507 <input type="hidden" name="type" value="'.$person::RECORD_TYPE . '"> 508 <input type="hidden" name="action" value="add1"> 509 <ul> 510 <li><input type="radio" name="others" checked value="none">'. I18N::translate('Add just this individual.') . '</li> 511 <li><input type="radio" name="others" value="parents">'. I18N::translate('Add this individual, his parents, and siblings.') . '</li> 512 <li><input type="radio" name="others" value="ancestors" id="ancestors">'. I18N::translate('Add this individual and his direct line ancestors.') . '<br> 513 '. I18N::translate('Number of generations:') . '<input type="text" size="4" name="level1" value="' . $MAX_PEDIGREE_GENERATIONS . '" onfocus="radAncestors(\'ancestors\');"></li> 514 <li><input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies">'. I18N::translate('Add this individual, his direct line ancestors, and their families.') . '<br> 515 '. I18N::translate('Number of generations:') . ' <input type="text" size="4" name="level2" value="' . $MAX_PEDIGREE_GENERATIONS . '" onfocus="radAncestors(\'ancestorsfamilies\');"></li> 516 <li><input type="radio" name="others" value="members">'. I18N::translate('Add this individual, his spouse, and children.') . '</li> 517 <li><input type="radio" name="others" value="descendants" id="descendants">'. I18N::translate('Add this individual, his spouse, and all descendants.') . '<br > 518 '. I18N::translate('Number of generations:') . ' <input type="text" size="4" name="level3" value="' . $MAX_PEDIGREE_GENERATIONS . '" onfocus="radAncestors(\'descendants\');"></li> 519 </ul> 520 <input type="submit" value="'. I18N::translate('Continue adding') . '"> 521 </form>'; 522 } else if ($person instanceof Source) { 523 $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> 524 <input type="hidden" name="mod" value="clippings"> 525 <input type="hidden" name="mod_action" value="index"> 526 <table> 527 <tr><td class="topbottombar">' . I18N::translate('Which records linked to this source should be added?') . ' 528 <input type="hidden" name="pid" value="'.$person->getXref() . '"> 529 <input type="hidden" name="type" value="'.$person::RECORD_TYPE . '"> 530 <input type="hidden" name="action" value="add1"></td></tr> 531 <tr><td class="optionbox"><input type="radio" name="others" checked value="none">'. I18N::translate('Add just this source.') . '</td></tr> 532 <tr><td class="optionbox"><input type="radio" name="others" value="linked">'. I18N::translate('Add this source and families/individuals linked to it.') . '</td></tr> 533 <tr><td class="topbottombar"><input type="submit" value="'. I18N::translate('Continue adding') . '"> 534 </table> 535 </form>'; 536 } else { 537 return $this->getSidebarContent(); 538 } 539 return $out; 540 } 541 542 /** 543 * @param ClippingsCart $clip_ctrl 544 * 545 * @return string 546 */ 547 public function downloadForm(ClippingsCart $clip_ctrl) { 548 global $WT_TREE; 549 550 $pid = Filter::get('pid', WT_REGEX_XREF); 551 552 $out = '<script>'; 553 $out .= 'function cancelDownload() { 554 var link = "module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&pid=' . $pid . '"; 555 jQuery("#sb_clippings_content").load(link); 556 }'; 557 $out .= '</script>'; 558 $out .= '<form method="get" action="module.php"> 559 <input type="hidden" name="mod" value="clippings"> 560 <input type="hidden" name="mod_action" value="index"> 561 <input type="hidden" name="pid" value="' .$pid . '"> 562 <input type="hidden" name="action" value="download"> 563 <table> 564 <tr><td colspan="2" class="topbottombar"><h2>'. I18N::translate('Download') . '</h2></td></tr> 565 <tr><td class="descriptionbox width50 wrap">'. I18N::translate('Zip file(s)') . help_link('zip') . '</td> 566 <td class="optionbox"><input type="checkbox" name="Zip" value="yes" checked></td></tr> 567 568 <tr><td class="descriptionbox width50 wrap">'. I18N::translate('Include media (automatically zips files)') . help_link('include_media') . '</td> 569 <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes" checked></td></tr> 570 '; 571 572 if (WT_USER_GEDCOM_ADMIN) { 573 $out .= 574 '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . help_link('apply_privacy') . '</td>' . 575 '<td class="optionbox">' . 576 ' <input type="radio" name="privatize_export" value="none" checked> ' . I18N::translate('None') . '<br>' . 577 ' <input type="radio" name="privatize_export" value="gedadmin"> ' . I18N::translate('Manager') . '<br>' . 578 ' <input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' . 579 ' <input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . 580 '</td></tr>'; 581 } elseif (WT_USER_CAN_ACCESS) { 582 $out .= 583 '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . help_link('apply_privacy') . '</td>' . 584 '<td class="list_value">' . 585 ' <input type="radio" name="privatize_export" value="user" checked> ' . I18N::translate('Member') . '<br>' . 586 ' <input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . 587 '</td></tr>'; 588 } 589 590 $out .= ' 591 <tr><td class="descriptionbox width50 wrap">'. I18N::translate('Convert from UTF-8 to ISO-8859-1') . help_link('utf8_ansi') . '</td> 592 <td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr> 593 594 <tr> 595 <td class="descriptionbox width50 wrap">'. I18N::translate('Add the GEDCOM media path to filenames') . help_link('GEDCOM_MEDIA_PATH') . '</td> 596 <td class="optionbox"> 597 <input type="checkbox" name="conv_path" value="' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '"> 598 <span dir="auto">' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '</span></td> 599 </tr> 600 601 <input type="hidden" name="conv_path" value="'.$clip_ctrl->conv_path . '"> 602 603 </td></tr> 604 605 <tr><td class="topbottombar" colspan="2"> 606 <input type="button" value="'. I18N::translate('Cancel') . '" onclick="cancelDownload();"> 607 <input type="submit" value="'. I18N::translate('Download') . '"> 608 </form>'; 609 610 return $out; 611 } 612 613} 614