/** * Smarty function * ------------------------------------------------------------- * Purpose: Output price string * add [{oxprice price="..." currency="..."}] where you want to display content * price - decimal number: 13; 12.45; 13.01; * currency - currency abbreviation: EUR, USD, LTL etc. * ------------------------------------------------------------- * * @param array $params params * @param Smarty &$smarty clever simulation of a method * * @return string */ function smarty_function_oxprice($params, &$smarty) { $sOutput = ''; $iDecimals = 2; $sDecimalsSeparator = ','; $sThousandSeparator = '.'; $sCurrencySign = ''; $sSide = ''; $mPrice = $params['price']; if (!is_null($mPrice)) { $oConfig = Registry::getConfig(); $sPrice = $mPrice instanceof \OxidEsales\EshopCommunity\Core\Price ? $mPrice->getPrice() : $mPrice; $oCurrency = isset($params['currency']) ? $params['currency'] : $oConfig->getActShopCurrencyObject(); if (!is_null($oCurrency)) { $sDecimalsSeparator = isset($oCurrency->dec) ? $oCurrency->dec : $sDecimalsSeparator; $sThousandSeparator = isset($oCurrency->thousand) ? $oCurrency->thousand : $sThousandSeparator; $sCurrencySign = isset($oCurrency->sign) ? $oCurrency->sign : $sCurrencySign; $sSide = isset($oCurrency->side) ? $oCurrency->side : $sSide; $iDecimals = isset($oCurrency->decimal) ? (int) $oCurrency->decimal : $iDecimals; } if (is_numeric($sPrice)) { if ((double) $sPrice > 0 || $sCurrencySign) { $sPrice = number_format($sPrice, $iDecimals, $sDecimalsSeparator, $sThousandSeparator); $sOutput = isset($sSide) && $sSide == 'Front' ? $sCurrencySign . $sPrice : $sPrice . ' ' . $sCurrencySign; } $sOutput = trim($sOutput); } } return $sOutput; }
/** * Returns path to edition directory. If no additional editions are found, returns base path. * * @return string */ public function getDirectoryPath() { if (Registry::instanceExists('oxConfigFile')) { $configFile = Registry::get('oxConfigFile'); } else { $configFile = new ConfigFile(getShopBasePath() . '/config.inc.php'); Registry::set('oxConfigFile', $configFile); } $editionsPath = $configFile->getVar('vendorDirectory') . '/' . static::EDITIONS_DIRECTORY; $path = getShopBasePath(); if ($this->getEditionSelector()->isEnterprise()) { $path = $editionsPath . '/' . static::ENTERPRISE_DIRECTORY; } elseif ($this->getEditionSelector()->isProfessional()) { $path = $editionsPath . '/' . static::PROFESSIONAL_DIRECTORY; } return realpath($path) . DIRECTORY_SEPARATOR; }
/** * loadBargain loads 'Bargain' rss data * * @access public * * @return void */ public function loadBargain() { if ($this->_aChannel = $this->_loadFromCache(self::RSS_BARGAIN)) { return; } $oArtList = oxNew('oxArticleList'); $oArtList->loadActionArticles('OXBARGAIN', $this->getConfig()->getConfigParam('iRssItemsCount')); $oLang = Registry::getLang(); $this->_loadData(self::RSS_BARGAIN, $this->getBargainTitle(), $oLang->translateString('BARGAIN_PRODUCTS', $oLang->getBaseLanguage()), $this->_getArticleItems($oArtList), $this->getBargainUrl()); }
public function testInstanceExists() { oxRegistry::set("testKey", "testVal"); $this->assertTrue(Registry::instanceExists('testKey')); oxRegistry::set("testKey", null); $this->assertFalse(Registry::instanceExists('testKey')); }
/** * Expire/remove the cache file for the given action rss feed. * * @param string $sName The name of the stream we want to remove from the file cache. */ public function removeCacheFile($sName) { $sFileKey = $this->mapOxActionToFileCache($sName); $sFilePath = Registry::getUtils()->getCacheFilePath($this->_getCacheId($sFileKey)); $this->_deleteFile($sFilePath); }
/** * Deletes record and other information related to this article such as images from DB, * also removes variants. Returns true if entry was deleted. * * @param string $sOXID Article id * * @throws \Exception * * @return bool */ public function delete($sOXID = null) { if (!$sOXID) { $sOXID = $this->getId(); } if (!$sOXID) { return false; } $database = oxDb::getDb(); $database->startTransaction(); try { // #2339 delete first variants before deleting parent product $this->_deleteVariantRecords($sOXID); $this->load($sOXID); $this->_deletePics(); $this->_onChangeResetCounts($sOXID, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value); // delete self $deleted = parent::delete($sOXID); $this->_deleteRecords($sOXID); Registry::get("oxSeoEncoderArticle")->onDeleteArticle($this); $this->onChange(ACTION_DELETE, $sOXID, $this->oxarticles__oxparentid->value); $database->commitTransaction(); } catch (Exception $exception) { $database->rollbackTransaction(); throw $exception; } return $deleted; }
/** * @return string */ private function getVendorDir() { /** @var ConfigFile $shopConfig */ $shopConfig = Registry::get("oxConfigFile"); $vendorDir = $shopConfig->getVar('vendorDirectory'); return $vendorDir; }
/** * Returns default category sorting for selected category * * @return array */ public function getUserSelectedSorting() { $sortDirections = array('desc', 'asc'); $request = Registry::get(Request::class); $sortBy = $request->getRequestParameter($this->getSortOrderByParameterName()); $sortOrder = $request->getRequestParameter($this->getSortOrderParameterName()); if ($sortBy && $sortOrder && Registry::getUtils()->isValidAlpha($sortOrder) && in_array(Str::getStr()->strtolower($sortOrder), $sortDirections) && in_array($sortBy, oxNew('oxArticle')->getFieldNames())) { return array('sortby' => $sortBy, 'sortdir' => $sortOrder); } }
/** * Check for forced edition in config file. If edition is not specified, * determine it by ClassMap existence. * * @return string */ protected function findEdition() { if (!class_exists('OxidEsales\\Eshop\\Core\\Registry') || !Registry::instanceExists('oxConfigFile')) { $configFile = new ConfigFile(getShopBasePath() . "config.inc.php"); } $configFile = isset($configFile) ? $configFile : Registry::get('oxConfigFile'); $edition = $configFile->getVar('edition') ?: $this->findEditionByClassMap(); $configFile->setVar('edition', $edition); return strtoupper($edition); }
* along with OXID eShop Community Edition. If not, see <http://www.gnu.org/licenses/>. * * @link http://www.oxid-esales.com * @copyright (C) OXID eSales AG 2003-2016 * @version OXID eShop CE */ use OxidEsales\Eshop\Core\ConfigFile; use OxidEsales\Eshop\Core\Registry; if (defined('E_DEPRECATED')) { //E_DEPRECATED is disabled particularly for PHP 5.3 as some 3rd party modules still uses deprecated functionality error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); } else { error_reporting(E_ALL ^ E_NOTICE); } if (!defined('OX_BASE_PATH')) { define('OX_BASE_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR); } // custom functions file require_once OX_BASE_PATH . 'modules/functions.php'; // Generic utility method file including autoloading definition require_once OX_BASE_PATH . 'Core/oxfunctions.php'; // Composer autoloader. registerComposerAutoload(); //init config.inc.php file reader $oConfigFile = new ConfigFile(OX_BASE_PATH . "config.inc.php"); Registry::set("oxConfigFile", $oConfigFile); registerModuleDependenciesAutoload(); registerShopAutoLoad(); registerModuleAutoload(); //sets default PHP ini params setPhpIniParams();
/** * First test if all required fields were filled, then performed * additional checking oxcmp_user::CheckValues(). If no errors * occured - trying to create new user (oxuser::CreateUser()), * logging him to shop (oxuser::Login() if user has entered password). * If oxuser::CreateUser() returns false - this means user is * already created - we only logging him to shop (oxcmp_user::Login()). * If there is any error with missing data - function will return * false and set error code (oxcmp_user::iError). If user was * created successfully - will return "payment" to redirect to * payment interface. * * Template variables: * <b>usr_err</b> * * Session variables: * <b>usr_err</b>, <b>usr</b> * * @return mixed redirection string or true if successful, false otherwise */ public function createUser() { $blActiveLogin = $this->getParent()->isEnabledPrivateSales(); $oConfig = $this->getConfig(); if ($blActiveLogin && !$oConfig->getRequestParameter('ord_agb') && $oConfig->getConfigParam('blConfirmAGB')) { oxRegistry::get("oxUtilsView")->addErrorToDisplay('READ_AND_CONFIRM_TERMS', false, true); return false; } // collecting values to check $sUser = $oConfig->getRequestParameter('lgn_usr'); // first pass $sPassword = $oConfig->getRequestParameter('lgn_pwd', true); // second pass $sPassword2 = $oConfig->getRequestParameter('lgn_pwd2', true); $aInvAdress = $oConfig->getRequestParameter('invadr', true); $aInvAdress = $this->cleanBillingAddress($aInvAdress); $aDelAdress = $this->_getDelAddressData(); $aDelAdress = $this->cleanDeliveryAddress($aDelAdress); $database = oxDb::getDb(); $database->startTransaction(); try { /** @var oxUser $oUser */ $oUser = oxNew('oxuser'); $oUser->checkValues($sUser, $sPassword, $sPassword2, $aInvAdress, $aDelAdress); $iActState = $blActiveLogin ? 0 : 1; // setting values $oUser->oxuser__oxusername = new oxField($sUser, oxField::T_RAW); $oUser->setPassword($sPassword); $oUser->oxuser__oxactive = new oxField($iActState, oxField::T_RAW); // used for checking if user email currently subscribed $iSubscriptionStatus = $oUser->getNewsSubscription()->getOptInStatus(); $oUser->createUser(); $oUser = $this->configureUserBeforeCreation($oUser); $oUser->load($oUser->getId()); $oUser->changeUserData($oUser->oxuser__oxusername->value, $sPassword, $sPassword, $aInvAdress, $aDelAdress); if ($blActiveLogin) { // accepting terms.. $oUser->acceptTerms(); } $sUserId = oxRegistry::getSession()->getVariable("su"); $sRecEmail = oxRegistry::getSession()->getVariable("re"); if ($this->getConfig()->getConfigParam('blInvitationsEnabled') && $sUserId && $sRecEmail) { // setting registration credit points.. $oUser->setCreditPointsForRegistrant($sUserId, $sRecEmail); } // assigning to newsletter $blOptin = oxRegistry::getConfig()->getRequestParameter('blnewssubscribed'); if ($blOptin && $iSubscriptionStatus == 1) { // if user was assigned to newsletter // and is creating account with newsletter checked, // don't require confirm $oUser->getNewsSubscription()->setOptInStatus(1); $oUser->addToGroup('oxidnewsletter'); $this->_blNewsSubscriptionStatus = 1; } else { $blOrderOptInEmailParam = $this->getConfig()->getConfigParam('blOrderOptInEmail'); $this->_blNewsSubscriptionStatus = $oUser->setNewsSubscription($blOptin, $blOrderOptInEmailParam); } $oUser->addToGroup('oxidnotyetordered'); $oUser->logout(); $database->commitTransaction(); } catch (\OxidEsales\EshopCommunity\Core\Exception\UserException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\InputException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\DatabaseConnectionException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\ConnectionException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (Exception $exception) { $database->rollbackTransaction(); throw $exception; } if (!$blActiveLogin) { oxRegistry::getSession()->setVariable('usr', $oUser->getId()); $this->_afterLogin($oUser); // order remark //V #427: order remark for new users $sOrderRemark = oxRegistry::getConfig()->getRequestParameter('order_remark', true); if ($sOrderRemark) { oxRegistry::getSession()->setVariable('ordrem', $sOrderRemark); } } // send register eMail //TODO: move into user if ((int) oxRegistry::getConfig()->getRequestParameter('option') == 3) { $oxEMail = oxNew('oxemail'); if ($blActiveLogin) { $oxEMail->sendRegisterConfirmEmail($oUser); } else { $oxEMail->sendRegisterEmail($oUser); } } // new registered $this->_blIsNewUser = true; $sAction = 'payment?new_user=1&success=1'; if ($this->_blNewsSubscriptionStatus !== null && !$this->_blNewsSubscriptionStatus) { $sAction = 'payment?new_user=1&success=1&newslettererror=4'; } return $sAction; }
/** * Get search table name. * Needed in case of searching for data in table oxartextends or its views. * * @param string $table * @param string $field Chose table depending on field. * * @return string */ protected function getSearchTableName($table, $field) { $searchTable = $table; if ($field == 'oxlongdesc') { $searchTable = Registry::get('oxTableViewNameGenerator')->getViewName('oxartextends'); } return $searchTable; }