summaryrefslogtreecommitdiff
path: root/app/Module/ClippingsCartModule.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2015-03-08 17:09:41 +0000
committerGreg Roach <fisharebest@gmail.com>2015-03-09 00:08:53 +0000
commit24ec66ce7e77188cd2495b0f8d4dd0ae6e8c9c52 (patch)
tree0059c30afd4b78da23f28067165a7b17415924d8 /app/Module/ClippingsCartModule.php
parent3763c3f2dff6a4360b7b8810b6250e372dded805 (diff)
downloadwebtrees-24ec66ce7e77188cd2495b0f8d4dd0ae6e8c9c52.tar.gz
webtrees-24ec66ce7e77188cd2495b0f8d4dd0ae6e8c9c52.tar.bz2
webtrees-24ec66ce7e77188cd2495b0f8d4dd0ae6e8c9c52.zip
Use Tree object instead of ID/name
Diffstat (limited to 'app/Module/ClippingsCartModule.php')
-rw-r--r--app/Module/ClippingsCartModule.php34
1 files changed, 17 insertions, 17 deletions
diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php
index 00350cd1a4..c1726d9712 100644
--- a/app/Module/ClippingsCartModule.php
+++ b/app/Module/ClippingsCartModule.php
@@ -65,12 +65,12 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
echo '</script>';
- if (!$WT_SESSION->cart[WT_GED_ID]) {
+ if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>';
}
if ($clip_ctrl->action == 'add') {
- $person = GedcomRecord::getInstance($clip_ctrl->id);
+ $person = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE);
echo '<h3><a href="', $person->getHtmlUrl(), '">' . $person->getFullName(), '</a></h3>';
if ($clip_ctrl->type === 'FAM') { ?>
<form action="module.php" method="get">
@@ -127,7 +127,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
<?php }
}
- if (!$WT_SESSION->cart[WT_GED_ID]) {
+ if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
if ($clip_ctrl->action != 'add') {
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>');
@@ -263,8 +263,8 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
<th class="list_label"><?php echo I18N::translate('Remove'); ?></th>
</tr>
<?php
- foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) {
- $record = GedcomRecord::getInstance($xref);
+ foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ $record = GedcomRecord::getInstance($xref, $WT_TREE);
if ($record) {
switch ($record::RECORD_TYPE) {
case 'INDI': $icon = 'icon-indis'; break;
@@ -357,7 +357,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
/** {@inheritdoc} */
public function getSidebarAjaxContent() {
- global $WT_SESSION;
+ global $WT_SESSION, $WT_TREE;
$clip_ctrl = new ClippingsCart;
$add = Filter::get('add', WT_REGEX_XREF);
@@ -368,14 +368,14 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
$clip_ctrl->level2 = Filter::getInteger('level2');
$clip_ctrl->level3 = Filter::getInteger('level3');
if ($add) {
- $record = GedcomRecord::getInstance($add);
+ $record = GedcomRecord::getInstance($add, $WT_TREE);
if ($record) {
$clip_ctrl->id = $record->getXref();
$clip_ctrl->type = $record::RECORD_TYPE;
$clip_ctrl->addClipping($record);
}
} elseif ($add1) {
- $record = Individual::getInstance($add1);
+ $record = Individual::getInstance($add1, $WT_TREE);
if ($record) {
$clip_ctrl->id = $record->getXref();
$clip_ctrl->type = $record::RECORD_TYPE;
@@ -401,9 +401,9 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
}
}
} elseif ($remove) {
- unset ($WT_SESSION->cart[WT_GED_ID][$remove]);
+ unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$remove]);
} elseif (isset($_REQUEST['empty'])) {
- $WT_SESSION->cart[WT_GED_ID] = array();
+ $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
} elseif (isset($_REQUEST['download'])) {
return $this->downloadForm($clip_ctrl);
}
@@ -416,18 +416,18 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
* @return string
*/
public function getCartList() {
- global $WT_SESSION;
+ global $WT_SESSION, $WT_TREE;
// Keep track of the INDI from the parent page, otherwise it will
// get lost after ajax updates
$pid = Filter::get('pid', WT_REGEX_XREF);
- if (!$WT_SESSION->cart[WT_GED_ID]) {
+ if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
$out = I18N::translate('Your clippings cart is empty.');
} else {
$out = '<ul>';
- foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) {
- $record = GedcomRecord::getInstance($xref);
+ foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ $record = GedcomRecord::getInstance($xref, $WT_TREE);
if ($record instanceof Individual || $record instanceof Family) {
switch ($record::RECORD_TYPE) {
case 'INDI':
@@ -457,7 +457,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
$out .= '</ul>';
}
- if ($WT_SESSION->cart[WT_GED_ID]) {
+ if ($WT_SESSION->cart[$WT_TREE->getTreeId()]) {
$out .=
'<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;empty=true&amp;pid=' . $pid . '" class="remove_cart">' .
I18N::translate('Empty the clippings cart') .
@@ -467,8 +467,8 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS
I18N::translate('Download') .
'</a>';
}
- $record = Individual::getInstance($pid);
- if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) {
+ $record = Individual::getInstance($pid, $WT_TREE);
+ if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
$out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;add=' . $pid . '&amp;pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>';
}
return $out;