summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Auth.php15
-rw-r--r--app/Controller/AjaxController.php4
-rw-r--r--app/Controller/BaseController.php5
-rw-r--r--app/Controller/IndividualController.php4
-rw-r--r--app/Controller/LifespanController.php10
-rw-r--r--app/Controller/PageController.php5
-rw-r--r--app/Controller/SearchController.php6
-rw-r--r--app/Filter.php10
-rw-r--r--app/FlashMessages.php23
-rw-r--r--app/HitCounter.php18
-rw-r--r--app/I18N.php6
-rw-r--r--app/Module/ClippingsCart/ClippingsCart.php36
-rw-r--r--app/Module/ClippingsCartModule.php39
-rw-r--r--app/Module/DescendancyModule.php3
-rw-r--r--app/Module/FamiliesSidebarSidebarModule.php3
-rw-r--r--app/Module/GoogleMapsModule.php2
-rw-r--r--app/Module/IndividualSidebarModule.php3
-rw-r--r--app/Module/InteractiveTreeModule.php4
-rw-r--r--app/Module/SiteMapModule.php3
-rw-r--r--app/Session.php110
-rw-r--r--app/Theme/BaseTheme.php17
-rw-r--r--app/Theme/ColorsTheme.php4
22 files changed, 185 insertions, 145 deletions
diff --git a/app/Auth.php b/app/Auth.php
index 45f3afc791..0bda01a7d1 100644
--- a/app/Auth.php
+++ b/app/Auth.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class Auth - authentication functions
*/
@@ -156,9 +154,7 @@ class Auth {
* @return string|null
*/
public static function id() {
- global $WT_SESSION;
-
- return $WT_SESSION ? $WT_SESSION->wt_user : null;
+ return Session::get('wt_user');
}
/**
@@ -187,17 +183,14 @@ class Auth {
* @param User $user
*/
public static function login(User $user) {
- global $WT_SESSION;
-
- $WT_SESSION->wt_user = $user->getUserId();
- Zend_Session::regenerateId();
+ Session::put('wt_user', $user->getUserId());
+ Session::regenerate(false);
}
/**
* End the session for the current user.
*/
public static function logout() {
- Zend_Session::regenerateId();
- Zend_Session::destroy();
+ Session::regenerate(true);
}
}
diff --git a/app/Controller/AjaxController.php b/app/Controller/AjaxController.php
index d43820e463..b39dd9230b 100644
--- a/app/Controller/AjaxController.php
+++ b/app/Controller/AjaxController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class AjaxController - Base controller for all popup pages
*/
@@ -27,8 +25,6 @@ class AjaxController extends BaseController {
* @return $this
*/
public function pageHeader() {
- // We have finished writing session data, so release the lock
- Zend_Session::writeClose();
// Ajax responses are always UTF8
header('Content-Type: text/html; charset=UTF-8');
$this->page_header = true;
diff --git a/app/Controller/BaseController.php b/app/Controller/BaseController.php
index f7587b0665..53da165b17 100644
--- a/app/Controller/BaseController.php
+++ b/app/Controller/BaseController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class BaseController - Base controller for all other controllers
*/
@@ -130,9 +128,6 @@ class BaseController {
* @return $this
*/
public function pageHeader() {
- // Once we've displayed the header, we should no longer write session data.
- Zend_Session::writeClose();
-
// We've displayed the header - display the footer automatically
$this->page_header = true;
diff --git a/app/Controller/IndividualController.php b/app/Controller/IndividualController.php
index 80623ee95d..9d21a714f3 100644
--- a/app/Controller/IndividualController.php
+++ b/app/Controller/IndividualController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class IndividualController - Controller for the individual page
*/
@@ -106,8 +104,6 @@ class IndividualController extends GedcomRecordController {
header("Content-Type: text/html; charset=UTF-8"); // AJAX calls do not have the meta tag headers and need this set
header("X-Robots-Tag: noindex,follow"); // AJAX pages should not show up in search results, any links can be followed though
- Zend_Session::writeClose();
-
echo $mod->getTabContent();
if (WT_DEBUG_SQL) {
diff --git a/app/Controller/LifespanController.php b/app/Controller/LifespanController.php
index a140491573..628ad738cf 100644
--- a/app/Controller/LifespanController.php
+++ b/app/Controller/LifespanController.php
@@ -64,7 +64,7 @@ class LifespanController extends PageController {
* Startup activity
*/
public function __construct() {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
parent::__construct();
$this->setPageTitle(I18N::translate('Lifespans'));
@@ -105,8 +105,8 @@ class LifespanController extends PageController {
$this->place = $place;
} else {
// Modify an existing list of records
- if (is_array($WT_SESSION->timeline_pids)) {
- $this->pids = $WT_SESSION->timeline_pids;
+ if (is_array(Session::get('timeline_pids'))) {
+ $this->pids = Session::get('timeline_pids');
} else {
$this->pids = array();
}
@@ -122,7 +122,7 @@ class LifespanController extends PageController {
$this->addFamily($this->getSignificantIndividual(), false);
}
}
- $WT_SESSION->timeline_pids = $this->pids;
+ Session::put('timeline_pids', $this->pids);
$this->beginYear = $beginYear;
$this->endYear = $endYear;
@@ -162,7 +162,7 @@ class LifespanController extends PageController {
}
}
}
- $WT_SESSION->timeline_pids = null;
+ Session::forget('timeline_pids');
}
// Sort the array in order of birth year
diff --git a/app/Controller/PageController.php b/app/Controller/PageController.php
index 1832fa9084..560c4b5873 100644
--- a/app/Controller/PageController.php
+++ b/app/Controller/PageController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class PageController Controller for full-page, themed HTML responses
*/
@@ -199,9 +197,6 @@ class PageController extends BaseController {
}
flush();
- // Once we've displayed the header, we should no longer write session data.
- Zend_Session::writeClose();
-
// We've displayed the header - display the footer automatically
$this->page_header = true;
diff --git a/app/Controller/SearchController.php b/app/Controller/SearchController.php
index 324d83c7a8..2113fa9081 100644
--- a/app/Controller/SearchController.php
+++ b/app/Controller/SearchController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class SearchController - Controller for the search page
*/
@@ -236,7 +234,6 @@ class SearchController extends PageController {
if (count($this->myindilist) == 1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
$indi = $this->myindilist[0];
if ($indi->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $indi->getRawUrl());
exit;
}
@@ -244,7 +241,6 @@ class SearchController extends PageController {
if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
$fam = $this->myfamlist[0];
if ($fam->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $fam->getRawUrl());
exit;
}
@@ -252,7 +248,6 @@ class SearchController extends PageController {
if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
$sour = $this->mysourcelist[0];
if ($sour->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $sour->getRawUrl());
exit;
}
@@ -260,7 +255,6 @@ class SearchController extends PageController {
if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
$note = $this->mynotelist[0];
if ($note->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $note->getRawUrl());
exit;
}
diff --git a/app/Filter.php b/app/Filter.php
index 2a5fc13cfb..cbd4ce50e2 100644
--- a/app/Filter.php
+++ b/app/Filter.php
@@ -445,16 +445,16 @@ $_SERVER[$variable]))) {
* @return string
*/
public static function getCsrfToken() {
- global $WT_SESSION;
-
- if ($WT_SESSION->CSRF_TOKEN === null) {
+ if (!Session::has('CSRF_TOKEN')) {
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789';
+ $csrf_token = '';
for ($n = 0; $n < 32; ++$n) {
- $WT_SESSION->CSRF_TOKEN .= substr($charset, mt_rand(0, 61), 1);
+ $csrf_token .= substr($charset, mt_rand(0, 61), 1);
}
+ Session::put('CSRF_TOKEN', $csrf_token);
}
- return $WT_SESSION->CSRF_TOKEN;
+ return Session::get('CSRF_TOKEN');
}
/**
diff --git a/app/FlashMessages.php b/app/FlashMessages.php
index 6456c9a88a..6c804d4b5a 100644
--- a/app/FlashMessages.php
+++ b/app/FlashMessages.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Controller_Action_HelperBroker;
-
/**
* Class FlashMessages - Flash messages allow us to generate messages
* in one context, and display them in another.
@@ -33,9 +31,10 @@ class FlashMessages {
$message = new \stdClass;
$message->text = $text;
$message->status = $status;
- $flash_messenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
- $flash_messenger->addMessage($message);
+ $messages = Session::get('flash_messages', array());
+ $messages[] = $message;
+ Session::put('flash_messages', $messages);
}
/**
@@ -44,20 +43,8 @@ class FlashMessages {
* @return string[]
*/
public static function getMessages() {
- $flash_messenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
-
- $messages = array();
-
- // Get messages from previous requests
- foreach ($flash_messenger->getMessages() as $message) {
- $messages[] = $message;
- }
-
- // Get messages from the current request
- foreach ($flash_messenger->getCurrentMessages() as $message) {
- $messages[] = $message;
- }
- $flash_messenger->clearCurrentMessages();
+ $messages = Session::get('flash_messages', array());
+ Session::forget('flash_messages');
return $messages;
}
diff --git a/app/HitCounter.php b/app/HitCounter.php
index 6e5dff03fa..ffa8f1cf29 100644
--- a/app/HitCounter.php
+++ b/app/HitCounter.php
@@ -30,15 +30,13 @@ class HitCounter {
* @return integer
*/
public static function countHit(Tree $tree, $page, $parameter) {
- global $WT_SESSION;
-
// Don't increment the counter while we stay on the same page.
if (
- $WT_SESSION->last_tree_id === $tree->getTreeId() &&
- $WT_SESSION->last_page === $page &&
- $WT_SESSION->last_parameter === $parameter
+ Session::get('last_tree_id') === $tree->getTreeId() &&
+ Session::get('last_page') === $page &&
+ Session::get('last_parameter') === $parameter
) {
- return $WT_SESSION->last_count;
+ return Session::get('last_count');
}
$page_count = self::getCount($tree, $page, $parameter);
@@ -65,10 +63,10 @@ class HitCounter {
$page_count++;
- $WT_SESSION->last_tree_id = $tree->getTreeId();
- $WT_SESSION->last_page = $page;
- $WT_SESSION->last_parameter = $parameter;
- $WT_SESSION->last_count = $page_count;
+ Session::put('last_tree_id', $tree->getTreeId());
+ Session::put('last_page', $page);
+ Session::put('last_parameter', $parameter);
+ Session::put('last_count', $page_count);
return $page_count;
}
diff --git a/app/I18N.php b/app/I18N.php
index 797aae4dff..a628dd0ea6 100644
--- a/app/I18N.php
+++ b/app/I18N.php
@@ -352,7 +352,7 @@ class I18N {
* @return string $string
*/
public static function init($code = null) {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
if ($code !== null) {
// Create the specified locale
@@ -369,9 +369,9 @@ class I18N {
}
} catch (\Exception $ex) {
}
- } elseif ($WT_SESSION->locale) {
+ } elseif (Session::has('locale')) {
// Previously used
- self::$locale = Locale::create($WT_SESSION->locale);
+ self::$locale = Locale::create(Session::get('locale'));
} else {
// Browser negotiation
$default_locale = new LocaleEnUs;
diff --git a/app/Module/ClippingsCart/ClippingsCart.php b/app/Module/ClippingsCart/ClippingsCart.php
index 1f4923a23d..559514b846 100644
--- a/app/Module/ClippingsCart/ClippingsCart.php
+++ b/app/Module/ClippingsCart/ClippingsCart.php
@@ -17,7 +17,6 @@ namespace Fisharebest\Webtrees;
*/
use PclZip;
-use Zend_Session;
/**
* The clippings cart.
@@ -60,14 +59,12 @@ class ClippingsCart {
* Create the clippings controller
*/
public function __construct() {
- global $WT_TREE, $WT_SESSION;
+ global $WT_TREE;
// Our cart is an array of items in the session
- if (!is_array($WT_SESSION->cart)) {
- $WT_SESSION->cart = array();
- }
- if (!array_key_exists($WT_TREE->getTreeId(), $WT_SESSION->cart)) {
- $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
+ $cart = Session::get('cart', array());
+ if (!array_key_exists($WT_TREE->getTreeId(), $cart)) {
+ $cart[$WT_TREE->getTreeId()] = array();
}
$this->action = Filter::get('action');
@@ -149,12 +146,12 @@ class ClippingsCart {
$this->addFamilyDescendancy($family, $this->level3);
}
}
- uksort($WT_SESSION->cart[$WT_TREE->getTreeId()], __NAMESPACE__ . '\ClippingsCart::compareClippings');
+ uksort($cart[$WT_TREE->getTreeId()], __NAMESPACE__ . '\ClippingsCart::compareClippings');
}
} elseif ($this->action === 'remove') {
- unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$this->id]);
+ unset ($cart[$WT_TREE->getTreeId()][$this->id]);
} elseif ($this->action === 'empty') {
- $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
+ $cart[$WT_TREE->getTreeId()] = array();
} elseif ($this->action === 'download') {
$media = array();
$mediacount = 0;
@@ -194,7 +191,7 @@ class ClippingsCart {
break;
}
- foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
$object = GedcomRecord::getInstance($xref, $WT_TREE);
// The object may have been deleted since we added it to the cart....
if ($object) {
@@ -202,19 +199,19 @@ class ClippingsCart {
// Remove links to objects that aren't in the cart
preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
@@ -259,6 +256,7 @@ class ClippingsCart {
}
}
}
+ Session::put('cart', $cart);
if ($this->IncludeMedia === "yes") {
$this->media_list = $media;
@@ -315,8 +313,6 @@ class ClippingsCart {
* based on the options he or she selected.
*/
function downloadClipping() {
- Zend_Session::writeClose();
-
if ($this->IncludeMedia === 'yes' || $this->Zip === 'yes') {
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="clipping.zip"');
@@ -337,15 +333,15 @@ class ClippingsCart {
* @param GedcomRecord $record
*/
function addClipping(GedcomRecord $record) {
- global $WT_SESSION;
-
if ($record->canShowName()) {
- $WT_SESSION->cart[$record->getTree()->getTreeId()][$record->getXref()] = true;
+ $cart = Session::get('cart');
+ $cart[$record->getTree()->getTreeId()][$record->getXref()] = true;
// Add directly linked records
preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches);
foreach ($matches[1] as $match) {
- $WT_SESSION->cart[$record->getTree()->getTreeId()][$match] = true;
+ $cart[$record->getTree()->getTreeId()][$match] = true;
}
+ Session::put('cart', $cart);
}
}
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() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;empty=true&amp;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() . '&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;
diff --git a/app/Module/DescendancyModule.php b/app/Module/DescendancyModule.php
index 27a3ac277e..0c91123e92 100644
--- a/app/Module/DescendancyModule.php
+++ b/app/Module/DescendancyModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class DescendancyModule
*/
@@ -38,7 +36,6 @@ class DescendancyModule extends AbstractModule implements ModuleSidebarInterface
public function modAction($modAction) {
global $WT_TREE;
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
switch ($modAction) {
diff --git a/app/Module/FamiliesSidebarSidebarModule.php b/app/Module/FamiliesSidebarSidebarModule.php
index 3f678b9b93..a3b2ebd209 100644
--- a/app/Module/FamiliesSidebarSidebarModule.php
+++ b/app/Module/FamiliesSidebarSidebarModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class FamiliesSidebarModule
*/
@@ -36,7 +34,6 @@ class FamiliesSidebarModule extends AbstractModule implements ModuleSidebarInter
public function modAction($modAction) {
switch ($modAction) {
case 'ajax':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
echo $this->getSidebarAjaxContent();
break;
diff --git a/app/Module/GoogleMapsModule.php b/app/Module/GoogleMapsModule.php
index f65de7b409..bf06203da9 100644
--- a/app/Module/GoogleMapsModule.php
+++ b/app/Module/GoogleMapsModule.php
@@ -18,7 +18,6 @@ namespace Fisharebest\Webtrees;
use PDO;
use PDOException;
-use Zend_Session;
/**
* Class GoogleMapsModule
@@ -4110,7 +4109,6 @@ class GoogleMapsModule extends AbstractModule implements ModuleConfigInterface,
$controller->restrictAccess(Auth::isAdmin());
if ($action == 'ExportFile' && Auth::isAdmin()) {
- Zend_Session::writeClose();
$tmp = $this->placeIdToHierarchy($parent);
$maxLevel = $this->getHighestLevel();
if ($maxLevel > 8) $maxLevel = 8;
diff --git a/app/Module/IndividualSidebarModule.php b/app/Module/IndividualSidebarModule.php
index 55a16a5823..e9f4f2ff1e 100644
--- a/app/Module/IndividualSidebarModule.php
+++ b/app/Module/IndividualSidebarModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class IndividualSidebarModule
*/
@@ -36,7 +34,6 @@ class IndividualSidebarModule extends AbstractModule implements ModuleSidebarInt
public function modAction($modAction) {
switch ($modAction) {
case 'ajax':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
echo $this->getSidebarAjaxContent();
break;
diff --git a/app/Module/InteractiveTreeModule.php b/app/Module/InteractiveTreeModule.php
index ea7134cb25..012038c9f0 100644
--- a/app/Module/InteractiveTreeModule.php
+++ b/app/Module/InteractiveTreeModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class InteractiveTreeModule
* Tip : you could change the number of generations loaded before ajax calls both in individual page and in treeview page to optimize speed and server load
@@ -117,7 +115,6 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
break;
case 'getDetails':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$pid = Filter::get('pid', WT_REGEX_XREF);
$i = Filter::get('instance');
@@ -129,7 +126,6 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
break;
case 'getPersons':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$q = Filter::get('q');
$i = Filter::get('instance');
diff --git a/app/Module/SiteMapModule.php b/app/Module/SiteMapModule.php
index 6cba05c33a..3a0dcdee83 100644
--- a/app/Module/SiteMapModule.php
+++ b/app/Module/SiteMapModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class SiteMapModule
*/
@@ -42,7 +40,6 @@ class SiteMapModule extends AbstractModule implements ModuleConfigInterface {
$this->admin();
break;
case 'generate':
- Zend_Session::writeClose();
$this->generate(Filter::get('file'));
break;
default:
diff --git a/app/Session.php b/app/Session.php
new file mode 100644
index 0000000000..499a7ac02e
--- /dev/null
+++ b/app/Session.php
@@ -0,0 +1,110 @@
+<?php
+namespace Fisharebest\Webtrees;
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2015 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Class Session - temporary class to migrate away from Zend_Session
+ * to Symfony-based sessions, which need PHP 5.4
+ */
+class Session {
+ /**
+ * Start a session
+ *
+ * @param array $config
+ */
+ public static function start(array $config = array()) {
+ $default_config = array(
+ 'session.use_cookies' => 1,
+ 'name' => 'WT_SESSION',
+ 'cookie_lifetime' => 0,
+ 'gc_maxlifetime' => 7200,
+ 'gc_probability' => 1,
+ 'gc_divisor' => 100,
+ 'cookie_path' => '',
+ 'cookie_httponly' => true,
+ );
+ session_register_shutdown();
+ foreach ($config + $default_config as $key => $value) {
+ ini_set($key, $value);
+ }
+ session_start();
+ }
+
+ /**
+ * Read a value from the session
+ *
+ * @param string $name
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public static function get($name, $default = null) {
+ if (isset($_SESSION[$name])) {
+ return $_SESSION[$name];
+ } else {
+ return $default;
+ }
+ }
+
+ /**
+ * Write a value to the session
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ public static function put($name, $value) {
+ $_SESSION[$name] = $value;
+ }
+
+ /**
+ * Remove a value from the session
+ *
+ * @param string $name
+ */
+ public static function forget($name) {
+ unset($_SESSION[$name]);
+ }
+
+ /**
+ * Does a session variable exist?
+ *
+ * @param string $name
+ *
+ * @return boolean
+ */
+ public static function has($name) {
+ return array_key_exists($name, $_SESSION);
+ }
+
+ /**
+ * After any change in authentication level, we should use a new session ID.
+ *
+ * @param bool $destroy
+ */
+ public static function regenerate($destroy = false) {
+ session_regenerate_id($destroy);
+ }
+
+ /**
+ * Set an explicit session ID. Typically used for search robots.
+ *
+ * @param string $id
+ */
+ public static function setId($id) {
+ session_id($id);
+ }
+}
diff --git a/app/Theme/BaseTheme.php b/app/Theme/BaseTheme.php
index 3c6b0cc0b0..c7325b45fe 100644
--- a/app/Theme/BaseTheme.php
+++ b/app/Theme/BaseTheme.php
@@ -16,15 +16,10 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session_Namespace;
-
/**
* Class Base - Common functions and interfaces for all themes.
*/
abstract class BaseTheme {
- /** @var Zend_Session_Namespace */
- protected $session;
-
/** @var Tree The current tree */
protected $tree;
@@ -956,21 +951,19 @@ abstract class BaseTheme {
* Initialise the theme. We cannot pass these in a constructor, as the construction
* happens in a theme file, and we need to be able to change it.
*
- * @param Zend_Session_Namespace $session
- * @param Tree|null $tree The current tree (if there is one).
+ * @param Tree|null $tree The current tree (if there is one).
*
* @return void
*/
- final public function init(Zend_Session_Namespace $session, Tree $tree = null) {
- $this->tree = $tree;
- $this->tree_url = $tree ? 'ged=' . $tree->getNameUrl() : '';
- $this->session = $session;
+ final public function init(Tree $tree = null) {
+ $this->tree = $tree;
+ $this->tree_url = $tree ? 'ged=' . $tree->getNameUrl() : '';
$this->hookAfterInit();
}
/**
- * A large webtrees logo, for the footer.
+ * A large webtrees logo, for the header.
*
* @return string
*/
diff --git a/app/Theme/ColorsTheme.php b/app/Theme/ColorsTheme.php
index ba6a054b29..e029ca45b7 100644
--- a/app/Theme/ColorsTheme.php
+++ b/app/Theme/ColorsTheme.php
@@ -86,13 +86,13 @@ class ColorsTheme extends CloudsTheme {
}
unset($_GET['themecolor']);
// Rember that we have selected a value
- $this->session->subColor = $this->palette;
+ Session::set('subColor', $this->palette);
}
// If we are logged in, use our preference
$this->palette = Auth::user()->getPreference('themecolor');
// If not logged in or no preference, use one we selected earlier in the session?
if (!$this->palette) {
- $this->palette = $this->session->subColor;
+ $this->palette = Session::get('subColor');
}
// We haven't selected one this session? Use the site default
if (!$this->palette) {