1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Persistent_Helper_Data extends Mage_Core_Helper_Data
36: {
37: const XML_PATH_ENABLED = 'persistent/options/enabled';
38: const XML_PATH_LIFE_TIME = 'persistent/options/lifetime';
39: const XML_PATH_LOGOUT_CLEAR = 'persistent/options/logout_clear';
40: const XML_PATH_REMEMBER_ME_ENABLED = 'persistent/options/remember_enabled';
41: const XML_PATH_REMEMBER_ME_DEFAULT = 'persistent/options/remember_default';
42: const XML_PATH_PERSIST_SHOPPING_CART = 'persistent/options/shopping_cart';
43:
44: const LOGGED_IN_LAYOUT_HANDLE = 'customer_logged_in_psc_handle';
45: const LOGGED_OUT_LAYOUT_HANDLE = 'customer_logged_out_psc_handle';
46:
47: 48: 49: 50: 51:
52: protected $_configFileName = 'persistent.xml';
53:
54: 55: 56: 57: 58: 59:
60: public function isEnabled($store = null)
61: {
62: return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
63: }
64:
65: 66: 67: 68: 69: 70:
71: public function isRememberMeEnabled($store = null)
72: {
73: return Mage::getStoreConfigFlag(self::XML_PATH_REMEMBER_ME_ENABLED, $store);
74: }
75:
76: 77: 78: 79: 80: 81:
82: public function isRememberMeCheckedDefault($store = null)
83: {
84: return Mage::getStoreConfigFlag(self::XML_PATH_REMEMBER_ME_DEFAULT, $store);
85: }
86:
87: 88: 89: 90: 91: 92:
93: public function isShoppingCartPersist($store = null)
94: {
95: return Mage::getStoreConfigFlag(self::XML_PATH_PERSIST_SHOPPING_CART, $store);
96: }
97:
98: 99: 100: 101: 102: 103:
104: public function getLifeTime($store = null)
105: {
106: $lifeTime = intval(Mage::getStoreConfig(self::XML_PATH_LIFE_TIME, $store));
107: return ($lifeTime < 0) ? 0 : $lifeTime;
108: }
109:
110: 111: 112: 113: 114:
115: public function getClearOnLogout()
116: {
117: return Mage::getStoreConfigFlag(self::XML_PATH_LOGOUT_CLEAR);
118: }
119:
120: 121: 122: 123: 124:
125: public function getUnsetCookieUrl()
126: {
127: return $this->_getUrl('persistent/index/unsetCookie');
128: }
129:
130: 131: 132: 133: 134:
135: public function getPersistentName()
136: {
137: return $this->__('(Not %s?)', $this->escapeHtml(Mage::helper('persistent/session')->getCustomer()->getName()));
138: }
139:
140: 141: 142: 143: 144:
145: public function getPersistentConfigFilePath()
146: {
147: return Mage::getConfig()->getModuleDir('etc', $this->_getModuleName()) . DS . $this->_configFileName;
148: }
149:
150: 151: 152: 153: 154: 155:
156: public function canProcess($observer)
157: {
158: $action = $observer->getEvent()->getAction();
159: $controllerAction = $observer->getEvent()->getControllerAction();
160:
161: if ($action instanceof Mage_Core_Controller_Varien_Action) {
162: return !$action->getFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION);
163: }
164: if ($controllerAction instanceof Mage_Core_Controller_Varien_Action) {
165: return !$controllerAction->getFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION);
166: }
167: return true;
168: }
169:
170: 171: 172: 173: 174: 175:
176: public function getCreateAccountUrl($url)
177: {
178: if (Mage::helper('checkout')->isContextCheckout()) {
179: $url = Mage::helper('core/url')->addRequestParam($url, array('context' => 'checkout'));
180: }
181: return $url;
182: }
183:
184: }
185: