示例#1
0
 /**
  * @param mixed $value
  *
  * @throws InvalidLocaleException
  */
 protected function guard($value)
 {
     $localeName = Intl::getLocaleBundle()->getLocaleName($value);
     if (null === $localeName) {
         throw new InvalidLocaleException($value);
     }
 }
 /**
  * Constructor
  */
 public function __construct(ProfileService $profileService, DocumentManager $documentManager, TranslatorInterface $translator)
 {
     $this->dm = $documentManager;
     $this->languages = Intl::getLanguageBundle()->getLanguageNames();
     $this->profileService = $profileService;
     $this->translator = $translator;
 }
 public static function validateUPU_S10($track)
 {
     if (!preg_match("/^([A-Z]{2})(\\d{8})(\\d{1})([A-Z]{2})\$/", $track, $matches)) {
         return false;
     }
     list($track, $serviceIndicator, $serialNumber, $checkDigit, $countryCode) = $matches;
     // Check $serviceIndicator
     if (!preg_match("/([ELMRUVCHABDNPZ][A-Z])|(Q[A-M])|(G[AD])/", $serviceIndicator)) {
         return false;
     }
     // Check $checkDigit
     $serialNumberDigits = str_split($serialNumber);
     $weightFactors = array(8, 6, 4, 2, 3, 5, 9, 7);
     $weightedSum = array_reduce(range(0, 7), function ($sum, $i) use($serialNumberDigits, $weightFactors) {
         return $sum + $serialNumberDigits[$i] * $weightFactors[$i];
     });
     $res = 11 - $weightedSum % 11;
     $appropriateCheckDigit = $res >= 1 && $res <= 9 ? $res : ($res == 11 ? 5 : 0);
     if ($appropriateCheckDigit != $checkDigit) {
         return false;
     }
     // Check $countryCode
     $countryCodes = array_keys(Intl::getRegionBundle()->getCountryNames());
     if (!in_array($countryCode, $countryCodes)) {
         return false;
     }
     return true;
 }
 /**
  * Should be called before tests that require a feature-complete intl
  * implementation.
  *
  * @param \PhpUnit_Framework_TestCase $testCase
  */
 public static function requireFullIntl(\PhpUnit_Framework_TestCase $testCase)
 {
     // We only run tests if the intl extension is loaded...
     if (!Intl::isExtensionLoaded()) {
         $testCase->markTestSkipped('The intl extension is not available.');
     }
     // ... and only if the version is *one specific version* ...
     if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
         $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
     }
     // ... and only if the data in the Icu component matches that version.
     if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
         $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x');
     }
     // Normalize the default locale in case this is not done explicitly
     // in the test
     \Locale::setDefault('en');
     // Consequently, tests will
     //
     //   * run only for one ICU version (see Intl::getIcuStubVersion())
     //     there is no need to add control structures to your tests that
     //     change the test depending on the ICU version.
     //   * always use the C intl classes
     //   * always use the binary resource bundles (any locale is allowed)
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function loadChoiceList($value = null)
 {
     if (null !== $this->choiceList) {
         return $this->choiceList;
     }
     return $this->choiceList = new ArrayChoiceList(array_flip(Intl::getLanguageBundle()->getLanguageNames()), $value);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $textWriter = new TextBundleWriter();
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'en', ['data' => ['Ok']]);
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'ru', ['data' => ['Хорошо']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'en', ['data' => 'php bundle: Ok', 'nested' => ['message' => 'Hi!']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'ru', ['data' => 'php bundle: Хорошо', 'nested' => ['message' => 'Привет!']]);
     $compiler = new GenrbCompiler();
     $compiler->compile(CACHE_PATH . 'intl/text_bundle', CACHE_PATH . 'intl/compiled');
     $phpReader = new PhpBundleReader();
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'en');
     $output->writeln($data['data']);
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'ru');
     $output->writeln($data['data']);
     $reader = new BundleEntryReader($phpReader);
     $data = $reader->readEntry(CACHE_PATH . 'intl/php_bundle', 'ru', ['nested', 'message']);
     $output->writeln($data);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'en');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'de');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'ru');
     $output->writeln($language);
     $currencyName = Intl::getCurrencyBundle()->getCurrencyName('RUB', 'en');
     $output->writeln($currencyName);
     $currencyName = Intl::getCurrencyBundle()->getCurrencySymbol('USD', 'en');
     $output->writeln($currencyName);
     $output->writeln('<comment>Ok</comment>');
 }
 /**
  * Return the country name using the Locale class.
  *
  * @param string      $isoCode Country ISO 3166-1 alpha 2 code
  * @param null|string $locale  Locale code
  *
  * @return null|string Country name
  */
 public function getCountryName($isoCode, $locale = null)
 {
     if ($isoCode === null) {
         return;
     }
     return $locale === null ? Intl::getRegionBundle()->getCountryName($isoCode) : Intl::getRegionBundle()->getCountryName($isoCode, $locale);
 }
示例#8
0
 /**
  * @return string
  */
 public function getName($locale = null)
 {
     $enc = 'utf-8';
     $names = Intl::getLocaleBundle()->getLocaleNames($locale ?: $this->locale);
     $str = isset($names[$this->locale]) ? $names[$this->locale] : $this->locale;
     return mb_strtoupper(mb_substr($str, 0, 1, $enc), $enc) . mb_substr($str, 1, mb_strlen($str, $enc), $enc);
 }
示例#9
0
 public function getGlobals()
 {
     $locales = array('current' => null, 'other' => null);
     $enabledLocales = $this->localeRepository->findBy(array('isEnabled' => true));
     $otherLocales = $enabledLocales;
     if (count($enabledLocales)) {
         /** @var Locale $locale */
         foreach ($enabledLocales as $localeKey => $locale) {
             if ($this->currentLocale == $locale->getCode()) {
                 $locales['current'] = $locale;
                 unset($otherLocales[$localeKey]);
                 break;
             }
         }
     }
     if (!count($enabledLocales) || empty($locales['current'])) {
         $defaultLocaleCode = $this->container->getParameter('locale');
         $locale = new Locale();
         $locale->setCode($defaultLocaleCode);
         $locale->setTitle(Intl::getLocaleBundle()->getLocaleName($defaultLocaleCode, $defaultLocaleCode));
         $locales['current'] = $locale;
     }
     $locales['other'] = $otherLocales;
     return array('locales' => $locales);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (self::WIDGET_COUNTRY_CHOICE === $options['widget']) {
         $util = PhoneNumberUtil::getInstance();
         $countries = array();
         if (is_array($options['country_choices'])) {
             foreach ($options['country_choices'] as $country) {
                 $code = $util->getCountryCodeForRegion($country);
                 if ($code) {
                     $countries[$country] = $code;
                 }
             }
         }
         if (empty($countries)) {
             foreach ($util->getSupportedRegions() as $country) {
                 $countries[$country] = $util->getCountryCodeForRegion($country);
             }
         }
         $countryChoices = array();
         foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
             if (false === isset($countries[$region])) {
                 continue;
             }
             $countryChoices[$region] = sprintf('%s (+%s)', $name, $countries[$region]);
         }
         $countryOptions = $numberOptions = array('error_bubbling' => true, 'required' => $options['required'], 'disabled' => $options['disabled'], 'translation_domain' => $options['translation_domain']);
         $countryOptions['required'] = true;
         $countryOptions['choices'] = $countryChoices;
         $countryOptions['preferred_choices'] = $options['preferred_country_choices'];
         $countryOptions['choice_translation_domain'] = false;
         $builder->add('country', 'choice', $countryOptions)->add('number', 'text', $numberOptions)->addViewTransformer(new PhoneNumberToArrayTransformer(array_keys($countryChoices)));
     } else {
         $builder->addViewTransformer(new PhoneNumberToStringTransformer($options['default_region'], $options['format']));
     }
 }
示例#11
0
 /**
  * @param mixed $value
  *
  * @throws InvalidLanguageCodeException
  */
 protected function guard($value)
 {
     $languageName = Intl::getLanguageBundle()->getLanguageName($value);
     if (null === $languageName) {
         throw new InvalidLanguageCodeException($value);
     }
 }
示例#12
0
 /**
  * @param mixed  $country
  * @param string $locale
  *
  * @return string
  */
 public function translateCountryIsoCode($country, $locale = null)
 {
     if ($country instanceof CountryInterface) {
         return Intl::getRegionBundle()->getCountryName($country->getCode(), $locale);
     }
     return Intl::getRegionBundle()->getCountryName($country, $locale);
 }
示例#13
0
 public function testToString($value, $currencyCode, $expectedOutput)
 {
     if (Intl::isExtensionLoaded()) {
         \Locale::setDefault('en');
     }
     $this->if($price = new TestedPrice($value, $currencyCode))->string((string) $price)->isIdenticalTo($expectedOutput);
 }
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $intlBundle = Intl::getLanguageBundle();
     $builder->add('locale', ChoiceType::class, ['choices' => $options['lang_code'], 'choices_as_values' => true, 'choice_label' => function ($lang) use($intlBundle) {
         return $intlBundle->getLanguageName($lang);
     }]);
 }
示例#15
0
    /**
     * {@inheritdoc}
     */
    public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Country) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country');
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;
        $countries = Intl::getRegionBundle()->getCountryNames();

        if (!isset($countries[$value])) {
            if ($this->context instanceof ExecutionContextInterface) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Country::NO_SUCH_COUNTRY_ERROR)
                    ->addViolation();
            } else {
                $this->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Country::NO_SUCH_COUNTRY_ERROR)
                    ->addViolation();
            }
        }
    }
 public function __construct()
 {
     parent::__construct();
     $phpVersion = phpversion();
     $gdVersion = defined('GD_VERSION') ? GD_VERSION : null;
     $curlVersion = function_exists('curl_version') ? curl_version() : null;
     $icuVersion = Intl::getIcuVersion();
     $this->addOroRequirement(version_compare($phpVersion, self::REQUIRED_PHP_VERSION, '>='), sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $phpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Oro needs at least PHP "<strong>%s</strong>" to run.
             Before using Oro, upgrade your PHP installation, preferably to the latest version.', $phpVersion, self::REQUIRED_PHP_VERSION), sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $phpVersion));
     $this->addOroRequirement(null !== $gdVersion && version_compare($gdVersion, self::REQUIRED_GD_VERSION, '>='), 'GD extension must be at least ' . self::REQUIRED_GD_VERSION, 'Install and enable the <strong>GD</strong> extension at least ' . self::REQUIRED_GD_VERSION . ' version');
     $this->addOroRequirement(function_exists('mcrypt_encrypt'), 'mcrypt_encrypt() should be available', 'Install and enable the <strong>Mcrypt</strong> extension.');
     $this->addOroRequirement(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension.');
     $this->addOroRequirement(null !== $icuVersion && version_compare($icuVersion, self::REQUIRED_ICU_VERSION, '>='), 'icu library must be at least ' . self::REQUIRED_ICU_VERSION, 'Install and enable the <strong>icu</strong> library at least ' . self::REQUIRED_ICU_VERSION . ' version');
     $this->addRecommendation(class_exists('SoapClient'), 'SOAP extension should be installed (API calls)', 'Install and enable the <strong>SOAP</strong> extension.');
     $this->addRecommendation(null !== $curlVersion && version_compare($curlVersion['version'], self::REQUIRED_CURL_VERSION, '>='), 'cURL extension must be at least ' . self::REQUIRED_CURL_VERSION, 'Install and enable the <strong>cURL</strong> extension at least ' . self::REQUIRED_CURL_VERSION . ' version');
     // Windows specific checks
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('finfo_open'), 'finfo_open() should be available', 'Install and enable the <strong>Fileinfo</strong> extension.');
         $this->addRecommendation(class_exists('COM'), 'COM extension should be installed', 'Install and enable the <strong>COM</strong> extension.');
     }
     $baseDir = realpath(__DIR__ . '/..');
     $mem = $this->getBytes(ini_get('memory_limit'));
     $this->addPhpIniRequirement('memory_limit', function ($cfgValue) use($mem) {
         return $mem >= 256 * 1024 * 1024 || -1 == $mem;
     }, false, 'memory_limit should be at least 256M', 'Set the "<strong>memory_limit</strong>" setting in php.ini<a href="#phpini">*</a> to at least "256M".');
     $directories = array('web/bundles', 'app/cache', 'app/logs', 'app/archive', 'app/uploads/product');
     foreach ($directories as $directory) {
         $this->addOroRequirement(is_writable($baseDir . '/' . $directory), $directory . ' directory must be writable', 'Change the permissions of the "<strong>' . $directory . '</strong>" directory so that the web server can write into it.');
     }
 }
 public function indexAction(Request $request)
 {
     $searchForm = $this->createForm(new MainSearch());
     $searchForm->handleRequest($request);
     if ($searchForm->isValid()) {
         $userAgent = $request->headers->get('User-Agent');
         $clientIp = $request->getClientIp();
         $preferredLanguage = $request->getPreferredLanguage();
         $acceptedLanguages = $request->getLanguages();
         $languageName = Intl::getLanguageBundle()->getLanguageName($preferredLanguage);
         $data = $searchForm->getData();
         $searchRecord = new Searches();
         $searchRecord->setSearchDate(new DateTime());
         $searchRecord->setClientIpAddress($clientIp);
         $searchRecord->setAcceptedLanguages($acceptedLanguages);
         $searchRecord->setPreferredLanguage($languageName);
         $searchRecord->setUserAgent($userAgent);
         $searchRecord->setSearchText($data['search_element_text']);
         $searchRecord->setSerializedData($data);
         $em = $this->get('doctrine')->getManager();
         $em->persist($searchRecord);
         $em->flush();
         //redirect off to google
         $queryParams = array('q' => $data['search_element_text']);
         return $this->redirect(sprintf("%s#%s&tbs=qdr:y", self::GOOGLE_URL, http_build_query($queryParams)));
     } else {
         //get last 10 searches
         $lastTenSearches = $this->getDoctrine()->getRepository('YeargleCoreBundle:Searches')->getLastTenSearches();
         if (!$lastTenSearches) {
             //
             $lastTenSearches = array();
         }
         return $this->render('YeargleCoreBundle:Default:index.html.twig', array('searchForm' => $searchForm->createView(), 'lastTenSearches' => $lastTenSearches));
     }
 }
示例#18
0
 /**
  * @param mixed $value
  *
  * @throws InvalidCountryCodeException
  */
 protected function guard($value)
 {
     $countryName = Intl::getRegionBundle()->getCountryName($value);
     if (null === $countryName) {
         throw new InvalidCountryCodeException($value);
     }
 }
 /**
  * Display the name of a locale by its code, like English (United States) when you provide en_US
  *
  * @param string $code
  *
  * @return string
  */
 public function prettyLocaleName($code)
 {
     if (empty($code)) {
         return '';
     }
     return Intl::getLocaleBundle()->getLocaleName($code);
 }
示例#20
0
 /**
  * @param string $value
  *
  * @throws InvalidCurrencyException
  */
 protected function guard($value)
 {
     $currency = Intl::getCurrencyBundle()->getCurrencyName($value);
     if (null === $currency) {
         throw new InvalidCurrencyException($value);
     }
 }
示例#21
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array(
         'choices' => Intl::getCurrencyBundle()->getCurrencyNames(),
         'choice_translation_domain' => false,
     ));
 }
示例#22
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $countries = Intl::getRegionBundle()->getCountryNames();
     // add your custom field
     $builder->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', 'repeated', array('type' => 'password', 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password'), 'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'))->add('lastname', 'text')->add('firstname', 'text')->add('image', new AetImageType())->add('pays', 'country', array('expanded' => false, 'multiple' => false))->add('matricule', 'text')->add('whoami', 'textarea', array('required' => false))->add('ville', 'text')->add('code_postale', 'text')->add('telephone', 'text')->add('activite_principale', 'choice', array('choices' => array('Art, Design' => 'Art, Design', 'Audiovisuel - Spectacle' => 'Audiovisuel - Spectacle', 'Audit, gestion' => 'Audit, gestion', 'Automobile' => 'Automobile', 'Banque, assurance' => 'Banque, assurance', 'Bois (filière)' => 'Bois (filière)', 'BTP, architecture' => 'BTP, architecture', 'Chimie, pharmacie' => 'Chimie, pharmacie', 'Commerce, distribution' => 'Commerce, distribution', 'Communication - Marketing, publicité' => 'Communication - Marketing, publicité', 'Construction aéronautique, ferroviaire et navale' => 'Construction aéronautique, ferroviaire et navale', 'Culture - Artisanat d\'art' => 'Culture - Artisanat d\'art', 'Droit, justice' => 'Droit, justice', 'Edition, Journalisme' => 'Edition, Journalisme', 'Électronique' => 'Électronique', 'Énergie' => 'Énergie', 'Enseignement' => 'Enseignement', 'Environnement' => 'Environnement', 'Fonction publique' => 'Fonction publique', 'Hôtellerie, restauration' => 'Hôtellerie, restauration', 'Industrie alimentaire' => 'Industrie alimentaire', 'Informatique, internet et télécom' => 'Informatique, internet et télécom', 'Logistique, transport' => 'Logistique, transport', 'Maintenance, entretien' => 'Maintenance, entretien', 'Mécanique' => 'Mécanique', 'Mode et industrie textile' => 'Mode et industrie textile', 'Recherche' => 'Recherche', 'Santé' => 'Santé', 'Social' => 'Social', 'Sport, loisirs – Tourisme' => 'Sport, loisirs – Tourisme', 'Traduction - interprétariat' => 'Traduction - interprétariat'), 'required' => false, 'mapped' => true))->add('promotion', 'birthday', array('widget' => 'choice', 'years' => range(date('Y') - 110, date('Y')), 'empty_value' => array('year' => '----')));
 }
示例#23
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $countryRepository = $this->getCountryRepository();
     $countries = Intl::getRegionBundle()->getCountryNames($this->defaultLocale);
     if (Intl::isExtensionLoaded()) {
         $localisedCountries = array('es_ES' => Intl::getRegionBundle()->getCountryNames('es_ES'));
     } else {
         $localisedCountries = array();
     }
     foreach ($countries as $isoName => $name) {
         $country = $countryRepository->createNew();
         $country->setCurrentLocale($this->defaultLocale);
         $country->setName($name);
         foreach ($localisedCountries as $locale => $translatedCountries) {
             $country->setCurrentLocale($locale);
             $country->setName($translatedCountries[$isoName]);
         }
         $country->setIsoName($isoName);
         if ('US' === $isoName) {
             $this->addUsStates($country);
         }
         $manager->persist($country);
         $this->setReference('Sylius.Country.' . $isoName, $country);
     }
     $manager->flush();
 }
示例#24
0
文件: Add.php 项目: forkcms/forkcms
 /**
  * Load the form
  */
 private function loadForm()
 {
     // gender dropdown values
     $genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female')));
     // birthdate dropdown values
     $days = range(1, 31);
     $months = \SpoonLocale::getMonths(BL::getInterfaceLanguage());
     $years = range(date('Y'), 1900);
     // create form
     $this->frm = new BackendForm('add');
     // create elements
     $this->frm->addText('email')->setAttribute('type', 'email');
     $this->frm->addPassword('password');
     $this->frm->addText('display_name');
     $this->frm->addText('first_name');
     $this->frm->addText('last_name');
     $this->frm->addText('city');
     $this->frm->addDropdown('gender', $genderValues);
     $this->frm->addDropdown('day', array_combine($days, $days));
     $this->frm->addDropdown('month', $months);
     $this->frm->addDropdown('year', array_combine($years, $years));
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()));
     // set default elements dropdowns
     $this->frm->getField('gender')->setDefaultElement('');
     $this->frm->getField('day')->setDefaultElement('');
     $this->frm->getField('month')->setDefaultElement('');
     $this->frm->getField('year')->setDefaultElement('');
     $this->frm->getField('country')->setDefaultElement('');
 }
示例#25
0
 private function getLanguageName($locale = null)
 {
     if (!$locale) {
         $locale = $this->getCurrentLocale();
     }
     return Intl::getLanguageBundle()->getLanguageName($locale, null, $this->getCurrentLocale());
 }
示例#26
0
 /**
  * Load the form
  */
 protected function loadForm()
 {
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $this->frm = new BackendForm('edit');
     $this->frm->addText('company', $this->record['company']);
     $this->frm->addText('name', $this->record['name']);
     $this->frm->addText('firstname', $this->record['firstname']);
     $this->frm->addText('email', $this->record['email']);
     $this->frm->addText('address', $this->record['address']);
     $this->frm->addText('zipcode', $this->record['zipcode']);
     $this->frm->addText('city', $this->record['city']);
     //        $this->frm->addText('country', $this->record['country']);
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), $this->record['country']);
     $this->frm->addText('phone', $this->record['phone']);
     $this->frm->addText('fax', $this->record['fax']);
     $this->frm->addText('website', $this->record['website']);
     $this->frm->addText('vat', $this->record['vat']);
     $this->frm->addTextArea('zipcodes', $this->record['zipcodes']);
     $this->frm->addText('remark', $this->record['remark']);
     //$this->frm->addText('assort', $this->record['assort']);
     //$this->frm->addText('open', $this->record['open']);
     //$this->frm->addText('closed', $this->record['closed']);
     //$this->frm->addText('visit', $this->record['visit']);
     //$this->frm->addText('size', $this->record['size']);
     //$this->frm->addEditor('text', $this->record['text']);
     $this->frm->addImage('image');
     $this->frm->addCheckbox('delete_image');
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
         $addressesLanguage = BackendAddressesModel::getLanguage($this->id, $language);
         $fieldText = $this->frm->addEditor("text_" . strtolower($language), $addressesLanguage['text']);
         $fieldOpeningHours = $this->frm->addEditor("opening_hours_" . strtolower($language), $addressesLanguage['opening_hours']);
         $this->fieldLanguages[$key]["key"] = $key;
         $this->fieldLanguages[$key]["language"] = $language;
         $this->fieldLanguages[$key]["text"] = $fieldText->parse();
         $this->fieldLanguages[$key]["opening_hours"] = $fieldOpeningHours->parse();
     }
     //--Get all the groups
     $groups = BackendAddressesModel::getAllGroups();
     if (!empty($groups)) {
         //--Loop all the users
         foreach ($groups as &$group) {
             $groupCheckboxes[] = array("label" => $group["title"], "value" => $group["id"]);
         }
         //--Get the users from the group
         $groupsAddress = BackendAddressesModel::getGroupsForAddress($this->id);
         //--Create a selected-array
         $groupCheckboxesSelected = count($groupsAddress) > 0 ? array_keys($groupsAddress) : null;
         //--Add multicheckboxes to form
         $this->frm->addMultiCheckbox("groups", $groupCheckboxes, $groupCheckboxesSelected);
     }
     $groups2 = BackendAddressesModel::getAllGroupsTreeArray();
     $this->tpl->assign('groups2', $groups2);
     $this->tpl->assign('groups2selected', $groupCheckboxesSelected == null ? array() : $groupCheckboxesSelected);
     // meta
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'company', true);
     $this->meta->setUrlCallback('Backend\\Modules\\Addresses\\Engine\\Model', 'getUrl', array($this->record['id']));
 }
示例#27
0
 public function getCurrencySymbol($currency = null)
 {
     $currency = $currency ?: $this->helper->getSettingsParameter($this->generalCurrencyKey);
     if (array_key_exists($currency, $this->currencySymbols)) {
         return $this->currencySymbols[$currency];
     }
     return SymfonyIntl::getCurrencyBundle()->getCurrencySymbol($currency);
 }
示例#28
0
 /**
  * @return array
  */
 public function getLocales()
 {
     $localeCodes = explode('|', $this->locales);
     foreach ($localeCodes as $localeCode) {
         $locales[] = array('code' => $localeCode, 'name' => Intl::getLocaleBundle()->getLocaleName($localeCode, $localeCode));
     }
     return $locales;
 }
 /**
  * Returns template for event detail
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function eventDetailAction()
 {
     $countries = array();
     foreach (Intl::getRegionBundle()->getCountryNames() as $alpha2 => $country) {
         $countries[] = array('id' => $alpha2, 'name' => $country);
     }
     return $this->render('SuluEventBundle:Event:detail.html.twig', array('countries' => $countries));
 }
示例#30
0
 /**
  * @return array
  */
 public function getSettings()
 {
     $settings = $this->getYamlParameters();
     $currency = new Setting();
     $currency->setKey('currency')->setValue($settings['currency'])->setType('select2')->setOptions(Intl::getCurrencyBundle()->getCurrencyNames($settings['locale']));
     $emailSettings = $this->getEmailSettings($settings);
     return ['system' => ['general' => ['currency' => $currency]], 'email' => ['sending_options' => $emailSettings]];
 }