/** * Get label value * * @return string */ protected function getLabelValue() { $value = strval($this->getValue()); if (!$this->getParam(static::PARAM_UNESCAPE)) { $value = func_htmlspecialchars($value); } return $value; }
/** * Get tooltip * * @return string */ protected function getTooltip() { if ($this->getAttributeGroup()) { $result = ''; } elseif ($this->getProductClass()) { $result = static::t('These attributes can be applied to the "{{name}}" product class.', array('name' => func_htmlspecialchars($this->getProductClass()->getName()))); } elseif ($this->getPersonalOnly()) { $result = static::t('These attributes can only be applied to this particular product.'); } else { $result = static::t('These attributes can be applied to all the products in the store.'); } return $result; }
/** * Check coupon * * @return void */ protected function doActionCheckCoupon() { $code = strval(\XLite\Core\Request::getInstance()->code); $coupon = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->findOneByCode($code); $codes = $coupon ? $coupon->getErrorCodes($this->getOrder()) : array(); $error = null; $this->valid = false; if (!$coupon || $codes) { if ($coupon && in_array(\XLite\Module\CDev\Coupons\Model\Coupon::ERROR_TOTAL, $codes)) { $currency = $this->getOrder()->getCurrency(); if (0 < $coupon->getTotalRangeBegin() && 0 < $coupon->getTotalRangeEnd()) { $error = static::t('To use the coupon, your order subtotal must be between X and Y', array('min' => $currency->formatValue($coupon->getTotalRangeBegin()), 'max' => $currency->formatValue($coupon->getTotalRangeEnd()))); } elseif (0 < $coupon->getTotalRangeBegin()) { $error = static::t('To use the coupon, your order subtotal must be at least X', array('min' => $currency->formatValue($coupon->getTotalRangeBegin()))); } else { $error = static::t('To use the coupon, your order subtotal must not exceed Y', array('max' => $currency->formatValue($coupon->getTotalRangeEnd()))); } } else { $error = static::t('There is no such a coupon, please check the spelling: X', array('code' => func_htmlspecialchars($code))); } } else { $found = false; foreach ($this->getOrder()->getUsedCoupons() as $usedCoupon) { if ($usedCoupon->getCoupon() && $usedCoupon->getCoupon()->getId() == $coupon->getId()) { $found = true; break; } } if ($found) { // Duplicate $error = static::t('You have already used the coupon'); } else { $this->valid = true; } } $data = array('error' => null); if ($error) { $data['error'] = $error; } else { $data['amount'] = $coupon->getAmount($this->getOrder()); } $this->setPureAction(); $this->suppressOutput = true; $this->silent = true; print json_encode($data); }
/** * Return HTML representation for widget attributes * * @return string */ protected function getAttributesCode() { $result = ''; foreach ($this->getAttributes() as $name => $value) { $result .= ' ' . $name . '="' . func_htmlspecialchars($value) . '"'; } return $result; }
/** * Get profile name * * @return string */ protected function getProfileName() { $profile = $this->getOrder()->getProfile(); $address = $profile->getBillingAddress() ?: $profile->getShippingAddress(); if (!$address) { $profile->getAddresses()->first(); } return $address ? func_htmlspecialchars($address->getName()) : $profile->getLogin(); }
/** * Return shortened review content * * @param \XLite\Module\XC\Reviews\Model\Review $entity Review * * @return string */ protected function getReviewShortContent(\XLite\Module\XC\Reviews\Model\Review $entity) { $review = $entity->getReview(); $review = trim($review); if (function_exists('mb_substr')) { $value = mb_substr($review, 0, 30, 'utf-8'); $result = $value . (mb_strlen($value, 'utf-8') != mb_strlen($review, 'utf-8') ? '...' : ''); } else { $value = substr($review, 0, 30); $result = $value . (strlen($value) != strlen($review) ? '...' : ''); } return func_htmlspecialchars($result); }
/** * Get formatted path of current category * * @return string */ protected function getFormattedPath() { $list = array(); foreach ($this->getCategory()->getPath() as $category) { $list[] = '<a href="' . static::buildURL('categories', '', array('id' => $category->getCategoryId())) . '">' . func_htmlspecialchars($category->getName()) . '</a>'; } return implode(' :: ', $list); }
/** * Return HTML representation for widget attributes * * @return string */ protected function getDataCode() { $result = ''; foreach ($this->getAttributes() as $name => $value) { if ('class' != $name) { $result .= ' data-' . $name . '="' . func_htmlspecialchars($value) . '"'; } } return $result; }
/** * Get option attributes * * @param mixed $value Value * * @return array */ protected function getOptionAttributes($value) { $attributes = array('value' => func_htmlspecialchars($value)); if ($this->isOptionSelected($value)) { $attributes['selected'] = 'selected'; } if ($this->isOptionDisabled($value)) { $attributes['disabled'] = 'disabled'; } return $attributes; }
/** * htmlspecialchars умеющая обрабатывать массивы * * @param unknown_type $data */ function func_htmlspecialchars(&$data) { if (is_array($data)) { foreach ($data as $sKey => $value) { if (is_array($value)) { func_htmlspecialchars($data[$sKey]); } else { $data[$sKey] = htmlspecialchars($value); } } } else { $data = htmlspecialchars($data); } }
/** * Выполняет загрузку необходимых (возможно даже системных :)) переменных в шаблон * */ public function VarAssign() { /** * Загружаем весь $_REQUEST, предварительно обработав его функцией func_htmlspecialchars() */ $aRequest = $_REQUEST; func_htmlspecialchars($aRequest); $this->Assign("_aRequest", $aRequest); /** * Параметры стандартной сессии */ $this->Assign("_sPhpSessionName", session_name()); $this->Assign("_sPhpSessionId", session_id()); /** * Short Engine aliases */ $this->Assign("LS", LS::getInstance()); /** * Загружаем объект доступа к конфигурации */ $this->Assign("oConfig", Config::getInstance()); /** * Загружаем роутинг с учетом правил rewrite */ $aRouter = array(); if ($aPages = Config::Get('router.page')) { foreach ($aPages as $sPage => $aAction) { $aRouter[$sPage] = Router::GetPath($sPage); } } $this->Assign("aRouter", $aRouter); /** * Загружаем в шаблон блоки */ $this->Assign("aBlocks", $this->aBlocks); /** * Загружаем в шаблон JS переменные */ $this->Assign("aVarsJs", $this->aVarsJs); /** * Загружаем HTML заголовки */ $this->Assign("sHtmlTitle", htmlspecialchars($this->GetHtmlTitle(Config::Get('view.title_sort_reverse')))); $this->Assign("sHtmlKeywords", htmlspecialchars($this->sHtmlKeywords)); $this->Assign("sHtmlDescription", htmlspecialchars($this->sHtmlDescription)); $this->Assign("aHtmlHeadFiles", $this->aHtmlHeadFiles); $this->Assign("aHtmlRssAlternate", $this->aHtmlRssAlternate); $this->Assign("sHtmlCanonical", func_urlspecialchars($this->sHtmlCanonical)); $this->Assign("sHtmlRobots", $this->sHtmlRobots); /** * Загружаем список активных плагинов */ $aPlugins = Engine::getInstance()->GetPlugins(); $this->Assign("aPluginActive", array_fill_keys(array_keys($aPlugins), true)); /** * Загружаем пути до шаблонов плагинов */ $aTemplateWebPathPlugin = array(); $aTemplatePathPlugin = array(); foreach ($aPlugins as $k => $oPlugin) { $aTemplateWebPathPlugin[$k] = Plugin::GetTemplateWebPath(get_class($oPlugin)); $aTemplatePathPlugin[$k] = Plugin::GetTemplatePath(get_class($oPlugin)); } $this->Assign("aTemplateWebPathPlugin", $aTemplateWebPathPlugin); $this->Assign("aTemplatePathPlugin", $aTemplatePathPlugin); /** * Загружаем security-ключ */ $this->Assign("LIVESTREET_SECURITY_KEY", $this->Security_GetSecurityKey()); }
/** * Get option attributes as HTML code * * @param mixed $value Value * @param mixed $text Text * * @return string */ protected function getOptionAttributesCode($value, $text) { $list = array(); foreach ($this->getOptionAttributes($value, $text) as $name => $value) { $list[] = $name . '="' . func_htmlspecialchars($value) . '"'; } return implode(' ', $list); }
/** * Format price as HTML block * * @param float $value Value * @param \XLite\Model\Currency $currency Currency OPTIONAL * * @return string */ public function formatPriceHTML($value, \XLite\Model\Currency $currency = null) { if (!isset($currency)) { $currency = \XLite::getInstance()->getCurrency(); } $parts = $currency->formatParts($value); if (isset($parts['sign']) && '-' == $parts['sign']) { $parts['sign'] = '− '; } foreach ($parts as $name => $value) { $class = 'part-' . $name; $parts[$name] = '<span class="' . $class . '">' . func_htmlspecialchars($value) . '</span>'; } return implode('', $parts); }
/** * Возвращает экранированный список параметров * * @return array */ public function getParamsEscape() { $aParams = $this->getParams(); func_htmlspecialchars($aParams); return $aParams; }
/** * Validate string for using in XML node * * @param mixed $arg Arguments string/array * * @return mixed */ protected function getQuoted($arg) { if (is_array($arg)) { foreach ($arg as $k => $v) { if ($k == 'phone') { $arg[$k] = preg_replace('/[^0-9]/', "", $v); } elseif (is_string($v)) { $arg[$k] = func_htmlspecialchars($v); } } } elseif (is_string($arg)) { $arg = func_htmlspecialchars($arg); } return $arg; }
/** * Get escaped widget parameter * * @param string $name Parameters name * * @return string */ protected function getEscapedParam($name) { $value = $this->getParam($name); return func_htmlspecialchars($value); }
/** * Выполняет загрузку необходимый(возможно даже системный :)) переменных в шалон * */ public function VarAssign() { /** * Загружаем весь $_REQUEST, предварительно обработав его функцией func_htmlspecialchars() */ $aRequest = $_REQUEST; func_htmlspecialchars($aRequest); $this->Assign("_aRequest", $aRequest); /** * Параметры стандартной сессии */ $this->Assign("_sPhpSessionName", session_name()); $this->Assign("_sPhpSessionId", session_id()); /** * Short Engine aliases */ $this->Assign("LS", LS::getInstance()); /** * Загружаем объект доступа к конфигурации */ $this->Assign("oConfig", Config::getInstance()); /** * Загружаем роутинг с учетом правил rewrite */ $aRouter = array(); $aPages = Config::Get('router.page'); if (!$aPages or !is_array($aPages)) { throw new Exception('Router rules is underfined.'); } foreach ($aPages as $sPage => $aAction) { $aRouter[$sPage] = Router::GetPath($sPage); } $this->Assign("aRouter", $aRouter); /** * Загружаем в шаблон блоки */ $this->Assign("aBlocks", $this->aBlocks); /** * Загружаем HTML заголовки */ $this->Assign("sHtmlTitle", htmlspecialchars($this->sHtmlTitle)); $this->Assign("sHtmlKeywords", htmlspecialchars($this->sHtmlKeywords)); $this->Assign("sHtmlDescription", htmlspecialchars($this->sHtmlDescription)); $this->Assign("aHtmlHeadFiles", $this->aHtmlHeadFiles); $this->Assign("aHtmlRssAlternate", $this->aHtmlRssAlternate); /** * Загружаем список активных плагинов */ $aPlugins = $this->oEngine->GetPlugins(); $this->Assign("aPluginActive", array_fill_keys(array_keys($aPlugins), true)); /** * Загружаем пути до шаблонов плагинов */ $aTemplateWebPathPlugin = array(); $aTemplatePathPlugin = array(); foreach ($aPlugins as $k => $oPlugin) { $aTemplateWebPathPlugin[$k] = Plugin::GetTemplateWebPath(get_class($oPlugin)); $aTemplatePathPlugin[$k] = Plugin::GetTemplatePath(get_class($oPlugin)); } $this->Assign("aTemplateWebPathPlugin", $aTemplateWebPathPlugin); $this->Assign("aTemplatePathPlugin", $aTemplatePathPlugin); }
/** * Preprocess category * * @param integer $date Date * @param array $column Column data * @param \XLite\Model\Product $entity Product * * @return string */ protected function preprocessCategory($date, array $column, \XLite\Model\Product $entity) { return $date ? func_htmlspecialchars($date->getName()) : ''; }
/** * Print AJAX request output * * @param mixed $viewer Viewer to display in AJAX * * @return void */ protected function printAJAXOutput($viewer) { $content = $viewer->getContent(); $class = 'ajax-container-loadable' . ' ctrl-' . implode('-', \XLite\Core\Operator::getInstance()->getClassNameAsKeys(get_called_class())) . ' widget-' . implode('-', \XLite\Core\Operator::getInstance()->getClassNameAsKeys($viewer)); echo '<div' . ' class="' . $class . '"' . ' title="' . func_htmlspecialchars(static::t($this->getTitle())) . '">' . $content . '</div>'; }
/** * Get container attributes as string * * @return string */ protected function getContainerAttributesAsString() { $list = array(); foreach ($this->getContainerAttributes() as $name => $value) { $list[] = $name . '="' . func_htmlspecialchars($value) . '"'; } return implode(' ', $list); }