/** * Get the currently active Isotope configuration * * @return Config */ public static function getConfig() { if (null === static::$objConfig) { static::initialize(); if (($objCart = static::getCart()) !== null) { static::$objConfig = Config::findByPk($objCart->config_id); } // If cart was null or still did not find a config if (null === static::$objConfig) { global $objPage; static::$objConfig = TL_MODE == 'FE' ? Config::findByRootPageOrFallback($objPage->rootId) : Config::findByFallback(); } // No config at all, create empty model as fallback if (null === static::$objConfig) { static::$objConfig = new Config(); trigger_error($GLOBALS['TL_LANG']['ERR']['noDefaultStoreConfiguration']); } } return static::$objConfig; }
/** * Load the current cart * @param Config * @return Cart */ public static function findForCurrentStore() { global $objPage; if (TL_MODE != 'FE' || null === $objPage || $objPage->rootId == 0) { return null; } $time = time(); $strHash = \Input::cookie(static::$strCookie); $intStore = (int) \PageModel::findByPk($objPage->rootId)->iso_store_id; // Check to see if the user is logged in. if (FE_USER_LOGGED_IN !== true) { if ($strHash == '') { $strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . $intStore . static::$strCookie); \System::setCookie(static::$strCookie, $strHash, $time + $GLOBALS['TL_CONFIG']['iso_cartTimeout'], $GLOBALS['TL_CONFIG']['websitePath']); } $objCart = static::findOneBy(array('uniqid=?', 'store_id=?'), array($strHash, $intStore)); } else { $objCart = static::findOneBy(array('member=?', 'store_id=?'), array(\FrontendUser::getInstance()->id, $intStore)); } // Create new cart if ($objCart === null) { $objConfig = Config::findByRootPageOrFallback($objPage->rootId); $objCart = new static(); // Can't call the individual rows here, it would trigger markModified and a save() $objCart->setRow(array_merge($objCart->row(), array('tstamp' => $time, 'member' => FE_USER_LOGGED_IN === true ? \FrontendUser::getInstance()->id : 0, 'uniqid' => FE_USER_LOGGED_IN === true ? '' : $strHash, 'config_id' => $objConfig->id, 'store_id' => $intStore))); } else { $objCart->tstamp = $time; } return $objCart; }