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;
 }
Example #2
0
 /**
  * Execute certain hook handler
  *
  * @return void
  */
 public function executeHookHandler()
 {
     \XLite\Core\Translation::getInstance()->reset();
     \XLite\Core\Database::getEM()->flush();
     \XLite\Core\Translation::getInstance()->resetDriver();
     \XLite\Core\Translation::getInstance()->translateByString('label');
     \XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->setVar(\XLite::CACHE_TIMESTAMP, intval(microtime(true)));
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * Return list of product labels
  *
  * @param \XLite\Model\Product $product The product to look for
  *
  * @return array
  */
 protected function getLabels(\XLite\Model\Product $product)
 {
     $labels = parent::getLabels($product);
     if ($this->participateSale($product)) {
         $label = intval($product->getSalePercent()) . '% ' . \XLite\Core\Translation::getInstance()->translate('off');
         $labels += array('orange sale-price' => $label);
     }
     return $labels;
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
 /**
  * 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;
 }
 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;
 }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
File: Date.php Project: kingsj/core
 /**
  * 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;
 }
Example #12
0
 /**
  * Get label translation 
  * 
  * @param string $code Language code OPTIONAL
  *  
  * @return \XLite\Model\LanguageLabelTranslation
  */
 public function getLabelTranslation($code = null)
 {
     $result = null;
     $query = \XLite\Core\Translation::getLanguageQuery($code);
     foreach ($query as $code) {
         $result = $this->getTranslation($code, true);
         if (isset($result) || 'en' == $code) {
             break;
         }
     }
     return $result;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct()
 {
     $this->em = \XLite\Core\Database::getEM();
     $this->translation = \XLite\Core\Translation::getInstance();
     $entities = \XLite\Core\Database::getCacheDriver()->fetch('quickEntities');
     if (!is_array($entities) || !$entities) {
         foreach ($this->em->getMetadataFactory()->getAllMetadata() as $md) {
             if (!$md->isMappedSuperclass && preg_match('/^XLite\\\\(?:Module\\\\([a-z0-9]+)\\\\)?Model\\\\(.+)$/iSs', $md->name, $m)) {
                 $key = ($m[1] ? $m[1] . '\\' : '') . $m[2];
                 $entities[$key] = $md->name;
             }
         }
         \XLite\Core\Database::getCacheDriver()->save('quickEntities', $entities);
     }
     $this->entities = $entities;
 }
Example #16
0
 /**
  * Get field label
  *
  * @return string
  */
 public function getLabel()
 {
     return \XLite\Core\Translation::lbl('Authorize amount for card setup');
 }
Example #17
0
 /**
  * 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'));
 }
Example #18
0
 /**
  * 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;
 }
Example #19
0
File: Main.php Project: kingsj/core
 /**
  * Decorator run this method at the end of cache rebuild
  *
  * @return void
  */
 public static function runBuildCacheHandler()
 {
     $language = \XLite\Core\Database::getRepo('\\XLite\\Model\\Language')->findOneByCode(static::LANG_CODE);
     if (isset($language)) {
         if (!$language->getEnabled()) {
             $language->setEnabled(true);
             \XLite\Core\Database::getRepo('\\XLite\\Model\\Language')->update($language);
             \XLite\Core\TopMessage::addInfo('The X language has been added and enabled successfully', array('language' => $language->getName()), $language->getCode());
         }
         \XLite\Core\Translation::getInstance()->reset();
     } else {
         \XLite\Core\TopMessage::addError('The language you want to add has not been found');
     }
 }
Example #20
0
 /**
  * Return current translation code
  *
  * @param string $code Language code OPTIONAL
  *
  * @return string
  */
 protected function getTranslationCode($code = null)
 {
     if (!isset($code)) {
         if ($this->editLanguage) {
             $code = $this->editLanguage;
         } elseif (\XLite\Logic\Export\Generator::getLanguageCode()) {
             $code = \XLite\Logic\Export\Generator::getLanguageCode();
         } elseif (\XLite\Logic\Import\Importer::getLanguageCode()) {
             $code = \XLite\Logic\Import\Importer::getLanguageCode();
         } elseif (\XLite\Core\Translation::getTmpMailTranslationCode()) {
             $code = \XLite\Core\Translation::getTmpMailTranslationCode();
         } else {
             $code = $this->getSessionLanguageCode();
         }
     }
     return $code;
 }
Example #21
0
 /**
  * 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'));
 }
Example #22
0
 /**
  * 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)));
 }
Example #23
0
 /**
  * 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;
 }
Example #24
0
 /**
  * Get content of Free shipping label
  *
  * @return array
  */
 protected static function getLabelContent()
 {
     return array('blue free-shipping' => \XLite\Core\Translation::getInstance()->translate('FREE'));
 }
Example #25
0
 /**
  * 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'));
 }
Example #26
0
 /**
  * "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);
 }
Example #27
0
File: I18n.php Project: kingsj/core
 /**
  * Get translation in safe mode
  *
  * @param string $code Language code OPTIONAL
  *
  * @return \XLite\Model\Base\Translation
  */
 public function getSoftTranslation($code = null)
 {
     $result = null;
     // Select by languages query (current languge -> default language -> hardcoded default language)
     $query = \XLite\Core\Translation::getLanguageQuery($this->getTranslationCode($code));
     foreach ($query as $code) {
         $result = $this->getTranslation($code, true);
         if (isset($result)) {
             break;
         }
     }
     // Get first translation
     if (!isset($result)) {
         $result = $this->getTranslations()->first() ?: null;
     }
     // Get empty dump translation with specified code
     if (!isset($result)) {
         $result = $this->getTranslation(array_shift($query));
     }
     return $result;
 }
Example #28
0
 /**
  * Get time label
  *
  * @return string
  */
 protected function getTimeLabel()
 {
     return \XLite\Core\Translation::formatTimePeriod($this->getImporter()->getStep()->getTimeRemain());
 }
Example #29
0
 /**
  * Get title
  *
  * @return string
  */
 protected function getHead()
 {
     return \XLite\Core\Translation::getInstance()->translate('Customers who bought this product also bought');
 }
Example #30
0
 /**
  * Orders collect garbage
  *
  * @return void
  */
 public function collectGarbage()
 {
     // Remove old temporary orders
     $list = $this->findAllExpiredTemporaryOrders();
     if (count($list)) {
         foreach ($list as $order) {
             \XLite\Core\Database::getEM()->remove($order);
         }
         \XLite\Core\Database::getEM()->flush();
         // Log operation only in debug mode
         \XLite\Logger::getInstance()->log(\XLite\Core\Translation::getInstance()->translate('X expired shopping cart(s) have been successfully removed', array('count' => count($list))));
     }
 }