コード例 #1
0
ファイル: Begin.php プロジェクト: kewaunited/xcart
 /**
  * Check - charset enabledor not
  * 
  * @return boolean
  */
 protected function isCharsetEnabled()
 {
     return \XLite\Core\Iconv::getInstance()->isValid();
 }
コード例 #2
0
ファイル: Importer.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Initialize
  *
  * @return void
  */
 protected function initialize()
 {
     $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->getOptions()->dir);
     // Unpack
     foreach ($this->getOptions()->files as $path) {
         if (\XLite\Core\Archive::getInstance()->isArchive($path)) {
             \XLite\Core\Archive::getInstance()->unpack($path, $dir, true);
             $this->getOptions()->linkedFiles[$path] = \XLite\Core\Archive::getInstance()->getList($path);
         }
     }
     // Delete all logs
     \XLite\Core\Database::getRepo('XLite\\Model\\ImportLog')->clearAll();
     // Convert charsets
     if (static::DEFAULT_CHARSET != $this->getOptions()->charset) {
         $iconv = \XLite\Core\Iconv::getInstance();
         foreach ($this->getCSVList() as $file) {
             $iconv->convertFile($this->getOptions()->charset, static::DEFAULT_CHARSET, $file->getPathname());
         }
     }
     // Preprocess import data
     if ($this->preprocessImport()) {
         // Save import options if they were changed
         $record = \XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->getEventState('import');
         $record['state'] = \XLite\Core\EventTask::STATE_IN_PROGRESS;
         $record['options'] = $this->getOptions()->getArrayCopy();
         \XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->setEventState('import', $record);
     }
 }
コード例 #3
0
ファイル: AStep.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Convert charset
  *
  * @param array $row Row
  *
  * @return array
  */
 protected function convertCharset(array $row)
 {
     if (static::DEFAULT_CHARSET != $this->generator->getOptions()->charset && \XLite\Core\Iconv::getInstance()->isValid()) {
         $iconv = \XLite\Core\Iconv::getInstance();
         foreach ($row as $k => $v) {
             $row[$k] = $iconv->convert(static::DEFAULT_CHARSET, $this->generator->getOptions()->charset, $v);
         }
     }
     return $row;
 }
コード例 #4
0
ファイル: Converter.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Get strftime() with specified format and timestamp value
  *
  * @param string  $format Format string
  * @param integer $base   UNIX time stamp OPTIONAL
  *
  * @return string
  */
 protected static function getStrftime($format, $base = null)
 {
     static::setLocaleToUTF8();
     $win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
     if ($win) {
         $format = str_replace('%e', '%#d', $format);
     }
     $date = null !== $base ? strftime($format, $base) : strftime($format);
     if ($win) {
         $locale = setlocale(LC_TIME, 0);
         if (preg_match('/(([^_]+)_?([^.]*))\\.?(.*)?/', $locale, $match) && preg_match('/^.+_.+\\.(\\d+)$/', $match[0], $match) && \XLite\Core\Iconv::getInstance()->isValid()) {
             $date = \XLite\Core\Iconv::getInstance()->convert('WINDOWS-' . $match[1], 'UTF-8', $date) ?: $date;
         } elseif (!empty(static::$charsetsTable[$locale])) {
             $date = \XLite\Core\Iconv::getInstance()->convert(static::$charsetsTable[$locale], 'UTF-8', $date) ?: $date;
         }
     }
     return $date;
 }
コード例 #5
0
ファイル: IconvCharset.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Get default options
  *
  * @return array
  */
 protected function getDefaultOptions()
 {
     return \XLite\Core\Iconv::getInstance()->getCharsets();
 }