php XLite-Core-Translation类(方法)实例源码

下面列出了php XLite-Core-Translation 类(方法)源码代码实例,从而了解它的用法。

作者:ChessMes    项目:heartland-x-cart5-plugi   
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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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)));
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:hp    项目:heartland-x-cart5-plugi   
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;
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * Get field label
  *
  * @return string
  */
 public function getLabel()
 {
     return \XLite\Core\Translation::lbl('Authorize amount for card setup');
 }

作者:kings    项目:cor   
/**
  * 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'));
 }

作者:kings    项目:cor   
/**
  * 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;
 }

作者:kings    项目:cor   
/**
  * 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');
     }
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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;
 }

作者:kirkbauer    项目:kirkx   
/**
  * 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'));
 }


问题


面经


文章

微信
公众号

扫码关注公众号