コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if (null !== $options['ip_lookup_service'] && $options['ip_lookup_service'] instanceof AbstractLocalDataLookup) {
         $localFilePath = $options['ip_lookup_service']->getLocalDataStoreFilepath();
         $localDataExists = file_exists($localFilePath);
         if ($localDataExists && ($lastModifiedTimestamp = filemtime($localFilePath))) {
             $lastModified = $this->dateHelper->toText($lastModifiedTimestamp, 'UTC', 'U');
             $view->vars['ipDataStoreLastDownloaded'] = $this->translator->trans('mautic.core.ip_lookup.last_updated', ['%date%' => $lastModified]);
         }
     }
 }
コード例 #2
0
ファイル: FormatterHelper.php プロジェクト: dongilbert/mautic
 /**
  * Format a string.
  *
  * @param $val
  * @param $type
  */
 public function _($val, $type, $textOnly = false, $round = 1)
 {
     if (empty($val)) {
         return $val;
     }
     switch ($type) {
         case 'array':
             if (!is_array($val)) {
                 //assume that it's serialized
                 $unserialized = unserialize($val);
                 if ($unserialized) {
                     $val = $unserialized;
                 }
             }
             $stringParts = [];
             foreach ($val as $k => $v) {
                 if (is_array($v)) {
                     $stringParts = $this->_($v, 'array', $textOnly, $round + 1);
                 } else {
                     $stringParts[] = $v;
                 }
             }
             if ($round === 1) {
                 $string = implode('; ', $stringParts);
             } else {
                 $string = implode(', ', $stringParts);
             }
             break;
         case 'datetime':
             $string = $this->dateHelper->toFull($val, 'utc');
             break;
         case 'time':
             $string = $this->dateHelper->toTime($val, 'utc');
             break;
         case 'date':
             $string = $this->dateHelper->toDate($val, 'utc');
             break;
         case 'url':
             $string = $textOnly ? $val : '<a href="' . $val . '" target="_new">' . $val . '</a>';
             break;
         case 'email':
             $string = $textOnly ? $val : '<a href="mailto:' . $val . '">' . $val . '</a>';
             break;
         case 'int':
             $string = (int) $val;
             break;
         default:
             $string = InputHelper::clean($val);
             break;
     }
     return $string;
 }