/** * Composes and sends user written message, returns false if some parameters * are missing. * * @return bool */ public function send() { $aParams = oxConfig::getParameter('editval'); // checking email address if (!oxUtils::getInstance()->isValidEmail($aParams['oxuser__oxusername'])) { oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_INPUT_NOVALIDEMAIL'); return false; } // spam spider prevension $sMac = oxConfig::getParameter('c_mac'); $sMacHash = oxConfig::getParameter('c_mach'); $oCaptcha = $this->getCaptcha(); if (!$oCaptcha->pass($sMac, $sMacHash)) { // even if there is no exception, use this as a default display method oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_INPUT_WRONGCAPTCHA'); return false; } $sSubject = oxConfig::getParameter('c_subject'); if (!$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject) { // even if there is no exception, use this as a default display method oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_INPUT_NOTALLFIELDS'); return false; } $oLang = oxLang::getInstance(); $sMessage = $oLang->translateString('CONTACT_FROM') . " " . $oLang->translateString($aParams['oxuser__oxsal']) . " " . $aParams['oxuser__oxfname'] . " " . $aParams['oxuser__oxlname'] . "(" . $aParams['oxuser__oxusername'] . ")<br /><br />" . nl2br(oxConfig::getParameter('c_message')); $oEmail = oxNew('oxemail'); if ($oEmail->sendContactMail($aParams['oxuser__oxusername'], $sSubject, $sMessage)) { $this->_blContactSendStatus = 1; } }
/** * Executes parent method parent::render(), prints shop and * PHP configuration information. * * @return string */ public function render() { if ($this->getConfig()->isDemoShop()) { return oxUtils::getInstance()->showMessageAndExit("Access denied !"); } parent::render(); return "tools.tpl"; }
/** * Executes parent method parent::render(), passes data to Smarty engine * and returns name of template file "imex_export.tpl". * * @return string */ public function render() { if ($this->getConfig()->isDemoShop()) { oxUtils::getInstance()->showMessageAndExit("Access denied !"); } parent::render(); $oAuthUser = oxNew('oxuser'); $oAuthUser->loadAdminUser(); $this->_aViewData["blIsMallAdmin"] = $oAuthUser->oxuser__oxrights->value == "malladmin"; $blShowUpdateViews = $this->getConfig()->getConfigParam('blShowUpdateViews'); $this->_aViewData['showViewUpdate'] = isset($blShowUpdateViews) && !$blShowUpdateViews ? false : true; return "tools_main.tpl"; }
/** * resturns a single instance of this class * * @return oxUtils */ public static function getInstance() { // disable caching for test modules if (defined('OXID_PHP_UNIT')) { self::$_instance = modInstances::getMod(__CLASS__); } if (!self::$_instance instanceof oxUtils) { self::$_instance = oxNew('oxUtils'); if (defined('OXID_PHP_UNIT')) { modInstances::addMod(__CLASS__, self::$_instance); } } return self::$_instance; }
/** * Returns shopping cart URL * * @return string */ protected function _getBasketUrl() { if (is_null($this->_sBasketUrl)) { $homeUrl = $this->getConfig()->getShopHomeURL(); $basketUrl = oxUtilsUrl::getInstance()->processUrl($homeUrl, true, array('cl' => 'basket')); if (oxUtils::getInstance()->seoIsActive()) { if ($sStaticUrl = oxSeoEncoder::getInstance()->getStaticUrl($basketUrl)) { $basketUrl = $sStaticUrl; } else { $basketUrl = oxUtilsUrl::getInstance()->processUrl($basketUrl); } } $this->_sBasketUrl = $basketUrl; } return $this->_sBasketUrl; }
/** * Initializes all required components. * * @return null|void */ public function init() { parent::init(); set_exception_handler(array($this, 'exceptionHandler')); try { $this->_initVersionLayer(); } catch (Exception $e) { $sMessage = json_encode($this->_errorMessage($e->getMessage()), JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); if ($this->_hasRegistry('getUtils')) { $oUtils = oxRegistry::getUtils(); } else { $oUtils = oxUtils::getInstance(); } $oUtils->showMessageAndExit($sMessage); } }
/** * Initialize the fixture. * * @return null */ protected function setUp() { $this->_aBackup['_SERVER'] = $_SERVER; $this->_aBackup['_POST'] = $_POST; $this->_aBackup['_GET'] = $_GET; $this->_aBackup['_SESSION'] = $_SESSION; $this->_aBackup['_COOKIE'] = $_COOKIE; parent::setUp(); error_reporting(E_ALL ^ E_NOTICE | E_STRICT); ini_set('display_errors', true); modConfig::getInstance(); modSession::getInstance(); oxUtils::getInstance()->cleanStaticCache(); error_reporting(E_ALL ^ E_NOTICE | E_STRICT); ini_set('display_errors', true); }
/** * Saves main orders configuration parameters. * * @return string */ public function save() { $soxId = $this->getEditObjectId(); $aParams = oxConfig::getParameter("editval"); // shopid $sShopID = oxSession::getVar("actshop"); $aParams['oxorder__oxshopid'] = $sShopID; $oOrder = oxNew("oxorder"); if ($soxId != "-1") { $oOrder->load($soxId); } else { $aParams['oxorder__oxid'] = null; } if ($oOrder->oxorder__oxpaymenttype->value != 'rakuten') { //change payment $sPayId = oxConfig::getParameter("setPayment"); if ($sPayId != $oOrder->oxorder__oxpaymenttype->value) { $aParams['oxorder__oxpaymenttype'] = $sPayId; } } $oOrder->assign($aParams); $aDynvalues = oxConfig::getParameter("dynvalue"); if (isset($aDynvalues)) { // #411 Dodger $oPayment = oxNew("oxuserpayment"); $oPayment->load($oOrder->oxorder__oxpaymentid->value); $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText($aDynvalues)); $oPayment->save(); } if ($oOrder->oxorder__oxpaymenttype->value != 'rakuten') { //change delivery set $sDelSetId = oxConfig::getParameter("setDelSet"); if ($sDelSetId != $oOrder->oxorder__oxdeltype->value) { $oOrder->oxorder__oxpaymenttype->setValue("oxempty"); $oOrder->setDelivery($sDelSetId); } else { // keeps old delivery cost $oOrder->reloadDelivery(false); } } // keeps old discount $oOrder->reloadDiscount(false); $oOrder->recalculateOrder(); // set oxid if inserted $this->setEditObjectId($oOrder->getId()); }
/** * @overload */ public function executePayment($dAmount, &$oOrder) { if (!in_array($oOrder->oxorder__oxpaymenttype->rawValue, array("paymill_cc", "paymill_elv"))) { return parent::executePayment($dAmount, $oOrder); } if (oxSession::hasVar('paymill_token')) { $this->_token = oxSession::getVar('paymill_token'); } else { oxUtilsView::getInstance()->addErrorToDisplay("No Token was provided"); oxUtils::getInstance()->redirect($this->getConfig()->getSslShopUrl() . 'index.php?cl=payment', false); } $this->getSession()->setVar("paymill_identifier", time()); $this->_apiUrl = paymill_util::API_ENDPOINT; $this->_iLastErrorNo = null; $this->_sLastError = null; $this->_initializePaymentProcessor($dAmount, $oOrder); if ($this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue) === 'cc') { $this->_paymentProcessor->setPreAuthAmount((int) oxSession::getVar('paymill_authorized_amount')); } $this->_loadFastCheckoutData(); $this->_existingClientHandling($oOrder); if ($this->_token === 'dummyToken') { $prop = 'paymill_fastcheckout__paymentid_' . $this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue); $this->_paymentProcessor->setPaymentId($this->_fastCheckoutData->{$prop}->rawValue); } $result = $this->_paymentProcessor->processPayment(); $this->log($result ? 'Payment results in success' : 'Payment results in failure', null); if ($result) { $saveData = array('oxid' => $oOrder->oxorder__oxuserid->rawValue, 'clientid' => $this->_paymentProcessor->getClientId()); if (oxConfig::getInstance()->getShopConfVar('PAYMILL_ACTIVATE_FASTCHECKOUT')) { $paymentColumn = 'paymentID_' . strtoupper($this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue)); $saveData[$paymentColumn] = $this->_paymentProcessor->getPaymentId(); } $this->_fastCheckoutData->assign($saveData); $this->_fastCheckoutData->save(); if (oxConfig::getInstance()->getShopConfVar('PAYMILL_SET_PAYMENTDATE')) { $this->_setPaymentDate($oOrder); } // set transactionId to session for updating the description after order execute $transactionId = $this->_paymentProcessor->getTransactionId(); $this->getSession()->setVar('paymillPgTransId', $transactionId); } else { oxUtilsView::getInstance()->addErrorToDisplay($this->_getErrorMessage($this->_paymentProcessor->getErrorCode())); } return $result; }
/** * Renders requested RSS feed * * Template variables: * <b>rss</b> * * @return string $this->_sThisTemplate current template file name */ public function render() { parent::render(); $oSmarty = oxUtilsView::getInstance()->getSmarty(); // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU // as SMARTY_PHP_REMOVE removes not only php tags, but also xml if ($this->getConfig()->isDemoShop()) { $oSmarty->php_handling = SMARTY_PHP_PASSTHRU; } foreach (array_keys($this->_aViewData) as $sViewName) { $oSmarty->assign_by_ref($sViewName, $this->_aViewData[$sViewName]); } // variables are set as deprecated, use getters // $oSmarty->assign('xmldef', $this->getXmlDef()); // return rss xml, no further processing oxUtils::getInstance()->setHeader("Content-Type: text/xml; charset=" . oxLang::getInstance()->translateString("charset")); oxUtils::getInstance()->showMessageAndExit($this->_processOutput($oSmarty->fetch($this->_sThisTemplate, $this->getViewId()))); }
/** * Executes parent::render() and returns active shop object. * * @return object $this->oActShop active shop object */ public function render() { parent::render(); $myConfig = $this->getConfig(); $sShopLogo = $myConfig->getConfigParam('sShopLogo'); if ($sShopLogo && file_exists($myConfig->getImageDir() . '/' . $sShopLogo)) { $oParentView = $this->getParent(); $oParentView->setShopLogo($sShopLogo); } // is shop active? $oShop = $myConfig->getActiveShop(); if (!$oShop->oxshops__oxactive->value && 'oxstart' != $myConfig->getActiveView()->getClassName() && !$this->isAdmin()) { // redirect to offline if there is no active shop $sShopUrl = oxConfig::getInstance()->getShopMainUrl(); oxUtils::getInstance()->redirect($sShopUrl . 'offline.html', false); } return $oShop; }
/** * Initialize the fixture. * * @return null */ protected function setUp() { $this->_aBackup['_SERVER'] = $_SERVER; $this->_aBackup['_POST'] = $_POST; $this->_aBackup['_GET'] = $_GET; $this->_aBackup['_SESSION'] = $_SESSION; $this->_aBackup['_COOKIE'] = $_COOKIE; parent::setUp(); error_reporting(E_ALL ^ E_NOTICE | E_STRICT); ini_set('display_errors', true); $this->getConfig(); $this->getSession(); $this->setAdminMode(false); $this->setShopId(null); oxAddClassModule('modOxUtilsDate', 'oxUtilsDate'); oxUtils::getInstance()->cleanStaticCache(); error_reporting(E_ALL ^ E_NOTICE | E_STRICT); ini_set('display_errors', true); // initiating the modules oxTestModuleLoader::loadModule(); }
/** * Returns shops home link * * @return string */ public function getHomeLink() { if (($sValue = $this->getViewConfigParam('homeLink')) === null) { $myConfig = $this->getConfig(); $myUtils = oxUtils::getInstance(); $oLang = oxLang::getInstance(); $iLang = $oLang->getBaseLanguage(); $sValue = null; $blAddStartCl = $myUtils->seoIsActive() && $iLang != $myConfig->getConfigParam('sDefaultLang'); if ($blAddStartCl) { $sValue = oxSeoEncoder::getInstance()->getStaticUrl($this->getSelfLink() . 'cl=start', $iLang); $sValue = oxUtilsUrl::getInstance()->appendUrl($sValue, oxUtilsUrl::getInstance()->getBaseAddUrlParams()); $sValue = getStr()->preg_replace('/(\\?|&(amp;)?)$/', '', $sValue); } if (!$sValue) { $sValue = getStr()->preg_replace('#index.php\\??$#', '', $this->getSelfLink()); } $this->setViewConfigParam('homeLink', $sValue); } return $sValue; }
/** * Smarty function * ------------------------------------------------------------- * Purpose: output SEO style url * add [{ oxgetseourl ident="..." }] where you want to display content * ------------------------------------------------------------- * * @param array $params params * @param Smarty &$smarty clever simulation of a method * * @return string */ function smarty_function_oxgetseourl($params, &$smarty) { $sOxid = isset($params['oxid']) ? $params['oxid'] : null; $sType = isset($params['type']) ? $params['type'] : null; $sUrl = $sIdent = isset($params['ident']) ? $params['ident'] : null; // requesting specified object SEO url if ($sType) { $oObject = oxNew($sType); // special case for content type object when ident is provided if ($sType == 'oxcontent' && $sIdent && $oObject->loadByIdent($sIdent)) { $sUrl = $oObject->getLink(); } elseif ($sOxid) { //minimising aricle object loading if (strtolower($sType) == "oxarticle") { $oObject->disablePriceLoad(); $oObject->setNoVariantLoading(true); } if ($oObject->load($sOxid)) { $sUrl = $oObject->getLink(); } } } elseif ($sUrl && oxUtils::getInstance()->seoIsActive()) { // if SEO is on .. $oEncoder = oxSeoEncoder::getInstance(); if ($sStaticUrl = $oEncoder->getStaticUrl($sUrl)) { $sUrl = $sStaticUrl; } else { // in case language parameter is not added to url $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl); } } $sDynParams = isset($params['params']) ? $params['params'] : false; if ($sDynParams) { include_once $smarty->_get_plugin_filepath('modifier', 'oxaddparams'); $sUrl = smarty_modifier_oxaddparams($sUrl, $sDynParams); } return $sUrl; }
/** * Executes parent method parent::render(), prints shop and * PHP configuration information. * * @return null */ public function render() { $myConfig = $this->getConfig(); parent::render(); $oAuthUser = oxNew('oxuser'); $oAuthUser->loadAdminUser(); $blisMallAdmin = $oAuthUser->oxuser__oxrights->value == "malladmin"; if ($blisMallAdmin && !$myConfig->isDemoShop()) { $aClassVars = get_object_vars($myConfig); $aSystemInfo = array(); $oSmarty = oxUtilsView::getInstance()->getSmarty(); while (list($name, $value) = each($aClassVars)) { if (gettype($value) == "object") { continue; } // security fix - we do not output dbname and dbpwd cause of demoshops if ($name == "oDB" || $name == "dbUser" || $name == "dbPwd" || $name == "oSerial" || $name == "aSerials" || $name == "sSerialNr") { continue; } $value = var_export($value, true); $value = str_replace("\n", "<br>", $value); $aSystemInfo[$name] = $value; //echo( "$name = $value <br>"); } $oSmarty->assign("oViewConf", $this->_aViewData["oViewConf"]); $oSmarty->assign("shop", $this->_aViewData["shop"]); $oSmarty->assign("isdemo", $myConfig->isDemoShop()); $oSmarty->assign("aSystemInfo", $aSystemInfo); echo $oSmarty->fetch("systeminfo.tpl"); echo "<br><br>"; phpinfo(); oxUtils::getInstance()->showMessageAndExit(""); } else { return oxUtils::getInstance()->showMessageAndExit("Access denied !"); } }
/** * return url to this recomm list page * * @param int $iLang language id [optional] * * @return string */ public function getLink($iLang = null) { if ($iLang === null) { $iLang = oxLang::getInstance()->getBaseLanguage(); } if (!oxUtils::getInstance()->seoIsActive()) { return $this->getStdLink($iLang); } if (!isset($this->_aSeoUrls[$iLang])) { $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang); } return $this->_aSeoUrls[$iLang]; }
/** * Returns database object * * @param boolean $blAssoc default false * * @throws oxConnectionException error while initiating connection to DB * * @return ADOConnection */ public static function getDb($blAssoc = false) { global $ADODB_FETCH_MODE; if ($blAssoc) { $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; } else { $ADODB_FETCH_MODE = ADODB_FETCH_NUM; } if (defined('OXID_PHP_UNIT')) { if (isset(modDB::$unitMOD) && is_object(modDB::$unitMOD)) { return modDB::$unitMOD; } } if (self::$_oDB !== null) { return self::$_oDB; } global $ADODB_CACHE_DIR; global $ADODB_DRIVER, $ADODB_SESSION_TBL, $ADODB_SESSION_CONNECT, $ADODB_SESSION_DRIVER, $ADODB_SESSION_USER, $ADODB_SESSION_PWD, $ADODB_SESSION_DB, $ADODB_SESS_LIFE, $ADODB_SESS_DEBUG; //adding exception handler for SQL errors $myConfig = self::getInstance()->getConfig(); $iDebug = $myConfig->getConfigParam('iDebug'); if ($iDebug) { include_once getShopBasePath() . 'core/adodblite/adodb-exceptions.inc.php'; } // session related parameters. don't change. //Tomas //the default setting is 3000 * 60, but actually changing this will give no effect as now redefinition of this constant //appears after OXID custom settings are loaded and $ADODB_SESS_LIFE depends on user settings. //You can find the redefinition of ADODB_SESS_LIFE @ oxconfig.php:: line ~ 390. $ADODB_SESS_LIFE = 3000 * 60; $ADODB_SESSION_TBL = "oxsessions"; $ADODB_SESSION_DRIVER = $myConfig->getConfigParam('dbType'); $ADODB_SESSION_USER = $myConfig->getConfigParam('dbUser'); $ADODB_SESSION_PWD = $myConfig->getConfigParam('dbPwd'); $ADODB_SESSION_DB = $myConfig->getConfigParam('dbName'); $ADODB_SESSION_CONNECT = $myConfig->getConfigParam('dbHost'); $ADODB_SESS_DEBUG = false; $ADODB_CACHE_DIR = $myConfig->getConfigParam('sCompileDir'); $sModules = ''; if ($iDebug == 2 || $iDebug == 3 || $iDebug == 4 || $iDebug == 7) { $sModules = 'perfmon'; } // log admin changes ? if ($myConfig->isAdmin() && $myConfig->getConfigParam('blLogChangesInAdmin')) { $sModules = ($sModules ? ':' : '') . 'oxadminlog'; } self::$_oDB = ADONewConnection($myConfig->getConfigParam('dbType'), $sModules); $sVerPrefix = ''; $sVerPrefix = '_ce'; if (!self::$_oDB->connect($myConfig->getConfigParam('dbHost'), $myConfig->getConfigParam('dbUser'), $myConfig->getConfigParam('dbPwd'), $myConfig->getConfigParam('dbName'))) { $sConfig = join('', file(getShopBasePath() . 'config.inc.php')); if (strpos($sConfig, '<dbHost' . $sVerPrefix . '>') !== false && strpos($sConfig, '<dbName' . $sVerPrefix . '>') !== false) { header('location:setup/index.php'); // pop to setup as there is something wrong oxUtils::getInstance()->showMessageAndExit(""); } else { // notifying shop owner about connection problems $sFailedShop = isset($_REQUEST['shp']) ? addslashes($_REQUEST['shp']) : 'Base shop'; $sDate = date('l dS of F Y h:i:s A'); $sScript = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; $sReferer = $_SERVER['HTTP_REFERER']; //sending a message to admin $sWarningSubject = 'Offline warning!'; $sWarningBody = "\n Database error in OXID eShop:\n Date: {$sDate}\n Shop: {$sFailedShop}\n\n mysql error: " . self::$_oDB->errorMsg() . "\n mysql error no: " . self::$_oDB->errorNo() . "\n\n Script: {$sScript}\n Referer: {$sReferer}"; if ($sAdminEmail = $myConfig->getConfigParam('sAdminEmail')) { include 'core/phpmailer/class.phpmailer.php'; $oMailer = new phpmailer(); $oMailer->isMail(); $oMailer->From = $sAdminEmail; $oMailer->AddAddress($sAdminEmail); $oMailer->Subject = $sWarningSubject; $oMailer->Body = $sWarningBody; $oMailer->send(); } //only exception to default construction method $oEx = new oxConnectionException(); $oEx->setMessage('EXCEPTION_CONNECTION_NODB'); $oEx->setConnectionError($myConfig->getConfigParam('dbUser') . 's' . getShopBasePath() . self::$_oDB->errorMsg()); throw $oEx; } } if ($iDebug == 2 || $iDebug == 3 || $iDebug == 4 || $iDebug == 7) { try { self::$_oDB->execute('truncate table adodb_logsql;'); } catch (ADODB_Exception $e) { // nothing } self::$_oDB->logSQL(true); } self::$_oDB->cacheSecs = 60 * 10; // 10 minute caching self::$_oDB->execute('SET @@session.sql_mode = ""'); if ($myConfig->isUtf()) { self::$_oDB->execute('SET NAMES "utf8"'); self::$_oDB->execute('SET CHARACTER SET utf8'); self::$_oDB->execute('SET CHARACTER_SET_CONNECTION = utf8'); self::$_oDB->execute('SET CHARACTER_SET_DATABASE = utf8'); self::$_oDB->execute('SET character_set_results = utf8'); self::$_oDB->execute('SET character_set_server = utf8'); } elseif ($myConfig->getConfigParam('sDefaultDatabaseConnection') != '') { self::$_oDB->execute('SET NAMES ' . $myConfig->getConfigParam('sDefaultDatabaseConnection')); } return self::$_oDB; }
/** * Prints exception in file EXCEPTION_LOG.txt * * @return null */ public function debugOut() { //We are most likely are already dealing with an exception so making sure no other exceptions interfere try { $sLogMsg = $this->getString() . "\n---------------------------------------------\n"; oxUtils::getInstance()->writeToLog($sLogMsg, $this->getLogFileName()); } catch (Exception $e) { } }
/** * Sets user address and name to "reply to" array. * On error (wrong email) default shop email is added as a reply address. * Returns array of recipients * f.e. array( array('*****@*****.**', 'user1Name'), array('*****@*****.**', 'user2Name') ) * * @param string $sEmail email address * @param string $sName user name * * @return null */ public function setReplyTo($sEmail = null, $sName = null) { if (!oxUtils::getInstance()->isValidEmail($sEmail)) { $sEmail = $this->_getShop()->oxshops__oxorderemail->value; } $this->_aReplies[] = array($sEmail, $sName); try { parent::addReplyTo($sEmail, $sName); } catch (Exception $oEx) { } }
/** * For some user actions (like writing guestbook entry or product * review) user must be logged in. So e.g. in product details page * there is a link leading to current view. Link contains parameter * "sourcecl", which tells where to redirect after successfull login. * If this parameter is defined and oxcmp_user::getLoginStatus() == * USER_LOGIN_SUCCESS (means user has just logged in) then user is * redirected back to source view. * * @return null */ public function redirectAfterLogin() { // in case source class is provided - redirecting back to it with all default parameters if (($sSource = oxConfig::getParameter("sourcecl")) && $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS) { $sRedirectUrl = $this->getConfig()->getShopUrl() . 'index.php?cl=' . rawurlencode($sSource); // building redirect link foreach ($this->getNavigationParams() as $sName => $sValue) { if ($sValue && $sName != "sourcecl") { $sRedirectUrl .= '&' . rawurlencode($sName) . "=" . rawurlencode($sValue); } } return oxUtils::getInstance()->redirect(oxUtilsUrl::getInstance()->processUrl($sRedirectUrl), true, 302); } }
/** * Adds/removes chosen article to/from article comparison list * * @param object $sProductId product id * @param double $dAmount amount * @param array $aSel (default null) * @param bool $blOverride allow override * @param bool $blBundle bundled * * @return void */ public function toCompareList($sProductId = null, $dAmount = null, $aSel = null, $blOverride = false, $blBundle = false) { // only if enabled and not search engine.. if ($this->getViewConfig()->getShowCompareList() && !oxUtils::getInstance()->isSearchEngine()) { // #657 special treatment if we want to put on comparelist $blAddCompare = oxConfig::getParameter('addcompare'); $blRemoveCompare = oxConfig::getParameter('removecompare'); $sProductId = $sProductId ? $sProductId : oxConfig::getParameter('aid'); if (($blAddCompare || $blRemoveCompare) && $sProductId) { // toggle state in session array $aItems = oxSession::getVar('aFiltcompproducts'); if ($blAddCompare && !isset($aItems[$sProductId])) { $aItems[$sProductId] = true; } if ($blRemoveCompare) { unset($aItems[$sProductId]); } oxSession::setVar('aFiltcompproducts', $aItems); $oParentView = $this->getParent(); // #843C there was problem then field "blIsOnComparisonList" was not set to article object if ($oProduct = $oParentView->getViewProduct()) { if (isset($aItems[$oProduct->getId()])) { $oProduct->setOnComparisonList(true); } else { $oProduct->setOnComparisonList(false); } } $aViewProds = $oParentView->getViewProductList(); if (is_array($aViewProds) && count($aViewProds)) { foreach ($aViewProds as $oProduct) { if (isset($aItems[$oProduct->getId()])) { $oProduct->setOnComparisonList(true); } else { $oProduct->setOnComparisonList(false); } } } } } }
/** * Returns array of palain of formatted VATs which were calculated for basket * * @param bool $blFormatCurrency enambles currency formating * * @return array */ public function getProductVats($blFormatCurrency = true) { if (!$this->_oNotDiscountedProductsPriceList) { return array(); } $aVats = $this->_oNotDiscountedProductsPriceList->getVatInfo(); $oUtils = oxUtils::getInstance(); foreach ($this->_aDiscountedVats as $sKey => $dVat) { if (!isset($aVats[$sKey])) { $aVats[$sKey] = 0; } // add prices of the same discounts $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency); } if ($blFormatCurrency) { $oLang = oxLang::getInstance(); foreach ($aVats as $sKey => $dVat) { $aVats[$sKey] = $oLang->formatCurrency($dVat, $this->getBasketCurrency()); } } return $aVats; }
/** * Processes manufacturer category URLs * * @return null */ protected function _seoSetManufacturerData() { // only when SEO id on and in front end if (oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) { $oEncoder = oxSeoEncoderManufacturer::getInstance(); // preparing root manufacturer category if ($this->_oRoot) { $oEncoder->getManufacturerUrl($this->_oRoot); } // encoding manufacturer category foreach ($this as $sVndId => $value) { $oEncoder->getManufacturerUrl($this->_aArray[$sVndId]); } } }
/** * Adds page number parameter to current Url and returns formatted url * * @param string $sUrl url to append page numbers * @param int $iPage current page number * @param int $iLang requested language * * @return string */ protected function _addPageNrParam($sUrl, $iPage, $iLang = null) { if (oxUtils::getInstance()->seoIsActive() && ($oRecomm = $this->getActiveRecommList())) { if ($iPage) { // only if page number > 0 $sUrl = $oRecomm->getBaseSeoLink($iLang, $iPage); } } else { $sUrl = oxUBase::_addPageNrParam($sUrl, $iPage, $iLang); } return $sUrl; }
/** * Returns config sSSLShopURL or sMallSSLShopURL if secondary shop * * @param int $iLang language (default is null) * * @return string */ public function getSslShopUrl($iLang = null) { // #680 per language another URL $iLang = isset($iLang) ? $iLang : oxLang::getInstance()->getBaseLanguage(); $aLanguageSSLURLs = $this->getConfigParam('aLanguageSSLURLs'); if (isset($iLang) && isset($aLanguageSSLURLs[$iLang]) && !empty($aLanguageSSLURLs[$iLang])) { $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash($aLanguageSSLURLs[$iLang]); return $aLanguageSSLURLs[$iLang]; } //mall mode if ($sMallSSLShopURL = $this->getConfigParam('sMallSSLShopURL')) { $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash($sMallSSLShopURL); return $sMallSSLShopURL; } if ($sMallShopURL = $this->getConfigParam('sMallShopURL')) { $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash($sMallShopURL); return $sMallShopURL; } //normal section if ($sSSLShopURL = $this->getConfigParam('sSSLShopURL')) { return $sSSLShopURL; } return $this->getShopUrl($iLang); }
/** * Performs Voucherserie export to export file. * * @return null */ public function download() { $oUtils = oxUtils::getInstance(); $oUtils->setHeader("Pragma: public"); $oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0"); $oUtils->setHeader("Expires: 0"); $oUtils->setHeader("Content-Disposition: attachment; filename=vouchers.csv"); $oUtils->setHeader("Content-Type: application/csv"); $sFile = $this->_getExportFilePath(); if (file_exists($sFile) && is_readable($sFile)) { readfile($sFile); } $oUtils->showMessageAndExit(""); }
/** * send page headers (content type, charset) * * @return null */ public function sendHeaders() { switch ($this->_sOutputFormat) { case self::OUTPUT_FORMAT_JSON: oxUtils::getInstance()->setHeader("Content-Type: application/json; charset=" . $this->_sCharset); break; case self::OUTPUT_FORMAT_HTML: default: oxUtils::getInstance()->setHeader("Content-Type: text/html; charset=" . $this->_sCharset); break; } }
/** * Executes parent::render(), if basket is empty - redirects to main page * and exits the script (oxorder::validateOrder()). Loads and passes payment * info to template engine. Refreshes basket articles info by additionally loading * each article object (oxorder::getProdFromBasket()), adds customer addressing/delivering * data (oxorder::getDelAddressInfo()) and delivery sets info (oxorder::getShipping()). * Returns name of template to render order::_sThisTemplate. * * @return string */ public function render() { if ($this->getIsOrderStep()) { $oBasket = $this->getBasket(); $myConfig = $this->getConfig(); if ($myConfig->getConfigParam('blPsBasketReservationEnabled')) { $this->getSession()->getBasketReservations()->renewExpiration(); if (!$oBasket || $oBasket && !$oBasket->getProductsCount()) { oxUtils::getInstance()->redirect($myConfig->getShopHomeURL() . 'cl=basket', true, 302); } } // can we proceed with ordering ? $oUser = $this->getUser(); if (!$oUser && ($oBasket && $oBasket->getProductsCount() > 0)) { oxUtils::getInstance()->redirect($myConfig->getShopHomeURL() . 'cl=basket', false, 302); } elseif (!$oBasket || !$oUser || $oBasket && !$oBasket->getProductsCount()) { oxUtils::getInstance()->redirect($myConfig->getShopHomeURL(), false, 302); } // payment is set ? if (!$this->getPayment()) { // redirecting to payment step on error .. oxUtils::getInstance()->redirect($myConfig->getShopCurrentURL() . '&cl=payment', true, 302); } } parent::render(); // reload blocker if (!oxSession::getVar('sess_challenge')) { oxSession::setVar('sess_challenge', oxUtilsObject::getInstance()->generateUID()); } return $this->_sThisTemplate; }
/** * Saves seo cache data for active view (in non admin mode) * * @param string $sCacheIdent cache identifier * @param string $sCache cacheable data * @param string $sType object type * @param int $iLang active language id * @param mixed $iShopId active shop id * @param string $sParams additional seo params. optional (mostly used for db indexing) * * @return bool */ protected function _saveInCache($sCacheIdent, $sCache, $sType, $iLang = null, $iShopId = null, $sParams = null) { if (!$this->getConfig()->getConfigParam('blEnableSeoCache')) { return false; } startProfile("seoencoder_saveInCache"); $blSaved = false; if ($sCache && ($sCacheKey = $this->_getCacheKey($sType, $iLang, $iShopId, $sParams)) !== false) { self::$_aCache[$sCacheKey][$sCacheIdent] = $sCache; $blSaved = oxUtils::getInstance()->toFileCache($sCacheKey, self::$_aCache[$sCacheKey]); } stopProfile("seoencoder_saveInCache"); return $blSaved; }
/** * No oxid exception, just write log file. * IMPOARTANT: uses _safeShopRedirectAndExit(), see description * * @param Exception $oEx exception object * * @return null */ protected function _dealWithNoOxException(Exception $oEx) { if (0 != $this->_iDebug) { $sLogMsg = date('Y-m-d H:i:s') . $oEx . "\n---------------------------------------------\n"; oxUtils::getInstance()->writeToLog($sLogMsg, $this->getLogFileName()); if (defined('OXID_PHP_UNIT')) { return; } elseif (0 != $this->_iDebug) { oxUtils::getInstance()->showMessageAndExit($sLogMsg); } } $sShopUrl = oxConfig::getInstance()->getShopMainUrl(); $this->_safeShopRedirectAndExit($sShopUrl . "offline.html"); }