diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-04-26 14:26:55 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-04-26 14:27:05 +0100 |
| commit | 31bc7874190e33336a5ff742eac1246d7473e530 (patch) | |
| tree | bfd9d4cf8570ef955fa1627583bc08461e84cb7d /app/Module/ClippingsCartModule.php | |
| parent | c6310c76a32767ad2a02c7050e92fbc8506572e8 (diff) | |
| download | webtrees-31bc7874190e33336a5ff742eac1246d7473e530.tar.gz webtrees-31bc7874190e33336a5ff742eac1246d7473e530.tar.bz2 webtrees-31bc7874190e33336a5ff742eac1246d7473e530.zip | |
Replace Zend_Session with our own class
Diffstat (limited to 'app/Module/ClippingsCartModule.php')
| -rw-r--r-- | app/Module/ClippingsCartModule.php | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php index 66dffedca9..bf5ff3fe7d 100644 --- a/app/Module/ClippingsCartModule.php +++ b/app/Module/ClippingsCartModule.php @@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -use Zend_Session; - /** * Class ClippingsCartModule */ @@ -43,15 +41,15 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, switch ($mod_action) { case 'ajax': $html = $this->getSidebarAjaxContent(); - Zend_Session::writeClose(); header('Content-Type: text/html; charset=UTF-8'); echo $html; break; case 'index': - global $controller, $WT_SESSION, $WT_TREE; + global $controller, $WT_TREE; $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'); + $cart = Session::get('cart'); $clip_ctrl = new ClippingsCart; $controller = new PageController; @@ -65,7 +63,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; echo '</script>'; - if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { + if (!$cart[$WT_TREE->getTreeId()]) { echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; } @@ -275,7 +273,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, <?php } } - if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { + if (!$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>'); ?> @@ -416,7 +414,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, <th class="list_label"><?php echo I18N::translate('Remove'); ?></th> </tr> <?php - foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) { + foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { $record = GedcomRecord::getInstance($xref, $WT_TREE); if ($record) { switch ($record::RECORD_TYPE) { @@ -510,7 +508,9 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, /** {@inheritdoc} */ public function getSidebarAjaxContent() { - global $WT_SESSION, $WT_TREE; + global $WT_TREE; + + $cart = Session::get('cart'); $clip_ctrl = new ClippingsCart; $add = Filter::get('add', WT_REGEX_XREF); @@ -554,12 +554,15 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, } } } elseif ($remove) { - unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$remove]); + unset ($cart[$WT_TREE->getTreeId()][$remove]); + Session::put('cart', $cart); } elseif (isset($_REQUEST['empty'])) { - $WT_SESSION->cart[$WT_TREE->getTreeId()] = array(); + $cart[$WT_TREE->getTreeId()] = array(); + Session::put('cart', $cart); } elseif (isset($_REQUEST['download'])) { return $this->downloadForm($clip_ctrl); } + return $this->getCartList(); } @@ -569,17 +572,19 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, * @return string */ public function getCartList() { - global $WT_SESSION, $WT_TREE; + global $WT_TREE; - // Keep track of the INDI from the parent page, otherwise it will - // get lost after ajax updates + $cart = Session::get('cart', array()); + if (!array_key_exists($WT_TREE->getTreeId(), $cart)) { + $cart[$WT_TREE->getTreeId()] = array(); + } $pid = Filter::get('pid', WT_REGEX_XREF); - if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { + if (!$cart[$WT_TREE->getTreeId()]) { $out = I18N::translate('Your clippings cart is empty.'); } else { $out = '<ul>'; - foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) { + foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { $record = GedcomRecord::getInstance($xref, $WT_TREE); if ($record instanceof Individual || $record instanceof Family) { switch ($record::RECORD_TYPE) { @@ -610,7 +615,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, $out .= '</ul>'; } - if ($WT_SESSION->cart[$WT_TREE->getTreeId()]) { + if ($cart[$WT_TREE->getTreeId()]) { $out .= '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&empty=true&pid=' . $pid . '" class="remove_cart">' . I18N::translate('Empty the clippings cart') . @@ -621,7 +626,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface, '</a>'; } $record = Individual::getInstance($pid, $WT_TREE); - if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[$WT_TREE->getTreeId()])) { + if ($record && !array_key_exists($record->getXref(), $cart[$WT_TREE->getTreeId()])) { $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>'; } return $out; |
