public function getInputErrors(array $data) { $errors = parent::getInputErrors($data); if (empty($data['securesubmit_token'])) { $errors[] = \XLite\Core\Translation::lbl('Payment processed with errors. Please, try again or ask administrator'); } return $errors; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && !preg_match('/^[\\-\\+]{1}([0-9]+)([\\.,]([0-9]+))?([%]{1})?$/Ss', $this->getValue())) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && !preg_match('/^([\\+]\\d{1,3}[ \\.\\-])?([\\(]{1}\\d{2,6}[\\)])?([\\d \\.\\-\\/]{3,20})((x|ext|extension)[ ]?\\d{1,4})?$/Ss', $this->getValue())) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && false === filter_var($this->getValue(), FILTER_VALIDATE_EMAIL)) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
public function getInputErrors(array $data) { $errors = parent::getInputErrors($data); error_log(print_r($data, true)); if (!isset($data['securesubmit_use_stored_card']) && empty($data['securesubmit_token']) || empty($data['securesubmit_token']) && $data['securesubmit_use_stored_card'] === 'new') { $errors[] = \XLite\Core\Translation::lbl('Payment processed with errors. Please, try again or ask administrator'); } return $errors; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && strlen($result) > $this->getParam(self::PARAM_MAX_LENGTH)) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field should not be longer than Y', array('name' => $this->getLabel(), 'max' => $this->getParam(self::PARAM_MAX_LENGTH))); } return $result; }
/** * Get input errors * * @param array $data Input data * * @return array */ public function getInputErrors(array $data) { $errors = parent::getInputErrors($data); foreach ($this->getInputDataLabels() as $k => $t) { if (!isset($data[$k]) || !$data[$k]) { $errors[] = \XLite\Core\Translation::lbl('X field is required', array('field' => $t)); } } return $errors; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $parts = @parse_url($this->getValue()); if (!$parts || !isset($parts['scheme']) || !isset($parts['host'])) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } } return $result; }
/** * Check range * * @return boolean */ protected function checkRange() { $result = true; if (!is_null($this->getParam(self::PARAM_MIN)) && $this->getValue() < $this->getParam(self::PARAM_MIN)) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field must be greater than Y', array('name' => $this->getLabel(), 'min' => $this->formatDate($this->getParam(self::PARAM_MIN)))); } elseif (!is_null($this->getParam(self::PARAM_MAX)) && $this->getValue() > $this->getParam(self::PARAM_MAX)) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field must be less than Y', array('name' => $this->getLabel(), 'max' => $this->formatDate($this->getParam(self::PARAM_MAX)))); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $validator = new \XLite\Core\Validator\String\CleanURL(false, null, '\\XLite\\Module\\CDev\\SimpleCMS\\Model\\Page', \XLite\Core\Request::getInstance()->id); try { $validator->validate($this->getValue()); } catch (\XLite\Core\Validator\Exception $exception) { $message = static::t($exception->getMessage(), $exception->getLabelArguments()); $result = false; $this->errorMessage = \XLite\Core\Translation::lbl(($exception->getPublicName() ? static::t($exception->getPublicName()) . ': ' : '') . $message, array('name' => $this->getLabel())); } } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $validator = new \XLite\Core\Validator\SKU($this->getProductId()); try { $validator->validate($this->getValue()); } catch (\XLite\Core\Validator\Exception $exception) { $message = static::t($exception->getMessage(), $exception->getLabelArguments()); $result = false; $this->errorMessage = \XLite\Core\Translation::lbl(($exception->getPublicName() ? static::t($exception->getPublicName()) . ': ' : '') . $message, array('name' => $this->getLabel())); } } return $result; }
/** * "Upload" handler for category images. * * @return void */ protected function doActionSelectUploadLanguageFile() { $result = null; $error = null; $message = null; $key = 'uploaded_file'; $cell = isset($_FILES[$key]) ? $_FILES[$key] : null; if ($cell) { $size = null; switch ($cell['error']) { case UPLOAD_ERR_OK: $path = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, $cell['name']); if (move_uploaded_file($cell['tmp_name'], $path)) { $result = $path; } break; case UPLOAD_ERR_INI_SIZE: $size = ini_get('upload_max_filesize'); case UPLOAD_ERR_FORM_SIZE: $size = $size ?: \XLite\Core\Request::getInstance()->MAX_FILE_SIZE; $error = 'File size exceeds the maximum size (' . $size . ')'; $size = \XLite\Core\Converter::convertShortSizeToHumanReadable($size); $message = \XLite\Core\Translation::lbl('File size exceeds the maximum size', array('size' => $size)); break; case UPLOAD_ERR_PARTIAL: $error = 'The uploaded file was only partially uploaded'; case UPLOAD_ERR_NO_FILE: $error = $error ?: 'No file was uploaded'; case UPLOAD_ERR_NO_TMP_DIR: $error = $error ?: 'Missing a temporary folder'; case UPLOAD_ERR_CANT_WRITE: $error = $error ?: 'Failed to write file to disk'; case UPLOAD_ERR_EXTENSION: $message = \XLite\Core\Translation::lbl('The file was not loaded because of a failure on the server.'); $error = $error ?: 'File upload stopped by extension'; break; default: } } if ($result && $message) { \XLite\Logger::getInstance()->log('Upload file error: ' . $error ?: $message, LOG_ERR); } $this->doActionSelectLanguageFile($result, $message); }
/** * Returns available layout colors * * @return array */ public static function getLayoutColors() { return array('Fashion' => \XLite\Core\Translation::lbl('Fashion'), 'Noblesse' => \XLite\Core\Translation::lbl('Noblesse'), 'Digital' => \XLite\Core\Translation::lbl('Digital')); }
/** * Get field label * * @return string */ public function getLabel() { return \XLite\Core\Translation::lbl('Authorize amount for card setup'); }
/** * Define columns structure * * @return array */ protected function defineColumns() { return array('order_id' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Order ID'), static::COLUMN_LINK => 'order'), 'date' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Date'), static::COLUMN_TEMPLATE => $this->getDir() . '/' . $this->getPageBodyDir() . '/order/cell.date.tpl'), 'profile' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Customer'), static::COLUMN_TEMPLATE => $this->getDir() . '/' . $this->getPageBodyDir() . '/order/cell.profile.tpl'), 'status' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Status'), static::COLUMN_CLASS => 'XLite\\View\\FormField\\Inline\\Select\\OrderStatus'), 'total' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Amount'), static::COLUMN_TEMPLATE => $this->getDir() . '/' . $this->getPageBodyDir() . '/order/cell.total.tpl')); }
/** * Send message * * @return void */ protected function doActionSend() { $data = \XLite\Core\Request::getInstance()->getData(); $config = \XLite\Core\Config::getInstance()->CDev->ContactUs; $isValid = true; foreach ($this->requiredFields as $key => $name) { if (!isset($data[$key]) || empty($data[$key])) { $isValid = false; \XLite\Core\TopMessage::addError(static::t('The X field is empty', array('name' => $name))); } } if ($isValid && false === filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { $isValid = false; \XLite\Core\TopMessage::addError(\XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->requiredFields['email']))); } if ($isValid && $config->recaptcha_private_key && $config->recaptcha_public_key) { require_once LC_DIR_MODULES . '/CDev/ContactUs/recaptcha/recaptchalib.php'; $resp = recaptcha_check_answer($config->recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $data['recaptcha_challenge_field'], $data['recaptcha_response_field']); $isValid = $resp->is_valid; if (!$isValid) { \XLite\Core\TopMessage::addError('Please enter the correct captcha'); } } if ($isValid) { $errorMessage = \XLite\Core\Mailer::sendContactUsMessage($data, \XLite\Core\Config::getInstance()->CDev->ContactUs->email ?: \XLite\Core\Config::getInstance()->Company->support_department); if ($errorMessage) { \XLite\Core\TopMessage::addError($errorMessage); } else { unset($data['message']); unset($data['subject']); \XLite\Core\TopMessage::addInfo('Message has been sent'); } } \XLite\Core\Session::getInstance()->contact_us = $data; }
/** * Get field label * * @return string */ public function getLabel() { return \XLite\Core\Translation::lbl('Payment method for card setup' . \XLite\Core\Config::getInstance()->CDev->XPaymentsConnector->xpc_zero_auth_method_id); }
/** * Define columns structure * * @return array */ protected function defineColumns() { return array('name' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Name'), static::COLUMN_TEMPLATE => 'modules/XC/CustomProductTabs/product/name.tpl')); }
/** * Get create message * * @param integer $count Count * * @return string */ protected function getCreateMessage($count) { return \XLite\Core\Translation::lbl('X product(s) has been created', array('count' => $count)); }
/** * Define columns structure * * @return array */ protected function defineColumns() { return array_merge(parent::defineColumns(), array('featured_products' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Featured'), static::COLUMN_TEMPLATE => false, static::COLUMN_ORDERBY => 250))); }
/** * Define columns structure * * @return array */ protected function defineColumns() { return array('quantityRangeBegin' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Quantity range'), static::COLUMN_CLASS => 'XLite\\Module\\CDev\\Wholesale\\View\\FormField\\QuantityRangeBegin', static::COLUMN_ORDERBY => 100), 'price' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Price'), static::COLUMN_CLASS => 'XLite\\Module\\CDev\\Wholesale\\View\\FormField\\Price', static::COLUMN_ORDERBY => 200), 'membership' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Membership'), static::COLUMN_CLASS => 'XLite\\Module\\CDev\\Wholesale\\View\\FormField\\Membership', static::COLUMN_ORDERBY => 300)); }
/** * Define columns structure * * @return array */ protected function defineColumns() { return array('sku' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('SKU'), static::COLUMN_CLASS => 'XLite\\View\\FormField\\Inline\\Input\\Text\\Product\\SKU', static::COLUMN_ORDERBY => 100), 'name' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Name'), static::COLUMN_CLASS => 'XLite\\View\\FormField\\Inline\\Input\\Text\\Product\\Name', static::COLUMN_MAIN => true, static::COLUMN_ORDERBY => 200), 'price' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Price'), static::COLUMN_CLASS => 'XLite\\View\\FormField\\Inline\\Input\\Text\\Price', static::COLUMN_PARAMS => array('min' => 0), static::COLUMN_ORDERBY => 300), 'qty' => array(static::COLUMN_NAME => \XLite\Core\Translation::lbl('Stock'), static::COLUMN_CLASS => 'XLite\\View\\FormField\\Inline\\Input\\Text\\Integer\\ProductQuantity', static::COLUMN_ORDERBY => 400), 'edit' => array(static::COLUMN_TEMPLATE => 'items_list/product/table/parts/columns/edit.tpl', static::COLUMN_ORDERBY => 500)); }
/** * Get surcharge name * * @param \XLite\Model\Order\Surcharge $surcharge Surcharge * * @return \XLite\DataSet\Transport\Order\Surcharge */ public function getSurchargeInfo(\XLite\Model\Base\Surcharge $surcharge) { $info = new \XLite\DataSet\Transport\Order\Surcharge(); $info->name = \XLite\Core\Translation::lbl('Discount'); return $info; }
/** * Get required field error message * * @return string */ protected function getRequiredFieldErrorMessage() { return \XLite\Core\Translation::lbl('The X field is empty', array('name' => $this->getLabel())); }
/** * Check maximum value * * @return boolean */ protected function checkMaxValue() { $result = true; $max = $this->getMaxValue(); if (!is_null($max) && $this->getValue() > $max) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field must be less than Y', array('name' => $this->getLabel(), 'max' => $max)); } return $result; }
/** * Convert short size (2M, 8K) to human readable * * @param string $size Shortsize * * @return string */ public static function convertShortSizeToHumanReadable($size) { $size = static::convertShortSize($size); if (static::GIGABYTE < $size) { $label = 'X GB'; $size = round($size / static::GIGABYTE, 3); } elseif (static::MEGABYTE < $size) { $label = 'X MB'; $size = round($size / static::MEGABYTE, 3); } elseif (static::KILOBYTE < $size) { $label = 'X kB'; $size = round($size / static::KILOBYTE, 3); } else { $label = 'X bytes'; } return \XLite\Core\Translation::lbl($label, array('value' => $size)); }
/** * Get surcharge name * * @param \XLite\Model\Order\Surcharge $surcharge Surcharge * * @return \XLite\DataSet\Transport\Order\Surcharge */ public function getSurchargeInfo(\XLite\Model\Base\Surcharge $surcharge) { $info = new \XLite\DataSet\Transport\Order\Surcharge(); $info->name = \XLite\Core\Translation::lbl('Shipping cost'); $info->notAvailableReason = \XLite\Core\Translation::lbl('Shipping address is not defined'); return $info; }
/** * Define the warning if amount is less or more than purchase limits * * @param integer $amount * * @return string */ public function getAmountWarning($amount) { $result = ''; $minQuantity = $this->getObject()->getMinPurchaseLimit(); $maxQuantity = $this->getObject()->getMaxPurchaseLimit(); if ($amount < $minQuantity) { //There's a minimum purchase limit of MinQuantity. The number of units of the product ProductName in cart has been adjusted to reach this limit. $result = \XLite\Core\Translation::lbl('There is a minimum purchase limit of MinQuantity', array('minQuantity' => $minQuantity, 'productName' => $this->getName())); } elseif ($amount > $maxQuantity) { $result = \XLite\Core\Translation::lbl('There is a maximum purchase limit of MaxQuantity', array('maxQuantity' => $maxQuantity, 'productName' => $this->getName())); } return $result; }
/** * Get create message * * @param integer $count Count * * @return string */ protected function getCreateMessage($count) { return \XLite\Core\Translation::lbl('X variants have been created', array('count' => $count)); }
/** * Get surcharge name * * @param \XLite\Model\Base\Surcharge $surcharge Surcharge * * @return \XLite\DataSet\Transport\Order\Surcharge */ public function getSurchargeInfo(\XLite\Model\Base\Surcharge $surcharge) { $info = new \XLite\DataSet\Transport\Order\Surcharge(); if (0 === strpos($surcharge->getCode(), $this->code . '.')) { $id = intval(substr($surcharge->getCode(), strlen($this->code) + 1)); $tax = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\SalesTax\\Model\\Tax')->find($id); $info->name = $tax ? $tax->getName() : \XLite\Core\Translation::lbl('Sales tax'); } else { $info->name = \XLite\Core\Translation::lbl('Sales tax'); } $info->notAvailableReason = \XLite\Core\Translation::lbl('Billing address is not defined'); return $info; }