Advertisement
Guest User

Untitled

a guest
Feb 28th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. class Tx_xxx_Controller_AbstractController extends Tx_Extbase_MVC_Controller_ActionController {
  3.  
  4. /**
  5. * Session storage key used
  6. * @var string
  7. */
  8. protected $sessionDataStorageKey = 'tx_xxx';
  9.  
  10. /**
  11. * The session data container
  12. * @var array
  13. */
  14. protected $sessionData = array();
  15.  
  16. protected function getExtConf() {
  17. return unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['xxx']);
  18. }
  19.  
  20. public function initializeAction() {
  21. $this->loadSessionData();
  22. if(!$this->sessionData['productcategory']){
  23. $this->sessionData['productcategory'] = 1;
  24. $this->storeSessionData();
  25. }
  26. }
  27.  
  28. /**
  29. * Loads data from session
  30. * @return void
  31. */
  32. protected function loadSessionData() {
  33. $GLOBALS['TSFE']->fe_user->fetchSessionData();
  34. $this->sessionData = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->sessionDataStorageKey);
  35. }
  36.  
  37. /**
  38. * Stores data to session
  39. * @return void
  40. */
  41. protected function storeSessionData() {
  42. $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sessionDataStorageKey, $this->sessionData);
  43. $GLOBALS['TSFE']->fe_user->storeSessionData();
  44. }
  45.  
  46. /**
  47. * removes all date from session
  48. * @return void
  49. */
  50. protected function clearSessionData() {
  51. $this->sessionData = array();
  52. $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sessionDataStorageKey, $this->sessionData);
  53. $GLOBALS['TSFE']->fe_user->storeSessionData();
  54. }
  55.  
  56. /**
  57. * fetches the cookie of a given name and handles magic quotes
  58. *
  59. * @param string $cookieName
  60. */
  61. protected static function getCookie($cookieName) {
  62. $cookie = $_COOKIE[$cookieName];
  63. if ($cookie && get_magic_quotes_gpc()) {
  64. $cookie = stripslashes($cookie);
  65. }
  66. return $cookie;
  67. }
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement